#include <netdb.h>
#endif
#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
+#include <fcntl.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
xmlNanoFTPInit(void) {
const char *env;
#ifdef _WINSOCKAPI_
- WSADATA wsaData;
+ WSADATA wsaData;
#endif
if (initialized)
/*
* Clear any existing data from the context
*/
- if (ctxt->protocol != NULL) {
+ if (ctxt->protocol != NULL) {
xmlFree(ctxt->protocol);
ctxt->protocol = NULL;
}
- if (ctxt->hostname != NULL) {
+ if (ctxt->hostname != NULL) {
xmlFree(ctxt->hostname);
ctxt->hostname = NULL;
}
- if (ctxt->path != NULL) {
+ if (ctxt->path != NULL) {
xmlFree(ctxt->path);
ctxt->path = NULL;
}
xmlFreeURI(uri);
return;
}
-
+
ctxt->protocol = xmlMemStrdup(uri->scheme);
ctxt->hostname = xmlMemStrdup(uri->server);
if (uri->path != NULL)
* @URL: The URL used to update the context
*
* Update an FTP context by parsing the URL and finding
- * new path it indicates. If there is an error in the
+ * new path it indicates. If there is an error in the
* protocol, hostname, port or other information, the
* error is raised. It indicates a new connection has to
* be established.
ctxt->path = NULL;
}
- if (uri->path == NULL)
+ if (uri->path == NULL)
ctxt->path = xmlMemStrdup("/");
else
ctxt->path = xmlMemStrdup(uri->path);
xmlNanoFTPScanProxy(const char *URL) {
xmlURIPtr uri;
- if (proxy != NULL) {
+ if (proxy != NULL) {
xmlFree(proxy);
proxy = NULL;
}
xmlFreeURI(uri);
return;
}
-
+
proxy = xmlMemStrdup(uri->server);
if (uri->port != 0)
proxyPort = uri->port;
* xmlNanoFTPParseResponse:
* @buf: the buffer containing the response
* @len: the buffer length
- *
+ *
* Parsing of the server answer, we just extract the code.
*
* returns 0 for errors
int val = 0;
if (len < 3) return(-1);
- if ((*buf >= '0') && (*buf <= '9'))
+ if ((*buf >= '0') && (*buf <= '9'))
val = val * 10 + (*buf - '0');
else
return(0);
buf++;
- if ((*buf >= '0') && (*buf <= '9'))
+ if ((*buf >= '0') && (*buf <= '9'))
val = val * 10 + (*buf - '0');
else
return(0);
buf++;
- if ((*buf >= '0') && (*buf <= '9'))
+ if ((*buf >= '0') && (*buf <= '9'))
val = val * 10 + (*buf - '0');
else
return(0);
buf++;
- if (*buf == '-')
+ if (*buf == '-')
return(-val);
return(val);
}
case -1:
__xmlIOErr(XML_FROM_FTP, 0, "select");
return(-1);
-
+
}
return(xmlNanoFTPReadResponse(ctx));
/* we assume it worked :-\ 1 is error for SITE command */
proxyType = 1;
break;
- }
+ }
if (proxyType == 1) {
closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
ctxt->controlFd = INVALID_SOCKET;
/* we assume it worked :-\ */
proxyType = 2;
return(0);
- }
+ }
if (ctxt->passwd == NULL)
snprintf(buf, sizeof(buf), "PASS anonymous@\r\n");
else
int res;
xmlNanoFTPInit();
- if (server == NULL)
+ if (server == NULL)
return(NULL);
if (port <= 0)
return(NULL);
* 450, 550
* 500, 501, 502, 421, 530
*/
-
+
snprintf(buf, sizeof(buf), "DELE %s\r\n", file);
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
ctxt->passive = 0;
}
}
- cur = &ctxt->controlBuf[ctxt->controlBufAnswer];
+ cur = &ctxt->controlBuf[ctxt->controlBufAnswer];
while (((*cur < '0') || (*cur > '9')) && *cur != '\0') cur++;
#ifdef SUPPORT_IP6
if ((ctxt->ftpAddr).ss_family == AF_INET6) {
}
}
return(ctxt->dataFd);
-
+
}
/**
* @callback: the user callback
* @userData: the user callback data
*
- * Parse at most one entry from the listing.
+ * Parse at most one entry from the listing.
*
* Returns -1 incase of error, the length of data parsed otherwise
*/
if (*cur == 0) return(0);
i = 0;
while (*cur != ' ') {
- if (i < 10)
+ if (i < 10)
attrib[i++] = *cur;
cur++;
if (*cur == 0) return(0);
if (*cur == 0) return(0);
i = 0;
while (*cur != ' ') {
- if (i < 10)
+ if (i < 10)
owner[i++] = *cur;
cur++;
if (*cur == 0) return(0);
if (*cur == 0) return(0);
i = 0;
while (*cur != ' ') {
- if (i < 10)
+ if (i < 10)
group[i++] = *cur;
cur++;
if (*cur == 0) return(0);
*
* Start to fetch the given ftp:// resource
*
- * Returns an FTP context, or NULL
+ * Returns an FTP context, or NULL
*/
void*
#ifdef STANDALONE
/************************************************************************
- * *
- * Basic test in Standalone mode *
- * *
+ * *
+ * Basic test in Standalone mode *
+ * *
************************************************************************/
static
void ftpList(void *userData, const char *filename, const char* attrib,
if (len <= 0) {
fclose((FILE*)userData);
return;
- }
+ }
fwrite(data, len, 1, (FILE*)userData);
}
if (xmlNanoFTPGet(ctxt, ftpData, (void *) output, tstfile) < 0)
xmlGenericError(xmlGenericErrorContext,
"Failed to get file\n");
-
+
}
xmlNanoFTPClose(ctxt);
xmlMemoryDump();