cookie.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef __COOKIE_H
  2. #define __COOKIE_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at http://curl.haxx.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. * $Id$
  24. ***************************************************************************/
  25. #include <stdio.h>
  26. #ifdef WIN32
  27. #include <time.h>
  28. #else
  29. #include <sys/time.h>
  30. #endif
  31. #include <curl/curl.h>
  32. struct Cookie {
  33. struct Cookie *next; /* next in the chain */
  34. char *name; /* <this> = value */
  35. char *value; /* name = <this> */
  36. char *path; /* path = <this> */
  37. char *domain; /* domain = <this> */
  38. long expires; /* expires = <this> */
  39. char *expirestr; /* the plain text version */
  40. bool tailmatch; /* weather we do tail-matchning of the domain name */
  41. /* RFC 2109 keywords. Version=1 means 2109-compliant cookie sending */
  42. char *version; /* Version = <value> */
  43. char *maxage; /* Max-Age = <value> */
  44. bool secure; /* whether the 'secure' keyword was used */
  45. bool livecookie; /* updated from a server, not a stored file */
  46. };
  47. struct CookieInfo {
  48. /* linked list of cookies we know of */
  49. struct Cookie *cookies;
  50. char *filename; /* file we read from/write to */
  51. bool running; /* state info, for cookie adding information */
  52. long numcookies; /* number of cookies in the "jar" */
  53. bool newsession; /* new session, discard session cookies on load */
  54. };
  55. /* This is the maximum line length we accept for a cookie line */
  56. #define MAX_COOKIE_LINE 2048
  57. #define MAX_COOKIE_LINE_TXT "2047"
  58. /* This is the maximum length of a cookie name we deal with: */
  59. #define MAX_NAME 256
  60. #define MAX_NAME_TXT "255"
  61. struct SessionHandle;
  62. /*
  63. * Add a cookie to the internal list of cookies. The domain and path arguments
  64. * are only used if the header boolean is TRUE.
  65. */
  66. struct Cookie *Curl_cookie_add(struct SessionHandle *data,
  67. struct CookieInfo *, bool header, char *line,
  68. char *domain, char *path);
  69. struct CookieInfo *Curl_cookie_init(struct SessionHandle *data,
  70. char *, struct CookieInfo *, bool);
  71. struct Cookie *Curl_cookie_getlist(struct CookieInfo *, char *, char *, bool);
  72. void Curl_cookie_freelist(struct Cookie *);
  73. void Curl_cookie_cleanup(struct CookieInfo *);
  74. int Curl_cookie_output(struct CookieInfo *, char *);
  75. #endif