removed tabs and trailing whitespace from source
[platform/upstream/curl.git] / lib / cookie.h
1 #ifndef __COOKIE_H
2 #define __COOKIE_H
3 /***************************************************************************
4  *                                  _   _ ____  _
5  *  Project                     ___| | | |  _ \| |
6  *                             / __| | | | |_) | |
7  *                            | (__| |_| |  _ <| |___
8  *                             \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) 1998 - 2004, 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  * $Id$
24  ***************************************************************************/
25
26 #include <stdio.h>
27 #ifdef WIN32
28 #include <time.h>
29 #else
30 #include <sys/time.h>
31 #endif
32
33 #include <curl/curl.h>
34
35 struct Cookie {
36   struct Cookie *next; /* next in the chain */
37   char *name;        /* <this> = value */
38   char *value;       /* name = <this> */
39   char *path;         /* path = <this> */
40   char *domain;      /* domain = <this> */
41   long expires;    /* expires = <this> */
42   char *expirestr;   /* the plain text version */
43   bool tailmatch;    /* weather we do tail-matchning of the domain name */
44
45   /* RFC 2109 keywords. Version=1 means 2109-compliant cookie sending */
46   char *version;     /* Version = <value> */
47   char *maxage;      /* Max-Age = <value> */
48
49   bool secure;       /* whether the 'secure' keyword was used */
50   bool livecookie;   /* updated from a server, not a stored file */
51 };
52
53 struct CookieInfo {
54   /* linked list of cookies we know of */
55   struct Cookie *cookies;
56
57   char *filename;  /* file we read from/write to */
58   bool running;    /* state info, for cookie adding information */
59   long numcookies; /* number of cookies in the "jar" */
60   bool newsession; /* new session, discard session cookies on load */
61 };
62
63 /* This is the maximum line length we accept for a cookie line. RFC 2109
64    section 6.3 says:
65
66    "at least 4096 bytes per cookie (as measured by the size of the characters
67    that comprise the cookie non-terminal in the syntax description of the
68    Set-Cookie header)"
69
70 */
71 #define MAX_COOKIE_LINE 5000
72 #define MAX_COOKIE_LINE_TXT "4999"
73
74 /* This is the maximum length of a cookie name we deal with: */
75 #define MAX_NAME 1024
76 #define MAX_NAME_TXT "1023"
77
78 struct SessionHandle;
79 /*
80  * Add a cookie to the internal list of cookies. The domain and path arguments
81  * are only used if the header boolean is TRUE.
82  */
83
84 struct Cookie *Curl_cookie_add(struct SessionHandle *data,
85                                struct CookieInfo *, bool header, char *line,
86                                char *domain, char *path);
87
88 struct CookieInfo *Curl_cookie_init(struct SessionHandle *data,
89                                     char *, struct CookieInfo *, bool);
90 struct Cookie *Curl_cookie_getlist(struct CookieInfo *, char *, char *, bool);
91 void Curl_cookie_freelist(struct Cookie *);
92 void Curl_cookie_cleanup(struct CookieInfo *);
93 int Curl_cookie_output(struct CookieInfo *, char *);
94
95 #endif