Newer
Older
*/
int Curl_cookie_output(struct CookieInfo *c, const char *dumphere)
{
struct Cookie *co;
Daniel Stenberg
committed
if((NULL == c) || (0 == c->numcookies))
/* If there are no known cookies, we don't write or even create any
destination file */
return 0;
if(strequal("-", dumphere)) {
/* use stdout */
out = stdout;
use_stdout=TRUE;
}
else {
out = fopen(dumphere, "w");
if(!out)
return 1; /* failure */
}
if(c) {
Daniel Stenberg
committed
char *format_ptr;
Daniel Stenberg
committed
"# http://curl.haxx.se/rfc/cookie_spec.html\n"
"# This file was generated by libcurl! Edit at your own risk.\n\n",
co = c->cookies;
while(co) {
Daniel Stenberg
committed
format_ptr = get_netscape_format(co);
Daniel Stenberg
committed
fprintf(out, "#\n# Fatal libcurl error\n");
Daniel Stenberg
committed
if(!use_stdout)
fclose(out);
Daniel Stenberg
committed
return 1;
}
fprintf(out, "%s\n", format_ptr);
free(format_ptr);
co=co->next;
}
}
if(!use_stdout)
fclose(out);
return 0;
}
Daniel Stenberg
committed
struct curl_slist *Curl_cookie_list(struct SessionHandle *data)
{
struct curl_slist *list = NULL;
struct curl_slist *beg;
struct Cookie *c;
char *line;
Daniel Stenberg
committed
(data->cookies->numcookies == 0))
return NULL;
Daniel Stenberg
committed
Daniel Stenberg
committed
/* fill the list with _all_ the cookies we know */
line = get_netscape_format(c);
return NULL;
}
list = curl_slist_append(list, line);
free(line);
curl_slist_free_all(beg);
return NULL;
}
Daniel Stenberg
committed
Daniel Stenberg
committed
}
#endif /* CURL_DISABLE_HTTP || CURL_DISABLE_COOKIES */