Edit README
[sigilutils.git] / sigutils.c
blobaa4d99c399ada812b0699055c257ff0b7f516436
2 #include "basics.h"
3 #include "numbers.h"
4 #include "squares.h"
5 #include <unistd.h>
7 #define VERSION 0.01
9 char name[] = "Sigil Utilities, version";
10 char contact[] = "(C) 2020 theblaqcksquid <theblacksquid@subvertising.org>\n";
11 char license[] = "Licensed under GNU GPL v3\n";
13 char help0[] = "usage: sigutils [options] <STATEMENT OF INTENT>\n";
14 char help1[] = "-h Print this message and quit.\n";
15 char help2[] = "-v Print the version and license info, then quit.\n";
16 char help3[] = "-n Append the numerical and root values to the result.\n";
17 char help4[] = "-w Generate a Word Square based on the SOI\n";
18 char help5[] = "-W Generate word square ONLY.\n";
20 int main(int argc, char** argv)
22 int numeric_flag = 0;
23 int version_flag = 0;
24 int help_flag = 0;
25 int word_flag = 0;
26 int word_only_flag = 0;
27 int c;
29 while ((c = getopt(argc, argv, "nvhwW")) != -1)
30 switch (c)
32 case 'n': numeric_flag = 1;
33 break;
35 case 'v': version_flag = 1;
36 break;
38 case 'h': help_flag = 1;
39 break;
41 case 'w': word_flag = 1;
42 break;
44 case 'W': word_only_flag = 1;
45 break;
48 if (version_flag)
50 printf("%s %.2f\n%s%s", name, VERSION, contact, license);
51 return 0;
54 else if (help_flag)
56 printf("%s%s%s%s%s%s", help0, help1, help2, help3, help4, help5);
57 return 0;
60 char* raw = absorb_words(argc, argv, optind);
61 char* result = string_process(raw);
63 if (!word_only_flag)
64 printf("%s", result);
66 if (numeric_flag)
68 int value = string_value(result, LETTERS);
69 int root = digital_root(value, 10);
70 printf(" %d %d", value, root);
73 if (word_flag || word_only_flag)
75 printf("%s", generate_square(result));
78 printf("\n");
80 free(result);
81 free(raw);
82 return 0;