~ubuntu-branches/ubuntu/gutsy/curl/gutsy

« back to all changes in this revision

Viewing changes to lib/urldata.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-06-29 15:04:24 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20060629150424-pn00qumt9sml8p4m
Tags: 7.15.4-1ubuntu1
Synchronize to Debian. Only change left: Removal of stunnel and
libdb4.2-dev build dependencies.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 *                            | (__| |_| |  _ <| |___
8
8
 *                             \___|\___/|_| \_\_____|
9
9
 *
10
 
 * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
 
10
 * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
11
11
 *
12
12
 * This software is licensed as described in the file COPYING, which
13
13
 * you should have received as part of this distribution. The terms
20
20
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21
21
 * KIND, either express or implied.
22
22
 *
23
 
 * $Id: urldata.h,v 1.275 2005/11/28 23:06:00 bagder Exp $
 
23
 * $Id: urldata.h,v 1.291 2006-05-26 11:26:42 bagder Exp $
24
24
 ***************************************************************************/
25
25
 
26
26
/* This file is for lib internal stuff */
30
30
#define PORT_FTP 21
31
31
#define PORT_FTPS 990
32
32
#define PORT_TELNET 23
33
 
#define PORT_GOPHER 70
34
33
#define PORT_HTTP 80
35
34
#define PORT_HTTPS 443
36
35
#define PORT_DICT 2628
97
96
#include "http_chunks.h" /* for the structs and enum stuff */
98
97
#include "hostip.h"
99
98
#include "hash.h"
 
99
#include "splay.h"
100
100
 
101
101
#ifdef HAVE_GSSAPI
102
102
# ifdef HAVE_GSSGNU
129
129
  int eof_flag;
130
130
};
131
131
enum protection_level {
132
 
    prot_clear,
133
 
    prot_safe,
134
 
    prot_confidential,
135
 
    prot_private
 
132
  prot_clear,
 
133
  prot_safe,
 
134
  prot_confidential,
 
135
  prot_private
136
136
};
137
137
#endif
138
138
 
 
139
/* enum for the nonblocking SSL connection state machine */
 
140
typedef enum {
 
141
  ssl_connect_1,
 
142
  ssl_connect_2,
 
143
  ssl_connect_2_reading,
 
144
  ssl_connect_2_writing,
 
145
  ssl_connect_3,
 
146
  ssl_connect_done
 
147
} ssl_connect_state;
 
148
 
139
149
/* struct for data related to each SSL connection */
140
150
struct ssl_connect_data {
141
151
  bool use;        /* use ssl encrypted communications TRUE/FALSE */
144
154
  SSL_CTX* ctx;
145
155
  SSL*     handle;
146
156
  X509*    server_cert;
 
157
  ssl_connect_state connecting_state;
147
158
#endif /* USE_SSLEAY */
148
159
#ifdef USE_GNUTLS
149
160
  gnutls_session session;
150
 
  gnutls_anon_client_credentials cred;
 
161
  gnutls_certificate_credentials cred;
151
162
#endif /* USE_GNUTLS */
152
163
};
153
164
 
209
220
#include <rpc.h>
210
221
#endif
211
222
 
 
223
#if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
 
224
#include <iconv.h>
 
225
#endif
 
226
 
212
227
/* Struct used for NTLM challenge-response authentication */
213
228
struct ntlmdata {
214
229
  curlntlm state;
221
236
  void *type_2;
222
237
  int n_type_2;
223
238
#else
 
239
  unsigned int flags;
224
240
  unsigned char nonce[8];
225
241
#endif
226
242
};
343
359
                       should be FALSE when it gets to Curl_ftp_quit() */
344
360
  bool cwddone;     /* if it has been determined that the proper CWD combo
345
361
                       already has been done */
 
362
  bool cwdfail;     /* set TRUE if a CWD command fails, as then we must prevent
 
363
                       caching the current directory */
346
364
  char *prevpath;   /* conn->path from the previous transfer */
347
365
 
348
366
  size_t nread_resp; /* number of bytes currently read of a server response */
426
444
  bool ftp_use_eprt;  /* As set with CURLOPT_FTP_USE_EPRT, but if we find out
427
445
                         EPRT doesn't work we disable it for the forthcoming
428
446
                         requests */
429
 
  bool ftp_use_lprt;  /* As set with CURLOPT_FTP_USE_EPRT, but if we find out
430
 
                         LPRT doesn't work we disable it for the forthcoming
431
 
                         requests */
432
447
  bool netrc;         /* name+password provided by netrc */
433
448
 
434
449
  bool trailerHdrPresent; /* Set when Trailer: header found in HTTP response.
435
450
                             Required to determine whether to look for trailers
436
451
                             in case of Transfer-Encoding: chunking */
 
452
  bool done;          /* set to FALSE when Curl_do() is called and set to TRUE
 
453
                         when Curl_done() is called, to prevent Curl_done() to
 
454
                         get invoked twice when the multi interface is
 
455
                         used. */
437
456
};
438
457
 
439
458
struct hostname {
527
546
#define FIRSTSOCKET     0
528
547
#define SECONDARYSOCKET 1
529
548
 
 
549
/* These function pointer types are here only to allow easier typecasting
 
550
   within the source when we need to cast between data pointers (such as NULL)
 
551
   and function pointers. */
 
552
typedef CURLcode (*Curl_do_more_func)(struct connectdata *);
 
553
typedef CURLcode (*Curl_done_func)(struct connectdata *, CURLcode);
 
554
 
530
555
/*
531
556
 * The connectdata struct contains all fields and variables that should be
532
557
 * unique for an entire connection.
539
564
 
540
565
  long protocol; /* PROT_* flags concerning the protocol set */
541
566
#define PROT_MISSING (1<<0)
542
 
#define PROT_GOPHER  (1<<1)
543
567
#define PROT_HTTP    (1<<2)
544
568
#define PROT_HTTPS   (1<<3)
545
569
#define PROT_FTP     (1<<4)
612
636
  /* These two functions MUST be set by the curl_connect() function to be
613
637
     be protocol dependent */
614
638
  CURLcode (*curl_do)(struct connectdata *, bool *done);
615
 
  CURLcode (*curl_done)(struct connectdata *, CURLcode);
 
639
  Curl_done_func curl_done;
616
640
 
617
641
  /* If the curl_do() function is better made in two halves, this
618
642
   * curl_do_more() function will be called afterwards, if set. For example
619
643
   * for doing the FTP stuff after the PASV/PORT command.
620
644
   */
621
 
  CURLcode (*curl_do_more)(struct connectdata *);
 
645
  Curl_do_more_func curl_do_more;
622
646
 
623
647
  /* This function *MAY* be set to a protocol-dependent function that is run
624
648
   * after the connect() and everything is done, as a step in the connection.
634
658
 
635
659
  /* Called from the multi interface during the PROTOCONNECT phase, and it
636
660
     should then return a proper fd set */
637
 
  CURLcode (*curl_proto_fdset)(struct connectdata *conn,
638
 
                               fd_set *read_fd_set,
639
 
                               fd_set *write_fd_set,
640
 
                               int *max_fdp);
 
661
  int (*curl_proto_getsock)(struct connectdata *conn,
 
662
                            curl_socket_t *socks,
 
663
                            int numsocks);
641
664
 
642
665
  /* Called from the multi interface during the DOING phase, and it should
643
666
     then return a proper fd set */
644
 
  CURLcode (*curl_doing_fdset)(struct connectdata *conn,
645
 
                               fd_set *read_fd_set,
646
 
                               fd_set *write_fd_set,
647
 
                               int *max_fdp);
 
667
  int (*curl_doing_getsock)(struct connectdata *conn,
 
668
                            curl_socket_t *socks,
 
669
                            int numsocks);
648
670
 
649
671
  /* This function *MAY* be set to a protocol-dependent function that is run
650
672
   * by the curl_disconnect(), as a step in the disconnection.
701
723
  /* previously this was in the urldata struct */
702
724
  union {
703
725
    struct HTTP *http;
704
 
    struct HTTP *gopher; /* alias, just for the sake of being more readable */
705
726
    struct HTTP *https;  /* alias, just for the sake of being more readable */
706
727
    struct FTP *ftp;
707
728
    void *tftp;        /* private for tftp.c-eyes only */
822
843
 
823
844
/*
824
845
 * Values that are generated, temporary or calculated internally for a
825
 
 * "session handle" must be defined within the 'struct urlstate'.  This struct
 
846
 * "session handle" must be defined within the 'struct UrlState'.  This struct
826
847
 * will be used within the SessionHandle struct. When the 'SessionHandle'
827
848
 * struct is cloned, this data MUST NOT be copied.
828
849
 *
860
881
     set, it holds an allocated connection. */
861
882
  struct connectdata **connects;
862
883
  long numconnects; /* size of the 'connects' array */
 
884
  long lastconnect;  /* index of most recent connect or -1 if undefined */
863
885
 
864
886
  char *headerbuff; /* allocated buffer to store headers in */
865
887
  size_t headersize;   /* size of the allocation */
909
931
#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
910
932
  ENGINE *engine;
911
933
#endif /* USE_SSLEAY */
 
934
  struct timeval expiretime; /* set this with Curl_expire() only */
 
935
  struct Curl_tree timenode; /* for the splay stuff */
 
936
 
 
937
  /* a place to store the most recenlty set FTP entrypath */
 
938
  char *most_recent_ftp_entrypath;
 
939
 
 
940
#ifndef WIN32
 
941
/* do FTP line-end conversions on most platforms */
 
942
#define CURL_DO_LINEEND_CONV
 
943
  /* for FTP downloads: track CRLF sequences that span blocks */
 
944
  bool prev_block_had_trailing_cr;
 
945
  /* for FTP downloads: how many CRLFs did we converted to LFs? */
 
946
  curl_off_t crlf_conversions;
 
947
#endif
912
948
};
913
949
 
914
950
 
938
974
 * This 'UserDefined' struct must only contain data that is set once to go
939
975
 * for many (perhaps) independent connections. Values that are generated or
940
976
 * calculated internally for the "session handle" MUST be defined within the
941
 
 * 'struct urlstate' instead. The only exceptions MUST note the changes in
 
977
 * 'struct UrlState' instead. The only exceptions MUST note the changes in
942
978
 * the 'DynamicStatic' struct.
943
979
 */
 
980
struct Curl_one_easy; /* declared and used only in multi.c */
 
981
struct Curl_multi;    /* declared and used only in multi.c */
944
982
 
945
983
struct UserDefined {
946
984
  FILE *err;         /* the stderr user data goes here */
952
990
                     this. */
953
991
  void *out;         /* the fetched file goes here */
954
992
  void *in;          /* the uploaded file is read from here */
955
 
  void *writeheader; /* write the header to this is non-NULL */
 
993
  void *writeheader; /* write the header to this if non-NULL */
956
994
  char *set_url;     /* what original URL to work on */
957
995
  char *set_proxy;   /* proxy to use */
958
996
  long use_port;     /* which port to use (when not using default) */
974
1012
                               of strlen(), and then the data *may* be binary
975
1013
                               (contain zero bytes) */
976
1014
  char *ftpport;     /* port to send with the FTP PORT command */
977
 
  char *device;      /* network interface to use */
 
1015
  char *device;      /* local network interface/address to use */
 
1016
  unsigned short localport; /* local port number to bind to */
 
1017
  int localportrange; /* number of additional port numbers to test in case the
 
1018
                         'localport' one can't be bind()ed */
978
1019
  curl_write_callback fwrite;        /* function that stores the output */
979
1020
  curl_write_callback fwrite_header; /* function that stores headers */
980
1021
  curl_read_callback fread;          /* function that reads the input */
981
1022
  curl_progress_callback fprogress;  /* function for progress information */
982
1023
  curl_debug_callback fdebug;      /* function that write informational data */
983
1024
  curl_ioctl_callback ioctl;       /* function for I/O control */
 
1025
 
 
1026
  /* the 3 curl_conv_callback functions below are used on non-ASCII hosts */
 
1027
  /* function to convert from the network encoding: */
 
1028
  curl_conv_callback convfromnetwork;
 
1029
  /* function to convert to the network encoding: */
 
1030
  curl_conv_callback convtonetwork;
 
1031
  /* function to convert from UTF-8 encoding: */
 
1032
  curl_conv_callback convfromutf8;
 
1033
 
984
1034
  void *progress_client; /* pointer to pass to the progress callback */
985
1035
  void *ioctl_client;   /* pointer to pass to the ioctl callback */
986
1036
  long timeout;         /* in seconds, 0 means no timeout */
1032
1082
 
1033
1083
  char *private_data; /* Private data */
1034
1084
 
 
1085
  struct Curl_one_easy *one_easy; /* When adding an easy handle to a multi
 
1086
                                     handle, an internal 'Curl_one_easy'
 
1087
                                     struct is created and this is a pointer
 
1088
                                     to the particular struct associated with
 
1089
                                     this SessionHandle */
 
1090
 
1035
1091
  struct curl_slist *http200aliases; /* linked list of aliases for http200 */
1036
1092
 
1037
1093
  long ip_version;
1076
1132
  bool expect100header;  /* TRUE if we added Expect: 100-continue */
1077
1133
  bool ftp_use_epsv;     /* if EPSV is to be attempted or not */
1078
1134
  bool ftp_use_eprt;     /* if EPRT is to be attempted or not */
1079
 
  bool ftp_use_lprt;     /* if LPRT is to be attempted or not */
1080
1135
  curl_ftpssl ftp_ssl;   /* if AUTH TLS is to be attempted etc */
1081
1136
  curl_ftpauth ftpsslauth; /* what AUTH XXX to be attempted */
1082
1137
  bool no_signal;        /* do not use any signal/alarm handler */
1085
1140
  bool ignorecl;         /* ignore content length */
1086
1141
  bool ftp_skip_ip;      /* skip the IP address the FTP server passes on to
1087
1142
                            us */
 
1143
  bool connect_only;     /* make connection, let application use the socket */
1088
1144
};
1089
1145
 
1090
1146
/*
1096
1152
 * From now on, the 'SessionHandle' must only contain data that is set once to
1097
1153
 * go for many (perhaps) independent connections. Values that are generated or
1098
1154
 * calculated internally for the "session handle" must be defined within the
1099
 
 * 'struct urlstate' instead.  */
 
1155
 * 'struct UrlState' instead.  */
1100
1156
 
1101
1157
struct SessionHandle {
1102
1158
  struct curl_hash *hostcache;
1103
 
  void *multi;                 /* if non-NULL, points to the multi handle
 
1159
  struct Curl_multi *multi;    /* if non-NULL, points to the multi handle
1104
1160
                                  struct of which this "belongs" */
1105
1161
  struct Curl_share *share;    /* Share, handles global variable mutexing */
1106
1162
  struct UserDefined set;      /* values set by the libcurl user */
1111
1167
  struct UrlState state;       /* struct for fields used for state info and
1112
1168
                                  other dynamic purposes */
1113
1169
  struct PureInfo info;        /* stats, reports and info data */
 
1170
  /* set by ftp_transfertype for use by Curl_client_write and others */
 
1171
  bool ftp_in_ascii_mode;
 
1172
#if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
 
1173
  iconv_t outbound_cd;         /* for translating to the network encoding */
 
1174
  iconv_t inbound_cd;          /* for translating from the network encoding */
 
1175
  iconv_t utf8_cd;             /* for translating to UTF8 */
 
1176
#endif /* CURL_DOES_CONVERSIONS && HAVE_ICONV */
1114
1177
};
1115
1178
 
1116
1179
#define LIBCURL_NAME "libcurl"