summaryrefslogtreecommitdiff
path: root/usr/src/cmd/ssh/libssh/common/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd/ssh/libssh/common/misc.c')
-rw-r--r--usr/src/cmd/ssh/libssh/common/misc.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/usr/src/cmd/ssh/libssh/common/misc.c b/usr/src/cmd/ssh/libssh/common/misc.c
index 1b7646f4dc..9fe8d8c1b8 100644
--- a/usr/src/cmd/ssh/libssh/common/misc.c
+++ b/usr/src/cmd/ssh/libssh/common/misc.c
@@ -420,3 +420,28 @@ mysignal(int sig, mysig_t act)
return (signal(sig, act));
#endif
}
+
+/*
+ * Return true if argument is one of "yes", "true", "no" or "false". If
+ * 'active' is 0 than we are in a non-matching Host section of the
+ * configuration file so we check the syntax but will not set the value of
+ * '*option'. Otherwise we set its value if not already set.
+ */
+int
+get_yes_no_flag(int *option, const char *arg, const char *filename, int linenum,
+ int active)
+{
+ int value = -1;
+
+ if (arg == NULL || *arg == '\0')
+ fatal("%.200s line %d: Missing argument.", filename, linenum);
+ if (strcmp(arg, "yes") == 0 || strcmp(arg, "true") == 0)
+ value = 1;
+ else if (strcmp(arg, "no") == 0 || strcmp(arg, "false") == 0)
+ value = 0;
+
+ if (active && *option == -1 && value != -1)
+ *option = value;
+
+ return (value != -1);
+}