Compare commits
57 Commits
curl-7_8
...
curl-7_8_1
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a6a3673804 | ||
![]() |
944f9a73f4 | ||
![]() |
5ab1a10e9c | ||
![]() |
1813d2ddf7 | ||
![]() |
2827f5327a | ||
![]() |
47bb09e908 | ||
![]() |
7f21669ef2 | ||
![]() |
3a145180cc | ||
![]() |
f24d54a9c4 | ||
![]() |
9478d796a3 | ||
![]() |
00b00c6931 | ||
![]() |
e791f6ec58 | ||
![]() |
8987244758 | ||
![]() |
9b69f6faab | ||
![]() |
e7b966b9eb | ||
![]() |
e7801afed1 | ||
![]() |
929366b5ae | ||
![]() |
e1d8c5daa7 | ||
![]() |
2b44fdab2e | ||
![]() |
3e0a95bb78 | ||
![]() |
f0efa89484 | ||
![]() |
45037a39aa | ||
![]() |
31336d63ae | ||
![]() |
2c39a4381a | ||
![]() |
532624bafe | ||
![]() |
8469918306 | ||
![]() |
9646a8b346 | ||
![]() |
5e2a74fcc4 | ||
![]() |
813d7585c7 | ||
![]() |
ae55c1c144 | ||
![]() |
1a6143feba | ||
![]() |
b70a4227b3 | ||
![]() |
7d82bc81a2 | ||
![]() |
be449bdea1 | ||
![]() |
798aaf0c0a | ||
![]() |
6f2fca53ad | ||
![]() |
cd4aed6690 | ||
![]() |
fa601af722 | ||
![]() |
303b3cf41c | ||
![]() |
fc535aa086 | ||
![]() |
cd33795903 | ||
![]() |
c9d233d34a | ||
![]() |
bd192d5387 | ||
![]() |
4ac7a087c6 | ||
![]() |
2d5039184e | ||
![]() |
b1bbaebb17 | ||
![]() |
8f6997cbde | ||
![]() |
e18ecaf108 | ||
![]() |
fe67ba6d2b | ||
![]() |
e39e6c537e | ||
![]() |
4e4a899306 | ||
![]() |
9a78db6e59 | ||
![]() |
6475600afa | ||
![]() |
e450888b15 | ||
![]() |
23522a66d1 | ||
![]() |
116462a512 | ||
![]() |
217e033120 |
1381
CHANGES.2000
Normal file
1381
CHANGES.2000
Normal file
File diff suppressed because it is too large
Load Diff
44
configure.in
44
configure.in
@@ -64,8 +64,32 @@ AC_ARG_ENABLE(debug,
|
|||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
dnl ************************************************************
|
||||||
|
dnl check for "localhost", if it doesn't exist, we can't do the
|
||||||
|
dnl gethostbyname_r tests!
|
||||||
|
dnl
|
||||||
|
|
||||||
dnl
|
AC_DEFUN(CURL_CHECK_WORKING_RESOLVER,[
|
||||||
|
AC_MSG_CHECKING([if "localhost" resolves])
|
||||||
|
AC_TRY_RUN([
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main () {
|
||||||
|
struct hostent *h;
|
||||||
|
h = gethostbyname("localhost");
|
||||||
|
exit (h == NULL ? 1 : 0); }],[
|
||||||
|
AC_MSG_RESULT(yes)],[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
AC_MSG_ERROR([can't figure out gethostbyname_r() since localhost doesn't resolve])
|
||||||
|
|
||||||
|
]
|
||||||
|
)
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl ************************************************************
|
||||||
dnl check for working getaddrinfo()
|
dnl check for working getaddrinfo()
|
||||||
dnl
|
dnl
|
||||||
AC_DEFUN(CURL_CHECK_WORKING_GETADDRINFO,[
|
AC_DEFUN(CURL_CHECK_WORKING_GETADDRINFO,[
|
||||||
@@ -559,13 +583,20 @@ then
|
|||||||
else
|
else
|
||||||
|
|
||||||
dnl Check for and handle argument to --with-ssl.
|
dnl Check for and handle argument to --with-ssl.
|
||||||
EXTRA_SSL=
|
|
||||||
|
dnl save the pre-ssl check flags for a while
|
||||||
|
CLEANLDFLAGS="$LDFLAGS"
|
||||||
|
CLEANCPPFLAGS="$CPPFLAGS"
|
||||||
|
|
||||||
case "$OPT_SSL" in
|
case "$OPT_SSL" in
|
||||||
yes)
|
yes)
|
||||||
EXTRA_SSL=/usr/local/ssl ;;
|
EXTRA_SSL=/usr/local/ssl ;;
|
||||||
*)
|
*)
|
||||||
EXTRA_SSL=$OPT_SSL ;;
|
dnl check the given spot right away!
|
||||||
|
EXTRA_SSL=$OPT_SSL
|
||||||
|
LDFLAGS="$LDFLAGS -L$EXTRA_SSL/lib"
|
||||||
|
CPPFLAGS="$CPPFLAGS -I$EXTRA_SSL/include/openssl -I$EXTRA_SSL/include"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
AC_CHECK_LIB(crypto, CRYPTO_lock,[
|
AC_CHECK_LIB(crypto, CRYPTO_lock,[
|
||||||
@@ -573,8 +604,8 @@ else
|
|||||||
],[
|
],[
|
||||||
OLDLDFLAGS="$LDFLAGS"
|
OLDLDFLAGS="$LDFLAGS"
|
||||||
OLDCPPFLAGS="$CPPFLAGS"
|
OLDCPPFLAGS="$CPPFLAGS"
|
||||||
LDFLAGS="$LDFLAGS -L$EXTRA_SSL/lib"
|
LDFLAGS="$CLEANLDFLAGS -L$EXTRA_SSL/lib"
|
||||||
CPPFLAGS="$CPPFLAGS -I$EXTRA_SSL/include/openssl -I$EXTRA_SSL/include"
|
CPPFLAGS="$CLEANCPPFLAGS -I$EXTRA_SSL/include/openssl -I$EXTRA_SSL/include"
|
||||||
AC_CHECK_LIB(crypto, CRYPTO_add_lock,[
|
AC_CHECK_LIB(crypto, CRYPTO_add_lock,[
|
||||||
HAVECRYPTO="yes" ], [
|
HAVECRYPTO="yes" ], [
|
||||||
LDFLAGS="$OLDLDFLAGS"
|
LDFLAGS="$OLDLDFLAGS"
|
||||||
@@ -681,6 +712,9 @@ then
|
|||||||
Set to explicitly specify we don't want to use thread-safe functions)
|
Set to explicitly specify we don't want to use thread-safe functions)
|
||||||
else
|
else
|
||||||
|
|
||||||
|
dnl check that 'localhost' resolves first
|
||||||
|
CURL_CHECK_WORKING_RESOLVER
|
||||||
|
|
||||||
dnl dig around for gethostbyname_r()
|
dnl dig around for gethostbyname_r()
|
||||||
CURL_CHECK_GETHOSTBYNAME_R()
|
CURL_CHECK_GETHOSTBYNAME_R()
|
||||||
|
|
||||||
|
@@ -591,7 +591,7 @@ HTTPS
|
|||||||
Run the 'openssl' application to convert the certificate. If you cd to the
|
Run the 'openssl' application to convert the certificate. If you cd to the
|
||||||
openssl installation, you can do it like:
|
openssl installation, you can do it like:
|
||||||
|
|
||||||
# ./apps/openssl pkcs12 -certfile [file you saved] -out [PEMfile]
|
# ./apps/openssl pkcs12 -in [file you saved] -clcerts -out [PEMfile]
|
||||||
|
|
||||||
|
|
||||||
RESUMING FILE TRANSFERS
|
RESUMING FILE TRANSFERS
|
||||||
|
@@ -26,7 +26,7 @@ man_MANS = \
|
|||||||
curl_mprintf.3 \
|
curl_mprintf.3 \
|
||||||
curl_global_init.3 \
|
curl_global_init.3 \
|
||||||
curl_global_cleanup.3 \
|
curl_global_cleanup.3 \
|
||||||
libcurl.5
|
libcurl.3
|
||||||
|
|
||||||
EXTRA_DIST = $(man_MANS) \
|
EXTRA_DIST = $(man_MANS) \
|
||||||
MANUAL BUGS CONTRIBUTE FAQ FEATURES INTERNALS \
|
MANUAL BUGS CONTRIBUTE FAQ FEATURES INTERNALS \
|
||||||
|
43
docs/TODO
43
docs/TODO
@@ -7,22 +7,43 @@
|
|||||||
TODO
|
TODO
|
||||||
|
|
||||||
Things to do in project cURL. Please tell me what you think, contribute and
|
Things to do in project cURL. Please tell me what you think, contribute and
|
||||||
send me patches that improve things!
|
send me patches that improve things! Also check the http://curl.haxx.se/dev
|
||||||
|
web section for various development notes.
|
||||||
|
|
||||||
To do in a future release (random order):
|
To do in a future release (random order):
|
||||||
|
|
||||||
|
* It would be nice to be able to use "-d" (or something similar) to attach
|
||||||
|
parameters of EITHER the GET or POST type... It would either require
|
||||||
|
another curl argument to specify "GET" (obviously the default should remain
|
||||||
|
POST), or it would require a new curl argument (perhaps -G/--get-data).
|
||||||
|
|
||||||
|
I know we're running out of letters, but it somehow feels a little
|
||||||
|
"cleaner" to just tag on each of your HTTP "parameters" (data-items) one by
|
||||||
|
one and let curl put them together, rather than having to put them together
|
||||||
|
myself and include them in the URL.
|
||||||
|
|
||||||
|
* Add an interface that enables a user to select prefered SSL ciphers to use.
|
||||||
|
|
||||||
|
* Make curl deal with cookies better. libcurl should be able to maintain a
|
||||||
|
"cookie jar". Updating it with cookies that is received, and using it to
|
||||||
|
pass cookies to the servers that have matching cookies in the jar.
|
||||||
|
http://curl.haxx.se/dev/cookie-jar.txt
|
||||||
|
|
||||||
|
* Consider an interface to libcurl that allows applications to easier get to
|
||||||
|
know what cookies that are sent back in the response headers.
|
||||||
|
|
||||||
* Make SSL session ids get used if multiple HTTPS documents from the same
|
* Make SSL session ids get used if multiple HTTPS documents from the same
|
||||||
host is requested. Note: is this really prioritized now with the persistent
|
host is requested. http://curl.haxx.se/dev/SSL_session_id.txt
|
||||||
connections?
|
|
||||||
|
* HTTP PUT for files passed on stdin. Requires libcurl to send the file
|
||||||
|
with chunked content encoding. http://curl.haxx.se/dev/HTTP-PUT-stdin.txt
|
||||||
|
|
||||||
|
* Introduce another callback interface for upload/download that makes one
|
||||||
|
less copy of data and thus a faster operation.
|
||||||
|
http://curl.haxx.se/dev/no_copy_callbacks.txt
|
||||||
|
|
||||||
* Suggested on the mailing list: CURLOPT_FTP_MKDIR...!
|
* Suggested on the mailing list: CURLOPT_FTP_MKDIR...!
|
||||||
|
|
||||||
* Rewrite parts of the test suite. Make a (XML?) format to store all
|
|
||||||
test-data in a single for a single test case. The current system makes far
|
|
||||||
too many separate files. We also need to have the test suite support
|
|
||||||
different behaviors, like when libcurl is compiled for IPv6 support and
|
|
||||||
thus performs a different set of FTP commands.
|
|
||||||
|
|
||||||
* Add configure options that disables certain protocols in libcurl to
|
* Add configure options that disables certain protocols in libcurl to
|
||||||
decrease footprint. '--disable-[protocol]' where protocol is http, ftp,
|
decrease footprint. '--disable-[protocol]' where protocol is http, ftp,
|
||||||
telnet, ldap, dict or file.
|
telnet, ldap, dict or file.
|
||||||
@@ -30,6 +51,8 @@ To do in a future release (random order):
|
|||||||
* Extend the test suite to include telnet. The telnet could just do ftp or
|
* Extend the test suite to include telnet. The telnet could just do ftp or
|
||||||
http operations (for which we have test servers).
|
http operations (for which we have test servers).
|
||||||
|
|
||||||
|
* Make TELNET work on windows!
|
||||||
|
|
||||||
* Add a command line option that allows the output file to get the same time
|
* Add a command line option that allows the output file to get the same time
|
||||||
stamp as the remote file. libcurl already is capable of fetching the remote
|
stamp as the remote file. libcurl already is capable of fetching the remote
|
||||||
file's date.
|
file's date.
|
||||||
@@ -40,7 +63,7 @@ To do in a future release (random order):
|
|||||||
(http://gnutls.hellug.gr/)
|
(http://gnutls.hellug.gr/)
|
||||||
|
|
||||||
* Add asynchronous name resolving, as this enables full timeout support for
|
* Add asynchronous name resolving, as this enables full timeout support for
|
||||||
fork() systems.
|
fork() systems. http://curl.haxx.se/dev/async-resolver.txt
|
||||||
|
|
||||||
* Move non-URL related functions that are used by both the lib and the curl
|
* Move non-URL related functions that are used by both the lib and the curl
|
||||||
application to a separate "portability lib".
|
application to a separate "portability lib".
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
.\" nroff -man curl.1
|
.\" nroff -man curl.1
|
||||||
.\" Written by Daniel Stenberg
|
.\" Written by Daniel Stenberg
|
||||||
.\"
|
.\"
|
||||||
.TH curl 1 "8 May 2001" "Curl 7.7.3" "Curl Manual"
|
.TH curl 1 "3 Aug 2001" "Curl 7.8" "Curl Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
curl \- get a URL with FTP, TELNET, LDAP, GOPHER, DICT, FILE, HTTP or
|
curl \- get a URL with FTP, TELNET, LDAP, GOPHER, DICT, FILE, HTTP or
|
||||||
HTTPS syntax.
|
HTTPS syntax.
|
||||||
@@ -134,7 +134,8 @@ name=daniel -d skill=lousy' would generate a post chunk that looks like
|
|||||||
If you start the data with the letter @, the rest should be a file name to
|
If you start the data with the letter @, the rest should be a file name to
|
||||||
read the data from, or - if you want curl to read the data from stdin. The
|
read the data from, or - if you want curl to read the data from stdin. The
|
||||||
contents of the file must already be url-encoded. Multiple files can also be
|
contents of the file must already be url-encoded. Multiple files can also be
|
||||||
specified.
|
specified. Posting data from a file named 'foobar' would thus be done with
|
||||||
|
"--data @foobar".
|
||||||
|
|
||||||
To post data purely binary, you should instead use the --data-binary option.
|
To post data purely binary, you should instead use the --data-binary option.
|
||||||
|
|
||||||
|
@@ -8,7 +8,7 @@ curl_easy_cleanup - End a libcurl session
|
|||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B #include <curl/curl.h>
|
.B #include <curl/curl.h>
|
||||||
.sp
|
.sp
|
||||||
.BI "curl_easy_cleanup(CURL *" handle ");"
|
.BI "void curl_easy_cleanup(CURL *" handle ");"
|
||||||
.ad
|
.ad
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
This function must be the last function to call for a curl session. It is the
|
This function must be the last function to call for a curl session. It is the
|
||||||
|
@@ -27,10 +27,13 @@ This function was added in libcurl 7.8.
|
|||||||
.SH FLAGS
|
.SH FLAGS
|
||||||
.TP 5
|
.TP 5
|
||||||
.B CURL_GLOBAL_ALL
|
.B CURL_GLOBAL_ALL
|
||||||
Initialise everyting possible. This sets all known bits.
|
Initialize everything possible. This sets all known bits.
|
||||||
.TP
|
.TP
|
||||||
.B CURL_GLOBAL_SSL
|
.B CURL_GLOBAL_SSL
|
||||||
Initialise SSL
|
Initialize SSL
|
||||||
|
.TP
|
||||||
|
.B CURL_GLOBAL_WIN32
|
||||||
|
Initialize the Win32 socket libraries.
|
||||||
.TP
|
.TP
|
||||||
.B CURL_GLOBAL_NOTHING
|
.B CURL_GLOBAL_NOTHING
|
||||||
Initialise nothing extra. This sets no bit.
|
Initialise nothing extra. This sets no bit.
|
||||||
|
@@ -25,6 +25,6 @@ These functions are provided by libcurl to enable applications to compare
|
|||||||
strings in a truly portable manner. There are no standard portable case
|
strings in a truly portable manner. There are no standard portable case
|
||||||
insensitive string comparison functions. These two works on all platforms.
|
insensitive string comparison functions. These two works on all platforms.
|
||||||
.SH RETURN VALUE
|
.SH RETURN VALUE
|
||||||
A pointer to a zero terminated string.
|
Non-zero if the strings are identical. Zero if they're not.
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
.BR strcmp "(3), " strcasecmp "(3)"
|
.BR strcmp "(3), " strcasecmp "(3)"
|
||||||
|
@@ -1,14 +1,23 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Note: This is only required if you use curl 7.8 or lower, later
|
||||||
|
* versions provide an option to curl_global_init() that does the
|
||||||
|
* win32 initialization for you.
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These are example functions doing socket init that Windows
|
* These are example functions doing socket init that Windows
|
||||||
* require. If you don't use windows, you can safely ignore this crap.
|
* require. If you don't use windows, you can safely ignore this crap.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void win32_cleanup(void)
|
#include <windows.h>
|
||||||
|
|
||||||
|
void win32_cleanup(void)
|
||||||
{
|
{
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
static CURLcode win32_init(void)
|
int win32_init(void)
|
||||||
{
|
{
|
||||||
WORD wVersionRequested;
|
WORD wVersionRequested;
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
|
@@ -443,6 +443,11 @@ typedef enum {
|
|||||||
* parameters will use fwrite() syntax, make sure to follow them. */
|
* parameters will use fwrite() syntax, make sure to follow them. */
|
||||||
CINIT(HEADERFUNCTION, FUNCTIONPOINT, 79),
|
CINIT(HEADERFUNCTION, FUNCTIONPOINT, 79),
|
||||||
|
|
||||||
|
/* Set this to force the HTTP request to get back to GET. Only really usable
|
||||||
|
if POST, PUT or a custom request have been used first.
|
||||||
|
*/
|
||||||
|
CINIT(HTTPGET, LONG, 80),
|
||||||
|
|
||||||
CURLOPT_LASTENTRY /* the last unusued */
|
CURLOPT_LASTENTRY /* the last unusued */
|
||||||
} CURLoption;
|
} CURLoption;
|
||||||
|
|
||||||
@@ -504,8 +509,8 @@ void curl_global_cleanup(void);
|
|||||||
|
|
||||||
|
|
||||||
/* This is the version number */
|
/* This is the version number */
|
||||||
#define LIBCURL_VERSION "7.8"
|
#define LIBCURL_VERSION "7.8.1-pre3"
|
||||||
#define LIBCURL_VERSION_NUM 0x070800
|
#define LIBCURL_VERSION_NUM 0x070801
|
||||||
|
|
||||||
/* linked-list structure for the CURLOPT_QUOTE option (and other) */
|
/* linked-list structure for the CURLOPT_QUOTE option (and other) */
|
||||||
struct curl_slist {
|
struct curl_slist {
|
||||||
@@ -575,7 +580,8 @@ typedef enum {
|
|||||||
} curl_closepolicy;
|
} curl_closepolicy;
|
||||||
|
|
||||||
#define CURL_GLOBAL_SSL (1<<0)
|
#define CURL_GLOBAL_SSL (1<<0)
|
||||||
#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL)
|
#define CURL_GLOBAL_WIN32 (1<<1)
|
||||||
|
#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32)
|
||||||
#define CURL_GLOBAL_NOTHING 0
|
#define CURL_GLOBAL_NOTHING 0
|
||||||
#define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL
|
#define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL
|
||||||
|
|
||||||
|
6
lib/.cvsignore
Normal file
6
lib/.cvsignore
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
*.la
|
||||||
|
*.lo
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
.deps
|
||||||
|
.libs
|
@@ -16,7 +16,7 @@ lib_LTLIBRARIES = libcurl.la
|
|||||||
INCLUDES = -I$(top_srcdir)/include
|
INCLUDES = -I$(top_srcdir)/include
|
||||||
|
|
||||||
|
|
||||||
libcurl_la_LDFLAGS = -version-info 2:0:1
|
libcurl_la_LDFLAGS = -version-info 2:1:0
|
||||||
# This flag accepts an argument of the form current[:revision[:age]]. So,
|
# This flag accepts an argument of the form current[:revision[:age]]. So,
|
||||||
# passing -version-info 3:12:1 sets current to 3, revision to 12, and age to
|
# passing -version-info 3:12:1 sets current to 3, revision to 12, and age to
|
||||||
# 1.
|
# 1.
|
||||||
|
@@ -55,7 +55,8 @@ SOURCES = \
|
|||||||
getinfo.c \
|
getinfo.c \
|
||||||
version.c \
|
version.c \
|
||||||
easy.c \
|
easy.c \
|
||||||
strequal.c
|
strequal.c \
|
||||||
|
strtok.c
|
||||||
|
|
||||||
OBJECTS = $(SOURCES:.c=.obj)
|
OBJECTS = $(SOURCES:.c=.obj)
|
||||||
|
|
||||||
|
@@ -1,321 +1,101 @@
|
|||||||
/*
|
#ifndef __ARPA_TELNET_H
|
||||||
* Copyright (c) 1983, 1993
|
#define __ARPA_TELNET_H
|
||||||
* The Regents of the University of California. All rights reserved.
|
/*****************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Copyright (C) 2001, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
* In order to be useful for every potential user, curl and libcurl are
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* dual-licensed under the MPL and the MIT/X-derivate licenses.
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
*
|
||||||
* @(#)telnet.h 8.2 (Berkeley) 12/15/93
|
* 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 MPL or the MIT/X-derivate
|
||||||
#ifndef _ARPA_TELNET_H
|
* licenses. You may pick one of these licenses.
|
||||||
#define _ARPA_TELNET_H
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Definitions for the TELNET protocol.
|
* Telnet option defines. Add more here if in need.
|
||||||
*/
|
*/
|
||||||
#define IAC 255 /* interpret as command: */
|
#define TELOPT_BINARY 0 /* binary 8bit data */
|
||||||
#define DONT 254 /* you are not to use option */
|
#define TELOPT_SGA 3 /* Supress Go Ahead */
|
||||||
#define DO 253 /* please, you use option */
|
#define TELOPT_EXOPL 255 /* EXtended OPtions List */
|
||||||
#define WONT 252 /* I won't use option */
|
#define TELOPT_TTYPE 24 /* Terminal TYPE */
|
||||||
#define WILL 251 /* I will use option */
|
#define TELOPT_XDISPLOC 35 /* X DISPlay LOCation */
|
||||||
#define SB 250 /* interpret as subnegotiation */
|
|
||||||
#define GA 249 /* you may reverse the line */
|
|
||||||
#define EL 248 /* erase the current line */
|
|
||||||
#define EC 247 /* erase the current character */
|
|
||||||
#define AYT 246 /* are you there */
|
|
||||||
#define AO 245 /* abort output--but let prog finish */
|
|
||||||
#define IP 244 /* interrupt process--permanently */
|
|
||||||
#define BREAK 243 /* break */
|
|
||||||
#define DM 242 /* data mark--for connect. cleaning */
|
|
||||||
#define NOP 241 /* nop */
|
|
||||||
#define SE 240 /* end sub negotiation */
|
|
||||||
#define EOR 239 /* end of record (transparent mode) */
|
|
||||||
#define ABORT 238 /* Abort process */
|
|
||||||
#define SUSP 237 /* Suspend process */
|
|
||||||
#define xEOF 236 /* End of file: EOF is already used... */
|
|
||||||
|
|
||||||
#define SYNCH 242 /* for telfunc calls */
|
#define TELOPT_NEW_ENVIRON 39 /* NEW ENVIRONment variables */
|
||||||
|
#define NEW_ENV_VAR 0
|
||||||
|
#define NEW_ENV_VALUE 1
|
||||||
|
|
||||||
#ifdef TELCMDS
|
/*
|
||||||
static
|
* The telnet options represented as strings
|
||||||
char *telcmds[] = {
|
*/
|
||||||
"EOF", "SUSP", "ABORT", "EOR",
|
static char *telnetoptions[]=
|
||||||
"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
|
{
|
||||||
"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
|
"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD",
|
||||||
|
"NAME", "STATUS" "TIMING MARK", "RCTE",
|
||||||
|
"NAOL", "NAOP", "NAOCRD", "NAOHTS",
|
||||||
|
"NAOHTD", "NAOFFD", "NAOVTS", "NAOVTD",
|
||||||
|
"NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
|
||||||
|
"DE TERMINAL", "SUPDUP", "SUPDUP OUTPUT", "SEND LOCATION",
|
||||||
|
"TERM TYPE", "END OF RECORD", "TACACS UID", "OUTPUT MARKING",
|
||||||
|
"TTYLOC", "3270 REGIME", "X3 PAD", "NAWS",
|
||||||
|
"TERM SPEED", "LFLOW", "LINEMODE", "XDISPLOC",
|
||||||
|
"OLD-ENVIRON", "AUTHENTICATION", "ENCRYPT", "NEW-ENVIRON"
|
||||||
};
|
};
|
||||||
#else
|
|
||||||
extern char *telcmds[];
|
#define TELOPT_MAXIMUM TELOPT_NEW_ENVIRON
|
||||||
|
|
||||||
|
#define TELOPT_OK(x) ((x) <= TELOPT_MAXIMUM)
|
||||||
|
#define TELOPT(x) telnetoptions[x]
|
||||||
|
|
||||||
|
#define NTELOPTS 40
|
||||||
|
|
||||||
|
/*
|
||||||
|
* First some defines
|
||||||
|
*/
|
||||||
|
#define xEOF 236 /* End Of File */
|
||||||
|
#define SE 240 /* Sub negotiation End */
|
||||||
|
#define NOP 241 /* No OPeration */
|
||||||
|
#define DM 242 /* Data Mark */
|
||||||
|
#define GA 249 /* Go Ahead, reverse the line */
|
||||||
|
#define SB 250 /* SuBnegotiation */
|
||||||
|
#define WILL 251 /* Our side WILL use this option */
|
||||||
|
#define WONT 252 /* Our side WON'T use this option */
|
||||||
|
#define DO 253 /* DO use this option! */
|
||||||
|
#define DONT 254 /* DON'T use this option! */
|
||||||
|
#define IAC 255 /* Interpret As Command */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Then those numbers represented as strings:
|
||||||
|
*/
|
||||||
|
static char *telnetcmds[]=
|
||||||
|
{
|
||||||
|
"EOF", "SUSP", "ABORT", "EOR", "SE",
|
||||||
|
"NOP", "DMARK", "BRK", "IP", "AO",
|
||||||
|
"AYT", "EC", "EL", "GA", "SB",
|
||||||
|
"WILL", "WONT", "DO", "DONT", "IAC"
|
||||||
|
};
|
||||||
|
|
||||||
|
#define TELCMD_MINIMUM xEOF /* the first one */
|
||||||
|
#define TELCMD_MAXIMUM IAC /* surprise, 255 is the last one! ;-) */
|
||||||
|
|
||||||
|
#define TELQUAL_IS 0
|
||||||
|
#define TELQUAL_SEND 1
|
||||||
|
#define TELQUAL_INFO 2
|
||||||
|
#define TELQUAL_NAME 3
|
||||||
|
|
||||||
|
#define TELCMD_OK(x) ( ((unsigned int)(x) >= TELCMD_MINIMUM) && \
|
||||||
|
((unsigned int)(x) <= TELCMD_MAXIMUM) )
|
||||||
|
#define TELCMD(x) telnetcmds[(x)-TELCMD_MINIMUM]
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TELCMD_FIRST xEOF
|
|
||||||
#define TELCMD_LAST IAC
|
|
||||||
#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
|
|
||||||
(unsigned int)(x) >= TELCMD_FIRST)
|
|
||||||
#define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
|
|
||||||
|
|
||||||
/* telnet options */
|
|
||||||
#define TELOPT_BINARY 0 /* 8-bit data path */
|
|
||||||
#define TELOPT_ECHO 1 /* echo */
|
|
||||||
#define TELOPT_RCP 2 /* prepare to reconnect */
|
|
||||||
#define TELOPT_SGA 3 /* suppress go ahead */
|
|
||||||
#define TELOPT_NAMS 4 /* approximate message size */
|
|
||||||
#define TELOPT_STATUS 5 /* give status */
|
|
||||||
#define TELOPT_TM 6 /* timing mark */
|
|
||||||
#define TELOPT_RCTE 7 /* remote controlled transmission and echo */
|
|
||||||
#define TELOPT_NAOL 8 /* negotiate about output line width */
|
|
||||||
#define TELOPT_NAOP 9 /* negotiate about output page size */
|
|
||||||
#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */
|
|
||||||
#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
|
|
||||||
#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */
|
|
||||||
#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
|
|
||||||
#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
|
|
||||||
#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
|
|
||||||
#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
|
|
||||||
#define TELOPT_XASCII 17 /* extended ascic character set */
|
|
||||||
#define TELOPT_LOGOUT 18 /* force logout */
|
|
||||||
#define TELOPT_BM 19 /* byte macro */
|
|
||||||
#define TELOPT_DET 20 /* data entry terminal */
|
|
||||||
#define TELOPT_SUPDUP 21 /* supdup protocol */
|
|
||||||
#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */
|
|
||||||
#define TELOPT_SNDLOC 23 /* send location */
|
|
||||||
#define TELOPT_TTYPE 24 /* terminal type */
|
|
||||||
#define TELOPT_EOR 25 /* end or record */
|
|
||||||
#define TELOPT_TUID 26 /* TACACS user identification */
|
|
||||||
#define TELOPT_OUTMRK 27 /* output marking */
|
|
||||||
#define TELOPT_TTYLOC 28 /* terminal location number */
|
|
||||||
#define TELOPT_3270REGIME 29 /* 3270 regime */
|
|
||||||
#define TELOPT_X3PAD 30 /* X.3 PAD */
|
|
||||||
#define TELOPT_NAWS 31 /* window size */
|
|
||||||
#define TELOPT_TSPEED 32 /* terminal speed */
|
|
||||||
#define TELOPT_LFLOW 33 /* remote flow control */
|
|
||||||
#define TELOPT_LINEMODE 34 /* Linemode option */
|
|
||||||
#define TELOPT_XDISPLOC 35 /* X Display Location */
|
|
||||||
#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */
|
|
||||||
#define TELOPT_AUTHENTICATION 37/* Authenticate */
|
|
||||||
#define TELOPT_ENCRYPT 38 /* Encryption option */
|
|
||||||
#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */
|
|
||||||
#define TELOPT_EXOPL 255 /* extended-options-list */
|
|
||||||
|
|
||||||
|
|
||||||
#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
|
|
||||||
#ifdef TELOPTS
|
|
||||||
static
|
|
||||||
char *telopts[NTELOPTS+1] = {
|
|
||||||
"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
|
|
||||||
"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
|
|
||||||
"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
|
|
||||||
"NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
|
|
||||||
"DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
|
|
||||||
"SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
|
|
||||||
"TACACS UID", "OUTPUT MARKING", "TTYLOC",
|
|
||||||
"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
|
|
||||||
"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
|
|
||||||
"ENCRYPT", "NEW-ENVIRON",
|
|
||||||
0,
|
|
||||||
};
|
|
||||||
#define TELOPT_FIRST TELOPT_BINARY
|
|
||||||
#define TELOPT_LAST TELOPT_NEW_ENVIRON
|
|
||||||
#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
|
|
||||||
#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* sub-option qualifiers */
|
|
||||||
#define TELQUAL_IS 0 /* option is... */
|
|
||||||
#define TELQUAL_SEND 1 /* send option */
|
|
||||||
#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */
|
|
||||||
#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */
|
|
||||||
#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */
|
|
||||||
|
|
||||||
#define LFLOW_OFF 0 /* Disable remote flow control */
|
|
||||||
#define LFLOW_ON 1 /* Enable remote flow control */
|
|
||||||
#define LFLOW_RESTART_ANY 2 /* Restart output on any char */
|
|
||||||
#define LFLOW_RESTART_XON 3 /* Restart output only on XON */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* LINEMODE suboptions
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LM_MODE 1
|
|
||||||
#define LM_FORWARDMASK 2
|
|
||||||
#define LM_SLC 3
|
|
||||||
|
|
||||||
#define MODE_EDIT 0x01
|
|
||||||
#define MODE_TRAPSIG 0x02
|
|
||||||
#define MODE_ACK 0x04
|
|
||||||
#define MODE_SOFT_TAB 0x08
|
|
||||||
#define MODE_LIT_ECHO 0x10
|
|
||||||
|
|
||||||
#define MODE_MASK 0x1f
|
|
||||||
|
|
||||||
/* Not part of protocol, but needed to simplify things... */
|
|
||||||
#define MODE_FLOW 0x0100
|
|
||||||
#define MODE_ECHO 0x0200
|
|
||||||
#define MODE_INBIN 0x0400
|
|
||||||
#define MODE_OUTBIN 0x0800
|
|
||||||
#define MODE_FORCE 0x1000
|
|
||||||
|
|
||||||
#define SLC_SYNCH 1
|
|
||||||
#define SLC_BRK 2
|
|
||||||
#define SLC_IP 3
|
|
||||||
#define SLC_AO 4
|
|
||||||
#define SLC_AYT 5
|
|
||||||
#define SLC_EOR 6
|
|
||||||
#define SLC_ABORT 7
|
|
||||||
#define SLC_EOF 8
|
|
||||||
#define SLC_SUSP 9
|
|
||||||
#define SLC_EC 10
|
|
||||||
#define SLC_EL 11
|
|
||||||
#define SLC_EW 12
|
|
||||||
#define SLC_RP 13
|
|
||||||
#define SLC_LNEXT 14
|
|
||||||
#define SLC_XON 15
|
|
||||||
#define SLC_XOFF 16
|
|
||||||
#define SLC_FORW1 17
|
|
||||||
#define SLC_FORW2 18
|
|
||||||
|
|
||||||
#define NSLC 18
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For backwards compatability, we define SLC_NAMES to be the
|
|
||||||
* list of names if SLC_NAMES is not defined.
|
|
||||||
*/
|
|
||||||
#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
|
|
||||||
"ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
|
|
||||||
"LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
|
|
||||||
#ifdef SLC_NAMES
|
|
||||||
char *slc_names[] = {
|
|
||||||
SLC_NAMELIST
|
|
||||||
};
|
|
||||||
#else
|
|
||||||
extern char *slc_names[];
|
|
||||||
#define SLC_NAMES SLC_NAMELIST
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
|
|
||||||
#define SLC_NAME(x) slc_names[x]
|
|
||||||
|
|
||||||
#define SLC_NOSUPPORT 0
|
|
||||||
#define SLC_CANTCHANGE 1
|
|
||||||
#define SLC_VARIABLE 2
|
|
||||||
#define SLC_DEFAULT 3
|
|
||||||
#define SLC_LEVELBITS 0x03
|
|
||||||
|
|
||||||
#define SLC_FUNC 0
|
|
||||||
#define SLC_FLAGS 1
|
|
||||||
#define SLC_VALUE 2
|
|
||||||
|
|
||||||
#define SLC_ACK 0x80
|
|
||||||
#define SLC_FLUSHIN 0x40
|
|
||||||
#define SLC_FLUSHOUT 0x20
|
|
||||||
|
|
||||||
#define OLD_ENV_VAR 1
|
|
||||||
#define OLD_ENV_VALUE 0
|
|
||||||
#define NEW_ENV_VAR 0
|
|
||||||
#define NEW_ENV_VALUE 1
|
|
||||||
#define ENV_ESC 2
|
|
||||||
#define ENV_USERVAR 3
|
|
||||||
|
|
||||||
/*
|
|
||||||
* AUTHENTICATION suboptions
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Who is authenticating who ...
|
|
||||||
*/
|
|
||||||
#define AUTH_WHO_CLIENT 0 /* Client authenticating server */
|
|
||||||
#define AUTH_WHO_SERVER 1 /* Server authenticating client */
|
|
||||||
#define AUTH_WHO_MASK 1
|
|
||||||
|
|
||||||
/*
|
|
||||||
* amount of authentication done
|
|
||||||
*/
|
|
||||||
#define AUTH_HOW_ONE_WAY 0
|
|
||||||
#define AUTH_HOW_MUTUAL 2
|
|
||||||
#define AUTH_HOW_MASK 2
|
|
||||||
|
|
||||||
#define AUTHTYPE_NULL 0
|
|
||||||
#define AUTHTYPE_KERBEROS_V4 1
|
|
||||||
#define AUTHTYPE_KERBEROS_V5 2
|
|
||||||
#define AUTHTYPE_SPX 3
|
|
||||||
#define AUTHTYPE_MINK 4
|
|
||||||
#define AUTHTYPE_CNT 5
|
|
||||||
|
|
||||||
#define AUTHTYPE_TEST 99
|
|
||||||
|
|
||||||
#ifdef AUTH_NAMES
|
|
||||||
char *authtype_names[] = {
|
|
||||||
"NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
|
|
||||||
};
|
|
||||||
#else
|
|
||||||
extern char *authtype_names[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
|
|
||||||
#define AUTHTYPE_NAME(x) authtype_names[x]
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ENCRYPTion suboptions
|
|
||||||
*/
|
|
||||||
#define ENCRYPT_IS 0 /* I pick encryption type ... */
|
|
||||||
#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */
|
|
||||||
#define ENCRYPT_REPLY 2 /* Initial setup response */
|
|
||||||
#define ENCRYPT_START 3 /* Am starting to send encrypted */
|
|
||||||
#define ENCRYPT_END 4 /* Am ending encrypted */
|
|
||||||
#define ENCRYPT_REQSTART 5 /* Request you start encrypting */
|
|
||||||
#define ENCRYPT_REQEND 6 /* Request you send encrypting */
|
|
||||||
#define ENCRYPT_ENC_KEYID 7
|
|
||||||
#define ENCRYPT_DEC_KEYID 8
|
|
||||||
#define ENCRYPT_CNT 9
|
|
||||||
|
|
||||||
#define ENCTYPE_ANY 0
|
|
||||||
#define ENCTYPE_DES_CFB64 1
|
|
||||||
#define ENCTYPE_DES_OFB64 2
|
|
||||||
#define ENCTYPE_CNT 3
|
|
||||||
|
|
||||||
#ifdef ENCRYPT_NAMES
|
|
||||||
char *encrypt_names[] = {
|
|
||||||
"IS", "SUPPORT", "REPLY", "START", "END",
|
|
||||||
"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
|
|
||||||
0,
|
|
||||||
};
|
|
||||||
char *enctype_names[] = {
|
|
||||||
"ANY", "DES_CFB64", "DES_OFB64", 0,
|
|
||||||
};
|
|
||||||
#else
|
|
||||||
extern char *encrypt_names[];
|
|
||||||
extern char *enctype_names[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
|
|
||||||
#define ENCRYPT_NAME(x) encrypt_names[x]
|
|
||||||
|
|
||||||
#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
|
|
||||||
#define ENCTYPE_NAME(x) enctype_names[x]
|
|
||||||
#endif /* _ARPA_TELNET_H */
|
|
||||||
|
367
lib/base64.c
367
lib/base64.c
@@ -1,34 +1,35 @@
|
|||||||
/*
|
/*****************************************************************************
|
||||||
* Copyright (c) 1995 - 1999 Kungliga Tekniska H<>gskolan
|
* _ _ ____ _
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* Project ___| | | | _ \| |
|
||||||
* All rights reserved.
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* Copyright (C) 2001, Andrew Francis and Daniel Stenberg
|
||||||
|
*
|
||||||
|
* In order to be useful for every potential user, curl and libcurl are
|
||||||
|
* dual-licensed under the MPL and the MIT/X-derivate licenses.
|
||||||
|
*
|
||||||
|
* 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 MPL or the MIT/X-derivate
|
||||||
|
* licenses. You may pick one of these licenses.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
/* Base64 encoding/decoding
|
||||||
|
*
|
||||||
|
* Test harnesses down the bottom - compile with -DTEST_ENCODE for
|
||||||
|
* a program that will read in raw data from stdin and write out
|
||||||
|
* a base64-encoded version to stdout, and the length returned by the
|
||||||
|
* encoding function to stderr. Compile with -DTEST_DECODE for a program that
|
||||||
|
* will go the other way.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* This code will break if int is smaller than 32 bits
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
@@ -38,115 +39,221 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
|
|
||||||
/* The last #include file should be: */
|
|
||||||
#ifdef MALLOCDEBUG
|
#ifdef MALLOCDEBUG
|
||||||
#include "memdebug.h"
|
#include "memdebug.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
static void decodeQuantum(unsigned char *dest, char *src)
|
||||||
|
|
||||||
static int pos(char c)
|
|
||||||
{
|
{
|
||||||
char *p;
|
unsigned int x = 0;
|
||||||
for(p = base64; *p; p++)
|
|
||||||
if(*p == c)
|
|
||||||
return p - base64;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
int Curl_base64_encode(const void *data, int size, char **str)
|
|
||||||
{
|
|
||||||
char *s, *p;
|
|
||||||
int i;
|
int i;
|
||||||
int c;
|
for(i = 0; i < 4; i++) {
|
||||||
const unsigned char *q;
|
if(src[i] >= 'A' && src[i] <= 'Z')
|
||||||
|
x = (x << 6) + (unsigned int)(src[i] - 'A' + 0);
|
||||||
p = s = (char*)malloc(size*4/3+4);
|
else if(src[i] >= 'a' && src[i] <= 'z')
|
||||||
if (p == NULL)
|
x = (x << 6) + (unsigned int)(src[i] - 'a' + 26);
|
||||||
return -1;
|
else if(src[i] >= '0' && src[i] <= '9')
|
||||||
q = (const unsigned char*)data;
|
x = (x << 6) + (unsigned int)(src[i] - '0' + 52);
|
||||||
i=0;
|
else if(src[i] == '+')
|
||||||
for(i = 0; i < size;){
|
x = (x << 6) + 62;
|
||||||
c=q[i++];
|
else if(src[i] == '/')
|
||||||
c*=256;
|
x = (x << 6) + 63;
|
||||||
if(i < size)
|
|
||||||
c+=q[i];
|
|
||||||
i++;
|
|
||||||
c*=256;
|
|
||||||
if(i < size)
|
|
||||||
c+=q[i];
|
|
||||||
i++;
|
|
||||||
p[0]=base64[(c&0x00fc0000) >> 18];
|
|
||||||
p[1]=base64[(c&0x0003f000) >> 12];
|
|
||||||
p[2]=base64[(c&0x00000fc0) >> 6];
|
|
||||||
p[3]=base64[(c&0x0000003f) >> 0];
|
|
||||||
if(i > size)
|
|
||||||
p[3]='=';
|
|
||||||
if(i > size+1)
|
|
||||||
p[2]='=';
|
|
||||||
p+=4;
|
|
||||||
}
|
}
|
||||||
*p=0;
|
|
||||||
*str = s;
|
dest[2] = (unsigned char)(x & 255); x >>= 8;
|
||||||
return strlen(s);
|
dest[1] = (unsigned char)(x & 255); x >>= 8;
|
||||||
|
dest[0] = (unsigned char)(x & 255); x >>= 8;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
/* base64Decode
|
||||||
|
* Given a base64 string at src, decode it into the memory pointed
|
||||||
|
* to by dest. If rawLength points to a valid address (ie not NULL),
|
||||||
|
* store the length of the decoded data to it.
|
||||||
|
*/
|
||||||
|
static void base64Decode(unsigned char *dest, char *src, int *rawLength)
|
||||||
|
{
|
||||||
|
int length = 0;
|
||||||
|
int equalsTerm = 0;
|
||||||
|
int i;
|
||||||
|
unsigned char lastQuantum[3];
|
||||||
|
|
||||||
|
while((src[length] != '=') && src[length])
|
||||||
|
length++;
|
||||||
|
while(src[length+equalsTerm] == '=')
|
||||||
|
equalsTerm++;
|
||||||
|
|
||||||
|
if(rawLength)
|
||||||
|
*rawLength = (length * 3 / 4) - equalsTerm;
|
||||||
|
|
||||||
|
for(i = 0; i < length/4 - 1; i++) {
|
||||||
|
decodeQuantum(dest, src);
|
||||||
|
dest += 3; src += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
decodeQuantum(lastQuantum, src);
|
||||||
|
for(i = 0; i < 3 - equalsTerm; i++) dest[i] = lastQuantum[i];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---- Base64 Encoding --- */
|
||||||
|
static char table64[]=
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Curl_base64_encode()
|
||||||
|
*
|
||||||
|
* Returns the length of the newly created base64 string. The third argument
|
||||||
|
* is a pointer to an allocated area holding the base64 data. If something
|
||||||
|
* went wrong, -1 is returned.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int Curl_base64_encode(const void *inp, int insize, char **outptr)
|
||||||
|
{
|
||||||
|
unsigned char ibuf[3];
|
||||||
|
unsigned char obuf[4];
|
||||||
|
int i;
|
||||||
|
int inputparts;
|
||||||
|
char *output;
|
||||||
|
char *base64data;
|
||||||
|
|
||||||
|
char *indata = (char *)inp;
|
||||||
|
|
||||||
|
if(0 == insize)
|
||||||
|
insize = strlen(indata);
|
||||||
|
|
||||||
|
base64data = output = (char*)malloc(insize*4/3+4);
|
||||||
|
if(NULL == output)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
while(insize > 0) {
|
||||||
|
for (i = inputparts = 0; i < 3; i++) {
|
||||||
|
if(*indata) {
|
||||||
|
inputparts++;
|
||||||
|
ibuf[i] = *indata;
|
||||||
|
indata++;
|
||||||
|
insize--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ibuf[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
obuf [0] = (ibuf [0] & 0xFC) >> 2;
|
||||||
|
obuf [1] = ((ibuf [0] & 0x03) << 4) | ((ibuf [1] & 0xF0) >> 4);
|
||||||
|
obuf [2] = ((ibuf [1] & 0x0F) << 2) | ((ibuf [2] & 0xC0) >> 6);
|
||||||
|
obuf [3] = ibuf [2] & 0x3F;
|
||||||
|
|
||||||
|
switch(inputparts) {
|
||||||
|
case 1: /* only one byte read */
|
||||||
|
sprintf(output, "%c%c==",
|
||||||
|
table64[obuf[0]],
|
||||||
|
table64[obuf[1]]);
|
||||||
|
break;
|
||||||
|
case 2: /* two bytes read */
|
||||||
|
sprintf(output, "%c%c%c=",
|
||||||
|
table64[obuf[0]],
|
||||||
|
table64[obuf[1]],
|
||||||
|
table64[obuf[2]]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sprintf(output, "%c%c%c%c",
|
||||||
|
table64[obuf[0]],
|
||||||
|
table64[obuf[1]],
|
||||||
|
table64[obuf[2]],
|
||||||
|
table64[obuf[3]] );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
output += 4;
|
||||||
|
}
|
||||||
|
*output=0;
|
||||||
|
*outptr = base64data; /* make it return the actual data memory */
|
||||||
|
|
||||||
|
return strlen(base64data); /* return the length of the new data */
|
||||||
|
}
|
||||||
|
/* ---- End of Base64 Encoding ---- */
|
||||||
|
|
||||||
int Curl_base64_decode(const char *str, void *data)
|
int Curl_base64_decode(const char *str, void *data)
|
||||||
{
|
{
|
||||||
const char *p;
|
int ret;
|
||||||
unsigned char *q;
|
|
||||||
int c;
|
base64Decode((unsigned char *)data, (char *)str, &ret);
|
||||||
int x;
|
return ret;
|
||||||
int done = 0;
|
|
||||||
q=(unsigned char*)data;
|
|
||||||
for(p=str; *p && !done; p+=4){
|
|
||||||
x = pos(p[0]);
|
|
||||||
if(x >= 0)
|
|
||||||
c = x;
|
|
||||||
else{
|
|
||||||
done = 3;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
c*=64;
|
|
||||||
|
|
||||||
x = pos(p[1]);
|
|
||||||
if(x >= 0)
|
|
||||||
c += x;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
c*=64;
|
|
||||||
|
|
||||||
if(p[2] == '=')
|
|
||||||
done++;
|
|
||||||
else{
|
|
||||||
x = pos(p[2]);
|
|
||||||
if(x >= 0)
|
|
||||||
c += x;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
c*=64;
|
|
||||||
|
|
||||||
if(p[3] == '=')
|
|
||||||
done++;
|
|
||||||
else{
|
|
||||||
if(done)
|
|
||||||
return -1;
|
|
||||||
x = pos(p[3]);
|
|
||||||
if(x >= 0)
|
|
||||||
c += x;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(done < 3)
|
|
||||||
*q++=(c&0x00ff0000)>>16;
|
|
||||||
|
|
||||||
if(done < 2)
|
|
||||||
*q++=(c&0x0000ff00)>>8;
|
|
||||||
if(done < 1)
|
|
||||||
*q++=(c&0x000000ff)>>0;
|
|
||||||
}
|
|
||||||
return q - (unsigned char*)data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/************* TEST HARNESS STUFF ****************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef TEST_ENCODE
|
||||||
|
/* encoding test harness. Read in standard input and write out the length
|
||||||
|
* returned by Curl_base64_encode, followed by the base64'd data itself
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define TEST_NEED_SUCK
|
||||||
|
void *suck(int *);
|
||||||
|
|
||||||
|
int main(int argc, char **argv, char **envp) {
|
||||||
|
char *base64;
|
||||||
|
int base64Len;
|
||||||
|
unsigned char *data;
|
||||||
|
int dataLen;
|
||||||
|
|
||||||
|
data = (unsigned char *)suck(&dataLen);
|
||||||
|
base64Len = Curl_base64_encode(data, dataLen, &base64);
|
||||||
|
|
||||||
|
fprintf(stderr, "%d\n", base64Len);
|
||||||
|
fprintf(stdout, "%s", base64);
|
||||||
|
|
||||||
|
free(base64); free(data);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TEST_DECODE
|
||||||
|
/* decoding test harness. Read in a base64 string from stdin and write out the
|
||||||
|
* length returned by Curl_base64_decode, followed by the decoded data itself
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define TEST_NEED_SUCK
|
||||||
|
void *suck(int *);
|
||||||
|
|
||||||
|
int main(int argc, char **argv, char **envp) {
|
||||||
|
char *base64;
|
||||||
|
int base64Len;
|
||||||
|
unsigned char *data;
|
||||||
|
int dataLen;
|
||||||
|
|
||||||
|
base64 = (char *)suck(&base64Len);
|
||||||
|
data = (unsigned char *)malloc(base64Len * 3/4 + 8);
|
||||||
|
dataLen = Curl_base64_decode(base64, data);
|
||||||
|
|
||||||
|
fprintf(stderr, "%d\n", dataLen);
|
||||||
|
fwrite(data,1,dataLen,stdout);
|
||||||
|
|
||||||
|
|
||||||
|
free(base64); free(data);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TEST_NEED_SUCK
|
||||||
|
/* this function 'sucks' in as much as possible from stdin */
|
||||||
|
void *suck(int *lenptr) {
|
||||||
|
int cursize = 8192;
|
||||||
|
unsigned char *buf = NULL;
|
||||||
|
int lastread;
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
cursize *= 2;
|
||||||
|
buf = (unsigned char *)realloc(buf, cursize);
|
||||||
|
memset(buf + len, 0, cursize - len);
|
||||||
|
lastread = fread(buf + len, 1, cursize - len, stdin);
|
||||||
|
len += lastread;
|
||||||
|
} while(!feof(stdin));
|
||||||
|
|
||||||
|
lenptr[0] = len;
|
||||||
|
return (void *)buf;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
57
lib/base64.h
57
lib/base64.h
@@ -1,40 +1,27 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska H<>gskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __BASE64_H
|
#ifndef __BASE64_H
|
||||||
#define __BASE64_H
|
#define __BASE64_H
|
||||||
|
/*****************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* Copyright (C) 2000, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
|
*
|
||||||
|
* In order to be useful for every potential user, curl and libcurl are
|
||||||
|
* dual-licensed under the MPL and the MIT/X-derivate licenses.
|
||||||
|
*
|
||||||
|
* 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 MPL or the MIT/X-derivate
|
||||||
|
* licenses. You may pick one of these licenses.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*****************************************************************************/
|
||||||
int Curl_base64_encode(const void *data, int size, char **str);
|
int Curl_base64_encode(const void *data, int size, char **str);
|
||||||
int Curl_base64_decode(const char *str, void *data);
|
int Curl_base64_decode(const char *str, void *data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
72
lib/easy.c
72
lib/easy.c
@@ -78,27 +78,95 @@
|
|||||||
#define _MPRINTF_REPLACE /* use our functions only */
|
#define _MPRINTF_REPLACE /* use our functions only */
|
||||||
#include <curl/mprintf.h>
|
#include <curl/mprintf.h>
|
||||||
|
|
||||||
/* true globals */
|
|
||||||
|
/* Silly win32 socket initialization functions */
|
||||||
|
|
||||||
|
#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
|
||||||
|
static void win32_cleanup(void)
|
||||||
|
{
|
||||||
|
WSACleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CURLcode win32_init(void)
|
||||||
|
{
|
||||||
|
WORD wVersionRequested;
|
||||||
|
WSADATA wsaData;
|
||||||
|
int err;
|
||||||
|
wVersionRequested = MAKEWORD(1, 1);
|
||||||
|
|
||||||
|
err = WSAStartup(wVersionRequested, &wsaData);
|
||||||
|
|
||||||
|
if (err != 0)
|
||||||
|
/* Tell the user that we couldn't find a useable */
|
||||||
|
/* winsock.dll. */
|
||||||
|
return CURLE_FAILED_INIT;
|
||||||
|
|
||||||
|
/* Confirm that the Windows Sockets DLL supports 1.1.*/
|
||||||
|
/* Note that if the DLL supports versions greater */
|
||||||
|
/* than 1.1 in addition to 1.1, it will still return */
|
||||||
|
/* 1.1 in wVersion since that is the version we */
|
||||||
|
/* requested. */
|
||||||
|
|
||||||
|
if ( LOBYTE( wsaData.wVersion ) != 1 ||
|
||||||
|
HIBYTE( wsaData.wVersion ) != 1 ) {
|
||||||
|
/* Tell the user that we couldn't find a useable */
|
||||||
|
|
||||||
|
/* winsock.dll. */
|
||||||
|
WSACleanup();
|
||||||
|
return CURLE_FAILED_INIT;
|
||||||
|
}
|
||||||
|
return CURLE_OK;
|
||||||
|
}
|
||||||
|
/* The Windows Sockets DLL is acceptable. Proceed. */
|
||||||
|
#else
|
||||||
|
static CURLcode win32_init(void) { return CURLE_OK; }
|
||||||
|
#define win32_cleanup()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* true globals -- for curl_global_init() and curl_global_cleanup() */
|
||||||
static unsigned int initialized = 0;
|
static unsigned int initialized = 0;
|
||||||
static long init_flags = 0;
|
static long init_flags = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Globally initializes cURL given a bitwise set of
|
||||||
|
* the different features to initialize.
|
||||||
|
*/
|
||||||
CURLcode curl_global_init(long flags)
|
CURLcode curl_global_init(long flags)
|
||||||
{
|
{
|
||||||
if(flags & CURL_GLOBAL_SSL)
|
if (initialized)
|
||||||
|
return CURLE_OK;
|
||||||
|
|
||||||
|
if (flags & CURL_GLOBAL_SSL)
|
||||||
Curl_SSL_init();
|
Curl_SSL_init();
|
||||||
|
|
||||||
|
if (flags & CURL_GLOBAL_WIN32)
|
||||||
|
if (win32_init() != CURLE_OK)
|
||||||
|
return CURLE_FAILED_INIT;
|
||||||
|
|
||||||
initialized = 1;
|
initialized = 1;
|
||||||
init_flags = flags;
|
init_flags = flags;
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Globally cleanup cURL, uses the value of "init_flags" to determine
|
||||||
|
* what needs to be cleaned up and what doesn't
|
||||||
|
*/
|
||||||
void curl_global_cleanup(void)
|
void curl_global_cleanup(void)
|
||||||
{
|
{
|
||||||
|
if (!initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
if (init_flags & CURL_GLOBAL_SSL)
|
if (init_flags & CURL_GLOBAL_SSL)
|
||||||
Curl_SSL_cleanup();
|
Curl_SSL_cleanup();
|
||||||
|
|
||||||
|
if (init_flags & CURL_GLOBAL_WIN32)
|
||||||
|
win32_cleanup();
|
||||||
|
|
||||||
initialized = 0;
|
initialized = 0;
|
||||||
|
init_flags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CURL *curl_easy_init(void)
|
CURL *curl_easy_init(void)
|
||||||
|
27
lib/escape.c
27
lib/escape.c
@@ -54,28 +54,15 @@ char *curl_escape(char *string, int length)
|
|||||||
!(in >= 'A' && in <= 'Z') &&
|
!(in >= 'A' && in <= 'Z') &&
|
||||||
!(in >= '0' && in <= '9')) {
|
!(in >= '0' && in <= '9')) {
|
||||||
/* encode it */
|
/* encode it */
|
||||||
if(('%' == in) &&
|
newlen += 2; /* the size grows with two, since this'll become a %XX */
|
||||||
(length>=2) &&
|
if(newlen > alloc) {
|
||||||
isxdigit((int)string[1]) &&
|
alloc *= 2;
|
||||||
isxdigit((int)string[2]) ) {
|
ns = realloc(ns, alloc);
|
||||||
/*
|
if(!ns)
|
||||||
* This is an already encoded letter, leave it!
|
return NULL;
|
||||||
*/
|
|
||||||
memcpy(&ns[index], string, 3);
|
|
||||||
string+=2;
|
|
||||||
}
|
}
|
||||||
else {
|
sprintf(&ns[index], "%%%02X", in);
|
||||||
/* encode this now */
|
|
||||||
|
|
||||||
newlen += 2; /* the size grows with two, since this'll become a %XX */
|
|
||||||
if(newlen > alloc) {
|
|
||||||
alloc *= 2;
|
|
||||||
ns = realloc(ns, alloc);
|
|
||||||
if(!ns)
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
sprintf(&ns[index], "%%%02X", in);
|
|
||||||
}
|
|
||||||
index+=3;
|
index+=3;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@@ -115,7 +115,7 @@ int FormParse(char *input,
|
|||||||
struct HttpPost *subpost; /* a sub-node */
|
struct HttpPost *subpost; /* a sub-node */
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if(1 <= sscanf(input, "%255[^ =] = %4095[^\n]", name, contents)) {
|
if(1 <= sscanf(input, "%255[^=]=%4095[^\n]", name, contents)) {
|
||||||
/* the input was using the correct format */
|
/* the input was using the correct format */
|
||||||
contp = contents;
|
contp = contents;
|
||||||
|
|
||||||
|
@@ -172,7 +172,7 @@ int Curl_GetFTPResponse(int sockfd,
|
|||||||
fd_set readfd;
|
fd_set readfd;
|
||||||
struct UrlData *data = conn->data;
|
struct UrlData *data = conn->data;
|
||||||
char *line_start;
|
char *line_start;
|
||||||
int code;
|
int code=0; /* default "error code" to return */
|
||||||
|
|
||||||
#define SELECT_OK 0
|
#define SELECT_OK 0
|
||||||
#define SELECT_ERROR 1
|
#define SELECT_ERROR 1
|
||||||
@@ -680,7 +680,7 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
|
|||||||
|
|
||||||
/* 226 Transfer complete, 250 Requested file action okay, completed. */
|
/* 226 Transfer complete, 250 Requested file action okay, completed. */
|
||||||
if((ftpcode != 226) && (ftpcode != 250)) {
|
if((ftpcode != 226) && (ftpcode != 250)) {
|
||||||
failf(data, "%s", buf+4);
|
failf(data, "server did not report OK, got %d", ftpcode);
|
||||||
return CURLE_FTP_WRITE_ERROR;
|
return CURLE_FTP_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
25
lib/http.c
25
lib/http.c
@@ -361,7 +361,7 @@ CURLcode Curl_http_done(struct connectdata *conn)
|
|||||||
data=conn->data;
|
data=conn->data;
|
||||||
http=conn->proto.http;
|
http=conn->proto.http;
|
||||||
|
|
||||||
if(data->bits.http_formpost) {
|
if(HTTPREQ_POST_FORM == data->httpreq) {
|
||||||
*bytecount = http->readbytecount + http->writebytecount;
|
*bytecount = http->readbytecount + http->writebytecount;
|
||||||
|
|
||||||
Curl_FormFree(http->sendit); /* Now free that whole lot */
|
Curl_FormFree(http->sendit); /* Now free that whole lot */
|
||||||
@@ -369,7 +369,7 @@ CURLcode Curl_http_done(struct connectdata *conn)
|
|||||||
data->fread = http->storefread; /* restore */
|
data->fread = http->storefread; /* restore */
|
||||||
data->in = http->in; /* restore */
|
data->in = http->in; /* restore */
|
||||||
}
|
}
|
||||||
else if(data->bits.http_put) {
|
else if(HTTPREQ_PUT == data->httpreq) {
|
||||||
*bytecount = http->readbytecount + http->writebytecount;
|
*bytecount = http->readbytecount + http->writebytecount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,7 +405,7 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
|
|
||||||
if ( (conn->protocol&(PROT_HTTP|PROT_FTP)) &&
|
if ( (conn->protocol&(PROT_HTTP|PROT_FTP)) &&
|
||||||
data->bits.upload) {
|
data->bits.upload) {
|
||||||
data->bits.http_put=1;
|
data->httpreq = HTTPREQ_PUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The User-Agent string has been built in url.c already, because it might
|
/* The User-Agent string has been built in url.c already, because it might
|
||||||
@@ -457,7 +457,7 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
/* The path sent to the proxy is in fact the entire URL */
|
/* The path sent to the proxy is in fact the entire URL */
|
||||||
ppath = data->url;
|
ppath = data->url;
|
||||||
}
|
}
|
||||||
if(data->bits.http_formpost) {
|
if(HTTPREQ_POST_FORM == data->httpreq) {
|
||||||
/* we must build the whole darned post sequence first, so that we have
|
/* we must build the whole darned post sequence first, so that we have
|
||||||
a size of the whole shebang before we start to send it */
|
a size of the whole shebang before we start to send it */
|
||||||
http->sendit = Curl_getFormData(data->httppost, &http->postsize);
|
http->sendit = Curl_getFormData(data->httppost, &http->postsize);
|
||||||
@@ -488,9 +488,9 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
if(!checkheaders(data, "Accept:"))
|
if(!checkheaders(data, "Accept:"))
|
||||||
http->p_accept = "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*\r\n";
|
http->p_accept = "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*\r\n";
|
||||||
|
|
||||||
if((data->bits.http_post ||
|
if(( (HTTPREQ_POST == data->httpreq) ||
|
||||||
data->bits.http_formpost ||
|
(HTTPREQ_POST_FORM == data->httpreq) ||
|
||||||
data->bits.http_put) &&
|
(HTTPREQ_PUT == data->httpreq) ) &&
|
||||||
conn->resume_from) {
|
conn->resume_from) {
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Resuming upload in HTTP means that we PUT or POST and that we have
|
* Resuming upload in HTTP means that we PUT or POST and that we have
|
||||||
@@ -597,8 +597,9 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
|
|
||||||
data->customrequest?data->customrequest:
|
data->customrequest?data->customrequest:
|
||||||
(data->bits.no_body?"HEAD":
|
(data->bits.no_body?"HEAD":
|
||||||
(data->bits.http_post || data->bits.http_formpost)?"POST":
|
((HTTPREQ_POST == data->httpreq) ||
|
||||||
(data->bits.http_put)?"PUT":"GET"),
|
(HTTPREQ_POST_FORM == data->httpreq))?"POST":
|
||||||
|
(HTTPREQ_PUT == data->httpreq)?"PUT":"GET"),
|
||||||
ppath,
|
ppath,
|
||||||
(conn->bits.proxy_user_passwd &&
|
(conn->bits.proxy_user_passwd &&
|
||||||
conn->allocptr.proxyuserpwd)?conn->allocptr.proxyuserpwd:"",
|
conn->allocptr.proxyuserpwd)?conn->allocptr.proxyuserpwd:"",
|
||||||
@@ -703,7 +704,7 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
headers = headers->next;
|
headers = headers->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data->bits.http_formpost) {
|
if(HTTPREQ_POST_FORM == data->httpreq) {
|
||||||
if(Curl_FormInit(&http->form, http->sendit)) {
|
if(Curl_FormInit(&http->form, http->sendit)) {
|
||||||
failf(data, "Internal HTTP POST error!\n");
|
failf(data, "Internal HTTP POST error!\n");
|
||||||
return CURLE_HTTP_POST_ERROR;
|
return CURLE_HTTP_POST_ERROR;
|
||||||
@@ -734,7 +735,7 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(data->bits.http_put) {
|
else if(HTTPREQ_PUT == data->httpreq) {
|
||||||
/* Let's PUT the data to the server! */
|
/* Let's PUT the data to the server! */
|
||||||
|
|
||||||
if(data->infilesize>0) {
|
if(data->infilesize>0) {
|
||||||
@@ -762,7 +763,7 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(data->bits.http_post) {
|
if(HTTPREQ_POST == data->httpreq) {
|
||||||
/* this is the simple POST, using x-www-form-urlencoded style */
|
/* this is the simple POST, using x-www-form-urlencoded style */
|
||||||
|
|
||||||
if(!checkheaders(data, "Content-Length:"))
|
if(!checkheaders(data, "Content-Length:"))
|
||||||
|
@@ -22,14 +22,13 @@ EXPORTS
|
|||||||
curl_global_init @ 13 ;
|
curl_global_init @ 13 ;
|
||||||
curl_slist_append @ 14 ;
|
curl_slist_append @ 14 ;
|
||||||
curl_slist_free_all @ 15 ;
|
curl_slist_free_all @ 15 ;
|
||||||
curl_unescape @ 16 ;
|
curl_version @ 16 ;
|
||||||
curl_version @ 17 ;
|
curl_maprintf @ 17 ;
|
||||||
curl_maprintf @ 18 ;
|
curl_mfprintf @ 18 ;
|
||||||
curl_mfprintf @ 19 ;
|
curl_mprintf @ 19 ;
|
||||||
curl_mprintf @ 20 ;
|
curl_msprintf @ 20 ;
|
||||||
curl_msprintf @ 21 ;
|
curl_msnprintf @ 21 ;
|
||||||
curl_msnprintf @ 22 ;
|
curl_mvfprintf @ 22 ;
|
||||||
curl_mvfprintf @ 23 ;
|
curl_strequal @ 23 ;
|
||||||
curl_strequal @ 24 ;
|
curl_strnequal @ 24 ;
|
||||||
curl_strnequal @ 25 ;
|
|
||||||
|
|
||||||
|
@@ -97,7 +97,9 @@ void Curl_pgrsDone(struct connectdata *conn)
|
|||||||
if(!(data->progress.flags & PGRS_HIDE)) {
|
if(!(data->progress.flags & PGRS_HIDE)) {
|
||||||
data->progress.lastshow=0;
|
data->progress.lastshow=0;
|
||||||
Curl_pgrsUpdate(conn); /* the final (forced) update */
|
Curl_pgrsUpdate(conn); /* the final (forced) update */
|
||||||
fprintf(data->err, "\n");
|
if(!data->progress.callback)
|
||||||
|
/* only output if we don't use progress callback */
|
||||||
|
fprintf(data->err, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -230,7 +230,8 @@ CURLcode Curl_client_write(struct UrlData *data,
|
|||||||
return CURLE_WRITE_ERROR;
|
return CURLE_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((type & CLIENTWRITE_HEADER) && data->writeheader) {
|
if((type & CLIENTWRITE_HEADER) &&
|
||||||
|
(data->fwrite_header || data->writeheader) ) {
|
||||||
/*
|
/*
|
||||||
* Write headers to the same callback or to the especially setup
|
* Write headers to the same callback or to the especially setup
|
||||||
* header callback function (added after version 7.7.1).
|
* header callback function (added after version 7.7.1).
|
||||||
|
@@ -230,7 +230,7 @@ int cert_verify_callback(int ok, X509_STORE_CTX *ctx)
|
|||||||
err_cert=X509_STORE_CTX_get_current_cert(ctx);
|
err_cert=X509_STORE_CTX_get_current_cert(ctx);
|
||||||
X509_NAME_oneline(X509_get_subject_name(err_cert),buf,256);
|
X509_NAME_oneline(X509_get_subject_name(err_cert),buf,256);
|
||||||
|
|
||||||
return 1;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -316,7 +316,7 @@ Curl_SSLConnect(struct connectdata *conn)
|
|||||||
|
|
||||||
if(data->cert) {
|
if(data->cert) {
|
||||||
if (!cert_stuff(conn, data->cert, data->cert)) {
|
if (!cert_stuff(conn, data->cert, data->cert)) {
|
||||||
failf(data, "couldn't use certificate!\n");
|
/* failf() is already done in cert_stuff() */
|
||||||
return CURLE_SSL_CONNECT_ERROR;
|
return CURLE_SSL_CONNECT_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -194,7 +194,7 @@ Transfer(struct connectdata *c_conn)
|
|||||||
int offset = 0; /* possible resume offset read from the
|
int offset = 0; /* possible resume offset read from the
|
||||||
Content-Range: header */
|
Content-Range: header */
|
||||||
int httpcode = 0; /* error code from the 'HTTP/1.? XXX' line */
|
int httpcode = 0; /* error code from the 'HTTP/1.? XXX' line */
|
||||||
int httpversion = -1; /* the last digit in the HTTP/1.1 string */
|
int httpversion = -1; /* the HTTP version*10 */
|
||||||
|
|
||||||
/* for the low speed checks: */
|
/* for the low speed checks: */
|
||||||
CURLcode urg;
|
CURLcode urg;
|
||||||
@@ -302,6 +302,7 @@ Transfer(struct connectdata *c_conn)
|
|||||||
we bail out from this! */
|
we bail out from this! */
|
||||||
else if (0 >= (signed int) nread) {
|
else if (0 >= (signed int) nread) {
|
||||||
keepon &= ~KEEP_READ;
|
keepon &= ~KEEP_READ;
|
||||||
|
FD_ZERO(&rkeepfd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,8 +465,21 @@ Transfer(struct connectdata *c_conn)
|
|||||||
if (!headerline++) {
|
if (!headerline++) {
|
||||||
/* This is the first header, it MUST be the error code line
|
/* This is the first header, it MUST be the error code line
|
||||||
or else we consiser this to be the body right away! */
|
or else we consiser this to be the body right away! */
|
||||||
if (2 == sscanf (p, " HTTP/1.%d %3d", &httpversion,
|
int httpversion_major;
|
||||||
&httpcode)) {
|
int nc=sscanf (p, " HTTP/%d.%d %3d",
|
||||||
|
&httpversion_major ,&httpversion, &httpcode);
|
||||||
|
if (nc==3) {
|
||||||
|
httpversion+=10*httpversion_major;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* this is the real world, not a Nirvana
|
||||||
|
NCSA 1.5.x returns this crap when asked for HTTP/1.1
|
||||||
|
*/
|
||||||
|
nc=sscanf (p, " HTTP %3d", &httpcode);
|
||||||
|
httpversion = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nc) {
|
||||||
data->progress.httpcode = httpcode;
|
data->progress.httpcode = httpcode;
|
||||||
data->progress.httpversion = httpversion;
|
data->progress.httpversion = httpversion;
|
||||||
|
|
||||||
@@ -484,7 +498,7 @@ Transfer(struct connectdata *c_conn)
|
|||||||
return CURLE_HTTP_NOT_FOUND;
|
return CURLE_HTTP_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(httpversion == 0)
|
if(httpversion == 10)
|
||||||
/* Default action for HTTP/1.0 must be to close, unless
|
/* Default action for HTTP/1.0 must be to close, unless
|
||||||
we get one of those fancy headers that tell us the
|
we get one of those fancy headers that tell us the
|
||||||
server keeps it open for us! */
|
server keeps it open for us! */
|
||||||
@@ -510,7 +524,7 @@ Transfer(struct connectdata *c_conn)
|
|||||||
conn->size = contentlength;
|
conn->size = contentlength;
|
||||||
Curl_pgrsSetDownloadSize(data, contentlength);
|
Curl_pgrsSetDownloadSize(data, contentlength);
|
||||||
}
|
}
|
||||||
else if((httpversion == 0) &&
|
else if((httpversion == 10) &&
|
||||||
conn->bits.httpproxy &&
|
conn->bits.httpproxy &&
|
||||||
compareheader(p, "Proxy-Connection:", "keep-alive")) {
|
compareheader(p, "Proxy-Connection:", "keep-alive")) {
|
||||||
/*
|
/*
|
||||||
@@ -522,7 +536,7 @@ Transfer(struct connectdata *c_conn)
|
|||||||
conn->bits.close = FALSE; /* don't close when done */
|
conn->bits.close = FALSE; /* don't close when done */
|
||||||
infof(data, "HTTP/1.0 proxy connection set to keep alive!\n");
|
infof(data, "HTTP/1.0 proxy connection set to keep alive!\n");
|
||||||
}
|
}
|
||||||
else if((httpversion == 0) &&
|
else if((httpversion == 10) &&
|
||||||
compareheader(p, "Connection:", "keep-alive")) {
|
compareheader(p, "Connection:", "keep-alive")) {
|
||||||
/*
|
/*
|
||||||
* A HTTP/1.0 reply with the 'Connection: keep-alive' line
|
* A HTTP/1.0 reply with the 'Connection: keep-alive' line
|
||||||
@@ -711,6 +725,7 @@ Transfer(struct connectdata *c_conn)
|
|||||||
else if(CHUNKE_STOP == res) {
|
else if(CHUNKE_STOP == res) {
|
||||||
/* we're done reading chunks! */
|
/* we're done reading chunks! */
|
||||||
keepon &= ~KEEP_READ; /* read no more */
|
keepon &= ~KEEP_READ; /* read no more */
|
||||||
|
FD_ZERO(&rkeepfd);
|
||||||
|
|
||||||
/* There are now possibly N number of bytes at the end of the
|
/* There are now possibly N number of bytes at the end of the
|
||||||
str buffer that weren't written to the client, but we don't
|
str buffer that weren't written to the client, but we don't
|
||||||
@@ -724,7 +739,9 @@ Transfer(struct connectdata *c_conn)
|
|||||||
nread = conn->maxdownload - bytecount;
|
nread = conn->maxdownload - bytecount;
|
||||||
if((signed int)nread < 0 ) /* this should be unusual */
|
if((signed int)nread < 0 ) /* this should be unusual */
|
||||||
nread = 0;
|
nread = 0;
|
||||||
|
|
||||||
keepon &= ~KEEP_READ; /* we're done reading */
|
keepon &= ~KEEP_READ; /* we're done reading */
|
||||||
|
FD_ZERO(&rkeepfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
bytecount += nread;
|
bytecount += nread;
|
||||||
@@ -758,6 +775,7 @@ Transfer(struct connectdata *c_conn)
|
|||||||
if ((signed int)nread<=0) {
|
if ((signed int)nread<=0) {
|
||||||
/* done */
|
/* done */
|
||||||
keepon &= ~KEEP_WRITE; /* we're done writing */
|
keepon &= ~KEEP_WRITE; /* we're done writing */
|
||||||
|
FD_ZERO(&wkeepfd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
writebytecount += nread;
|
writebytecount += nread;
|
||||||
@@ -1041,10 +1059,8 @@ CURLcode Curl_perform(CURL *curl)
|
|||||||
case 303: /* See Other */
|
case 303: /* See Other */
|
||||||
/* Disable both types of POSTs, since doing a second POST when
|
/* Disable both types of POSTs, since doing a second POST when
|
||||||
* following isn't what anyone would want! */
|
* following isn't what anyone would want! */
|
||||||
data->bits.http_post = FALSE;
|
data->httpreq = HTTPREQ_GET; /* enforce GET request */
|
||||||
data->bits.http_formpost = FALSE;
|
infof(data, "Disables POST, goes with GET\n");
|
||||||
data->httpreq = HTTPREQ_GET; /* enfore GET request */
|
|
||||||
infof(data, "Disables POST\n");
|
|
||||||
break;
|
break;
|
||||||
case 304: /* Not Modified */
|
case 304: /* Not Modified */
|
||||||
/* 304 means we did a conditional request and it was "Not modified".
|
/* 304 means we did a conditional request and it was "Not modified".
|
||||||
|
35
lib/url.c
35
lib/url.c
@@ -432,10 +432,10 @@ CURLcode Curl_setopt(CURL *curl, CURLoption option, ...)
|
|||||||
break;
|
break;
|
||||||
case CURLOPT_PUT:
|
case CURLOPT_PUT:
|
||||||
/*
|
/*
|
||||||
* Use the HTTP PUT request to transfer data.
|
* Use the HTTP PUT request to transfer data if this is TRUE. If this is
|
||||||
|
* FALSE, don't set the httpreq. We can't know what to revert it to!
|
||||||
*/
|
*/
|
||||||
data->bits.http_put = va_arg(param, long)?TRUE:FALSE;
|
if(va_arg(param, long))
|
||||||
if(data->bits.http_put)
|
|
||||||
data->httpreq = HTTPREQ_PUT;
|
data->httpreq = HTTPREQ_PUT;
|
||||||
break;
|
break;
|
||||||
#if 0
|
#if 0
|
||||||
@@ -480,9 +480,9 @@ CURLcode Curl_setopt(CURL *curl, CURLoption option, ...)
|
|||||||
break;
|
break;
|
||||||
case CURLOPT_WRITEHEADER:
|
case CURLOPT_WRITEHEADER:
|
||||||
/*
|
/*
|
||||||
* Callback function for header data
|
* Custom pointer to pass the header write callback function
|
||||||
*/
|
*/
|
||||||
data->writeheader = (FILE *)va_arg(param, FILE *);
|
data->writeheader = (void *)va_arg(param, void *);
|
||||||
break;
|
break;
|
||||||
case CURLOPT_COOKIE:
|
case CURLOPT_COOKIE:
|
||||||
/*
|
/*
|
||||||
@@ -529,10 +529,18 @@ CURLcode Curl_setopt(CURL *curl, CURLoption option, ...)
|
|||||||
* Set to make us do HTTP POST
|
* Set to make us do HTTP POST
|
||||||
*/
|
*/
|
||||||
data->httppost = va_arg(param, struct HttpPost *);
|
data->httppost = va_arg(param, struct HttpPost *);
|
||||||
data->bits.http_formpost = data->httppost?1:0;
|
if(data->httppost)
|
||||||
if(data->bits.http_formpost)
|
|
||||||
data->httpreq = HTTPREQ_POST_FORM;
|
data->httpreq = HTTPREQ_POST_FORM;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CURLOPT_HTTPGET:
|
||||||
|
/*
|
||||||
|
* Set to force us do HTTP GET
|
||||||
|
*/
|
||||||
|
if(va_arg(param, long))
|
||||||
|
data->httpreq = HTTPREQ_GET;
|
||||||
|
break;
|
||||||
|
|
||||||
case CURLOPT_INFILE:
|
case CURLOPT_INFILE:
|
||||||
/*
|
/*
|
||||||
* FILE pointer to read the file to be uploaded from. Or possibly
|
* FILE pointer to read the file to be uploaded from. Or possibly
|
||||||
@@ -575,8 +583,8 @@ CURLcode Curl_setopt(CURL *curl, CURLoption option, ...)
|
|||||||
break;
|
break;
|
||||||
case CURLOPT_POST:
|
case CURLOPT_POST:
|
||||||
/* Does this option serve a purpose anymore? */
|
/* Does this option serve a purpose anymore? */
|
||||||
data->bits.http_post = va_arg(param, long)?TRUE:FALSE;
|
|
||||||
if(data->bits.http_post)
|
if(va_arg(param, long))
|
||||||
data->httpreq = HTTPREQ_POST;
|
data->httpreq = HTTPREQ_POST;
|
||||||
break;
|
break;
|
||||||
case CURLOPT_POSTFIELDS:
|
case CURLOPT_POSTFIELDS:
|
||||||
@@ -584,8 +592,7 @@ CURLcode Curl_setopt(CURL *curl, CURLoption option, ...)
|
|||||||
* A string with POST data. Makes curl HTTP POST.
|
* A string with POST data. Makes curl HTTP POST.
|
||||||
*/
|
*/
|
||||||
data->postfields = va_arg(param, char *);
|
data->postfields = va_arg(param, char *);
|
||||||
data->bits.http_post = data->postfields?TRUE:FALSE;
|
if(data->postfields)
|
||||||
if(data->bits.http_post)
|
|
||||||
data->httpreq = HTTPREQ_POST;
|
data->httpreq = HTTPREQ_POST;
|
||||||
break;
|
break;
|
||||||
case CURLOPT_POSTFIELDSIZE:
|
case CURLOPT_POSTFIELDSIZE:
|
||||||
@@ -2080,6 +2087,12 @@ static CURLcode Connect(struct UrlData *data,
|
|||||||
conn->bits.use_range = TRUE; /* enable range download */
|
conn->bits.use_range = TRUE; /* enable range download */
|
||||||
conn->bits.rangestringalloc = TRUE; /* mark range string allocated */
|
conn->bits.rangestringalloc = TRUE; /* mark range string allocated */
|
||||||
}
|
}
|
||||||
|
else if (data->set_range) {
|
||||||
|
/* There is a range, but is not a resume, useful for random ftp access */
|
||||||
|
conn->range = strdup(data->set_range);
|
||||||
|
conn->bits.rangestringalloc = TRUE; /* mark range string allocated */
|
||||||
|
conn->bits.use_range = TRUE; /* enable range download */
|
||||||
|
}
|
||||||
|
|
||||||
*in_connect = conn; /* return this instead! */
|
*in_connect = conn; /* return this instead! */
|
||||||
|
|
||||||
|
@@ -382,12 +382,6 @@ typedef enum {
|
|||||||
/* This struct is for boolean settings that define how to behave during
|
/* This struct is for boolean settings that define how to behave during
|
||||||
this session. */
|
this session. */
|
||||||
struct Configbits {
|
struct Configbits {
|
||||||
/* these four request types mirror the httpreq field */
|
|
||||||
bool http_formpost;
|
|
||||||
bool http_post;
|
|
||||||
bool http_put;
|
|
||||||
bool http_get;
|
|
||||||
|
|
||||||
bool get_filetime;
|
bool get_filetime;
|
||||||
bool tunnel_thru_httpproxy;
|
bool tunnel_thru_httpproxy;
|
||||||
bool ftp_append;
|
bool ftp_append;
|
||||||
|
64
src/main.c
64
src/main.c
@@ -126,52 +126,6 @@ char *strdup(char *str)
|
|||||||
|
|
||||||
extern void hugehelp(void);
|
extern void hugehelp(void);
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* Start with some silly functions to make win32-systems survive
|
|
||||||
***********************************************************************/
|
|
||||||
#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
|
|
||||||
static void win32_cleanup(void)
|
|
||||||
{
|
|
||||||
WSACleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
static CURLcode win32_init(void)
|
|
||||||
{
|
|
||||||
WORD wVersionRequested;
|
|
||||||
WSADATA wsaData;
|
|
||||||
int err;
|
|
||||||
wVersionRequested = MAKEWORD(1, 1);
|
|
||||||
|
|
||||||
err = WSAStartup(wVersionRequested, &wsaData);
|
|
||||||
|
|
||||||
if (err != 0)
|
|
||||||
/* Tell the user that we couldn't find a useable */
|
|
||||||
/* winsock.dll. */
|
|
||||||
return CURLE_FAILED_INIT;
|
|
||||||
|
|
||||||
/* Confirm that the Windows Sockets DLL supports 1.1.*/
|
|
||||||
/* Note that if the DLL supports versions greater */
|
|
||||||
/* than 1.1 in addition to 1.1, it will still return */
|
|
||||||
/* 1.1 in wVersion since that is the version we */
|
|
||||||
/* requested. */
|
|
||||||
|
|
||||||
if ( LOBYTE( wsaData.wVersion ) != 1 ||
|
|
||||||
HIBYTE( wsaData.wVersion ) != 1 ) {
|
|
||||||
/* Tell the user that we couldn't find a useable */
|
|
||||||
|
|
||||||
/* winsock.dll. */
|
|
||||||
WSACleanup();
|
|
||||||
return CURLE_FAILED_INIT;
|
|
||||||
}
|
|
||||||
return CURLE_OK;
|
|
||||||
}
|
|
||||||
/* The Windows Sockets DLL is acceptable. Proceed. */
|
|
||||||
#else
|
|
||||||
static CURLcode win32_init(void) { return CURLE_OK; }
|
|
||||||
#define win32_cleanup()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the main global constructor for the app. Call this before
|
* This is the main global constructor for the app. Call this before
|
||||||
* _any_ libcurl usage. If this fails, *NO* libcurl functions may be
|
* _any_ libcurl usage. If this fails, *NO* libcurl functions may be
|
||||||
@@ -179,8 +133,7 @@ static CURLcode win32_init(void) { return CURLE_OK; }
|
|||||||
*/
|
*/
|
||||||
CURLcode main_init(void)
|
CURLcode main_init(void)
|
||||||
{
|
{
|
||||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
return curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||||
return win32_init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -189,7 +142,6 @@ CURLcode main_init(void)
|
|||||||
*/
|
*/
|
||||||
void main_free(void)
|
void main_free(void)
|
||||||
{
|
{
|
||||||
win32_cleanup();
|
|
||||||
curl_global_cleanup();
|
curl_global_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,6 +261,7 @@ struct Configurable {
|
|||||||
char *useragent;
|
char *useragent;
|
||||||
char *cookie;
|
char *cookie;
|
||||||
bool use_resume;
|
bool use_resume;
|
||||||
|
bool resume_from_current;
|
||||||
int resume_from;
|
int resume_from;
|
||||||
char *postfields;
|
char *postfields;
|
||||||
long postfieldsize;
|
long postfieldsize;
|
||||||
@@ -757,8 +710,14 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
/* This makes us continue an ftp transfer at given position */
|
/* This makes us continue an ftp transfer at given position */
|
||||||
if(!strequal(nextarg, "-"))
|
if(!strequal(nextarg, "-")) {
|
||||||
config->resume_from= atoi(nextarg);
|
config->resume_from= atoi(nextarg);
|
||||||
|
config->resume_from_current = FALSE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
config->resume_from_current = TRUE;
|
||||||
|
config->resume_from = 0;
|
||||||
|
}
|
||||||
config->use_resume=TRUE;
|
config->use_resume=TRUE;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
@@ -1639,7 +1598,7 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
free(storefile);
|
free(storefile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((0 == config->resume_from) && config->use_resume) {
|
if(config->resume_from_current) {
|
||||||
/* we're told to continue where we are now, then we get the size of
|
/* we're told to continue where we are now, then we get the size of
|
||||||
the file as it is now and open it for append instead */
|
the file as it is now and open it for append instead */
|
||||||
|
|
||||||
@@ -1707,8 +1666,7 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
|
|
||||||
}
|
}
|
||||||
if((config->conf&CONF_UPLOAD) &&
|
if((config->conf&CONF_UPLOAD) &&
|
||||||
config->use_resume &&
|
config->resume_from_current) {
|
||||||
(0==config->resume_from)) {
|
|
||||||
config->resume_from = -1; /* -1 will then force get-it-yourself */
|
config->resume_from = -1; /* -1 will then force get-it-yourself */
|
||||||
}
|
}
|
||||||
if(config->headerfile) {
|
if(config->headerfile) {
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
#define CURL_NAME "curl"
|
#define CURL_NAME "curl"
|
||||||
#define CURL_VERSION "7.8"
|
#define CURL_VERSION "7.8.1-pre3"
|
||||||
#define CURL_ID CURL_NAME " " CURL_VERSION " (" OS ") "
|
#define CURL_ID CURL_NAME " " CURL_VERSION " (" OS ") "
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
EXTRA_DIST = ftpserver.pl httpserver.pl runtests.pl ftpsserver.pl stunnel.pm \
|
EXTRA_DIST = ftpserver.pl httpserver.pl httpsserver.pl runtests.pl \
|
||||||
getpart.pm
|
ftpsserver.pl stunnel.pm getpart.pm
|
||||||
|
|
||||||
SUBDIRS = data
|
SUBDIRS = data
|
||||||
|
|
||||||
|
@@ -5,6 +5,7 @@ test:
|
|||||||
[ -f test1 ] || ln -s $(srcdir)/test* .
|
[ -f test1 ] || ln -s $(srcdir)/test* .
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
test1 test11 test14 test3 test400 test7 \
|
test1 test102 test106 test13 test17 test300 test43 test8 \
|
||||||
test10 test12 test2 test300 test5 test8 \
|
test10 test103 test107 test14 test2 test33 test5 test9 \
|
||||||
test100 test13 test200 test4 test6 test9
|
test100 test104 test11 test15 test200 test4 test6 \
|
||||||
|
test101 test105 test12 test16 test3 test400 test7
|
||||||
|
44
tests/data/test101
Normal file
44
tests/data/test101
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
<data>
|
||||||
|
total 20
|
||||||
|
drwxr-xr-x 8 98 98 512 Oct 22 13:06 .
|
||||||
|
drwxr-xr-x 8 98 98 512 Oct 22 13:06 ..
|
||||||
|
drwxr-xr-x 2 98 98 512 May 2 1996 .NeXT
|
||||||
|
-r--r--r-- 1 0 1 35 Jul 16 1996 README
|
||||||
|
lrwxrwxrwx 1 0 1 7 Dec 9 1999 bin -> usr/bin
|
||||||
|
dr-xr-xr-x 2 0 1 512 Oct 1 1997 dev
|
||||||
|
drwxrwxrwx 2 98 98 512 May 29 16:04 download.html
|
||||||
|
dr-xr-xr-x 2 0 1 512 Nov 30 1995 etc
|
||||||
|
drwxrwxrwx 2 98 1 512 Oct 30 14:33 pub
|
||||||
|
dr-xr-xr-x 5 0 1 512 Oct 1 1997 usr
|
||||||
|
</data>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<name>
|
||||||
|
FTP dir list, PORT with specified IP
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
ftp://%HOSTIP:%FTPPORT/ -P %HOSTIP
|
||||||
|
</command>
|
||||||
|
</test>
|
||||||
|
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
# strip all kinds of PORT, EPRT and LPRT curl can do
|
||||||
|
<strip>
|
||||||
|
^PORT 127,0,0,1,.*
|
||||||
|
^EPRT.*
|
||||||
|
^LPRT.*
|
||||||
|
</strip>
|
||||||
|
<protocol>
|
||||||
|
USER anonymous
|
||||||
|
PASS curl_by_daniel@haxx.se
|
||||||
|
PWD
|
||||||
|
PORT 127,0,0,1,243,212
|
||||||
|
TYPE A
|
||||||
|
LIST
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
33
tests/data/test102
Normal file
33
tests/data/test102
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
<data>
|
||||||
|
data
|
||||||
|
to
|
||||||
|
see
|
||||||
|
that FTP
|
||||||
|
works
|
||||||
|
so does it?
|
||||||
|
</data>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<name>
|
||||||
|
FTP RETR PASV
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
ftp://%HOSTIP:%FTPPORT/102
|
||||||
|
</command>
|
||||||
|
</test>
|
||||||
|
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<protocol>
|
||||||
|
USER anonymous
|
||||||
|
PASS curl_by_daniel@haxx.se
|
||||||
|
PWD
|
||||||
|
PASV
|
||||||
|
TYPE I
|
||||||
|
RETR 102
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
39
tests/data/test103
Normal file
39
tests/data/test103
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
<data>
|
||||||
|
data
|
||||||
|
to
|
||||||
|
see
|
||||||
|
that FTP
|
||||||
|
works
|
||||||
|
so does it?
|
||||||
|
</data>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<name>
|
||||||
|
FTP RETR PORT with CWD
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
ftp://%HOSTIP:%FTPPORT/a/path/103 -P -
|
||||||
|
</command>
|
||||||
|
</test>
|
||||||
|
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<strip>
|
||||||
|
^PORT .*
|
||||||
|
^EPRT.*
|
||||||
|
^LPRT.*
|
||||||
|
</strip>
|
||||||
|
<protocol>
|
||||||
|
USER anonymous
|
||||||
|
PASS curl_by_daniel@haxx.se
|
||||||
|
PWD
|
||||||
|
CWD a/path
|
||||||
|
PORT 127,0,0,1,246,33
|
||||||
|
TYPE I
|
||||||
|
RETR 103
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
29
tests/data/test104
Normal file
29
tests/data/test104
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
<size>
|
||||||
|
51
|
||||||
|
</size>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<name>
|
||||||
|
FTP --head to get file size only
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
ftp://%HOSTIP:%FTPPORT/a/path/103 --head
|
||||||
|
</command>
|
||||||
|
</test>
|
||||||
|
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<protocol>
|
||||||
|
USER anonymous
|
||||||
|
PASS curl_by_daniel@haxx.se
|
||||||
|
PWD
|
||||||
|
CWD a/path
|
||||||
|
MDTM 103
|
||||||
|
TYPE I
|
||||||
|
SIZE 103
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
33
tests/data/test105
Normal file
33
tests/data/test105
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
<data>
|
||||||
|
data
|
||||||
|
to
|
||||||
|
see
|
||||||
|
that FTP
|
||||||
|
works
|
||||||
|
so does it?
|
||||||
|
</data>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<name>
|
||||||
|
FTP user+password in URL and ASCII transfer
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
ftp://userdude:passfellow@%HOSTIP:%FTPPORT/103 --use-ascii
|
||||||
|
</command>
|
||||||
|
</test>
|
||||||
|
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<protocol>
|
||||||
|
USER userdude
|
||||||
|
PASS passfellow
|
||||||
|
PWD
|
||||||
|
PASV
|
||||||
|
TYPE A
|
||||||
|
RETR 103
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
34
tests/data/test106
Normal file
34
tests/data/test106
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
<data>
|
||||||
|
data
|
||||||
|
to
|
||||||
|
see
|
||||||
|
that FTP
|
||||||
|
works
|
||||||
|
so does it?
|
||||||
|
</data>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<name>
|
||||||
|
FTP GET with type=A style ASCII URL using %20 codes
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
"ftp://%HOSTIP:%FTPPORT//path%20with%20%20spaces/and%20things2/106;type=A"
|
||||||
|
</command>
|
||||||
|
</test>
|
||||||
|
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<protocol>
|
||||||
|
USER anonymous
|
||||||
|
PASS curl_by_daniel@haxx.se
|
||||||
|
PWD
|
||||||
|
CWD /path with spaces/and things2
|
||||||
|
PASV
|
||||||
|
TYPE A
|
||||||
|
RETR 106
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
38
tests/data/test107
Normal file
38
tests/data/test107
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<name>
|
||||||
|
FTP PASV upload file
|
||||||
|
</name>
|
||||||
|
<file name="log/test107.txt">
|
||||||
|
data
|
||||||
|
to
|
||||||
|
see
|
||||||
|
that FTP
|
||||||
|
works
|
||||||
|
so does it?
|
||||||
|
</file>
|
||||||
|
<command>
|
||||||
|
ftp://%HOSTIP:%FTPPORT/107 -T log/test107.txt
|
||||||
|
</command>
|
||||||
|
</test>
|
||||||
|
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<upload>
|
||||||
|
data
|
||||||
|
to
|
||||||
|
see
|
||||||
|
that FTP
|
||||||
|
works
|
||||||
|
so does it?
|
||||||
|
</upload>
|
||||||
|
<protocol>
|
||||||
|
USER anonymous
|
||||||
|
PASS curl_by_daniel@haxx.se
|
||||||
|
PWD
|
||||||
|
PASV
|
||||||
|
TYPE I
|
||||||
|
STOR 107
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
44
tests/data/test15
Normal file
44
tests/data/test15
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
<data nocheck=true>
|
||||||
|
HTTP/1.4 200 OK
|
||||||
|
Fake: yes
|
||||||
|
Fake: yes
|
||||||
|
Fake: yes
|
||||||
|
|
||||||
|
Repeated nonsense-headers
|
||||||
|
</data>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<name>
|
||||||
|
--write-out test
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
http://%HOSTIP:%HOSTPORT/want/15 --write-out '%{url_effective} %{http_code} %{size_download}\n'
|
||||||
|
</command>
|
||||||
|
</test>
|
||||||
|
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<stdout>
|
||||||
|
HTTP/1.4 200 OK
|
||||||
|
Fake: yes
|
||||||
|
Fake: yes
|
||||||
|
Fake: yes
|
||||||
|
|
||||||
|
Repeated nonsense-headers
|
||||||
|
http://127.0.0.1:8999/want/15 200 26
|
||||||
|
</stdout>
|
||||||
|
<strip>
|
||||||
|
^User-Agent:.*
|
||||||
|
</strip>
|
||||||
|
<protocol>
|
||||||
|
GET /want/15 HTTP/1.1
|
||||||
|
Host: 127.0.0.1:8999
|
||||||
|
Pragma: no-cache
|
||||||
|
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
|
||||||
|
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
37
tests/data/test16
Normal file
37
tests/data/test16
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
<data>
|
||||||
|
HTTP/1.1 200 OK
|
||||||
|
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||||
|
Server: test-server/fake
|
||||||
|
Content-Type: text/html
|
||||||
|
Funny-head: yesyes
|
||||||
|
|
||||||
|
the content goes here
|
||||||
|
</data>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<name>
|
||||||
|
HTTP with proxy athorization
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
-U fake@user:<3A><><EFBFBD>looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong -x %HOSTIP:%HOSTPORT http://we.want.that.site.com/16
|
||||||
|
</command>
|
||||||
|
</test>
|
||||||
|
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<strip>
|
||||||
|
^User-Agent:.*
|
||||||
|
</strip>
|
||||||
|
<protocol>
|
||||||
|
GET http://we.want.that.site.com/16 HTTP/1.1
|
||||||
|
Proxy-authorization: Basic ZmFrZUB1c2VyOqenp2xvb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb28=
|
||||||
|
Host: we.want.that.site.com
|
||||||
|
Pragma: no-cache
|
||||||
|
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
|
||||||
|
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
42
tests/data/test17
Normal file
42
tests/data/test17
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
<data>
|
||||||
|
HTTP/1.1 200 OK
|
||||||
|
Funny-head: yesyes
|
||||||
|
|
||||||
|
This is the proof it works
|
||||||
|
</data>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<name>
|
||||||
|
HTTP with config file on stdin
|
||||||
|
</name>
|
||||||
|
<stdin>
|
||||||
|
#
|
||||||
|
# Use a silly request without '--':
|
||||||
|
request MOOO
|
||||||
|
#
|
||||||
|
# Set the user-agent using a short-option:
|
||||||
|
-A "agent007 license to drill\t"
|
||||||
|
#
|
||||||
|
# long option *with* '--':
|
||||||
|
--max-time 180
|
||||||
|
</stdin>
|
||||||
|
<command>
|
||||||
|
-K - %HOSTIP:%HOSTPORT/that.site.com/17
|
||||||
|
</command>
|
||||||
|
</test>
|
||||||
|
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<protocol>
|
||||||
|
MOOO /that.site.com/17 HTTP/1.1
|
||||||
|
User-Agent: agent007 license to drill
|
||||||
|
Host: 127.0.0.1:8999
|
||||||
|
Pragma: no-cache
|
||||||
|
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
|
||||||
|
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
50
tests/data/test33
Normal file
50
tests/data/test33
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<name>
|
||||||
|
HTTP PUT with resume
|
||||||
|
</name>
|
||||||
|
<file name="log/test33.txt">
|
||||||
|
012345678
|
||||||
|
012345678
|
||||||
|
012345678
|
||||||
|
012345678
|
||||||
|
012345678
|
||||||
|
012345678
|
||||||
|
012345678
|
||||||
|
012345678
|
||||||
|
012345678
|
||||||
|
012345678
|
||||||
|
</file>
|
||||||
|
<command>
|
||||||
|
http://%HOSTIP:%HOSTPORT/33 -Tlog/test33.txt -C 50
|
||||||
|
</command>
|
||||||
|
</test>
|
||||||
|
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<strip>
|
||||||
|
^User-Agent:.*
|
||||||
|
</strip>
|
||||||
|
<protocol>
|
||||||
|
PUT /33 HTTP/1.1
|
||||||
|
Content-Range: bytes 50-99/100
|
||||||
|
User-Agent: curl/7.6 (sparc-sun-solaris2.7) libcurl 7.6-pre4 (SSL 0.9.6) (krb4 enabled)
|
||||||
|
Host: 127.0.0.1:8999
|
||||||
|
Pragma: no-cache
|
||||||
|
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
|
||||||
|
Content-Length: 50
|
||||||
|
|
||||||
|
012345678
|
||||||
|
012345678
|
||||||
|
012345678
|
||||||
|
012345678
|
||||||
|
012345678
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
64
tests/data/test43
Normal file
64
tests/data/test43
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
<data>
|
||||||
|
HTTP/1.1 301 This is a weirdo text message
|
||||||
|
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||||
|
Server: test-server/fake
|
||||||
|
Location: data/110002.txt?coolsite=yes
|
||||||
|
Connection: close
|
||||||
|
|
||||||
|
This server reply is for testing a simple Location: following
|
||||||
|
|
||||||
|
</data>
|
||||||
|
<data2>
|
||||||
|
HTTP/1.1 200 Followed here fine
|
||||||
|
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||||
|
Server: test-server/fake
|
||||||
|
|
||||||
|
If this is received, the location following worked
|
||||||
|
|
||||||
|
</data2>
|
||||||
|
<datacheck>
|
||||||
|
HTTP/1.1 301 This is a weirdo text message
|
||||||
|
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||||
|
Server: test-server/fake
|
||||||
|
Location: data/110002.txt?coolsite=yes
|
||||||
|
Connection: close
|
||||||
|
|
||||||
|
HTTP/1.1 200 Followed here fine
|
||||||
|
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||||
|
Server: test-server/fake
|
||||||
|
|
||||||
|
If this is received, the location following worked
|
||||||
|
|
||||||
|
</datacheck>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<name>
|
||||||
|
HTTP Location: following over HTTP proxy
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
http://%HOSTIP:%HOSTPORT/want/11 -L -x %HOSTIP:%HOSTPORT
|
||||||
|
</command>
|
||||||
|
</test>
|
||||||
|
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<strip>
|
||||||
|
^User-Agent:.*
|
||||||
|
</strip>
|
||||||
|
<protocol>
|
||||||
|
GET http://127.0.0.1:8999/want/11 HTTP/1.1
|
||||||
|
Host: 127.0.0.1:8999
|
||||||
|
Pragma: no-cache
|
||||||
|
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
|
||||||
|
|
||||||
|
GET http://127.0.0.1:8999/want/data/110002.txt?coolsite=yes HTTP/1.1
|
||||||
|
Host: 127.0.0.1:8999
|
||||||
|
Pragma: no-cache
|
||||||
|
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
|
||||||
|
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
@@ -162,11 +162,9 @@ sub SIZE_command {
|
|||||||
|
|
||||||
logmsg "SIZE number $testno\n";
|
logmsg "SIZE number $testno\n";
|
||||||
|
|
||||||
my $filename = "data/reply$testno.txt";
|
my @data = getpart("reply", "size");
|
||||||
|
|
||||||
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
|
my $size = $data[0];
|
||||||
$atime,$mtime,$ctime,$blksize,$blocks)
|
|
||||||
= stat($filename);
|
|
||||||
|
|
||||||
if($size) {
|
if($size) {
|
||||||
print "213 $size\r\n";
|
print "213 $size\r\n";
|
||||||
@@ -198,7 +196,7 @@ sub RETR_command {
|
|||||||
|
|
||||||
my $size=0;
|
my $size=0;
|
||||||
for(@data) {
|
for(@data) {
|
||||||
$size =+ length($_);
|
$size += length($_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($size) {
|
if($size) {
|
||||||
@@ -206,10 +204,16 @@ sub RETR_command {
|
|||||||
if($rest) {
|
if($rest) {
|
||||||
# move read pointer forward
|
# move read pointer forward
|
||||||
$size -= $rest;
|
$size -= $rest;
|
||||||
|
if($verbose) {
|
||||||
|
print STDERR "** REST $rest was removed from size.\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
print "150 Binary data connection for $testno () ($size bytes).\r\n";
|
print "150 Binary data connection for $testno () ($size bytes).\r\n";
|
||||||
$rest=0; # reset rest again
|
$rest=0; # reset rest again
|
||||||
|
|
||||||
|
if($verbose) {
|
||||||
|
print STDERR "150 Binary data connection for $testno ($size bytes).\n";
|
||||||
|
}
|
||||||
for(@data) {
|
for(@data) {
|
||||||
print SOCK $_;
|
print SOCK $_;
|
||||||
}
|
}
|
||||||
@@ -219,6 +223,9 @@ sub RETR_command {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print "550 $testno: No such file or directory.\r\n";
|
print "550 $testno: No such file or directory.\r\n";
|
||||||
|
if($verbose) {
|
||||||
|
print STDERR "550 $testno: no such file\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -470,7 +470,7 @@ sub singletest {
|
|||||||
# run curl, add -v for debug information output
|
# run curl, add -v for debug information output
|
||||||
my $cmdargs="$out--include -v $cmd";
|
my $cmdargs="$out--include -v $cmd";
|
||||||
|
|
||||||
my @stdintest = getpart("verify", "stdin");
|
my @stdintest = getpart("client", "stdin");
|
||||||
|
|
||||||
if(@stdintest) {
|
if(@stdintest) {
|
||||||
my $stdinfile="$LOGDIR/stdin-for-$testnum";
|
my $stdinfile="$LOGDIR/stdin-for-$testnum";
|
||||||
@@ -514,7 +514,7 @@ sub singletest {
|
|||||||
if(!$short) {
|
if(!$short) {
|
||||||
print "curl returned $res\n";
|
print "curl returned $res\n";
|
||||||
}
|
}
|
||||||
print " error FAILED";
|
print " error FAILED\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -525,7 +525,7 @@ sub singletest {
|
|||||||
|
|
||||||
$res = compare(\@actual, \@validstdout);
|
$res = compare(\@actual, \@validstdout);
|
||||||
if($res) {
|
if($res) {
|
||||||
print " stdout FAILED";
|
print " stdout FAILED\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(!$short) {
|
if(!$short) {
|
||||||
@@ -533,12 +533,14 @@ sub singletest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(@reply) {
|
my %replyattr = getpartattr("reply", "data");
|
||||||
|
if(!$replyattr{'nocheck'} &&
|
||||||
|
@reply) {
|
||||||
# verify the received data
|
# verify the received data
|
||||||
my @out = loadarray($CURLOUT);
|
my @out = loadarray($CURLOUT);
|
||||||
$res = compare(\@out, \@reply);
|
$res = compare(\@out, \@reply);
|
||||||
if ($res) {
|
if ($res) {
|
||||||
print " data FAILED";
|
print " data FAILED\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(!$short) {
|
if(!$short) {
|
||||||
@@ -551,7 +553,7 @@ sub singletest {
|
|||||||
my @out = loadarray("$LOGDIR/upload.$testnum");
|
my @out = loadarray("$LOGDIR/upload.$testnum");
|
||||||
$res = compare(\@out, \@upload);
|
$res = compare(\@out, \@upload);
|
||||||
if ($res) {
|
if ($res) {
|
||||||
print " upload FAILED";
|
print " upload FAILED\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(!$short) {
|
if(!$short) {
|
||||||
@@ -565,13 +567,18 @@ sub singletest {
|
|||||||
|
|
||||||
# what to cut off from the live protocol sent by curl
|
# what to cut off from the live protocol sent by curl
|
||||||
my @strip = getpart("verify", "strip");
|
my @strip = getpart("verify", "strip");
|
||||||
@out = striparray( $strip[0], \@out);
|
|
||||||
|
|
||||||
my @protstrip= striparray($strip[0], \@protocol);
|
my @protstrip=@protocol;
|
||||||
|
|
||||||
|
for(@strip) {
|
||||||
|
# strip all patterns from both arrays
|
||||||
|
@out = striparray( $_, \@out);
|
||||||
|
@protstrip= striparray( $_, \@protstrip);
|
||||||
|
}
|
||||||
|
|
||||||
$res = compare(\@out, \@protstrip);
|
$res = compare(\@out, \@protstrip);
|
||||||
if($res) {
|
if($res) {
|
||||||
print " protocol FAILED";
|
print " protocol FAILED\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(!$short) {
|
if(!$short) {
|
||||||
@@ -593,7 +600,7 @@ sub singletest {
|
|||||||
|
|
||||||
$res = compare(\@generated, \@outfile);
|
$res = compare(\@generated, \@outfile);
|
||||||
if($res) {
|
if($res) {
|
||||||
print " output FAILED";
|
print " output FAILED\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(!$short) {
|
if(!$short) {
|
||||||
|
Reference in New Issue
Block a user