+2000-03-24 Miro Jurisic <meeroh@mit.edu>
+
+ * prof_get.c: Added prof_get_boolean and changed prof_get_integer
+ to return errors for malformed input
+ * prof.hin: Added prof_get_boolean
+ * profile.exp: Added prof_get_boolean
+ * prof_err.et: Added PROF_BAD_BOOLEAN, PROF_BAD_INTEGER
+
Fri Jan 28 16:27:01 2000 Ezra Peisach <epeisach@mit.edu>
* argv_parse.c: Include string.h (for strlen prototype)
const char *value;
errcode_t retval;
const char *names[4];
+ const char *end_value;
+ long ret_long;
if (profile == 0) {
*ret_int = def_val;
return 0;
} else if (retval)
return retval;
+
+ ret_long = strtol (value, &end_value, 10);
+ if ((errno != 0) || (end_value != value + strlen (value)) ||
+ (end_value == value) || (ret_long > INT_MAX) ||
+ (ret_long < INT_MIN)) {
+ return PROF_BAD_INTEGER;
+ }
+
- *ret_int = atoi(value);
+ *ret_int = ret_long;
return 0;
}
+static char *conf_yes[] = {
+ "y", "yes", "true", "t", "1", "on",
+ 0,
+};
+
+static char *conf_no[] = {
+ "n", "no", "false", "nil", "0", "off",
+ 0,
+};
+
+static errcode_t
+profile_parse_boolean(s, ret_boolean)
+ char *s;
+ int* ret_boolean;
+{
+ char **p;
+
+ if (ret_boolean == NULL)
+ return PROF_EINVAL;
+
+ for(p=conf_yes; *p; p++) {
+ if (!strcasecmp(*p,s))
+ *ret_boolean = 1;
+ return 0;
+ }
+
+ for(p=conf_no; *p; p++) {
+ if (!strcasecmp(*p,s))
+ *ret_boolean = 0;
+ return 0;
+ }
+
+ return PROF_BAD_BOOLEAN;
+}
+
+KRB5_DLLIMP errcode_t KRB5_CALLCONV
+profile_get_boolean(profile, name, subname, subsubname,
+ def_val, ret_boolean)
+ profile_t profile;
+ const char *name, *subname, *subsubname;
+ int def_val;
+ int *ret_int;
+{
+ const char *value;
+ errcode_t retval;
+ const char *names[4];
+
+ if (profile == 0) {
+ *ret_int = def_val;
+ return 0;
+ }
+
+ names[0] = name;
+ names[1] = subname;
+ names[2] = subsubname;
+ names[3] = 0;
+ retval = profile_get_value(profile, names, &value);
+ if (retval == PROF_NO_SECTION || retval == PROF_NO_RELATION) {
+ *ret_int = def_val;
+ return 0;
+ } else if (retval)
+ return retval;
+
+ return prof_parse_boolean (value, ret_int);
+}
+
/*
* This function will return the list of the names of subections in the
* under the specified section name.
const char *subsubname, int def_val,
int *ret_default));
+KRB5_DLLIMP long KRB5_CALLCONV profile_get_boolean
+ PROTOTYPE((profile_t profile, const char *name, const char *subname,
+ const char *subsubname, int def_val,
+ int *ret_default));
+
KRB5_DLLIMP long KRB5_CALLCONV profile_get_relation_names
PROTOTYPE((profile_t profile, const char **names, char ***ret_names));