1 /***********************************************************************
2  *    ftp.h: for downloading via ftp (File Transfer Protocol)
3  ***********************************************************************
4  * Copyright (C) 2007 metro <me_t_ro@yahoo.com>
5  *
6  * This file is part of msdl, media stream downloader
7  *
8  * This is just an very simple ftp implementation.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *
25  ***********************************************************************/
26 
27 
28 #ifndef __FTP_H__
29 #define __FTP_H__
30 
31 
32 struct ftp_ctrl_t {
33     int mode;            /* active/passive  mode       */
34     int command_sock;
35     int data_wait_sock;  /* not used in passive mode   */
36     int data_sock;
37     uint64_t file_size;  /* file size                  */
38     uint64_t down_size;  /* size alrady downlaoded     */
39     uint64_t transfer_force_end_size; /**/
40 };
41 
42 
43 struct ftp_response_t {  /* this is not a header       */
44     int num_lines;
45     struct list_h *lines;
46 };
47 
48 
49 enum { /* FTP modes, default is PASSIVE_FTP */
50     ACTIVE_FTP,
51     PASSIVE_FTP,
52 };
53 
54 
55 struct ftp_ctrl_t *new_ftp_ctrl_t(void);
56 void free_ftp_ctrl_t(struct ftp_ctrl_t *fctrl);
57 struct ftp_response_t *new_ftp_response_t(void);
58 void free_ftp_response_t(struct ftp_response_t *fres);
59 
60 
61 
62 int ftp_streaming_start(struct stream_t *stream);
63 int ftp_streaming_read(struct stream_t *stream,uint8_t *buffer, size_t buffer_size);
64 void ftp_streaming_close(struct stream_t *stream);
65 struct stream_t *ftp_streaming_init();
66 
67 
68 
69 #endif /* __FTP_H__ */
70 
71