--- /dev/null
+BasedOnStyle: llvm
+AlwaysBreakAfterReturnType: AllDefinitions
+IndentWidth: 4
\ No newline at end of file
/* 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>
-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);
}
// CGI program to get fortunes. Powers https://fortune.armaanb.net.
-#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
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;
}
-/* 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>