Now we're setting a default domain for received cookies so that we can
[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) 2000, Daniel Stenberg, <daniel@haxx.se>, et al.
11  *
12  * In order to be useful for every potential user, curl and libcurl are
13  * dual-licensed under the MPL and the MIT/X-derivate licenses.
14  *
15  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
16  * copies of the Software, and permit persons to whom the Software is
17  * furnished to do so, under the terms of the MPL or the MIT/X-derivate
18  * licenses. You may pick one of these licenses.
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   time_t expires;    /* expires = <this> */
42   char *expirestr;   /* the plain text version */
43
44   char field1;       /* read from a cookie file, 1 => FALSE, 2=> TRUE */
45   
46   /* RFC 2109 keywords. Version=1 means 2109-compliant cookie sending */
47   char *version;     /* Version = <value> */
48   char *maxage;      /* Max-Age = <value> */
49   
50   bool secure;       /* whether the 'secure' keyword was used */
51   bool livecookie;   /* updated from a server, not a stored file */
52 };
53
54 struct CookieInfo {
55   /* linked list of cookies we know of */
56   struct Cookie *cookies;
57
58   char *filename; /* file we read from/write to */
59   bool running;   /* state info, for cookie adding information */
60   long numcookies; /* number of cookies in the "jar" */
61 };
62
63 /* This is the maximum line length we accept for a cookie line */
64 #define MAX_COOKIE_LINE 2048
65 #define MAX_COOKIE_LINE_TXT "2047"
66
67 /* This is the maximum length of a cookie name we deal with: */
68 #define MAX_NAME 256
69 #define MAX_NAME_TXT "255"
70
71 /*
72  * Add a cookie to the internal list of cookies. The domain argument is only
73  * used if the header boolean is TRUE.
74  */
75 struct Cookie *Curl_cookie_add(struct CookieInfo *, bool header, char *line,
76                                char *domain);
77
78 struct CookieInfo *Curl_cookie_init(char *, struct CookieInfo *);
79 struct Cookie *Curl_cookie_getlist(struct CookieInfo *, char *, char *, bool);
80 void Curl_cookie_freelist(struct Cookie *);
81 void Curl_cookie_cleanup(struct CookieInfo *);
82 int Curl_cookie_output(struct CookieInfo *, char *);
83
84 #endif