Skip to content
Snippets Groups Projects
url.c 153 KiB
Newer Older
/***************************************************************************
 *                                  _   _ ____  _
 *  Project                     ___| | | |  _ \| |
 *                             / __| | | | |_) | |
 *                            | (__| |_| |  _ <| |___
Daniel Stenberg's avatar
Daniel Stenberg committed
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
Daniel Stenberg's avatar
Daniel Stenberg committed
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
 * are also available at http://curl.haxx.se/docs/copyright.html.
Daniel Stenberg's avatar
Daniel Stenberg committed
 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
 * copies of the Software, and permit persons to whom the Software is
 * furnished to do so, under the terms of the COPYING file.
Daniel Stenberg's avatar
Daniel Stenberg committed
 *
Daniel Stenberg's avatar
Daniel Stenberg committed
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
Daniel Stenberg's avatar
Daniel Stenberg committed
 *
Daniel Stenberg's avatar
Daniel Stenberg committed
 * $Id$
 ***************************************************************************/
Daniel Stenberg's avatar
Daniel Stenberg committed

/* -- WIN32 approved -- */
Daniel Stenberg's avatar
Daniel Stenberg committed
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>

#ifdef WIN32
Daniel Stenberg's avatar
Daniel Stenberg committed
#include <time.h>
#include <io.h>
#else
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
Daniel Stenberg's avatar
Daniel Stenberg committed
#include <netinet/in.h>
Daniel Stenberg's avatar
Daniel Stenberg committed
#include <sys/time.h>
Gisle Vanem's avatar
Gisle Vanem committed
#endif
Daniel Stenberg's avatar
Daniel Stenberg committed
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
Daniel Stenberg's avatar
Daniel Stenberg committed
#include <netdb.h>
Daniel Stenberg's avatar
Daniel Stenberg committed
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef HAVE_NET_IF_H
#include <net/if.h>
#endif
Daniel Stenberg's avatar
Daniel Stenberg committed
#include <sys/ioctl.h>
Daniel Stenberg's avatar
Daniel Stenberg committed

#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif

Daniel Stenberg's avatar
Daniel Stenberg committed
#ifdef VMS
Daniel Stenberg's avatar
Daniel Stenberg committed
#include <in.h>
#include <inet.h>
#endif

Daniel Stenberg's avatar
Daniel Stenberg committed
#ifndef HAVE_SOCKET
#error "We can't compile without socket() support!"
#endif
Yang Tse's avatar
 
Yang Tse committed
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif

Gisle Vanem's avatar
 
Gisle Vanem committed
#include <tld.h>
#ifdef HAVE_IDN_FREE_H
#include <idn-free.h>
#else
void idn_free (void *ptr); /* prototype from idn-free.h, not provided by
                              libidn 0.4.5's make install! */
#ifndef HAVE_IDN_FREE
/* if idn_free() was not found in this version of libidn, use plain free()
   instead */
#define idn_free(x) (free)(x)
#endif
#endif  /* USE_LIBIDN */
Daniel Stenberg's avatar
Daniel Stenberg committed
#include "urldata.h"
#include "netrc.h"

#include "formdata.h"
Daniel Stenberg's avatar
Daniel Stenberg committed
#include "hostip.h"
Daniel Stenberg's avatar
Daniel Stenberg committed
#include "sendf.h"
#include "progress.h"
#include "cookie.h"
#include "strequal.h"
#include "strtok.h"
#include "share.h"
#include "http_digest.h"
#include "select.h"
Daniel Stenberg's avatar
Daniel Stenberg committed

/* And now for the protocols */
#include "ftp.h"
#include "dict.h"
#include "telnet.h"
Daniel Stenberg's avatar
Daniel Stenberg committed
#include "http.h"
#include "file.h"
#include "connect.h"
#include "http_ntlm.h"
Daniel Stenberg's avatar
Daniel Stenberg committed
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>

#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
Daniel Stenberg's avatar
Daniel Stenberg committed

/* Local static prototypes */
static long ConnectionKillOne(struct SessionHandle *data);
static void conn_free(struct connectdata *conn);
static void signalPipeClose(struct curl_llist *pipeline, bool pipe_broke);
#ifdef CURL_DISABLE_VERBOSE_STRINGS
#define verboseconnect(x)  do { } while (0)
#endif

static const struct Curl_handler * const protocols[] = {

#ifndef CURL_DISABLE_HTTP
  &Curl_handler_http,
#endif

#if defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)
  &Curl_handler_https,
#endif

#ifndef CURL_DISABLE_FTP
  &Curl_handler_ftp,
#endif

#if defined(USE_SSL) && !defined(CURL_DISABLE_FTP)
  &Curl_handler_ftps,
#endif

#ifndef CURL_DISABLE_TELNET
  &Curl_handler_telnet,
#endif

#ifndef CURL_DISABLE_DICT
  &Curl_handler_dict,
#endif

#ifndef CURL_DISABLE_LDAP
  &Curl_handler_ldap,
#endif

#if !defined(CURL_DISABLE_LDAP) && defined(HAVE_LDAP_SSL)
  &Curl_handler_ldaps,
#endif

#ifndef CURL_DISABLE_FILE
  &Curl_handler_file,
#endif

#ifndef CURL_DISABLE_TFTP
  &Curl_handler_tftp,
#endif
Loading
Loading full blame...