1 /*
2  *      Much of the FTP routines was inspired by the nanoftp.c module from
3  *      libxml2 (Copyright Daniel Veillard, 2003).  The routines have been
4  *      modified to fit the needs of the Motion project.
5  *
6  *      Copyright 2005, William M. Brack
7  *      This software is distributed under the GNU Public license Version 2.
8  *      See also the file 'COPYING'.
9  *
10  */
11 #ifndef _INCLUDE_NETCAM_FTP_H
12 #define _INCLUDE_NETCAM_FTP_H
13 
14 #define FTP_BUF_SIZE    1024
15 
16 typedef struct ftp_context {
17     char      *path;               /* the path within the URL */
18     char      *user;               /* user string */
19     char      *passwd;             /* passwd string */
20     struct    sockaddr_in ftp_address; /* the socket addr structure */
21     int       passive;             /* flag show passive/active mode used */
22     int       control_file_desc;   /* file descriptor for the control socket */
23     int       data_file_desc;      /* file descriptor for the data socket */
24     int       state;               /* WRITE / READ / CLOSED */
25     int       returnValue;         /* the protocol return value */
26 
27     /* buffer for data received from the control connection */
28     char      control_buffer[FTP_BUF_SIZE + 1];
29     int       control_buffer_index;
30     int       control_buffer_used;
31     int       control_buffer_answer;
32 } ftp_context, *ftp_context_pointer;
33 
34 
35 /* The public interface */
36 ftp_context_pointer ftp_new_context(void);
37 void ftp_free_context(ftp_context_pointer);
38 ftp_context_pointer ftpOpen(const char *);
39 int ftp_connect(netcam_context_ptr);
40 int ftp_send_type(ftp_context_pointer, const char);
41 int ftp_get_socket(ftp_context_pointer);
42 int ftp_read(ftp_context_pointer, void *, int);
43 int ftp_close(ftp_context_pointer);
44 int netcam_setup_ftp(netcam_context_ptr netcam, struct url_t *url);
45 
46 #endif
47