b212b3d031
So propagator can download ISO from a directory with "many" [1] files and display a nice progress bar. [1] In fact 12 of them or so is enough. The `LIST` ftp command produces quite a lot of noise^W data. For instance, this single entry: -rw-r--r-- 1 ftp ftp 1862483968 Jul 28 00:23 alt-p10-gnome3-20210728-aarch64.iso takes 95 bytes, hence it takes only 21 files to overflow the fixed size 2000 bytes buffer, so `ftp_get_filesize` is unable to figure out the size of 22nd and subsequent files. Process the output of the `LIST` command line by line to avoid the problem. While at it avoid buffer underruns (i.e. when the server reply contains no whitespace at all).
63 lines
2.0 KiB
C
63 lines
2.0 KiB
C
/*
|
|
* Guillaume Cottenceau (gc@mandrakesoft.com)
|
|
*
|
|
* Copyright 2000 MandrakeSoft
|
|
*
|
|
* This software may be freely redistributed under the terms of the GNU
|
|
* public license.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
*
|
|
*/
|
|
|
|
/*
|
|
* Portions from Erik Troan <ewt@redhat.com> and Matt Wilson <msw@redhat.com>
|
|
*
|
|
* Copyright 1999 Red Hat, Inc.
|
|
*
|
|
*/
|
|
|
|
#ifndef _URL_H_
|
|
#define _URL_H_
|
|
|
|
int ftp_open_connection(char * host, char * name, char * password, char * proxy);
|
|
int ftp_start_download(int sock, char * remotename, unsigned long * size);
|
|
int ftp_end_data_command(int sock);
|
|
|
|
int http_download_file(char * hostname, char * remotename, unsigned long * size);
|
|
|
|
/**
|
|
* @brief split the absolute path into directory and file name
|
|
* @param abspath the path to operate on
|
|
* @param dirp, pointer to directory name, will be set by this function
|
|
* @param namep, pointer to file name, will be set by this function
|
|
* @returns -1 on error, otherwise 0
|
|
*
|
|
* @note Memory for directory and file name is allocated by this
|
|
* function. Freeing it is the responsibility of the caller.
|
|
* @note dirp and namep are NOT altered on error
|
|
* @note On error the caller don't have to cleanup dirp, namep
|
|
*
|
|
* XXX: dirname and basename in libc are too tricky (can change
|
|
* the argument, return pointers that can't be freed, etc),
|
|
* hence this function
|
|
*/
|
|
int basename_dirname(const char *abspath, char **dirp, char **namep);
|
|
|
|
#define FTPERR_BAD_SERVER_RESPONSE -1
|
|
#define FTPERR_SERVER_IO_ERROR -2
|
|
#define FTPERR_SERVER_TIMEOUT -3
|
|
#define FTPERR_BAD_HOST_ADDR -4
|
|
#define FTPERR_BAD_HOSTNAME -5
|
|
#define FTPERR_FAILED_CONNECT -6
|
|
#define FTPERR_FILE_IO_ERROR -7
|
|
#define FTPERR_PASSIVE_ERROR -8
|
|
#define FTPERR_FAILED_DATA_CONNECT -9
|
|
#define FTPERR_FILE_NOT_FOUND -10
|
|
#define FTPERR_FILE2BIG -11
|
|
#define FTPERR_UNKNOWN -100
|
|
|
|
#endif
|