wer: Add new stubbed wer.dll.
[wine/hramrach.git] / dlls / wininet / cookie.c
blob7dfd2a82a8d5515687f7739d0dd685c6f9b1ed77
1 /*
2 * Wininet - cookie handling stuff
4 * Copyright 2002 TransGaming Technologies Inc.
6 * David Hammerton
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.
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.
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
23 #include "config.h"
24 #include "wine/port.h"
26 #if defined(__MINGW32__) || defined (_MSC_VER)
27 #include <ws2tcpip.h>
28 #endif
30 #include <stdarg.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34 #ifdef HAVE_UNISTD_H
35 # include <unistd.h>
36 #endif
38 #include "windef.h"
39 #include "winbase.h"
40 #include "wininet.h"
41 #include "winerror.h"
43 #include "wine/debug.h"
44 #include "internet.h"
46 #define RESPONSE_TIMEOUT 30 /* FROM internet.c */
49 WINE_DEFAULT_DEBUG_CHANNEL(wininet);
51 /* FIXME
52 * Cookies are currently memory only.
53 * Cookies are NOT THREAD SAFE
54 * Cookies could use A LOT OF MEMORY. We need some kind of memory management here!
57 typedef struct _cookie_domain cookie_domain;
58 typedef struct _cookie cookie;
60 struct _cookie
62 struct list entry;
64 struct _cookie_domain *parent;
66 LPWSTR lpCookieName;
67 LPWSTR lpCookieData;
68 FILETIME expiry;
71 struct _cookie_domain
73 struct list entry;
75 LPWSTR lpCookieDomain;
76 LPWSTR lpCookiePath;
77 struct list cookie_list;
80 static struct list domain_list = LIST_INIT(domain_list);
82 static cookie *COOKIE_addCookie(cookie_domain *domain, LPCWSTR name, LPCWSTR data, FILETIME expiry);
83 static cookie *COOKIE_findCookie(cookie_domain *domain, LPCWSTR lpszCookieName);
84 static void COOKIE_deleteCookie(cookie *deadCookie, BOOL deleteDomain);
85 static cookie_domain *COOKIE_addDomain(LPCWSTR domain, LPCWSTR path);
86 static void COOKIE_deleteDomain(cookie_domain *deadDomain);
89 /* adds a cookie to the domain */
90 static cookie *COOKIE_addCookie(cookie_domain *domain, LPCWSTR name, LPCWSTR data, FILETIME expiry)
92 cookie *newCookie = HeapAlloc(GetProcessHeap(), 0, sizeof(cookie));
94 list_init(&newCookie->entry);
95 newCookie->lpCookieName = NULL;
96 newCookie->lpCookieData = NULL;
97 newCookie->expiry = expiry;
98 newCookie->lpCookieName = heap_strdupW(name);
99 newCookie->lpCookieData = heap_strdupW(data);
101 TRACE("added cookie %p (data is %s)\n", newCookie, debugstr_w(data) );
103 list_add_tail(&domain->cookie_list, &newCookie->entry);
104 newCookie->parent = domain;
105 return newCookie;
109 /* finds a cookie in the domain matching the cookie name */
110 static cookie *COOKIE_findCookie(cookie_domain *domain, LPCWSTR lpszCookieName)
112 struct list * cursor;
113 TRACE("(%p, %s)\n", domain, debugstr_w(lpszCookieName));
115 LIST_FOR_EACH(cursor, &domain->cookie_list)
117 cookie *searchCookie = LIST_ENTRY(cursor, cookie, entry);
118 BOOL candidate = TRUE;
119 if (candidate && lpszCookieName)
121 if (candidate && !searchCookie->lpCookieName)
122 candidate = FALSE;
123 if (candidate && strcmpW(lpszCookieName, searchCookie->lpCookieName) != 0)
124 candidate = FALSE;
126 if (candidate)
127 return searchCookie;
129 return NULL;
132 /* removes a cookie from the list, if its the last cookie we also remove the domain */
133 static void COOKIE_deleteCookie(cookie *deadCookie, BOOL deleteDomain)
135 HeapFree(GetProcessHeap(), 0, deadCookie->lpCookieName);
136 HeapFree(GetProcessHeap(), 0, deadCookie->lpCookieData);
137 list_remove(&deadCookie->entry);
139 /* special case: last cookie, lets remove the domain to save memory */
140 if (list_empty(&deadCookie->parent->cookie_list) && deleteDomain)
141 COOKIE_deleteDomain(deadCookie->parent);
142 HeapFree(GetProcessHeap(), 0, deadCookie);
145 /* allocates a domain and adds it to the end */
146 static cookie_domain *COOKIE_addDomain(LPCWSTR domain, LPCWSTR path)
148 cookie_domain *newDomain = HeapAlloc(GetProcessHeap(), 0, sizeof(cookie_domain));
150 list_init(&newDomain->entry);
151 list_init(&newDomain->cookie_list);
152 newDomain->lpCookieDomain = NULL;
153 newDomain->lpCookiePath = NULL;
154 newDomain->lpCookieDomain = heap_strdupW(domain);
155 newDomain->lpCookiePath = heap_strdupW(path);
157 list_add_tail(&domain_list, &newDomain->entry);
159 TRACE("Adding domain: %p\n", newDomain);
160 return newDomain;
163 static BOOL COOKIE_crackUrlSimple(LPCWSTR lpszUrl, LPWSTR hostName, int hostNameLen, LPWSTR path, int pathLen)
165 URL_COMPONENTSW UrlComponents;
167 UrlComponents.lpszExtraInfo = NULL;
168 UrlComponents.lpszPassword = NULL;
169 UrlComponents.lpszScheme = NULL;
170 UrlComponents.lpszUrlPath = path;
171 UrlComponents.lpszUserName = NULL;
172 UrlComponents.lpszHostName = hostName;
173 UrlComponents.dwExtraInfoLength = 0;
174 UrlComponents.dwPasswordLength = 0;
175 UrlComponents.dwSchemeLength = 0;
176 UrlComponents.dwUserNameLength = 0;
177 UrlComponents.dwHostNameLength = hostNameLen;
178 UrlComponents.dwUrlPathLength = pathLen;
180 if (!InternetCrackUrlW(lpszUrl, 0, 0, &UrlComponents)) return FALSE;
182 /* discard the webpage off the end of the path */
183 if (UrlComponents.dwUrlPathLength)
185 if (path[UrlComponents.dwUrlPathLength - 1] != '/')
187 WCHAR *ptr;
188 if ((ptr = strrchrW(path, '/'))) *(++ptr) = 0;
189 else
191 path[0] = '/';
192 path[1] = 0;
196 else if (pathLen >= 2)
198 path[0] = '/';
199 path[1] = 0;
201 return TRUE;
204 /* match a domain. domain must match if the domain is not NULL. path must match if the path is not NULL */
205 static BOOL COOKIE_matchDomain(LPCWSTR lpszCookieDomain, LPCWSTR lpszCookiePath,
206 cookie_domain *searchDomain, BOOL allow_partial)
208 TRACE("searching on domain %p\n", searchDomain);
209 if (lpszCookieDomain)
211 if (!searchDomain->lpCookieDomain)
212 return FALSE;
214 TRACE("comparing domain %s with %s\n",
215 debugstr_w(lpszCookieDomain),
216 debugstr_w(searchDomain->lpCookieDomain));
218 if (allow_partial && !strstrW(lpszCookieDomain, searchDomain->lpCookieDomain))
219 return FALSE;
220 else if (!allow_partial && lstrcmpW(lpszCookieDomain, searchDomain->lpCookieDomain) != 0)
221 return FALSE;
223 if (lpszCookiePath)
225 INT len;
226 TRACE("comparing paths: %s with %s\n", debugstr_w(lpszCookiePath), debugstr_w(searchDomain->lpCookiePath));
227 /* paths match at the beginning. so a path of /foo would match
228 * /foobar and /foo/bar
230 if (!searchDomain->lpCookiePath)
231 return FALSE;
232 if (allow_partial)
234 len = lstrlenW(searchDomain->lpCookiePath);
235 if (strncmpiW(searchDomain->lpCookiePath, lpszCookiePath, len)!=0)
236 return FALSE;
238 else if (strcmpW(lpszCookiePath, searchDomain->lpCookiePath))
239 return FALSE;
242 return TRUE;
245 /* remove a domain from the list and delete it */
246 static void COOKIE_deleteDomain(cookie_domain *deadDomain)
248 struct list * cursor;
249 while ((cursor = list_tail(&deadDomain->cookie_list)))
251 COOKIE_deleteCookie(LIST_ENTRY(cursor, cookie, entry), FALSE);
252 list_remove(cursor);
255 HeapFree(GetProcessHeap(), 0, deadDomain->lpCookieDomain);
256 HeapFree(GetProcessHeap(), 0, deadDomain->lpCookiePath);
258 list_remove(&deadDomain->entry);
260 HeapFree(GetProcessHeap(), 0, deadDomain);
263 /***********************************************************************
264 * InternetGetCookieW (WININET.@)
266 * Retrieve cookie from the specified url
268 * It should be noted that on windows the lpszCookieName parameter is "not implemented".
269 * So it won't be implemented here.
271 * RETURNS
272 * TRUE on success
273 * FALSE on failure
276 BOOL WINAPI InternetGetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
277 LPWSTR lpCookieData, LPDWORD lpdwSize)
279 BOOL ret;
280 struct list * cursor;
281 unsigned int cnt = 0, domain_count = 0, cookie_count = 0;
282 WCHAR hostName[2048], path[2048];
283 FILETIME tm;
285 TRACE("(%s, %s, %p, %p)\n", debugstr_w(lpszUrl),debugstr_w(lpszCookieName),
286 lpCookieData, lpdwSize);
288 if (!lpszUrl)
290 SetLastError(ERROR_INVALID_PARAMETER);
291 return FALSE;
294 hostName[0] = 0;
295 ret = COOKIE_crackUrlSimple(lpszUrl, hostName, sizeof(hostName)/sizeof(hostName[0]), path, sizeof(path)/sizeof(path[0]));
296 if (!ret || !hostName[0]) return FALSE;
298 GetSystemTimeAsFileTime(&tm);
300 LIST_FOR_EACH(cursor, &domain_list)
302 cookie_domain *cookiesDomain = LIST_ENTRY(cursor, cookie_domain, entry);
303 if (COOKIE_matchDomain(hostName, path, cookiesDomain, TRUE))
305 struct list * cursor;
306 domain_count++;
307 TRACE("found domain %p\n", cookiesDomain);
309 LIST_FOR_EACH(cursor, &cookiesDomain->cookie_list)
311 cookie *thisCookie = LIST_ENTRY(cursor, cookie, entry);
312 /* check for expiry */
313 if ((thisCookie->expiry.dwLowDateTime != 0 || thisCookie->expiry.dwHighDateTime != 0) && CompareFileTime(&tm,&thisCookie->expiry) > 0)
315 TRACE("Found expired cookie. deleting\n");
316 COOKIE_deleteCookie(thisCookie, FALSE);
317 continue;
320 if (lpCookieData == NULL) /* return the size of the buffer required to lpdwSize */
322 unsigned int len;
324 if (cookie_count) cnt += 2; /* '; ' */
325 cnt += strlenW(thisCookie->lpCookieName);
326 if ((len = strlenW(thisCookie->lpCookieData)))
328 cnt += 1; /* = */
329 cnt += len;
332 else
334 static const WCHAR szsc[] = { ';',' ',0 };
335 static const WCHAR szname[] = { '%','s',0 };
336 static const WCHAR szdata[] = { '=','%','s',0 };
338 if (cookie_count) cnt += snprintfW(lpCookieData + cnt, *lpdwSize - cnt, szsc);
339 cnt += snprintfW(lpCookieData + cnt, *lpdwSize - cnt, szname, thisCookie->lpCookieName);
341 if (thisCookie->lpCookieData[0])
342 cnt += snprintfW(lpCookieData + cnt, *lpdwSize - cnt, szdata, thisCookie->lpCookieData);
344 TRACE("Cookie: %s\n", debugstr_w(lpCookieData));
346 cookie_count++;
351 if (!domain_count)
353 TRACE("no cookies found for %s\n", debugstr_w(hostName));
354 SetLastError(ERROR_NO_MORE_ITEMS);
355 return FALSE;
358 if (lpCookieData == NULL)
360 *lpdwSize = (cnt + 1) * sizeof(WCHAR);
361 TRACE("returning %u\n", *lpdwSize);
362 return TRUE;
365 *lpdwSize = cnt + 1;
367 TRACE("Returning %u (from %u domains): %s\n", cnt, domain_count,
368 debugstr_w(lpCookieData));
370 return (cnt ? TRUE : FALSE);
374 /***********************************************************************
375 * InternetGetCookieA (WININET.@)
377 * Retrieve cookie from the specified url
379 * RETURNS
380 * TRUE on success
381 * FALSE on failure
384 BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
385 LPSTR lpCookieData, LPDWORD lpdwSize)
387 DWORD len;
388 LPWSTR szCookieData = NULL, url, name;
389 BOOL r;
391 TRACE("(%s,%s,%p)\n", debugstr_a(lpszUrl), debugstr_a(lpszCookieName),
392 lpCookieData);
394 url = heap_strdupAtoW(lpszUrl);
395 name = heap_strdupAtoW(lpszCookieName);
397 r = InternetGetCookieW( url, name, NULL, &len );
398 if( r )
400 szCookieData = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
401 if( !szCookieData )
403 r = FALSE;
405 else
407 r = InternetGetCookieW( url, name, szCookieData, &len );
409 *lpdwSize = WideCharToMultiByte( CP_ACP, 0, szCookieData, len,
410 lpCookieData, *lpdwSize, NULL, NULL );
414 HeapFree( GetProcessHeap(), 0, szCookieData );
415 HeapFree( GetProcessHeap(), 0, name );
416 HeapFree( GetProcessHeap(), 0, url );
418 return r;
421 static BOOL set_cookie(LPCWSTR domain, LPCWSTR path, LPCWSTR cookie_name, LPCWSTR cookie_data)
423 cookie_domain *thisCookieDomain = NULL;
424 cookie *thisCookie;
425 struct list *cursor;
426 LPWSTR data, value;
427 WCHAR *ptr;
428 FILETIME expiry;
429 BOOL expired = FALSE;
431 value = data = heap_strdupW(cookie_data);
432 if (!data)
434 ERR("could not allocate the cookie data buffer\n");
435 return FALSE;
438 memset(&expiry,0,sizeof(expiry));
440 /* lots of information can be parsed out of the cookie value */
442 ptr = data;
443 for (;;)
445 static const WCHAR szDomain[] = {'d','o','m','a','i','n','=',0};
446 static const WCHAR szPath[] = {'p','a','t','h','=',0};
447 static const WCHAR szExpires[] = {'e','x','p','i','r','e','s','=',0};
448 static const WCHAR szSecure[] = {'s','e','c','u','r','e',0};
449 static const WCHAR szHttpOnly[] = {'h','t','t','p','o','n','l','y',0};
451 if (!(ptr = strchrW(ptr,';'))) break;
452 *ptr++ = 0;
454 if (value != data)
455 HeapFree(GetProcessHeap(), 0, value);
456 value = HeapAlloc(GetProcessHeap(), 0, (ptr - data) * sizeof(WCHAR));
457 if (value == NULL)
459 HeapFree(GetProcessHeap(), 0, data);
460 ERR("could not allocate the cookie value buffer\n");
461 return FALSE;
463 strcpyW(value, data);
465 while (*ptr == ' ') ptr++; /* whitespace */
467 if (strncmpiW(ptr, szDomain, 7) == 0)
469 ptr+=strlenW(szDomain);
470 domain = ptr;
471 TRACE("Parsing new domain %s\n",debugstr_w(domain));
473 else if (strncmpiW(ptr, szPath, 5) == 0)
475 ptr+=strlenW(szPath);
476 path = ptr;
477 TRACE("Parsing new path %s\n",debugstr_w(path));
479 else if (strncmpiW(ptr, szExpires, 8) == 0)
481 FILETIME ft;
482 SYSTEMTIME st;
483 FIXME("persistent cookies not handled (%s)\n",debugstr_w(ptr));
484 ptr+=strlenW(szExpires);
485 if (InternetTimeToSystemTimeW(ptr, &st, 0))
487 SystemTimeToFileTime(&st, &expiry);
488 GetSystemTimeAsFileTime(&ft);
490 if (CompareFileTime(&ft,&expiry) > 0)
492 TRACE("Cookie already expired.\n");
493 expired = TRUE;
497 else if (strncmpiW(ptr, szSecure, 6) == 0)
499 FIXME("secure not handled (%s)\n",debugstr_w(ptr));
500 ptr += strlenW(szSecure);
502 else if (strncmpiW(ptr, szHttpOnly, 8) == 0)
504 FIXME("httponly not handled (%s)\n",debugstr_w(ptr));
505 ptr += strlenW(szHttpOnly);
507 else if (*ptr)
509 FIXME("Unknown additional option %s\n",debugstr_w(ptr));
510 break;
514 LIST_FOR_EACH(cursor, &domain_list)
516 thisCookieDomain = LIST_ENTRY(cursor, cookie_domain, entry);
517 if (COOKIE_matchDomain(domain, path, thisCookieDomain, FALSE))
518 break;
519 thisCookieDomain = NULL;
522 if (!thisCookieDomain)
524 if (!expired)
525 thisCookieDomain = COOKIE_addDomain(domain, path);
526 else
528 HeapFree(GetProcessHeap(),0,data);
529 if (value != data) HeapFree(GetProcessHeap(), 0, value);
530 return TRUE;
534 if ((thisCookie = COOKIE_findCookie(thisCookieDomain, cookie_name)))
535 COOKIE_deleteCookie(thisCookie, FALSE);
537 TRACE("setting cookie %s=%s for domain %s path %s\n", debugstr_w(cookie_name),
538 debugstr_w(value), debugstr_w(thisCookieDomain->lpCookieDomain),debugstr_w(thisCookieDomain->lpCookiePath));
540 if (!expired && !COOKIE_addCookie(thisCookieDomain, cookie_name, value, expiry))
542 HeapFree(GetProcessHeap(),0,data);
543 if (value != data) HeapFree(GetProcessHeap(), 0, value);
544 return FALSE;
547 HeapFree(GetProcessHeap(),0,data);
548 if (value != data) HeapFree(GetProcessHeap(), 0, value);
549 return TRUE;
552 /***********************************************************************
553 * InternetSetCookieW (WININET.@)
555 * Sets cookie for the specified url
557 * RETURNS
558 * TRUE on success
559 * FALSE on failure
562 BOOL WINAPI InternetSetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
563 LPCWSTR lpCookieData)
565 BOOL ret;
566 WCHAR hostName[2048], path[2048];
568 TRACE("(%s,%s,%s)\n", debugstr_w(lpszUrl),
569 debugstr_w(lpszCookieName), debugstr_w(lpCookieData));
571 if (!lpszUrl || !lpCookieData)
573 SetLastError(ERROR_INVALID_PARAMETER);
574 return FALSE;
577 hostName[0] = 0;
578 ret = COOKIE_crackUrlSimple(lpszUrl, hostName, sizeof(hostName)/sizeof(hostName[0]), path, sizeof(path)/sizeof(path[0]));
579 if (!ret || !hostName[0]) return FALSE;
581 if (!lpszCookieName)
583 WCHAR *cookie, *data;
585 cookie = heap_strdupW(lpCookieData);
586 if (!cookie)
588 SetLastError(ERROR_OUTOFMEMORY);
589 return FALSE;
592 /* some apps (or is it us??) try to add a cookie with no cookie name, but
593 * the cookie data in the form of name[=data].
595 if (!(data = strchrW(cookie, '='))) data = cookie + strlenW(cookie);
596 else *data++ = 0;
598 ret = set_cookie(hostName, path, cookie, data);
600 HeapFree(GetProcessHeap(), 0, cookie);
601 return ret;
603 return set_cookie(hostName, path, lpszCookieName, lpCookieData);
607 /***********************************************************************
608 * InternetSetCookieA (WININET.@)
610 * Sets cookie for the specified url
612 * RETURNS
613 * TRUE on success
614 * FALSE on failure
617 BOOL WINAPI InternetSetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
618 LPCSTR lpCookieData)
620 LPWSTR data, url, name;
621 BOOL r;
623 TRACE("(%s,%s,%s)\n", debugstr_a(lpszUrl),
624 debugstr_a(lpszCookieName), debugstr_a(lpCookieData));
626 url = heap_strdupAtoW(lpszUrl);
627 name = heap_strdupAtoW(lpszCookieName);
628 data = heap_strdupAtoW(lpCookieData);
630 r = InternetSetCookieW( url, name, data );
632 HeapFree( GetProcessHeap(), 0, data );
633 HeapFree( GetProcessHeap(), 0, name );
634 HeapFree( GetProcessHeap(), 0, url );
636 return r;
639 /***********************************************************************
640 * InternetSetCookieExA (WININET.@)
642 * See InternetSetCookieExW.
644 DWORD WINAPI InternetSetCookieExA( LPCSTR lpszURL, LPCSTR lpszCookieName, LPCSTR lpszCookieData,
645 DWORD dwFlags, DWORD_PTR dwReserved)
647 TRACE("(%s, %s, %s, 0x%08x, 0x%08lx)\n",
648 debugstr_a(lpszURL), debugstr_a(lpszCookieName), debugstr_a(lpszCookieData),
649 dwFlags, dwReserved);
651 if (dwFlags) FIXME("flags 0x%08x not supported\n", dwFlags);
652 return InternetSetCookieA(lpszURL, lpszCookieName, lpszCookieData);
655 /***********************************************************************
656 * InternetSetCookieExW (WININET.@)
658 * Sets a cookie for the specified URL.
660 * RETURNS
661 * TRUE on success
662 * FALSE on failure
665 DWORD WINAPI InternetSetCookieExW( LPCWSTR lpszURL, LPCWSTR lpszCookieName, LPCWSTR lpszCookieData,
666 DWORD dwFlags, DWORD_PTR dwReserved)
668 TRACE("(%s, %s, %s, 0x%08x, 0x%08lx)\n",
669 debugstr_w(lpszURL), debugstr_w(lpszCookieName), debugstr_w(lpszCookieData),
670 dwFlags, dwReserved);
672 if (dwFlags) FIXME("flags 0x%08x not supported\n", dwFlags);
673 return InternetSetCookieW(lpszURL, lpszCookieName, lpszCookieData);
676 /***********************************************************************
677 * InternetGetCookieExA (WININET.@)
679 * See InternetGetCookieExW.
681 BOOL WINAPI InternetGetCookieExA( LPCSTR pchURL, LPCSTR pchCookieName, LPSTR pchCookieData,
682 LPDWORD pcchCookieData, DWORD dwFlags, LPVOID lpReserved)
684 TRACE("(%s, %s, %s, %p, 0x%08x, %p)\n",
685 debugstr_a(pchURL), debugstr_a(pchCookieName), debugstr_a(pchCookieData),
686 pcchCookieData, dwFlags, lpReserved);
688 if (dwFlags) FIXME("flags 0x%08x not supported\n", dwFlags);
689 return InternetGetCookieA(pchURL, pchCookieName, pchCookieData, pcchCookieData);
692 /***********************************************************************
693 * InternetGetCookieExW (WININET.@)
695 * Retrieve cookie for the specified URL.
697 * RETURNS
698 * TRUE on success
699 * FALSE on failure
702 BOOL WINAPI InternetGetCookieExW( LPCWSTR pchURL, LPCWSTR pchCookieName, LPWSTR pchCookieData,
703 LPDWORD pcchCookieData, DWORD dwFlags, LPVOID lpReserved)
705 TRACE("(%s, %s, %s, %p, 0x%08x, %p)\n",
706 debugstr_w(pchURL), debugstr_w(pchCookieName), debugstr_w(pchCookieData),
707 pcchCookieData, dwFlags, lpReserved);
709 if (dwFlags) FIXME("flags 0x%08x not supported\n", dwFlags);
710 return InternetGetCookieW(pchURL, pchCookieName, pchCookieData, pcchCookieData);
713 /***********************************************************************
714 * InternetClearAllPerSiteCookieDecisions (WININET.@)
716 * Clears all per-site decisions about cookies.
718 * RETURNS
719 * TRUE on success
720 * FALSE on failure
723 BOOL WINAPI InternetClearAllPerSiteCookieDecisions( VOID )
725 FIXME("stub\n");
726 return TRUE;
729 /***********************************************************************
730 * InternetEnumPerSiteCookieDecisionA (WININET.@)
732 * See InternetEnumPerSiteCookieDecisionW.
734 BOOL WINAPI InternetEnumPerSiteCookieDecisionA( LPSTR pszSiteName, ULONG *pcSiteNameSize,
735 ULONG *pdwDecision, ULONG dwIndex )
737 FIXME("(%s, %p, %p, 0x%08x) stub\n",
738 debugstr_a(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex);
739 return FALSE;
742 /***********************************************************************
743 * InternetEnumPerSiteCookieDecisionW (WININET.@)
745 * Enumerates all per-site decisions about cookies.
747 * RETURNS
748 * TRUE on success
749 * FALSE on failure
752 BOOL WINAPI InternetEnumPerSiteCookieDecisionW( LPWSTR pszSiteName, ULONG *pcSiteNameSize,
753 ULONG *pdwDecision, ULONG dwIndex )
755 FIXME("(%s, %p, %p, 0x%08x) stub\n",
756 debugstr_w(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex);
757 return FALSE;
760 /***********************************************************************
761 * InternetGetPerSiteCookieDecisionA (WININET.@)
763 BOOL WINAPI InternetGetPerSiteCookieDecisionA( LPCSTR pwchHostName, ULONG *pResult )
765 FIXME("(%s, %p) stub\n", debugstr_a(pwchHostName), pResult);
766 return FALSE;
769 /***********************************************************************
770 * InternetGetPerSiteCookieDecisionW (WININET.@)
772 BOOL WINAPI InternetGetPerSiteCookieDecisionW( LPCWSTR pwchHostName, ULONG *pResult )
774 FIXME("(%s, %p) stub\n", debugstr_w(pwchHostName), pResult);
775 return FALSE;
778 /***********************************************************************
779 * InternetSetPerSiteCookieDecisionA (WININET.@)
781 BOOL WINAPI InternetSetPerSiteCookieDecisionA( LPCSTR pchHostName, DWORD dwDecision )
783 FIXME("(%s, 0x%08x) stub\n", debugstr_a(pchHostName), dwDecision);
784 return FALSE;
787 /***********************************************************************
788 * InternetSetPerSiteCookieDecisionW (WININET.@)
790 BOOL WINAPI InternetSetPerSiteCookieDecisionW( LPCWSTR pchHostName, DWORD dwDecision )
792 FIXME("(%s, 0x%08x) stub\n", debugstr_w(pchHostName), dwDecision);
793 return FALSE;
796 /***********************************************************************
797 * IsDomainLegalCookieDomainW (WININET.@)
799 BOOL WINAPI IsDomainLegalCookieDomainW( LPCWSTR s1, LPCWSTR s2 )
801 const WCHAR *p;
803 FIXME("(%s, %s)\n", debugstr_w(s1), debugstr_w(s2));
805 if (!s1 || !s2)
807 SetLastError(ERROR_INVALID_PARAMETER);
808 return FALSE;
810 if (s1[0] == '.' || !s1[0] || s2[0] == '.' || !s2[0])
812 SetLastError(ERROR_INVALID_NAME);
813 return FALSE;
815 if (!(p = strchrW(s2, '.'))) return FALSE;
816 if (strchrW(p + 1, '.') && !strcmpW(p + 1, s1)) return TRUE;
817 else if (!strcmpW(s1, s2)) return TRUE;
818 return FALSE;