summaryrefslogtreecommitdiff
path: root/nanoftp.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2003-03-05 16:45:40 +0000
committerDaniel Veillard <veillard@src.gnome.org>2003-03-05 16:45:40 +0000
commit6c73cb8b67f3332b6bd2b2ff0480482770713838 (patch)
tree31abe5845ee909e05b2b7e58037645ab2d6900ae /nanoftp.c
parent5f704afe98c584b7188aa0e4fbc9d9e68e0d7b1b (diff)
downloadlibxml2-6c73cb8b67f3332b6bd2b2ff0480482770713838.tar.gz
adding xmlNanoFTPDele() from Philipp Dunkel Daniel
* nanoftp.c include/libxml/nanoftp.h: adding xmlNanoFTPDele() from Philipp Dunkel Daniel
Diffstat (limited to 'nanoftp.c')
-rw-r--r--nanoftp.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/nanoftp.c b/nanoftp.c
index a179deb9..8df6f29d 100644
--- a/nanoftp.c
+++ b/nanoftp.c
@@ -1232,6 +1232,50 @@ xmlNanoFTPCwd(void *ctx, char *directory) {
}
/**
+ * 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
*