History of Changes
+Daniel (5 January 2001)
+- The krb4 support was broken in the release. Fixed now.
+
+- Huge internal symbol rename operation.
+
Version 7.5.2
Daniel (4 January 2001)
Thus, the largest amount of code and complexity is in the library part.
+SYMBOLS
+=======
+ All symbols used internally must use a 'Curl_' prefix if they're used in
+ more than a single file. Single file symbols must be made static. Public
+ symbols must use a 'curl_' prefix. (There are exceptions, but they are
+ destined to change to this pattern in the future.)
+
CVS
===
NOTE: they return TRUE if the strings match *case insensitively*.
*/
-extern int (strequal)(const char *s1, const char *s2);
-extern int (strnequal)(const char *s1, const char *s2, size_t n);
+extern int (Curl_strequal)(const char *s1, const char *s2);
+extern int (Curl_strnequal)(const char *s1, const char *s2, size_t n);
+#define strequal(a,b) Curl_strequal(a,b)
+#define strnequal(a,b,c) Curl_strnequal(a,b,c)
/* external form function */
int curl_formparse(char *string,
#include <stdarg.h>
-int mprintf(const char *format, ...);
-int mfprintf(FILE *fd, const char *format, ...);
-int msprintf(char *buffer, const char *format, ...);
-int msnprintf(char *buffer, size_t maxlength, const char *format, ...);
-int mvprintf(const char *format, va_list args);
-int mvfprintf(FILE *fd, const char *format, va_list args);
-int mvsprintf(char *buffer, const char *format, va_list args);
-int mvsnprintf(char *buffer, size_t maxlength, const char *format, va_list args);
-char *maprintf(const char *format, ...);
-char *mvaprintf(const char *format, va_list args);
+int Curl_mprintf(const char *format, ...);
+int Curl_mfprintf(FILE *fd, const char *format, ...);
+int Curl_msprintf(char *buffer, const char *format, ...);
+int Curl_msnprintf(char *buffer, size_t maxlength, const char *format, ...);
+int Curl_mvprintf(const char *format, va_list args);
+int Curl_mvfprintf(FILE *fd, const char *format, va_list args);
+int Curl_mvsprintf(char *buffer, const char *format, va_list args);
+int Curl_mvsnprintf(char *buffer, size_t maxlength, const char *format, va_list args);
+char *Curl_maprintf(const char *format, ...);
+char *Curl_mvaprintf(const char *format, va_list args);
#ifdef _MPRINTF_REPLACE
-# define printf mprintf
-# define fprintf mfprintf
-# define sprintf msprintf
-# define snprintf msnprintf
-# define vprintf mvprintf
-# define vfprintf mvfprintf
-# define vsprintf mvsprintf
-# define vsnprintf mvsnprintf
+# define printf Curl_mprintf
+# define fprintf Curl_mfprintf
+# define sprintf Curl_msprintf
+# define snprintf Curl_msnprintf
+# define vprintf Curl_mvprintf
+# define vfprintf Curl_mvfprintf
+# define vsprintf Curl_mvsprintf
+# define vsnprintf Curl_mvsnprintf
+# define aprintf Curl_maprintf
+# define vaprintf Curl_mvaprintf
#endif
#endif /* H_MPRINTF */
#define SYNCH 242 /* for telfunc calls */
#ifdef TELCMDS
+static
char *telcmds[] = {
"EOF", "SUSP", "ABORT", "EOR",
"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
#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",
}
#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;
}
#endif
-int base64_decode(const char *str, void *data)
+int Curl_base64_decode(const char *str, void *data)
{
const char *p;
unsigned char *q;
#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
*
***************************************************************************/
-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];
* 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;
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! */
while(*lineptr && isspace((int)*lineptr))
lineptr++;
- cookie_add(c, FALSE, lineptr);
+ Curl_cookie_add(c, FALSE, lineptr);
}
}
if(fromfile)
*
****************************************************************************/
-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;
*
****************************************************************************/
-void cookie_freelist(struct Cookie *co)
+void Curl_cookie_freelist(struct Cookie *co)
{
struct Cookie *next;
if(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;
#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
#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;
*
* $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
#endif
#include "progress.h"
-#include "speedcheck.h"
#include "sendf.h"
#include <curl/types.h>
<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 */
* $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
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);
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);
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);
*
***************************************************************************/
-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)
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)
}
-char *MakeFormBoundary(void)
+char *Curl_FormBoundary(void)
{
char *retstring;
static int randomizer=0; /* this is just so that two boundaries within
}
/* Used from http.c */
-void FormFree(struct FormData *form)
+void Curl_FormFree(struct FormData *form)
{
struct FormData *next;
do {
} 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;
if(!post)
return NULL; /* no input => no output! */
- boundary = MakeFormBoundary();
+ boundary = Curl_FormBoundary();
/* Make the first line of the output */
AddFormDataf(&form,
/* 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,"
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;
}
/* 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;
}
}
- form=getFormData(httppost, &size);
+ form=Curl_getFormData(httppost, &size);
FormInit(&formread, 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
#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)
{
#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;
#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 */
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);
/* 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;
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;
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;
/* 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;
/* 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;
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;
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;
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;
/* 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;
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;
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;
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;
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;
/* 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;
}
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);
porttouse & 255);
}
- nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
+ nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
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;
}
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;
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;
}
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;
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;
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;
/* 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);
/* 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;
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;
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;
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;
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;
/* -- deal with the ftp server! -- */
/* argument is already checked for validity */
-CURLcode ftp(struct connectdata *conn)
+CURLcode Curl_ftp(struct connectdata *conn)
{
CURLcode retcode;
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);
+}
+
+
*
* $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
#include "memdebug.h"
#endif
+static
char *GetEnv(char *variable)
{
#ifdef WIN32
* $Id$
*****************************************************************************/
-/* Unix and Win32 getenv function call */
-char *GetEnv(char *variable);
+#include <curl/curl.h>
#endif
#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
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 ||
if ('\n' == *p)
p++; /* pass the \n byte */
- pgrsSetDownloadSize(data, conn->size);
+ Curl_pgrsSetDownloadSize(data, conn->size);
header = FALSE; /* no more header to parse! */
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;
}
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:")) &&
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;
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;
break;
}
writebytecount += nread;
- pgrsSetUploadCounter(data, (double)writebytecount);
+ Curl_pgrsSetUploadCounter(data, (double)writebytecount);
/* convert LF to CRLF if so asked */
if (data->crlf) {
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;
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;
contentlength-bytecount);
return CURLE_PARTIAL_FILE;
}
- if(pgrsUpdate(data))
+ if(Curl_pgrsUpdate(data))
return CURLE_ABORTED_BY_CALLBACK;
if(conn->bytecountp)
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);
/* --- 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;
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;
* $Id$
*****************************************************************************/
-struct hostent *GetHost(struct UrlData *data, char *hostname, char **bufp );
+struct hostent *Curl_gethost(struct UrlData *data,
+ char *hostname,
+ char **bufp);
#endif
#include "memdebug.h"
#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).
}
/*
- * 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;
return CURLE_OK;
}
-CURLcode http_connect(struct connectdata *conn)
+CURLcode Curl_http_connect(struct connectdata *conn)
{
struct UrlData *data;
CURLcode result;
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) {
/* 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;
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 */
}
-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 */
!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 */
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:")) {
(!(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:"))
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;
}
}
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;
}
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);
data->firstsocket,
&http->writebytecount);
if(result) {
- FormFree(http->sendit); /* free that whole lot */
+ Curl_FormFree(http->sendit); /* free that whole lot */
return result;
}
}
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 =
*****************************************************************************/
/* 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
#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;
#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
#include <string.h>
#include <krb.h>
+#include "ftp.h"
+#include "sendf.h"
+
/* The last #include file should be: */
#ifdef MALLOCDEBUG
#include "memdebug.h"
else
return n + strlen (src);
}
-
+#else
+size_t strlcpy (char *dst, const char *src, size_t dst_sz);
#endif
static int
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();
/*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);
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;
void krb_kauth(struct connectdata *conn)
{
- int ret;
- char buf[1024];
des_cblock key;
des_key_schedule schedule;
KTEXT_ST tkt, tktcopy;
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*/;
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);
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;***/
}
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);
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;
*
* $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 */
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)
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)
{
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");
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;
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;
}
-char *maprintf(const char *format, ...)
+char *Curl_maprintf(const char *format, ...)
{
va_list ap_save; /* argument pointer */
int retcode;
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;
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;
extern int fputc(int, FILE *);
-int mprintf(const char *format, ...)
+int Curl_mprintf(const char *format, ...)
{
int retcode;
va_list ap_save; /* argument pointer */
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 */
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);
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);
}
#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;
*
* $Id$
*****************************************************************************/
-int ParseNetrc(char *host,
- char *login,
- char *password);
+int Curl_parsenetrc(char *host,
+ char *login,
+ char *password);
#endif
#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;
/* 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)
*/
-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:
/* 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:
}
}
-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;
}
}
-void pgrsSetUploadSize(struct UrlData *data, double size)
+void Curl_pgrsSetUploadSize(struct UrlData *data, double size)
{
if(size > 0) {
data->progress.size_ul = size;
*/
-int pgrsUpdate(struct UrlData *data)
+int Curl_pgrsUpdate(struct UrlData *data)
{
struct timeval now;
int result;
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);
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: */
#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"
{ prot_private, "private" }
};
+#if 0
static const char *
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
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;
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)
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);
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;
}
static int
sec_prot_internal(struct connectdata *conn, int level)
{
- int ret;
char *p;
unsigned int s = 1048576;
size_t nread;
}
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'){
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'){
}
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'){
/* 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) {
/* 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);
}
/* 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 */
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 */
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;
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;
-}
-
* $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;
#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
#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. "
#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
* 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;
#endif
#ifdef USE_SSLEAY
+static
int cert_verify_callback(int ok, X509_STORE_CTX *ctx)
{
X509 *err_cert;
/* ====================================================== */
int
-UrgSSLConnect (struct UrlData *data)
+Curl_SSLConnect (struct UrlData *data)
{
#ifdef USE_SSLEAY
int err;
RAND_screen();
#else
int len;
- char *area = MakeFormBoundary();
+ char *area = Curl_FormBoundary();
if(!area)
return 3; /* out of memory */
}
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;
}
*
* $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
#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);
#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);
*
* $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
#define TELOPTS
#define TELCMDS
-#define SLC_NAMES
#include "arpa_telnet.h"
#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 */
static int himq[256];
static int him_preferred[256];
+static
void init_telnet(struct UrlData *data)
{
telrcv_state = TS_DATA;
printoption(data, "SENT", cmd, option);
}
+static
void set_remote_option(struct UrlData *data, int option, int newstate)
{
if(newstate == YES)
}
}
+static
void rec_will(struct UrlData *data, int option)
{
switch(him[option])
}
}
+static
void rec_wont(struct UrlData *data, int option)
{
switch(him[option])
}
}
+static
void rec_do(struct UrlData *data, int option)
{
switch(us[option])
break;
}
}
-
+
+static
void rec_dont(struct UrlData *data, int option)
{
switch(us[option])
return;
}
+static
void telrcv(struct UrlData *data,
unsigned char *inbuf, /* Data received from socket */
int count) /* Number of bytes received */
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:
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:
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:
}
}
+static
void telwrite(struct UrlData *data,
unsigned char *buffer, /* Data to write */
int count) /* Number of bytes to write */
}
}
-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;
*
* $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
#endif
#endif
-struct timeval tvnow ()
+struct timeval Curl_tvnow ()
{
struct timeval now;
#ifdef HAVE_GETTIMEOFDAY
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;
}
#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
#include "if2ip.h"
#include "download.h"
#include "sendf.h"
-#include "speedcheck.h"
#include "getpass.h"
#include "progress.h"
#include "cookie.h"
/* the URL is allocated, free it! */
free(data->url);
- cookie_cleanup(data->cookies);
+ Curl_cookie_cleanup(data->cookies);
free(data);
return CURLE_OK;
}
+static
int my_getpass(void *clientp, char *prompt, char* buffer, int buflen )
{
char *retbuf;
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:
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) */
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 */
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) {
*/
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;
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
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!");
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;
!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 */
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")) {
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;
}
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);
}
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;
}
/* 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;
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);
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 */
if(! *myhost) {
/* need to fix this
- h=GetHost(data,
+ h=Curl_gethost(data,
getmyhost(*myhost,sizeof(myhost)),
hostent_buf,
sizeof(hostent_buf));
}
if(hostdataptr)
- free(hostdataptr); /* allocated by GetHost() */
+ free(hostdataptr); /* allocated by Curl_gethost() */
} /* end of device selection support */
#endif /* end of HAVE_INET_NTOA */
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: */
else
result = CURLE_OK;
- pgrsDone(data); /* done with the operation */
+ Curl_pgrsDone(data); /* done with the operation */
conn->state = CONN_DONE;
*
* $Id$
*****************************************************************************/
-int GetLine(int sockfd, char *buf, struct UrlData *data);
+
+/* empty */
#endif
{
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');
(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
/* we already have a string, we append this one
with a separating &-letter */
char *oldpost=config->postfields;
- config->postfields=maprintf("%s&%s", oldpost, postdata);
+ config->postfields=aprintf("%s&%s", oldpost, postdata);
free(oldpost);
free(postdata);
}