xref: /dragonfly/lib/libftpio/ftpio.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
1 #ifndef _FTP_H_INCLUDE
2 #define _FTP_H_INCLUDE
3 
4 #include <sys/types.h>
5 #include <sys/cdefs.h>
6 #include <stdio.h>
7 #include <time.h>
8 
9 /*
10  * ----------------------------------------------------------------------------
11  * "THE BEER-WARE LICENSE" (Revision 42):
12  * <phk@login.dknet.dk> wrote this file.  As long as you retain this notice you
13  * can do whatever you want with this stuff. If we meet some day, and you think
14  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
15  * ----------------------------------------------------------------------------
16  *
17  * Major Changelog:
18  *
19  * Jordan K. Hubbard
20  * 17 Jan 1996
21  *
22  * Turned inside out. Now returns xfers as new file ids, not as a special
23  * `state' of FTP_t
24  *
25  * $FreeBSD: src/lib/libftpio/ftpio.h,v 1.15.2.1 2000/07/15 07:24:03 kris Exp $
26  * $DragonFly: src/lib/libftpio/ftpio.h,v 1.3 2004/08/16 13:51:21 joerg Exp $
27  */
28 
29 /* Internal housekeeping data structure for FTP sessions */
30 typedef struct {
31     enum { init, isopen, quit } con_state;
32     int             fd_ctrl;
33     int             addrtype;
34     char  *host;
35     char  *file;
36     int             error;
37     int             is_binary;
38     int             is_passive;
39     int             is_verbose;
40 } *FTP_t;
41 
42 /* Structure we use to match FTP error codes with readable strings */
43 struct ftperr {
44   const int         num;
45   const char        *string;
46 };
47 
48 __BEGIN_DECLS
49 extern struct       ftperr ftpErrList[];
50 extern int          const ftpErrListLength;
51 
52 /* Exported routines - deal only with FILE* type */
53 extern FILE         *ftpLogin(const char *host, const char *user,
54                                 const char *passwd, int port, int verbose,
55                                 int *retcode);
56 extern int          ftpChdir(FILE *fp, char *dir);
57 extern int          ftpErrno(FILE *fp);
58 extern off_t        ftpGetSize(FILE *fp, const char *file);
59 extern FILE         *ftpGet(FILE *fp, const char *file, off_t *seekto);
60 extern FILE         *ftpPut(FILE *fp, const char *file);
61 extern int          ftpAscii(FILE *fp);
62 extern int          ftpBinary(FILE *fp);
63 extern int          ftpPassive(FILE *fp, int status);
64 extern void         ftpVerbose(FILE *fp, int status);
65 extern FILE         *ftpGetURL(const char *url, const char *user,
66                                  const char *passwd, int *retcode);
67 extern FILE         *ftpPutURL(const char *url, const char *user,
68                                  const char *passwd, int *retcode);
69 extern time_t       ftpGetModtime(FILE *fp, const char *file);
70 extern const        char *ftpErrString(int error);
71 extern FILE         *ftpLoginAf(const char *host, int af, const char *user,
72                                   const char *passwd, int port, int verbose,
73                                   int *retcode);
74 extern FILE         *ftpGetURLAf(const char *url, int af, const char *user,
75                                    const char *passwd, int *retcode);
76 extern FILE         *ftpPutURLAf(const char *url, int af, const char *user,
77                                    const char *passwd, int *retcode);
78 __END_DECLS
79 
80 #endif    /* _FTP_H_INCLUDE */
81