Welcome to little lamb

Code » limb » commit a534042

Add exitcode.h to harmonize exit code amongst programs

author Olivier Brunel
2023-02-17 09:14:52 UTC
committer Olivier Brunel
2023-02-20 09:02:02 UTC
parent 592988037805e1aac627dbeae88aa3d2f9cb55b5

Add exitcode.h to harmonize exit code amongst programs

Those are values to be used as return/exit code from app, with
consistent/predictable meaning.

They are actually based upon/taken from BSD's sysexits.h

include/limb/exitcode.h +43 -0

diff --git a/include/limb/exitcode.h b/include/limb/exitcode.h
new file mode 100644
index 0000000..e68d62d
--- /dev/null
+++ b/include/limb/exitcode.h
@@ -0,0 +1,43 @@
+#ifndef LIMB_EXITCODE_H
+#define LIMB_EXITCODE_H
+
+/* the following exit codes aim for consistency amongst applications. They are
+ * based upon/taken from BSD's sysexits.h */
+
+enum {
+    /* incorrect usage */
+    EX_USAGE        = 64,
+    /* invalid input/user data */
+    EX_DATA_ERR,
+    /* input/user file missing or not readable */
+    EX_NOINPUT,
+    /* specified user does not exist */
+    EX_NOUSER,
+    /* specified host does not exist */
+    EX_NOHOST,
+    /* service unavailable, or support file/program does not exist.
+     * May also be a catch-all for "something didn't work, don't know what" */
+    EX_UNAVAILABLE,
+    /* internal error */
+    EX_SOFTWARE,
+    /* OS error, e.g. cannot fork, cannot create pipe, etc */
+    EX_OSERR,
+    /* system file (e.g. /etc/passwd) does not exist, cannot be open, has
+     * invalid syntax, etc */
+    EX_OSFILE,
+    /* (user-specified) output file cannot be created */
+    EX_CANTCREAT,
+    /* I/O error */
+    EX_IOERR,
+    /* temporary error, try again (e.g. no memory) */
+    EX_TEMPFAIL,
+    /* invalid value during protocol exchange */
+    EX_PROTOCOL,
+    /* permession denied. Make sure to use EX_NOINPUT or EX_CANTCREAT if
+     * applicable */
+    EX_NOPERM,
+    /* configuration error */
+    EX_CONFIG,
+};
+
+#endif /* LIMB_EXITCODE_H */