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