~ubuntu-branches/ubuntu/lucid/curl/lucid-201101212007

« back to all changes in this revision

Viewing changes to lib/cookie.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-02-08 11:20:41 UTC
  • mto: (3.1.1 lenny) (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: james.westby@ubuntu.com-20080208112041-hed7sb5r6ghmjf8v
Tags: upstream-7.18.0
Import upstream version 7.18.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
 * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
9
9
 *
10
10
 * This software is licensed as described in the file COPYING, which
11
11
 * you should have received as part of this distribution. The terms
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
21
 
 * $Id: cookie.c,v 1.84 2007-08-29 05:36:53 danf Exp $
 
21
 * $Id: cookie.c,v 1.86 2008-01-23 22:22:12 bagder Exp $
22
22
 ***************************************************************************/
23
23
 
24
24
/***
483
483
        /* It turns out, that sometimes the file format allows the path
484
484
           field to remain not filled in, we try to detect this and work
485
485
           around it! Andr�s Garc�a made us aware of this... */
486
 
        if (strcmp("TRUE", ptr) && strcmp("FALSE", ptr)) {
 
486
        if(strcmp("TRUE", ptr) && strcmp("FALSE", ptr)) {
487
487
          /* only if the path doesn't look like a boolean option! */
488
488
          co->path = strdup(ptr);
489
489
          if(!co->path)
812
812
void Curl_cookie_clearall(struct CookieInfo *cookies)
813
813
{
814
814
  if(cookies) {
815
 
    Curl_cookie_freelist(cookies->cookies);
 
815
    Curl_cookie_freelist(cookies->cookies, TRUE);
816
816
    cookies->cookies = NULL;
817
817
    cookies->numcookies = 0;
818
818
  }
824
824
 *
825
825
 * Free a list of cookies previously returned by Curl_cookie_getlist();
826
826
 *
 
827
 * The 'cookiestoo' argument tells this function whether to just free the
 
828
 * list or actually also free all cookies within the list as well.
 
829
 *
827
830
 ****************************************************************************/
828
831
 
829
 
void Curl_cookie_freelist(struct Cookie *co)
 
832
void Curl_cookie_freelist(struct Cookie *co, bool cookiestoo)
830
833
{
831
834
  struct Cookie *next;
832
835
  if(co) {
833
836
    while(co) {
834
837
      next = co->next;
835
 
      free(co); /* we only free the struct since the "members" are all
836
 
                      just copied! */
 
838
      if(cookiestoo)
 
839
        freecookie(co);
 
840
      else
 
841
        free(co); /* we only free the struct since the "members" are all just
 
842
                     pointed out in the main cookie list! */
837
843
      co = next;
838
844
    }
839
845
  }
867
873
      else
868
874
        prev->next = next;
869
875
 
870
 
      free(curr);
 
876
      freecookie(curr);
871
877
      cookies->numcookies--;
872
878
    }
873
879
    else
972
978
 
973
979
    while(co) {
974
980
      format_ptr = get_netscape_format(co);
975
 
      if (format_ptr == NULL) {
 
981
      if(format_ptr == NULL) {
976
982
        fprintf(out, "#\n# Fatal libcurl error\n");
977
983
        fclose(out);
978
984
        return 1;
996
1002
  struct Cookie *c;
997
1003
  char *line;
998
1004
 
999
 
  if ((data->cookies == NULL) ||
 
1005
  if((data->cookies == NULL) ||
1000
1006
      (data->cookies->numcookies == 0))
1001
1007
    return NULL;
1002
1008
 
1003
1009
  c = data->cookies->cookies;
1004
1010
 
1005
1011
  beg = list;
1006
 
  while (c) {
 
1012
  while(c) {
1007
1013
    /* fill the list with _all_ the cookies we know */
1008
1014
    line = get_netscape_format(c);
1009
 
    if (line == NULL) {
 
1015
    if(line == NULL) {
1010
1016
      curl_slist_free_all(beg);
1011
1017
      return NULL;
1012
1018
    }
1013
1019
    list = curl_slist_append(list, line);
1014
1020
    free(line);
1015
 
    if (list == NULL) {
 
1021
    if(list == NULL) {
1016
1022
      curl_slist_free_all(beg);
1017
1023
      return NULL;
1018
1024
    }
1019
 
    else if (beg == NULL) {
 
1025
    else if(beg == NULL) {
1020
1026
      beg = list;
1021
1027
    }
1022
1028
    c = c->next;