Skip to content

Commit

Permalink
Decrust pass
Browse files Browse the repository at this point in the history
  • Loading branch information
PQCraft authored Jul 22, 2023
1 parent 6573705 commit 96cdcb4
Showing 1 changed file with 17 additions and 38 deletions.
55 changes: 17 additions & 38 deletions interjection.c
Original file line number Diff line number Diff line change
@@ -1,59 +1,38 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>

char VER[] = "1.2";
char VER[] = "1.3";

char* GNU = NULL;
char* Linux = NULL;

void cleanExit(int err) {
fflush(stdout);
if (GNU != NULL) free(GNU);
if (Linux != NULL) free(Linux);
exit(err);
}
char* GNU = "GNU";
char* Linux = "Linux";

int main(int argc, char *argv[]) {
signal(SIGINT, cleanExit);
for (int i = 1; i < argc; i++) {
for (int i = 1; i < argc; ++i) {
if (!strcmp(argv[i], "--version")) {
if (argc > 2) {fprintf(stderr, "Incorrent number of options passed.\n"); cleanExit(1);}
printf("Stallman Interjection Text Generator %s\n", VER);
printf("Copyright (C) 2021 PQCraft\n");
cleanExit(0);
} else
if (!strcmp(argv[i], "--help")) {
if (argc > 2) {fprintf(stderr, "Incorrent number of options passed.\n"); cleanExit(1);}
return 0;
} else if (!strcmp(argv[i], "--help")) {
printf("Usage: interject [options]\n");
printf("Options:\n");
printf(" --help Shows the help screen.\n");
printf(" --version Shows the version info.\n");
printf(" --gnu <text> Changes all occurrences of 'GNU' to <text>.\n");
printf(" --linux <text> Changes all occurrences of 'Linux' to <text>.\n");
cleanExit(0);
} else
if (!strcmp(argv[i], "--gnu")) {
if (GNU != NULL) {fprintf(stderr, "Cannot define 'GNU' more than once.\n"); cleanExit(1);}
i++;
if (i > argc - 1) {fprintf(stderr, "No value specified for 'GNU'.\n"); cleanExit(1);}
GNU = (char *)malloc(strlen(argv[i]) + 1);
strcpy(GNU, argv[i]);
} else
if (!strcmp(argv[i], "--linux")) {
if (Linux != NULL) {fprintf(stderr, "Cannot define 'Linux' more than once.\n"); cleanExit(1);}
i++;
if (i > argc - 1) {fprintf(stderr, "No value specified for 'Linux'.\n"); cleanExit(1);}
Linux = (char *)malloc(strlen(argv[i]) + 1);
strcpy(Linux, argv[i]);
return 0;
} else if (!strcmp(argv[i], "--gnu")) {
if (i > argc) {fprintf(stderr, "No value specified for 'GNU'.\n"); return 1;}
++i;
GNU = argv[i];
} else if (!strcmp(argv[i], "--linux")) {
if (i > argc) {fprintf(stderr, "No value specified for 'Linux'.\n"); return 1;}
++i;
Linux = argv[i];
} else {
fprintf(stderr, "Invalid option: %s\n", argv[i]);
cleanExit(1);
return 1;
}
}
if (GNU == NULL) {GNU = malloc(4); strcpy(GNU, "GNU");}
if (Linux == NULL) {Linux = malloc(6); strcpy(Linux, "Linux");}
printf(
"I'd just like to interject for a moment.\n"
"What you're referring to as %s, is in fact, %s/%s, or as I've recently taken to calling it, %s plus %s.\n"
Expand All @@ -74,5 +53,5 @@ int main(int argc, char *argv[]) {
Linux, GNU, GNU, Linux, GNU, Linux,
Linux, GNU, Linux
);
cleanExit(0);
return 0;
}

0 comments on commit 96cdcb4

Please sign in to comment.