Small dll interfaces cleanups.
[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 "winversion.h"
10 #include "heap.h"
11
12 #include "shellapi.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(VERSION_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         if (lstrcpyW (lpWideCharStr, lpWString ))
65         { return lstrlenW (lpWideCharStr);
66         }
67         return 0;
68 }
69
70 BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString)
71 {
72         if (VERSION_OsIsUnicode())
73           return StrToOleStrW (lpWideCharStr, lpString);
74         return StrToOleStrA (lpWideCharStr, lpString);
75 }
76
77 /*************************************************************************
78  * StrToOleStrN                                 [SHELL32.79]
79  *  lpMulti, nMulti, nWide [IN]
80  *  lpWide [OUT]
81  */
82 BOOL WINAPI StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr) 
83 {
84         TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_an(lpStrA,nStr), nStr);
85         return MultiByteToWideChar (0, 0, lpStrA, nStr, lpWide, nWide);
86 }
87 BOOL WINAPI StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr) 
88 {
89         TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_wn(lpStrW, nStr), nStr);
90
91         if (lstrcpynW (lpWide, lpStrW, nWide))
92         { return lstrlenW (lpWide);
93         }
94         return 0;
95 }
96
97 BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr) 
98 {
99         if (VERSION_OsIsUnicode())
100           return StrToOleStrNW (lpWide, nWide, lpStr, nStr);
101         return StrToOleStrNA (lpWide, nWide, lpStr, nStr);
102 }
103
104 /*************************************************************************
105  * OleStrToStrN                                 [SHELL32.78]
106  */
107 BOOL WINAPI OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle) 
108 {
109         TRACE("(%p, %x, %s, %x)\n", lpStr, nStr, debugstr_wn(lpOle,nOle), nOle);
110         return WideCharToMultiByte (0, 0, lpOle, nOle, lpStr, nStr, NULL, NULL);
111 }
112
113 BOOL WINAPI OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle) 
114 {
115         TRACE("(%p, %x, %s, %x)\n", lpwStr, nwStr, debugstr_wn(lpOle,nOle), nOle);
116
117         if (lstrcpynW ( lpwStr, lpOle, nwStr))
118         { return lstrlenW (lpwStr);
119         }
120         return 0;
121 }
122
123 BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn) 
124 {
125         if (VERSION_OsIsUnicode())
126           return OleStrToStrNW (lpOut, nOut, lpIn, nIn);
127         return OleStrToStrNA (lpOut, nOut, lpIn, nIn);
128 }