diff options
author | Richard Sharpe <sharpe@samba.org> | 2003-04-17 08:09:20 +0000 |
---|---|---|
committer | Richard Sharpe <sharpe@samba.org> | 2003-04-17 08:09:20 +0000 |
commit | 953aef482beec9a88da200aa54773226a23b66b0 (patch) | |
tree | 9c00c96a8537c0c518c34dedf60b2d515f240973 /source3/utils/editreg.c | |
parent | 6584cde2131cc8356b350ec245166a00a35f845e (diff) | |
download | samba-953aef482beec9a88da200aa54773226a23b66b0.tar.gz samba-953aef482beec9a88da200aa54773226a23b66b0.tar.xz samba-953aef482beec9a88da200aa54773226a23b66b0.zip |
More updates ...
(This used to be commit 410451f9478ff1e73cabc8ee2213ded4f08315c6)
Diffstat (limited to 'source3/utils/editreg.c')
-rw-r--r-- | source3/utils/editreg.c | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/source3/utils/editreg.c b/source3/utils/editreg.c index 01df68521c1..ad4417921c8 100644 --- a/source3/utils/editreg.c +++ b/source3/utils/editreg.c @@ -310,6 +310,7 @@ Hope this helps.... (Although it was "fun" for me to uncover this things, #define False 0 #define True 1 +#define REG_KEY_LIST_SIZE 10; static int verbose = 0; static int print_security = 0; @@ -944,14 +945,75 @@ int nt_delete_reg_key(REG_KEY *key, int delete_name) * We return the key structure for the final component as that is * often where we want to add values ... */ -REG_KEY *nt_add_reg_key_list(KEY_LIST *list, char * name, REG_KEY *key, int xxx) + +/* + * Create a 1 component key name and set its parent to parent + */ +REG_KEY *nt_create_reg_key1(char *name, REG_KEY *parent) { + REG_KEY *tmp; + + if (!name || !*name) return NULL; /* A key's name cannot be empty */ + + /* There should not be more than one component */ + if (strchr(name, '\\')) return NULL; + + if (!(tmp = (REG_KEY *)malloc(sizeof(REG_KEY)))) return NULL; + + bzero(tmp, sizeof(REG_KEY)); + + if (!(tmp->name = strdup(name))) goto error; + + + error: + if (tmp) free(tmp); return NULL; +} + +REG_KEY *nt_add_reg_key(REG_KEY *key, char *name, int create); +REG_KEY *nt_add_reg_key_list(KEY_LIST *list, char * name, REG_KEY *parent, int create) +{ + int i; + REG_KEY *ret; + char *lname, *c1, *c2; + + if (!list || !name || !*name) return NULL; + for (i = 0; i < list->key_count; i++) { + if ((ret = nt_add_reg_key(list->keys[i], name, create))) + return ret; + } + + /* + * If we reach here we could not find the the first component + * so create it ... + */ + + lname = strdup(name); + if (!lname) return NULL; + + c1 = lname; + c2 = strchr(c1, '\\'); + if (c2) { /* Split here ... */ + *c2 = 0; + c2++; + } + + if (list->key_count < list->max_keys){ + list->key_count++; + } + else { /* Create more space in the list ... */ + + } + + return NULL; + error: + if (lname) free(lname); + return NULL; } -REG_KEY *nt_add_reg_key(REG_KEY *key, char *name) +REG_KEY *nt_add_reg_key(REG_KEY *key, char *name, int create) { char *lname = NULL, *c1, *c2; REG_KEY * tmp; |