From f902fd6cebf297090891201b057c7f5c8605e974 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Thu, 19 Feb 2004 01:35:15 +0000 Subject: [PATCH] Protoize git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16099 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/profile/ChangeLog | 5 ++ src/util/profile/prof_file.c | 23 +++------ src/util/profile/prof_get.c | 88 ++++++++++----------------------- src/util/profile/prof_init.c | 49 ++++++------------- src/util/profile/prof_parse.c | 38 +++++---------- src/util/profile/prof_set.c | 26 +++------- src/util/profile/prof_tree.c | 91 ++++++++++++----------------------- 7 files changed, 105 insertions(+), 215 deletions(-) diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog index bab4b5368..f3fe34151 100644 --- a/src/util/profile/ChangeLog +++ b/src/util/profile/ChangeLog @@ -1,3 +1,8 @@ +2004-02-18 Ken Raeburn + + * prof_file.c, prof_get.c, prof_init.c, prof_parse.c, prof_set.c, + prof_tree.c: Use ANSI style function definitions. + 2004-01-30 Alexandra Ellwood * prof-int.h: prof-int.h should include pthread.h when USE_PTHREADS diff --git a/src/util/profile/prof_file.c b/src/util/profile/prof_file.c index 357568def..23c64b4c6 100644 --- a/src/util/profile/prof_file.c +++ b/src/util/profile/prof_file.c @@ -35,8 +35,7 @@ struct global_shared_profile_data krb5int_profile_shared_data = { static void profile_free_file_data(prf_data_t); -static int rw_access(filespec) - profile_filespec_t filespec; +static int rw_access(profile_filespec_t filespec) { #ifdef HAVE_ACCESS if (access(filespec, W_OK) == 0) @@ -61,8 +60,7 @@ static int rw_access(filespec) } #ifdef SHARE_TREE_DATA -static int r_access(filespec) - profile_filespec_t filespec; +static int r_access(profile_filespec_t filespec) { #ifdef HAVE_ACCESS if (access(filespec, R_OK) == 0) @@ -87,9 +85,8 @@ static int r_access(filespec) } #endif /* SHARE_TREE_DATA */ -errcode_t profile_open_file(filespec, ret_prof) - const_profile_filespec_t filespec; - prf_file_t *ret_prof; +errcode_t profile_open_file(const_profile_filespec_t filespec, + prf_file_t *ret_prof) { prf_file_t prf; errcode_t retval; @@ -244,8 +241,7 @@ make_hard_link(const char *oldpath, const char *newpath) #endif } -errcode_t profile_flush_file_data(data) - prf_data_t data; +errcode_t profile_flush_file_data(prf_data_t data) { FILE *f; profile_filespec_t new_file; @@ -344,16 +340,14 @@ void profile_dereference_data(prf_data_t data) #endif } -void profile_free_file(prf) - prf_file_t prf; +void profile_free_file(prf_file_t prf) { profile_dereference_data(prf->data); free(prf); } /* Call with mutex locked! */ -static void profile_free_file_data(data) - prf_data_t data; +static void profile_free_file_data(prf_data_t data) { #ifdef SHARE_TREE_DATA if (data->flags & PROFILE_FILE_SHARED) { @@ -387,8 +381,7 @@ static void profile_free_file_data(data) #endif } -errcode_t profile_close_file(prf) - prf_file_t prf; +errcode_t profile_close_file(prf_file_t prf) { errcode_t retval; diff --git a/src/util/profile/prof_get.c b/src/util/profile/prof_get.c index 07ebfd870..0251e84e8 100644 --- a/src/util/profile/prof_get.c +++ b/src/util/profile/prof_get.c @@ -35,8 +35,7 @@ struct profile_string_list { /* * Initialize the string list abstraction. */ -static errcode_t init_list(list) - struct profile_string_list *list; +static errcode_t init_list(struct profile_string_list *list) { list->num = 0; list->max = 10; @@ -51,9 +50,7 @@ static errcode_t init_list(list) * Free any memory left over in the string abstraction, returning the * built up list in *ret_list if it is non-null. */ -static void end_list(list, ret_list) - struct profile_string_list *list; - char ***ret_list; +static void end_list(struct profile_string_list *list, char ***ret_list) { char **cp; @@ -75,9 +72,7 @@ static void end_list(list, ret_list) /* * Add a string to the list. */ -static errcode_t add_to_list(list, str) - struct profile_string_list *list; - const char *str; +static errcode_t add_to_list(struct profile_string_list *list, const char *str) { char *newstr, **newlist; int newmax; @@ -103,9 +98,7 @@ static errcode_t add_to_list(list, str) /* * Return TRUE if the string is already a member of the list. */ -static int is_list_member(list, str) - struct profile_string_list *list; - const char *str; +static int is_list_member(struct profile_string_list *list, const char *str) { char **cpp; @@ -123,8 +116,7 @@ static int is_list_member(list, str) * This function frees a null-terminated list as returned by * profile_get_values. */ -void KRB5_CALLCONV profile_free_list(list) - char **list; +void KRB5_CALLCONV profile_free_list(char **list) { char **cp; @@ -137,10 +129,8 @@ void KRB5_CALLCONV profile_free_list(list) } errcode_t KRB5_CALLCONV -profile_get_values(profile, names, ret_values) - profile_t profile; - const char *const *names; - char ***ret_values; +profile_get_values(profile_t profile, const char *const *names, + char ***ret_values) { errcode_t retval; void *state; @@ -179,10 +169,8 @@ cleanup: * This function only gets the first value from the file; it is a * helper function for profile_get_string, profile_get_integer, etc. */ -errcode_t profile_get_value(profile, names, ret_value) - profile_t profile; - const char **names; - const char **ret_value; +errcode_t profile_get_value(profile_t profile, const char **names, + const char **ret_value) { errcode_t retval; void *state; @@ -207,12 +195,9 @@ cleanup: } errcode_t KRB5_CALLCONV -profile_get_string(profile, name, subname, subsubname, - def_val, ret_string) - profile_t profile; - const char *name, *subname, *subsubname; - const char *def_val; - char **ret_string; +profile_get_string(profile_t profile, const char *name, const char *subname, + const char *subsubname, const char *def_val, + char **ret_string) { const char *value; errcode_t retval; @@ -242,12 +227,8 @@ profile_get_string(profile, name, subname, subsubname, } errcode_t KRB5_CALLCONV -profile_get_integer(profile, name, subname, subsubname, - def_val, ret_int) - profile_t profile; - const char *name, *subname, *subsubname; - int def_val; - int *ret_int; +profile_get_integer(profile_t profile, const char *name, const char *subname, + const char *subsubname, int def_val, int *ret_int) { const char *value; errcode_t retval; @@ -302,9 +283,7 @@ static const char *const conf_no[] = { }; static errcode_t -profile_parse_boolean(s, ret_boolean) - char *s; - int* ret_boolean; +profile_parse_boolean(char *s, int *ret_boolean) { const char *const *p; @@ -329,12 +308,8 @@ profile_parse_boolean(s, ret_boolean) } 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_boolean; +profile_get_boolean(profile_t profile, const char *name, const char *subname, + const char *subsubname, int def_val, int *ret_boolean) { const char *value; errcode_t retval; @@ -364,10 +339,8 @@ profile_get_boolean(profile, name, subname, subsubname, * under the specified section name. */ errcode_t KRB5_CALLCONV -profile_get_subsection_names(profile, names, ret_names) - profile_t profile; - const char **names; - char ***ret_names; +profile_get_subsection_names(profile_t profile, const char **names, + char ***ret_names) { errcode_t retval; void *state; @@ -402,10 +375,8 @@ cleanup: * under the specified section name. */ errcode_t KRB5_CALLCONV -profile_get_relation_names(profile, names, ret_names) - profile_t profile; - const char **names; - char ***ret_names; +profile_get_relation_names(profile_t profile, const char **names, + char ***ret_names) { errcode_t retval; void *state; @@ -436,26 +407,20 @@ cleanup: } errcode_t KRB5_CALLCONV -profile_iterator_create(profile, names, flags, ret_iter) - profile_t profile; - const char *const *names; - int flags; - void **ret_iter; +profile_iterator_create(profile_t profile, const char *const *names, int flags, + void **ret_iter) { return profile_node_iterator_create(profile, names, flags, ret_iter); } void KRB5_CALLCONV -profile_iterator_free(iter_p) - void **iter_p; +profile_iterator_free(void **iter_p) { profile_node_iterator_free(iter_p); } errcode_t KRB5_CALLCONV -profile_iterator(iter_p, ret_name, ret_value) - void **iter_p; - char **ret_name, **ret_value; +profile_iterator(void **iter_p, char **ret_name, char **ret_value) { char *name, *value; errcode_t retval; @@ -491,8 +456,7 @@ profile_iterator(iter_p, ret_name, ret_value) } void KRB5_CALLCONV -profile_release_string(str) - char *str; +profile_release_string(char *str) { free(str); } diff --git a/src/util/profile/prof_init.c b/src/util/profile/prof_init.c index 2dbcd826f..703631d3b 100644 --- a/src/util/profile/prof_init.c +++ b/src/util/profile/prof_init.c @@ -24,9 +24,7 @@ error(do not have a 4-byte integer type) #endif /* SIZEOF_LONG == 4 */ errcode_t KRB5_CALLCONV -profile_init(files, ret_profile) - const_profile_filespec_t *files; - profile_t *ret_profile; +profile_init(const_profile_filespec_t *files, profile_t *ret_profile) { const_profile_filespec_t *fs; profile_t profile; @@ -74,9 +72,8 @@ profile_init(files, ret_profile) } errcode_t KRB5_CALLCONV -profile_init_path(filepath, ret_profile) - const_profile_filespec_list_t filepath; - profile_t *ret_profile; +profile_init_path(const_profile_filespec_list_t filepath, + profile_t *ret_profile) { int n_entries, i; unsigned int ent_len; @@ -126,8 +123,7 @@ profile_init_path(filepath, ret_profile) } errcode_t KRB5_CALLCONV -profile_flush(profile) - profile_t profile; +profile_flush(profile_t profile) { if (!profile || profile->magic != PROF_MAGIC_PROFILE) return PROF_MAGIC_PROFILE; @@ -139,8 +135,7 @@ profile_flush(profile) } void KRB5_CALLCONV -profile_abandon(profile) - profile_t profile; +profile_abandon(profile_t profile) { prf_file_t p, next; @@ -156,8 +151,7 @@ profile_abandon(profile) } void KRB5_CALLCONV -profile_release(profile) - profile_t profile; +profile_release(profile_t profile) { prf_file_t p, next; @@ -175,10 +169,8 @@ profile_release(profile) /* * Here begins the profile serialization functions. */ -errcode_t profile_ser_size(unused, profile, sizep) - const char *unused; - profile_t profile; - size_t *sizep; +errcode_t profile_ser_size(const char *unused, profile_t profile, + size_t *sizep) { size_t required; prf_file_t pfp; @@ -193,10 +185,7 @@ errcode_t profile_ser_size(unused, profile, sizep) return 0; } -static void pack_int32(oval, bufpp, remainp) - prof_int32 oval; - unsigned char **bufpp; - size_t *remainp; +static void pack_int32(prof_int32 oval, unsigned char **bufpp, size_t *remainp) { (*bufpp)[0] = (unsigned char) ((oval >> 24) & 0xff); (*bufpp)[1] = (unsigned char) ((oval >> 16) & 0xff); @@ -206,11 +195,8 @@ static void pack_int32(oval, bufpp, remainp) *remainp -= sizeof(prof_int32); } -errcode_t profile_ser_externalize(unused, profile, bufpp, remainp) - const char *unused; - profile_t profile; - unsigned char **bufpp; - size_t *remainp; +errcode_t profile_ser_externalize(const char *unused, profile_t profile, + unsigned char **bufpp, size_t *remainp) { errcode_t retval; size_t required; @@ -251,10 +237,8 @@ errcode_t profile_ser_externalize(unused, profile, bufpp, remainp) return(retval); } -static int unpack_int32(intp, bufpp, remainp) - prof_int32 *intp; - unsigned char **bufpp; - size_t *remainp; +static int unpack_int32(prof_int32 *intp, unsigned char **bufpp, + size_t *remainp) { if (*remainp >= sizeof(prof_int32)) { *intp = (((prof_int32) (*bufpp)[0] << 24) | @@ -269,11 +253,8 @@ static int unpack_int32(intp, bufpp, remainp) return 1; } -errcode_t profile_ser_internalize(unused, profilep, bufpp, remainp) - const char *unused; - profile_t *profilep; - unsigned char **bufpp; - size_t *remainp; +errcode_t profile_ser_internalize(const char *unused, profile_t *profilep, + unsigned char **bufpp, size_t *remainp) { errcode_t retval; unsigned char *bp; diff --git a/src/util/profile/prof_parse.c b/src/util/profile/prof_parse.c index b18b8befa..f2cd691a4 100644 --- a/src/util/profile/prof_parse.c +++ b/src/util/profile/prof_parse.c @@ -21,16 +21,14 @@ struct parse_state { struct profile_node *current_section; }; -static char *skip_over_blanks(cp) - char *cp; +static char *skip_over_blanks(char *cp) { while (*cp && isspace((int) (*cp))) cp++; return cp; } -static void strip_line(line) - char *line; +static void strip_line(char *line) { char *p = line + strlen(line); while (p > line && (p[-1] == '\n' || p[-1] == '\r')) @@ -67,8 +65,7 @@ static void parse_quoted_string(char *str) } -static errcode_t parse_init_state(state) - struct parse_state *state; +static errcode_t parse_init_state(struct parse_state *state) { state->state = STATE_INIT_COMMENT; state->group_level = 0; @@ -76,9 +73,7 @@ static errcode_t parse_init_state(state) return profile_create_node("(root)", 0, &state->root_section); } -static errcode_t parse_std_line(line, state) - char *line; - struct parse_state *state; +static errcode_t parse_std_line(char *line, struct parse_state *state) { char *cp, ch, *tag, *value; char *p; @@ -196,9 +191,7 @@ static errcode_t parse_std_line(line, state) return 0; } -static errcode_t parse_line(line, state) - char *line; - struct parse_state *state; +static errcode_t parse_line(char *line, struct parse_state *state) { char *cp; @@ -218,9 +211,7 @@ static errcode_t parse_line(line, state) return 0; } -errcode_t profile_parse_file(f, root) - FILE *f; - struct profile_node **root; +errcode_t profile_parse_file(FILE *f, struct profile_node **root) { #define BUF_SIZE 2048 char *bptr; @@ -304,8 +295,7 @@ errcode_t profile_parse_file(f, root) /* * Return TRUE if the string begins or ends with whitespace */ -static int need_double_quotes(str) - char *str; +static int need_double_quotes(char *str) { if (!str || !*str) return 0; @@ -320,9 +310,7 @@ static int need_double_quotes(str) * Output a string with double quotes, doing appropriate backquoting * of characters as necessary. */ -static void output_quoted_string(str, f) - char *str; - FILE *f; +static void output_quoted_string(char *str, FILE *f) { char ch; @@ -367,10 +355,8 @@ static void output_quoted_string(str, f) #define EOL "\n" #endif -static void dump_profile_to_file(root, level, dstfile) - struct profile_node *root; - int level; - FILE *dstfile; +static void dump_profile_to_file(struct profile_node *root, int level, + FILE *dstfile) { int i; struct profile_node *p; @@ -421,9 +407,7 @@ static void dump_profile_to_file(root, level, dstfile) } while (iter != 0); } -errcode_t profile_write_tree_file(root, dstfile) - struct profile_node *root; - FILE *dstfile; +errcode_t profile_write_tree_file(struct profile_node *root, FILE *dstfile) { dump_profile_to_file(root, 0, dstfile); return 0; diff --git a/src/util/profile/prof_set.c b/src/util/profile/prof_set.c index c121d64da..3c4489860 100644 --- a/src/util/profile/prof_set.c +++ b/src/util/profile/prof_set.c @@ -20,8 +20,7 @@ #endif #include -static errcode_t rw_setup(profile) - profile_t profile; +static errcode_t rw_setup(profile_t profile) { prf_file_t file; errcode_t retval = 0; @@ -84,11 +83,8 @@ static errcode_t rw_setup(profile) * ADL - 2/23/99, rewritten TYT 2/25/99 */ errcode_t KRB5_CALLCONV -profile_update_relation(profile, names, old_value, new_value) - profile_t profile; - const char **names; - const char *old_value; - const char *new_value; +profile_update_relation(profile_t profile, const char **names, + const char *old_value, const char *new_value) { errcode_t retval; struct profile_node *section, *node; @@ -137,9 +133,7 @@ profile_update_relation(profile, names, old_value, new_value) * TYT - 2/25/99 */ errcode_t KRB5_CALLCONV -profile_clear_relation(profile, names) - profile_t profile; - const char **names; +profile_clear_relation(profile_t profile, const char **names) { errcode_t retval; struct profile_node *section, *node; @@ -184,10 +178,8 @@ profile_clear_relation(profile, names) * ADL - 2/23/99, rewritten TYT 2/25/99 */ errcode_t KRB5_CALLCONV -profile_rename_section(profile, names, new_name) - profile_t profile; - const char **names; - const char *new_name; +profile_rename_section(profile_t profile, const char **names, + const char *new_name) { errcode_t retval; struct profile_node *section, *node; @@ -237,10 +229,8 @@ profile_rename_section(profile, names, new_name) * ADL - 2/23/99, rewritten TYT 2/25/99 */ errcode_t KRB5_CALLCONV -profile_add_relation(profile, names, new_value) - profile_t profile; - const char **names; - const char *new_value; +profile_add_relation(profile_t profile, const char **names, + const char *new_value) { errcode_t retval; struct profile_node *section; diff --git a/src/util/profile/prof_tree.c b/src/util/profile/prof_tree.c index 38b86f368..a99689e25 100644 --- a/src/util/profile/prof_tree.c +++ b/src/util/profile/prof_tree.c @@ -45,8 +45,7 @@ struct profile_node { /* * Free a node, and any children */ -void profile_free_node(node) - struct profile_node *node; +void profile_free_node(struct profile_node *node) { struct profile_node *child, *next; @@ -83,9 +82,8 @@ static char *MYstrdup (const char *s) /* * Create a node */ -errcode_t profile_create_node(name, value, ret_node) - const char *name, *value; - struct profile_node **ret_node; +errcode_t profile_create_node(const char *name, const char *value, + struct profile_node **ret_node) { struct profile_node *new; @@ -116,8 +114,7 @@ errcode_t profile_create_node(name, value, ret_node) * the profile are true. If not, we have a programming bug somewhere, * probably in this file. */ -errcode_t profile_verify_node(node) - struct profile_node *node; +errcode_t profile_verify_node(struct profile_node *node) { struct profile_node *p, *last; errcode_t retval; @@ -147,10 +144,8 @@ errcode_t profile_verify_node(node) /* * Add a node to a particular section */ -errcode_t profile_add_node(section, name, value, ret_node) - struct profile_node *section; - const char *name, *value; - struct profile_node **ret_node; +errcode_t profile_add_node(struct profile_node *section, const char *name, + const char *value, struct profile_node **ret_node) { errcode_t retval; struct profile_node *p, *last, *new; @@ -192,8 +187,7 @@ errcode_t profile_add_node(section, name, value, ret_node) /* * Set the final flag on a particular node. */ -errcode_t profile_make_node_final(node) - struct profile_node *node; +errcode_t profile_make_node_final(struct profile_node *node) { CHECK_MAGIC(node); @@ -204,8 +198,7 @@ errcode_t profile_make_node_final(node) /* * Check the final flag on a node */ -int profile_is_node_final(node) - struct profile_node *node; +int profile_is_node_final(struct profile_node *node) { return (node->final != 0); } @@ -215,8 +208,7 @@ int profile_is_node_final(node) * only; if the name needs to be returned from an exported function, * strdup it first!) */ -const char *profile_get_node_name(node) - struct profile_node *node; +const char *profile_get_node_name(struct profile_node *node) { return node->name; } @@ -226,8 +218,7 @@ const char *profile_get_node_name(node) * only; if the name needs to be returned from an exported function, * strdup it first!) */ -const char *profile_get_node_value(node) - struct profile_node *node; +const char *profile_get_node_value(struct profile_node *node) { return node->value; } @@ -246,13 +237,9 @@ const char *profile_get_node_value(node) * (This won't happen if section_flag is non-zero, obviously.) * */ -errcode_t profile_find_node(section, name, value, section_flag, state, node) - struct profile_node *section; - const char *name; - const char *value; - int section_flag; - void **state; - struct profile_node **node; +errcode_t profile_find_node(struct profile_node *section, const char *name, + const char *value, int section_flag, void **state, + struct profile_node **node) { struct profile_node *p; @@ -322,11 +309,9 @@ errcode_t profile_find_node(section, name, value, section_flag, state, node) * returned to a calling application (profile_find_node_relation is not an * exported interface), it should be strdup()'ed. */ -errcode_t profile_find_node_relation(section, name, state, ret_name, value) - struct profile_node *section; - const char *name; - void **state; - char **ret_name, **value; +errcode_t profile_find_node_relation(struct profile_node *section, + const char *name, void **state, + char **ret_name, char **value) { struct profile_node *p; errcode_t retval; @@ -356,13 +341,10 @@ errcode_t profile_find_node_relation(section, name, state, ret_name, value) * profile node) makes this function mostly syntactic sugar for * profile_find_node. */ -errcode_t profile_find_node_subsection(section, name, state, ret_name, - subsection) - struct profile_node *section; - const char *name; - void **state; - char **ret_name; - struct profile_node **subsection; +errcode_t profile_find_node_subsection(struct profile_node *section, + const char *name, void **state, + char **ret_name, + struct profile_node **subsection) { struct profile_node *p; errcode_t retval; @@ -383,8 +365,8 @@ errcode_t profile_find_node_subsection(section, name, state, ret_name, /* * This function returns the parent of a particular node. */ -errcode_t profile_get_node_parent(section, parent) - struct profile_node *section, **parent; +errcode_t profile_get_node_parent(struct profile_node *section, + struct profile_node **parent) { *parent = section->parent; return 0; @@ -407,11 +389,9 @@ struct profile_iterator { int num; }; -errcode_t profile_node_iterator_create(profile, names, flags, ret_iter) - profile_t profile; - const char *const *names; - int flags; - void **ret_iter; +errcode_t profile_node_iterator_create(profile_t profile, + const char *const *names, int flags, + void **ret_iter) { struct profile_iterator *iter; int done_idx = 0; @@ -443,8 +423,7 @@ errcode_t profile_node_iterator_create(profile, names, flags, ret_iter) return 0; } -void profile_node_iterator_free(iter_p) - void **iter_p; +void profile_node_iterator_free(void **iter_p) { struct profile_iterator *iter; @@ -464,10 +443,8 @@ void profile_node_iterator_free(iter_p) * (profile_node_iterator is not an exported interface), it should be * strdup()'ed. */ -errcode_t profile_node_iterator(iter_p, ret_node, ret_name, ret_value) - void **iter_p; - struct profile_node **ret_node; - char **ret_name, **ret_value; +errcode_t profile_node_iterator(void **iter_p, struct profile_node **ret_node, + char **ret_name, char **ret_value) { struct profile_iterator *iter = *iter_p; struct profile_node *section, *p; @@ -579,8 +556,7 @@ get_new_file: * * TYT, 2/25/99 */ -errcode_t profile_remove_node(node) - struct profile_node *node; +errcode_t profile_remove_node(struct profile_node *node) { CHECK_MAGIC(node); @@ -605,9 +581,8 @@ errcode_t profile_remove_node(node) * * TYT, 2/25/99 */ -errcode_t profile_set_relation_value(node, new_value) - struct profile_node *node; - const char *new_value; +errcode_t profile_set_relation_value(struct profile_node *node, + const char *new_value) { char *cp; @@ -632,9 +607,7 @@ errcode_t profile_set_relation_value(node, new_value) * * TYT 2/25/99 */ -errcode_t profile_rename_node(node, new_name) - struct profile_node *node; - const char *new_name; +errcode_t profile_rename_node(struct profile_node *node, const char *new_name) { char *new_string; struct profile_node *p, *last; -- 2.26.2