summaryrefslogtreecommitdiffstats
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index e099197..92f17f8 100644
--- a/src/util.c
+++ b/src/util.c
@@ -114,3 +114,24 @@ char *xsubstr(const char *s, size_t len)
p[len] = '\0';
return p;
}
+
+// The two things every caller of getopt_long otherwise writes by hand.
+
+const char *authz_optname(int val, const struct option *lo)
+{
+ for (; lo->name != NULL; lo++) {
+ if (lo->val == val)
+ return lo->name;
+ }
+ return "?";
+}
+
+// optind = 1 is how a second getopt_long call is told to begin again; opterr = 0
+// is so the messages come out in this program's words and not glibc's.
+
+void authz_opt_reset(void)
+{
+ optind = 1;
+ opterr = 0;
+}
+