Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 175 of file cookie.c.
Referenced by record_cookies().
{ static const WCHAR pathW[] = {'p','a','t','h',0}; static const WCHAR domainW[] = {'d','o','m','a','i','n',0}; BOOL ret = FALSE; WCHAR *buffer, *p, *q, *r; WCHAR *cookie_domain = NULL, *cookie_path = NULL; session_t *session = request->connect->session; cookie_t *cookie; int len; len = strlenW( cookies ); if (!(buffer = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE; strcpyW( buffer, cookies ); p = buffer; while (*p && *p != ';') p++; if (*p == ';') *p++ = 0; if (!(cookie = parse_cookie( buffer ))) { heap_free( buffer ); return FALSE; } if ((q = strstrW( p, domainW ))) /* FIXME: do real attribute parsing */ { while (*q && *q != '=') q++; if (!*q) goto end; r = ++q; while (*r && *r != ';') r++; len = r - q; if (!(cookie_domain = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end; memcpy( cookie_domain, q, len * sizeof(WCHAR) ); cookie_domain[len] = 0; } if ((q = strstrW( p, pathW ))) { while (*q && *q != '=') q++; if (!*q) goto end; r = ++q; while (*r && *r != ';') r++; len = r - q; if (!(cookie_path = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end; memcpy( cookie_path, q, len * sizeof(WCHAR) ); cookie_path[len] = 0; } if (!cookie_domain && !(cookie_domain = strdupW( request->connect->servername ))) goto end; if (!cookie_path && !(cookie_path = strdupW( request->path ))) goto end; if ((p = strrchrW( cookie_path, '/' )) && p != cookie_path) *p = 0; ret = add_cookie( session, cookie, cookie_domain, cookie_path ); end: if (!ret) free_cookie( cookie ); heap_free( cookie_domain ); heap_free( cookie_path ); heap_free( buffer ); return ret; }