1 /*
2  *  Download a file from storage or network
3  *
4  *  Copyright (C) 2015 Jaroslav Kysela
5  *
6  *  This program is free software: you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation, either version 3 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __DOWNLOAD__
21 #define __DOWNLOAD__
22 
23 #include "http.h"
24 
25 typedef struct download {
26   int   subsys;
27   char *url;
28   void *aux;
29   int   ssl_peer_verify;
30   int (*process)(void *aux, const char *last_url, const char *host_url,
31                  char *data, size_t len);
32   void (*stop)(void *aux);
33   /* internal members */
34   http_client_t *http_client;
35   mtimer_t       fetch_timer;
36   mtimer_t       pipe_read_timer;
37   sbuf_t         pipe_sbuf;
38   int            pipe_fd;
39   pid_t          pipe_pid;
40 } download_t;
41 
42 void download_init ( download_t *dn, int subsys );
43 void download_start( download_t *dn, const char *url, void *aux );
44 void download_done ( download_t *dn );
45 
46 #endif /* __DOWNLOAD__ */
47