wininet: Partial implementation of InternetGet/SetCookieEx.
[wine] / dlls / wininet / cookie.c
1 /*
2  * Wininet - cookie handling stuff
3  *
4  * Copyright 2002 TransGaming Technologies Inc.
5  *
6  * David Hammerton
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22
23 #include "config.h"
24 #include "wine/port.h"
25
26 #include <stdarg.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #ifdef HAVE_UNISTD_H
31 # include <unistd.h>
32 #endif
33
34 #include "windef.h"
35 #include "winbase.h"
36 #include "wininet.h"
37 #include "winerror.h"
38
39 #include "wine/debug.h"
40 #include "internet.h"
41
42 #define RESPONSE_TIMEOUT        30            /* FROM internet.c */
43
44
45 WINE_DEFAULT_DEBUG_CHANNEL(wininet);
46
47 /* FIXME
48  *     Cookies are currently memory only.
49  *     Cookies are NOT THREAD SAFE
50  *     Cookies could use A LOT OF MEMORY. We need some kind of memory management here!
51  *     Cookies should care about the expiry time
52  */
53
54 typedef struct _cookie_domain cookie_domain;
55 typedef struct _cookie cookie;
56
57 struct _cookie
58 {
59     struct list entry;
60
61     struct _cookie_domain *parent;
62
63     LPWSTR lpCookieName;
64     LPWSTR lpCookieData;
65     time_t expiry; /* FIXME: not used */
66 };
67
68 struct _cookie_domain
69 {
70     struct list entry;
71
72     LPWSTR lpCookieDomain;
73     LPWSTR lpCookiePath;
74     struct list cookie_list;
75 };
76
77 static struct list domain_list = LIST_INIT(domain_list);
78
79 static cookie *COOKIE_addCookie(cookie_domain *domain, LPCWSTR name, LPCWSTR data);
80 static cookie *COOKIE_findCookie(cookie_domain *domain, LPCWSTR lpszCookieName);
81 static void COOKIE_deleteCookie(cookie *deadCookie, BOOL deleteDomain);
82 static cookie_domain *COOKIE_addDomain(LPCWSTR domain, LPCWSTR path);
83 static void COOKIE_deleteDomain(cookie_domain *deadDomain);
84
85
86 /* adds a cookie to the domain */
87 static cookie *COOKIE_addCookie(cookie_domain *domain, LPCWSTR name, LPCWSTR data)
88 {
89     cookie *newCookie = HeapAlloc(GetProcessHeap(), 0, sizeof(cookie));
90
91     list_init(&newCookie->entry);
92     newCookie->lpCookieName = NULL;
93     newCookie->lpCookieData = NULL;
94
95     if (name)
96     {
97         newCookie->lpCookieName = HeapAlloc(GetProcessHeap(), 0, (strlenW(name) + 1)*sizeof(WCHAR));
98         lstrcpyW(newCookie->lpCookieName, name);
99     }
100     if (data)
101     {
102         newCookie->lpCookieData = HeapAlloc(GetProcessHeap(), 0, (strlenW(data) + 1)*sizeof(WCHAR));
103         lstrcpyW(newCookie->lpCookieData, data);
104     }
105
106     TRACE("added cookie %p (data is %s)\n", newCookie, debugstr_w(data) );
107
108     list_add_tail(&domain->cookie_list, &newCookie->entry);
109     newCookie->parent = domain;
110     return newCookie;
111 }
112
113
114 /* finds a cookie in the domain matching the cookie name */
115 static cookie *COOKIE_findCookie(cookie_domain *domain, LPCWSTR lpszCookieName)
116 {
117     struct list * cursor;
118     TRACE("(%p, %s)\n", domain, debugstr_w(lpszCookieName));
119
120     LIST_FOR_EACH(cursor, &domain->cookie_list)
121     {
122         cookie *searchCookie = LIST_ENTRY(cursor, cookie, entry);
123         BOOL candidate = TRUE;
124         if (candidate && lpszCookieName)
125         {
126             if (candidate && !searchCookie->lpCookieName)
127                 candidate = FALSE;
128             if (candidate && strcmpW(lpszCookieName, searchCookie->lpCookieName) != 0)
129                 candidate = FALSE;
130         }
131         if (candidate)
132             return searchCookie;
133     }
134     return NULL;
135 }
136
137 /* removes a cookie from the list, if its the last cookie we also remove the domain */
138 static void COOKIE_deleteCookie(cookie *deadCookie, BOOL deleteDomain)
139 {
140     HeapFree(GetProcessHeap(), 0, deadCookie->lpCookieName);
141     HeapFree(GetProcessHeap(), 0, deadCookie->lpCookieData);
142     list_remove(&deadCookie->entry);
143
144     /* special case: last cookie, lets remove the domain to save memory */
145     if (list_empty(&deadCookie->parent->cookie_list) && deleteDomain)
146         COOKIE_deleteDomain(deadCookie->parent);
147     HeapFree(GetProcessHeap(), 0, deadCookie);
148 }
149
150 /* allocates a domain and adds it to the end */
151 static cookie_domain *COOKIE_addDomain(LPCWSTR domain, LPCWSTR path)
152 {
153     cookie_domain *newDomain = HeapAlloc(GetProcessHeap(), 0, sizeof(cookie_domain));
154
155     list_init(&newDomain->entry);
156     list_init(&newDomain->cookie_list);
157     newDomain->lpCookieDomain = NULL;
158     newDomain->lpCookiePath = NULL;
159
160     if (domain)
161     {
162         newDomain->lpCookieDomain = HeapAlloc(GetProcessHeap(), 0, (strlenW(domain) + 1)*sizeof(WCHAR));
163         strcpyW(newDomain->lpCookieDomain, domain);
164     }
165     if (path)
166     {
167         newDomain->lpCookiePath = HeapAlloc(GetProcessHeap(), 0, (strlenW(path) + 1)*sizeof(WCHAR));
168         lstrcpyW(newDomain->lpCookiePath, path);
169     }
170
171     list_add_tail(&domain_list, &newDomain->entry);
172
173     TRACE("Adding domain: %p\n", newDomain);
174     return newDomain;
175 }
176
177 static BOOL COOKIE_crackUrlSimple(LPCWSTR lpszUrl, LPWSTR hostName, int hostNameLen, LPWSTR path, int pathLen)
178 {
179     URL_COMPONENTSW UrlComponents;
180
181     UrlComponents.lpszExtraInfo = NULL;
182     UrlComponents.lpszPassword = NULL;
183     UrlComponents.lpszScheme = NULL;
184     UrlComponents.lpszUrlPath = path;
185     UrlComponents.lpszUserName = NULL;
186     UrlComponents.lpszHostName = hostName;
187     UrlComponents.dwExtraInfoLength = 0;
188     UrlComponents.dwPasswordLength = 0;
189     UrlComponents.dwSchemeLength = 0;
190     UrlComponents.dwUserNameLength = 0;
191     UrlComponents.dwHostNameLength = hostNameLen;
192     UrlComponents.dwUrlPathLength = pathLen;
193
194     return InternetCrackUrlW(lpszUrl, 0, 0, &UrlComponents);
195 }
196
197 /* match a domain. domain must match if the domain is not NULL. path must match if the path is not NULL */
198 static BOOL COOKIE_matchDomain(LPCWSTR lpszCookieDomain, LPCWSTR lpszCookiePath,
199                                cookie_domain *searchDomain, BOOL allow_partial)
200 {
201     TRACE("searching on domain %p\n", searchDomain);
202         if (lpszCookieDomain)
203         {
204             if (!searchDomain->lpCookieDomain)
205             return FALSE;
206
207             TRACE("comparing domain %s with %s\n", 
208             debugstr_w(lpszCookieDomain), 
209             debugstr_w(searchDomain->lpCookieDomain));
210
211         if (allow_partial && !strstrW(lpszCookieDomain, searchDomain->lpCookieDomain))
212             return FALSE;
213         else if (!allow_partial && lstrcmpW(lpszCookieDomain, searchDomain->lpCookieDomain) != 0)
214             return FALSE;
215         }
216     if (lpszCookiePath)
217     {
218         TRACE("comparing paths: %s with %s\n", debugstr_w(lpszCookiePath), debugstr_w(searchDomain->lpCookiePath));
219         if (!searchDomain->lpCookiePath)
220             return FALSE;
221         if (strcmpW(lpszCookiePath, searchDomain->lpCookiePath))
222             return FALSE;
223         }
224         return TRUE;
225 }
226
227 /* remove a domain from the list and delete it */
228 static void COOKIE_deleteDomain(cookie_domain *deadDomain)
229 {
230     struct list * cursor;
231     while ((cursor = list_tail(&deadDomain->cookie_list)))
232     {
233         COOKIE_deleteCookie(LIST_ENTRY(cursor, cookie, entry), FALSE);
234         list_remove(cursor);
235     }
236
237     HeapFree(GetProcessHeap(), 0, deadDomain->lpCookieDomain);
238     HeapFree(GetProcessHeap(), 0, deadDomain->lpCookiePath);
239
240     list_remove(&deadDomain->entry);
241
242     HeapFree(GetProcessHeap(), 0, deadDomain);
243 }
244
245 /***********************************************************************
246  *           InternetGetCookieW (WININET.@)
247  *
248  * Retrieve cookie from the specified url
249  *
250  *  It should be noted that on windows the lpszCookieName parameter is "not implemented".
251  *    So it won't be implemented here.
252  *
253  * RETURNS
254  *    TRUE  on success
255  *    FALSE on failure
256  *
257  */
258 BOOL WINAPI InternetGetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
259     LPWSTR lpCookieData, LPDWORD lpdwSize)
260 {
261     BOOL ret;
262     struct list * cursor;
263     unsigned int cnt = 0, domain_count = 0, cookie_count = 0;
264     WCHAR hostName[2048], path[2048];
265
266     TRACE("(%s, %s, %p, %p)\n", debugstr_w(lpszUrl),debugstr_w(lpszCookieName),
267           lpCookieData, lpdwSize);
268
269     if (!lpszUrl)
270     {
271         SetLastError(ERROR_INVALID_PARAMETER);
272         return FALSE;
273     }
274
275     hostName[0] = 0;
276     ret = COOKIE_crackUrlSimple(lpszUrl, hostName, sizeof(hostName)/sizeof(hostName[0]), path, sizeof(path)/sizeof(path[0]));
277     if (!ret || !hostName[0]) return FALSE;
278
279     LIST_FOR_EACH(cursor, &domain_list)
280     {
281         cookie_domain *cookiesDomain = LIST_ENTRY(cursor, cookie_domain, entry);
282         if (COOKIE_matchDomain(hostName, NULL /* FIXME: path */, cookiesDomain, TRUE))
283         {
284             struct list * cursor;
285             domain_count++;
286             TRACE("found domain %p\n", cookiesDomain);
287     
288             LIST_FOR_EACH(cursor, &cookiesDomain->cookie_list)
289             {
290                 cookie *thisCookie = LIST_ENTRY(cursor, cookie, entry);
291                 if (lpCookieData == NULL) /* return the size of the buffer required to lpdwSize */
292                 {
293                     unsigned int len;
294
295                     if (cookie_count) cnt += 2; /* '; ' */
296                     cnt += strlenW(thisCookie->lpCookieName);
297                     if ((len = strlenW(thisCookie->lpCookieData)))
298                     {
299                         cnt += 1; /* = */
300                         cnt += len;
301                     }
302                 }
303                 else
304                 {
305                     static const WCHAR szsc[] = { ';',' ',0 };
306                     static const WCHAR szname[] = { '%','s',0 };
307                     static const WCHAR szdata[] = { '=','%','s',0 };
308
309                     if (cookie_count) cnt += snprintfW(lpCookieData + cnt, *lpdwSize - cnt, szsc);
310                     cnt += snprintfW(lpCookieData + cnt, *lpdwSize - cnt, szname, thisCookie->lpCookieName);
311
312                     if (thisCookie->lpCookieData[0])
313                         cnt += snprintfW(lpCookieData + cnt, *lpdwSize - cnt, szdata, thisCookie->lpCookieData);
314
315                     TRACE("Cookie: %s\n", debugstr_w(lpCookieData));
316                 }
317                 cookie_count++;
318             }
319         }
320     }
321
322     if (!domain_count)
323     {
324         TRACE("no cookies found for %s\n", debugstr_w(hostName));
325         SetLastError(ERROR_NO_MORE_ITEMS);
326         return FALSE;
327     }
328
329     if (lpCookieData == NULL)
330     {
331         *lpdwSize = (cnt + 1) * sizeof(WCHAR);
332         TRACE("returning %u\n", *lpdwSize);
333         return TRUE;
334     }
335
336     *lpdwSize = cnt + 1;
337
338     TRACE("Returning %u (from %u domains): %s\n", cnt, domain_count,
339            debugstr_w(lpCookieData));
340
341     return (cnt ? TRUE : FALSE);
342 }
343
344
345 /***********************************************************************
346  *           InternetGetCookieA (WININET.@)
347  *
348  * Retrieve cookie from the specified url
349  *
350  * RETURNS
351  *    TRUE  on success
352  *    FALSE on failure
353  *
354  */
355 BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
356     LPSTR lpCookieData, LPDWORD lpdwSize)
357 {
358     DWORD len;
359     LPWSTR szCookieData = NULL, szUrl = NULL, szCookieName = NULL;
360     BOOL r;
361
362     TRACE("(%s,%s,%p)\n", debugstr_a(lpszUrl), debugstr_a(lpszCookieName),
363         lpCookieData);
364
365     if( lpszUrl )
366     {
367         len = MultiByteToWideChar( CP_ACP, 0, lpszUrl, -1, NULL, 0 );
368         szUrl = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
369         MultiByteToWideChar( CP_ACP, 0, lpszUrl, -1, szUrl, len );
370     }
371
372     if( lpszCookieName )
373     {
374         len = MultiByteToWideChar( CP_ACP, 0, lpszCookieName, -1, NULL, 0 );
375         szCookieName = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
376         MultiByteToWideChar( CP_ACP, 0, lpszCookieName, -1, szCookieName, len );
377     }
378
379     r = InternetGetCookieW( szUrl, szCookieName, NULL, &len );
380     if( r )
381     {
382         szCookieData = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
383         if( !szCookieData )
384         {
385             r = FALSE;
386         }
387         else
388         {
389             r = InternetGetCookieW( szUrl, szCookieName, szCookieData, &len );
390
391             *lpdwSize = WideCharToMultiByte( CP_ACP, 0, szCookieData, len,
392                                     lpCookieData, *lpdwSize, NULL, NULL );
393         }
394     }
395
396     HeapFree( GetProcessHeap(), 0, szCookieData );
397     HeapFree( GetProcessHeap(), 0, szCookieName );
398     HeapFree( GetProcessHeap(), 0, szUrl );
399
400     return r;
401 }
402
403 static BOOL set_cookie(LPCWSTR domain, LPCWSTR path, LPCWSTR cookie_name, LPCWSTR cookie_data)
404 {
405     cookie_domain *thisCookieDomain = NULL;
406     cookie *thisCookie;
407     struct list *cursor;
408
409     LIST_FOR_EACH(cursor, &domain_list)
410     {
411         thisCookieDomain = LIST_ENTRY(cursor, cookie_domain, entry);
412         if (COOKIE_matchDomain(domain, NULL /* FIXME: path */, thisCookieDomain, FALSE))
413             break;
414         thisCookieDomain = NULL;
415     }
416
417     if (!thisCookieDomain)
418         thisCookieDomain = COOKIE_addDomain(domain, path);
419
420     if ((thisCookie = COOKIE_findCookie(thisCookieDomain, cookie_name)))
421         COOKIE_deleteCookie(thisCookie, FALSE);
422
423     TRACE("setting cookie %s=%s for domain %s\n", debugstr_w(cookie_name),
424           debugstr_w(cookie_data), debugstr_w(thisCookieDomain->lpCookieDomain));
425
426     if (!COOKIE_addCookie(thisCookieDomain, cookie_name, cookie_data))
427         return FALSE;
428
429     return TRUE;
430 }
431
432 /***********************************************************************
433  *           InternetSetCookieW (WININET.@)
434  *
435  * Sets cookie for the specified url
436  *
437  * RETURNS
438  *    TRUE  on success
439  *    FALSE on failure
440  *
441  */
442 BOOL WINAPI InternetSetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
443     LPCWSTR lpCookieData)
444 {
445     BOOL ret;
446     WCHAR hostName[2048], path[2048];
447
448     TRACE("(%s,%s,%s)\n", debugstr_w(lpszUrl),
449         debugstr_w(lpszCookieName), debugstr_w(lpCookieData));
450
451     if (!lpszUrl || !lpCookieData)
452     {
453         SetLastError(ERROR_INVALID_PARAMETER);
454         return FALSE;
455     }
456
457     hostName[0] = path[0] = 0;
458     ret = COOKIE_crackUrlSimple(lpszUrl, hostName, sizeof(hostName)/sizeof(hostName[0]), path, sizeof(path)/sizeof(path[0]));
459     if (!ret || !hostName[0]) return FALSE;
460
461     if (!lpszCookieName)
462     {
463         unsigned int len;
464         WCHAR *cookie, *data;
465
466         len = strlenW(lpCookieData);
467         if (!(cookie = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR))))
468         {
469             SetLastError(ERROR_OUTOFMEMORY);
470             return FALSE;
471         }
472         strcpyW(cookie, lpCookieData);
473
474         /* some apps (or is it us??) try to add a cookie with no cookie name, but
475          * the cookie data in the form of name[=data].
476          */
477         if (!(data = strchrW(cookie, '='))) data = cookie + len;
478         else data++;
479
480         ret = set_cookie(hostName, path, cookie, data);
481
482         HeapFree(GetProcessHeap(), 0, cookie);
483         return ret;
484     }
485     return set_cookie(hostName, path, lpszCookieName, lpCookieData);
486 }
487
488
489 /***********************************************************************
490  *           InternetSetCookieA (WININET.@)
491  *
492  * Sets cookie for the specified url
493  *
494  * RETURNS
495  *    TRUE  on success
496  *    FALSE on failure
497  *
498  */
499 BOOL WINAPI InternetSetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
500     LPCSTR lpCookieData)
501 {
502     DWORD len;
503     LPWSTR szCookieData = NULL, szUrl = NULL, szCookieName = NULL;
504     BOOL r;
505
506     TRACE("(%s,%s,%s)\n", debugstr_a(lpszUrl),
507         debugstr_a(lpszCookieName), debugstr_a(lpCookieData));
508
509     if( lpszUrl )
510     {
511         len = MultiByteToWideChar( CP_ACP, 0, lpszUrl, -1, NULL, 0 );
512         szUrl = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
513         MultiByteToWideChar( CP_ACP, 0, lpszUrl, -1, szUrl, len );
514     }
515
516     if( lpszCookieName )
517     {
518         len = MultiByteToWideChar( CP_ACP, 0, lpszCookieName, -1, NULL, 0 );
519         szCookieName = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
520         MultiByteToWideChar( CP_ACP, 0, lpszCookieName, -1, szCookieName, len );
521     }
522
523     if( lpCookieData )
524     {
525         len = MultiByteToWideChar( CP_ACP, 0, lpCookieData, -1, NULL, 0 );
526         szCookieData = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
527         MultiByteToWideChar( CP_ACP, 0, lpCookieData, -1, szCookieData, len );
528     }
529
530     r = InternetSetCookieW( szUrl, szCookieName, szCookieData );
531
532     HeapFree( GetProcessHeap(), 0, szCookieData );
533     HeapFree( GetProcessHeap(), 0, szCookieName );
534     HeapFree( GetProcessHeap(), 0, szUrl );
535
536     return r;
537 }
538
539 /***********************************************************************
540  *           InternetSetCookieExA (WININET.@)
541  *
542  * See InternetSetCookieExW.
543  */
544 DWORD WINAPI InternetSetCookieExA( LPCSTR lpszURL, LPCSTR lpszCookieName, LPCSTR lpszCookieData,
545                                    DWORD dwFlags, DWORD_PTR dwReserved)
546 {
547     TRACE("(%s, %s, %s, 0x%08x, 0x%08lx)\n",
548           debugstr_a(lpszURL), debugstr_a(lpszCookieName), debugstr_a(lpszCookieData),
549           dwFlags, dwReserved);
550
551     if (dwFlags) FIXME("flags 0x%08x not supported\n", dwFlags);
552     return InternetSetCookieA(lpszURL, lpszCookieName, lpszCookieData);
553 }
554
555 /***********************************************************************
556  *           InternetSetCookieExW (WININET.@)
557  *
558  * Sets a cookie for the specified URL.
559  *
560  * RETURNS
561  *    TRUE  on success
562  *    FALSE on failure
563  *
564  */
565 DWORD WINAPI InternetSetCookieExW( LPCWSTR lpszURL, LPCWSTR lpszCookieName, LPCWSTR lpszCookieData,
566                                    DWORD dwFlags, DWORD_PTR dwReserved)
567 {
568     TRACE("(%s, %s, %s, 0x%08x, 0x%08lx)\n",
569           debugstr_w(lpszURL), debugstr_w(lpszCookieName), debugstr_w(lpszCookieData),
570           dwFlags, dwReserved);
571
572     if (dwFlags) FIXME("flags 0x%08x not supported\n", dwFlags);
573     return InternetSetCookieW(lpszURL, lpszCookieName, lpszCookieData);
574 }
575
576 /***********************************************************************
577  *           InternetGetCookieExA (WININET.@)
578  *
579  * See InternetGetCookieExW.
580  */
581 BOOL WINAPI InternetGetCookieExA( LPCSTR pchURL, LPCSTR pchCookieName, LPSTR pchCookieData,
582                                   LPDWORD pcchCookieData, DWORD dwFlags, LPVOID lpReserved)
583 {
584     TRACE("(%s, %s, %s, %p, 0x%08x, %p)\n",
585           debugstr_a(pchURL), debugstr_a(pchCookieName), debugstr_a(pchCookieData),
586           pcchCookieData, dwFlags, lpReserved);
587
588     if (dwFlags) FIXME("flags 0x%08x not supported\n", dwFlags);
589     return InternetGetCookieA(pchURL, pchCookieName, pchCookieData, pcchCookieData);
590 }
591
592 /***********************************************************************
593  *           InternetGetCookieExW (WININET.@)
594  *
595  * Retrieve cookie for the specified URL.
596  *
597  * RETURNS
598  *    TRUE  on success
599  *    FALSE on failure
600  *
601  */
602 BOOL WINAPI InternetGetCookieExW( LPCWSTR pchURL, LPCWSTR pchCookieName, LPWSTR pchCookieData,
603                                   LPDWORD pcchCookieData, DWORD dwFlags, LPVOID lpReserved)
604 {
605     TRACE("(%s, %s, %s, %p, 0x%08x, %p)\n",
606           debugstr_w(pchURL), debugstr_w(pchCookieName), debugstr_w(pchCookieData),
607           pcchCookieData, dwFlags, lpReserved);
608
609     if (dwFlags) FIXME("flags 0x%08x not supported\n", dwFlags);
610     return InternetGetCookieW(pchURL, pchCookieName, pchCookieData, pcchCookieData);
611 }
612
613 /***********************************************************************
614  *           InternetClearAllPerSiteCookieDecisions (WININET.@)
615  *
616  * Clears all per-site decisions about cookies.
617  *
618  * RETURNS
619  *    TRUE  on success
620  *    FALSE on failure
621  *
622  */
623 BOOL WINAPI InternetClearAllPerSiteCookieDecisions( VOID )
624 {
625     FIXME("stub\n");
626     return TRUE;
627 }
628
629 /***********************************************************************
630  *           InternetEnumPerSiteCookieDecisionA (WININET.@)
631  *
632  * See InternetEnumPerSiteCookieDecisionW.
633  */
634 BOOL WINAPI InternetEnumPerSiteCookieDecisionA( LPSTR pszSiteName, unsigned long *pcSiteNameSize,
635                                                 unsigned long *pdwDecision, unsigned long dwIndex )
636 {
637     FIXME("(%s, %p, %p, 0x%08lx) stub\n",
638           debugstr_a(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex);
639     return FALSE;
640 }
641
642 /***********************************************************************
643  *           InternetEnumPerSiteCookieDecisionW (WININET.@)
644  *
645  * Enumerates all per-site decisions about cookies.
646  *
647  * RETURNS
648  *    TRUE  on success
649  *    FALSE on failure
650  *
651  */
652 BOOL WINAPI InternetEnumPerSiteCookieDecisionW( LPWSTR pszSiteName, unsigned long *pcSiteNameSize,
653                                                 unsigned long *pdwDecision, unsigned long dwIndex )
654 {
655     FIXME("(%s, %p, %p, 0x%08lx) stub\n",
656           debugstr_w(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex);
657     return FALSE;
658 }
659
660 /***********************************************************************
661  *           InternetGetPerSiteCookieDecisionA (WININET.@)
662  */
663 BOOL WINAPI InternetGetPerSiteCookieDecisionA( LPCSTR pwchHostName, unsigned long *pResult )
664 {
665     FIXME("(%s, %p) stub\n", debugstr_a(pwchHostName), pResult);
666     return FALSE;
667 }
668
669 /***********************************************************************
670  *           InternetGetPerSiteCookieDecisionW (WININET.@)
671  */
672 BOOL WINAPI InternetGetPerSiteCookieDecisionW( LPCWSTR pwchHostName, unsigned long *pResult )
673 {
674     FIXME("(%s, %p) stub\n", debugstr_w(pwchHostName), pResult);
675     return FALSE;
676 }
677
678 /***********************************************************************
679  *           InternetSetPerSiteCookieDecisionA (WININET.@)
680  */
681 BOOL WINAPI InternetSetPerSiteCookieDecisionA( LPCSTR pchHostName, DWORD dwDecision )
682 {
683     FIXME("(%s, 0x%08x) stub\n", debugstr_a(pchHostName), dwDecision);
684     return FALSE;
685 }
686
687 /***********************************************************************
688  *           InternetSetPerSiteCookieDecisionW (WININET.@)
689  */
690 BOOL WINAPI InternetSetPerSiteCookieDecisionW( LPCWSTR pchHostName, DWORD dwDecision )
691 {
692     FIXME("(%s, 0x%08x) stub\n", debugstr_w(pchHostName), dwDecision);
693     return FALSE;
694 }