~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/shell32/shellstring.c

Version: ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Copyright 2000 Juergen Schmied
  3  *
  4  * This library is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2.1 of the License, or (at your option) any later version.
  8  *
  9  * This library is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with this library; if not, write to the Free Software
 16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 17  */
 18 
 19 #include <string.h>
 20 #include <stdarg.h>
 21 #include <stdio.h>
 22 #include <ctype.h>
 23 #include <stdlib.h>
 24 
 25 #define NONAMELESSUNION
 26 #define NONAMELESSSTRUCT
 27 #include "windef.h"
 28 #include "winbase.h"
 29 #include "winnls.h"
 30 #include "wingdi.h"
 31 #include "winuser.h"
 32 #include "winreg.h"
 33 
 34 #include "shlobj.h"
 35 #include "shlwapi.h"
 36 #include "shell32_main.h"
 37 #include "undocshell.h"
 38 #include "wine/unicode.h"
 39 #include "wine/debug.h"
 40 
 41 WINE_DEFAULT_DEBUG_CHANNEL(shell);
 42 
 43 /************************* STRRET functions ****************************/
 44 
 45 BOOL WINAPI StrRetToStrNA(LPSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
 46 {
 47         TRACE("dest=%p len=0x%x strret=%p(%s) pidl=%p\n",
 48             dest,len,src,
 49             (src->uType == STRRET_WSTR) ? "STRRET_WSTR" :
 50             (src->uType == STRRET_CSTR) ? "STRRET_CSTR" :
 51             (src->uType == STRRET_OFFSET) ? "STRRET_OFFSET" : "STRRET_???",
 52             pidl);
 53 
 54     if (!dest)
 55         return FALSE;
 56 
 57         switch (src->uType)
 58         {
 59           case STRRET_WSTR:
 60             WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, dest, len, NULL, NULL);
 61             CoTaskMemFree(src->u.pOleStr);
 62             break;
 63 
 64           case STRRET_CSTR:
 65             lstrcpynA(dest, src->u.cStr, len);
 66             break;
 67 
 68           case STRRET_OFFSET:
 69             lstrcpynA(dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
 70             break;
 71 
 72           default:
 73             FIXME("unknown type!\n");
 74             if (len) *dest = '\0';
 75             return FALSE;
 76         }
 77         TRACE("-- %s\n", debugstr_a(dest) );
 78         return TRUE;
 79 }
 80 
 81 /************************************************************************/
 82 
 83 BOOL WINAPI StrRetToStrNW(LPWSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
 84 {
 85         TRACE("dest=%p len=0x%x strret=%p(%s) pidl=%p\n",
 86             dest,len,src,
 87             (src->uType == STRRET_WSTR) ? "STRRET_WSTR" :
 88             (src->uType == STRRET_CSTR) ? "STRRET_CSTR" :
 89             (src->uType == STRRET_OFFSET) ? "STRRET_OFFSET" : "STRRET_???",
 90             pidl);
 91 
 92     if (!dest)
 93         return FALSE;
 94 
 95         switch (src->uType)
 96         {
 97           case STRRET_WSTR:
 98             lstrcpynW(dest, src->u.pOleStr, len);
 99             CoTaskMemFree(src->u.pOleStr);
100             break;
101 
102           case STRRET_CSTR:
103             if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ) && len)
104                   dest[len-1] = 0;
105             break;
106 
107           case STRRET_OFFSET:
108             if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1, dest, len ) && len)
109                   dest[len-1] = 0;
110             break;
111 
112           default:
113             FIXME("unknown type!\n");
114             if (len) *dest = '\0';
115             return FALSE;
116         }
117         return TRUE;
118 }
119 
120 
121 /*************************************************************************
122  * StrRetToStrN                         [SHELL32.96]
123  *
124  * converts a STRRET to a normal string
125  *
126  * NOTES
127  *  the pidl is for STRRET OFFSET
128  */
129 BOOL WINAPI StrRetToStrNAW(LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
130 {
131         if(SHELL_OsIsUnicode())
132         return StrRetToStrNW(dest, len, src, pidl);
133     else
134         return StrRetToStrNA(dest, len, src, pidl);
135 }
136 
137 /************************* OLESTR functions ****************************/
138 
139 /************************************************************************
140  *      StrToOleStr                     [SHELL32.163]
141  *
142  */
143 int WINAPI StrToOleStrA (LPWSTR lpWideCharStr, LPCSTR lpMultiByteString)
144 {
145         TRACE("(%p, %p %s)\n",
146         lpWideCharStr, lpMultiByteString, debugstr_a(lpMultiByteString));
147 
148         return MultiByteToWideChar(0, 0, lpMultiByteString, -1, lpWideCharStr, MAX_PATH);
149 
150 }
151 int WINAPI StrToOleStrW (LPWSTR lpWideCharStr, LPCWSTR lpWString)
152 {
153         TRACE("(%p, %p %s)\n",
154         lpWideCharStr, lpWString, debugstr_w(lpWString));
155 
156         strcpyW (lpWideCharStr, lpWString );
157         return strlenW(lpWideCharStr);
158 }
159 
160 BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString)
161 {
162         if (SHELL_OsIsUnicode())
163           return StrToOleStrW (lpWideCharStr, lpString);
164         return StrToOleStrA (lpWideCharStr, lpString);
165 }
166 
167 /*************************************************************************
168  * StrToOleStrN                                 [SHELL32.79]
169  *  lpMulti, nMulti, nWide [IN]
170  *  lpWide [OUT]
171  */
172 BOOL WINAPI StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr)
173 {
174         TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_an(lpStrA,nStr), nStr);
175         return MultiByteToWideChar (0, 0, lpStrA, nStr, lpWide, nWide);
176 }
177 BOOL WINAPI StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr)
178 {
179         TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_wn(lpStrW, nStr), nStr);
180 
181         if (lstrcpynW (lpWide, lpStrW, nWide))
182         { return lstrlenW (lpWide);
183         }
184         return 0;
185 }
186 
187 BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr)
188 {
189         if (SHELL_OsIsUnicode())
190           return StrToOleStrNW (lpWide, nWide, lpStr, nStr);
191         return StrToOleStrNA (lpWide, nWide, lpStr, nStr);
192 }
193 
194 /*************************************************************************
195  * OleStrToStrN                                 [SHELL32.78]
196  */
197 BOOL WINAPI OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle)
198 {
199         TRACE("(%p, %x, %s, %x)\n", lpStr, nStr, debugstr_wn(lpOle,nOle), nOle);
200         return WideCharToMultiByte (0, 0, lpOle, nOle, lpStr, nStr, NULL, NULL);
201 }
202 
203 BOOL WINAPI OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle)
204 {
205         TRACE("(%p, %x, %s, %x)\n", lpwStr, nwStr, debugstr_wn(lpOle,nOle), nOle);
206 
207         if (lstrcpynW ( lpwStr, lpOle, nwStr))
208         { return lstrlenW (lpwStr);
209         }
210         return 0;
211 }
212 
213 BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn)
214 {
215         if (SHELL_OsIsUnicode())
216           return OleStrToStrNW (lpOut, nOut, lpIn, nIn);
217         return OleStrToStrNA (lpOut, nOut, lpIn, nIn);
218 }
219 
220 
221 /*************************************************************************
222  * CheckEscapesA             [SHELL32.@]
223  *
224  * Checks a string for special characters which are not allowed in a path
225  * and encloses it in quotes if that is the case.
226  *
227  * PARAMS
228  *  string     [I/O] string to check and on return eventually quoted
229  *  len        [I]   length of string
230  *
231  * RETURNS
232  *  length of actual string
233  *
234  * NOTES
235  *  Not really sure if this function returns actually a value at all. 
236  */
237 DWORD WINAPI CheckEscapesA(
238         LPSTR   string,         /* [I/O]   string to check ??*/
239         DWORD   len)            /* [I]      is 0 */
240 {
241         LPWSTR wString;
242         DWORD ret = 0;
243 
244         TRACE("(%s %d)\n", debugstr_a(string), len);
245         wString = LocalAlloc(LPTR, len * sizeof(WCHAR));
246         if (wString)
247         {
248           MultiByteToWideChar(CP_ACP, 0, string, len, wString, len);
249           ret = CheckEscapesW(wString, len);
250           WideCharToMultiByte(CP_ACP, 0, wString, len, string, len, NULL, NULL);
251           LocalFree(wString);
252         }
253         return ret;
254 }
255 
256 static const WCHAR strEscapedChars[] = {' ','"',',',';','^',0};
257 
258 /*************************************************************************
259  * CheckEscapesW             [SHELL32.@]
260  *
261  * See CheckEscapesA.
262  */
263 DWORD WINAPI CheckEscapesW(
264         LPWSTR  string,
265         DWORD   len)
266 {
267         DWORD size = lstrlenW(string);
268         LPWSTR s, d;
269 
270         TRACE("(%s %d) stub\n", debugstr_w(string), len);
271 
272         if (StrPBrkW(string, strEscapedChars) && size + 2 <= len)
273         {
274           s = &string[size - 1];
275           d = &string[size + 2];
276           *d-- = 0;
277           *d-- = '"';
278           for (;d > string;)
279             *d-- = *s--;
280           *d = '"';
281           return size + 2;
282         }
283         return size;
284 }
285 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.