Module: wine Branch: master Commit: 606cc0614840459be900628e48be3638cc40a781 URL: http://source.winehq.org/git/wine.git/?a=commit;h=606cc0614840459be900628e48...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Mar 4 20:46:42 2010 +0100
server: Add a helper function for the common functionality between open_key and create_key.
---
server/registry.c | 66 +++++++++++++++++++++++++---------------------------- 1 files changed, 31 insertions(+), 35 deletions(-)
diff --git a/server/registry.c b/server/registry.c index ad57bd2..c342603 100644 --- a/server/registry.c +++ b/server/registry.c @@ -643,33 +643,45 @@ static struct key *follow_symlink( struct key *key, int iteration ) return key; }
-/* open a subkey */ -static struct key *open_key( struct key *key, const struct unicode_str *name, unsigned int access, - unsigned int attributes ) +/* open a key until we find an element that doesn't exist */ +/* helper for open_key and create_key */ +static struct key *open_key_prefix( struct key *key, const struct unicode_str *name, + unsigned int access, struct unicode_str *token, int *index ) { - int index; - struct unicode_str token; - - token.str = NULL; - if (!get_path_token( name, &token )) return NULL; - if (access & KEY_WOW64_32KEY) key = find_wow64_subkey( key, &token ); - while (token.len) + token->str = NULL; + if (!get_path_token( name, token )) return NULL; + if (access & KEY_WOW64_32KEY) key = find_wow64_subkey( key, token ); + while (token->len) { - if (!(key = find_subkey( key, &token, &index ))) - { - set_error( STATUS_OBJECT_NAME_NOT_FOUND ); - return NULL; - } - get_path_token( name, &token ); - if (!token.len) break; - if (!(access & KEY_WOW64_64KEY)) key = find_wow64_subkey( key, &token ); + struct key *subkey; + if (!(subkey = find_subkey( key, token, index ))) break; + key = subkey; + get_path_token( name, token ); + if (!token->len) break; + if (!(access & KEY_WOW64_64KEY)) key = find_wow64_subkey( key, token ); if (!(key = follow_symlink( key, 0 ))) { set_error( STATUS_OBJECT_NAME_NOT_FOUND ); return NULL; } } + return key; +}
+/* open a subkey */ +static struct key *open_key( struct key *key, const struct unicode_str *name, unsigned int access, + unsigned int attributes ) +{ + int index; + struct unicode_str token; + + if (!(key = open_key_prefix( key, name, access, &token, &index ))) return NULL; + + if (token.len) + { + set_error( STATUS_OBJECT_NAME_NOT_FOUND ); + return NULL; + } if (!(access & KEY_WOW64_64KEY)) key = find_wow64_subkey( key, &token ); if (!(attributes & OBJ_OPENLINK) && !(key = follow_symlink( key, 0 ))) { @@ -695,24 +707,8 @@ static struct key *create_key( struct key *key, const struct unicode_str *name, return NULL; }
- token.str = NULL; - if (!get_path_token( name, &token )) return NULL; *created = 0; - if (access & KEY_WOW64_32KEY) key = find_wow64_subkey( key, &token ); - while (token.len) - { - struct key *subkey; - if (!(subkey = find_subkey( key, &token, &index ))) break; - key = subkey; - get_path_token( name, &token ); - if (!token.len) break; - if (!(access & KEY_WOW64_64KEY)) key = find_wow64_subkey( key, &token ); - if (!(key = follow_symlink( key, 0 ))) - { - set_error( STATUS_OBJECT_NAME_NOT_FOUND ); - return NULL; - } - } + if (!(key = open_key_prefix( key, name, access, &token, &index ))) return NULL;
if (!token.len) /* the key already exists */ {