summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2001-01-05 10:11:41 +0000
committerDaniel Stenberg <daniel@haxx.se>2001-01-05 10:11:41 +0000
commit4031104404c6ceed5e57134125dcdb6cac51c564 (patch)
tree18bd035e58e42180cf416d0d94d4726cd44d9d7f /lib
parent9f9cac7402f9f134be6f6d5b7fb830e9946a83d8 (diff)
downloadcurl-4031104404c6ceed5e57134125dcdb6cac51c564.tar.gz
Internal symbols that aren't static are now prefixed with 'Curl_'
Diffstat (limited to 'lib')
-rw-r--r--lib/arpa_telnet.h2
-rw-r--r--lib/base64.c4
-rw-r--r--lib/base64.h3
-rw-r--r--lib/cookie.c21
-rw-r--r--lib/cookie.h10
-rw-r--r--lib/dict.c4
-rw-r--r--lib/dict.h4
-rw-r--r--lib/download.c3
-rw-r--r--lib/download.h20
-rw-r--r--lib/file.c14
-rw-r--r--lib/formdata.c52
-rw-r--r--lib/formdata.h22
-rw-r--r--lib/ftp.c134
-rw-r--r--lib/ftp.h13
-rw-r--r--lib/getenv.c1
-rw-r--r--lib/getenv.h3
-rw-r--r--lib/highlevel.c42
-rw-r--r--lib/hostip.c15
-rw-r--r--lib/hostip.h4
-rw-r--r--lib/http.c209
-rw-r--r--lib/http.h12
-rw-r--r--lib/if2ip.c2
-rw-r--r--lib/if2ip.h4
-rw-r--r--lib/krb4.c35
-rw-r--r--lib/ldap.c6
-rw-r--r--lib/ldap.h4
-rw-r--r--lib/memdebug.c2
-rw-r--r--lib/mprintf.c26
-rw-r--r--lib/netrc.c8
-rw-r--r--lib/netrc.h6
-rw-r--r--lib/progress.c38
-rw-r--r--lib/progress.h16
-rw-r--r--lib/security.c42
-rw-r--r--lib/sendf.c142
-rw-r--r--lib/sendf.h23
-rw-r--r--lib/speedcheck.c10
-rw-r--r--lib/speedcheck.h6
-rw-r--r--lib/ssluse.c14
-rw-r--r--lib/ssluse.h5
-rw-r--r--lib/strequal.c4
-rw-r--r--lib/strequal.h7
-rw-r--r--lib/telnet.c23
-rw-r--r--lib/telnet.h4
-rw-r--r--lib/timeval.c6
-rw-r--r--lib/timeval.h6
-rw-r--r--lib/url.c146
-rw-r--r--lib/url.h3
-rw-r--r--lib/version.c25
48 files changed, 633 insertions, 572 deletions
diff --git a/lib/arpa_telnet.h b/lib/arpa_telnet.h
index 25085b89a..7c1c3b02b 100644
--- a/lib/arpa_telnet.h
+++ b/lib/arpa_telnet.h
@@ -63,6 +63,7 @@
#define SYNCH 242 /* for telfunc calls */
#ifdef TELCMDS
+static
char *telcmds[] = {
"EOF", "SUSP", "ABORT", "EOR",
"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
@@ -124,6 +125,7 @@ extern char *telcmds[];
#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",
diff --git a/lib/base64.c b/lib/base64.c
index 16423e6d2..f716e52ed 100644
--- a/lib/base64.c
+++ b/lib/base64.c
@@ -55,7 +55,7 @@ static int pos(char c)
}
#if 1
-int base64_encode(const void *data, int size, char **str)
+int Curl_base64_encode(const void *data, int size, char **str)
{
char *s, *p;
int i;
@@ -93,7 +93,7 @@ int base64_encode(const void *data, int size, char **str)
}
#endif
-int base64_decode(const char *str, void *data)
+int Curl_base64_decode(const char *str, void *data)
{
const char *p;
unsigned char *q;
diff --git a/lib/base64.h b/lib/base64.h
index dbd94ca0c..c7f0dbf3a 100644
--- a/lib/base64.h
+++ b/lib/base64.h
@@ -34,6 +34,7 @@
#ifndef __BASE64_H
#define __BASE64_H
-int 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);
#endif
diff --git a/lib/cookie.c b/lib/cookie.c
index 8016a63f1..d1c308304 100644
--- a/lib/cookie.c
+++ b/lib/cookie.c
@@ -100,9 +100,10 @@ Example set of cookies:
*
***************************************************************************/
-struct Cookie *cookie_add(struct CookieInfo *c,
- bool httpheader, /* TRUE if HTTP header-style line */
- char *lineptr) /* first non-space of the line */
+struct Cookie *
+Curl_cookie_add(struct CookieInfo *c,
+ bool httpheader, /* TRUE if HTTP header-style line */
+ char *lineptr) /* first non-space of the line */
{
struct Cookie *clist;
char what[MAX_COOKIE_LINE];
@@ -347,7 +348,7 @@ struct Cookie *cookie_add(struct CookieInfo *c,
* called before any cookies are set. File may be NULL.
*
****************************************************************************/
-struct CookieInfo *cookie_init(char *file)
+struct CookieInfo *Curl_cookie_init(char *file)
{
char line[MAX_COOKIE_LINE];
struct CookieInfo *c;
@@ -375,7 +376,7 @@ struct CookieInfo *cookie_init(char *file)
while(*lineptr && isspace((int)*lineptr))
lineptr++;
- cookie_add(c, TRUE, lineptr);
+ Curl_cookie_add(c, TRUE, lineptr);
}
else {
/* This might be a netscape cookie-file line, get it! */
@@ -383,7 +384,7 @@ struct CookieInfo *cookie_init(char *file)
while(*lineptr && isspace((int)*lineptr))
lineptr++;
- cookie_add(c, FALSE, lineptr);
+ Curl_cookie_add(c, FALSE, lineptr);
}
}
if(fromfile)
@@ -405,8 +406,8 @@ struct CookieInfo *cookie_init(char *file)
*
****************************************************************************/
-struct Cookie *cookie_getlist(struct CookieInfo *c,
- char *host, char *path, bool secure)
+struct Cookie *Curl_cookie_getlist(struct CookieInfo *c,
+ char *host, char *path, bool secure)
{
struct Cookie *newco;
struct Cookie *co;
@@ -473,7 +474,7 @@ struct Cookie *cookie_getlist(struct CookieInfo *c,
*
****************************************************************************/
-void cookie_freelist(struct Cookie *co)
+void Curl_cookie_freelist(struct Cookie *co)
{
struct Cookie *next;
if(co) {
@@ -493,7 +494,7 @@ void cookie_freelist(struct Cookie *co)
* Free a "cookie object" previous created with cookie_init().
*
****************************************************************************/
-void cookie_cleanup(struct CookieInfo *c)
+void Curl_cookie_cleanup(struct CookieInfo *c)
{
struct Cookie *co;
struct Cookie *next;
diff --git a/lib/cookie.h b/lib/cookie.h
index d045e6b48..a3be519ca 100644
--- a/lib/cookie.h
+++ b/lib/cookie.h
@@ -63,10 +63,10 @@ struct CookieInfo {
#define MAX_NAME 256
#define MAX_NAME_TXT "255"
-struct Cookie *cookie_add(struct CookieInfo *, bool, char *);
-struct CookieInfo *cookie_init(char *);
-struct Cookie *cookie_getlist(struct CookieInfo *, char *, char *, bool);
-void cookie_freelist(struct Cookie *);
-void cookie_cleanup(struct CookieInfo *);
+struct Cookie *Curl_cookie_add(struct CookieInfo *, bool, char *);
+struct CookieInfo *Curl_cookie_init(char *);
+struct Cookie *Curl_cookie_getlist(struct CookieInfo *, char *, char *, bool);
+void Curl_cookie_freelist(struct Cookie *);
+void Curl_cookie_cleanup(struct CookieInfo *);
#endif
diff --git a/lib/dict.c b/lib/dict.c
index d6de23aa6..2e3dd7ab0 100644
--- a/lib/dict.c
+++ b/lib/dict.c
@@ -80,12 +80,12 @@
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
-CURLcode dict_done(struct connectdata *conn)
+CURLcode Curl_dict_done(struct connectdata *conn)
{
return CURLE_OK;
}
-CURLcode dict(struct connectdata *conn)
+CURLcode Curl_dict(struct connectdata *conn)
{
int nth;
char *word;
diff --git a/lib/dict.h b/lib/dict.h
index cb043f6c9..348403dc0 100644
--- a/lib/dict.h
+++ b/lib/dict.h
@@ -23,7 +23,7 @@
*
* $Id$
*****************************************************************************/
-CURLcode dict(struct connectdata *conn);
-CURLcode dict_done(struct connectdata *conn);
+CURLcode Curl_dict(struct connectdata *conn);
+CURLcode Curl_dict_done(struct connectdata *conn);
#endif
diff --git a/lib/download.c b/lib/download.c
index 1984125ea..1f79ec1c0 100644
--- a/lib/download.c
+++ b/lib/download.c
@@ -58,7 +58,6 @@
#endif
#include "progress.h"
-#include "speedcheck.h"
#include "sendf.h"
#include <curl/types.h>
@@ -69,7 +68,7 @@
<butlerm@xmission.com>. */
CURLcode
-Transfer(CURLconnect *c_conn,
+Curl_Transfer(CURLconnect *c_conn,
/* READ stuff */
int sockfd, /* socket to read from or -1 */
int size, /* -1 if unknown at this point */
diff --git a/lib/download.h b/lib/download.h
index 551f288b0..3c894dd24 100644
--- a/lib/download.h
+++ b/lib/download.h
@@ -23,14 +23,18 @@
* $Id$
*****************************************************************************/
CURLcode
-Transfer (struct connectdata *data,
- int sockfd, /* socket to read from or -1 */
- int size, /* -1 if unknown at this point */
- bool getheader, /* TRUE if header parsing is wanted */
- long *bytecountp, /* return number of bytes read */
- int writesockfd, /* socket to write to, it may very well be
- the same we read from. -1 disables */
- long *writebytecountp /* return number of bytes written */
+Curl_Transfer (struct connectdata *data,
+ int sockfd, /* socket to read from or -1 */
+ int size, /* -1 if unknown at this point */
+ bool getheader, /* TRUE if header parsing is wanted */
+ long *bytecountp, /* return number of bytes read */
+ int writesockfd, /* socket to write to, it may very well be
+ the same we read from. -1 disables */
+ long *writebytecountp /* return number of bytes written */
);
+/* "hackish" define to make sources compile without too much human editing.
+ Don't use "Tranfer()" anymore! */
+#define Transfer(a,b,c,d,e,f,g) Curl_Transfer(a,b,c,d,e,f,g)
+
#endif
diff --git a/lib/file.c b/lib/file.c
index 33dc09f4e..12823812a 100644
--- a/lib/file.c
+++ b/lib/file.c
@@ -106,7 +106,7 @@ CURLcode file(struct connectdata *conn)
struct UrlData *data = conn->data;
char *buf = data->buffer;
int bytecount = 0;
- struct timeval start = tvnow();
+ struct timeval start = Curl_tvnow();
struct timeval now = start;
int fd;
char *actual_path = curl_unescape(path, 0);
@@ -139,7 +139,7 @@ CURLcode file(struct connectdata *conn)
it avoids problems with select() and recv() on file descriptors
in Winsock */
if(expected_size != -1)
- pgrsSetDownloadSize(data, expected_size);
+ Curl_pgrsSetDownloadSize(data, expected_size);
while (res == CURLE_OK) {
nread = read(fd, buf, BUFSIZE-1);
@@ -155,16 +155,16 @@ CURLcode file(struct connectdata *conn)
to prevent CR/LF translation (this then goes to a binary mode
file descriptor). */
- res = client_write(data, CLIENTWRITE_BODY, buf, nread);
+ res = Curl_client_write(data, CLIENTWRITE_BODY, buf, nread);
if(res)
return res;
- now = tvnow();
- if(pgrsUpdate(data))
+ now = Curl_tvnow();
+ if(Curl_pgrsUpdate(data))
res = CURLE_ABORTED_BY_CALLBACK;
}
- now = tvnow();
- if(pgrsUpdate(data))
+ now = Curl_tvnow();
+ if(Curl_pgrsUpdate(data))
res = CURLE_ABORTED_BY_CALLBACK;
close(fd);
diff --git a/lib/formdata.c b/lib/formdata.c
index 8f86b980c..14d911d35 100644
--- a/lib/formdata.c
+++ b/lib/formdata.c
@@ -91,16 +91,10 @@ static void GetStr(char **string,
*
***************************************************************************/
-int curl_formparse(char *input,
- struct HttpPost **httppost,
- struct HttpPost **last_post)
-{
- return FormParse(input, httppost, last_post);
-}
-
#define FORM_FILE_SEPARATOR ','
#define FORM_TYPE_SEPARATOR ';'
+static
int FormParse(char *input,
struct HttpPost **httppost,
struct HttpPost **last_post)
@@ -298,6 +292,13 @@ int FormParse(char *input,
return 0;
}
+int curl_formparse(char *input,
+ struct HttpPost **httppost,
+ struct HttpPost **last_post)
+{
+ return FormParse(input, httppost, last_post);
+}
+
static int AddFormData(struct FormData **formp,
void *line,
long length)
@@ -339,7 +340,7 @@ static int AddFormDataf(struct FormData **formp,
}
-char *MakeFormBoundary(void)
+char *Curl_FormBoundary(void)
{
char *retstring;
static int randomizer=0; /* this is just so that two boundaries within
@@ -367,7 +368,7 @@ char *MakeFormBoundary(void)
}
/* Used from http.c */
-void FormFree(struct FormData *form)
+void Curl_FormFree(struct FormData *form)
{
struct FormData *next;
do {
@@ -400,8 +401,8 @@ void curl_formfree(struct HttpPost *form)
} while((form=next)); /* continue */
}
-struct FormData *getFormData(struct HttpPost *post,
- int *sizep)
+struct FormData *Curl_getFormData(struct HttpPost *post,
+ int *sizep)
{
struct FormData *form = NULL;
struct FormData *firstform;
@@ -415,7 +416,7 @@ struct FormData *getFormData(struct HttpPost *post,
if(!post)
return NULL; /* no input => no output! */
- boundary = MakeFormBoundary();
+ boundary = Curl_FormBoundary();
/* Make the first line of the output */
AddFormDataf(&form,
@@ -439,7 +440,7 @@ struct FormData *getFormData(struct HttpPost *post,
/* If used, this is a link to more file names, we must then do
the magic to include several files with the same field name */
- fileboundary = MakeFormBoundary();
+ fileboundary = Curl_FormBoundary();
size += AddFormDataf(&form,
"\r\nContent-Type: multipart/mixed,"
@@ -535,24 +536,11 @@ struct FormData *getFormData(struct HttpPost *post,
return firstform;
}
-int FormInit(struct Form *form, struct FormData *formdata )
+int Curl_FormInit(struct Form *form, struct FormData *formdata )
{
if(!formdata)
return 1; /* error */
-#if 0
- struct FormData *lastnode=formdata;
-
- /* find the last node in the list */
- while(lastnode->next) {
- lastnode = lastnode->next;
- }
-
- /* Now, make sure that we'll send a nice terminating sequence at the end
- * of the post. We *DONT* add this string to the size of the data since this
- * is actually AFTER the data. */
- AddFormDataf(&lastnode, "\r\n\r\n");
-#endif
form->data = formdata;
form->sent = 0;
@@ -560,10 +548,10 @@ int FormInit(struct Form *form, struct FormData *formdata )
}
/* fread() emulation */
-int FormReader(char *buffer,
- size_t size,
- size_t nitems,
- FILE *mydata)
+int Curl_FormReader(char *buffer,
+ size_t size,
+ size_t nitems,
+ FILE *mydata)
{
struct Form *form;
int wantedsize;
@@ -638,7 +626,7 @@ int main(int argc, char **argv)
}
}
- form=getFormData(httppost, &size);
+ form=Curl_getFormData(httppost, &size);
FormInit(&formread, form);
diff --git a/lib/formdata.h b/lib/formdata.h
index dd5e0a4ad..4a0d8509d 100644
--- a/lib/formdata.h
+++ b/lib/formdata.h
@@ -36,23 +36,19 @@ struct Form {
been sent in a previous invoke */
};
-int FormParse(char *string,
- struct HttpPost **httppost,
- struct HttpPost **last_post);
+int Curl_FormInit(struct Form *form, struct FormData *formdata );
-int FormInit(struct Form *form, struct FormData *formdata );
-
-struct FormData *getFormData(struct HttpPost *post,
- int *size);
+struct FormData *Curl_getFormData(struct HttpPost *post,
+ int *size);
/* fread() emulation */
-int FormReader(char *buffer,
- size_t size,
- size_t nitems,
- FILE *mydata);
+int Curl_FormReader(char *buffer,
+ size_t size,
+ size_t nitems,
+ FILE *mydata);
-char *MakeFormBoundary(void);
+char *Curl_FormBoundary(void);
-void FormFree(struct FormData *);
+void Curl_FormFree(struct FormData *);
#endif
diff --git a/lib/ftp.c b/lib/ftp.c
index a7c1cf179..a52ba190f 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -69,15 +69,21 @@
#include "download.h"
#include "escape.h"
#include "http.h" /* for HTTP proxy tunnel stuff */
+#include "ftp.h"
#ifdef KRB4
#include "security.h"
+#include "krb4.h"
#endif
+
/* The last #include file should be: */
#ifdef MALLOCDEBUG
#include "memdebug.h"
#endif
+/* easy-to-use macro: */
+#define ftpsendf Curl_ftpsendf
+
/* returns last node in linked list */
static struct curl_slist *slist_get_last(struct curl_slist *list)
{
@@ -202,9 +208,13 @@ static CURLcode AllowServerConnect(struct UrlData *data,
#define lastline(line) (isdigit((int)line[0]) && isdigit((int)line[1]) && \
isdigit((int)line[2]) && (' ' == line[3]))
-int GetLastResponse(int sockfd, char *buf,
- struct connectdata *conn,
- int *ftpcode)
+/*
+ * We allow the ftpcode pointer to be NULL if no reply integer is wanted
+ */
+
+int Curl_GetFTPResponse(int sockfd, char *buf,
+ struct connectdata *conn,
+ int *ftpcode)
{
int nread;
int keepon=TRUE;
@@ -220,12 +230,13 @@ int GetLastResponse(int sockfd, char *buf,
#define SELECT_TIMEOUT 2
int error = SELECT_OK;
- *ftpcode=0; /* 0 for errors */
+ if(ftpcode)
+ *ftpcode=0; /* 0 for errors */
if(data->timeout) {
/* if timeout is requested, find out how much remaining time we have */
timeout = data->timeout - /* timeout time */
- (tvlong(tvnow()) - tvlong(conn->now)); /* spent time */
+ (Curl_tvlong(Curl_tvnow()) - Curl_tvlong(conn->now)); /* spent time */
if(timeout <=0 ) {
failf(data, "Transfer aborted due to timeout");
return -SELECT_TIMEOUT; /* already too little time */
@@ -306,13 +317,14 @@ int GetLastResponse(int sockfd, char *buf,
if(error)
return -error;
- *ftpcode=atoi(buf); /* return the initial number like this */
+ if(ftpcode)
+ *ftpcode=atoi(buf); /* return the initial number like this */
return nread;
}
/* -- who are we? -- */
-char *getmyhost(char *buf, int buf_size)
+char *Curl_getmyhost(char *buf, int buf_size)
{
#if defined(HAVE_GETHOSTNAME)
gethostname(buf, buf_size);
@@ -330,7 +342,7 @@ char *getmyhost(char *buf, int buf_size)
/* ftp_connect() should do everything that is to be considered a part
of the connection phase. */
-CURLcode ftp_connect(struct connectdata *conn)
+CURLcode Curl_ftp_connect(struct connectdata *conn)
{
/* this is FTP and no proxy */
int nread;
@@ -356,14 +368,14 @@ CURLcode ftp_connect(struct connectdata *conn)
if (data->bits.tunnel_thru_httpproxy) {
/* We want "seamless" FTP operations through HTTP proxy tunnel */
- result = GetHTTPProxyTunnel(data, data->firstsocket,
- data->hostname, data->remote_port);
+ result = Curl_ConnectHTTPProxyTunnel(data, data->firstsocket,
+ data->hostname, data->remote_port);
if(CURLE_OK != result)
return result;
}
/* The first thing we do is wait for the "220*" line: */
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -396,7 +408,7 @@ CURLcode ftp_connect(struct connectdata *conn)
ftpsendf(data->firstsocket, conn, "USER %s", ftp->user);
/* wait for feedback */
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -410,7 +422,7 @@ CURLcode ftp_connect(struct connectdata *conn)
/* 331 Password required for ...
(the server requires to send the user's password too) */
ftpsendf(data->firstsocket, conn, "PASS %s", ftp->passwd);
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -459,7 +471,7 @@ CURLcode ftp_connect(struct connectdata *conn)
/* argument is already checked for validity */
-CURLcode ftp_done(struct connectdata *conn)
+CURLcode Curl_ftp_done(struct connectdata *conn)
{
struct UrlData *data = conn->data;
struct FTP *ftp = data->proto.ftp;
@@ -496,7 +508,7 @@ CURLcode ftp_done(struct connectdata *conn)
if(!data->bits.no_body) {
/* now let's see what the server says about the transfer we
just performed: */
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -516,7 +528,7 @@ CURLcode ftp_done(struct connectdata *conn)
if (qitem->data) {
ftpsendf(data->firstsocket, conn, "%s", qitem->data);
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -570,7 +582,7 @@ CURLcode _ftp(struct connectdata *conn)
if (qitem->data) {
ftpsendf(data->firstsocket, conn, "%s", qitem->data);
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -587,7 +599,7 @@ CURLcode _ftp(struct connectdata *conn)
/* change directory first! */
if(ftp->dir && ftp->dir[0]) {
ftpsendf(data->firstsocket, conn, "CWD %s", ftp->dir);
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -602,7 +614,7 @@ CURLcode _ftp(struct connectdata *conn)
again a grey area as the MDTM is not kosher RFC959 */
ftpsendf(data->firstsocket, conn, "MDTM %s", ftp->file);
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -639,7 +651,7 @@ CURLcode _ftp(struct connectdata *conn)
ftpsendf(data->firstsocket, conn, "TYPE %s",
(data->bits.ftp_ascii)?"A":"I");
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -652,7 +664,7 @@ CURLcode _ftp(struct connectdata *conn)
ftpsendf(data->firstsocket, conn, "SIZE %s", ftp->file);
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -664,7 +676,7 @@ CURLcode _ftp(struct connectdata *conn)
filesize = atoi(buf+4);
sprintf(buf, "Content-Length: %d\r\n", filesize);
- result = client_write(data, CLIENTWRITE_BOTH, buf, 0);
+ result = Curl_client_write(data, CLIENTWRITE_BOTH, buf, 0);
if(result)
return result;
@@ -680,7 +692,7 @@ CURLcode _ftp(struct connectdata *conn)
/* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
strftime(buf, BUFSIZE-1, "Last-Modified: %a, %d %b %Y %H:%M:%S %Z\r\n",
tm);
- result = client_write(data, CLIENTWRITE_BOTH, buf, 0);
+ result = Curl_client_write(data, CLIENTWRITE_BOTH, buf, 0);
if(result)
return result;
}
@@ -699,18 +711,20 @@ CURLcode _ftp(struct connectdata *conn)
char myhost[256] = "";
if(data->ftpport) {
- if(if2ip(data->ftpport, myhost, sizeof(myhost))) {
- h = GetHost(data, myhost, &hostdataptr);
+ if(Curl_if2ip(data->ftpport, myhost, sizeof(myhost))) {
+ h = Curl_gethost(data, myhost, &hostdataptr);
}
else {
if(strlen(data->ftpport)>1)
- h = GetHost(data, data->ftpport, &hostdataptr);
+ h = Curl_gethost(data, data->ftpport, &hostdataptr);
if(h)
strcpy(myhost, data->ftpport); /* buffer overflow risk */
}
}
if(! *myhost) {
- h=GetHost(data, getmyhost(myhost, sizeof(myhost)), &hostdataptr);
+ h=Curl_gethost(data,
+ Curl_getmyhost(myhost, sizeof(myhost)),
+ &hostdataptr);
}
infof(data, "We connect from %s\n", myhost);
@@ -788,7 +802,7 @@ CURLcode _ftp(struct connectdata *conn)
porttouse & 255);
}
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -801,7 +815,7 @@ CURLcode _ftp(struct connectdata *conn)
ftpsendf(data->firstsocket, conn, "PASV");
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -856,7 +870,7 @@ CURLcode _ftp(struct connectdata *conn)
}
else {
/* normal, direct, ftp connection */
- he = GetHost(data, newhost, &hostdataptr);
+ he = Curl_gethost(data, newhost, &hostdataptr);
if(!he) {
failf(data, "Can't resolve new host %s", newhost);
return CURLE_FTP_CANT_GET_HOST;
@@ -961,8 +975,8 @@ CURLcode _ftp(struct connectdata *conn)
if (data->bits.tunnel_thru_httpproxy) {
/* We want "seamless" FTP operations through HTTP proxy tunnel */
- result = GetHTTPProxyTunnel(data, data->secondarysocket,
- newhost, newport);
+ result = Curl_ConnectHTTPProxyTunnel(data, data->secondarysocket,
+ newhost, newport);
if(CURLE_OK != result)
return result;
}
@@ -977,7 +991,7 @@ CURLcode _ftp(struct connectdata *conn)
ftpsendf(data->firstsocket, conn, "TYPE %s",
(data->bits.ftp_ascii)?"A":"I");
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -1008,7 +1022,7 @@ CURLcode _ftp(struct connectdata *conn)
ftpsendf(data->firstsocket, conn, "SIZE %s", ftp->file);
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -1069,7 +1083,7 @@ CURLcode _ftp(struct connectdata *conn)
else
ftpsendf(data->firstsocket, conn, "STOR %s", ftp->file);
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -1090,7 +1104,7 @@ CURLcode _ftp(struct connectdata *conn)
/* When we know we're uploading a specified file, we can get the file
size prior to the actual upload. */
- pgrsSetUploadSize(data, data->infilesize);
+ Curl_pgrsSetUploadSize(data, data->infilesize);
result = Transfer(conn, -1, -1, FALSE, NULL, /* no download */
data->secondarysocket, bytecountp);
@@ -1149,7 +1163,7 @@ CURLcode _ftp(struct connectdata *conn)
/* Set type to ASCII */
ftpsendf(data->firstsocket, conn, "TYPE A");
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -1171,7 +1185,7 @@ CURLcode _ftp(struct connectdata *conn)
ftpsendf(data->firstsocket, conn, "TYPE %s",
(data->bits.ftp_ascii)?"A":"I");
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -1192,7 +1206,7 @@ CURLcode _ftp(struct connectdata *conn)
ftpsendf(data->firstsocket, conn, "SIZE %s", ftp->file);
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -1236,7 +1250,7 @@ CURLcode _ftp(struct connectdata *conn)
ftpsendf(data->firstsocket, conn, "REST %d", data->resume_from);
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -1249,7 +1263,7 @@ CURLcode _ftp(struct connectdata *conn)
ftpsendf(data->firstsocket, conn, "RETR %s", ftp->file);
}
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@@ -1341,7 +1355,7 @@ CURLcode _ftp(struct connectdata *conn)
/* -- deal with the ftp server! -- */
/* argument is already checked for validity */
-CURLcode ftp(struct connectdata *conn)
+CURLcode Curl_ftp(struct connectdata *conn)
{
CURLcode retcode;
@@ -1403,3 +1417,39 @@ CURLcode ftp(struct connectdata *conn)
return retcode;
}
+/*
+ * ftpsendf() sends the formated string as a ftp command to a ftp server
+ *
+ * NOTE: we build the command in a fixed-length buffer, which sets length
+ * restrictions on the command!
+ *
+ */
+size_t Curl_ftpsendf(int fd, struct connectdata *conn, char *fmt, ...)
+{
+ size_t bytes_written;
+ char s[256];
+
+ va_list ap;
+ va_start(ap, fmt);
+ vsnprintf(s, 250, fmt, ap);
+ va_end(ap);
+
+ if(conn->data->bits.verbose)
+ fprintf(conn->data->err, "> %s\n", s);
+
+ strcat(s, "\r\n"); /* append a trailing CRLF */
+
+#ifdef KRB4
+ if(conn->sec_complete && conn->data->cmdchannel) {
+ bytes_written = sec_fprintf(conn, conn->data->cmdchannel, s);
+ fflush(conn->data->cmdchannel);
+ }
+ else
+#endif /* KRB4 */
+ {
+ bytes_written = swrite(fd, s, strlen(s));
+ }
+ return(bytes_written);
+}
+
+
diff --git a/lib/ftp.h b/lib/ftp.h
index 433e778c8..3471ec87b 100644
--- a/lib/ftp.h
+++ b/lib/ftp.h
@@ -23,11 +23,18 @@
*
* $Id$
*****************************************************************************/
-CURLcode ftp(struct connectdata *conn);
-CURLcode ftp_done(struct connectdata *conn);
-CURLcode ftp_connect(struct connectdata *conn);
+CURLcode Curl_ftp(struct connectdata *conn);
+CURLcode Curl_ftp_done(struct connectdata *conn);
+CURLcode Curl_ftp_connect(struct connectdata *conn);
+
+size_t Curl_ftpsendf(int fd, struct connectdata *, char *fmt, ...);
struct curl_slist *curl_slist_append(struct curl_slist *list, char *data);
void curl_slist_free_all(struct curl_slist *list);
+/* The kerberos stuff needs this: */
+int Curl_GetFTPResponse(int sockfd, char *buf,
+ struct connectdata *conn,
+ int *ftpcode);
+
#endif
diff --git a/lib/getenv.c b/lib/getenv.c
index 80c68f68a..0c23e76aa 100644
--- a/lib/getenv.c
+++ b/lib/getenv.c
@@ -33,6 +33,7 @@
#include "memdebug.h"
#endif
+static
char *GetEnv(char *variable)
{
#ifdef WIN32
diff --git a/lib/getenv.h b/lib/getenv.h
index 7373c1c9b..2922b6e92 100644
--- a/lib/getenv.h
+++ b/lib/getenv.h
@@ -23,7 +23,6 @@
* $Id$
*****************************************************************************/
-/* Unix and Win32 getenv function call */
-char *GetEnv(char *variable);
+#include <curl/curl.h>
#endif
diff --git a/lib/highlevel.c b/lib/highlevel.c
index 94eb5be9b..6a89e3bff 100644
--- a/lib/highlevel.c
+++ b/lib/highlevel.c
@@ -103,14 +103,14 @@
#define min(a, b) ((a) < (b) ? (a) : (b))
#endif
-CURLcode
+CURLcode static
_Transfer(struct connectdata *c_conn)
{
size_t nread; /* number of bytes read */
int bytecount = 0; /* total number of bytes read */
int writebytecount = 0; /* number of bytes written */
long contentlength=0; /* size of incoming data */
- struct timeval start = tvnow();
+ struct timeval start = Curl_tvnow();
struct timeval now = start; /* current time */
bool header = TRUE; /* incoming data has HTTP header */
int headerline = 0; /* counts header lines to better track the
@@ -151,19 +151,19 @@ _Transfer(struct connectdata *c_conn)
myalarm (0); /* switch off the alarm-style timeout */
- now = tvnow();
+ now = Curl_tvnow();
start = now;
#define KEEP_READ 1
#define KEEP_WRITE 2
- pgrsTime(data, TIMER_PRETRANSFER);
- speedinit(data);
+ Curl_pgrsTime(data, TIMER_PRETRANSFER);
+ Curl_speedinit(data);
if (!conn->getheader) {
header = FALSE;
if(conn->size > 0)
- pgrsSetDownloadSize(data, conn->size);
+ Curl_pgrsSetDownloadSize(data, conn->size);
}
/* we want header and/or body, if neither then don't do this! */
if(conn->getheader ||
@@ -314,7 +314,7 @@ _Transfer(struct connectdata *c_conn)
if ('\n' == *p)
p++; /* pass the \n byte */
- pgrsSetDownloadSize(data, conn->size);
+ Curl_pgrsSetDownloadSize(data, conn->size);
header = FALSE; /* no more header to parse! */
@@ -324,8 +324,8 @@ _Transfer(struct connectdata *c_conn)
if (data->bits.http_include_header)
writetype |= CLIENTWRITE_BODY;
- urg = client_write(data, writetype, data->headerbuff,
- p - data->headerbuff);
+ urg = Curl_client_write(data, writetype, data->headerbuff,
+ p - data->headerbuff);
if(urg)
return urg;
@@ -374,7 +374,7 @@ _Transfer(struct connectdata *c_conn)
}
else if(data->cookies &&
strnequal("Set-Cookie: ", p, 11)) {
- cookie_add(data->cookies, TRUE, &p[12]);
+ Curl_cookie_add(data->cookies, TRUE, &p[12]);
}
else if(strnequal("Last-Modified:", p,
strlen("Last-Modified:")) &&
@@ -398,7 +398,7 @@ _Transfer(struct connectdata *c_conn)
if (data->bits.http_include_header)
writetype |= CLIENTWRITE_BODY;
- urg = client_write(data, writetype, p, hbuflen);
+ urg = Curl_client_write(data, writetype, p, hbuflen);
if(urg)
return urg;
@@ -484,9 +484,9 @@ _Transfer(struct connectdata *c_conn)
bytecount += nread;
- pgrsSetDownloadCounter(data, (double)bytecount);
+ Curl_pgrsSetDownloadCounter(data, (double)bytecount);
- urg = client_write(data, CLIENTWRITE_BODY, str, nread);
+ urg = Curl_client_write(data, CLIENTWRITE_BODY, str, nread);
if(urg)
return urg;
@@ -513,7 +513,7 @@ _Transfer(struct connectdata *c_conn)
break;
}
writebytecount += nread;
- pgrsSetUploadCounter(data, (double)writebytecount);
+ Curl_pgrsSetUploadCounter(data, (double)writebytecount);
/* convert LF to CRLF if so asked */
if (data->crlf) {
@@ -543,11 +543,11 @@ _Transfer(struct connectdata *c_conn)
break;
}
- now = tvnow();
- if(pgrsUpdate(data))
+ now = Curl_tvnow();
+ if(Curl_pgrsUpdate(data))
urg = CURLE_ABORTED_BY_CALLBACK;
else
- urg = speedcheck (data, now);
+ urg = Curl_speedcheck (data, now);
if (urg)
return urg;
@@ -560,7 +560,7 @@ _Transfer(struct connectdata *c_conn)
conn->upload_bufsize=(long)min(data->progress.ulspeed, BUFSIZE);
}
- if (data->timeout && (tvdiff (now, start) > data->timeout)) {
+ if (data->timeout && (Curl_tvdiff (now, start) > data->timeout)) {
failf (data, "Operation timed out with %d out of %d bytes received",
bytecount, conn->size);
return CURLE_OPERATION_TIMEOUTED;
@@ -573,7 +573,7 @@ _Transfer(struct connectdata *c_conn)
contentlength-bytecount);
return CURLE_PARTIAL_FILE;
}
- if(pgrsUpdate(data))
+ if(Curl_pgrsUpdate(data))
return CURLE_ABORTED_BY_CALLBACK;
if(conn->bytecountp)
@@ -592,10 +592,10 @@ CURLcode curl_transfer(CURL *curl)
struct UrlData *data = curl;
struct connectdata *c_connect=NULL;
- pgrsStartNow(data);
+ Curl_pgrsStartNow(data);
do {
- pgrsTime(data, TIMER_STARTSINGLE);
+ Curl_pgrsTime(data, TIMER_STARTSINGLE);
res = curl_connect(curl, (CURLconnect **)&c_connect);
if(res == CURLE_OK) {
res = curl_do(c_connect);
diff --git a/lib/hostip.c b/lib/hostip.c
index f5f492dcf..cb7bc19a5 100644
--- a/lib/hostip.c
+++ b/lib/hostip.c
@@ -62,7 +62,7 @@
/* --- resolve name or IP-number --- */
-char *MakeIP(unsigned long num,char *addr, int addr_len)
+static char *MakeIP(unsigned long num,char *addr, int addr_len)
{
#if defined(HAVE_INET_NTOA) || defined(HAVE_INET_NTOA_R)
struct in_addr in;
@@ -83,14 +83,17 @@ char *MakeIP(unsigned long num,char *addr, int addr_len)
return (addr);
}
-/* The original code to this function was stolen from the Dancer source code,
- written by Bjorn Reese, it has since been patched and modified. */
+/* The original code to this function was once stolen from the Dancer source
+ code, written by Bjorn Reese, it has since been patched and modified
+ considerably. */
+
#ifndef INADDR_NONE
#define INADDR_NONE (unsigned long) ~0
#endif
-struct hostent *GetHost(struct UrlData *data,
- char *hostname,
- char **bufp)
+
+struct hostent *Curl_gethost(struct UrlData *data,
+ char *hostname,
+ char **bufp)
{
struct hostent *h = NULL;
unsigned long in;
diff --git a/lib/hostip.h b/lib/hostip.h
index 60107d96a..78453487b 100644
--- a/lib/hostip.h
+++ b/lib/hostip.h
@@ -23,6 +23,8 @@
* $Id$
*****************************************************************************/
-struct hostent *GetHost(struct UrlData *data, char *hostname, char **bufp );
+struct hostent *Curl_gethost(struct UrlData *data,
+ char *hostname,
+ char **bufp);
#endif
diff --git a/lib/http.c b/lib/http.c
index b97213d8f..555845abb 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -106,6 +106,150 @@
#endif
/*
+ * The add_buffer series of functions are used to build one large memory chunk
+ * from repeated function invokes. Used so that the entire HTTP request can
+ * be sent in one go.
+ */
+static CURLcode
+ add_buffer(send_buffer *in, void *inptr, size_t size);
+
+/*
+ * add_buffer_init() returns a fine buffer struct
+ */
+static
+send_buffer *add_buffer_init(void)
+{
+ send_buffer *blonk;
+ blonk=(send_buffer *)malloc(sizeof(send_buffer));
+ if(blonk) {
+ memset(blonk, 0, sizeof(send_buffer));
+ return blonk;
+ }
+ return NULL; /* failed, go home */
+}
+
+/*
+ * add_buffer_send() sends a buffer and frees all associated memory.
+ */
+static
+size_t add_buffer_send(int sockfd, struct connectdata *conn, send_buffer *in)
+{
+ size_t amount;
+ if(conn->data->bits.verbose) {
+ fputs("> ", conn->data->err);
+ /* this data _may_ contain binary stuff */
+ fwrite(in->buffer, in->size_used, 1, conn->data->err);
+ }
+
+ amount = ssend(sockfd, conn, in->buffer, in->size_used);
+
+ if(in->buffer)
+ free(in->buffer);
+ free(in);
+
+ return amount;
+}
+
+
+/*
+ * add_bufferf() builds a buffer from the formatted input
+ */
+static
+CURLcode add_bufferf(send_buffer *in, char *fmt, ...)
+{
+ CURLcode result = CURLE_OUT_OF_MEMORY;
+ char *s;
+ va_list ap;
+ va_start(ap, fmt);
+ s = Curl_mvaprintf(fmt, ap); /* this allocs a new string to append */
+ va_end(ap);
+
+ if(s) {
+ result = add_buffer(in, s, strlen(s));
+ free(s);
+ }
+ return result;
+}
+
+/*
+ * add_buffer() appends a memory chunk to the existing one
+ */
+static
+CURLcode add_buffer(send_buffer *in, void *inptr, size_t size)
+{
+ char *new_rb;
+ int new_size;
+
+ if(size > 0) {
+ if(!in->buffer ||
+ ((in->size_used + size) > (in->size_max - 1))) {
+ new_size = (in->size_used+size)*2;
+ if(in->buffer)
+ /* we have a buffer, enlarge the existing one */
+ new_rb = (char *)realloc(in->buffer, new_size);
+ else
+ /* create a new buffer */
+ new_rb = (char *)malloc(new_size);
+
+ if(!new_rb)
+ return CURLE_OUT_OF_MEMORY;
+
+ in->buffer = new_rb;
+ in->size_max = new_size;
+ }
+ memcpy(&in->buffer[in->size_used], inptr, size);
+
+ in->size_used += size;
+ }
+
+ return CURLE_OK;
+}
+
+/* end of the add_buffer functions */
+/*****************************************************************************/
+
+/*
+ * Read everything until a newline.
+ */
+
+static
+int GetLine(int sockfd, char *buf, struct UrlData *data)
+{
+ int nread;
+ int read_rc=1;
+ char *ptr;
+ ptr=buf;
+
+ /* get us a full line, terminated with a newline */
+ for(nread=0;
+ (nread<BUFSIZE) && read_rc;
+ nread++, ptr++) {
+#ifdef USE_SSLEAY
+ if (data->ssl.use) {
+ read_rc = SSL_read(data->ssl.handle, ptr, 1);
+ }
+ else {
+#endif
+ read_rc = sread(sockfd, ptr, 1);
+#ifdef USE_SSLEAY
+ }
+#endif /* USE_SSLEAY */
+ if (*ptr == '\n')
+ break;
+ }
+ *ptr=0; /* zero terminate */
+
+ if(data->bits.verbose) {
+ fputs("< ", data->err);
+ fwrite(buf, 1, nread, data->err);
+ fputs("\n", data->err);
+ }
+ return nread;
+}
+
+
+
+/*
* This function checks the linked list of custom HTTP headers for a particular
* header (prefix).
*/
@@ -123,13 +267,13 @@ bool static checkheaders(struct UrlData *data, char *thisheader)
}
/*
- * GetHTTPProxyTunnel() requires that we're connected to a HTTP proxy. This
+ * ConnectHTTPProxyTunnel() requires that we're connected to a HTTP proxy. This
* function will issue the necessary commands to get a seamless tunnel through
* this proxy. After that, the socket can be used just as a normal socket.
*/
-CURLcode GetHTTPProxyTunnel(struct UrlData *data, int tunnelsocket,
- char *hostname, int remote_port)
+CURLcode Curl_ConnectHTTPProxyTunnel(struct UrlData *data, int tunnelsocket,
+ char *hostname, int remote_port)
{
int httperror=0;
int subversion=0;
@@ -170,7 +314,7 @@ CURLcode GetHTTPProxyTunnel(struct UrlData *data, int tunnelsocket,
return CURLE_OK;
}
-CURLcode http_connect(struct connectdata *conn)
+CURLcode Curl_http_connect(struct connectdata *conn)
{
struct UrlData *data;
CURLcode result;
@@ -186,16 +330,15 @@ CURLcode http_connect(struct connectdata *conn)
if (conn->protocol & PROT_HTTPS) {
if (data->bits.httpproxy) {
/* HTTPS through a proxy can only be done with a tunnel */
- result = GetHTTPProxyTunnel(data, data->firstsocket,
- data->hostname, data->remote_port);
+ result = Curl_ConnectHTTPProxyTunnel(data, data->firstsocket,
+ data->hostname, data->remote_port);
if(CURLE_OK != result)
return result;
}
/* now, perform the SSL initialization for this socket */
- if(UrgSSLConnect (data)) {
+ if(Curl_SSLConnect(data))
return CURLE_SSL_CONNECT_ERROR;
- }
}
if(data->bits.user_passwd && !data->bits.this_is_a_follow) {
@@ -209,14 +352,14 @@ CURLcode http_connect(struct connectdata *conn)
/* called from curl_close() when this struct is about to get wasted, free
protocol-specific resources */
-CURLcode http_close(struct connectdata *conn)
+CURLcode Curl_http_close(struct connectdata *conn)
{
if(conn->data->auth_host)
free(conn->data->auth_host);
return CURLE_OK;
}
-CURLcode http_done(struct connectdata *conn)
+CURLcode Curl_http_done(struct connectdata *conn)
{
struct UrlData *data;
long *bytecount = &conn->bytecount;
@@ -228,7 +371,7 @@ CURLcode http_done(struct connectdata *conn)
if(data->bits.http_formpost) {
*bytecount = http->readbytecount + http->writebytecount;
- FormFree(http->sendit); /* Now free that whole lot */
+ Curl_FormFree(http->sendit); /* Now free that whole lot */
data->fread = http->storefread; /* restore */
data->in = http->in; /* restore */
@@ -244,7 +387,7 @@ CURLcode http_done(struct connectdata *conn)
}
-CURLcode http(struct connectdata *conn)
+CURLcode Curl_http(struct connectdata *conn)
{
struct UrlData *data=conn->data;
char *buf = data->buffer; /* this is a short cut to the buffer */
@@ -284,29 +427,29 @@ CURLcode http(struct connectdata *conn)
!data->auth_host ||
strequal(data->auth_host, data->hostname)) {
sprintf(data->buffer, "%s:%s", data->user, data->passwd);
- if(base64_encode(data->buffer, strlen(data->buffer),
- &authorization) >= 0) {
- data->ptr_userpwd = maprintf( "Authorization: Basic %s\015\012",
- authorization);
+ if(Curl_base64_encode(data->buffer, strlen(data->buffer),
+ &authorization) >= 0) {
+ data->ptr_userpwd = aprintf( "Authorization: Basic %s\015\012",
+ authorization);
free(authorization);
}
}
}
if((data->bits.set_range) && !checkheaders(data, "Range:")) {
- data->ptr_rangeline = maprintf("Range: bytes=%s\015\012", data->range);
+ data->ptr_rangeline = aprintf("Range: bytes=%s\015\012", data->range);
}
if((data->bits.http_set_referer) && !checkheaders(data, "Referer:")) {
- data->ptr_ref = maprintf("Referer: %s\015\012", data->referer);
+ data->ptr_ref = aprintf("Referer: %s\015\012", data->referer);
}
if(data->cookie && !checkheaders(data, "Cookie:")) {
- data->ptr_cookie = maprintf("Cookie: %s\015\012", data->cookie);
+ data->ptr_cookie = aprintf("Cookie: %s\015\012", data->cookie);
}
if(data->cookies) {
- co = cookie_getlist(data->cookies,
- host,
- ppath,
- conn->protocol&PROT_HTTPS?TRUE:FALSE);
+ co = Curl_cookie_getlist(data->cookies,
+ host,
+ ppath,
+ conn->protocol&PROT_HTTPS?TRUE:FALSE);
}
if ((data->bits.httpproxy) && !(conn->protocol&PROT_HTTPS)) {
/* The path sent to the proxy is in fact the entire URL */
@@ -315,7 +458,7 @@ CURLcode http(struct connectdata *conn)
if(data->bits.http_formpost) {
/* 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 */
- http->sendit = getFormData(data->httppost, &http->postsize);
+ http->sendit = Curl_getFormData(data->httppost, &http->postsize);
}
if(!checkheaders(data, "Host:")) {
@@ -323,9 +466,9 @@ CURLcode http(struct connectdata *conn)
(!(conn->protocol&PROT_HTTPS) && (data->remote_port == PORT_HTTP)) )
/* If (HTTPS on port 443) OR (non-HTTPS on port 80) then don't include
the port number in the host string */
- data->ptr_host = maprintf("Host: %s\r\n", host);
+ data->ptr_host = aprintf("Host: %s\r\n", host);
else
- data->ptr_host = maprintf("Host: %s:%d\r\n", host, data->remote_port);
+ data->ptr_host = aprintf("Host: %s:%d\r\n", host, data->remote_port);
}
if(!checkheaders(data, "Pragma:"))
@@ -389,7 +532,7 @@ CURLcode http(struct connectdata *conn)
if(count) {
add_buffer(req_buffer, "\r\n", 2);
}
- cookie_freelist(store); /* free the cookie list */
+ Curl_cookie_freelist(store); /* free the cookie list */
co=NULL;
}
@@ -451,7 +594,7 @@ CURLcode http(struct connectdata *conn)
}
if(data->bits.http_formpost) {
- if(FormInit(&http->form, http->sendit)) {
+ if(Curl_FormInit(&http->form, http->sendit)) {
failf(data, "Internal HTTP POST error!\n");
return CURLE_HTTP_POST_ERROR;
}
@@ -461,15 +604,15 @@ CURLcode http(struct connectdata *conn)
data->fread =
(size_t (*)(char *, size_t, size_t, FILE *))
- FormReader; /* set the read function to read from the
- generated form data */
+ Curl_FormReader; /* set the read function to read from the
+ generated form data */
data->in = (FILE *)&http->form;
add_bufferf(req_buffer,
"Content-Length: %d\r\n", http->postsize-2);
/* set upload size to the progress meter */
- pgrsSetUploadSize(data, http->postsize);
+ Curl_pgrsSetUploadSize(data, http->postsize);
data->request_size =
add_buffer_send(data->firstsocket, conn, req_buffer);
@@ -478,7 +621,7 @@ CURLcode http(struct connectdata *conn)
data->firstsocket,
&http->writebytecount);
if(result) {
- FormFree(http->sendit); /* free that whole lot */
+ Curl_FormFree(http->sendit); /* free that whole lot */
return result;
}
}
@@ -494,7 +637,7 @@ CURLcode http(struct connectdata *conn)
add_bufferf(req_buffer, "\015\012");
/* set the upload size to the progress meter */
- pgrsSetUploadSize(data, data->infilesize);
+ Curl_pgrsSetUploadSize(data, data->infilesize);
/* this sends the buffer and frees all the buffer resources */
data->request_size =
diff --git a/lib/http.h b/lib/http.h
index 65d9458bf..48adc5231 100644
--- a/lib/http.h
+++ b/lib/http.h
@@ -25,13 +25,13 @@
*****************************************************************************/
/* ftp can use this as well */
-CURLcode GetHTTPProxyTunnel(struct UrlData *data, int tunnelsocket,
- char *hostname, int remote_port);
+CURLcode Curl_ConnectHTTPProxyTunnel(struct UrlData *data, int tunnelsocket,
+ char *hostname, int remote_port);
/* protocol-specific functions set up to be called by the main engine */
-CURLcode http(struct connectdata *conn);
-CURLcode http_done(struct connectdata *conn);
-CURLcode http_connect(struct connectdata *conn);
-CURLcode http_close(struct connectdata *conn);
+CURLcode Curl_http(struct connectdata *conn);
+CURLcode Curl_http_done(struct connectdata *conn);
+CURLcode Curl_http_connect(struct connectdata *conn);
+CURLcode Curl_http_close(struct connectdata *conn);
#endif
diff --git a/lib/if2ip.c b/lib/if2ip.c
index 06be25d8a..dc3138a01 100644
--- a/lib/if2ip.c
+++ b/lib/if2ip.c
@@ -72,7 +72,7 @@
#define SYS_ERROR -1
-char *if2ip(char *interface, char *buf, int buf_size)
+char *Curl_if2ip(char *interface, char *buf, int buf_size)
{
int dummy;
char *ip=NULL;
diff --git a/lib/if2ip.h b/lib/if2ip.h
index 502f6732d..6a4801c2e 100644
--- a/lib/if2ip.h
+++ b/lib/if2ip.h
@@ -25,9 +25,9 @@
#include "setup.h"
#if ! defined(WIN32) && ! defined(__BEOS__)
-extern char *if2ip(char *interface, char *buf, int buf_size);
+extern char *Curl_if2ip(char *interface, char *buf, int buf_size);
#else
-#define if2ip(a,b,c) NULL
+#define Curl_if2ip(a,b,c) NULL
#endif
#endif
diff --git a/lib/krb4.c b/lib/krb4.c
index 073ba4cc0..4efa72b98 100644
--- a/lib/krb4.c
+++ b/lib/krb4.c
@@ -47,6 +47,9 @@
#include <string.h>
#include <krb.h>
+#include "ftp.h"
+#include "sendf.h"
+
/* The last #include file should be: */
#ifdef MALLOCDEBUG
#include "memdebug.h"
@@ -95,7 +98,8 @@ strlcpy (char *dst, const char *src, size_t dst_sz)
else
return n + strlen (src);
}
-
+#else
+size_t strlcpy (char *dst, const char *src, size_t dst_sz);
#endif
static int
@@ -284,7 +288,8 @@ krb4_auth(void *app_data, struct connectdata *conn)
size_t nread;
int l = sizeof(local_addr);
- if(getsockname(conn->data->firstsocket, LOCAL_ADDR, &l) < 0)
+ if(getsockname(conn->data->firstsocket,
+ (struct sockaddr *)LOCAL_ADDR, &l) < 0)
perror("getsockname()");
checksum = getpid();
@@ -327,15 +332,15 @@ krb4_auth(void *app_data, struct connectdata *conn)
/*printf("Local address is %s\n", inet_ntoa(localaddr->sin_addr));***/
/*printf("Remote address is %s\n", inet_ntoa(remoteaddr->sin_addr));***/
- if(base64_encode(adat.dat, adat.length, &p) < 0) {
+ if(Curl_base64_encode(adat.dat, adat.length, &p) < 0) {
printf("Out of memory base64-encoding.\n");
return AUTH_CONTINUE;
}
/*ret = command("ADAT %s", p)*/
- ftpsendf(conn->data->firstsocket, conn, "ADAT %s", p);
+ Curl_ftpsendf(conn->data->firstsocket, conn, "ADAT %s", p);
/* wait for feedback */
- nread = GetLastResponse(conn->data->firstsocket,
- conn->data->buffer, conn);
+ nread = Curl_GetFTPResponse(conn->data->firstsocket,
+ conn->data->buffer, conn, NULL);
if(nread < 0)
return /*CURLE_OPERATION_TIMEOUTED*/-1;
free(p);
@@ -351,7 +356,7 @@ krb4_auth(void *app_data, struct connectdata *conn)
return AUTH_ERROR;
}
p += 5;
- len = base64_decode(p, adat.dat);
+ len = Curl_base64_decode(p, adat.dat);
if(len < 0){
printf("Failed to decode base64 from server.\n");
return AUTH_ERROR;
@@ -389,8 +394,6 @@ struct sec_client_mech krb4_client_mech = {
void krb_kauth(struct connectdata *conn)
{
- int ret;
- char buf[1024];
des_cblock key;
des_key_schedule schedule;
KTEXT_ST tkt, tktcopy;
@@ -405,10 +408,11 @@ void krb_kauth(struct connectdata *conn)
save = set_command_prot(conn, prot_private);
/*ret = command("SITE KAUTH %s", name);***/
- ftpsendf(conn->data->firstsocket, conn,
+ Curl_ftpsendf(conn->data->firstsocket, conn,
"SITE KAUTH %s", conn->data->user);
/* wait for feedback */
- nread = GetLastResponse(conn->data->firstsocket, conn->data->buffer, conn);
+ nread = Curl_GetFTPResponse(conn->data->firstsocket, conn->data->buffer,
+ conn, NULL);
if(nread < 0)
return /*CURLE_OPERATION_TIMEOUTED*/;
@@ -427,7 +431,7 @@ void krb_kauth(struct connectdata *conn)
return;
}
p += 2;
- tmp = base64_decode(p, &tkt.dat);
+ tmp = Curl_base64_decode(p, &tkt.dat);
if(tmp < 0){
printf("Failed to decode base64 in reply.\n");
set_command_prot(conn, save);
@@ -476,7 +480,7 @@ void krb_kauth(struct connectdata *conn)
memset(key, 0, sizeof(key));
memset(schedule, 0, sizeof(schedule));
memset(passwd, 0, sizeof(passwd));
- if(base64_encode(tktcopy.dat, tktcopy.length, &p) < 0) {
+ if(Curl_base64_encode(tktcopy.dat, tktcopy.length, &p) < 0) {
failf(conn->data, "Out of memory base64-encoding.\n");
set_command_prot(conn, save);
/*code = -1;***/
@@ -484,10 +488,11 @@ void krb_kauth(struct connectdata *conn)
}
memset (tktcopy.dat, 0, tktcopy.length);
/*ret = command("SITE KAUTH %s %s", name, p);***/
- ftpsendf(conn->data->firstsocket, conn,
+ Curl_ftpsendf(conn->data->firstsocket, conn,
"SITE KAUTH %s %s", name, p);
/* wait for feedback */
- nread = GetLastResponse(conn->data->firstsocket, conn->data->buffer, conn);
+ nread = Curl_GetFTPResponse(conn->data->firstsocket, conn->data->buffer,
+ conn, NULL);
if(nread < 0)
return /*CURLE_OPERATION_TIMEOUTED*/;
free(p);
diff --git a/lib/ldap.c b/lib/ldap.c
index a60816381..28bdc88de 100644
--- a/lib/ldap.c
+++ b/lib/ldap.c
@@ -117,18 +117,18 @@ static void * DynaGetFunction(char *name)
static int WriteProc(void *param, char *text, int len)
{
struct UrlData *data = (struct UrlData *)param;
- client_write(data, CLIENTWRITE_BODY, text, 0);
+ Curl_client_write(data, CLIENTWRITE_BODY, text, 0);
return 0;
}
-CURLcode ldap_done(struct connectdata *conn)
+CURLcode Curl_ldap_done(struct connectdata *conn)
{
return CURLE_OK;
}
/***********************************************************************
*/
-CURLcode ldap(struct connectdata *conn)
+CURLcode Curl_ldap(struct connectdata *conn)
{
CURLcode status = CURLE_OK;
int rc;
diff --git a/lib/ldap.h b/lib/ldap.h
index 4de5d7a5e..c9ab7c891 100644
--- a/lib/ldap.h
+++ b/lib/ldap.h
@@ -23,7 +23,7 @@
*
* $Id$
*****************************************************************************/
-CURLcode ldap(struct connectdata *conn);
-CURLcode ldap_done(struct connectdata *conn);
+CURLcode Curl_ldap(struct connectdata *conn);
+CURLcode Curl_ldap_done(struct connectdata *conn);
#endif /* __LDAP_H */
diff --git a/lib/memdebug.c b/lib/memdebug.c
index e25ad4fe3..ef7c0c6ee 100644
--- a/lib/memdebug.c
+++ b/lib/memdebug.c
@@ -135,7 +135,7 @@ int curl_sclose(int sockfd, int line, char *source)
int res=sclose(sockfd);
fprintf(logfile?logfile:stderr, "FD %s:%d sclose(%d)\n",
source, line, sockfd);
- return sockfd;
+ return res;
}
FILE *curl_fopen(char *file, char *mode, int line, char *source)
diff --git a/lib/mprintf.c b/lib/mprintf.c
index a14e56ea2..dd6dbabad 100644
--- a/lib/mprintf.c
+++ b/lib/mprintf.c
@@ -207,7 +207,7 @@ struct asprintf {
size_t alloc; /* length of alloc */
};
-int msprintf(char *buffer, const char *format, ...);
+int Curl_msprintf(char *buffer, const char *format, ...);
static int dprintf_DollarString(char *input, char **end)
{
@@ -955,11 +955,11 @@ static int dprintf_formatf(
if(width >= 0) {
/* RECURSIVE USAGE */
- fptr += msprintf(fptr, "%d", width);
+ fptr += Curl_msprintf(fptr, "%d", width);
}
if(prec >= 0) {
/* RECURSIVE USAGE */
- fptr += msprintf(fptr, ".%d", prec);
+ fptr += Curl_msprintf(fptr, ".%d", prec);
}
if (p->flags & FLAGS_LONG)
strcat(fptr, "l");
@@ -1025,7 +1025,7 @@ static int addbyter(int output, FILE *data)
return -1;
}
-int msnprintf(char *buffer, size_t maxlength, const char *format, ...)
+int Curl_msnprintf(char *buffer, size_t maxlength, const char *format, ...)
{
va_list ap_save; /* argument pointer */
int retcode;
@@ -1045,7 +1045,7 @@ int msnprintf(char *buffer, size_t maxlength, const char *format, ...)
return retcode;
}
-int mvsnprintf(char *buffer, size_t maxlength, const char *format, va_list ap_save)
+int Curl_mvsnprintf(char *buffer, size_t maxlength, const char *format, va_list ap_save)
{
int retcode;
struct nsprintf info;
@@ -1092,7 +1092,7 @@ static int alloc_addbyter(int output, FILE *data)
}
-char *maprintf(const char *format, ...)
+char *Curl_maprintf(const char *format, ...)
{
va_list ap_save; /* argument pointer */
int retcode;
@@ -1113,7 +1113,7 @@ char *maprintf(const char *format, ...)
return NULL;
}
-char *mvaprintf(const char *format, va_list ap_save)
+char *Curl_mvaprintf(const char *format, va_list ap_save)
{
int retcode;
struct asprintf info;
@@ -1140,7 +1140,7 @@ static int storebuffer(int output, FILE *data)
return output; /* act like fputc() ! */
}
-int msprintf(char *buffer, const char *format, ...)
+int Curl_msprintf(char *buffer, const char *format, ...)
{
va_list ap_save; /* argument pointer */
int retcode;
@@ -1153,7 +1153,7 @@ int msprintf(char *buffer, const char *format, ...)
extern int fputc(int, FILE *);
-int mprintf(const char *format, ...)
+int Curl_mprintf(const char *format, ...)
{
int retcode;
va_list ap_save; /* argument pointer */
@@ -1163,7 +1163,7 @@ int mprintf(const char *format, ...)
return retcode;
}
-int mfprintf(FILE *whereto, const char *format, ...)
+int Curl_mfprintf(FILE *whereto, const char *format, ...)
{
int retcode;
va_list ap_save; /* argument pointer */
@@ -1173,7 +1173,7 @@ int mfprintf(FILE *whereto, const char *format, ...)
return retcode;
}
-int mvsprintf(char *buffer, const char *format, va_list ap_save)
+int Curl_mvsprintf(char *buffer, const char *format, va_list ap_save)
{
int retcode;
retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save);
@@ -1181,12 +1181,12 @@ int mvsprintf(char *buffer, const char *format, va_list ap_save)
return retcode;
}
-int mvprintf(const char *format, va_list ap_save)
+int Curl_mvprintf(const char *format, va_list ap_save)
{
return dprintf_formatf(stdout, fputc, format, ap_save);
}
-int mvfprintf(FILE *whereto, const char *format, va_list ap_save)
+int Curl_mvfprintf(FILE *whereto, const char *format, va_list ap_save)
{
return dprintf_formatf(whereto, fputc, format, ap_save);
}
diff --git a/lib/netrc.c b/lib/netrc.c
index d8c0a5971..7a9a10b83 100644
--- a/lib/netrc.c
+++ b/lib/netrc.c
@@ -51,15 +51,15 @@ enum {
#define LOGINSIZE 64
#define PASSWORDSIZE 64
-int ParseNetrc(char *host,
- char *login,
- char *password)
+int Curl_parsenetrc(char *host,
+ char *login,
+ char *password)
{
FILE *file;
char netrcbuffer[256];
int retcode=1;
- char *home = GetEnv("HOME"); /* portable environment reader */
+ char *home = curl_getenv("HOME"); /* portable environment reader */
int state=NOTHING;
char state_login=0;
diff --git a/lib/netrc.h b/lib/netrc.h
index cb043707d..de9539040 100644
--- a/lib/netrc.h
+++ b/lib/netrc.h
@@ -22,7 +22,7 @@
*
* $Id$
*****************************************************************************/
-int ParseNetrc(char *host,
- char *login,
- char *password);
+int Curl_parsenetrc(char *host,
+ char *login,
+ char *password);
#endif
diff --git a/lib/progress.c b/lib/progress.c
index fa902e03d..098a0e681 100644
--- a/lib/progress.c
+++ b/lib/progress.c
@@ -45,7 +45,7 @@
#include "progress.h"
-void time2str(char *r, int t)
+static void time2str(char *r, int t)
{
int h = (t/3600);
int m = (t-(h*3600))/60;
@@ -55,7 +55,7 @@ void time2str(char *r, int t)
/* The point of this function would be to return a string of the input data,
but never longer than 5 columns. Add suffix k, M, G when suitable... */
-char *max5data(double bytes, char *max5)
+static char *max5data(double bytes, char *max5)
{
#define ONE_KILOBYTE 1024
#define ONE_MEGABYTE (1024*1024)
@@ -91,16 +91,16 @@ char *max5data(double bytes, char *max5)
*/
-void pgrsDone(struct UrlData *data)
+void Curl_pgrsDone(struct UrlData *data)
{
if(!(data->progress.flags & PGRS_HIDE)) {
data->progress.lastshow=0;
- pgrsUpdate(data); /* the final (forced) update */
+ Curl_pgrsUpdate(data); /* the final (forced) update */
fprintf(data->err, "\n");
}
}
-void pgrsTime(struct UrlData *data, timerid timer)
+void Curl_pgrsTime(struct UrlData *data, timerid timer)
{
switch(timer) {
default:
@@ -111,19 +111,19 @@ void pgrsTime(struct UrlData *data, timerid timer)
/* This is set at the start of a single fetch, there may be several
fetches within an operation, why we add all other times relative
to this one */
- data->progress.t_startsingle = tvnow();
+ data->progress.t_startsingle = Curl_tvnow();
break;
case TIMER_NAMELOOKUP:
- data->progress.t_nslookup += tvdiff(tvnow(),
+ data->progress.t_nslookup += Curl_tvdiff(Curl_tvnow(),
data->progress.t_startsingle);
break;
case TIMER_CONNECT:
- data->progress.t_connect += tvdiff(tvnow(),
+ data->progress.t_connect += Curl_tvdiff(Curl_tvnow(),
data->progress.t_startsingle);
break;
case TIMER_PRETRANSFER:
- data->progress.t_pretransfer += tvdiff(tvnow(),
+ data->progress.t_pretransfer += Curl_tvdiff(Curl_tvnow(),
data->progress.t_startsingle);
break;
case TIMER_POSTRANSFER:
@@ -132,22 +132,22 @@ void pgrsTime(struct UrlData *data, timerid timer)
}
}
-void pgrsStartNow(struct UrlData *data)
+void Curl_pgrsStartNow(struct UrlData *data)
{
- data->progress.start = tvnow();
+ data->progress.start = Curl_tvnow();
}
-void pgrsSetDownloadCounter(struct UrlData *data, double size)
+void Curl_pgrsSetDownloadCounter(struct UrlData *data, double size)
{
data->progress.downloaded = size;
}
-void pgrsSetUploadCounter(struct UrlData *data, double size)
+void Curl_pgrsSetUploadCounter(struct UrlData *data, double size)
{
data->progress.uploaded = size;
}
-void pgrsSetDownloadSize(struct UrlData *data, double size)
+void Curl_pgrsSetDownloadSize(struct UrlData *data, double size)
{
if(size > 0) {
data->progress.size_dl = size;
@@ -155,7 +155,7 @@ void pgrsSetDownloadSize(struct UrlData *data, double size)
}
}
-void pgrsSetUploadSize(struct UrlData *data, double size)
+void Curl_pgrsSetUploadSize(struct UrlData *data, double size)
{
if(size > 0) {
data->progress.size_ul = size;
@@ -171,7 +171,7 @@ void pgrsSetUploadSize(struct UrlData *data, double size)
*/
-int pgrsUpdate(struct UrlData *data)
+int Curl_pgrsUpdate(struct UrlData *data)
{
struct timeval now;
int result;
@@ -210,15 +210,15 @@ int pgrsUpdate(struct UrlData *data)
data->progress.flags |= PGRS_HEADERS_OUT; /* headers are shown */
}
- now = tvnow(); /* what time is it */
+ now = Curl_tvnow(); /* what time is it */
- if(data->progress.lastshow == tvlong(now))
+ if(data->progress.lastshow == Curl_tvlong(now))
return 0; /* never update this more than once a second if the end isn't
reached */
data->progress.lastshow = now.tv_sec;
/* The exact time spent so far */
- data->progress.timespent = tvdiff (now, data->progress.start);
+ data->progress.timespent = Curl_tvdiff (now, data->progress.start);
/* The average download speed this far */
data->progress.dlspeed = data->progress.downloaded/(data->progress.timespent!=0.0?data->progress.timespent:1.0);
diff --git a/lib/progress.h b/lib/progress.h
index 0b5f3c61f..04b3d6c24 100644
--- a/lib/progress.h
+++ b/lib/progress.h
@@ -36,14 +36,14 @@ typedef enum {
TIMER_LAST /* must be last */
} timerid;
-void pgrsDone(struct UrlData *data);
-void pgrsStartNow(struct UrlData *data);
-void pgrsSetDownloadSize(struct UrlData *data, double size);
-void pgrsSetUploadSize(struct UrlData *data, double size);
-void pgrsSetDownloadCounter(struct UrlData *data, double size);
-void pgrsSetUploadCounter(struct UrlData *data, double size);
-int pgrsUpdate(struct UrlData *data);
-void pgrsTime(struct UrlData *data, timerid timer);
+void Curl_pgrsDone(struct UrlData *data);
+void Curl_pgrsStartNow(struct UrlData *data);
+void Curl_pgrsSetDownloadSize(struct UrlData *data, double size);
+void Curl_pgrsSetUploadSize(struct UrlData *data, double size);
+void Curl_pgrsSetDownloadCounter(struct UrlData *data, double size);
+void Curl_pgrsSetUploadCounter(struct UrlData *data, double size);
+int Curl_pgrsUpdate(struct UrlData *data);
+void Curl_pgrsTime(struct UrlData *data, timerid timer);
/* Don't show progress for sizes smaller than: */
diff --git a/lib/security.c b/lib/security.c
index 47b134159..ced5e7d38 100644
--- a/lib/security.c
+++ b/lib/security.c
@@ -40,13 +40,22 @@
#ifdef KRB4
+#define _MPRINTF_REPLACE /* we want curl-functions instead of native ones */
#include <curl/mprintf.h>
#include "security.h"
#include <stdlib.h>
#include <string.h>
#include <netdb.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
#include "base64.h"
+#include "sendf.h"
+#include "ftp.h"
+
/* The last #include file should be: */
#ifdef MALLOCDEBUG
#include "memdebug.h"
@@ -64,6 +73,7 @@ static struct {
{ prot_private, "private" }
};
+#if 0
static const char *
level_to_name(enum protection_level level)
{
@@ -73,6 +83,7 @@ level_to_name(enum protection_level level)
return level_names[i].name;
return "unknown";
}
+#endif
#ifndef FTP_SERVER /* not used in server */
static enum protection_level
@@ -319,7 +330,7 @@ sec_vfprintf2(struct connectdata *conn, FILE *f, const char *fmt, va_list ap)
if(conn->data_prot == prot_clear)
return vfprintf(f, fmt, ap);
else {
- buf = maprintf(fmt, ap);
+ buf = aprintf(fmt, ap);
ret = buffer_write(&conn->out_buffer, buf, strlen(buf));
free(buf);
return ret;
@@ -360,7 +371,7 @@ sec_read_msg(struct connectdata *conn, char *s, int level)
int code;
buf = malloc(strlen(s));
- len = base64_decode(s + 4, buf); /* XXX */
+ len = Curl_base64_decode(s + 4, buf); /* XXX */
len = (*mech->decode)(conn->app_data, buf, len, level, conn);
if(len < 0)
@@ -390,7 +401,7 @@ sec_vfprintf(struct connectdata *conn, FILE *f, const char *fmt, va_list ap)
if(!conn->sec_complete)
return vfprintf(f, fmt, ap);
- buf = maprintf(fmt, ap);
+ buf = aprintf(fmt, ap);
len = (*mech->encode)(conn->app_data, buf, strlen(buf),
conn->command_prot, &enc,
conn);
@@ -399,7 +410,7 @@ sec_vfprintf(struct connectdata *conn, FILE *f, const char *fmt, va_list ap)
failf(conn->data, "Failed to encode command.\n");
return -1;
}
- if(base64_encode(enc, len, &buf) < 0){
+ if(Curl_base64_encode(enc, len, &buf) < 0){
failf(conn->data, "Out of memory base64-encoding.\n");
return -1;
}
@@ -461,7 +472,6 @@ sec_status(void)
static int
sec_prot_internal(struct connectdata *conn, int level)
{
- int ret;
char *p;
unsigned int s = 1048576;
size_t nread;
@@ -472,11 +482,11 @@ sec_prot_internal(struct connectdata *conn, int level)
}
if(level){
- ftpsendf(conn->data->firstsocket, conn,
- "PBSZ %u", s);
+ Curl_ftpsendf(conn->data->firstsocket, conn,
+ "PBSZ %u", s);
/* wait for feedback */
- nread = GetLastResponse(conn->data->firstsocket,
- conn->data->buffer, conn);
+ nread = Curl_GetFTPResponse(conn->data->firstsocket,
+ conn->data->buffer, conn, NULL);
if(nread < 0)
return /*CURLE_OPERATION_TIMEOUTED*/-1;
if(/*ret != COMPLETE*/conn->data->buffer[0] != '2'){
@@ -491,11 +501,11 @@ sec_prot_internal(struct connectdata *conn, int level)
conn->buffer_size = s;
}
- ftpsendf(conn->data->firstsocket, conn,
- "PROT %c", level["CSEP"]);
+ Curl_ftpsendf(conn->data->firstsocket, conn,
+ "PROT %c", level["CSEP"]);
/* wait for feedback */
- nread = GetLastResponse(conn->data->firstsocket,
- conn->data->buffer, conn);
+ nread = Curl_GetFTPResponse(conn->data->firstsocket,
+ conn->data->buffer, conn, NULL);
if(nread < 0)
return /*CURLE_OPERATION_TIMEOUTED*/-1;
if(/*ret != COMPLETE*/conn->data->buffer[0] != '2'){
@@ -600,11 +610,11 @@ sec_login(struct connectdata *conn)
}
infof(data, "Trying %s...\n", (*m)->name);
/*ret = command("AUTH %s", (*m)->name);***/
- ftpsendf(conn->data->firstsocket, conn,
+ Curl_ftpsendf(conn->data->firstsocket, conn,
"AUTH %s", (*m)->name);
/* wait for feedback */
- nread = GetLastResponse(conn->data->firstsocket,
- conn->data->buffer, conn);
+ nread = Curl_GetFTPResponse(conn->data->firstsocket,
+ conn->data->buffer, conn, NULL);
if(nread < 0)
return /*CURLE_OPERATION_TIMEOUTED*/-1;
if(/*ret != CONTINUE*/conn->data->buffer[0] != '3'){
diff --git a/lib/sendf.c b/lib/sendf.c
index 25d53a620..69dc2ea14 100644
--- a/lib/sendf.c
+++ b/lib/sendf.c
@@ -52,7 +52,7 @@
/* infof() is for info message along the way */
-void infof(struct UrlData *data, char *fmt, ...)
+void Curl_infof(struct UrlData *data, char *fmt, ...)
{
va_list ap;
if(data->bits.verbose) {
@@ -66,7 +66,7 @@ void infof(struct UrlData *data, char *fmt, ...)
/* failf() is for messages stating why we failed, the LAST one will be
returned for the user (if requested) */
-void failf(struct UrlData *data, char *fmt, ...)
+void Curl_failf(struct UrlData *data, char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@@ -78,13 +78,13 @@ void failf(struct UrlData *data, char *fmt, ...)
}
/* sendf() sends the formated data to the server */
-size_t sendf(int fd, struct UrlData *data, char *fmt, ...)
+size_t Curl_sendf(int fd, struct UrlData *data, char *fmt, ...)
{
size_t bytes_written;
char *s;
va_list ap;
va_start(ap, fmt);
- s = mvaprintf(fmt, ap);
+ s = vaprintf(fmt, ap);
va_end(ap);
if(!s)
return 0; /* failure */
@@ -104,43 +104,8 @@ size_t sendf(int fd, struct UrlData *data, char *fmt, ...)
return(bytes_written);
}
-/*
- * ftpsendf() sends the formated string as a ftp command to a ftp server
- *
- * NOTE: we build the command in a fixed-length buffer, which sets length
- * restrictions on the command!
- *
- */
-size_t ftpsendf(int fd, struct connectdata *conn, char *fmt, ...)
-{
- size_t bytes_written;
- char s[256];
-
- va_list ap;
- va_start(ap, fmt);
- vsnprintf(s, 250, fmt, ap);
- va_end(ap);
-
- if(conn->data->bits.verbose)
- fprintf(conn->data->err, "> %s\n", s);
-
- strcat(s, "\r\n"); /* append a trailing CRLF */
-
-#ifdef KRB4
- if(conn->sec_complete && conn->data->cmdchannel) {
- bytes_written = sec_fprintf(conn, conn->data->cmdchannel, s);
- fflush(conn->data->cmdchannel);
- }
- else
-#endif /* KRB4 */
- {
- bytes_written = swrite(fd, s, strlen(s));
- }
- return(bytes_written);
-}
-
/* ssend() sends plain (binary) data to the server */
-size_t ssend(int fd, struct connectdata *conn, void *mem, size_t len)
+size_t Curl_ssend(int fd, struct connectdata *conn, void *mem, size_t len)
{
size_t bytes_written;
struct UrlData *data=conn->data; /* conn knows data, not vice versa */
@@ -170,10 +135,10 @@ size_t ssend(int fd, struct connectdata *conn, void *mem, size_t len)
The bit pattern defines to what "streams" to write to. Body and/or header.
The defines are in sendf.h of course.
*/
-CURLcode client_write(struct UrlData *data,
- int type,
- char *ptr,
- size_t len)
+CURLcode Curl_client_write(struct UrlData *data,
+ int type,
+ char *ptr,
+ size_t len)
{
size_t wrote;
@@ -198,92 +163,3 @@ CURLcode client_write(struct UrlData *data,
return CURLE_OK;
}
-
-/*
- * add_buffer_init() returns a fine buffer struct
- */
-send_buffer *add_buffer_init(void)
-{
- send_buffer *blonk;
- blonk=(send_buffer *)malloc(sizeof(send_buffer));
- if(blonk) {
- memset(blonk, 0, sizeof(send_buffer));
- return blonk;
- }
- return NULL; /* failed, go home */
-}
-
-/*
- * add_buffer_send() sends a buffer and frees all associated memory.
- */
-size_t add_buffer_send(int sockfd, struct connectdata *conn, send_buffer *in)
-{
- size_t amount;
- if(conn->data->bits.verbose) {
- fputs("> ", conn->data->err);
- /* this data _may_ contain binary stuff */
- fwrite(in->buffer, in->size_used, 1, conn->data->err);
- }
-
- amount = ssend(sockfd, conn, in->buffer, in->size_used);
-
- if(in->buffer)
- free(in->buffer);
- free(in);
-
- return amount;
-}
-
-
-/*
- * add_bufferf() builds a buffer from the formatted input
- */
-CURLcode add_bufferf(send_buffer *in, char *fmt, ...)
-{
- CURLcode result = CURLE_OUT_OF_MEMORY;
- char *s;
- va_list ap;
- va_start(ap, fmt);
- s = mvaprintf(fmt, ap); /* this allocs a new string to append */
- va_end(ap);
-
- if(s) {
- result = add_buffer(in, s, strlen(s));
- free(s);
- }
- return result;
-}
-
-/*
- * add_buffer() appends a memory chunk to the existing one
- */
-CURLcode add_buffer(send_buffer *in, void *inptr, size_t size)
-{
- char *new_rb;
- int new_size;
-
- if(size > 0) {
- if(!in->buffer ||
- ((in->size_used + size) > (in->size_max - 1))) {
- new_size = (in->size_used+size)*2;
- if(in->buffer)
- /* we have a buffer, enlarge the existing one */
- new_rb = (char *)realloc(in->buffer, new_size);
- else
- /* create a new buffer */
- new_rb = (char *)malloc(new_size);
-
- if(!new_rb)
- return CURLE_OUT_OF_MEMORY;
-
- in->buffer = new_rb;
- in->size_max = new_size;
- }
- memcpy(&in->buffer[in->size_used], inptr, size);
-
- in->size_used += size;
- }
-
- return CURLE_OK;
-}
-
diff --git a/lib/sendf.h b/lib/sendf.h
index 28e503da8..26771f38b 100644
--- a/lib/sendf.h
+++ b/lib/sendf.h
@@ -23,11 +23,15 @@
* $Id$
*****************************************************************************/
-size_t ftpsendf(int fd, struct connectdata *, char *fmt, ...);
-size_t sendf(int fd, struct UrlData *, char *fmt, ...);
-size_t ssend(int fd, struct connectdata *, void *fmt, size_t len);
-void infof(struct UrlData *, char *fmt, ...);
-void failf(struct UrlData *, char *fmt, ...);
+size_t Curl_sendf(int fd, struct UrlData *, char *fmt, ...);
+size_t Curl_ssend(int fd, struct connectdata *, void *fmt, size_t len);
+void Curl_infof(struct UrlData *, char *fmt, ...);
+void Curl_failf(struct UrlData *, char *fmt, ...);
+
+#define sendf Curl_sendf
+#define ssend Curl_ssend
+#define infof Curl_infof
+#define failf Curl_failf
struct send_buffer {
char *buffer;
@@ -40,12 +44,7 @@ typedef struct send_buffer send_buffer;
#define CLIENTWRITE_HEADER 2
#define CLIENTWRITE_BOTH (CLIENTWRITE_BODY|CLIENTWRITE_HEADER)
-CURLcode client_write(struct UrlData *data, int type, char *ptr,
- size_t len);
-send_buffer *add_buffer_init(void);
-CURLcode add_buffer(send_buffer *in, void *inptr, size_t size);
-CURLcode add_bufferf(send_buffer *in, char *fmt, ...);
-size_t add_buffer_send(int sockfd, struct connectdata *conn, send_buffer *in);
-
+CURLcode Curl_client_write(struct UrlData *data, int type, char *ptr,
+ size_t len);
#endif
diff --git a/lib/speedcheck.c b/lib/speedcheck.c
index 0578ccc22..17e9d90d7 100644
--- a/lib/speedcheck.c
+++ b/lib/speedcheck.c
@@ -33,24 +33,24 @@
#include "sendf.h"
#include "speedcheck.h"
-void speedinit(struct UrlData *data)
+void Curl_speedinit(struct UrlData *data)
{
memset(&data->keeps_speed, 0, sizeof(struct timeval));
}
-CURLcode speedcheck(struct UrlData *data,
- struct timeval now)
+CURLcode Curl_speedcheck(struct UrlData *data,
+ struct timeval now)
{
if((data->progress.current_speed >= 0) &&
data->low_speed_time &&
- (tvlong(data->keeps_speed) != 0) &&
+ (Curl_tvlong(data->keeps_speed) != 0) &&
(data->progress.current_speed < data->low_speed_limit)) {
/* We are now below the "low speed limit". If we are below it
for "low speed time" seconds we consider that enough reason
to abort the download. */
- if( tvdiff(now, data->keeps_speed) > data->low_speed_time) {
+ if( Curl_tvdiff(now, data->keeps_speed) > data->low_speed_time) {
/* we have been this slow for long enough, now die */
failf(data,
"Operation too slow. "
diff --git a/lib/speedcheck.h b/lib/speedcheck.h
index 6340528b3..6674048f3 100644
--- a/lib/speedcheck.h
+++ b/lib/speedcheck.h
@@ -27,8 +27,8 @@
#include "timeval.h"
-void speedinit(struct UrlData *data);
-CURLcode speedcheck(struct UrlData *data,
- struct timeval now);
+void Curl_speedinit(struct UrlData *data);
+CURLcode Curl_speedcheck(struct UrlData *data,
+ struct timeval now);
#endif
diff --git a/lib/ssluse.c b/lib/ssluse.c
index 52229218e..9def3e805 100644
--- a/lib/ssluse.c
+++ b/lib/ssluse.c
@@ -62,9 +62,10 @@ static int passwd_callback(char *buf, int num, int verify
* from) source from the SSLeay package written by Eric Young
* (eay@cryptsoft.com). */
-int SSL_cert_stuff(struct UrlData *data,
- char *cert_file,
- char *key_file)
+static
+int cert_stuff(struct UrlData *data,
+ char *cert_file,
+ char *key_file)
{
if (cert_file != NULL) {
SSL *ssl;
@@ -124,6 +125,7 @@ int SSL_cert_stuff(struct UrlData *data,
#endif
#ifdef USE_SSLEAY
+static
int cert_verify_callback(int ok, X509_STORE_CTX *ctx)
{
X509 *err_cert;
@@ -139,7 +141,7 @@ int cert_verify_callback(int ok, X509_STORE_CTX *ctx)
/* ====================================================== */
int
-UrgSSLConnect (struct UrlData *data)
+Curl_SSLConnect (struct UrlData *data)
{
#ifdef USE_SSLEAY
int err;
@@ -163,7 +165,7 @@ UrgSSLConnect (struct UrlData *data)
RAND_screen();
#else
int len;
- char *area = MakeFormBoundary();
+ char *area = Curl_FormBoundary();
if(!area)
return 3; /* out of memory */
@@ -198,7 +200,7 @@ UrgSSLConnect (struct UrlData *data)
}
if(data->cert) {
- if (!SSL_cert_stuff(data, data->cert, data->cert)) {
+ if (!cert_stuff(data, data->cert, data->cert)) {
failf(data, "couldn't use certificate!\n");
return 2;
}
diff --git a/lib/ssluse.h b/lib/ssluse.h
index 863d37a23..6279c6257 100644
--- a/lib/ssluse.h
+++ b/lib/ssluse.h
@@ -22,8 +22,5 @@
*
* $Id$
*****************************************************************************/
-int SSL_cert_stuff(struct UrlData *data,
- char *cert_file,
- char *key_file);
-int UrgSSLConnect (struct UrlData *data);
+int Curl_SSLConnect (struct UrlData *data);
#endif
diff --git a/lib/strequal.c b/lib/strequal.c
index 0bb893894..82e991cda 100644
--- a/lib/strequal.c
+++ b/lib/strequal.c
@@ -25,7 +25,7 @@
#include <string.h>
-int strequal(const char *first, const char *second)
+int Curl_strequal(const char *first, const char *second)
{
#if defined(HAVE_STRCASECMP)
return !strcasecmp(first, second);
@@ -45,7 +45,7 @@ int strequal(const char *first, const char *second)
#endif
}
-int strnequal(const char *first, const char *second, size_t max)
+int Curl_strnequal(const char *first, const char *second, size_t max)
{
#if defined(HAVE_STRCASECMP)
return !strncasecmp(first, second, max);
diff --git a/lib/strequal.h b/lib/strequal.h
index aea87d052..9901d281e 100644
--- a/lib/strequal.h
+++ b/lib/strequal.h
@@ -22,7 +22,10 @@
*
* $Id$
*****************************************************************************/
-int strequal(const char *first, const char *second);
-int strnequal(const char *first, const char *second, size_t max);
+int Curl_strequal(const char *first, const char *second);
+int Curl_strnequal(const char *first, const char *second, size_t max);
+
+#define strequal(a,b) Curl_strequal(a,b)
+#define strnequal(a,b,c) Curl_strnequal(a,b,c)
#endif
diff --git a/lib/telnet.c b/lib/telnet.c
index 60a2c647d..43cbb637b 100644
--- a/lib/telnet.c
+++ b/lib/telnet.c
@@ -81,7 +81,6 @@
#define TELOPTS
#define TELCMDS
-#define SLC_NAMES
#include "arpa_telnet.h"
@@ -98,10 +97,12 @@
#define SB_EOF() (subpointer >= subend)
#define SB_LEN() (subend - subpointer)
+static
void telwrite(struct UrlData *data,
unsigned char *buffer, /* Data to write */
int count); /* Number of bytes to write */
+static
void telrcv(struct UrlData *data,
unsigned char *inbuf, /* Data received from socket */
int count); /* Number of bytes received */
@@ -155,6 +156,7 @@ static int him[256];
static int himq[256];
static int him_preferred[256];
+static
void init_telnet(struct UrlData *data)
{
telrcv_state = TS_DATA;
@@ -246,6 +248,7 @@ static void send_negotiation(struct UrlData *data, int cmd, int option)
printoption(data, "SENT", cmd, option);
}
+static
void set_remote_option(struct UrlData *data, int option, int newstate)
{
if(newstate == YES)
@@ -326,6 +329,7 @@ void set_remote_option(struct UrlData *data, int option, int newstate)
}
}
+static
void rec_will(struct UrlData *data, int option)
{
switch(him[option])
@@ -377,6 +381,7 @@ void rec_will(struct UrlData *data, int option)
}
}
+static
void rec_wont(struct UrlData *data, int option)
{
switch(him[option])
@@ -500,6 +505,7 @@ void set_local_option(struct UrlData *data, int option, int newstate)
}
}
+static
void rec_do(struct UrlData *data, int option)
{
switch(us[option])
@@ -550,7 +556,8 @@ void rec_do(struct UrlData *data, int option)
break;
}
}
-
+
+static
void rec_dont(struct UrlData *data, int option)
{
switch(us[option])
@@ -669,6 +676,7 @@ static void suboption(struct UrlData *data)
return;
}
+static
void telrcv(struct UrlData *data,
unsigned char *inbuf, /* Data received from socket */
int count) /* Number of bytes received */
@@ -689,7 +697,7 @@ void telrcv(struct UrlData *data,
break; /* Ignore \0 after CR */
}
- client_write(data, CLIENTWRITE_BODY, (char *)&c, 1);
+ Curl_client_write(data, CLIENTWRITE_BODY, (char *)&c, 1);
continue;
case TS_DATA:
@@ -703,7 +711,7 @@ void telrcv(struct UrlData *data,
telrcv_state = TS_CR;
}
- client_write(data, CLIENTWRITE_BODY, (char *)&c, 1);
+ Curl_client_write(data, CLIENTWRITE_BODY, (char *)&c, 1);
continue;
case TS_IAC:
@@ -727,7 +735,7 @@ void telrcv(struct UrlData *data,
telrcv_state = TS_SB;
continue;
case IAC:
- client_write(data, CLIENTWRITE_BODY, (char *)&c, 1);
+ Curl_client_write(data, CLIENTWRITE_BODY, (char *)&c, 1);
break;
case DM:
case NOP:
@@ -818,6 +826,7 @@ void telrcv(struct UrlData *data,
}
}
+static
void telwrite(struct UrlData *data,
unsigned char *buffer, /* Data to write */
int count) /* Number of bytes to write */
@@ -847,12 +856,12 @@ void telwrite(struct UrlData *data,
}
}
-CURLcode telnet_done(struct connectdata *conn)
+CURLcode Curl_telnet_done(struct connectdata *conn)
{
return CURLE_OK;
}
-CURLcode telnet(struct connectdata *conn)
+CURLcode Curl_telnet(struct connectdata *conn)
{
struct UrlData *data = conn->data;
int sockfd = data->firstsocket;
diff --git a/lib/telnet.h b/lib/telnet.h
index 6ecc352ff..e576d1d48 100644
--- a/lib/telnet.h
+++ b/lib/telnet.h
@@ -23,7 +23,7 @@
*
* $Id$
*****************************************************************************/
-CURLcode telnet(struct connectdata *conn);
-CURLcode telnet_done(struct connectdata *conn);
+CURLcode Curl_telnet(struct connectdata *conn);
+CURLcode Curl_telnet_done(struct connectdata *conn);
#endif
diff --git a/lib/timeval.c b/lib/timeval.c
index 9e5182883..74bf10695 100644
--- a/lib/timeval.c
+++ b/lib/timeval.c
@@ -53,7 +53,7 @@ gettimeofday (struct timeval *tp, void *nothing)
#endif
#endif
-struct timeval tvnow ()
+struct timeval Curl_tvnow ()
{
struct timeval now;
#ifdef HAVE_GETTIMEOFDAY
@@ -65,12 +65,12 @@ struct timeval tvnow ()
return now;
}
-double tvdiff (struct timeval t1, struct timeval t2)
+double Curl_tvdiff (struct timeval t1, struct timeval t2)
{
return (double)(t1.tv_sec - t2.tv_sec) + ((t1.tv_usec-t2.tv_usec)/1000000.0);
}
-long tvlong (struct timeval t1)
+long Curl_tvlong (struct timeval t1)
{
return t1.tv_sec;
}
diff --git a/lib/timeval.h b/lib/timeval.h
index 8c94f3124..a37852598 100644
--- a/lib/timeval.h
+++ b/lib/timeval.h
@@ -42,8 +42,8 @@ struct timeval {
#endif
#endif
-struct timeval tvnow ();
-double tvdiff (struct timeval t1, struct timeval t2);
-long tvlong (struct timeval t1);
+struct timeval Curl_tvnow ();
+double Curl_tvdiff (struct timeval t1, struct timeval t2);
+long Curl_tvlong (struct timeval t1);
#endif
diff --git a/lib/url.c b/lib/url.c
index b6a2848b1..3bd3c6ce2 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -87,7 +87,6 @@
#include "if2ip.h"
#include "download.h"
#include "sendf.h"
-#include "speedcheck.h"
#include "getpass.h"
#include "progress.h"
#include "cookie.h"
@@ -224,7 +223,7 @@ void static urlfree(struct UrlData *data, bool totally)
/* the URL is allocated, free it! */
free(data->url);
- cookie_cleanup(data->cookies);
+ Curl_cookie_cleanup(data->cookies);
free(data);
@@ -248,6 +247,7 @@ CURLcode curl_close(CURL *curl)
return CURLE_OK;
}
+static
int my_getpass(void *clientp, char *prompt, char* buffer, int buflen )
{
char *retbuf;
@@ -381,7 +381,7 @@ CURLcode curl_setopt(CURL *curl, CURLoption option, ...)
case CURLOPT_COOKIEFILE:
cookiefile = (char *)va_arg(param, void *);
if(cookiefile) {
- data->cookies = cookie_init(cookiefile);
+ data->cookies = Curl_cookie_init(cookiefile);
}
break;
case CURLOPT_WRITEHEADER:
@@ -533,50 +533,11 @@ CURLcode curl_setopt(CURL *curl, CURLoption option, ...)
return CURLE_OK;
}
-
-/*
- * Read everything until a newline.
- */
-
-int GetLine(int sockfd, char *buf, struct UrlData *data)
-{
- int nread;
- int read_rc=1;
- char *ptr;
- ptr=buf;
-
- /* get us a full line, terminated with a newline */
- for(nread=0;
- (nread<BUFSIZE) && read_rc;
- nread++, ptr++) {
-#ifdef USE_SSLEAY
- if (data->ssl.use) {
- read_rc = SSL_read(data->ssl.handle, ptr, 1);
- }
- else {
-#endif
- read_rc = sread(sockfd, ptr, 1);
-#ifdef USE_SSLEAY
- }
-#endif /* USE_SSLEAY */
- if (*ptr == '\n')
- break;
- }
- *ptr=0; /* zero terminate */
-
- if(data->bits.verbose) {
- fputs("< ", data->err);
- fwrite(buf, 1, nread, data->err);
- fputs("\n", data->err);
- }
- return nread;
-}
-
-
#ifndef WIN32
#ifndef RETSIGTYPE
#define RETSIGTYPE void
#endif
+static
RETSIGTYPE alarmfunc(int signal)
{
/* this is for "-ansi -Wall -pedantic" to stop complaining! (rabe) */
@@ -865,9 +826,9 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
char *proxy=NULL;
char proxy_env[128];
- no_proxy=GetEnv("no_proxy");
+ no_proxy=curl_getenv("no_proxy");
if(!no_proxy)
- no_proxy=GetEnv("NO_PROXY");
+ no_proxy=curl_getenv("NO_PROXY");
if(!no_proxy || !strequal("*", no_proxy)) {
/* NO_PROXY wasn't specified or it wasn't just an asterisk */
@@ -899,22 +860,22 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
strcpy(envp, "_proxy");
/* read the protocol proxy: */
- prox=GetEnv(proxy_env);
+ prox=curl_getenv(proxy_env);
if(!prox) {
/* There was no lowercase variable, try the uppercase version: */
for(envp = proxy_env; *envp; envp++)
*envp = toupper(*envp);
- prox=GetEnv(proxy_env);
+ prox=curl_getenv(proxy_env);
}
if(prox && *prox) { /* don't count "" strings */
proxy = prox; /* use this */
}
else {
- proxy = GetEnv("all_proxy"); /* default proxy to use */
+ proxy = curl_getenv("all_proxy"); /* default proxy to use */
if(!proxy)
- proxy=GetEnv("ALL_PROXY");
+ proxy=curl_getenv("ALL_PROXY");
}
if(proxy && *proxy) {
@@ -935,7 +896,7 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
*/
char *reurl;
- reurl = maprintf("%s://%s", conn->proto, data->url);
+ reurl = aprintf("%s://%s", conn->proto, data->url);
if(!reurl)
return CURLE_OUT_OF_MEMORY;
@@ -984,9 +945,9 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
data->port = PORT_HTTP;
data->remote_port = PORT_HTTP;
conn->protocol |= PROT_HTTP;
- conn->curl_do = http;
- conn->curl_done = http_done;
- conn->curl_close = http_close;
+ conn->curl_do = Curl_http;
+ conn->curl_done = Curl_http_done;
+ conn->curl_close = Curl_http_close;
}
else if (strequal(conn->proto, "HTTPS")) {
#ifdef USE_SSLEAY
@@ -996,10 +957,10 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
conn->protocol |= PROT_HTTP;
conn->protocol |= PROT_HTTPS;
- conn->curl_do = http;
- conn->curl_done = http_done;
- conn->curl_connect = http_connect;
- conn->curl_close = http_close;
+ conn->curl_do = Curl_http;
+ conn->curl_done = Curl_http_done;
+ conn->curl_connect = Curl_http_connect;
+ conn->curl_close = Curl_http_close;
#else /* USE_SSLEAY */
failf(data, "libcurl was built with SSL disabled, https: not supported!");
@@ -1017,9 +978,9 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
conn->ppath = conn->path;
}
conn->protocol |= PROT_GOPHER;
- conn->curl_do = http;
- conn->curl_done = http_done;
- conn->curl_close = http_close;
+ conn->curl_do = Curl_http;
+ conn->curl_done = Curl_http_done;
+ conn->curl_close = Curl_http_close;
}
else if(strequal(conn->proto, "FTP")) {
char *type;
@@ -1032,14 +993,14 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
!data->bits.tunnel_thru_httpproxy) {
/* Unless we have asked to tunnel ftp operations through the proxy, we
switch and use HTTP operations only */
- conn->curl_do = http;
- conn->curl_done = http_done;
- conn->curl_close = http_close;
+ conn->curl_do = Curl_http;
+ conn->curl_done = Curl_http_done;
+ conn->curl_close = Curl_http_close;
}
else {
- conn->curl_do = ftp;
- conn->curl_done = ftp_done;
- conn->curl_connect = ftp_connect;
+ conn->curl_do = Curl_ftp;
+ conn->curl_done = Curl_ftp_done;
+ conn->curl_connect = Curl_ftp_connect;
}
conn->ppath++; /* don't include the initial slash */
@@ -1076,8 +1037,8 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
data->port = PORT_TELNET;
data->remote_port = PORT_TELNET;
- conn->curl_do = telnet;
- conn->curl_done = telnet_done;
+ conn->curl_do = Curl_telnet;
+ conn->curl_done = Curl_telnet_done;
}
else if (strequal(conn->proto, "DICT")) {
@@ -1085,16 +1046,16 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
if(!data->port)
data->port = PORT_DICT;
data->remote_port = PORT_DICT;
- conn->curl_do = dict;
- conn->curl_done = dict_done;
+ conn->curl_do = Curl_dict;
+ conn->curl_done = Curl_dict_done;
}
else if (strequal(conn->proto, "LDAP")) {
conn->protocol |= PROT_LDAP;
if(!data->port)
data->port = PORT_LDAP;
data->remote_port = PORT_LDAP;
- conn->curl_do = ldap;
- conn->curl_done = ldap_done;
+ conn->curl_do = Curl_ldap;
+ conn->curl_done = Curl_ldap_done;
}
else if (strequal(conn->proto, "FILE")) {
conn->protocol |= PROT_FILE;
@@ -1114,7 +1075,7 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
}
if(data->bits.use_netrc) {
- if(ParseNetrc(data->hostname, data->user, data->passwd)) {
+ if(Curl_parsenetrc(data->hostname, data->user, data->passwd)) {
infof(data, "Couldn't find host %s in the .netrc file, using defaults",
data->hostname);
}
@@ -1196,7 +1157,7 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
data->remote_port = data->port; /* it is the same port */
/* Connect to target host right on */
- conn->hp = GetHost(data, conn->name, &conn->hostent_buf);
+ conn->hp = Curl_gethost(data, conn->name, &conn->hostent_buf);
if(!conn->hp) {
failf(data, "Couldn't resolve host '%s'", conn->name);
return CURLE_COULDNT_RESOLVE_HOST;
@@ -1252,7 +1213,7 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
}
/* connect to proxy */
- conn->hp = GetHost(data, proxyptr, &conn->hostent_buf);
+ conn->hp = Curl_gethost(data, proxyptr, &conn->hostent_buf);
if(!conn->hp) {
failf(data, "Couldn't resolve proxy '%s'", proxyptr);
return CURLE_COULDNT_RESOLVE_PROXY;
@@ -1260,7 +1221,7 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
free(proxydup); /* free the duplicate pointer and not the modified */
}
- pgrsTime(data, TIMER_NAMELOOKUP);
+ Curl_pgrsTime(data, TIMER_NAMELOOKUP);
data->firstsocket = socket(AF_INET, SOCK_STREAM, 0);
@@ -1292,12 +1253,12 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
char myhost[256] = "";
unsigned long in;
- if(if2ip(data->device, myhost, sizeof(myhost))) {
- h = GetHost(data, myhost, &hostdataptr);
+ if(Curl_if2ip(data->device, myhost, sizeof(myhost))) {
+ h = Curl_gethost(data, myhost, &hostdataptr);
}
else {
if(strlen(data->device)>1) {
- h = GetHost(data, data->device, &hostdataptr);
+ h = Curl_gethost(data, data->device, &hostdataptr);
}
if(h) {
/* we know data->device is shorter than the myhost array */
@@ -1307,7 +1268,7 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
if(! *myhost) {
/* need to fix this
- h=GetHost(data,
+ h=Curl_gethost(data,
getmyhost(*myhost,sizeof(myhost)),
hostent_buf,
sizeof(hostent_buf));
@@ -1384,7 +1345,7 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
}
if(hostdataptr)
- free(hostdataptr); /* allocated by GetHost() */
+ free(hostdataptr); /* allocated by Curl_gethost() */
} /* end of device selection support */
#endif /* end of HAVE_INET_NTOA */
@@ -1443,32 +1404,35 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
char *authorization;
snprintf(data->buffer, BUFSIZE, "%s:%s",
data->proxyuser, data->proxypasswd);
- if(base64_encode(data->buffer, strlen(data->buffer),
- &authorization) >= 0) {
+ if(Curl_base64_encode(data->buffer, strlen(data->buffer),
+ &authorization) >= 0) {
data->ptr_proxyuserpwd =
- maprintf("Proxy-authorization: Basic %s\015\012", authorization);
+ aprintf("Proxy-authorization: Basic %s\015\012", authorization);
free(authorization);
}
}
if((conn->protocol&PROT_HTTP) || data->bits.httpproxy) {
if(data->useragent) {
- data->ptr_uagent = maprintf("User-Agent: %s\015\012", data->useragent);
+ data->ptr_uagent =
+ aprintf("User-Agent: %s\015\012", data->useragent);
}
}
if(conn->curl_connect) {
/* is there a connect() procedure? */
- conn->now = tvnow(); /* set this here for timeout purposes in the
- connect procedure, it is later set again for the
- progress meter purpose */
+
+ /* set start time here for timeout purposes in the
+ connect procedure, it is later set again for the
+ progress meter purpose */
+ conn->now = Curl_tvnow();
result = conn->curl_connect(conn);
if(result != CURLE_OK)
return result; /* pass back errors */
}
- pgrsTime(data, TIMER_CONNECT); /* we're connected */
+ Curl_pgrsTime(data, TIMER_CONNECT); /* we're connected */
- conn->now = tvnow(); /* time this *after* the connect is done */
+ conn->now = Curl_tvnow(); /* time this *after* the connect is done */
conn->bytecount = 0;
/* Figure out the ip-number and the first host name it shows: */
@@ -1560,7 +1524,7 @@ CURLcode curl_done(CURLconnect *c_connect)
else
result = CURLE_OK;
- pgrsDone(data); /* done with the operation */
+ Curl_pgrsDone(data); /* done with the operation */
conn->state = CONN_DONE;
diff --git a/lib/url.h b/lib/url.h
index b00699461..d2c80027b 100644
--- a/lib/url.h
+++ b/lib/url.h
@@ -22,6 +22,7 @@
*
* $Id$
*****************************************************************************/
-int GetLine(int sockfd, char *buf, struct UrlData *data);
+
+/* empty */
#endif
diff --git a/lib/version.c b/lib/version.c
index 6659f502e..9b2bbcded 100644
--- a/lib/version.c
+++ b/lib/version.c
@@ -33,9 +33,6 @@ char *curl_version(void)
{
static char version[200];
char *ptr;
-#if defined(USE_SSLEAY)
- static char sub[2];
-#endif
strcpy(version, LIBCURL_NAME " " LIBCURL_VERSION );
ptr=strchr(version, '\0');
@@ -47,17 +44,19 @@ char *curl_version(void)
(SSLEAY_VERSION_NUMBER>>20)&0xff,
(SSLEAY_VERSION_NUMBER>>12)&0xf);
#else
- if(SSLEAY_VERSION_NUMBER&0x0f) {
- sub[0]=(SSLEAY_VERSION_NUMBER&0x0f) + 'a' -1;
- }
- else
- sub[0]=0;
-
- sprintf(ptr, " (SSL %x.%x.%x%s)",
- (SSLEAY_VERSION_NUMBER>>12)&0xff,
- (SSLEAY_VERSION_NUMBER>>8)&0xf,
- (SSLEAY_VERSION_NUMBER>>4)&0xf, sub);
+ {
+ char sub[2];
+ if(SSLEAY_VERSION_NUMBER&0x0f) {
+ sub[0]=(SSLEAY_VERSION_NUMBER&0x0f) + 'a' -1;
+ }
+ else
+ sub[0]=0;
+ sprintf(ptr, " (SSL %x.%x.%x%s)",
+ (SSLEAY_VERSION_NUMBER>>12)&0xff,
+ (SSLEAY_VERSION_NUMBER>>8)&0xf,
+ (SSLEAY_VERSION_NUMBER>>4)&0xf, sub);
+ }
#endif
ptr=strchr(ptr, '\0');
#endif