From fc62adc264baaa3e2217271832563346f6a3920a Mon Sep 17 00:00:00 2001 From: arai Date: Sun, 20 Jul 2003 18:26:24 +0000 Subject: [PATCH] * src/prototypes.h: updated. * src/cproto.sh: added `indicator.c'. * src/Makefile.am: ditto. * src/indicator.c: separated from append.c. * src/append.c: ditto. * src/lha.h: ditto. * src/lha_macro.h: ditto. git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/lha/lha/trunk@719 6a8cc165-1e22-0410-a132-eb4e3f353aba --- src/Makefile.am | 6 +-- src/append.c | 102 ------------------------------------------------ src/cproto.sh | 2 +- src/indicator.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lha.h | 6 --- src/lha_macro.h | 2 - src/prototypes.h | 9 +++-- 7 files changed, 125 insertions(+), 118 deletions(-) create mode 100644 src/indicator.c diff --git a/src/Makefile.am b/src/Makefile.am index 751ce9d..23e625e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,8 +1,8 @@ ## Process this file with automake to produce Makefile.in bin_PROGRAMS = lha -lha_SOURCES = append.c bitio.c crcio.c dhuf.c extract.c header.c huf.c larc.c \ - lha.h lha_macro.h prototypes.h lhadd.c lharc.c lhext.c lhlist.c \ - maketbl.c maketree.c patmatch.c shuf.c slide.c util.c +lha_SOURCES = append.c bitio.c crcio.c dhuf.c extract.c header.c huf.c \ + indicator.c larc.c lha.h lha_macro.h prototypes.h lhadd.c lharc.c \ + lhext.c lhlist.c maketbl.c maketree.c patmatch.c shuf.c slide.c util.c lha_LDADD = @LIBOBJS@ EXTRA_DIST = lhdir.h fnmatch.h AM_CPPFLAGS=$(DEF_KCODE) $(SUPPORT_LZHUFF_METHOD) diff --git a/src/append.c b/src/append.c index 26b4b33..26ec62e 100644 --- a/src/append.c +++ b/src/append.c @@ -8,9 +8,6 @@ /* ------------------------------------------------------------------------ */ #include "lha.h" -static size_t reading_size; - -/* ------------------------------------------------------------------------ */ int encode_lzhuf(infp, outfp, size, original_size_var, packed_size_var, name, hdr_method) @@ -52,102 +49,3 @@ encode_lzhuf(infp, outfp, size, original_size_var, packed_size_var, (int) ((*packed_size_var * 100L) / *original_size_var)); return crc; } -/* ------------------------------------------------------------------------ */ -void -start_indicator(name, size, msg, def_indicator_threshold) - char *name; - size_t size; - char *msg; - long def_indicator_threshold; -{ -#ifdef NEED_INCREMENTAL_INDICATOR - long i; - int m; -#endif - - if (quiet) - return; - -#ifdef NEED_INCREMENTAL_INDICATOR - switch (quiet_mode) { - case 0: - m = MAX_INDICATOR_COUNT - strlen(name); - if (m < 1) /* Bug Fixed by N.Watazaki */ - m = 3; /* (^_^) */ - printf("\r%s\t- %s : ", name, msg); - indicator_threshold = - ((size + (m * def_indicator_threshold - 1)) / - (m * def_indicator_threshold) * - def_indicator_threshold); - if (indicator_threshold) - i = ((size + (indicator_threshold - 1)) / indicator_threshold); - else - i = 0; - while (i--) - putchar('.'); - indicator_count = 0; - printf("\r%s\t- %s : ", name, msg); - break; - case 1: - printf("\r%s :", name); - break; - } -#else - printf("%s\t- ", name); -#endif - fflush(stdout); - reading_size = 0L; -} -/* ------------------------------------------------------------------------ */ -#ifdef NEED_INCREMENTAL_INDICATOR -void -put_indicator(count) - long int count; -{ - reading_size += count; - if (!quiet && indicator_threshold) { - while (reading_size > indicator_count) { - putchar('o'); - fflush(stdout); - indicator_count += indicator_threshold; - } - } -} -#endif - -/* ------------------------------------------------------------------------ */ -void -finish_indicator2(name, msg, pcnt) - char *name; - char *msg; - int pcnt; -{ - if (quiet) - return; - - if (pcnt > 100) - pcnt = 100; /* (^_^) */ -#ifdef NEED_INCREMENTAL_INDICATOR - printf("\r%s\t- %s(%d%%)\n", name, msg, pcnt); -#else - printf("%s\n", msg); -#endif - fflush(stdout); -} - -/* ------------------------------------------------------------------------ */ -void -finish_indicator(name, msg) - char *name; - char *msg; -{ - if (quiet) - return; - -#ifdef NEED_INCREMENTAL_INDICATOR - printf("\r%s\t- %s\n", name, msg); -#else - printf("%s\n", msg); -#endif - fflush(stdout); -} diff --git a/src/cproto.sh b/src/cproto.sh index 327cba0..b8e87f4 100644 --- a/src/cproto.sh +++ b/src/cproto.sh @@ -19,7 +19,7 @@ CPPFLAGS='-DSTDC_HEADERS=1 # `interrupt' is the reserved word for cproto. SOURCES='append.c bitio.c crcio.c dhuf.c extract.c header.c - huf.c larc.c lhadd.c lharc.c lhext.c + huf.c indicator.c larc.c lhadd.c lharc.c lhext.c lhlist.c maketbl.c maketree.c patmatch.c shuf.c slide.c util.c ' diff --git a/src/indicator.c b/src/indicator.c new file mode 100644 index 0000000..733b786 --- /dev/null +++ b/src/indicator.c @@ -0,0 +1,116 @@ +/* ------------------------------------------------------------------------ */ +/* LHa for UNIX */ +/* indicator.c -- put indicator */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* Separated from append.c 2003.07.21 Koji Arai */ +/* ------------------------------------------------------------------------ */ +#include "lha.h" + +#define MAX_INDICATOR_COUNT 64 + +static size_t reading_size; + +#ifdef NEED_INCREMENTAL_INDICATOR +static size_t indicator_count; +static long indicator_threshold; +#endif + +void +start_indicator(name, size, msg, def_indicator_threshold) + char *name; + size_t size; + char *msg; + long def_indicator_threshold; +{ +#ifdef NEED_INCREMENTAL_INDICATOR + long i; + int m; +#endif + + if (quiet) + return; + +#ifdef NEED_INCREMENTAL_INDICATOR + switch (quiet_mode) { + case 0: + m = MAX_INDICATOR_COUNT - strlen(name); + if (m < 1) /* Bug Fixed by N.Watazaki */ + m = 3; /* (^_^) */ + printf("\r%s\t- %s : ", name, msg); + indicator_threshold = + ((size + (m * def_indicator_threshold - 1)) / + (m * def_indicator_threshold) * + def_indicator_threshold); + if (indicator_threshold) + i = ((size + (indicator_threshold - 1)) / indicator_threshold); + else + i = 0; + while (i--) + putchar('.'); + indicator_count = 0; + printf("\r%s\t- %s : ", name, msg); + break; + case 1: + printf("\r%s :", name); + break; + } +#else + printf("%s\t- ", name); +#endif + fflush(stdout); + reading_size = 0L; +} + +#ifdef NEED_INCREMENTAL_INDICATOR +void +put_indicator(count) + long int count; +{ + reading_size += count; + if (!quiet && indicator_threshold) { + while (reading_size > indicator_count) { + putchar('o'); + fflush(stdout); + indicator_count += indicator_threshold; + } + } +} +#endif + +void +finish_indicator2(name, msg, pcnt) + char *name; + char *msg; + int pcnt; +{ + if (quiet) + return; + + if (pcnt > 100) + pcnt = 100; /* (^_^) */ +#ifdef NEED_INCREMENTAL_INDICATOR + printf("\r%s\t- %s(%d%%)\n", name, msg, pcnt); +#else + printf("%s\n", msg); +#endif + fflush(stdout); +} + +void +finish_indicator(name, msg) + char *name; + char *msg; +{ + if (quiet) + return; + +#ifdef NEED_INCREMENTAL_INDICATOR + printf("\r%s\t- %s\n", name, msg); +#else + printf("%s\n", msg); +#endif + fflush(stdout); +} diff --git a/src/lha.h b/src/lha.h index 18cf104..30b26b2 100644 --- a/src/lha.h +++ b/src/lha.h @@ -357,12 +357,6 @@ EXTERN unsigned short c_freq[], c_table[], c_code[]; EXTERN unsigned short p_freq[], pt_table[], pt_code[], t_freq[]; #endif -/* append.c */ -#ifdef NEED_INCREMENTAL_INDICATOR -EXTERN size_t indicator_count; -EXTERN long indicator_threshold; -#endif - /* bitio.c */ EXTERN FILE *infile, *outfile; EXTERN unsigned short bitbuf; diff --git a/src/lha_macro.h b/src/lha_macro.h index 556b7a6..8689a98 100644 --- a/src/lha_macro.h +++ b/src/lha_macro.h @@ -171,8 +171,6 @@ #define LZHEADER_STORAGE 4096 -#define MAX_INDICATOR_COUNT 64 - /* ------------------------------------------------------------------------ */ /* FILE Attribute */ /* ------------------------------------------------------------------------ */ diff --git a/src/prototypes.h b/src/prototypes.h index 0829666..7dc32ad 100644 --- a/src/prototypes.h +++ b/src/prototypes.h @@ -7,10 +7,6 @@ /* append.c */ int encode_lzhuf P_((FILE *infp, FILE *outfp, size_t size, size_t *original_size_var, size_t *packed_size_var, char *name, char *hdr_method)); -void start_indicator P_((char *name, size_t size, char *msg, long def_indicator_threshold)); -void put_indicator P_((long int count)); -void finish_indicator2 P_((char *name, char *msg, int pcnt)); -void finish_indicator P_((char *name, char *msg)); /* bitio.c */ void fillbuf P_((int n)); unsigned short getbits P_((int n)); @@ -56,6 +52,11 @@ void encode_end_st1 P_((void)); unsigned short decode_c_st1 P_((void)); unsigned short decode_p_st1 P_((void)); void decode_start_st1 P_((void)); +/* indicator.c */ +void start_indicator P_((char *name, size_t size, char *msg, long def_indicator_threshold)); +void put_indicator P_((long int count)); +void finish_indicator2 P_((char *name, char *msg, int pcnt)); +void finish_indicator P_((char *name, char *msg)); /* larc.c */ unsigned short decode_c_lzs P_((void)); unsigned short decode_p_lzs P_((void)); -- 2.11.0