Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygencookie.c
Go to the documentation of this file.
00001 /* 00002 * Wininet - cookie handling stuff 00003 * 00004 * Copyright 2002 TransGaming Technologies Inc. 00005 * 00006 * David Hammerton 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00021 */ 00022 00023 #include "config.h" 00024 #include "wine/port.h" 00025 00026 #if defined(__MINGW32__) || defined (_MSC_VER) 00027 #include <ws2tcpip.h> 00028 #endif 00029 00030 #include <stdarg.h> 00031 #include <stdio.h> 00032 #include <stdlib.h> 00033 #include <string.h> 00034 #ifdef HAVE_UNISTD_H 00035 # include <unistd.h> 00036 #endif 00037 00038 #include "windef.h" 00039 #include "winbase.h" 00040 #include "wininet.h" 00041 #include "winerror.h" 00042 00043 #include "wine/debug.h" 00044 #include "internet.h" 00045 00046 #define RESPONSE_TIMEOUT 30 /* FROM internet.c */ 00047 00048 00049 WINE_DEFAULT_DEBUG_CHANNEL(wininet); 00050 00051 /* FIXME 00052 * Cookies are currently memory only. 00053 * Cookies are NOT THREAD SAFE 00054 * Cookies could use A LOT OF MEMORY. We need some kind of memory management here! 00055 */ 00056 00057 typedef struct _cookie_domain cookie_domain; 00058 typedef struct _cookie cookie; 00059 00060 struct _cookie 00061 { 00062 struct list entry; 00063 00064 struct _cookie_domain *parent; 00065 00066 LPWSTR lpCookieName; 00067 LPWSTR lpCookieData; 00068 FILETIME expiry; 00069 }; 00070 00071 struct _cookie_domain 00072 { 00073 struct list entry; 00074 00075 LPWSTR lpCookieDomain; 00076 LPWSTR lpCookiePath; 00077 struct list cookie_list; 00078 }; 00079 00080 static struct list domain_list = LIST_INIT(domain_list); 00081 00082 static cookie *COOKIE_addCookie(cookie_domain *domain, LPCWSTR name, LPCWSTR data, FILETIME expiry); 00083 static cookie *COOKIE_findCookie(cookie_domain *domain, LPCWSTR lpszCookieName); 00084 static void COOKIE_deleteCookie(cookie *deadCookie, BOOL deleteDomain); 00085 static cookie_domain *COOKIE_addDomain(LPCWSTR domain, LPCWSTR path); 00086 static void COOKIE_deleteDomain(cookie_domain *deadDomain); 00087 00088 00089 /* adds a cookie to the domain */ 00090 static cookie *COOKIE_addCookie(cookie_domain *domain, LPCWSTR name, LPCWSTR data, FILETIME expiry) 00091 { 00092 cookie *newCookie = heap_alloc(sizeof(cookie)); 00093 00094 list_init(&newCookie->entry); 00095 newCookie->lpCookieName = NULL; 00096 newCookie->lpCookieData = NULL; 00097 newCookie->expiry = expiry; 00098 newCookie->lpCookieName = heap_strdupW(name); 00099 newCookie->lpCookieData = heap_strdupW(data); 00100 00101 TRACE("added cookie %p (data is %s)\n", newCookie, debugstr_w(data) ); 00102 00103 list_add_tail(&domain->cookie_list, &newCookie->entry); 00104 newCookie->parent = domain; 00105 return newCookie; 00106 } 00107 00108 00109 /* finds a cookie in the domain matching the cookie name */ 00110 static cookie *COOKIE_findCookie(cookie_domain *domain, LPCWSTR lpszCookieName) 00111 { 00112 struct list * cursor; 00113 TRACE("(%p, %s)\n", domain, debugstr_w(lpszCookieName)); 00114 00115 LIST_FOR_EACH(cursor, &domain->cookie_list) 00116 { 00117 cookie *searchCookie = LIST_ENTRY(cursor, cookie, entry); 00118 BOOL candidate = TRUE; 00119 if (candidate && lpszCookieName) 00120 { 00121 if (candidate && !searchCookie->lpCookieName) 00122 candidate = FALSE; 00123 if (candidate && strcmpW(lpszCookieName, searchCookie->lpCookieName) != 0) 00124 candidate = FALSE; 00125 } 00126 if (candidate) 00127 return searchCookie; 00128 } 00129 return NULL; 00130 } 00131 00132 /* removes a cookie from the list, if its the last cookie we also remove the domain */ 00133 static void COOKIE_deleteCookie(cookie *deadCookie, BOOL deleteDomain) 00134 { 00135 HeapFree(GetProcessHeap(), 0, deadCookie->lpCookieName); 00136 HeapFree(GetProcessHeap(), 0, deadCookie->lpCookieData); 00137 list_remove(&deadCookie->entry); 00138 00139 /* special case: last cookie, lets remove the domain to save memory */ 00140 if (list_empty(&deadCookie->parent->cookie_list) && deleteDomain) 00141 COOKIE_deleteDomain(deadCookie->parent); 00142 HeapFree(GetProcessHeap(), 0, deadCookie); 00143 } 00144 00145 /* allocates a domain and adds it to the end */ 00146 static cookie_domain *COOKIE_addDomain(LPCWSTR domain, LPCWSTR path) 00147 { 00148 cookie_domain *newDomain = heap_alloc(sizeof(cookie_domain)); 00149 00150 list_init(&newDomain->entry); 00151 list_init(&newDomain->cookie_list); 00152 newDomain->lpCookieDomain = NULL; 00153 newDomain->lpCookiePath = NULL; 00154 newDomain->lpCookieDomain = heap_strdupW(domain); 00155 newDomain->lpCookiePath = heap_strdupW(path); 00156 00157 list_add_tail(&domain_list, &newDomain->entry); 00158 00159 TRACE("Adding domain: %p\n", newDomain); 00160 return newDomain; 00161 } 00162 00163 static BOOL COOKIE_crackUrlSimple(LPCWSTR lpszUrl, LPWSTR hostName, int hostNameLen, LPWSTR path, int pathLen) 00164 { 00165 URL_COMPONENTSW UrlComponents; 00166 00167 UrlComponents.lpszExtraInfo = NULL; 00168 UrlComponents.lpszPassword = NULL; 00169 UrlComponents.lpszScheme = NULL; 00170 UrlComponents.lpszUrlPath = path; 00171 UrlComponents.lpszUserName = NULL; 00172 UrlComponents.lpszHostName = hostName; 00173 UrlComponents.dwExtraInfoLength = 0; 00174 UrlComponents.dwPasswordLength = 0; 00175 UrlComponents.dwSchemeLength = 0; 00176 UrlComponents.dwUserNameLength = 0; 00177 UrlComponents.dwHostNameLength = hostNameLen; 00178 UrlComponents.dwUrlPathLength = pathLen; 00179 00180 if (!InternetCrackUrlW(lpszUrl, 0, 0, &UrlComponents)) return FALSE; 00181 00182 /* discard the webpage off the end of the path */ 00183 if (UrlComponents.dwUrlPathLength) 00184 { 00185 if (path[UrlComponents.dwUrlPathLength - 1] != '/') 00186 { 00187 WCHAR *ptr; 00188 if ((ptr = strrchrW(path, '/'))) *(++ptr) = 0; 00189 else 00190 { 00191 path[0] = '/'; 00192 path[1] = 0; 00193 } 00194 } 00195 } 00196 else if (pathLen >= 2) 00197 { 00198 path[0] = '/'; 00199 path[1] = 0; 00200 } 00201 return TRUE; 00202 } 00203 00204 /* match a domain. domain must match if the domain is not NULL. path must match if the path is not NULL */ 00205 static BOOL COOKIE_matchDomain(LPCWSTR lpszCookieDomain, LPCWSTR lpszCookiePath, 00206 cookie_domain *searchDomain, BOOL allow_partial) 00207 { 00208 TRACE("searching on domain %p\n", searchDomain); 00209 if (lpszCookieDomain) 00210 { 00211 if (!searchDomain->lpCookieDomain) 00212 return FALSE; 00213 00214 TRACE("comparing domain %s with %s\n", 00215 debugstr_w(lpszCookieDomain), 00216 debugstr_w(searchDomain->lpCookieDomain)); 00217 00218 if (allow_partial && !strstrW(lpszCookieDomain, searchDomain->lpCookieDomain)) 00219 return FALSE; 00220 else if (!allow_partial && lstrcmpW(lpszCookieDomain, searchDomain->lpCookieDomain) != 0) 00221 return FALSE; 00222 } 00223 if (lpszCookiePath) 00224 { 00225 INT len; 00226 TRACE("comparing paths: %s with %s\n", debugstr_w(lpszCookiePath), debugstr_w(searchDomain->lpCookiePath)); 00227 /* paths match at the beginning. so a path of /foo would match 00228 * /foobar and /foo/bar 00229 */ 00230 if (!searchDomain->lpCookiePath) 00231 return FALSE; 00232 if (allow_partial) 00233 { 00234 len = lstrlenW(searchDomain->lpCookiePath); 00235 if (strncmpiW(searchDomain->lpCookiePath, lpszCookiePath, len)!=0) 00236 return FALSE; 00237 } 00238 else if (strcmpW(lpszCookiePath, searchDomain->lpCookiePath)) 00239 return FALSE; 00240 00241 } 00242 return TRUE; 00243 } 00244 00245 /* remove a domain from the list and delete it */ 00246 static void COOKIE_deleteDomain(cookie_domain *deadDomain) 00247 { 00248 struct list * cursor; 00249 while ((cursor = list_tail(&deadDomain->cookie_list))) 00250 { 00251 COOKIE_deleteCookie(LIST_ENTRY(cursor, cookie, entry), FALSE); 00252 list_remove(cursor); 00253 } 00254 00255 HeapFree(GetProcessHeap(), 0, deadDomain->lpCookieDomain); 00256 HeapFree(GetProcessHeap(), 0, deadDomain->lpCookiePath); 00257 00258 list_remove(&deadDomain->entry); 00259 00260 HeapFree(GetProcessHeap(), 0, deadDomain); 00261 } 00262 00263 BOOL get_cookie(const WCHAR *host, const WCHAR *path, WCHAR *cookie_data, DWORD *size) 00264 { 00265 unsigned cnt = 0, len, domain_count = 0, cookie_count = 0; 00266 cookie_domain *domain; 00267 FILETIME tm; 00268 00269 GetSystemTimeAsFileTime(&tm); 00270 00271 LIST_FOR_EACH_ENTRY(domain, &domain_list, cookie_domain, entry) { 00272 struct list *cursor, *cursor2; 00273 00274 if(!COOKIE_matchDomain(host, path, domain, TRUE)) 00275 continue; 00276 00277 domain_count++; 00278 TRACE("found domain %p\n", domain); 00279 00280 LIST_FOR_EACH_SAFE(cursor, cursor2, &domain->cookie_list) { 00281 cookie *cookie_iter = LIST_ENTRY(cursor, cookie, entry); 00282 00283 /* check for expiry */ 00284 if((cookie_iter->expiry.dwLowDateTime != 0 || cookie_iter->expiry.dwHighDateTime != 0) 00285 && CompareFileTime(&tm, &cookie_iter->expiry) > 0) 00286 { 00287 TRACE("Found expired cookie. deleting\n"); 00288 COOKIE_deleteCookie(cookie_iter, FALSE); 00289 continue; 00290 } 00291 00292 if(!cookie_data) { /* return the size of the buffer required to lpdwSize */ 00293 if (cookie_count) 00294 cnt += 2; /* '; ' */ 00295 cnt += strlenW(cookie_iter->lpCookieName); 00296 if ((len = strlenW(cookie_iter->lpCookieData))) { 00297 cnt += 1; /* = */ 00298 cnt += len; 00299 } 00300 }else { 00301 static const WCHAR szsc[] = { ';',' ',0 }; 00302 static const WCHAR szname[] = { '%','s',0 }; 00303 static const WCHAR szdata[] = { '=','%','s',0 }; 00304 00305 if (cookie_count) cnt += snprintfW(cookie_data + cnt, *size - cnt, szsc); 00306 cnt += snprintfW(cookie_data + cnt, *size - cnt, szname, cookie_iter->lpCookieName); 00307 00308 if (cookie_iter->lpCookieData[0]) 00309 cnt += snprintfW(cookie_data + cnt, *size - cnt, szdata, cookie_iter->lpCookieData); 00310 00311 TRACE("Cookie: %s\n", debugstr_w(cookie_data)); 00312 } 00313 cookie_count++; 00314 } 00315 } 00316 00317 if (!domain_count) { 00318 TRACE("no cookies found for %s\n", debugstr_w(host)); 00319 SetLastError(ERROR_NO_MORE_ITEMS); 00320 return FALSE; 00321 } 00322 00323 if(!cookie_data) { 00324 *size = (cnt + 1) * sizeof(WCHAR); 00325 TRACE("returning %u\n", *size); 00326 return TRUE; 00327 } 00328 00329 *size = cnt + 1; 00330 00331 TRACE("Returning %u (from %u domains): %s\n", cnt, domain_count, debugstr_w(cookie_data)); 00332 return cnt != 0; 00333 } 00334 00335 /*********************************************************************** 00336 * InternetGetCookieW (WININET.@) 00337 * 00338 * Retrieve cookie from the specified url 00339 * 00340 * It should be noted that on windows the lpszCookieName parameter is "not implemented". 00341 * So it won't be implemented here. 00342 * 00343 * RETURNS 00344 * TRUE on success 00345 * FALSE on failure 00346 * 00347 */ 00348 BOOL WINAPI InternetGetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName, 00349 LPWSTR lpCookieData, LPDWORD lpdwSize) 00350 { 00351 WCHAR host[INTERNET_MAX_HOST_NAME_LENGTH], path[INTERNET_MAX_PATH_LENGTH]; 00352 BOOL ret; 00353 00354 TRACE("(%s, %s, %p, %p)\n", debugstr_w(lpszUrl),debugstr_w(lpszCookieName), lpCookieData, lpdwSize); 00355 00356 if (!lpszUrl) 00357 { 00358 SetLastError(ERROR_INVALID_PARAMETER); 00359 return FALSE; 00360 } 00361 00362 host[0] = 0; 00363 ret = COOKIE_crackUrlSimple(lpszUrl, host, sizeof(host)/sizeof(host[0]), path, sizeof(path)/sizeof(path[0])); 00364 if (!ret || !host[0]) return FALSE; 00365 00366 return get_cookie(host, path, lpCookieData, lpdwSize); 00367 } 00368 00369 00370 /*********************************************************************** 00371 * InternetGetCookieA (WININET.@) 00372 * 00373 * Retrieve cookie from the specified url 00374 * 00375 * RETURNS 00376 * TRUE on success 00377 * FALSE on failure 00378 * 00379 */ 00380 BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName, 00381 LPSTR lpCookieData, LPDWORD lpdwSize) 00382 { 00383 DWORD len; 00384 LPWSTR szCookieData = NULL, url, name; 00385 BOOL r; 00386 00387 TRACE("(%s,%s,%p)\n", debugstr_a(lpszUrl), debugstr_a(lpszCookieName), 00388 lpCookieData); 00389 00390 url = heap_strdupAtoW(lpszUrl); 00391 name = heap_strdupAtoW(lpszCookieName); 00392 00393 r = InternetGetCookieW( url, name, NULL, &len ); 00394 if( r ) 00395 { 00396 szCookieData = heap_alloc(len * sizeof(WCHAR)); 00397 if( !szCookieData ) 00398 { 00399 r = FALSE; 00400 } 00401 else 00402 { 00403 r = InternetGetCookieW( url, name, szCookieData, &len ); 00404 00405 *lpdwSize = WideCharToMultiByte( CP_ACP, 0, szCookieData, len, 00406 lpCookieData, *lpdwSize, NULL, NULL ); 00407 } 00408 } 00409 00410 HeapFree( GetProcessHeap(), 0, szCookieData ); 00411 HeapFree( GetProcessHeap(), 0, name ); 00412 HeapFree( GetProcessHeap(), 0, url ); 00413 00414 return r; 00415 } 00416 00417 BOOL set_cookie(LPCWSTR domain, LPCWSTR path, LPCWSTR cookie_name, LPCWSTR cookie_data) 00418 { 00419 cookie_domain *thisCookieDomain = NULL; 00420 cookie *thisCookie; 00421 struct list *cursor; 00422 LPWSTR data, value; 00423 WCHAR *ptr; 00424 FILETIME expiry; 00425 BOOL expired = FALSE; 00426 00427 value = data = heap_strdupW(cookie_data); 00428 if (!data) 00429 { 00430 ERR("could not allocate the cookie data buffer\n"); 00431 return FALSE; 00432 } 00433 00434 memset(&expiry,0,sizeof(expiry)); 00435 00436 /* lots of information can be parsed out of the cookie value */ 00437 00438 ptr = data; 00439 for (;;) 00440 { 00441 static const WCHAR szDomain[] = {'d','o','m','a','i','n','=',0}; 00442 static const WCHAR szPath[] = {'p','a','t','h','=',0}; 00443 static const WCHAR szExpires[] = {'e','x','p','i','r','e','s','=',0}; 00444 static const WCHAR szSecure[] = {'s','e','c','u','r','e',0}; 00445 static const WCHAR szHttpOnly[] = {'h','t','t','p','o','n','l','y',0}; 00446 00447 if (!(ptr = strchrW(ptr,';'))) break; 00448 *ptr++ = 0; 00449 00450 if (value != data) 00451 HeapFree(GetProcessHeap(), 0, value); 00452 value = heap_alloc((ptr - data) * sizeof(WCHAR)); 00453 if (value == NULL) 00454 { 00455 HeapFree(GetProcessHeap(), 0, data); 00456 ERR("could not allocate the cookie value buffer\n"); 00457 return FALSE; 00458 } 00459 strcpyW(value, data); 00460 00461 while (*ptr == ' ') ptr++; /* whitespace */ 00462 00463 if (strncmpiW(ptr, szDomain, 7) == 0) 00464 { 00465 ptr+=strlenW(szDomain); 00466 domain = ptr; 00467 TRACE("Parsing new domain %s\n",debugstr_w(domain)); 00468 } 00469 else if (strncmpiW(ptr, szPath, 5) == 0) 00470 { 00471 ptr+=strlenW(szPath); 00472 path = ptr; 00473 TRACE("Parsing new path %s\n",debugstr_w(path)); 00474 } 00475 else if (strncmpiW(ptr, szExpires, 8) == 0) 00476 { 00477 FILETIME ft; 00478 SYSTEMTIME st; 00479 FIXME("persistent cookies not handled (%s)\n",debugstr_w(ptr)); 00480 ptr+=strlenW(szExpires); 00481 if (InternetTimeToSystemTimeW(ptr, &st, 0)) 00482 { 00483 SystemTimeToFileTime(&st, &expiry); 00484 GetSystemTimeAsFileTime(&ft); 00485 00486 if (CompareFileTime(&ft,&expiry) > 0) 00487 { 00488 TRACE("Cookie already expired.\n"); 00489 expired = TRUE; 00490 } 00491 } 00492 } 00493 else if (strncmpiW(ptr, szSecure, 6) == 0) 00494 { 00495 FIXME("secure not handled (%s)\n",debugstr_w(ptr)); 00496 ptr += strlenW(szSecure); 00497 } 00498 else if (strncmpiW(ptr, szHttpOnly, 8) == 0) 00499 { 00500 FIXME("httponly not handled (%s)\n",debugstr_w(ptr)); 00501 ptr += strlenW(szHttpOnly); 00502 } 00503 else if (*ptr) 00504 { 00505 FIXME("Unknown additional option %s\n",debugstr_w(ptr)); 00506 break; 00507 } 00508 } 00509 00510 LIST_FOR_EACH(cursor, &domain_list) 00511 { 00512 thisCookieDomain = LIST_ENTRY(cursor, cookie_domain, entry); 00513 if (COOKIE_matchDomain(domain, path, thisCookieDomain, FALSE)) 00514 break; 00515 thisCookieDomain = NULL; 00516 } 00517 00518 if (!thisCookieDomain) 00519 { 00520 if (!expired) 00521 thisCookieDomain = COOKIE_addDomain(domain, path); 00522 else 00523 { 00524 HeapFree(GetProcessHeap(),0,data); 00525 if (value != data) HeapFree(GetProcessHeap(), 0, value); 00526 return TRUE; 00527 } 00528 } 00529 00530 if ((thisCookie = COOKIE_findCookie(thisCookieDomain, cookie_name))) 00531 COOKIE_deleteCookie(thisCookie, FALSE); 00532 00533 TRACE("setting cookie %s=%s for domain %s path %s\n", debugstr_w(cookie_name), 00534 debugstr_w(value), debugstr_w(thisCookieDomain->lpCookieDomain),debugstr_w(thisCookieDomain->lpCookiePath)); 00535 00536 if (!expired && !COOKIE_addCookie(thisCookieDomain, cookie_name, value, expiry)) 00537 { 00538 HeapFree(GetProcessHeap(),0,data); 00539 if (value != data) HeapFree(GetProcessHeap(), 0, value); 00540 return FALSE; 00541 } 00542 00543 HeapFree(GetProcessHeap(),0,data); 00544 if (value != data) HeapFree(GetProcessHeap(), 0, value); 00545 return TRUE; 00546 } 00547 00548 /*********************************************************************** 00549 * InternetSetCookieW (WININET.@) 00550 * 00551 * Sets cookie for the specified url 00552 * 00553 * RETURNS 00554 * TRUE on success 00555 * FALSE on failure 00556 * 00557 */ 00558 BOOL WINAPI InternetSetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName, 00559 LPCWSTR lpCookieData) 00560 { 00561 BOOL ret; 00562 WCHAR hostName[2048], path[2048]; 00563 00564 TRACE("(%s,%s,%s)\n", debugstr_w(lpszUrl), 00565 debugstr_w(lpszCookieName), debugstr_w(lpCookieData)); 00566 00567 if (!lpszUrl || !lpCookieData) 00568 { 00569 SetLastError(ERROR_INVALID_PARAMETER); 00570 return FALSE; 00571 } 00572 00573 hostName[0] = 0; 00574 ret = COOKIE_crackUrlSimple(lpszUrl, hostName, sizeof(hostName)/sizeof(hostName[0]), path, sizeof(path)/sizeof(path[0])); 00575 if (!ret || !hostName[0]) return FALSE; 00576 00577 if (!lpszCookieName) 00578 { 00579 WCHAR *cookie, *data; 00580 00581 cookie = heap_strdupW(lpCookieData); 00582 if (!cookie) 00583 { 00584 SetLastError(ERROR_OUTOFMEMORY); 00585 return FALSE; 00586 } 00587 00588 /* some apps (or is it us??) try to add a cookie with no cookie name, but 00589 * the cookie data in the form of name[=data]. 00590 */ 00591 if (!(data = strchrW(cookie, '='))) data = cookie + strlenW(cookie); 00592 else *data++ = 0; 00593 00594 ret = set_cookie(hostName, path, cookie, data); 00595 00596 HeapFree(GetProcessHeap(), 0, cookie); 00597 return ret; 00598 } 00599 return set_cookie(hostName, path, lpszCookieName, lpCookieData); 00600 } 00601 00602 00603 /*********************************************************************** 00604 * InternetSetCookieA (WININET.@) 00605 * 00606 * Sets cookie for the specified url 00607 * 00608 * RETURNS 00609 * TRUE on success 00610 * FALSE on failure 00611 * 00612 */ 00613 BOOL WINAPI InternetSetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName, 00614 LPCSTR lpCookieData) 00615 { 00616 LPWSTR data, url, name; 00617 BOOL r; 00618 00619 TRACE("(%s,%s,%s)\n", debugstr_a(lpszUrl), 00620 debugstr_a(lpszCookieName), debugstr_a(lpCookieData)); 00621 00622 url = heap_strdupAtoW(lpszUrl); 00623 name = heap_strdupAtoW(lpszCookieName); 00624 data = heap_strdupAtoW(lpCookieData); 00625 00626 r = InternetSetCookieW( url, name, data ); 00627 00628 HeapFree( GetProcessHeap(), 0, data ); 00629 HeapFree( GetProcessHeap(), 0, name ); 00630 HeapFree( GetProcessHeap(), 0, url ); 00631 00632 return r; 00633 } 00634 00635 /*********************************************************************** 00636 * InternetSetCookieExA (WININET.@) 00637 * 00638 * See InternetSetCookieExW. 00639 */ 00640 DWORD WINAPI InternetSetCookieExA( LPCSTR lpszURL, LPCSTR lpszCookieName, LPCSTR lpszCookieData, 00641 DWORD dwFlags, DWORD_PTR dwReserved) 00642 { 00643 TRACE("(%s, %s, %s, 0x%08x, 0x%08lx)\n", 00644 debugstr_a(lpszURL), debugstr_a(lpszCookieName), debugstr_a(lpszCookieData), 00645 dwFlags, dwReserved); 00646 00647 if (dwFlags) FIXME("flags 0x%08x not supported\n", dwFlags); 00648 return InternetSetCookieA(lpszURL, lpszCookieName, lpszCookieData); 00649 } 00650 00651 /*********************************************************************** 00652 * InternetSetCookieExW (WININET.@) 00653 * 00654 * Sets a cookie for the specified URL. 00655 * 00656 * RETURNS 00657 * TRUE on success 00658 * FALSE on failure 00659 * 00660 */ 00661 DWORD WINAPI InternetSetCookieExW( LPCWSTR lpszURL, LPCWSTR lpszCookieName, LPCWSTR lpszCookieData, 00662 DWORD dwFlags, DWORD_PTR dwReserved) 00663 { 00664 TRACE("(%s, %s, %s, 0x%08x, 0x%08lx)\n", 00665 debugstr_w(lpszURL), debugstr_w(lpszCookieName), debugstr_w(lpszCookieData), 00666 dwFlags, dwReserved); 00667 00668 if (dwFlags) FIXME("flags 0x%08x not supported\n", dwFlags); 00669 return InternetSetCookieW(lpszURL, lpszCookieName, lpszCookieData); 00670 } 00671 00672 /*********************************************************************** 00673 * InternetGetCookieExA (WININET.@) 00674 * 00675 * See InternetGetCookieExW. 00676 */ 00677 BOOL WINAPI InternetGetCookieExA( LPCSTR pchURL, LPCSTR pchCookieName, LPSTR pchCookieData, 00678 LPDWORD pcchCookieData, DWORD dwFlags, LPVOID lpReserved) 00679 { 00680 TRACE("(%s, %s, %s, %p, 0x%08x, %p)\n", 00681 debugstr_a(pchURL), debugstr_a(pchCookieName), debugstr_a(pchCookieData), 00682 pcchCookieData, dwFlags, lpReserved); 00683 00684 if (dwFlags) FIXME("flags 0x%08x not supported\n", dwFlags); 00685 return InternetGetCookieA(pchURL, pchCookieName, pchCookieData, pcchCookieData); 00686 } 00687 00688 /*********************************************************************** 00689 * InternetGetCookieExW (WININET.@) 00690 * 00691 * Retrieve cookie for the specified URL. 00692 * 00693 * RETURNS 00694 * TRUE on success 00695 * FALSE on failure 00696 * 00697 */ 00698 BOOL WINAPI InternetGetCookieExW( LPCWSTR pchURL, LPCWSTR pchCookieName, LPWSTR pchCookieData, 00699 LPDWORD pcchCookieData, DWORD dwFlags, LPVOID lpReserved) 00700 { 00701 TRACE("(%s, %s, %s, %p, 0x%08x, %p)\n", 00702 debugstr_w(pchURL), debugstr_w(pchCookieName), debugstr_w(pchCookieData), 00703 pcchCookieData, dwFlags, lpReserved); 00704 00705 if (dwFlags) FIXME("flags 0x%08x not supported\n", dwFlags); 00706 return InternetGetCookieW(pchURL, pchCookieName, pchCookieData, pcchCookieData); 00707 } 00708 00709 /*********************************************************************** 00710 * InternetClearAllPerSiteCookieDecisions (WININET.@) 00711 * 00712 * Clears all per-site decisions about cookies. 00713 * 00714 * RETURNS 00715 * TRUE on success 00716 * FALSE on failure 00717 * 00718 */ 00719 BOOL WINAPI InternetClearAllPerSiteCookieDecisions( VOID ) 00720 { 00721 FIXME("stub\n"); 00722 return TRUE; 00723 } 00724 00725 /*********************************************************************** 00726 * InternetEnumPerSiteCookieDecisionA (WININET.@) 00727 * 00728 * See InternetEnumPerSiteCookieDecisionW. 00729 */ 00730 BOOL WINAPI InternetEnumPerSiteCookieDecisionA( LPSTR pszSiteName, ULONG *pcSiteNameSize, 00731 ULONG *pdwDecision, ULONG dwIndex ) 00732 { 00733 FIXME("(%s, %p, %p, 0x%08x) stub\n", 00734 debugstr_a(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex); 00735 return FALSE; 00736 } 00737 00738 /*********************************************************************** 00739 * InternetEnumPerSiteCookieDecisionW (WININET.@) 00740 * 00741 * Enumerates all per-site decisions about cookies. 00742 * 00743 * RETURNS 00744 * TRUE on success 00745 * FALSE on failure 00746 * 00747 */ 00748 BOOL WINAPI InternetEnumPerSiteCookieDecisionW( LPWSTR pszSiteName, ULONG *pcSiteNameSize, 00749 ULONG *pdwDecision, ULONG dwIndex ) 00750 { 00751 FIXME("(%s, %p, %p, 0x%08x) stub\n", 00752 debugstr_w(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex); 00753 return FALSE; 00754 } 00755 00756 /*********************************************************************** 00757 * InternetGetPerSiteCookieDecisionA (WININET.@) 00758 */ 00759 BOOL WINAPI InternetGetPerSiteCookieDecisionA( LPCSTR pwchHostName, ULONG *pResult ) 00760 { 00761 FIXME("(%s, %p) stub\n", debugstr_a(pwchHostName), pResult); 00762 return FALSE; 00763 } 00764 00765 /*********************************************************************** 00766 * InternetGetPerSiteCookieDecisionW (WININET.@) 00767 */ 00768 BOOL WINAPI InternetGetPerSiteCookieDecisionW( LPCWSTR pwchHostName, ULONG *pResult ) 00769 { 00770 FIXME("(%s, %p) stub\n", debugstr_w(pwchHostName), pResult); 00771 return FALSE; 00772 } 00773 00774 /*********************************************************************** 00775 * InternetSetPerSiteCookieDecisionA (WININET.@) 00776 */ 00777 BOOL WINAPI InternetSetPerSiteCookieDecisionA( LPCSTR pchHostName, DWORD dwDecision ) 00778 { 00779 FIXME("(%s, 0x%08x) stub\n", debugstr_a(pchHostName), dwDecision); 00780 return FALSE; 00781 } 00782 00783 /*********************************************************************** 00784 * InternetSetPerSiteCookieDecisionW (WININET.@) 00785 */ 00786 BOOL WINAPI InternetSetPerSiteCookieDecisionW( LPCWSTR pchHostName, DWORD dwDecision ) 00787 { 00788 FIXME("(%s, 0x%08x) stub\n", debugstr_w(pchHostName), dwDecision); 00789 return FALSE; 00790 } 00791 00792 /*********************************************************************** 00793 * IsDomainLegalCookieDomainW (WININET.@) 00794 */ 00795 BOOL WINAPI IsDomainLegalCookieDomainW( LPCWSTR s1, LPCWSTR s2 ) 00796 { 00797 const WCHAR *p; 00798 00799 FIXME("(%s, %s)\n", debugstr_w(s1), debugstr_w(s2)); 00800 00801 if (!s1 || !s2) 00802 { 00803 SetLastError(ERROR_INVALID_PARAMETER); 00804 return FALSE; 00805 } 00806 if (s1[0] == '.' || !s1[0] || s2[0] == '.' || !s2[0]) 00807 { 00808 SetLastError(ERROR_INVALID_NAME); 00809 return FALSE; 00810 } 00811 if (!(p = strchrW(s2, '.'))) return FALSE; 00812 if (strchrW(p + 1, '.') && !strcmpW(p + 1, s1)) return TRUE; 00813 else if (!strcmpW(s1, s2)) return TRUE; 00814 return FALSE; 00815 } Generated on Thu May 24 2012 04:27:27 for ReactOS by
1.7.6.1
|