| 1 | /* $Id: shlwapi.cpp,v 1.9 2000-10-02 13:37:10 sandervl Exp $ */ | 
|---|
| 2 |  | 
|---|
| 3 | /* | 
|---|
| 4 | * Win32 URL-handling APIs for OS/2 | 
|---|
| 5 | * | 
|---|
| 6 | * Copyright 1999      Patrick Haller <phaller@gmx.net> | 
|---|
| 7 | * | 
|---|
| 8 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 9 | * | 
|---|
| 10 | * Copyright 1996,1998 Marcus Meissner | 
|---|
| 11 | * Copyright 1996 Jukka Iivonen | 
|---|
| 12 | * Copyright 1997 Uwe Bonnes | 
|---|
| 13 | * Copyright 1999 Jens Wiessner | 
|---|
| 14 | * | 
|---|
| 15 | * Two functions (WINE_StringFromCLSID and StringFromGUID2) are directly | 
|---|
| 16 | * borrowed from ole32/clsid.cpp. This is to avoid the direct dependency | 
|---|
| 17 | * between SHLWAPI.DLL and the OLE32.DLL. | 
|---|
| 18 | */ | 
|---|
| 19 |  | 
|---|
| 20 |  | 
|---|
| 21 | #include <odin.h> | 
|---|
| 22 | #include <odinwrap.h> | 
|---|
| 23 | #include <os2sel.h> | 
|---|
| 24 |  | 
|---|
| 25 | #include <string.h> | 
|---|
| 26 | #include <ctype.h> | 
|---|
| 27 | #include <wctype.h> | 
|---|
| 28 | #define HAVE_WCTYPE_H | 
|---|
| 29 | #include <odin.h> | 
|---|
| 30 |  | 
|---|
| 31 | #define ICOM_CINTERFACE 1 | 
|---|
| 32 | #define CINTERFACE 1 | 
|---|
| 33 |  | 
|---|
| 34 | #include "debugtools.h" | 
|---|
| 35 | #include "winnls.h" | 
|---|
| 36 | #include "winversion.h" | 
|---|
| 37 | #include "winreg.h" | 
|---|
| 38 | #include "crtdll.h" | 
|---|
| 39 |  | 
|---|
| 40 | #include <heapstring.h> | 
|---|
| 41 | #include <misc.h> | 
|---|
| 42 | #include <win\shell.h> | 
|---|
| 43 | #include <win\winerror.h> | 
|---|
| 44 |  | 
|---|
| 45 | // import OLE support | 
|---|
| 46 | #include <win/wtypes.h> | 
|---|
| 47 | #define OLE_OK 0 | 
|---|
| 48 |  | 
|---|
| 49 |  | 
|---|
| 50 | ODINDEBUGCHANNEL(SHLWAPI) | 
|---|
| 51 |  | 
|---|
| 52 | #include "shlwapi.h" | 
|---|
| 53 |  | 
|---|
| 54 |  | 
|---|
| 55 | /* | 
|---|
| 56 | * This enables procedures to automatically take care or | 
|---|
| 57 | * required unicode conversion or not. | 
|---|
| 58 | */ | 
|---|
| 59 |  | 
|---|
| 60 | BOOL VERSION_OsIsUnicode(void) | 
|---|
| 61 | { | 
|---|
| 62 | static version = 0; | 
|---|
| 63 |  | 
|---|
| 64 | if(version == 0) { | 
|---|
| 65 | version = GetVersion(); | 
|---|
| 66 | } | 
|---|
| 67 | /* if high-bit of version is 0, we are emulating NT */ | 
|---|
| 68 | return !(version & 0x80000000); | 
|---|
| 69 | } | 
|---|
| 70 |  | 
|---|
| 71 |  | 
|---|
| 72 | // ---------------------------------------------------------------------- | 
|---|
| 73 | // WINE_StringFromCLSID | 
|---|
| 74 | // ---------------------------------------------------------------------- | 
|---|
| 75 | HRESULT WINAPI WINE_StringFromCLSID(const CLSID *rclsid, LPSTR idstr) | 
|---|
| 76 | { | 
|---|
| 77 | //    dprintf(("OLE32: WINE_StringFromCLSID")); | 
|---|
| 78 |  | 
|---|
| 79 | if (rclsid == NULL) | 
|---|
| 80 | { | 
|---|
| 81 | dprintf(("       clsid: (NULL)")); | 
|---|
| 82 | *idstr = 0; | 
|---|
| 83 | return E_FAIL; | 
|---|
| 84 | } | 
|---|
| 85 |  | 
|---|
| 86 | // Setup new string... | 
|---|
| 87 | sprintf(idstr, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", | 
|---|
| 88 | rclsid->Data1, | 
|---|
| 89 | rclsid->Data2, | 
|---|
| 90 | rclsid->Data3, | 
|---|
| 91 | rclsid->Data4[0], | 
|---|
| 92 | rclsid->Data4[1], | 
|---|
| 93 | rclsid->Data4[2], | 
|---|
| 94 | rclsid->Data4[3], | 
|---|
| 95 | rclsid->Data4[4], | 
|---|
| 96 | rclsid->Data4[5], | 
|---|
| 97 | rclsid->Data4[6], | 
|---|
| 98 | rclsid->Data4[7]); | 
|---|
| 99 |  | 
|---|
| 100 | //    dprintf(("       clsid: %s", idstr)); | 
|---|
| 101 |  | 
|---|
| 102 | return OLE_OK; | 
|---|
| 103 | } | 
|---|
| 104 |  | 
|---|
| 105 | // ---------------------------------------------------------------------- | 
|---|
| 106 | // StringFromGUID2 | 
|---|
| 107 | // ---------------------------------------------------------------------- | 
|---|
| 108 | int WINAPI StringFromGUID2(REFGUID rguid, LPOLESTR lpsz, int cbMax) | 
|---|
| 109 | { | 
|---|
| 110 | // NB cbMax is a CHARACTER count not a BYTE count... :-) | 
|---|
| 111 | char        tmp[50]; | 
|---|
| 112 | size_t      strLen; | 
|---|
| 113 |  | 
|---|
| 114 | // Setup new string... | 
|---|
| 115 | WINE_StringFromCLSID(rguid, tmp); | 
|---|
| 116 |  | 
|---|
| 117 | strLen = (strlen(tmp) + 1); | 
|---|
| 118 | if (strLen > cbMax) | 
|---|
| 119 | strLen = cbMax; | 
|---|
| 120 |  | 
|---|
| 121 | AsciiToUnicodeN(tmp, lpsz, strLen); | 
|---|
| 122 |  | 
|---|
| 123 | return strLen;  // Num CHARACTERS including 0 terminator | 
|---|
| 124 | } | 
|---|
| 125 |  | 
|---|
| 126 |  | 
|---|
| 127 | /***************************************************************************** | 
|---|
| 128 | * Name      : DllGetVersion | 
|---|
| 129 | * Purpose   : Return version information about the DLL used | 
|---|
| 130 | * Parameters: | 
|---|
| 131 | * Variables : | 
|---|
| 132 | * Result    : | 
|---|
| 133 | * Remark    : SHLWAPI.446 | 
|---|
| 134 | * Status    : UNTESTED | 
|---|
| 135 | * | 
|---|
| 136 | * Author    : | 
|---|
| 137 | *****************************************************************************/ | 
|---|
| 138 |  | 
|---|
| 139 | typedef struct tagDLLVERSION | 
|---|
| 140 | { | 
|---|
| 141 | DWORD dwLength; // == 0x14 | 
|---|
| 142 | DWORD dwMajorVersion; | 
|---|
| 143 | DWORD dwMinorVersion; | 
|---|
| 144 | DWORD dwRevision; | 
|---|
| 145 | DWORD dwBuildNumber; | 
|---|
| 146 | } DLLVERSION, *LPDLLVERSION; | 
|---|
| 147 |  | 
|---|
| 148 |  | 
|---|
| 149 | ODINFUNCTION1(DWORD,        DllGetVersion, | 
|---|
| 150 | LPDLLVERSION, lpBuffer) | 
|---|
| 151 | { | 
|---|
| 152 | if (lpBuffer == NULL) | 
|---|
| 153 | return E_INVALIDARG; // error code: invalid parameters | 
|---|
| 154 |  | 
|---|
| 155 | if (IsBadWritePtr(lpBuffer, | 
|---|
| 156 | 20)) | 
|---|
| 157 | return E_INVALIDARG; | 
|---|
| 158 |  | 
|---|
| 159 | if (lpBuffer->dwLength != sizeof(DLLVERSION)) | 
|---|
| 160 | return E_INVALIDARG; | 
|---|
| 161 |  | 
|---|
| 162 | // our current version is 5.0.2314.1000 | 
|---|
| 163 | lpBuffer->dwMajorVersion = 5; | 
|---|
| 164 | //lpBuffer->dwMinorVersion = 0;  // @@@PH not touched in windows code ? | 
|---|
| 165 | lpBuffer->dwRevision     = 2314; | 
|---|
| 166 | lpBuffer->dwBuildNumber  = 1; | 
|---|
| 167 |  | 
|---|
| 168 | return ERROR_SUCCESS; | 
|---|
| 169 | } | 
|---|