n_cookies regression: Set-Cookie parsing, domain/path/secure/expiry matching.
n_cookies regression: Set-Cookie parsing, domain/path/secure/expiry matching.
#include <stdio.h>
#include <string.h>
int opt = 0;
while ((opt = getopt(argc, argv, "hvV:")) != EOF) {
switch (opt) {
case 'V':
if (!strncmp("LOG_NULL", optarg, 8))
else if (!strncmp("LOG_NOTICE", optarg, 10))
else if (!strncmp("LOG_INFO", optarg, 8))
else if (!strncmp("LOG_ERR", optarg, 7))
else if (!strncmp("LOG_DEBUG", optarg, 9))
else {
fprintf(stderr, "Unknown log level %s\n", optarg);
exit(1);
}
break;
case 'v':
fprintf(stderr, "ex_cookies\n");
exit(1);
case 'h':
default:
fprintf(stderr, "usage: %s [-V LOG_LEVEL]\n", argv[0]);
break;
}
}
}
return h && h->
data && strstr(h->
data, needle) != NULL;
}
int main(
int argc,
char** argv) {
if (!jar) {
return 1;
}
}
}
}
}
}
if (h != NULL) {
}
}
}
}
if (jar) {
}
return 1;
}
return 0;
}
void process_args(int argc, char **argv)
static int hdr_has(N_STR *h, const char *needle)
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_DEBUG
debug-level messages
#define LOG_ERR
error conditions
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL )
#define LOG_NOTICE
normal but significant condition
#define LOG_NULL
no log output
#define LOG_INFO
informational
void n_cookiejar_free(N_COOKIE_JAR **jar)
free a cookie jar and all its cookies, then NULL the pointer
void n_cookiejar_add_from_header(N_COOKIE_JAR *jar, const char *set_cookie_value, const char *request_domain)
parse one Set-Cookie value (without the "Set-Cookie:" name) and store it; request_domain/path supply ...
N_STR * n_cookiejar_build_header(N_COOKIE_JAR *jar, const char *domain, const char *path, int is_secure)
build a "name=value; name2=value2" Cookie header value for a request (domain/path/secure/expiry match...
N_COOKIE_JAR * n_cookiejar_new(void)
create an empty cookie jar; free with n_cookiejar_free.
void n_cookiejar_clear(N_COOKIE_JAR *jar)
drop every stored cookie
size_t n_cookiejar_count(N_COOKIE_JAR *jar)
number of cookies currently stored
#define free_nstr(__ptr)
free a N_STR structure and set the pointer to NULL
A box including a string and his lenght.
Common headers and low-level functions & define.
Domain-aware HTTP cookie jar: Set-Cookie parsing and Cookie header building.
N_STR and string function declaration.