home *** CD-ROM | disk | FTP | other *** search
- /*++
-
- Copyright (c) 1999 Microsoft Corporation
-
- Module Name:
-
- util.cpp
-
- Abstract:
-
- utility methods.
-
- --*/
-
- #pragma warning(disable:4514) // "unreferenced inline function" warning
-
- #pragma warning(disable:4201) // "nameless struct/union" warning
- #include <windows.h>
- #pragma warning(default:4201) // "nameless struct/union" warning
-
-
- //------------------------------------------------------------------------------
- // GUID2StringA()
- //
- // Utility function: convert a GUID into the ANSI string representation.
- //------------------------------------------------------------------------------
- VOID
- GUID2StringA(
- REFGUID rguid,
- LPSTR lpsz )
- {
- int i;
- LPSTR p = lpsz;
- static const CHAR szDigits[] = "0123456789ABCDEF";
- static const BYTE GuidMap[] = { 3, 2, 1, 0, '-', 5, 4, '-', 7, 6, '-',
- 8, 9, '-', 10, 11, 12, 13, 14, 15 };
-
- const BYTE * pBytes = (const BYTE *)&rguid;
-
- *p++ = '{';
-
- for (i = 0; i < sizeof(GuidMap); i++)
- {
- if (GuidMap[i] == '-')
- {
- *p++ = '-';
- }
- else
- {
- *p++ = szDigits[ (pBytes[GuidMap[i]] & 0xF0) >> 4 ];
- *p++ = szDigits[ (pBytes[GuidMap[i]] & 0x0F) ];
- }
- }
- *p++ = '}';
- *p = '\0';
- }
-
-
-
- //------------------------------------------------------------------------------
- // AnsiTranslateChars()
- //
- // NB: chFrom cannot be any character that can be a lead byte.
- //------------------------------------------------------------------------------
- VOID AnsiTranslateChars(LPSTR psz,CHAR chFrom,CHAR chTo)
- {
- if( psz != NULL )
- {
- while( *psz )
- {
- if ( *psz == chFrom )
- *psz = chTo;
-
- psz = CharNext(psz);
- }
- }
- }
-