| 1 | /* $Id: shellstring.c,v 1.1 2000-08-30 13:52:56 sandervl Exp $ */ | 
|---|
| 2 | #ifdef __WIN32OS2__ | 
|---|
| 3 | #define ICOM_CINTERFACE 1 | 
|---|
| 4 | #include <odin.h> | 
|---|
| 5 | #endif | 
|---|
| 6 | #include <string.h> | 
|---|
| 7 | #include <stdio.h> | 
|---|
| 8 | #include <ctype.h> | 
|---|
| 9 | #include <stdlib.h> | 
|---|
| 10 |  | 
|---|
| 11 | #include "winnls.h" | 
|---|
| 12 | #include "winerror.h" | 
|---|
| 13 | #include "debugtools.h" | 
|---|
| 14 | #include "heap.h" | 
|---|
| 15 |  | 
|---|
| 16 | #include "shellapi.h" | 
|---|
| 17 | #include "shell32_main.h" | 
|---|
| 18 | #include "wine/undocshell.h" | 
|---|
| 19 | #include "wine/unicode.h" | 
|---|
| 20 |  | 
|---|
| 21 | DEFAULT_DEBUG_CHANNEL(shell); | 
|---|
| 22 |  | 
|---|
| 23 | /************************* STRRET functions ****************************/ | 
|---|
| 24 |  | 
|---|
| 25 | /************************************************************************* | 
|---|
| 26 | * StrRetToStrN                                 [SHELL32.96] | 
|---|
| 27 | * | 
|---|
| 28 | * converts a STRRET to a normal string | 
|---|
| 29 | * | 
|---|
| 30 | * NOTES | 
|---|
| 31 | *  the pidl is for STRRET OFFSET | 
|---|
| 32 | */ | 
|---|
| 33 | HRESULT WINAPI StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl) | 
|---|
| 34 | { | 
|---|
| 35 | return StrRetToBufA( src, pidl, dest, len ); | 
|---|
| 36 | } | 
|---|
| 37 |  | 
|---|
| 38 | HRESULT WINAPI StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl) | 
|---|
| 39 | { | 
|---|
| 40 | return StrRetToBufW( src, pidl, dest, len ); | 
|---|
| 41 | } | 
|---|
| 42 |  | 
|---|
| 43 | HRESULT WINAPI StrRetToStrNAW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl) | 
|---|
| 44 | { | 
|---|
| 45 | if(SHELL_OsIsUnicode()) | 
|---|
| 46 | return StrRetToStrNW (dest, len, src, pidl); | 
|---|
| 47 | return StrRetToStrNA (dest, len, src, pidl); | 
|---|
| 48 | } | 
|---|
| 49 |  | 
|---|
| 50 | /************************* OLESTR functions ****************************/ | 
|---|
| 51 |  | 
|---|
| 52 | /************************************************************************ | 
|---|
| 53 | *      StrToOleStr                     [SHELL32.163] | 
|---|
| 54 | * | 
|---|
| 55 | */ | 
|---|
| 56 | int WINAPI StrToOleStrA (LPWSTR lpWideCharStr, LPCSTR lpMultiByteString) | 
|---|
| 57 | { | 
|---|
| 58 | TRACE("(%p, %p %s)\n", | 
|---|
| 59 | lpWideCharStr, lpMultiByteString, debugstr_a(lpMultiByteString)); | 
|---|
| 60 |  | 
|---|
| 61 | return MultiByteToWideChar(0, 0, lpMultiByteString, -1, lpWideCharStr, MAX_PATH); | 
|---|
| 62 |  | 
|---|
| 63 | } | 
|---|
| 64 | int WINAPI StrToOleStrW (LPWSTR lpWideCharStr, LPCWSTR lpWString) | 
|---|
| 65 | { | 
|---|
| 66 | TRACE("(%p, %p %s)\n", | 
|---|
| 67 | lpWideCharStr, lpWString, debugstr_w(lpWString)); | 
|---|
| 68 |  | 
|---|
| 69 | strcpyW (lpWideCharStr, lpWString ); | 
|---|
| 70 | return strlenW(lpWideCharStr); | 
|---|
| 71 | } | 
|---|
| 72 |  | 
|---|
| 73 | BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString) | 
|---|
| 74 | { | 
|---|
| 75 | if (SHELL_OsIsUnicode()) | 
|---|
| 76 | return StrToOleStrW (lpWideCharStr, lpString); | 
|---|
| 77 | return StrToOleStrA (lpWideCharStr, lpString); | 
|---|
| 78 | } | 
|---|
| 79 |  | 
|---|
| 80 | /************************************************************************* | 
|---|
| 81 | * StrToOleStrN                                 [SHELL32.79] | 
|---|
| 82 | *  lpMulti, nMulti, nWide [IN] | 
|---|
| 83 | *  lpWide [OUT] | 
|---|
| 84 | */ | 
|---|
| 85 | BOOL WINAPI StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr) | 
|---|
| 86 | { | 
|---|
| 87 | TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_an(lpStrA,nStr), nStr); | 
|---|
| 88 | return MultiByteToWideChar (0, 0, lpStrA, nStr, lpWide, nWide); | 
|---|
| 89 | } | 
|---|
| 90 | BOOL WINAPI StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr) | 
|---|
| 91 | { | 
|---|
| 92 | TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_wn(lpStrW, nStr), nStr); | 
|---|
| 93 |  | 
|---|
| 94 | if (lstrcpynW (lpWide, lpStrW, nWide)) | 
|---|
| 95 | { return lstrlenW (lpWide); | 
|---|
| 96 | } | 
|---|
| 97 | return 0; | 
|---|
| 98 | } | 
|---|
| 99 |  | 
|---|
| 100 | BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr) | 
|---|
| 101 | { | 
|---|
| 102 | if (SHELL_OsIsUnicode()) | 
|---|
| 103 | return StrToOleStrNW (lpWide, nWide, lpStr, nStr); | 
|---|
| 104 | return StrToOleStrNA (lpWide, nWide, lpStr, nStr); | 
|---|
| 105 | } | 
|---|
| 106 |  | 
|---|
| 107 | /************************************************************************* | 
|---|
| 108 | * OleStrToStrN                                 [SHELL32.78] | 
|---|
| 109 | */ | 
|---|
| 110 | BOOL WINAPI OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle) | 
|---|
| 111 | { | 
|---|
| 112 | TRACE("(%p, %x, %s, %x)\n", lpStr, nStr, debugstr_wn(lpOle,nOle), nOle); | 
|---|
| 113 | return WideCharToMultiByte (0, 0, lpOle, nOle, lpStr, nStr, NULL, NULL); | 
|---|
| 114 | } | 
|---|
| 115 |  | 
|---|
| 116 | BOOL WINAPI OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle) | 
|---|
| 117 | { | 
|---|
| 118 | TRACE("(%p, %x, %s, %x)\n", lpwStr, nwStr, debugstr_wn(lpOle,nOle), nOle); | 
|---|
| 119 |  | 
|---|
| 120 | if (lstrcpynW ( lpwStr, lpOle, nwStr)) | 
|---|
| 121 | { return lstrlenW (lpwStr); | 
|---|
| 122 | } | 
|---|
| 123 | return 0; | 
|---|
| 124 | } | 
|---|
| 125 |  | 
|---|
| 126 | BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn) | 
|---|
| 127 | { | 
|---|
| 128 | if (SHELL_OsIsUnicode()) | 
|---|
| 129 | return OleStrToStrNW (lpOut, nOut, lpIn, nIn); | 
|---|
| 130 | return OleStrToStrNA (lpOut, nOut, lpIn, nIn); | 
|---|
| 131 | } | 
|---|