1#ifndef HEADER_CURL_COOKIE_H
2#define HEADER_CURL_COOKIE_H
3/***************************************************************************
4 *                                  _   _ ____  _
5 *  Project                     ___| | | |  _ \| |
6 *                             / __| | | | |_) | |
7 *                            | (__| |_| |  _ <| |___
8 *                             \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at http://curl.haxx.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 ***************************************************************************/
24#include "setup.h"
25
26#include <curl/curl.h>
27
28struct Cookie {
29  struct Cookie *next; /* next in the chain */
30  char *name;        /* <this> = value */
31  char *value;       /* name = <this> */
32  char *path;         /* path = <this> */
33  char *domain;      /* domain = <this> */
34  curl_off_t expires;  /* expires = <this> */
35  char *expirestr;   /* the plain text version */
36  bool tailmatch;    /* weather we do tail-matchning of the domain name */
37
38  /* RFC 2109 keywords. Version=1 means 2109-compliant cookie sending */
39  char *version;     /* Version = <value> */
40  char *maxage;      /* Max-Age = <value> */
41
42  bool secure;       /* whether the 'secure' keyword was used */
43  bool livecookie;   /* updated from a server, not a stored file */
44  bool httponly;     /* true if the httponly directive is present */
45};
46
47struct CookieInfo {
48  /* linked list of cookies we know of */
49  struct Cookie *cookies;
50
51  char *filename;  /* file we read from/write to */
52  bool running;    /* state info, for cookie adding information */
53  long numcookies; /* number of cookies in the "jar" */
54  bool newsession; /* new session, discard session cookies on load */
55};
56
57/* This is the maximum line length we accept for a cookie line. RFC 2109
58   section 6.3 says:
59
60   "at least 4096 bytes per cookie (as measured by the size of the characters
61   that comprise the cookie non-terminal in the syntax description of the
62   Set-Cookie header)"
63
64*/
65#define MAX_COOKIE_LINE 5000
66#define MAX_COOKIE_LINE_TXT "4999"
67
68/* This is the maximum length of a cookie name we deal with: */
69#define MAX_NAME 1024
70#define MAX_NAME_TXT "1023"
71
72struct SessionHandle;
73/*
74 * Add a cookie to the internal list of cookies. The domain and path arguments
75 * are only used if the header boolean is TRUE.
76 */
77
78struct Cookie *Curl_cookie_add(struct SessionHandle *data,
79                               struct CookieInfo *, bool header, char *lineptr,
80                               const char *domain, const char *path);
81
82struct Cookie *Curl_cookie_getlist(struct CookieInfo *, const char *,
83                                   const char *, bool);
84void Curl_cookie_freelist(struct Cookie *cookies, bool cookiestoo);
85void Curl_cookie_clearall(struct CookieInfo *cookies);
86void Curl_cookie_clearsess(struct CookieInfo *cookies);
87
88#if defined(CURL_DISABLE_HTTP) || defined(CURL_DISABLE_COOKIES)
89#define Curl_cookie_list(x) NULL
90#define Curl_cookie_loadfiles(x) Curl_nop_stmt
91#define Curl_cookie_init(x,y,z,w) NULL
92#define Curl_cookie_cleanup(x) Curl_nop_stmt
93#define Curl_flush_cookies(x,y) Curl_nop_stmt
94#else
95void Curl_flush_cookies(struct SessionHandle *data, int cleanup);
96void Curl_cookie_cleanup(struct CookieInfo *);
97struct CookieInfo *Curl_cookie_init(struct SessionHandle *data,
98                                    const char *, struct CookieInfo *, bool);
99struct curl_slist *Curl_cookie_list(struct SessionHandle *data);
100void Curl_cookie_loadfiles(struct SessionHandle *data);
101#endif
102
103#endif /* HEADER_CURL_COOKIE_H */
104