ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

BOOL set_cookies ( request_t request,
const WCHAR cookies 
)

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;
}

Generated on Sun May 27 2012 05:20:32 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.