propagator/test_common.c
Alexey Sheplyakov b212b3d031 ftp_get_filesize: handle directories with "many" files
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).
2021-10-07 13:21:37 +04:00

15 lines
296 B
C

#ifndef PROPAGATOR_TEST_COMMON_H
#define PROPAGATOR_TEST_COMMON_H
#include <stdio.h>
#include <stdarg.h>
void log_message(const char *msg, ...) {
va_list args;
va_start(args, msg);
vfprintf(stderr, msg, args);
fprintf(stderr, "\n");
fflush(stderr);
}
#endif /* PROPAGATOR_TEST_COMMON_H */