httpfindcookie.c (591B)
1 #include "crossroads.h" 2 3 int http_findcookie (unsigned char const *buf, char const *cookie) { 4 char *val, *cp; 5 6 if (!cookie) 7 return (0); 8 if (! (val = http_headerval (buf, "cookie")) ) { 9 msg ("No cookies in '%s'", buf); 10 return (0); 11 } 12 13 for (cp = val; cp && *cp; cp = strchr (cp, ';')) { 14 while (*cp == ';' || *cp == ' ') 15 cp++; 16 if (!strncmp (cp, cookie, strlen (cookie))) { 17 msg ("Found cookie '%s' in '%s'", cookie, val); 18 free (val); 19 return (1); 20 } 21 } 22 msg ("Cookie '%s' not present in '%s'", cookie, val); 23 free (val); 24 return (0); 25 }