mistress
aq.c
1/*
2 * a utility for playing with alphanumeric qabbala (larp larp larp sahur)
3 * public domain
4 */
5
6#include <stdio.h>
7#include <stdlib.h>
8#include <string.h>
9#include <unistd.h>
10
11#include "libaq.h"
12
13static char *progname;
14
15static int
16aq_sum(const char *s)
17{
18 int r = 0;
19
20 while (*s != '\0') {
21 r += aq_value(*s++);
22 }
23
24 return r;
25}
26
27int
28main(int argc, char **argv)
29{
30 int i;
31
32 progname = strrchr(argv[0], '/');
33 progname = (progname == NULL) ? argv[0] : progname + 1;
34
35 if (argc < 2) {
36 fprintf(stderr, "usage: %s arg ...\n", progname);
37 exit(EXIT_FAILURE);
38 }
39
40 for (i = 1; i < argc; i++) {
41 printf("%s\t%d\n", argv[i], aq_sum(argv[i]));
42 }
43
44 return EXIT_SUCCESS;
45}