- Use OBJ_CASE_INSENSITIVE in object lookup.

- Remove case_sensitive flag from namespace.
- Remove todo_wine from now succeeding tests.
This commit is contained in:
Vitaliy Margolen 2005-11-01 10:22:38 +00:00 committed by Alexandre Julliard
parent a9a689c592
commit 1ca6e899ec
5 changed files with 17 additions and 23 deletions

View File

@ -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);

View File

@ -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() );

View File

@ -28,6 +28,8 @@
#include <string.h>
#include <unistd.h>
#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;

View File

@ -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 );

View File

@ -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 */