Shows how to manage cookies on a Ecore_Con_Url object. See the complete example description at Ecore_Con_Url - Managing cookies.
#include <stdio.h>
#include <Ecore.h>
#include <Ecore_Con.h>
#define COOKIEJAR "cookies.jar"
{
int i;
printf("\nData received from server:\n>>>>>\n");
for (i = 0; i < url_data->
size; i++)
printf(
"%c", url_data->
data[i]);
printf("\n>>>>>>\n\n");
}
{
char *str;
printf("\n");
printf(
"download completed with status code: %d\n", url_complete->
status);
printf("response headers:\n");
printf("header: %s", str);
}
int
main(int argc, const char *argv[])
{
char cmd = '\0';
if (argc < 2)
{
printf("need at least one parameter: <url> [command]\n");
return -1;
}
if (argc > 2)
cmd = argv[2][0];
if (!ec_url)
{
printf("error when creating ecore con url object.\n");
goto end;
}
if (cmd != 'c' && cmd != 's')
switch (cmd)
{
case 'c':
printf("Cleaning previously set cookies.\n");
break;
case 's':
printf("Cleaning previously set session cookies.\n");
break;
case 'i':
printf("Ignoring old session cookies.\n");
}
if (!r)
{
printf("could not realize request.\n");
goto free_ec_url;
}
free_ec_url:
end:
return 0;
}