83 #ifndef CURL_DISABLE_HTTP
102 free_cookiemess(
struct Cookie *co)
116 static bool tailmatch(
const char *little,
const char *bigone)
118 size_t littlelen = strlen(little);
119 size_t biglen = strlen(bigone);
121 if(littlelen > biglen)
124 return (
bool)
strequal(little, bigone+biglen-littlelen);
156 time_t now = time(
NULL);
157 bool replace_old =
FALSE;
158 bool badcookie =
FALSE;
168 semiptr=strchr(lineptr,
';');
170 while(*lineptr && isspace((
int)*lineptr))
176 sep = strchr(ptr,
'=');
177 if(sep && (!semiptr || (semiptr>sep)) ) {
192 size_t len=strlen(what);
193 while(len && isspace((
int)what[len-1])) {
200 while(isspace((
int)*whatptr)) {
211 const char *domptr=whatptr;
215 static const char *seventhree[]= {
216 "com",
"edu",
"net",
"org",
"gov",
"mil",
"int"
222 if(
'.' == whatptr[0])
227 domptr = strchr(domptr,
'.');
235 i<
sizeof(seventhree)/
sizeof(seventhree[0]); i++) {
251 infof(data,
"skipped cookie with illegal dotcount domain: %s",
258 if(!domain ||
tailmatch(whatptr, domain)) {
259 const char *tailptr=whatptr;
260 if(tailptr[0] ==
'.')
271 infof(data,
"skipped cookie with bad tailmatch domain: %s",
276 else if(
strequal(
"version", name)) {
279 else if(
strequal(
"max-age", name)) {
293 else if(
strequal(
"expires", name)) {
319 if(!semiptr || !*semiptr) {
326 while(ptr && *ptr && isspace((
int)*ptr))
328 semiptr=strchr(ptr,
';');
333 semiptr=strchr(ptr,
'\0');
336 if(badcookie || (
NULL == co->
name)) {
358 char *endslash = strrchr(path,
'/');
360 size_t pathlen = endslash-path+1;
361 co->
path=malloc(pathlen+1);
363 memcpy(co->
path, path, pathlen);
376 if(lineptr[0]==
'#') {
382 ptr=strchr(lineptr,
'\r');
385 ptr=strchr(lineptr,
'\n');
389 firstptr=
strtok_r(lineptr,
"\t", &tok_buf);
392 if(!firstptr || strchr(firstptr,
':')) {
399 for(ptr=firstptr, fields=0; ptr;
452 else if(7 != fields) {
564 infof(data,
"%s cookie %s=\"%s\" for domain %s, path %s, expire %d\n",
565 replace_old?
"Replaced":
"Added", co->
name, co->
value,
619 fp = file?fopen(file,
"r"):
NULL;
636 while(*lineptr && isspace((
int)*lineptr))
667 time_t now = time(
NULL);
700 memcpy(newco, co,
sizeof(
struct Cookie));
703 newco->
next = mainco;
792 bool use_stdout=
FALSE;
805 out = fopen(dumphere,
"w");
811 fputs(
"# Netscape HTTP Cookie File\n"
812 "# http://www.netscape.com/newsref/std/cookie_spec.html\n"
813 "# This file was generated by libcurl! Edit at your own risk.\n\n",
833 co->
secure?
"TRUE":
"FALSE",
time_t curl_getdate(const char *p, const time_t *now)
struct Cookie * Curl_cookie_add(struct SessionHandle *data, struct CookieInfo *c, bool httpheader, char *lineptr, char *domain, char *path)
#define MAX_COOKIE_LINE_TXT
GLsizei GLsizei GLenum GLenum const GLvoid * data
#define checkprefix(a, b)
struct Cookie * Curl_cookie_getlist(struct CookieInfo *c, char *host, char *path, bool secure)
void Curl_cookie_cleanup(struct CookieInfo *c)
void Curl_cookie_freelist(struct Cookie *co)
struct CookieInfo * Curl_cookie_init(struct SessionHandle *data, char *file, struct CookieInfo *inc, bool newsession)
int Curl_cookie_output(struct CookieInfo *c, char *dumphere)