From: Detlef Riekenberg Subject: [PATCH 1/2] mountmgr: Make parse_uuid visible, when hal or dbus/udisks is used [try 4] Message-Id: <1311335756-9824-1-git-send-email-wine.dev@web.de> Date: Fri, 22 Jul 2011 13:55:55 +0200 try 2: make parse_uuid only visible, when hal or dbus/udisks is used try 3: resend without changes try 4: Add a comment as reminder to parse NTFS serial number -- By by ... Detlef --- dlls/mountmgr.sys/device.c | 32 ++++++++++++++++++++++++++++++++ dlls/mountmgr.sys/hal.c | 27 --------------------------- dlls/mountmgr.sys/mountmgr.h | 1 + 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c index a3aa81c..9537551 100644 --- a/dlls/mountmgr.sys/device.c +++ b/dlls/mountmgr.sys/device.c @@ -121,6 +121,38 @@ static char *strdupA( const char *str ) return ret; } +#if defined (SONAME_LIBDBUS_1) || defined (SONAME_LIBHAL) +GUID *parse_uuid( GUID *guid, const char *str ) +{ + /* standard uuid format */ + if (strlen(str) == 36) + { + UNICODE_STRING strW; + WCHAR buffer[39]; + + if (MultiByteToWideChar( CP_UNIXCP, 0, str, 36, buffer + 1, 36 )) + { + buffer[0] = '{'; + buffer[37] = '}'; + buffer[38] = 0; + RtlInitUnicodeString( &strW, buffer ); + if (!RtlGUIDFromString( &strW, guid )) return guid; + } + } + + /* ToDo: Check for NTFS serial number */ + + /* check for xxxx-xxxx format (FAT serial number) */ + if (strlen(str) == 9 && str[4] == '-') + { + memset( guid, 0, sizeof(*guid) ); + if (sscanf( str, "%hx-%hx", &guid->Data2, &guid->Data3 ) == 2) return guid; + } + + return NULL; +} +#endif + static const GUID *get_default_uuid( int letter ) { static GUID guid; diff --git a/dlls/mountmgr.sys/hal.c b/dlls/mountmgr.sys/hal.c index 82a70e9..ff10a3e 100644 --- a/dlls/mountmgr.sys/hal.c +++ b/dlls/mountmgr.sys/hal.c @@ -106,33 +106,6 @@ static LONG WINAPI assert_fault(EXCEPTION_POINTERS *eptr) return EXCEPTION_CONTINUE_SEARCH; } -static GUID *parse_uuid( GUID *guid, const char *str ) -{ - /* standard uuid format */ - if (strlen(str) == 36) - { - UNICODE_STRING strW; - WCHAR buffer[39]; - - if (MultiByteToWideChar( CP_UNIXCP, 0, str, 36, buffer + 1, 36 )) - { - buffer[0] = '{'; - buffer[37] = '}'; - buffer[38] = 0; - RtlInitUnicodeString( &strW, buffer ); - if (!RtlGUIDFromString( &strW, guid )) return guid; - } - } - - /* check for xxxx-xxxx format (FAT serial number) */ - if (strlen(str) == 9 && str[4] == '-') - { - memset( guid, 0, sizeof(*guid) ); - if (sscanf( str, "%hx-%hx", &guid->Data2, &guid->Data3 ) == 2) return guid; - } - return NULL; -} - /* HAL callback for new device */ static void new_device( LibHalContext *ctx, const char *udi ) { diff --git a/dlls/mountmgr.sys/mountmgr.h b/dlls/mountmgr.sys/mountmgr.h index a47a3e3..a8e4389 100644 --- a/dlls/mountmgr.sys/mountmgr.h +++ b/dlls/mountmgr.sys/mountmgr.h @@ -52,6 +52,7 @@ enum device_type DEVICE_RAMDISK }; +extern GUID *parse_uuid( GUID *guid, const char *str ) DECLSPEC_HIDDEN; extern NTSTATUS add_volume( const char *udi, const char *device, const char *mount_point, enum device_type type, const GUID *guid ) DECLSPEC_HIDDEN; extern NTSTATUS remove_volume( const char *udi ) DECLSPEC_HIDDEN; -- 1.7.5.4