
#include <sys/time.h>

typedef char bool;
#ifndef TRUE
#define TRUE  1
#define FALSE 0
#endif

#include "cookie.h"

/*#include "escape.h" */

int main(int argc, char **argv)
{
#if 0
   char *escaped;
   char *unescaped;
   char *orig="This is a plain едц test!\n";

   escaped = curl_escape(orig);

   if(escaped) {
      printf("ESC: \"%s\"\n", escaped);

      unescaped = curl_unescape(escaped);

      if(unescaped) {
	 printf("DEC: \"%s\"\n", unescaped);
	 printf("ORG: \"%s\"\n", orig);
	 
	 free(unescaped);
      }
      free(escaped);
   }
#else
   struct CookieInfo *cookieanchor;
   struct Cookie *cookies;
   time_t now=time(NULL);

   if(argc<2) {
      printf("Usage: test <file>\n");
      return 0;
   }
   cookieanchor = cookie_init(argv[1]);

   printf("Init return %p\n", cookieanchor);

   cookies =cookieanchor->cookies;
   while(cookies) {
      printf("ALL Cookie: %s=%s  %d/%d\n",
	     cookies->name, cookies->value, cookies->expires, now);
      cookies=cookies->next;
   }

   cookies = cookie_getlist(cookieanchor,
			    "www.foo.boo.fidelity.com",
			    "/wearecool/",
			    TRUE);
   printf("Get return %p\n", cookies);
   while(cookies) {
      printf("Cookie: %s=%s\n", cookies->name, cookies->value);
      cookies=cookies->next;
   }
   cookie_freelist(cookies);

   cookie_cleanup(cookieanchor);
#endif
   return 0;
}
