From: Armaan Bhojwani Date: Mon, 5 Jul 2021 17:06:01 +0000 (-0400) Subject: *.c: run clang-format X-Git-Url: https://git.armaanb.net/?p=bin.git;a=commitdiff_plain;h=da66e111f8c4d4aabdd3378d512a1b7142cc1b49 *.c: run clang-format --- diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..3577d9d --- /dev/null +++ b/.clang-format @@ -0,0 +1,3 @@ +BasedOnStyle: llvm +AlwaysBreakAfterReturnType: AllDefinitions +IndentWidth: 4 \ No newline at end of file diff --git a/crontab-argh.c b/crontab-argh.c index 3fc7e3e..5c40756 100644 --- a/crontab-argh.c +++ b/crontab-argh.c @@ -1,29 +1,34 @@ /* Stops you from accidentally running crontab -r. alias this to crontab. - Alternatively, if you are on a GNU system, you can just alias "crontab -r" to - "crontab -ri", but this isn't POSIX. */ + Alternatively, if you are on a GNU system, you can just alias "crontab + -r" to "crontab -ri", but this isn't POSIX. */ #include #include #include -int main(int argc, char *argv[]) { - char arg[255] = "crontab "; +int +main(int argc, char *argv[]) { + char arg[255] = "crontab "; - for (int i = 1; i < argc; i++) { - strcat(arg, strcat(argv[i], " ")); - } + for (int i = 1; i < argc; i++) { + strcat(arg, strcat(argv[i], " ")); + } - if (strstr(arg, "-r") != NULL) { - printf("%s", "Delete user's crontab? [yes/no]: "); - char inp[255]; - int ret; - while (1) { - ret = scanf("%s", inp); - if (ret == EOF) continue; - else if (strcmp(inp, "no") == 0) exit(0); - else if (strcmp(inp, "yes") == 0) break; - else printf("%s", "Please answer yes or no. [yes/no]: "); - } - } - system(arg); + if (strstr(arg, "-r") != NULL) { + printf("%s", "Delete user's crontab? [yes/no]: "); + char inp[255]; + int ret; + while (1) { + ret = scanf("%s", inp); + if (ret == EOF) + continue; + else if (strcmp(inp, "no") == 0) + exit(0); + else if (strcmp(inp, "yes") == 0) + break; + else + printf("%s", "Please answer yes or no. [yes/no]: "); + } + } + system(arg); } diff --git a/fortune-cgi.c b/fortune-cgi.c index 63693d7..d0ec3b7 100644 --- a/fortune-cgi.c +++ b/fortune-cgi.c @@ -1,36 +1,35 @@ // CGI program to get fortunes. Powers https://fortune.armaanb.net. -#include #include #include +#include int -main(void) -{ - const char *path = getenv("PATH_INFO"); - FILE *fp; - char buf[255]; +main(void) { + const char *path = getenv("PATH_INFO"); + FILE *fp; + char buf[255]; - if (strcmp(path, "/latin-cowsay") == 0) { - fp = popen("phrases | cowsay", "r"); - } else if (strcmp(path, "/cowsay") == 0) { - fp = popen("fortune | cowsay", "r"); - } else if (strcmp(path, "/latin") == 0) { - fp = popen("phrases", "r"); - } else if (strcmp(path, "/") == 0) { - fp = popen("fortune", "r"); - } else { - printf("Status: 404" - "Content-type: text/plain\n\n" - "Page not found. Try /, /cowsay, /latin, or /latin-cowsay\n"); - return 0; - } + if (strcmp(path, "/latin-cowsay") == 0) { + fp = popen("phrases | cowsay", "r"); + } else if (strcmp(path, "/cowsay") == 0) { + fp = popen("fortune | cowsay", "r"); + } else if (strcmp(path, "/latin") == 0) { + fp = popen("phrases", "r"); + } else if (strcmp(path, "/") == 0) { + fp = popen("fortune", "r"); + } else { + printf("Status: 404" + "Content-type: text/plain\n\n" + "Page not found. Try /, /cowsay, /latin, or /latin-cowsay\n"); + return 0; + } - printf("Content-type: text/plain\n\n"); - while (fgets(buf, sizeof(buf), fp) != NULL) { - printf("%s", buf); - } - pclose(fp); + printf("Content-type: text/plain\n\n"); + while (fgets(buf, sizeof(buf), fp) != NULL) { + printf("%s", buf); + } + pclose(fp); - return 0; + return 0; } diff --git a/morse.c b/morse.c index eb0bd8e..3c5698e 100644 --- a/morse.c +++ b/morse.c @@ -1,6 +1,6 @@ -/* Convert ASCII to morse code. Reads from stdin if provided with no argument - or "-", otherwise reads from the first command line argument. Prints "?" if - character is not found. */ +/* Convert ASCII to morse code. Reads from stdin if provided with no argument + or "-", otherwise reads from the first command line argument. Prints "?" if + character is not found. */ #include #include