all repos — nimisewi_c @ b9307275555b201aecaca213003e14da142909bf

simple random toki pona phrase generator

main.c (view raw)

 1/* Copyright (c) 2021, la-ninpre
 2 * 
 3 * Permission to use, copy, modify, and/or distribute this software for any
 4 * purpose with or without fee is hereby granted, provided that the above
 5 * copyright notice and this permission notice appear in all copies.
 6 * 
 7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 *
15 * **********************************************************************
16 *
17 * this file contains main code for nimisewi as commandline utility
18 * that throws it's phrases to stdout.
19 *
20 * should be obvious :)
21 */
22
23#include <config.h>
24#include <err.h>
25#include <stdio.h>
26#include <stdlib.h>
27#include <unistd.h>
28#include <string.h>
29
30#include "nimisewi.h"
31
32int
33main(int argc, char *argv[])
34{
35    char *ns;
36
37#ifdef HAVE_PLEDGE
38    if (pledge("stdio", NULL) == -1) {
39        err(EXIT_FAILURE, "pledge");
40    }
41#endif
42    if (argc == 2) {
43        if (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")) {
44            printf("%s\n", PACKAGE_STRING);
45            printf("%s\n", PACKAGE_DESCRIPTION);
46            printf("compiled on %s %s using %s (%lu-bit)\n",
47                    __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8);
48#ifdef HAVE_PLEDGE
49            printf("HAVE_PLEDGE\n");
50#endif
51#ifdef HAVE_STRLCAT
52            printf("HAVE_STRLCAT\n");
53#endif
54#ifdef HAVE_ARC4RANDOM_UNIFORM
55            printf("HAVE_ARC4RANDOM_UNIFORM\n");
56#endif
57            return EXIT_SUCCESS;
58        }
59    }
60
61    ns = nimi_sewi();
62    printf("%s\n", ns);
63    weka_e_nimi_sewi(ns);
64
65    return EXIT_SUCCESS;
66}
67