Lines Matching refs:co

113 static void freecookie(struct Cookie *co)
115 free(co->domain);
116 free(co->path);
117 free(co->spath);
118 free(co->name);
119 free(co->value);
120 free(co);
382 struct Cookie *co, *nx;
402 co = cookies->cookies[i];
403 while(co) {
404 nx = co->next;
405 if(co->expires && co->expires < now) {
407 cookies->cookies[i] = co->next;
410 pv->next = co->next;
413 freecookie(co);
420 if(co->expires && co->expires < cookies->next_expiration)
421 cookies->next_expiration = co->expires;
422 pv = co;
424 co = nx;
493 struct Cookie *co;
508 co = calloc(1, sizeof(struct Cookie));
509 if(!co)
519 free(co);
563 freecookie(co);
580 freecookie(co);
594 co->prefix |= COOKIE_PREFIX__SECURE;
596 co->prefix |= COOKIE_PREFIX__HOST;
605 if(!co->name) {
612 strstore(&co->name, namep, nlen);
613 strstore(&co->value, valuep, vlen);
615 if(!co->name || !co->value) {
619 if(invalid_octets(co->value) || invalid_octets(co->name)) {
638 co->secure = TRUE;
646 co->httponly = TRUE;
654 strstore(&co->path, valuep, vlen);
655 if(!co->path) {
659 free(co->spath); /* if this is set again */
660 co->spath = sanitize_cookie_path(co->path);
661 if(!co->spath) {
696 strstore(&co->domain, valuep, vlen);
697 if(!co->domain) {
702 co->tailmatch = TRUE; /* we always do that if the domain name was
732 &co->expires);
736 co->expires = CURL_OFF_T_MAX;
740 co->expires = 1;
743 if(!co->expires)
745 co->expires = 1;
746 else if(CURL_OFF_T_MAX - now < co->expires)
748 co->expires = CURL_OFF_T_MAX;
750 co->expires += now;
756 if(!co->expires && (vlen < sizeof(date))) {
766 co->expires = Curl_getdate_capped(date);
773 if(co->expires == 0)
774 co->expires = 1;
775 else if(co->expires < 0)
776 co->expires = 0;
796 if(!badcookie && !co->domain) {
799 co->domain = strdup(domain);
800 if(!co->domain)
805 if(!badcookie && !co->path && path) {
824 co->path = Curl_memdup0(path, pathlen);
825 if(co->path) {
826 co->spath = sanitize_cookie_path(co->path);
827 if(!co->spath)
839 if(badcookie || !co->name) {
840 freecookie(co);
865 co->httponly = TRUE;
870 free(co);
893 co->domain = strdup(ptr);
894 if(!co->domain)
903 co->tailmatch = strcasecompare(ptr, "TRUE")?TRUE:FALSE;
909 co->path = strdup(ptr);
910 if(!co->path)
913 co->spath = sanitize_cookie_path(co->path);
914 if(!co->spath) {
921 co->path = strdup("/");
922 if(!co->path)
924 co->spath = strdup("/");
925 if(!co->spath)
930 co->secure = FALSE;
933 co->secure = TRUE;
939 if(curlx_strtoofft(ptr, NULL, 10, &co->expires))
943 co->name = strdup(ptr);
944 if(!co->name)
948 if(strncasecompare("__Secure-", co->name, 9))
949 co->prefix |= COOKIE_PREFIX__SECURE;
950 else if(strncasecompare("__Host-", co->name, 7))
951 co->prefix |= COOKIE_PREFIX__HOST;
955 co->value = strdup(ptr);
956 if(!co->value)
963 co->value = strdup("");
964 if(!co->value)
975 freecookie(co);
981 if(co->prefix & COOKIE_PREFIX__SECURE) {
983 if(!co->secure) {
984 freecookie(co);
988 if(co->prefix & COOKIE_PREFIX__HOST) {
993 if(co->secure && co->path && strcmp(co->path, "/") == 0 && !co->tailmatch)
996 freecookie(co);
1003 !co->expires) { /* this is a session cookie since it doesn't expire! */
1004 freecookie(co);
1008 co->livecookie = c->running;
1009 co->creationtime = ++c->lastct;
1027 if(data && (domain && co->domain && !Curl_host_is_ipnum(co->domain))) {
1032 size_t clen = strlen(co->domain);
1038 Curl_strntolower(lcookie, co->domain, clen + 1);
1048 "set cookies for '%s'", co->name, domain, co->domain);
1049 freecookie(co);
1056 myhash = cookiehash(co->domain);
1059 if(strcasecompare(clist->name, co->name)) {
1063 if(clist->domain && co->domain) {
1064 if(strcasecompare(clist->domain, co->domain))
1068 else if(!clist->domain && !co->domain)
1072 clist->spath && co->spath && /* both have paths */
1073 clist->secure && !co->secure && !secure) {
1091 if(strncasecompare(clist->spath, co->spath, cllen)) {
1093 "overlay an existing cookie", co->name, co->domain);
1094 freecookie(co);
1100 if(!replace_co && strcasecompare(clist->name, co->name)) {
1103 if(clist->domain && co->domain) {
1104 if(strcasecompare(clist->domain, co->domain) &&
1105 (clist->tailmatch == co->tailmatch))
1109 else if(!clist->domain && !co->domain)
1115 if(clist->spath && co->spath &&
1116 !strcasecompare(clist->spath, co->spath))
1118 else if(!clist->spath != !co->spath)
1122 if(replace_old && !co->livecookie && clist->livecookie) {
1129 freecookie(co);
1133 replace_co = co;
1141 co = replace_co;
1143 co->next = clist->next; /* get the next-pointer first */
1146 co->creationtime = clist->creationtime;
1155 *clist = *co; /* then store all the new data */
1157 free(co); /* free the newly allocated memory */
1158 co = clist;
1165 replace_old?"Replaced":"Added", co->name, co->value,
1166 co->domain, co->path, co->expires);
1171 lastc->next = co;
1173 c->cookies[myhash] = co;
1181 if(co->expires && (co->expires < c->next_expiration))
1182 c->next_expiration = co->expires;
1184 return co;
1390 struct Cookie *co;
1405 co = c->cookies[myhash];
1407 while(co) {
1409 if(co->secure?secure:TRUE) {
1412 if(!co->domain ||
1413 (co->tailmatch && !is_ip &&
1414 cookie_tailmatch(co->domain, strlen(co->domain), host)) ||
1415 ((!co->tailmatch || is_ip) && strcasecompare(host, co->domain)) ) {
1425 if(!co->spath || pathmatch(co->spath, path) ) {
1432 newco = dup_cookie(co);
1452 co = co->next;
1469 co = mainco;
1471 for(i = 0; co; co = co->next)
1472 array[i++] = co;
1517 void Curl_cookie_freelist(struct Cookie *co)
1520 while(co) {
1521 next = co->next;
1522 freecookie(co);
1523 co = next;
1590 static char *get_netscape_format(const struct Cookie *co)
1601 co->httponly?"#HttpOnly_":"",
1606 (co->tailmatch && co->domain && co->domain[0] != '.')? ".":"",
1607 co->domain?co->domain:"unknown",
1608 co->tailmatch?"TRUE":"FALSE",
1609 co->path?co->path:"/",
1610 co->secure?"TRUE":"FALSE",
1611 co->expires,
1612 co->name,
1613 co->value?co->value:"");
1627 struct Cookie *co;
1669 for(co = c->cookies[i]; co; co = co->next) {
1670 if(!co->domain)
1672 array[nvalid++] = co;