2 * Helper functions for debugging
4 * Copyright 1998, 2002 Juergen Schmied
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(pidl);
33 LPITEMIDLIST _dbg_ILGetNext(LPITEMIDLIST pidl)
42 pidl = (LPITEMIDLIST) (((LPBYTE)pidl)+len);
49 BOOL _dbg_ILIsDesktop(LPCITEMIDLIST pidl)
51 return ( !pidl || (pidl && pidl->mkid.cb == 0x00) );
54 LPPIDLDATA _dbg_ILGetDataPointer(LPITEMIDLIST pidl)
56 if(pidl && pidl->mkid.cb != 0x00)
57 return (LPPIDLDATA) &(pidl->mkid.abID);
61 LPSTR _dbg_ILGetTextPointer(LPCITEMIDLIST pidl)
63 LPPIDLDATA pdata =_dbg_ILGetDataPointer(pidl);
77 return (LPSTR)&(pdata->u.drive.szDriveName);
84 return (LPSTR)&(pdata->u.file.szNames);
90 return (LPSTR)&(pdata->u.network.szNames);
96 LPSTR _dbg_ILGetSTextPointer(LPCITEMIDLIST pidl)
98 LPPIDLDATA pdata =_dbg_ILGetDataPointer(pidl);
108 return (LPSTR)(pdata->u.file.szNames + strlen (pdata->u.file.szNames) + 1);
111 return (LPSTR)(pdata->u.network.szNames + strlen (pdata->u.network.szNames) + 1);
117 REFIID _dbg_ILGetGUIDPointer(LPCITEMIDLIST pidl)
119 LPPIDLDATA pdata =_ILGetDataPointer(pidl);
127 return (REFIID) &(pdata->u.mycomp.guid);
130 TRACE("Unknown pidl type 0x%04x\n", pdata->type);
137 DWORD _dbg_ILSimpleGetText (LPCITEMIDLIST pidl, LPSTR szOut, UINT uOutSize)
142 char szTemp[MAX_PATH];
149 if (_dbg_ILIsDesktop(pidl))
152 if (szOut) strncpy(szOut, "Desktop", uOutSize);
153 dwReturn = strlen ("Desktop");
155 else if (( szSrc = _dbg_ILGetTextPointer(pidl) ))
158 if (szOut) strncpy(szOut, szSrc, uOutSize);
159 dwReturn = strlen(szSrc);
161 else if (( riid = _dbg_ILGetGUIDPointer(pidl) ))
164 sprintf( szOut, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
165 riid->Data1, riid->Data2, riid->Data3,
166 riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
167 riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
168 dwReturn = strlen (szTemp);
180 void pdump (LPCITEMIDLIST pidl)
182 LPITEMIDLIST pidltemp = pidl;
184 if (!TRACE_ON(pidl)) return;
188 MESSAGE ("-------- pidl=NULL (Desktop)\n");
192 MESSAGE ("-------- pidl=%p\n", pidl);
193 if (pidltemp->mkid.cb)
198 LPPIDLDATA pData = _dbg_ILGetDataPointer(pidltemp);
199 DWORD type = pData->type;
200 LPSTR szLongName = _dbg_ILGetTextPointer(pidltemp);
201 LPSTR szShortName = _dbg_ILGetSTextPointer(pidltemp);
202 char szName[MAX_PATH];
204 _dbg_ILSimpleGetText(pidltemp, szName, MAX_PATH);
205 if( PT_FOLDER == type)
206 dwAttrib = pData->u.folder.uFileAttribs;
207 else if( PT_VALUE == type)
208 dwAttrib = pData->u.file.uFileAttribs;
210 MESSAGE ("-- pidl=%p size=%u type=%lx attr=0x%08lx name=%s (%s,%s)\n",
211 pidltemp, pidltemp->mkid.cb,type,dwAttrib,szName,debugstr_a(szLongName), debugstr_a(szShortName));
213 pidltemp = _dbg_ILGetNext(pidltemp);
215 } while (pidltemp->mkid.cb);
219 MESSAGE ("empty pidl (Desktop)\n");
224 #define BYTES_PRINTED 32
225 BOOL pcheck (LPCITEMIDLIST pidl)
227 DWORD type, ret=TRUE;
228 LPITEMIDLIST pidltemp = pidl;
230 if (pidltemp && pidltemp->mkid.cb)
232 { type = _dbg_ILGetDataPointer(pidltemp)->type;
253 char szTemp[BYTES_PRINTED*4 + 1];
257 memset(szTemp, ' ', BYTES_PRINTED*4 + 1);
258 for ( i = 0; (i<pidltemp->mkid.cb) && (i<BYTES_PRINTED); i++)
260 c = ((unsigned char *)pidltemp)[i];
262 szTemp[i*3+0] = ((c>>4)>9)? (c>>4)+55 : (c>>4)+48;
263 szTemp[i*3+1] = ((0x0F&c)>9)? (0x0F&c)+55 : (0x0F&c)+48;
265 szTemp[i+BYTES_PRINTED*3] = (c>=0x20 && c <=0x80) ? c : '.';
267 szTemp[BYTES_PRINTED*4] = 0x00;
268 ERR("unknown IDLIST type size=%u type=%lx\n%s\n",pidltemp->mkid.cb,type, szTemp);
272 pidltemp = _dbg_ILGetNext(pidltemp);
273 } while (pidltemp->mkid.cb);