From 1ca6e899ec5b86374665fb50729fe22e9b84a52a Mon Sep 17 00:00:00 2001 From: Vitaliy Margolen Date: Tue, 1 Nov 2005 10:22:38 +0000 Subject: [PATCH] - Use OBJ_CASE_INSENSITIVE in object lookup. - Remove case_sensitive flag from namespace. - Remove todo_wine from now succeeding tests. --- dlls/ntdll/tests/om.c | 4 ++-- server/main.c | 2 +- server/object.c | 30 ++++++++++++------------------ server/object.h | 2 +- server/winstation.c | 2 +- 5 files changed, 17 insertions(+), 23 deletions(-) diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c index 00e3141dbc3..d995cf7459c 100644 --- a/dlls/ntdll/tests/om.c +++ b/dlls/ntdll/tests/om.c @@ -63,7 +63,7 @@ void test_case_sensitive (void) pRtlInitUnicodeString(&str, buffer3); InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, 0, NULL); status = pNtOpenMutant(&h, GENERIC_ALL, &attr); - todo_wine ok(status == STATUS_OBJECT_TYPE_MISMATCH, + ok(status == STATUS_OBJECT_TYPE_MISMATCH, "NtOpenMutant should have failed with STATUS_OBJECT_TYPE_MISMATCH got(%08lx)\n", status); pNtClose(Mutant); @@ -71,7 +71,7 @@ void test_case_sensitive (void) pRtlInitUnicodeString(&str, buffer4); InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, 0, NULL); status = pNtCreateMutant(&Mutant, GENERIC_ALL, &attr, FALSE); - todo_wine ok(status == STATUS_OBJECT_NAME_COLLISION, + ok(status == STATUS_OBJECT_NAME_COLLISION, "NtCreateMutant should have failed with STATUS_OBJECT_NAME_COLLISION got(%08lx)\n", status); status = pNtCreateEvent(&h, GENERIC_ALL, &attr, FALSE, FALSE); diff --git a/server/main.c b/server/main.c index 3e258682114..6609a3aae00 100644 --- a/server/main.c +++ b/server/main.c @@ -130,7 +130,7 @@ int main( int argc, char *argv[] ) sock_init(); open_master_socket(); - sync_namespace = create_namespace( 37, TRUE ); + sync_namespace = create_namespace( 37 ); setvbuf( stderr, NULL, _IOLBF, 0 ); if (debug_level) fprintf( stderr, "wineserver: starting (pid=%ld)\n", (long) getpid() ); diff --git a/server/object.c b/server/object.c index 26b0f29d16a..342ce0c1039 100644 --- a/server/object.c +++ b/server/object.c @@ -28,6 +28,8 @@ #include #include +#include "winternl.h" + #include "file.h" #include "thread.h" #include "unicode.h" @@ -44,7 +46,6 @@ struct object_name struct namespace { unsigned int hash_size; /* size of hash table */ - int case_sensitive; /* are names case sensitive? */ struct list names[1]; /* array of hash entry lists */ }; @@ -92,8 +93,7 @@ static int get_name_hash( const struct namespace *namespace, const WCHAR *name, { WCHAR hash = 0; len /= sizeof(WCHAR); - if (namespace->case_sensitive) while (len--) hash ^= *name++; - else while (len--) hash ^= tolowerW(*name++); + while (len--) hash ^= tolowerW(*name++); return hash % namespace->hash_size; } @@ -233,29 +233,24 @@ struct object *find_object( const struct namespace *namespace, const WCHAR *name if (!name || !len) return NULL; list = &namespace->names[ get_name_hash( namespace, name, len ) ]; - if (namespace->case_sensitive) + LIST_FOR_EACH( p, list ) { - LIST_FOR_EACH( p, list ) + const struct object_name *ptr = LIST_ENTRY( p, const struct object_name, entry ); + if (ptr->len != len) continue; + if (attributes & OBJ_CASE_INSENSITIVE) { - const struct object_name *ptr = LIST_ENTRY( p, const struct object_name, entry ); - if (ptr->len != len) continue; - if (!memcmp( ptr->name, name, len )) return grab_object( ptr->obj ); - } - } - else - { - LIST_FOR_EACH( p, list ) - { - const struct object_name *ptr = LIST_ENTRY( p, const struct object_name, entry ); - if (ptr->len != len) continue; if (!strncmpiW( ptr->name, name, len/sizeof(WCHAR) )) return grab_object( ptr->obj ); } + else + { + if (!memcmp( ptr->name, name, len )) return grab_object( ptr->obj ); + } } return NULL; } /* allocate a namespace */ -struct namespace *create_namespace( unsigned int hash_size, int case_sensitive ) +struct namespace *create_namespace( unsigned int hash_size ) { struct namespace *namespace; unsigned int i; @@ -264,7 +259,6 @@ struct namespace *create_namespace( unsigned int hash_size, int case_sensitive ) if (namespace) { namespace->hash_size = hash_size; - namespace->case_sensitive = case_sensitive; for (i = 0; i < hash_size; i++) list_init( &namespace->names[i] ); } return namespace; diff --git a/server/object.h b/server/object.h index a360ebe41e3..33bab519268 100644 --- a/server/object.h +++ b/server/object.h @@ -95,7 +95,7 @@ extern const WCHAR *get_object_name( struct object *obj, size_t *len ); extern void dump_object_name( struct object *obj ); extern void *create_named_object( struct namespace *namespace, const struct object_ops *ops, const WCHAR *name, size_t len, unsigned int attributes ); -extern struct namespace *create_namespace( unsigned int hash_size, int case_sensitive ); +extern struct namespace *create_namespace( unsigned int hash_size ); /* grab/release_object can take any pointer, but you better make sure */ /* that the thing pointed to starts with a struct object... */ extern struct object *grab_object( void *obj ); diff --git a/server/winstation.c b/server/winstation.c index 0b457c45f41..486b2e228ed 100644 --- a/server/winstation.c +++ b/server/winstation.c @@ -84,7 +84,7 @@ static struct winstation *create_winstation( const WCHAR *name, size_t len, unsi { struct winstation *winstation; - if (!winstation_namespace && !(winstation_namespace = create_namespace( 7, FALSE ))) + if (!winstation_namespace && !(winstation_namespace = create_namespace( 7 ))) return NULL; if (memchrW( name, '\\', len / sizeof(WCHAR) )) /* no backslash allowed in name */