summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2024-03-11 01:34:22 -0500
committerzachir <zachir@librem.one>2024-03-11 01:34:22 -0500
commit2b135d87f5c1f1f307984f5fd78e151f5ee99dae (patch)
tree6e9e089326ea40badd6dab25a3ed5a7cef61dcbd /main.c
parent42b5d719a0207a56b482a4e0298d72b628b93fa0 (diff)
Replace build system with zig
Zig is actually handling the building and such, now the Makefile is here just as a wrapper for it.
Diffstat (limited to 'main.c')
-rw-r--r--main.c76
1 files changed, 0 insertions, 76 deletions
diff --git a/main.c b/main.c
deleted file mode 100644
index d986924..0000000
--- a/main.c
+++ /dev/null
@@ -1,76 +0,0 @@
-#include "./main.h"
-
-void printhelp() {
- fprintf(stderr, "even: a binary by ZachIR to check if a number is even or ");
- fprintf(stderr, "odd.\n");
- fprintf(stderr, "even [-hcv]\n");
- fprintf(stderr, "even [--help]\n");
- fprintf(stderr, "even [--copyright]\n");
- fprintf(stderr, "even [--version]\n");
- fprintf(stderr, "even [-q] [--quiet] NUMBER\n");
- fprintf(stderr, "\t-h: prints this help message\n");
- fprintf(stderr, "\t-c: prints the copyright information\n");
- fprintf(stderr, "\t-v: prints the version\n");
- fprintf(stderr, "\t-q: just uses error codes, no text\n");
- return;
-}
-
-void printcopyright() {
- fprintf(stderr, "Copyright (c) 2024 Zachary Smith\n");
- fprintf(stderr, "even is Free software under the MIT license, and is ");
- fprintf(stderr, "provided without warranty of any kind.\n");
- return;
-}
-
-void printversion() {
- fprintf(stderr, "even version %s, 2024\n", VERSION);
- return;
-}
-
-int main(int argc, char **argv) {
- bool quiet;
- bool value;
- long result;
-
- quiet = false;
- value = false;
- result = 0;
- char *output;
-
- if (argc > 1) {
- for (size_t i = 1; i < argc; i++) {
- if (argv[i][0] == '-') {
- switch (argv[i][1]) {
- case 'h':
- printhelp();
- return SUCCESS;
- case 'c':
- printcopyright();
- return SUCCESS;
- case 'v':
- printversion();
- return SUCCESS;
- case 'q':
- quiet = true;
- break;
- }
- }
- result = strtol(argv[i], &output, 10);
- value = true;
- }
- }
- if (value) {
- if (result % 2 == 0) {
- if (quiet) {
- fprintf(stdout, "even\n");
- }
- return 0;
- } else {
- if (quiet) {
- fprintf(stdout, "odd\n");
- }
- return 1;
- }
- }
- return ERR;
-}