cookie.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2002, Daniel Stenberg, <[email protected]>, et al.
  9. *
  10. * This software is licensed as described in the file COPYING, which
  11. * you should have received as part of this distribution. The terms
  12. * are also available at http://curl.haxx.se/docs/copyright.html.
  13. *
  14. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. * copies of the Software, and permit persons to whom the Software is
  16. * furnished to do so, under the terms of the COPYING file.
  17. *
  18. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. * KIND, either express or implied.
  20. *
  21. * $Id$
  22. ***************************************************************************/
  23. /***
  24. RECEIVING COOKIE INFORMATION
  25. ============================
  26. struct CookieInfo *cookie_init(char *file);
  27. Inits a cookie struct to store data in a local file. This is always
  28. called before any cookies are set.
  29. int cookies_set(struct CookieInfo *cookie, char *cookie_line);
  30. The 'cookie_line' parameter is a full "Set-cookie:" line as
  31. received from a server.
  32. The function need to replace previously stored lines that this new
  33. line superceeds.
  34. It may remove lines that are expired.
  35. It should return an indication of success/error.
  36. SENDING COOKIE INFORMATION
  37. ==========================
  38. struct Cookies *cookie_getlist(struct CookieInfo *cookie,
  39. char *host, char *path, bool secure);
  40. For a given host and path, return a linked list of cookies that
  41. the client should send to the server if used now. The secure
  42. boolean informs the cookie if a secure connection is achieved or
  43. not.
  44. It shall only return cookies that haven't expired.
  45. Example set of cookies:
  46. Set-cookie: PRODUCTINFO=webxpress; domain=.fidelity.com; path=/; secure
  47. Set-cookie: PERSONALIZE=none;expires=Monday, 13-Jun-1988 03:04:55 GMT;
  48. domain=.fidelity.com; path=/ftgw; secure
  49. Set-cookie: FidHist=none;expires=Monday, 13-Jun-1988 03:04:55 GMT;
  50. domain=.fidelity.com; path=/; secure
  51. Set-cookie: FidOrder=none;expires=Monday, 13-Jun-1988 03:04:55 GMT;
  52. domain=.fidelity.com; path=/; secure
  53. Set-cookie: DisPend=none;expires=Monday, 13-Jun-1988 03:04:55 GMT;
  54. domain=.fidelity.com; path=/; secure
  55. Set-cookie: FidDis=none;expires=Monday, 13-Jun-1988 03:04:55 GMT;
  56. domain=.fidelity.com; path=/; secure
  57. Set-cookie:
  58. Session_Key@6791a9e0-901a-11d0-a1c8-9b012c88aa77=none;expires=Monday,
  59. 13-Jun-1988 03:04:55 GMT; domain=.fidelity.com; path=/; secure
  60. ****/
  61. #include "setup.h"
  62. #ifndef CURL_DISABLE_HTTP
  63. #include <stdlib.h>
  64. #include <string.h>
  65. #include <ctype.h>
  66. #include "cookie.h"
  67. #include "getdate.h"
  68. #include "strequal.h"
  69. #include "strtok.h"
  70. /* The last #include file should be: */
  71. #ifdef MALLOCDEBUG
  72. #include "memdebug.h"
  73. #endif
  74. static void
  75. free_cookiemess(struct Cookie *co)
  76. {
  77. if(co->domain)
  78. free(co->domain);
  79. if(co->path)
  80. free(co->path);
  81. if(co->name)
  82. free(co->name);
  83. if(co->value)
  84. free(co->value);
  85. free(co);
  86. }
  87. /****************************************************************************
  88. *
  89. * Curl_cookie_add()
  90. *
  91. * Add a single cookie line to the cookie keeping object.
  92. *
  93. ***************************************************************************/
  94. struct Cookie *
  95. Curl_cookie_add(struct CookieInfo *c,
  96. bool httpheader, /* TRUE if HTTP header-style line */
  97. char *lineptr, /* first character of the line */
  98. char *domain) /* default domain */
  99. {
  100. struct Cookie *clist;
  101. char what[MAX_COOKIE_LINE];
  102. char name[MAX_NAME];
  103. char *ptr;
  104. char *semiptr;
  105. struct Cookie *co;
  106. struct Cookie *lastc=NULL;
  107. time_t now = time(NULL);
  108. bool replace_old = FALSE;
  109. /* First, alloc and init a new struct for it */
  110. co = (struct Cookie *)malloc(sizeof(struct Cookie));
  111. if(!co)
  112. return NULL; /* bail out if we're this low on memory */
  113. /* clear the whole struct first */
  114. memset(co, 0, sizeof(struct Cookie));
  115. if(httpheader) {
  116. /* This line was read off a HTTP-header */
  117. char *sep;
  118. semiptr=strchr(lineptr, ';'); /* first, find a semicolon */
  119. while(*lineptr && isspace((int)*lineptr))
  120. lineptr++;
  121. ptr = lineptr;
  122. do {
  123. /* we have a <what>=<this> pair or a 'secure' word here */
  124. sep = strchr(ptr, '=');
  125. if(sep && (!semiptr || (semiptr>sep)) ) {
  126. /*
  127. * There is a = sign and if there was a semicolon too, which make sure
  128. * that the semicolon comes _after_ the equal sign.
  129. */
  130. name[0]=what[0]=0; /* init the buffers */
  131. if(1 <= sscanf(ptr, "%" MAX_NAME_TXT "[^;=]=%"
  132. MAX_COOKIE_LINE_TXT "[^;\r\n]",
  133. name, what)) {
  134. /* this is a <name>=<what> pair */
  135. char *whatptr;
  136. /* Strip off trailing whitespace from the 'what' */
  137. size_t len=strlen(what);
  138. while(len && isspace((int)what[len-1])) {
  139. what[len-1]=0;
  140. len--;
  141. }
  142. /* Skip leading whitespace from the 'what' */
  143. whatptr=what;
  144. while(isspace((int)*whatptr)) {
  145. whatptr++;
  146. }
  147. if(strequal("path", name)) {
  148. co->path=strdup(whatptr);
  149. }
  150. else if(strequal("domain", name)) {
  151. co->domain=strdup(whatptr);
  152. co->field1= (char)((whatptr[0]=='.')?2:1);
  153. }
  154. else if(strequal("version", name)) {
  155. co->version=strdup(whatptr);
  156. }
  157. else if(strequal("max-age", name)) {
  158. /* Defined in RFC2109:
  159. Optional. The Max-Age attribute defines the lifetime of the
  160. cookie, in seconds. The delta-seconds value is a decimal non-
  161. negative integer. After delta-seconds seconds elapse, the
  162. client should discard the cookie. A value of zero means the
  163. cookie should be discarded immediately.
  164. */
  165. co->maxage = strdup(whatptr);
  166. co->expires =
  167. atoi((*co->maxage=='\"')?&co->maxage[1]:&co->maxage[0]) + (long)now;
  168. }
  169. else if(strequal("expires", name)) {
  170. co->expirestr=strdup(whatptr);
  171. co->expires = (long)curl_getdate(what, &now);
  172. }
  173. else if(!co->name) {
  174. co->name = strdup(name);
  175. co->value = strdup(whatptr);
  176. }
  177. /*
  178. else this is the second (or more) name we don't know
  179. about! */
  180. }
  181. else {
  182. /* this is an "illegal" <what>=<this> pair */
  183. }
  184. }
  185. else {
  186. if(sscanf(ptr, "%" MAX_COOKIE_LINE_TXT "[^;\r\n]",
  187. what)) {
  188. if(strequal("secure", what))
  189. co->secure = TRUE;
  190. /* else,
  191. unsupported keyword without assign! */
  192. }
  193. }
  194. if(!semiptr || !*semiptr) {
  195. /* we already know there are no more cookies */
  196. semiptr = NULL;
  197. continue;
  198. }
  199. ptr=semiptr+1;
  200. while(ptr && *ptr && isspace((int)*ptr))
  201. ptr++;
  202. semiptr=strchr(ptr, ';'); /* now, find the next semicolon */
  203. if(!semiptr && *ptr)
  204. /* There are no more semicolons, but there's a final name=value pair
  205. coming up */
  206. semiptr=strchr(ptr, '\0');
  207. } while(semiptr);
  208. if(NULL == co->name) {
  209. /* we didn't get a cookie name, this is an illegal line, bail out */
  210. if(co->domain)
  211. free(co->domain);
  212. if(co->path)
  213. free(co->path);
  214. if(co->name)
  215. free(co->name);
  216. if(co->value)
  217. free(co->value);
  218. free(co);
  219. return NULL;
  220. }
  221. if(NULL == co->domain)
  222. /* no domain given in the header line, set the default now */
  223. co->domain=domain?strdup(domain):NULL;
  224. }
  225. else {
  226. /* This line is NOT a HTTP header style line, we do offer support for
  227. reading the odd netscape cookies-file format here */
  228. char *firstptr;
  229. char *tok_buf;
  230. int fields;
  231. if(lineptr[0]=='#') {
  232. /* don't even try the comments */
  233. free(co);
  234. return NULL;
  235. }
  236. /* strip off the possible end-of-line characters */
  237. ptr=strchr(lineptr, '\r');
  238. if(ptr)
  239. *ptr=0; /* clear it */
  240. ptr=strchr(lineptr, '\n');
  241. if(ptr)
  242. *ptr=0; /* clear it */
  243. firstptr=strtok_r(lineptr, "\t", &tok_buf); /* first tokenize it on the TAB */
  244. /* Here's a quick check to eliminate normal HTTP-headers from this */
  245. if(!firstptr || strchr(firstptr, ':')) {
  246. free(co);
  247. return NULL;
  248. }
  249. /* Now loop through the fields and init the struct we already have
  250. allocated */
  251. for(ptr=firstptr, fields=0; ptr; ptr=strtok_r(NULL, "\t", &tok_buf), fields++) {
  252. switch(fields) {
  253. case 0:
  254. co->domain = strdup(ptr);
  255. break;
  256. case 1:
  257. /* This field got its explanation on the 23rd of May 2001 by
  258. Andrés García:
  259. flag: A TRUE/FALSE value indicating if all machines within a given
  260. domain can access the variable. This value is set automatically by
  261. the browser, depending on the value you set for the domain.
  262. As far as I can see, it is set to true when the cookie says
  263. .domain.com and to false when the domain is complete www.domain.com
  264. We don't currently take advantage of this knowledge.
  265. */
  266. co->field1=(char)(strequal(ptr, "TRUE")+1); /* store information */
  267. break;
  268. case 2:
  269. /* It turns out, that sometimes the file format allows the path
  270. field to remain not filled in, we try to detect this and work
  271. around it! Andrés García made us aware of this... */
  272. if (strcmp("TRUE", ptr) && strcmp("FALSE", ptr)) {
  273. /* only if the path doesn't look like a boolean option! */
  274. co->path = strdup(ptr);
  275. break;
  276. }
  277. /* this doesn't look like a path, make one up! */
  278. co->path = strdup("/");
  279. fields++; /* add a field and fall down to secure */
  280. /* FALLTHROUGH */
  281. case 3:
  282. co->secure = (bool)strequal(ptr, "TRUE");
  283. break;
  284. case 4:
  285. co->expires = atoi(ptr);
  286. break;
  287. case 5:
  288. co->name = strdup(ptr);
  289. break;
  290. case 6:
  291. co->value = strdup(ptr);
  292. break;
  293. }
  294. }
  295. if(7 != fields) {
  296. /* we did not find the sufficient number of fields to recognize this
  297. as a valid line, abort and go home */
  298. free_cookiemess(co);
  299. return NULL;
  300. }
  301. }
  302. if(!c->running && /* read from a file */
  303. c->newsession && /* clean session cookies */
  304. !co->expires) { /* this is a session cookie since it doesn't expire! */
  305. free_cookiemess(co);
  306. return NULL;
  307. }
  308. co->livecookie = c->running;
  309. /* now, we have parsed the incoming line, we must now check if this
  310. superceeds an already existing cookie, which it may if the previous have
  311. the same domain and path as this */
  312. clist = c->cookies;
  313. replace_old = FALSE;
  314. while(clist) {
  315. if(strequal(clist->name, co->name)) {
  316. /* the names are identical */
  317. if(clist->domain && co->domain) {
  318. if(strequal(clist->domain, co->domain) ||
  319. (clist->domain[0]=='.' &&
  320. strequal(&(clist->domain[1]), co->domain)) ||
  321. (co->domain[0]=='.' &&
  322. strequal(clist->domain, &(co->domain[1]))) )
  323. /* The domains are identical, or at least identical if you skip the
  324. preceeding dot */
  325. replace_old=TRUE;
  326. }
  327. else if(!clist->domain && !co->domain)
  328. replace_old = TRUE;
  329. if(replace_old) {
  330. /* the domains were identical */
  331. if(clist->path && co->path) {
  332. if(strequal(clist->path, co->path)) {
  333. replace_old = TRUE;
  334. }
  335. else
  336. replace_old = FALSE;
  337. }
  338. else if(!clist->path && !co->path)
  339. replace_old = TRUE;
  340. else
  341. replace_old = FALSE;
  342. }
  343. if(replace_old && !co->livecookie && clist->livecookie) {
  344. /* Both cookies matched fine, except that the already present
  345. cookie is "live", which means it was set from a header, while
  346. the new one isn't "live" and thus only read from a file. We let
  347. live cookies stay alive */
  348. /* Free the newcomer and get out of here! */
  349. if(co->domain)
  350. free(co->domain);
  351. if(co->path)
  352. free(co->path);
  353. if(co->name)
  354. free(co->name);
  355. if(co->value)
  356. free(co->value);
  357. free(co);
  358. return NULL;
  359. }
  360. if(replace_old) {
  361. co->next = clist->next; /* get the next-pointer first */
  362. /* then free all the old pointers */
  363. if(clist->name)
  364. free(clist->name);
  365. if(clist->value)
  366. free(clist->value);
  367. if(clist->domain)
  368. free(clist->domain);
  369. if(clist->path)
  370. free(clist->path);
  371. if(clist->expirestr)
  372. free(clist->expirestr);
  373. if(clist->version)
  374. free(clist->version);
  375. if(clist->maxage)
  376. free(clist->maxage);
  377. *clist = *co; /* then store all the new data */
  378. free(co); /* free the newly alloced memory */
  379. co = clist; /* point to the previous struct instead */
  380. /* We have replaced a cookie, now skip the rest of the list but
  381. make sure the 'lastc' pointer is properly set */
  382. do {
  383. lastc = clist;
  384. clist = clist->next;
  385. } while(clist);
  386. break;
  387. }
  388. }
  389. lastc = clist;
  390. clist = clist->next;
  391. }
  392. if(!replace_old) {
  393. /* then make the last item point on this new one */
  394. if(lastc)
  395. lastc->next = co;
  396. else
  397. c->cookies = co;
  398. }
  399. c->numcookies++; /* one more cookie in the jar */
  400. return co;
  401. }
  402. /*****************************************************************************
  403. *
  404. * Curl_cookie_init()
  405. *
  406. * Inits a cookie struct to read data from a local file. This is always
  407. * called before any cookies are set. File may be NULL.
  408. *
  409. * If 'newsession' is TRUE, discard all "session cookies" on read from file.
  410. *
  411. ****************************************************************************/
  412. struct CookieInfo *Curl_cookie_init(char *file,
  413. struct CookieInfo *inc,
  414. bool newsession)
  415. {
  416. char line[MAX_COOKIE_LINE];
  417. struct CookieInfo *c;
  418. FILE *fp;
  419. bool fromfile=TRUE;
  420. if(NULL == inc) {
  421. /* we didn't get a struct, create one */
  422. c = (struct CookieInfo *)malloc(sizeof(struct CookieInfo));
  423. if(!c)
  424. return NULL; /* failed to get memory */
  425. memset(c, 0, sizeof(struct CookieInfo));
  426. c->filename = strdup(file?file:"none"); /* copy the name just in case */
  427. }
  428. else {
  429. /* we got an already existing one, use that */
  430. c = inc;
  431. }
  432. c->running = FALSE; /* this is not running, this is init */
  433. if(file && strequal(file, "-")) {
  434. fp = stdin;
  435. fromfile=FALSE;
  436. }
  437. else
  438. fp = file?fopen(file, "r"):NULL;
  439. c->newsession = newsession; /* new session? */
  440. if(fp) {
  441. char *lineptr;
  442. bool headerline;
  443. while(fgets(line, MAX_COOKIE_LINE, fp)) {
  444. if(checkprefix("Set-Cookie:", line)) {
  445. /* This is a cookie line, get it! */
  446. lineptr=&line[11];
  447. headerline=TRUE;
  448. }
  449. else {
  450. lineptr=line;
  451. headerline=FALSE;
  452. }
  453. while(*lineptr && isspace((int)*lineptr))
  454. lineptr++;
  455. Curl_cookie_add(c, headerline, lineptr, NULL);
  456. }
  457. if(fromfile)
  458. fclose(fp);
  459. }
  460. c->running = TRUE; /* now, we're running */
  461. return c;
  462. }
  463. /*****************************************************************************
  464. *
  465. * Curl_cookie_getlist()
  466. *
  467. * For a given host and path, return a linked list of cookies that the
  468. * client should send to the server if used now. The secure boolean informs
  469. * the cookie if a secure connection is achieved or not.
  470. *
  471. * It shall only return cookies that haven't expired.
  472. *
  473. ****************************************************************************/
  474. struct Cookie *Curl_cookie_getlist(struct CookieInfo *c,
  475. char *host, char *path, bool secure)
  476. {
  477. struct Cookie *newco;
  478. struct Cookie *co;
  479. time_t now = time(NULL);
  480. int hostlen=(int)strlen(host);
  481. int domlen;
  482. struct Cookie *mainco=NULL;
  483. if(!c || !c->cookies)
  484. return NULL; /* no cookie struct or no cookies in the struct */
  485. co = c->cookies;
  486. while(co) {
  487. /* only process this cookie if it is not expired or had no expire
  488. date AND that if the cookie requires we're secure we must only
  489. continue if we are! */
  490. if( (co->expires<=0 || (co->expires> now)) &&
  491. (co->secure?secure:TRUE) ) {
  492. /* now check if the domain is correct */
  493. domlen=co->domain?(int)strlen(co->domain):0;
  494. if(!co->domain ||
  495. ((domlen<=hostlen) &&
  496. strequal(host+(hostlen-domlen), co->domain)) ) {
  497. /* the right part of the host matches the domain stuff in the
  498. cookie data */
  499. /* now check the left part of the path with the cookies path
  500. requirement */
  501. if(!co->path ||
  502. checkprefix(co->path, path) ) {
  503. /* and now, we know this is a match and we should create an
  504. entry for the return-linked-list */
  505. newco = (struct Cookie *)malloc(sizeof(struct Cookie));
  506. if(newco) {
  507. /* first, copy the whole source cookie: */
  508. memcpy(newco, co, sizeof(struct Cookie));
  509. /* then modify our next */
  510. newco->next = mainco;
  511. /* point the main to us */
  512. mainco = newco;
  513. }
  514. }
  515. }
  516. }
  517. co = co->next;
  518. }
  519. return mainco; /* return the new list */
  520. }
  521. /*****************************************************************************
  522. *
  523. * Curl_cookie_freelist()
  524. *
  525. * Free a list of cookies previously returned by Curl_cookie_getlist();
  526. *
  527. ****************************************************************************/
  528. void Curl_cookie_freelist(struct Cookie *co)
  529. {
  530. struct Cookie *next;
  531. if(co) {
  532. while(co) {
  533. next = co->next;
  534. free(co); /* we only free the struct since the "members" are all
  535. just copied! */
  536. co = next;
  537. }
  538. }
  539. }
  540. /*****************************************************************************
  541. *
  542. * Curl_cookie_cleanup()
  543. *
  544. * Free a "cookie object" previous created with cookie_init().
  545. *
  546. ****************************************************************************/
  547. void Curl_cookie_cleanup(struct CookieInfo *c)
  548. {
  549. struct Cookie *co;
  550. struct Cookie *next;
  551. if(c) {
  552. if(c->filename)
  553. free(c->filename);
  554. co = c->cookies;
  555. while(co) {
  556. if(co->name)
  557. free(co->name);
  558. if(co->value)
  559. free(co->value);
  560. if(co->domain)
  561. free(co->domain);
  562. if(co->path)
  563. free(co->path);
  564. if(co->expirestr)
  565. free(co->expirestr);
  566. if(co->version)
  567. free(co->version);
  568. if(co->maxage)
  569. free(co->maxage);
  570. next = co->next;
  571. free(co);
  572. co = next;
  573. }
  574. free(c); /* free the base struct as well */
  575. }
  576. }
  577. /*
  578. * Curl_cookie_output()
  579. *
  580. * Writes all internally known cookies to the specified file. Specify
  581. * "-" as file name to write to stdout.
  582. *
  583. * The function returns non-zero on write failure.
  584. */
  585. int Curl_cookie_output(struct CookieInfo *c, char *dumphere)
  586. {
  587. struct Cookie *co;
  588. FILE *out;
  589. bool use_stdout=FALSE;
  590. if((NULL == c) || (0 == c->numcookies))
  591. /* If there are no known cookies, we don't write or even create any
  592. destination file */
  593. return 0;
  594. if(strequal("-", dumphere)) {
  595. /* use stdout */
  596. out = stdout;
  597. use_stdout=TRUE;
  598. }
  599. else {
  600. out = fopen(dumphere, "w");
  601. if(!out)
  602. return 1; /* failure */
  603. }
  604. if(c) {
  605. fputs("# Netscape HTTP Cookie File\n"
  606. "# http://www.netscape.com/newsref/std/cookie_spec.html\n"
  607. "# This file was generated by libcurl! Edit at your own risk.\n\n",
  608. out);
  609. co = c->cookies;
  610. while(co) {
  611. fprintf(out,
  612. "%s\t" /* domain */
  613. "%s\t" /* field1 */
  614. "%s\t" /* path */
  615. "%s\t" /* secure */
  616. "%u\t" /* expires */
  617. "%s\t" /* name */
  618. "%s\n", /* value */
  619. co->domain?co->domain:"unknown",
  620. co->field1==2?"TRUE":"FALSE",
  621. co->path?co->path:"/",
  622. co->secure?"TRUE":"FALSE",
  623. (unsigned int)co->expires,
  624. co->name,
  625. co->value?co->value:"");
  626. co=co->next;
  627. }
  628. }
  629. if(!use_stdout)
  630. fclose(out);
  631. return 0;
  632. }
  633. #ifdef CURL_COOKIE_DEBUG
  634. /*
  635. * On my Solaris box, this command line builds this test program:
  636. *
  637. * gcc -g -o cooktest -DCURL_COOKIE_DEBUG -DHAVE_CONFIG_H -I.. -I../include cookie.c strequal.o getdate.o memdebug.o mprintf.o strtok.o -lnsl -lsocket
  638. *
  639. */
  640. int main(int argc, char **argv)
  641. {
  642. struct CookieInfo *c=NULL;
  643. if(argc>1) {
  644. c = Curl_cookie_init(argv[1], c);
  645. Curl_cookie_add(c, TRUE, "PERSONALIZE=none;expires=Monday, 13-Jun-1988 03:04:55 GMT; domain=.fidelity.com; path=/ftgw; secure");
  646. Curl_cookie_add(c, TRUE, "foobar=yes; domain=.haxx.se; path=/looser;");
  647. c = Curl_cookie_init(argv[1], c);
  648. Curl_cookie_output(c);
  649. Curl_cookie_cleanup(c);
  650. return 0;
  651. }
  652. return 1;
  653. }
  654. #endif
  655. #endif /* CURL_DISABLE_HTTP */
  656. /*
  657. * local variables:
  658. * eval: (load-file "../curl-mode.el")
  659. * end:
  660. * vim600: fdm=marker
  661. * vim: et sw=2 ts=2 sts=2 tw=78
  662. */