nanoftp.c revision 38ae7e4efe803ea78b6499cd05a394db32623e41
137N/A#define STANDALONE
137N/A#define HAVE_STDLIB_H
137N/A#define HAVE_UNISTD_H
137N/A#define HAVE_SYS_SOCKET_H
137N/A#define HAVE_NETINET_IN_H
137N/A#define HAVE_NETDB_H
137N/A#define HAVE_SYS_TIME_H
137N/A#define NEED_SOCKETS
137N/A#ifdef LIBXML_FTP_ENABLED
137N/A#ifdef HAVE_STDLIB_H
137N/A#ifdef HAVE_UNISTD_H
137N/A#ifdef HAVE_SYS_SOCKET_H
137N/A#ifdef HAVE_NETINET_IN_H
137N/A#ifdef HAVE_ARPA_INET_H
137N/A#ifdef HAVE_NETDB_H
137N/A#ifdef HAVE_FCNTL_H
137N/A#ifdef HAVE_ERRNO_H
137N/A#ifdef HAVE_SYS_TIME_H
137N/A#ifdef HAVE_SYS_SELECT_H
137N/A#ifdef HAVE_SYS_SOCKET_H
137N/A#ifdef HAVE_SYS_TYPES_H
137N/A#ifdef HAVE_STRINGS_H
#ifdef STANDALONE
#ifndef DEBUG_FTP
#define _WINSOCKAPI_
#include <wsockcompat.h>
#include <winsock2.h>
#define XML_SOCKLEN_T unsigned int
#ifndef _WINSOCKAPI_
#ifndef __BEOS__
#define SOCKET int
#ifdef __BEOS__
#ifndef PF_INET
#ifdef _AIX
#ifdef HAVE_BROKEN_SS_FAMILY
#ifndef XML_SOCKLEN_T
#define XML_SOCKLEN_T unsigned int
typedef struct xmlNanoFTPCtxt {
#ifdef SUPPORT_IP6
int controlBufIndex;
int controlBufUsed;
int controlBufAnswer;
static int initialized = 0;
#ifdef SUPPORT_IP6
int have_ipv6(void) {
close (s);
xmlNanoFTPInit(void) {
const char *env;
#ifdef _WINSOCKAPI_
if (initialized)
#ifdef _WINSOCKAPI_
xmlNanoFTPCleanup(void) {
#ifdef _WINSOCKAPI_
if (initialized)
WSACleanup();
initialized = 0;
if (host)
if (user)
if (passwd)
char *cptr;
* Should be like ftp://myproxy/ or ftp://myproxy:3128/
proxyPort = 0;
#ifdef DEBUG_FTP
char *unescaped;
return(NULL);
return(ret);
int val = 0;
buf++;
buf++;
buf++;
return(-val);
return(val);
int len;
int size;
#ifdef DEBUG_FTP
#ifdef DEBUG_FTP
#ifdef DEBUG_FTP
if (size == 0) {
#ifdef DEBUG_FTP
size, 0)) < 0) {
#ifdef DEBUG_FTP
return(len);
int len;
if (len < 0) {
#ifdef DEBUG_FTP
if (cur > 0) {
goto get_more;
#ifdef DEBUG_FTP
#ifdef DEBUG_FTP
int res;
return(res);
int len;
int res;
#ifdef DEBUG_FTP
if (res < 0) {
return(res);
int len;
int res;
#ifdef DEBUG_FTP
if (res < 0) {
return(res);
#ifdef DEBUG_FTP
xmlGenericError(xmlGenericErrorContext, "%s", buf); /* Just to be consistent, even though we know it can't have a % in it */
if (res < 0) {
return(res);
int port;
int res;
if (proxy) {
if (port == 0)
#ifdef SUPPORT_IP6
if (have_ipv6 ()) {
if (proxy) {
if (!tmp) {
if (result)
if (proxy)
addrlen) < 0) {
if (proxy) {
int len;
#ifdef DEBUG_FTP
if (res < 0) {
return(res);
switch (res) {
#ifdef DEBUG_FTP
if (res < 0) {
return(res);
switch (proxyType) {
#ifdef DEBUG_FTP
if (res < 0) {
return(res);
#ifdef DEBUG_FTP
if (res < 0) {
return(res);
#ifdef DEBUG_FTP
if (res < 0) {
return(res);
if (res < 0) {
switch (res) {
if (res < 0) {
switch (res) {
int res;
return(NULL);
if (port <= 0)
return(NULL);
if (port != 0)
if (res < 0) {
return(NULL);
return(ctxt);
int len;
int res;
#ifdef DEBUG_FTP
if (res < 0) {
return(res);
int len;
int res;
#ifdef DEBUG_FTP
if (res < 0) {
return(res);
int len, i;
int res;
#ifdef SUPPORT_IP6
#ifdef SUPPORT_IP6
#ifdef SUPPORT_IP6
#ifdef DEBUG_FTP
if (res < 0) {
return(res);
#ifdef SUPPORT_IP6
memcpy (&((struct sockaddr_in6 *)&dataAddr)->sin6_addr, &((struct sockaddr_in6 *)&ctxt->ftpAddr)->sin6_addr, sizeof(struct in6_addr));
#ifdef SUPPORT_IP6
#ifdef SUPPORT_IP6
#ifdef DEBUG_FTP
if (res < 0) {
return(res);
int res;
if (res < 0) {
#ifdef DEBUG_FTP
if (res == 0) {
#ifdef DEBUG_FTP
int year = 0;
int minute = 0;
int hour = 0;
int day = 0;
unsigned long size = 0;
int links = 0;
cur++;
cur++;
if (*cur == 0) return(0);
cur++;
if (*cur == 0) return(0);
if (*cur == 0) return(0);
if (*cur == 0) return(0);
cur++;
if (*cur == 0) return(0);
owner[i] = 0;
if (*cur == 0) return(0);
cur++;
if (*cur == 0) return(0);
group[i] = 0;
if (*cur == 0) return(0);
if (*cur == 0) return(0);
cur++;
if (*cur == 0) return(0);
month[i] = 0;
if (*cur == 0) return(0);
if (*cur == 0) return(0);
if (*cur == 0) return(0);
cur++;
if (*cur == 0) return(0);
filename[i] = 0;
cur++;
const char *filename) {
#ifdef DEBUG_FTP
if (res < 0) {
return(res);
return(-res);
if (res < 0) {
#ifdef DEBUG_FTP
if (res == 0) {
if (res < 0) {
#ifdef DEBUG_FTP
base = 0;
} while (res > 0);
} while (len != 0);
#ifdef DEBUG_FTP
if (res < 0) {
return(res);
return(-res);
#ifdef DEBUG_FTP
if (res < 0) {
return(res);
return(-res);
const char *filename) {
if (res < 0) {
#ifdef DEBUG_FTP
if (res == 0) {
if (res < 0) {
} while (len != 0);
if (len <= 0) return(0);
if (len <= 0) {
if (len < 0)
#ifdef DEBUG_FTP
return(len);
int sock;
return(NULL);
if (sock < 0) {
return(NULL);
return(ctxt);
#ifdef STANDALONE
if (len <= 0) {
void *ctxt;
exit(0);
#ifdef STANDALONE
#include <stdio.h>
#define bottom_nanoftp
#include "elfgcchack.h"