summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorTheodore Tso <tytso@mit.edu>1995-04-22 00:38:43 +0000
committerTheodore Tso <tytso@mit.edu>1995-04-22 00:38:43 +0000
commitddd67ee7a7009ba9fa27bc78da0405b0b8e908b4 (patch)
tree4982df890f3b39c468ebac5e7d0d39580f727851 /src/util
parent3b674e99b062c1b345dbc9386da886465b0838ed (diff)
downloadkrb5-ddd67ee7a7009ba9fa27bc78da0405b0b8e908b4.tar.gz
krb5-ddd67ee7a7009ba9fa27bc78da0405b0b8e908b4.tar.xz
krb5-ddd67ee7a7009ba9fa27bc78da0405b0b8e908b4.zip
configure.in: Add SUBDIR rule in so this directory can be included into
libkrb5.a prof_init.c: Modify function interface for profile_get_string and profile_get_integer to make it simpler to use. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5434 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util')
-rw-r--r--src/util/profile/configure.in1
-rw-r--r--src/util/profile/prof_init.c57
-rw-r--r--src/util/profile/profile.h.in6
3 files changed, 50 insertions, 14 deletions
diff --git a/src/util/profile/configure.in b/src/util/profile/configure.in
index 364e45edf8..51c2595001 100644
--- a/src/util/profile/configure.in
+++ b/src/util/profile/configure.in
@@ -6,4 +6,5 @@ AC_PROG_ARCHIVE
AC_PROG_RANLIB
ET_RULES
CopyHeader(profile.h,$(BUILDTOP)/include)
+SubdirLibraryRule([$(OBJS)])
V5_AC_OUTPUT_MAKEFILE
diff --git a/src/util/profile/prof_init.c b/src/util/profile/prof_init.c
index f277737067..19bcc1241b 100644
--- a/src/util/profile/prof_init.c
+++ b/src/util/profile/prof_init.c
@@ -20,6 +20,8 @@ errcode_t profile_init(filenames, ret_profile)
prf_file_t new_file, last = 0;
errcode_t retval;
+ initialize_prof_error_table();
+
profile = malloc(sizeof(struct _profile_t));
if (!profile)
return ENOMEM;
@@ -131,6 +133,10 @@ errcode_t profile_get_values(profile, names, ret_values)
init_list(&values);
file = profile->first_file;
+ retval = profile_update_file(file);
+ if (retval)
+ goto cleanup;
+
section = file->root;
for (cpp = names; cpp[1]; cpp++) {
@@ -175,6 +181,10 @@ static errcode_t profile_get_value(profile, names, ret_value)
return PROF_BAD_NAMESET;
file = profile->first_file;
+ retval = profile_update_file(file);
+ if (retval)
+ goto cleanup;
+
section = file->root;
for (cpp = names; cpp[1]; cpp++) {
@@ -196,37 +206,60 @@ cleanup:
return retval;
}
-errcode_t profile_get_string(profile, names, def_val, ret_string)
+errcode_t profile_get_string(profile, name, subname, subsubname,
+ def_val, ret_string)
profile_t profile;
- const char **names;
+ const char *name, *subname, *subsubname;
const char *def_val;
char **ret_string;
{
const char *value;
errcode_t retval;
+ const char *names[4];
- retval = profile_get_value(profile, names, &value);
- if (retval == PROF_NO_SECTION || retval == PROF_NO_RELATION)
+ if (profile) {
+ 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)
+ value = def_val;
+ else if (retval)
+ return retval;
+ } else
value = def_val;
- else if (retval)
- return retval;
- *ret_string = malloc(strlen(value)+1);
- if (*ret_string == 0)
- return ENOMEM;
- strcpy(*ret_string, value);
+ if (value) {
+ *ret_string = malloc(strlen(value)+1);
+ if (*ret_string == 0)
+ return ENOMEM;
+ strcpy(*ret_string, value);
+ } else
+ *ret_string = 0;
return 0;
}
-errcode_t profile_get_integer(profile, names, def_val, ret_int)
+errcode_t profile_get_integer(profile, name, subname, subsubname,
+ def_val, ret_int)
profile_t profile;
- const char **names;
+ const char *name, *subname, *subsubname;
int def_val;
int *ret_int;
{
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;
diff --git a/src/util/profile/profile.h.in b/src/util/profile/profile.h.in
index afa2a30328..3d34d082c4 100644
--- a/src/util/profile/profile.h.in
+++ b/src/util/profile/profile.h.in
@@ -20,9 +20,11 @@ extern long profile_get_values
PROTOTYPE ((profile_t profile, const char **names, char ***ret_values));
extern long profile_get_string
- PROTOTYPE((profile_t profile, const char **names, const char *def_val,
+ PROTOTYPE((profile_t profile, const char *name, const char *subname,
+ const char *subsubname, const char *def_val,
char **ret_string));
extern long profile_get_integer
- PROTOTYPE((profile_t profile, const char **names, int def_val,
+ PROTOTYPE((profile_t profile, const char *name, const char *subname,
+ const char *subsubname, int def_val,
int *ret_default));