summaryrefslogtreecommitdiff
path: root/ext/ftp/ftp.h
diff options
context:
space:
mode:
authorAndrew Skalski <askalski@php.net>1999-09-20 14:10:25 +0000
committerAndrew Skalski <askalski@php.net>1999-09-20 14:10:25 +0000
commit85ca1dfb0856579548339210235a4d5bdf934438 (patch)
tree2c5b291ac287a0c6d096037e2bb8907edbf23e05 /ext/ftp/ftp.h
parentfffbcf529736810b542fd0b3b62229e3ab15902e (diff)
downloadphp-git-85ca1dfb0856579548339210235a4d5bdf934438.tar.gz
Replaced ftplib because of incompatible license.
Diffstat (limited to 'ext/ftp/ftp.h')
-rw-r--r--ext/ftp/ftp.h149
1 files changed, 121 insertions, 28 deletions
diff --git a/ext/ftp/ftp.h b/ext/ftp/ftp.h
index 1a71ba70a1..f9a2cf549c 100644
--- a/ext/ftp/ftp.h
+++ b/ext/ftp/ftp.h
@@ -1,38 +1,131 @@
-/* $Id$ */
+/*
+ +----------------------------------------------------------------------+
+ | PHP HTML Embedded Scripting Language Version 3.0 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
+ +----------------------------------------------------------------------+
+ | This program is free software; you can redistribute it and/or modify |
+ | it under the terms of one of the following licenses: |
+ | |
+ | A) the GNU General Public License as published by the Free Software |
+ | Foundation; either version 2 of the License, or (at your option) |
+ | any later version. |
+ | |
+ | B) the PHP License as published by the PHP Development Team and |
+ | included in the distribution in the file: LICENSE |
+ | |
+ | This program is distributed in the hope that it will be useful, |
+ | but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+ | GNU General Public License for more details. |
+ | |
+ | You should have received a copy of both licenses referred to here. |
+ | If you did not, or have any questions about PHP licensing, please |
+ | contact core@php.net. |
+ +----------------------------------------------------------------------+
+ | Authors: |
+ | Andrew Skalski <askalski@chek.com> |
+ +----------------------------------------------------------------------+
+ */
-#ifndef _INCLUDED_FTP_H
-#define _INCLUDED_FTP_H
+#ifndef _FTP_H
+#define _FTP_H
-#if COMPILE_DL
-#undef HAVE_FTP
-#define HAVE_FTP 1
-#endif
+#include <stdio.h>
+#include <netinet/in.h>
+
+
+#define FTP_BUFSIZE 4096
+
+typedef enum ftptype {
+ FTPTYPE_ASCII,
+ FTPTYPE_IMAGE,
+} ftptype_t;
+
+typedef struct ftpbuf
+{
+ FILE *fp; /* control connection */
+ struct in_addr localaddr; /* local inet address */
+ int resp; /* last response code */
+ char inbuf[FTP_BUFSIZE]; /* last response text */
+ char *pwd; /* cached pwd */
+ char *syst; /* cached system type */
+ ftptype_t type; /* current transfer type */
+} ftpbuf_t;
+
+typedef struct databuf
+{
+ int listener; /* listener socket */
+ FILE *fp; /* data connection */
+ ftptype_t type; /* transfer type */
+} databuf_t;
+
+
+/* open a FTP connection, returns ftpbuf (NULL on error)
+ * port is the ftp port in network byte order, or 0 for the default
+ */
+ftpbuf_t* ftp_open(const char *host, short port);
+
+/* quits from the ftp session (it still needs to be closed)
+ * return true on success, false on error
+ */
+int ftp_quit(ftpbuf_t *ftp);
+
+/* frees up any cached data held in the ftp buffer */
+void ftp_gc(ftpbuf_t *ftp);
+
+/* close the FTP connection and return NULL */
+ftpbuf_t* ftp_close(ftpbuf_t *ftp);
+
+/* logs into the FTP server, returns true on success, false on error */
+int ftp_login(ftpbuf_t *ftp, const char *user, const char *pass);
+
+/* reinitializes the connection, returns true on success, false on error */
+int ftp_reinit(ftpbuf_t *ftp);
+
+/* returns the remote system type (NULL on error) */
+const char* ftp_syst(ftpbuf_t *ftp);
+
+/* returns the present working directory (NULL on error) */
+const char* ftp_pwd(ftpbuf_t *ftp);
+
+/* changes directories, return true on success, false on error */
+int ftp_chdir(ftpbuf_t *ftp, const char *dir);
+
+/* changes to parent directory, return true on success, false on error */
+int ftp_cdup(ftpbuf_t *ftp);
-#if HAVE_FTP
+/* creates a directory, return the directory name on success, NULL on error.
+ * the return value must be freed
+ */
+char* ftp_mkdir(ftpbuf_t *ftp, const char *dir);
-extern php3_module_entry php3_ftp_module_entry;
-#define php3_ftp_module_ptr &php3_ftp_module_entry
+/* removes a directory, return true on success, false on error */
+int ftp_rmdir(ftpbuf_t *ftp, const char *dir);
-extern PHP_MINIT_FUNCTION(ftp);
+/* returns a NULL-terminated array of filenames in the given path
+ * or NULL on error. the return array must be freed (but don't
+ * free the array elements)
+ */
+char** ftp_nlist(ftpbuf_t *ftp, const char *path);
-PHP_FUNCTION(ftp_connect);
-PHP_FUNCTION(ftp_login);
-PHP_FUNCTION(ftp_pwd);
-PHP_FUNCTION(ftp_cdup);
-PHP_FUNCTION(ftp_chdir);
-PHP_FUNCTION(ftp_mkdir);
-PHP_FUNCTION(ftp_rmdir);
-PHP_FUNCTION(ftp_nlist);
-PHP_FUNCTION(ftp_listraw);
-PHP_FUNCTION(ftp_systype);
-PHP_FUNCTION(ftp_get);
-PHP_FUNCTION(ftp_put);
-PHP_FUNCTION(ftp_quit);
+/* returns a NULL-terminated array of lines returned by the ftp
+ * LIST command for the given path or NULL on error. the return
+ * array must be freed (but don't
+ * free the array elements)
+ */
+char** ftp_list(ftpbuf_t *ftp, const char *path);
-#define phpext_ftp_ptr php3_ftp_module_ptr
+/* retrieves a file and saves its contents to outfp
+ * returns true on success, false on error
+ */
+int ftp_get(ftpbuf_t *ftp, FILE *outfp, const char *path,
+ ftptype_t type);
-#else
-#define php3_ftp_module_ptr NULL
-#endif /* HAVE_FTP */
+/* stores the data from infp as a file on the remote server
+ * returns true on success, false on error
+ */
+int ftp_put(ftpbuf_t *ftp, const char *path, FILE *infp,
+ ftptype_t type);
#endif