diff options
| author | Fuwn <[email protected]> | 2024-06-24 17:55:11 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-06-24 18:05:22 -0700 |
| commit | 34e8da2ffea26f3994c84170533c897ef3cfcfa7 (patch) | |
| tree | 6c2e742fc855c0c0a878c483049c4e09cff026ed | |
| parent | 105fcb3918a81d661797113ef2a6a4a1515130b5 (diff) | |
| download | gigi-34e8da2ffea26f3994c84170533c897ef3cfcfa7.tar.xz gigi-34e8da2ffea26f3994c84170533c897ef3cfcfa7.zip | |
feat(gigi.c): fallback to default
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | gigi.c | 18 |
2 files changed, 15 insertions, 6 deletions
@@ -63,7 +63,8 @@ passes any arguments from the Finger request to the executable. Static mode is enabled by default. A Finger request for `test` will return the contents of `./gigi/test`. A Finger request of nothing will return the contents -of `./gigi/default`. +of `./gigi/default`. The default file is also the fallback file in case the +requested file does not exist. To emulate dynamic mode, minus the arguments you can setup a service of some kind to periodically update the contents of one of the static files. @@ -176,15 +176,23 @@ void gigi_show(int connection_file_descriptor, const char *arguments) { snprintf(gigi_show_command, MAXIMUM_COMMAND_LENGTH, "./.gigi/%s", gigi_show_arguments); - printf("ok: %s\n", gigi_show_command); gigi_show_file = fopen(gigi_show_command, "r"); - } - if (!gigi_show_file) { - perror("error: could not open gigi show file\n"); + if (!gigi_show_file) { + fprintf(stderr, "error: could not open gigi show file: %s\n", + gigi_show_command); - return; + gigi_show_file = fopen("./.gigi/default", "r"); + } + + if (!gigi_show_file) { + perror("error: could not open default gigi show file: default\n"); + + return; + } + + printf("ok: %s\n", gigi_show_command); } while (fgets(gigi_show_message, MAXIMUM_DATA_SIZE, gigi_show_file) != NULL) { |