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