diff options
author | alex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-12-08 20:53:40 +0000 |
---|---|---|
committer | alex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-12-08 20:53:40 +0000 |
commit | a5766ca031aba607b687e230c4eea0130aae5e68 (patch) | |
tree | 8c0fdb66c13f500f87520449c95363b6cc97a46f /libmpdemux/cookies.c | |
parent | f861d2a4b3fc5332312d1597a8826f06d6dee3d5 (diff) | |
download | mpv-a5766ca031aba607b687e230c4eea0130aae5e68.tar.bz2 mpv-a5766ca031aba607b687e230c4eea0130aae5e68.tar.xz |
bsdism by Steven Schultz
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11592 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux/cookies.c')
-rw-r--r-- | libmpdemux/cookies.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/libmpdemux/cookies.c b/libmpdemux/cookies.c index 07c51991b6..a13e9f1ab0 100644 --- a/libmpdemux/cookies.c +++ b/libmpdemux/cookies.c @@ -41,7 +41,6 @@ static char *col_dup(const char *src) { char *dst; int length = 0; - char *p, *end; while (src[length] > 31) length++; @@ -177,14 +176,18 @@ static struct cookie_list_type *load_cookies() return list; - asprintf(&buf, "%s/.mozilla/default", homedir); + buf = malloc(strlen(homedir) + sizeof("/.mozilla/default") + 1); + sprintf(buf, "%s/.mozilla/default", homedir); dir = opendir(buf); free(buf); if (dir) { while ((ent = readdir(dir)) != NULL) { if ((ent->d_name)[0] != '.') { - asprintf(&buf, "%s/.mozilla/default/%s/cookies.txt", + buf = malloc(strlen(getenv("HOME")) + + sizeof("/.mozilla/default/") + + strlen(ent->d_name) + sizeof("cookies.txt") + 1); + sprintf(buf, "%s/.mozilla/default/%s/cookies.txt", getenv("HOME"), ent->d_name); list = load_cookies_from(buf, list); free(buf); @@ -193,7 +196,8 @@ static struct cookie_list_type *load_cookies() closedir(dir); } - asprintf(&buf, "%s/.netscape/cookies.txt", homedir); + buf = malloc(strlen(homedir) + sizeof("/.netscape/cookies.txt") + 1); + sprintf(buf, "%s/.netscape/cookies.txt", homedir); list = load_cookies_from(buf, list); free(buf); @@ -250,16 +254,19 @@ cookies_set(HTTP_header_t * http_hdr, const char *domain, const char *url) } - asprintf(&buf, "Cookie:"); + buf = strdup("Cookie:"); for (i = 0; i < found_cookies; i++) { char *nbuf; - asprintf(&nbuf, "%s %s=%s;", buf, cookies[i]->name, + nbuf = malloc(strlen(buf) + strlen(" ") + strlen(cookies[i]->name) + + strlen("=") + strlen(cookies[i]->value) + strlen(";") + 1); + sprintf(nbuf, "%s %s=%s;", buf, cookies[i]->name, cookies[i]->value); free(buf); buf = nbuf; } + if (found_cookies) http_set_field(http_hdr, buf); else |