diff options
| author | la-ninpre <leobrekalini@gmail.com> | 2021-11-20 19:00:28 +0000 |
|---|---|---|
| committer | la-ninpre <leobrekalini@gmail.com> | 2021-11-20 19:00:28 +0000 |
| commit | a09dfac1ad042d49ced01d79866878b6ce0a4045 (patch) | |
| tree | 26a59e5f1c6f5ac0ee18ae8b825d27131ce36585 /main.c | |
| parent | 6cf69cbaacfa8c509cbe541a26dfa119d68845b9 (diff) | |
| download | nimisewi_c-main.tar.gz nimisewi_c-main.zip | |
added new flag to main program, that displays sad version of prompt
removed unnecessary function that sets up random seed for systems where
arc4random is not available
updated readme
FossilOrigin-Name: 1195601f8a81524006e8d3c9014abb26cf613ad995b60455d9553fd7bb50d337
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 90 |
1 files changed, 69 insertions, 21 deletions
@@ -29,38 +29,86 @@ #include "nimisewi.h" -int -main(int argc, char *argv[]) +#define NIMISEWI_MAMA 0x01 +#define NIMISEWI_IKE 0x02 + +static void +pana_sona_pali(void) { - char *ns; + printf("nimisewi [-v|-i]\n"); + exit(EXIT_SUCCESS); +} +static void +pana_sona_mama(void) +{ + printf("%s\n", PACKAGE_STRING); + printf("%s\n", PACKAGE_DESCRIPTION); + printf("compiled on %s %s using %s (%ld-bit)\n", + __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8); #ifdef HAVE_PLEDGE - if (pledge("stdio", NULL) == -1) { - err(EXIT_FAILURE, "pledge"); - } -#endif - if (argc == 2) { - if (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")) { - printf("%s\n", PACKAGE_STRING); - printf("%s\n", PACKAGE_DESCRIPTION); - printf("compiled on %s %s using %s (%lu-bit)\n", - __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8); -#ifdef HAVE_PLEDGE - printf("HAVE_PLEDGE\n"); + printf("HAVE_PLEDGE\n"); #endif #ifdef HAVE_STRLCAT - printf("HAVE_STRLCAT\n"); + printf("HAVE_STRLCAT\n"); #endif #ifdef HAVE_ARC4RANDOM_UNIFORM - printf("HAVE_ARC4RANDOM_UNIFORM\n"); + printf("HAVE_ARC4RANDOM_UNIFORM\n"); #endif - return EXIT_SUCCESS; - } - } + /*return EXIT_SUCCESS;*/ +} - ns = nimi_sewi(); +static void +nimisewi_pona(void) +{ + char *ns; + ns = nimi_sewi(6); printf("%s\n", ns); weka_e_nimi_sewi(ns); +} + +static void +nimisewi_pi_pilin_ike(void) +{ + char *ns; + ns = nimi_sewi(3); + printf("%s mute li lon\n" + "tan pi %s sin li seme?\n", ns, ns); + weka_e_nimi_sewi(ns); +} + +int +main(int argc, char *argv[]) +{ + int ch, f; +#ifdef HAVE_PLEDGE + if (pledge("stdio", NULL) == -1) { + err(EXIT_FAILURE, "pledge"); + } +#endif + f = 0; + while ((ch = getopt(argc, argv, "vi")) != -1) { + switch (ch) { + case 'v': + f |= NIMISEWI_MAMA; + break; + case 'i': + f |= NIMISEWI_IKE; + break; + default: + pana_sona_pali(); + } + } + argc -= optind; + argv += optind; + + if (f & NIMISEWI_MAMA) + pana_sona_mama(); + + if (f & NIMISEWI_IKE) + nimisewi_pi_pilin_ike(); + else + nimisewi_pona(); return EXIT_SUCCESS; } |
