From 1c32b10c0c5e3cb5c7c622b1ff0249889d81175e Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Sun, 9 May 2021 16:03:40 -0400 Subject: [PATCH] Add usage message and clean up exit codes --- mmenu.1.scd | 6 ++++++ mmenu.c | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/mmenu.1.scd b/mmenu.1.scd index 11bbcd9..d7abf1b 100644 --- a/mmenu.1.scd +++ b/mmenu.1.scd @@ -10,5 +10,11 @@ mmenu - view the Castle menu The *mmenu* utility uses Nobilis in order to display the castle menu. There is no real command line interface, and the GUI is programmed in Motif. +# EXIT CODES +*0* all ok,++ +*1* libcurl/page request error,++ +*2* out of memory,++ +*3* usage error + # LICENSE MIT License, Armaan Bhojwani 2021. diff --git a/mmenu.c b/mmenu.c index 4e4283c..01a8963 100644 --- a/mmenu.c +++ b/mmenu.c @@ -20,7 +20,7 @@ int memfail(void) { printf("ERROR: Out of memory\n"); - exit(4); + exit(2); } static size_t @@ -73,7 +73,7 @@ getmenu(char *date) if (res != CURLE_OK) { fprintf(stderr,"ERROR: Could not fetch webpage\n%s\n", curl_easy_strerror(res)); - exit(2); + exit(1); } curl_easy_cleanup(curl); @@ -153,6 +153,11 @@ XmStringTable ArgvToXmStringTable (int argc, char **argv) int main(int argc, char *argv[]) { + if (argc > 1) { + printf("Usage: %s\n", argv[0]); + exit(3); + } + // Initialize motif Widget toplevel, rowcol, daysel, disp; XmStringTable strs; -- 2.39.2