mirror of
https://github.com/darlinghq/darling-libxml2.git
synced 2024-12-14 15:58:51 +00:00
adding xmlNanoFTPDele() from Philipp Dunkel Daniel
* nanoftp.c include/libxml/nanoftp.h: adding xmlNanoFTPDele() from Philipp Dunkel Daniel
This commit is contained in:
parent
5f704afe98
commit
6c73cb8b67
@ -1,3 +1,8 @@
|
||||
Wed Mar 5 17:41:37 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* nanoftp.c include/libxml/nanoftp.h: adding xmlNanoFTPDele()
|
||||
from Philipp Dunkel
|
||||
|
||||
Wed Mar 5 10:57:09 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* xmlschemastype.c: made powten array static it should not be exported
|
||||
|
@ -93,6 +93,8 @@ int xmlNanoFTPCheckResponse (void *ctx);
|
||||
*/
|
||||
int xmlNanoFTPCwd (void *ctx,
|
||||
char *directory);
|
||||
int xmlNanoFTPDele (void *ctx,
|
||||
char *file);
|
||||
|
||||
int xmlNanoFTPGetConnection (void *ctx);
|
||||
int xmlNanoFTPCloseConnection(void *ctx);
|
||||
|
44
nanoftp.c
44
nanoftp.c
@ -1231,6 +1231,50 @@ xmlNanoFTPCwd(void *ctx, char *directory) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlNanoFTPDele:
|
||||
* @ctx: an FTP context
|
||||
* @file: a file or directory on the server
|
||||
*
|
||||
* Tries to delete an item (file or directory) from server
|
||||
*
|
||||
* Returns -1 incase of error, 1 if DELE worked, 0 if it failed
|
||||
*/
|
||||
|
||||
int
|
||||
xmlNanoFTPDele(void *ctx, char *file) {
|
||||
xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx;
|
||||
char buf[400];
|
||||
int len;
|
||||
int res;
|
||||
|
||||
/*
|
||||
* Expected response code for DELE:
|
||||
*
|
||||
* DELE
|
||||
* 250
|
||||
* 450, 550
|
||||
* 500, 501, 502, 421, 530
|
||||
*/
|
||||
|
||||
snprintf(buf, sizeof(buf), "DELE %s\r\n", file);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
len = strlen(buf);
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||
#endif
|
||||
res = send(ctxt->controlFd, buf, len, 0);
|
||||
if (res < 0) return(res);
|
||||
res = xmlNanoFTPGetResponse(ctxt);
|
||||
if (res == 4) {
|
||||
return(-1);
|
||||
}
|
||||
if (res == 2) return(1);
|
||||
if (res == 5) {
|
||||
return(0);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
/**
|
||||
* xmlNanoFTPGetConnection:
|
||||
* @ctx: an FTP context
|
||||
|
Loading…
Reference in New Issue
Block a user