diff options
| author | Keith Vetter <keithv@fusion.com> | 1995-09-11 19:06:45 +0000 |
|---|---|---|
| committer | Keith Vetter <keithv@fusion.com> | 1995-09-11 19:06:45 +0000 |
| commit | cdd6c33b9ae48076999e33ffa70e2365ecc5eb8c (patch) | |
| tree | 84682f14e77a844dfab2174318ebccb9067c829f /src/util/profile | |
| parent | a66029e852781fa0333dc92bd88bd8184f6feeb1 (diff) | |
| download | krb5-cdd6c33b9ae48076999e33ffa70e2365ecc5eb8c.tar.gz krb5-cdd6c33b9ae48076999e33ffa70e2365ecc5eb8c.tar.xz krb5-cdd6c33b9ae48076999e33ffa70e2365ecc5eb8c.zip | |
Mac Beta 1 submission
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6749 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/profile')
| -rw-r--r-- | src/util/profile/prof_init.c | 54 | ||||
| -rw-r--r-- | src/util/profile/prof_parse.c | 55 | ||||
| -rw-r--r-- | src/util/profile/prof_section.c | 1 | ||||
| -rw-r--r-- | src/util/profile/prof_tree.c | 65 |
4 files changed, 175 insertions, 0 deletions
diff --git a/src/util/profile/prof_init.c b/src/util/profile/prof_init.c index d8e1c6bd1..c0d10f689 100644 --- a/src/util/profile/prof_init.c +++ b/src/util/profile/prof_init.c @@ -177,6 +177,60 @@ cleanup: /* * XXX this version only works to get values from the first file. + * To do more than that means we have to implement some "interesting" + * code to do the section searching. + */ +errcode_t profile_get_first_values(profile, names, ret_values) + profile_t profile; + const char **names; + char ***ret_values; +{ + prf_file_t file; + errcode_t retval; + struct profile_node *section; + void *state; + char *value; + struct string_list values; + const char **cpp; + char *dummyvalue; + char *secname; + const char *mynames[3]; + + + if (profile == 0) + return PROF_NO_PROFILE; + + if (names == 0 || names[0] == 0) + return PROF_BAD_NAMESET; + + init_list(&values); + + file = profile->first_file; + retval = profile_update_file(file); + if (retval) + goto cleanup; + + section = file->root; + + state = 0; + retval = profile_find_node_subsection(section, *names, &state, &secname, §ion); + + do { + retval = profile_find_node_name(section, &state, &value); + if (retval) + goto cleanup; + add_to_list(&values, value); + } while (state); + + *ret_values = values.list; + return 0; +cleanup: + free_list(&values); + return retval; +} + +/* + * XXX this version only works to get values from the first file. */ static errcode_t profile_get_value(profile, names, ret_value) profile_t profile; diff --git a/src/util/profile/prof_parse.c b/src/util/profile/prof_parse.c index fde563fac..6927321d0 100644 --- a/src/util/profile/prof_parse.c +++ b/src/util/profile/prof_parse.c @@ -230,3 +230,58 @@ void dump_profile(root, level) } while (iter != 0); } #endif /* ! _WINDOWS */ + + +void dump_profile_to_file(root, level, dstfile) + struct profile_node *root; + int level; + FILE *dstfile; +{ + int i; + struct profile_node *p; + void *iter; + long retval; + char *name, *value; + + iter = 0; + do { + retval = profile_find_node_relation(root, 0, &iter, + &name, &value); + if (retval) + break; + for (i=0; i < level; i++) + fprintf(dstfile, "\t"); + fprintf(dstfile, "%s = %s\r", name, value); + } while (iter != 0); + + iter = 0; + do { + retval = profile_find_node_subsection(root, 0, &iter, + &name, &p); + if (retval) + break; + if (level == 0) /* [xxx] */ + { + for (i=0; i < level; i++) + fprintf(dstfile, "\t"); + fprintf(dstfile, "[%s]\r", name); + dump_profile_to_file(p, level+1, dstfile); + fprintf(dstfile, "\r"); + } + else if (level == 1) /* xxx = { ... } */ + { + for (i=0; i < level; i++) + fprintf(dstfile, "\t"); + fprintf(dstfile, "%s = {\r", name); + dump_profile_to_file(p, level+1, dstfile); + for (i=0; i < level; i++) + fprintf(dstfile, "\t"); + fprintf(dstfile, "}\r"); + } + else /* +xxx+ */ + { + // don't know what comes next, this should get someones attention + fprintf(dstfile, "+%s+"); + } + } while (iter != 0); +} diff --git a/src/util/profile/prof_section.c b/src/util/profile/prof_section.c index b3407ecc0..e563e4f23 100644 --- a/src/util/profile/prof_section.c +++ b/src/util/profile/prof_section.c @@ -8,6 +8,7 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> +#include <errno.h> #include "prof_int.h" diff --git a/src/util/profile/prof_tree.c b/src/util/profile/prof_tree.c index 5cb86c92c..4934d29c5 100644 --- a/src/util/profile/prof_tree.c +++ b/src/util/profile/prof_tree.c @@ -323,6 +323,42 @@ errcode_t profile_delete_node_relation(section, name) } /* + * This function deletes a relation from a section. Subsections are + * not deleted; if those need to be deleted, they must be done so manually. + * And sections need not have a value to be delete, this is to enable + * deleting sections which are valueless headers for subsections. + */ +errcode_t profile_delete_interior_node_relation(section, name) + struct profile_node *section; + const char *name; +{ + struct profile_node *p, *next; + + for (p = section->first_child; p; p = p->next) { + if ((strcmp(p->name, name) == 0)) + break; + } + if (p == 0) + return PROF_NO_RELATION; + /* + * Now we start deleting the relations... if we find a + * subsection with the same name, delete it and keep going. + */ + while (p && (strcmp(p->name, name) == 0)) { + if (p->prev) + p->prev->next = p->next; + else + section->first_child = p->next; + next = p->next; + if (p->next) + p->next->prev = p; + profile_free_node(p); + p = next; + } + return 0; +} + +/* * This function returns the parent of a particular node. */ errcode_t profile_get_node_parent(section, parent) @@ -333,3 +369,32 @@ errcode_t profile_get_node_parent(section, parent) } +/* + * Taking the state from another find function, give the name of the + * section and move to the next section. In this case, state can't be null + */ +errcode_t profile_find_node_name(section, state, ret_name) + struct profile_node *section; + void **state; + char **ret_name; +{ + struct profile_node *p; + + CHECK_MAGIC(section); + p = *state; + if (p) { + CHECK_MAGIC(p); + } else + p = section->first_child; + + if (p == 0) { + *state = 0; + return PROF_NO_SECTION; + } +/* give the name back */ + *ret_name = p->name; + p = p->next; + + *state = p; + return 0; +} |
