]> git.armaanb.net Git - bin.git/commitdiff
*.c: run clang-format
authorArmaan Bhojwani <me@armaanb.net>
Mon, 5 Jul 2021 17:06:01 +0000 (13:06 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Mon, 5 Jul 2021 17:06:01 +0000 (13:06 -0400)
.clang-format [new file with mode: 0644]
crontab-argh.c
fortune-cgi.c
morse.c

diff --git a/.clang-format b/.clang-format
new file mode 100644 (file)
index 0000000..3577d9d
--- /dev/null
@@ -0,0 +1,3 @@
+BasedOnStyle: llvm
+AlwaysBreakAfterReturnType: AllDefinitions
+IndentWidth: 4
\ No newline at end of file
index 3fc7e3e991b0909396db7dc8972cf2d7c9132ccc..5c40756df7e18fd24852d03b5f1e0107e6608b2f 100644 (file)
@@ -1,29 +1,34 @@
 /* Stops you from accidentally running crontab -r. alias this to crontab.
 /* 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 <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-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);
 }
 }
index 63693d75ddd3e789db5f32a7577ca8ce8ed3772c..d0ec3b718bf0d382da6405890e612bfd3244d7bc 100644 (file)
@@ -1,36 +1,35 @@
 // CGI program to get fortunes. Powers https://fortune.armaanb.net.
 
 // CGI program to get fortunes. Powers https://fortune.armaanb.net.
 
-#include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 int
 
 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 eb0bd8ee4f3c7db0609a6bba37b19ab4657bfcbc..3c5698e27d56179206e3d1512c4d2640047acbad 100644 (file)
--- 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 <string.h>
 #include <stdio.h>
 
 #include <string.h>
 #include <stdio.h>