diff --git a/binhex/binhex.c b/binhex/binhex.c index 7cc3ce2..2577a28 100644 --- a/binhex/binhex.c +++ b/binhex/binhex.c @@ -7,10 +7,8 @@ #include "../fileio/rdfileopt.h" #include "../util/patchlevel.h" #include "../util/util.h" - -extern void transname(); -extern void do_indent(); -extern void dofile(); +#include "../util/transname.h" +#include "dofile.h" #define LOCALOPT "RilqVH" @@ -25,8 +23,6 @@ int dorep = 1; int main(int argc, char **argv) { int c, i, j, n; - extern int optind; - extern char *optarg; int errflg; char text[32], ftype[5], fauth[5]; int dir_skip = 0, write_it, query = 0, list = 0, info_only = 0; @@ -165,7 +161,8 @@ int main(int argc, char **argv) /* NOTREACHED */ } -static void usage() +static void +usage (void) { (void)fprintf(stderr, "Usage: binhex [-%s] [files]\n", options); (void)fprintf(stderr, "Use \"binhex -H\" for help.\n"); diff --git a/binhex/dofile.c b/binhex/dofile.c index 03cca60..1abfd9e 100644 --- a/binhex/dofile.c +++ b/binhex/dofile.c @@ -1,3 +1,4 @@ +#include "dofile.h" #include #include "../fileio/machdr.h" #include "../fileio/rdfile.h" @@ -23,7 +24,8 @@ void outbyte1(); void out6bit(); void outchar(); -void dofile() +void +dofile (void) { (void)printf("(This file must be converted; you knew that already.)\n"); (void)printf("\n"); @@ -40,7 +42,8 @@ void dofile() (void)putchar('\n'); } -void doheader() +void +doheader (void) { uint32_t crc; int i, n; @@ -78,9 +81,8 @@ int i, n; outbyte((int)(crc & 0xff)); } -void dofork(fork, size) -char *fork; -int size; +void +dofork (char *fork, int size) { uint32_t crc; int i; @@ -93,8 +95,8 @@ int i; outbyte((int)(crc & 0xff)); } -void outbyte(b) -int b; +void +outbyte (int b) { b &= 0xff; if(dorep && (b == rep_char)) { @@ -126,7 +128,8 @@ int b; } } -void finish() +void +finish (void) { if(rep_count > 0) { if(rep_count > 3) { @@ -150,8 +153,8 @@ void finish() } } -void outbyte1(b) -int b; +void +outbyte1 (int b) { switch(state) { case 0: @@ -174,14 +177,14 @@ int b; } } -void out6bit(c) -char c; +void +out6bit (int c) { outchar(codes[c & 0x3f]); } -void outchar(c) -char c; +void +outchar (int c) { (void)putchar(c); if(++pos_ptr > 64) { diff --git a/binhex/dofile.h b/binhex/dofile.h new file mode 100644 index 0000000..608aba6 --- /dev/null +++ b/binhex/dofile.h @@ -0,0 +1 @@ +void dofile (void); \ No newline at end of file diff --git a/comm/frommac.c b/comm/frommac.c index 40a0ae8..a0d0799 100644 --- a/comm/frommac.c +++ b/comm/frommac.c @@ -8,6 +8,7 @@ #include "../util/util.h" #include "../fileio/machdr.h" #include "globals.h" +#include "tty.h" #include "../fileio/fileglob.h" #include "../fileio/wrfile.h" #include "../fileio/wrfileopt.h" @@ -17,9 +18,6 @@ #define LOCALOPT "lmxyzoTVH" -extern void setup_tty(); -extern void reset_tty(); - extern char info[]; static void usage(); @@ -30,8 +28,6 @@ static int listmode = 0; int main(int argc, char **argv) { - extern int optind; - extern char *optarg; int errflg; int c; char tname[64]; @@ -165,7 +161,8 @@ int main(int argc, char **argv) /* NOTREACHED */ } -static void usage() +static void +usage (void) { (void)fprintf(stderr, "Usage: frommac [-%s]\n", options); (void)fprintf(stderr, "Use \"frommac -H\" for help.\n"); diff --git a/comm/tomac.c b/comm/tomac.c index 0063e88..afb39bb 100644 --- a/comm/tomac.c +++ b/comm/tomac.c @@ -8,17 +8,13 @@ #include "../fileio/rdfileopt.h" #include "../util/patchlevel.h" #include "../util/util.h" +#include "../util/transname.h" #include "globals.h" +#include "tty.h" #ifdef XM #include "xm_to.h" #endif /* XM */ -extern void transname(); -extern void do_indent(); -extern void dofile(); -extern void setup_tty(); -extern void reset_tty(); - #define LOCALOPT "ilqxyzoTVH" static void usage(); @@ -31,8 +27,6 @@ static int dir_max; int main(int argc, char **argv) { int c, i, j, n; - extern int optind; - extern char *optarg; int errflg; char text[32], ftype[5], fauth[5]; int dir_skip = 0, write_it, query = 0, list = 0, info_only = 0; @@ -236,7 +230,8 @@ int main(int argc, char **argv) /* NOTREACHED */ } -static void usage() +static void +usage (void) { (void)fprintf(stderr, "Usage: tomac [-%s] [files]\n", options); (void)fprintf(stderr, "Use \"tomac -H\" for help.\n"); diff --git a/comm/tty.c b/comm/tty.c index 6162d87..54f2586 100644 --- a/comm/tty.c +++ b/comm/tty.c @@ -1,3 +1,4 @@ +#include "tty.h" #include #include #include @@ -12,10 +13,7 @@ #include "protocol.h" #include "globals.h" -void cleanup(); -void timedout(); -int tgetc(); -void tputc(); +void timedout(int); static jmp_buf timobuf; @@ -27,7 +25,8 @@ static struct termios otty, ntty; static int ttyfd; static int signal_set; -void setup_tty() +void +setup_tty (void) { ttyfd = fileno(stderr); if(!signal_set) { @@ -58,7 +57,8 @@ void setup_tty() #endif /* TERMIOS_H */ } -void reset_tty() +void +reset_tty (void) { (void)sleep(1); /* Wait for output to drain */ #ifndef TERMIOS_H @@ -74,14 +74,15 @@ void cleanup(int sig) exit(sig); } -void timedout() +void +timedout (int) { (void)signal(SIGALRM, timedout); longjmp(timobuf, 1); } -int tgetc(timeout) -int timeout; +int +tgetc (int timeout) { char c; int i; @@ -136,9 +137,8 @@ void tputc(int c) (void)write(ttyfd, &cc, 1); } -void tputrec(buf, count) -char *buf; -int count; +void +tputrec (char *buf, int count) { (void)write(ttyfd, buf, count); } diff --git a/comm/tty.h b/comm/tty.h index 5b3db5e..7e3ae4f 100644 --- a/comm/tty.h +++ b/comm/tty.h @@ -1 +1,7 @@ void cleanup(int sig); +void reset_tty (void); +void setup_tty (void); +int tgetrec(char *buf, int count, int timeout); +int tgetc (int timeout); +void tputc(int c); +void tputrec (char *buf, int count); \ No newline at end of file diff --git a/comm/xm_from.c b/comm/xm_from.c index 53c7a6d..988e4f0 100644 --- a/comm/xm_from.c +++ b/comm/xm_from.c @@ -10,17 +10,14 @@ #include "protocol.h" #include "tty.h" -extern int tgetc(); -extern int tgetrec(); -extern void tputc(); - static void receive_part(); static int receive_sync(); static int receive_rec(); char info[INFOBYTES]; -void xm_from() +void +xm_from (void) { unsigned long data_size, rsrc_size; char text[64]; @@ -40,11 +37,10 @@ char text[64]; } } -static void receive_part(info, size, more) -char *info; -int size, more; +static void +receive_part (char *info, int size, int more) { -int recno = 1, i, status, naks = 0; +int recno = 1, status, naks = 0; status = 0; while(status != EOT) { @@ -82,7 +78,8 @@ int recno = 1, i, status, naks = 0; } } -static int receive_sync() +static int +receive_sync (void) { int c; @@ -109,9 +106,8 @@ int c; return ACK; } -static int receive_rec(buf, bufsize, recno) -char *buf; -int bufsize, recno; +static int +receive_rec (char *buf, int bufsize, int recno) { int i, cksum, c, rec, recbar; char *bp; diff --git a/comm/xm_to.c b/comm/xm_to.c index 93e9ede..b34cc21 100644 --- a/comm/xm_to.c +++ b/comm/xm_to.c @@ -7,15 +7,12 @@ #include "protocol.h" #include "tty.h" -extern int tgetc(); -extern void tputc(); -extern void tputrec(); - static void send_part(); static int send_sync(); static void send_rec(); -void xm_to() +void +xm_to (void) { if(send_sync() == ACK) { send_part(file_info, DATABYTES, 1); @@ -24,9 +21,8 @@ void xm_to() } } -static void send_part(info, size, more) -char *info; -int size, more; +static void +send_part (char *info, int size, int more) { int recno = 1, i, status; @@ -54,7 +50,8 @@ int recno = 1, i, status; } } -static int send_sync() +static int +send_sync (void) { int c, i; @@ -75,9 +72,8 @@ int c, i; return CAN; } -static void send_rec(buf, bufsize, recno) -char *buf; -int bufsize, recno; +static void +send_rec (char *buf, int bufsize, int recno) { int i, cksum; char *bp; diff --git a/crc/makecrc.c b/crc/makecrc.c index 3fa13dc..941336e 100644 --- a/crc/makecrc.c +++ b/crc/makecrc.c @@ -36,7 +36,8 @@ static void initcrctab(); -int main() +int +main (void) { initcrctab("ccitt", 0x1021, 0xffff, 0, 16); initcrctab("kermit", 0x8408, 0, 1, 16); @@ -47,9 +48,8 @@ int main() exit(0); } -static void initcrctab(name, poly, init, swapped, bits) -char *name; -int poly, init, swapped, bits; +static void +initcrctab (char *name, int poly, int init, int swapped, int bits) { register int b, i; unsigned short v; @@ -99,7 +99,7 @@ int poly, init, swapped, bits; for(vv = b<<24, i = 8; --i >= 0;) vv = vv & 0x80000000 ? (vv<<1)^poly : vv<<1; } - (void)fprintf(fd, "0x%.8x,", vv & 0xffffffff); + (void)fprintf(fd, "0x%.8lx,", vv & 0xffffffff); if((b&3) == 3) { (void)fprintf(fd, "\n"); if(b != 255) (void)fprintf(fd, " "); diff --git a/fileio/rdfile.c b/fileio/rdfile.c index 9567670..678e8d3 100644 --- a/fileio/rdfile.c +++ b/fileio/rdfile.c @@ -92,9 +92,8 @@ static void read_appledouble_info(); static char filename[255]; static int filekind; -void setup(argc, argv) -int argc; -char **argv; +void +setup (int argc, char **argv) { if(argc == 0) { read_stdin = 1; @@ -109,8 +108,8 @@ char **argv; } } -static void check_files(initial) -int initial; +static void +check_files (int initial) { struct stat stbuf; int i, j, n; @@ -292,7 +291,8 @@ int initial; } } -int nextfile() +int +nextfile (void) { int i; @@ -337,7 +337,8 @@ again: } } -static void read_file() +static void +read_file (void) { FILE *fd; int c, j, lname, skip; @@ -652,7 +653,8 @@ static void read_file() } } -static void enter_dir() +static void +enter_dir (void) { DIR *directory; struct dirstruct *curentry; @@ -746,7 +748,8 @@ static void enter_dir() check_files(0); } -static void exit_dir() +static void +exit_dir (void) { filelist *old_files; int i; @@ -767,8 +770,8 @@ static void exit_dir() #ifdef APPLESHARE #ifdef AUFS -static void read_aufs_info(fd) -FILE *fd; +static void +read_aufs_info (FILE *fd) { FileInfo theinfo; int i, n; @@ -832,8 +835,8 @@ FILE *fd; size and format. I have not yet seen something that will lead me to believe different. */ -static void read_appledouble_info(fd) -FILE *fd; +static void +read_appledouble_info (FILE *fd) { FileInfo theinfo; int i, n; @@ -866,7 +869,8 @@ FILE *fd; #endif /* APPLEDOUBLE */ #endif /* APPLESHARE */ -static int get_stdin_file() +static int +get_stdin_file (void) { int i, skip; @@ -934,10 +938,9 @@ static int get_stdin_file() return ISFILE; } -int rdfileopt(c) -char c; +int +rdfileopt (int c) { -extern char *optarg; char name[32]; switch(c) { @@ -965,7 +968,8 @@ char name[32]; return 1; } -void give_rdfileopt() +void +give_rdfileopt (void) { (void)fprintf(stderr, "File input options:\n"); (void)fprintf(stderr, "-r:\tread as resource files\n"); @@ -979,19 +983,22 @@ void give_rdfileopt() "-t ty:\tfiletype if one of the above options is used\n"); } -void set_norecurse() +void +set_norecurse (void) { no_recurse = 1; } -char *get_rdfileopt() +char * +get_rdfileopt (void) { static char options[] = "rduUc:t:"; return options; } -char *get_minb() +char * +get_minb (void) { #ifdef APPLESHARE #ifdef AUFS diff --git a/fileio/rdfile.h b/fileio/rdfile.h index b7cf4a6..c8d8695 100644 --- a/fileio/rdfile.h +++ b/fileio/rdfile.h @@ -7,6 +7,6 @@ extern char file_info[INFOBYTES]; extern char *data_fork, *rsrc_fork; extern int data_size, rsrc_size; -extern void setup(); -extern int nextfile(); -extern char *get_minb(); +extern void setup(int argc, char **argv); +extern int nextfile(void); +extern char *get_minb(void); diff --git a/fileio/wrfile.c b/fileio/wrfile.c index e7ded17..d60c0b7 100644 --- a/fileio/wrfile.c +++ b/fileio/wrfile.c @@ -1,3 +1,5 @@ +#include "wrfile.h" + #ifdef TYPES_H #include #endif /* TYPES_H */ @@ -8,7 +10,6 @@ #include #include #include "machdr.h" -#include "wrfile.h" #include "wrfileopt.h" #include "../util/util.h" #ifdef AUFSPLUS @@ -102,8 +103,8 @@ static char *rbuffer = NULL, *dbuffer = NULL; static char *ptr; static unsigned long rsz, dsz, totsize, maxsize; -void define_name(text) -char *text; +void +define_name (char *text) { (void)sprintf(f_info, "%s.info", text); (void)sprintf(f_rsrc, "%s.rsrc", text); @@ -118,9 +119,8 @@ char *text; #endif /* APPLESHARE */ } -void start_info(info, rsize, dsize) -char *info; -unsigned long rsize, dsize; +void +start_info (char *info, unsigned long rsize, unsigned long dsize) { int rs, ds; @@ -158,17 +158,20 @@ unsigned long rsize, dsize; #endif /* APPLEDOUBLE */ } -void start_rsrc() +void +start_rsrc (void) { out_buffer = out_ptr = rbuffer; } -void start_data() +void +start_data (void) { out_buffer = out_ptr = dbuffer; } -void end_file() +void +end_file (void) { FILE *fp; int i, c; @@ -324,9 +327,8 @@ void end_file() } #ifdef SCAN -void do_idf(name, kind) -char *name; -int kind; +void +do_idf (char *name, int kind) { int n; @@ -348,8 +350,8 @@ int kind; } #endif /* SCAN */ -void do_mkdir(name, header) -char *name, *header; +void +do_mkdir (char *name, char *header) { struct stat sbuf; FILE *fp; @@ -507,7 +509,7 @@ char dirinfo[I_NAMELEN*3+INFOSZ+10]; #endif /* APPLESHARE */ } -void enddir() +void enddir(void) { char header[INFOBYTES]; int i; @@ -621,8 +623,8 @@ static void check_appledouble() static void appledouble_namings() { mk_share_name(); - (void)sprintf(f_info_appledouble, "%s/%s", infodir, share_name); - (void)sprintf(f_data, "%s", share_name); + (void)snprintf(f_info_appledouble, sizeof(f_info_appledouble), "%s/%s", infodir, share_name); + (void)snprintf(f_data, sizeof(f_data), "%s", share_name); } static void wr_appledouble_info(fp) @@ -678,7 +680,7 @@ static void mk_share_name() mp = buffer + 2; up = &(share_name[0]); - while(ch = *mp++) { + while((ch = *mp++)) { if(isascii(ch) && ! iscntrl(ch) && isprint(ch) && ch != '/') { *up++ = ch; } else { @@ -827,7 +829,7 @@ char *get_wrfileopt() return options; } -char *get_mina() +char *get_mina(void) { #ifdef APPLESHARE #ifdef AUFS diff --git a/fileio/wrfile.h b/fileio/wrfile.h index d069d14..d8e4864 100644 --- a/fileio/wrfile.h +++ b/fileio/wrfile.h @@ -1,14 +1,14 @@ extern char *out_buffer, *out_ptr; -extern void define_name(); -extern void start_info(); -extern void start_rsrc(); -extern void start_data(); -extern void end_file(); +extern void define_name(char *text); +void start_info(char *info, unsigned long rsize, unsigned long dsize); +extern void start_rsrc(void); +extern void start_data(void); +extern void end_file(void); #ifdef SCAN extern void do_idf(); #endif /* SCAN */ -extern void do_mkdir(); -extern void enddir(); -extern char *get_mina(); +extern void do_mkdir(char *name, char *header); +extern void enddir(void); +extern char *get_mina(void); diff --git a/hexbin/buffer.c b/hexbin/buffer.c index 9b7459a..ed62110 100644 --- a/hexbin/buffer.c +++ b/hexbin/buffer.c @@ -9,8 +9,8 @@ int data_size, rsrc_size; static int max_data_size, max_rsrc_size; static int do_data; -void put_byte(c) -char c; +void +put_byte (int c) { if(do_data) { if(data_size >= max_data_size) { @@ -43,8 +43,8 @@ char c; } } -void set_put(data) -int data; +void +set_put (int data) { do_data = data; if(do_data) { @@ -54,7 +54,8 @@ int data; } } -void end_put() +void +end_put (void) { if(info_only) { return; diff --git a/hexbin/crc.c b/hexbin/crc.c index 121c5a7..968bcef 100644 --- a/hexbin/crc.c +++ b/hexbin/crc.c @@ -6,28 +6,28 @@ #include "../util/masks.h" #include "globals.h" -extern void exit(); +#include uint32_t crc; #ifdef HQX -void comp_q_crc(c) -register unsigned int c; +void +comp_q_crc (register unsigned int c) { unsigned char cc = c; crc = binhex_updcrc(crc, &cc, 1); } -void comp_q_crc_n(s, e) -register unsigned char *s, *e; +void +comp_q_crc_n (register unsigned char *s, register unsigned char *e) { crc = binhex_updcrc(crc, s, e - s); } #endif /* HQX */ -void verify_crc(calc_crc, file_crc) -unsigned long calc_crc, file_crc; +void +verify_crc (unsigned long calc_crc, unsigned long file_crc) { calc_crc &= WORDMASK; file_crc &= WORDMASK; diff --git a/hexbin/dl.c b/hexbin/dl.c index 700c1cb..87be82d 100644 --- a/hexbin/dl.c +++ b/hexbin/dl.c @@ -9,7 +9,7 @@ #include "buffer.h" #include "printhdr.h" -extern void exit(); +#include static long dl_fork(); static int nchar(); @@ -18,8 +18,8 @@ static int nextc(); static char *icp = &line[0]; /* oldest format -- process .dl files */ -void dl(macname, filename) -char *macname, *filename; +void +dl (char *macname, char *filename) { int n; @@ -75,7 +75,8 @@ char *macname, *filename; end_put(); } -static long dl_fork() +static long +dl_fork (void) { register unsigned long i, v, c; register unsigned long n, bytes; @@ -104,7 +105,8 @@ static long dl_fork() return bytes; } -static int nchar() +static int +nchar (void) { int i; @@ -118,7 +120,8 @@ static int nchar() return i & 0177; } -static int nextc() +static int +nextc (void) { while(*icp == 0) { if(readline() == 0) { diff --git a/hexbin/dl.h b/hexbin/dl.h new file mode 100644 index 0000000..d5ebf9f --- /dev/null +++ b/hexbin/dl.h @@ -0,0 +1,7 @@ +#include "hexbin.h" + +#ifdef DL + +void dl (char *macname, char *filename); + +#endif \ No newline at end of file diff --git a/hexbin/globals.c b/hexbin/globals.c index 91b3961..157e683 100644 --- a/hexbin/globals.c +++ b/hexbin/globals.c @@ -18,8 +18,8 @@ int was_macbin; FILE *ifp; #ifdef SCAN -void do_error(string) -char *string; +void +do_error (char *string) { do_idf(string, ERROR); } diff --git a/hexbin/hecx.c b/hexbin/hecx.c index 5d19d8e..98bd6da 100644 --- a/hexbin/hecx.c +++ b/hexbin/hecx.c @@ -10,7 +10,7 @@ #include "buffer.h" #include "printhdr.h" -extern void exit(); +#include static void do_o_forks(); static long make_file(); @@ -23,8 +23,8 @@ static int hexit(); static int compressed; /* old format -- process .hex and .hcx files */ -void hecx(macname, filename) -char *macname, *filename; +void +hecx (char *macname, char *filename) { int n; @@ -95,7 +95,8 @@ char *macname, *filename; end_put(); } -static void do_o_forks() +static void +do_o_forks (void) { int forks = 0, found_crc = 0; unsigned long calc_crc, file_crc; @@ -150,8 +151,8 @@ static void do_o_forks() } } -static long make_file(compressed) -int compressed; +static long +make_file (int compressed) { register long nbytes = 0L; @@ -171,22 +172,23 @@ int compressed; return nbytes; } -static void comp_c_crc(c) -unsigned char c; +static void +comp_c_crc (int c) { crc = (crc + c) & WORDMASK; crc = ((crc << 3) & WORDMASK) | (crc >> 13); } -static void comp_e_crc(c) -unsigned char c; +static void +comp_e_crc (int c) { crc += c; } #define SIXB(c) (((c)-0x20) & 0x3f) -static int comp_to_bin() +static int +comp_to_bin (void) { char obuf[BUFSIZ]; register char *ip = line; @@ -217,7 +219,8 @@ static int comp_to_bin() return outcount; } -static int hex_to_bin() +static int +hex_to_bin (void) { register char *ip = line; register int n, outcount; @@ -233,8 +236,8 @@ static int hex_to_bin() return outcount; } -static int hexit(c) -int c; +static int +hexit (int c) { if('0' <= c && c <= '9') { return c - '0'; diff --git a/hexbin/hecx.h b/hexbin/hecx.h new file mode 100644 index 0000000..66ead37 --- /dev/null +++ b/hexbin/hecx.h @@ -0,0 +1,7 @@ +#include "hexbin.h" + +#ifdef HECX + +void hecx (char *macname, char *filename); + +#endif \ No newline at end of file diff --git a/hexbin/hexbin.c b/hexbin/hexbin.c index 51a1eaf..e4561f2 100644 --- a/hexbin/hexbin.c +++ b/hexbin/hexbin.c @@ -16,38 +16,26 @@ #include "../fileio/machdr.h" #include "../fileio/kind.h" #include "../util/curtime.h" +#include "../util/backtrans.h" #include "hexbin.h" +#include "dl.h" +#include "hecx.h" +#include "hqx.h" +#include "mu.h" #define LOCALOPT "ilvcn:qVH" -extern void backtrans(); -#ifdef DL -extern void dl(); -#endif /* DL */ -#ifdef HECX -extern void hecx(); -#endif /* HECX */ -#ifdef HQX -extern void hqx(); -#endif /* HQX */ -#ifdef MU -extern void mu(); -#endif /* MU */ - -static void usage(); -static void do_files(); -static int find_header(); +static void usage(void); +static void do_files(char *filename, char *macname); +static int find_header(int again); static char options[128]; -int main(argc, argv) -int argc; -char **argv; +int +main (int argc, char **argv) { char *filename; char macname[32]; - extern int optind; - extern char *optarg; int errflg; int c; @@ -162,9 +150,11 @@ static char *extensions[] = { NULL }; -static void do_files(filename, macname) -char *filename; /* input file name -- extension optional */ -char *macname; /* name to use on the mac side of things */ +static void +do_files ( + char *filename, /* input file name -- extension optional */ + char *macname /* name to use on the mac side of things */ +) { char namebuf[256]; char **ep; @@ -237,8 +227,8 @@ nexttry: } /* eat characters until header detected, return which format */ -static int find_header(again) -int again; +static int +find_header (int again) { int c, dl_start, llen; char *cp; @@ -356,7 +346,8 @@ int again; return form_none; } -static void usage() +static void +usage (void) { (void)fprintf(stderr, "Usage: hexbin [-%s] [filenames]\n", options); (void)fprintf(stderr, "Use \"hexbin -H\" for help.\n"); diff --git a/hexbin/hqx.c b/hexbin/hqx.c index 9e3b7ee..b65a350 100644 --- a/hexbin/hqx.c +++ b/hexbin/hqx.c @@ -1,4 +1,5 @@ #include "hexbin.h" +#include "hqx.h" #ifdef HQX #include #include "globals.h" @@ -104,12 +105,12 @@ static long todo; #define output(c) { *op++ = (c); if(op >= &obuf[BUFSIZ]) oflush(); } -void hqx(macname) -char *macname; +void +hqx (char *macname) { int n, normlen, c; register char *in, *out; - register int b6, b8, data, lastc = 0; + register int b6, b8 = 0, data = 0, lastc = 0; char state68 = 0, run = 0, linestate, first = 1; g_macname = macname; @@ -231,7 +232,8 @@ done: print_header2(verbose); } -static void get_header() +static void +get_header (void) { int n; unsigned long calc_crc, file_crc; @@ -282,7 +284,8 @@ static void get_header() put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime); } -static void oflush() +static void +oflush (void) { int n, i; @@ -335,7 +338,7 @@ static void oflush() ++ostate; break; case S_EXCESS: - (void)fprintf(stderr, "%d excess bytes ignored\n", op-oq); + (void)fprintf(stderr, "%ld excess bytes ignored\n", op-oq); oq = op; break; } @@ -343,7 +346,8 @@ static void oflush() op = obuf; } -static int getq() +static int +getq (void) { int c; @@ -360,14 +364,16 @@ static int getq() } /* get2q(); q format -- read 2 bytes from input, return short */ -static long get2q() +static long +get2q (void) { short high = getq() << 8; return high | getq(); } /* get4q(); q format -- read 4 bytes from input, return long */ -static long get4q() +static long +get4q (void) { int i; long value = 0; diff --git a/hexbin/hqx.h b/hexbin/hqx.h new file mode 100644 index 0000000..2dc2297 --- /dev/null +++ b/hexbin/hqx.h @@ -0,0 +1,7 @@ +#include "hexbin.h" + +#ifdef HQX + +void hqx (char *macname); + +#endif \ No newline at end of file diff --git a/hexbin/mu.c b/hexbin/mu.c index 8b43c48..cd23639 100644 --- a/hexbin/mu.c +++ b/hexbin/mu.c @@ -1,4 +1,5 @@ #include "hexbin.h" +#include "mu.h" #ifdef MU #include "globals.h" #include "readline.h" @@ -9,15 +10,15 @@ #include "buffer.h" #include "printhdr.h" -extern void exit(); +#include static void do_mu_fork(); static int mu_comp_to_bin(); static int mu_convert(); /* mu format -- process .mu files */ -void mu(macname) -char *macname; +void +mu (char *macname) { int n; @@ -143,7 +144,8 @@ char *macname; end_put(); } -static void do_mu_fork() +static void +do_mu_fork (void) { long newbytes; @@ -179,7 +181,8 @@ static void do_mu_fork() /*NOTREACHED*/ } -static int mu_comp_to_bin() +static int +mu_comp_to_bin (void) { char obuf[BUFSIZ]; int outcount, n; @@ -193,8 +196,8 @@ static int mu_comp_to_bin() #define SIXB(c) (((c)-0x20) & 0x3f) -static int mu_convert(ibuf, obuf) -char *ibuf, *obuf; +static int +mu_convert (char *ibuf, char *obuf) { register char *ip = ibuf; register char *op = obuf; diff --git a/hexbin/mu.h b/hexbin/mu.h new file mode 100644 index 0000000..a951f31 --- /dev/null +++ b/hexbin/mu.h @@ -0,0 +1,7 @@ +#include "hexbin.h" + +#ifdef MU + +void mu (char *macname); + +#endif \ No newline at end of file diff --git a/hexbin/readline.c b/hexbin/readline.c index a4f82bd..75a8bce 100644 --- a/hexbin/readline.c +++ b/hexbin/readline.c @@ -6,7 +6,8 @@ char line[1024]; /* Allow a lot! */ /* Read a line. Allow termination by CR or LF or both. Also allow for a non-terminated line at end-of-file. Returns 1 if a line is read, 0 otherwise. */ -int readline() +int +readline (void) { int ptr = 0, c; diff --git a/macunpack/arc.h b/macunpack/arc.h index 67443ba..d155df0 100644 --- a/macunpack/arc.h +++ b/macunpack/arc.h @@ -18,7 +18,7 @@ #define SIZE2 84 /* Not present if KIND == 1 */ #define HEADERBYTES 88 -typedef struct fileHdr { /* 84 or 88 bytes */ +typedef struct arc_fileHdr { /* 84 or 88 bytes */ char magic1; char kind; char fname[31]; diff --git a/macunpack/bin.c b/macunpack/bin.c index 50cf3be..00e2750 100644 --- a/macunpack/bin.c +++ b/macunpack/bin.c @@ -1,4 +1,5 @@ #include "macunpack.h" +#include "bin.h" #ifdef BIN #include #include "globals.h" @@ -7,12 +8,10 @@ #include "../fileio/kind.h" #include "../util/util.h" #include "../util/masks.h" +#include "mcb.h" -extern void mcb(); - -void bin(header, data_size, UMcp) -char *header; -int data_size, UMcp; +void +bin (char *header, int data_size, int UMcp) { char hdr[INFOBYTES]; unsigned long rsrcLength, dataLength; diff --git a/macunpack/bin.h b/macunpack/bin.h new file mode 100644 index 0000000..e0b47f6 --- /dev/null +++ b/macunpack/bin.h @@ -0,0 +1,4 @@ +#include "macunpack.h" +#ifdef BIN +void bin (char *header, int data_size, int UMcp); +#endif \ No newline at end of file diff --git a/macunpack/bits_be.c b/macunpack/bits_be.c index e4ce810..33fb9fb 100644 --- a/macunpack/bits_be.c +++ b/macunpack/bits_be.c @@ -8,8 +8,10 @@ int bit_be_inbytes; static unsigned int bit_be_subbitbuf; static int bit_be_bitcount; -void bit_be_fillbuf(n) /* Shift bit_be_bitbuf n bits left, read n bits */ -int n; +void +bit_be_fillbuf ( /* Shift bit_be_bitbuf n bits left, read n bits */ + int n +) { bit_be_bitbuf <<= n; while (n > bit_be_bitcount) { @@ -26,8 +28,8 @@ int n; bit_be_bitbuf &= WORDMASK; } -unsigned int bit_be_getbits(n) -int n; +unsigned int +bit_be_getbits (int n) { unsigned int x; @@ -36,7 +38,8 @@ int n; return x; } -void bit_be_init_getbits() +void +bit_be_init_getbits (void) { bit_be_bitbuf = 0; bit_be_subbitbuf = 0; diff --git a/macunpack/cpt.c b/macunpack/cpt.c index af44e5c..a788ff4 100644 --- a/macunpack/cpt.c +++ b/macunpack/cpt.c @@ -47,7 +47,6 @@ static int cpt_filehdr(); static void cpt_folder(); static void cpt_uncompact(); static void cpt_wrfile(); -void cpt_wrfile1(); static void cpt_outch(); static void cpt_rle(); static void cpt_rle_lzh(); @@ -55,10 +54,11 @@ static void cpt_readHuff(); static int cpt_get6bits(); static int cpt_getbit(); -void cpt() +void +cpt (void) { struct cptHdr cpthdr; - struct fileHdr filehdr; + struct cpt_fileHdr filehdr; char *cptindex; int cptindsize; char *cptptr; @@ -75,7 +75,7 @@ void cpt() exit(1); } - cptindsize = cpthdr.entries * FILEHDRSIZE; + cptindsize = cpthdr.entries * CPT_FILEHDRSIZE; if(cpthdr.commentsize > cptindsize) { cptindsize = cpthdr.commentsize; } @@ -121,8 +121,8 @@ void cpt() } cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)(cptptr + F_FOLDERSIZE), 2); } else { - if(fread(cptptr + F_VOLUME, 1, FILEHDRSIZE - F_VOLUME, infp) != - FILEHDRSIZE - F_VOLUME) { + if(fread(cptptr + F_VOLUME, 1, CPT_FILEHDRSIZE - F_VOLUME, infp) != + CPT_FILEHDRSIZE - F_VOLUME) { (void)fprintf(stderr, "Can't read file header #%d\n", i+1); #ifdef SCAN do_error("macunpack: Can't read file header"); @@ -130,9 +130,9 @@ void cpt() exit(1); } cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)(cptptr + F_VOLUME), - FILEHDRSIZE - F_VOLUME); + CPT_FILEHDRSIZE - F_VOLUME); } - cptptr += FILEHDRSIZE; + cptptr += CPT_FILEHDRSIZE; } if(cpt_crc != cpthdr.hdrcrc) { (void)fprintf(stderr, "Header CRC mismatch: got 0x%08x, need 0x%08x\n", @@ -155,17 +155,17 @@ void cpt() if(filehdr.folder) { cpt_folder(text, filehdr, cptptr); i += filehdr.foldersize; - cptptr += filehdr.foldersize * FILEHDRSIZE; + cptptr += filehdr.foldersize * CPT_FILEHDRSIZE; } else { cpt_uncompact(filehdr); } - cptptr += FILEHDRSIZE; + cptptr += CPT_FILEHDRSIZE; } (void)free(cptindex); } -static int readcpthdr(s) -struct cptHdr *s; +static int +readcpthdr (struct cptHdr *s) { char temp[CHDRSIZE]; @@ -204,16 +204,15 @@ struct cptHdr *s; } cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)(temp + CPTHDRSIZE + C_ENTRIES), 3); - s->hdrcrc = get4(temp + CPTHDRSIZE + C_HDRCRC); + s->hdrcrc = get4(temp + CPTHDRSIZE + CPT_C_HDRCRC); s->entries = get2(temp + CPTHDRSIZE + C_ENTRIES); s->commentsize = temp[CPTHDRSIZE + C_COMMENT]; return 1; } -static int cpt_filehdr(f, hdr) -struct fileHdr *f; -char *hdr; +static int +cpt_filehdr (struct cpt_fileHdr *f, char *hdr) { register int i; int n; @@ -286,20 +285,18 @@ char *hdr; return 1; } -static void cpt_folder(name, fileh, cptptr) -char *name; -struct fileHdr fileh; -char *cptptr; +static void +cpt_folder (char *name, struct cpt_fileHdr fileh, char *cptptr) { int i, nfiles; char loc_name[64]; - struct fileHdr filehdr; + struct cpt_fileHdr filehdr; for(i = 0; i < 64; i++) { loc_name[i] = name[i]; } if(write_it || info_only) { - cptptr += FILEHDRSIZE; + cptptr += CPT_FILEHDRSIZE; nfiles = fileh.foldersize; if(write_it) { do_mkdir(text, info); @@ -316,11 +313,11 @@ char *cptptr; if(filehdr.folder) { cpt_folder(text, filehdr, cptptr); i += filehdr.foldersize; - cptptr += filehdr.foldersize * FILEHDRSIZE; + cptptr += filehdr.foldersize * CPT_FILEHDRSIZE; } else { cpt_uncompact(filehdr); } - cptptr += FILEHDRSIZE; + cptptr += CPT_FILEHDRSIZE; } if(write_it) { enddir(); @@ -333,8 +330,8 @@ char *cptptr; } } -static void cpt_uncompact(filehdr) -struct fileHdr filehdr; +static void +cpt_uncompact (struct cpt_fileHdr filehdr) { if(filehdr.cptFlag & 1) { (void)fprintf(stderr, "\tFile is password protected, skipping file\n"); @@ -398,9 +395,8 @@ struct fileHdr filehdr; } } -static void cpt_wrfile(ibytes, obytes, type) -unsigned long ibytes, obytes; -unsigned short type; +static void +cpt_wrfile (unsigned long ibytes, unsigned long obytes, int type) { if(ibytes == 0) { return; @@ -418,10 +414,8 @@ unsigned short type; cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)out_buffer, obytes); } -void cpt_wrfile1(in_char, ibytes, obytes, type, blocksize) -unsigned char *in_char; -unsigned long ibytes, obytes, blocksize; -int type; +void +cpt_wrfile1 (unsigned char *in_char, unsigned long ibytes, unsigned long obytes, int type, unsigned long blocksize) { cpt_char = in_char; if(ibytes == 0) { @@ -439,8 +433,8 @@ int type; } } -static void cpt_outch(ch) -unsigned char ch; +static void +cpt_outch (int ch) { cpt_LZbuff[cpt_LZptr++ & (CIRCSIZE - 1)] = ch; switch(cpt_outstat) { @@ -498,7 +492,8 @@ unsigned char ch; /*---------------------------------------------------------------------------*/ /* Run length encoding */ /*---------------------------------------------------------------------------*/ -static void cpt_rle() +static void +cpt_rle (void) { while(cpt_inlength-- > 0) { cpt_outch(*cpt_char++); @@ -508,7 +503,8 @@ static void cpt_rle() /*---------------------------------------------------------------------------*/ /* Run length encoding plus LZ compression plus Huffman encoding */ /*---------------------------------------------------------------------------*/ -static void cpt_rle_lzh() +static void +cpt_rle_lzh (void) { int block_count; unsigned int bptr; @@ -556,9 +552,8 @@ typedef struct sf_entry { /* See routine LoadTree. The parameter tree (actually an array and two integers) are only used locally in this version and hence locally declared. The parameter nodes has been renamed Hufftree.... */ -static void cpt_readHuff(size, Hufftree) -int size; -struct node *Hufftree; +static void +cpt_readHuff (int size, struct node *Hufftree) { sf_entry tree_entry[256 + SLACK]; /* maximal number of elements */ int tree_entries; @@ -680,7 +675,8 @@ struct node *Hufftree; Hufftree[0].flag = 0; } -static int cpt_get6bits() +static int +cpt_get6bits (void) { int b = 0, cn; @@ -696,7 +692,8 @@ int b = 0, cn; return b; } -static int cpt_getbit() +static int +cpt_getbit (void) { int b; diff --git a/macunpack/cpt.h b/macunpack/cpt.h index 89f233d..75581d8 100644 --- a/macunpack/cpt.h +++ b/macunpack/cpt.h @@ -4,7 +4,7 @@ #define C_IOFFSET 4 #define CPTHDRSIZE 8 -#define C_HDRCRC 0 +#define CPT_C_HDRCRC 0 #define C_ENTRIES 4 #define C_COMMENT 6 #define CPTHDR2SIZE 7 @@ -27,58 +27,58 @@ #define F_DATALENGTH 68 #define F_COMPRLENGTH 72 #define F_COMPDLENGTH 76 -#define FILEHDRSIZE 80 +#define CPT_FILEHDRSIZE 80 typedef long OSType; typedef struct cptHdr { /* 8 bytes */ - unsigned char signature; /* = 1 -- for verification */ - unsigned char volume; /* for multi-file archives */ - unsigned short xmagic; /* verification multi-file consistency*/ - unsigned long offset; /* index offset */ + unsigned char signature; /* = 1 -- for verification */ + unsigned char volume; /* for multi-file archives */ + unsigned short xmagic; /* verification multi-file consistency*/ + unsigned long offset; /* index offset */ /* The following are really in header2 at offset */ - unsigned long hdrcrc; /* header crc */ - unsigned short entries; /* number of index entries */ - unsigned char commentsize; /* number of bytes comment that follow*/ + unsigned long hdrcrc; /* header crc */ + unsigned short entries; /* number of index entries */ + unsigned char commentsize; /* number of bytes comment that follow*/ } cptHdr; -typedef struct fileHdr { /* 78 bytes */ - unsigned char fName[32]; /* a STR32 */ - unsigned char folder; /* set to 1 if a folder */ - unsigned short foldersize; /* number of entries in folder */ - unsigned char volume; /* for multi-file archives */ - unsigned long filepos; /* position of data in file */ - OSType fType; /* file type */ - OSType fCreator; /* er... */ - unsigned long creationDate; - unsigned long modDate; /* !restored-compat w/backup prgms */ - unsigned short FndrFlags; /* copy of Finder flags. For our - purposes, we can clear: - busy,onDesk */ - unsigned long fileCRC; /* crc on file */ - unsigned short cptFlag; /* cpt flags */ - unsigned long rsrcLength; /* decompressed lengths */ - unsigned long dataLength; - unsigned long compRLength; /* compressed lengths */ - unsigned long compDLength; -} fileHdr; +typedef struct cpt_fileHdr { /* 78 bytes */ + unsigned char fName[32]; /* a STR32 */ + unsigned char folder; /* set to 1 if a folder */ + unsigned short foldersize; /* number of entries in folder */ + unsigned char volume; /* for multi-file archives */ + unsigned long filepos; /* position of data in file */ + OSType fType; /* file type */ + OSType fCreator; /* er... */ + unsigned long creationDate; + unsigned long modDate; /* !restored-compat w/backup prgms */ + unsigned short FndrFlags; /* copy of Finder flags. For our + purposes, we can clear: + busy,onDesk */ + unsigned long fileCRC; /* crc on file */ + unsigned short cptFlag; /* cpt flags */ + unsigned long rsrcLength; /* decompressed lengths */ + unsigned long dataLength; + unsigned long compRLength; /* compressed lengths */ + unsigned long compDLength; +} cpt_fileHdr; /* file format is: - cptArchiveHdr - file1data - file1RsrcFork - file1DataFork - file2data - file2RsrcFork - file2DataFork - . - . - . - fileNdata - fileNRsrcFork - fileNDataFork - cptIndex + cptArchiveHdr + file1data + file1RsrcFork + file1DataFork + file2data + file2RsrcFork + file2DataFork + . + . + . + fileNdata + fileNRsrcFork + fileNDataFork + cptIndex */ @@ -91,3 +91,9 @@ typedef struct fileHdr { /* 78 bytes */ #define CIRCSIZE 8192 +void +cpt_wrfile1 (unsigned char *in_char, + unsigned long ibytes, + unsigned long obytes, + int type, + unsigned long blocksize); diff --git a/macunpack/dd.c b/macunpack/dd.c index df7126d..53ee85f 100644 --- a/macunpack/dd.c +++ b/macunpack/dd.c @@ -1,20 +1,19 @@ #include "macunpack.h" +#define DD_INTERNAL +#include "dd.h" #ifdef DD #include #include #include "globals.h" -#include "dd.h" #include "crc.h" +#include "cpt.h" +#include "de_compress.h" #include "../fileio/machdr.h" #include "../fileio/wrfile.h" #include "../fileio/fileglob.h" #include "../util/masks.h" #include "../util/util.h" -extern void cpt_wrfile1(); -extern void core_compress(); -extern void de_compress(); - static void dd_name(); static int dd_filehdr(); static void dd_cfilehdr(); @@ -73,12 +72,12 @@ static int dd_bitcount; static unsigned char *dd_bitptr; static char dd_LZbuff[2048]; -void dd_file(bin_hdr) -unsigned char *bin_hdr; +void +dd_file (unsigned char *bin_hdr) { unsigned long data_size; int i; - struct fileCHdr cf; + struct dd_fileCHdr cf; char ftype[5], fauth[5]; updcrc = binhex_updcrc; @@ -147,13 +146,13 @@ unsigned char *bin_hdr; } } -void dd_arch(bin_hdr) -unsigned char *bin_hdr; +void +dd_arch (unsigned char *bin_hdr) { unsigned long data_size; uint32_t crc, filecrc; - struct fileHdr f; - struct fileCHdr cf; + struct dd_fileHdr f; + struct dd_fileCHdr cf; char locname[64]; int i, nlength; @@ -225,7 +224,7 @@ unsigned char *bin_hdr; dd_chksum(f, dd_data_ptr); dd_expand(cf, dd_data_ptr); case DD_IVAL: - dd_data_ptr += f.dataLength - CFILEHDRSIZE; + dd_data_ptr += f.dataLength - CDD_FILEHDRSIZE; break; case DD_COPY: dd_copy(f, dd_data_ptr); @@ -281,8 +280,8 @@ unsigned char *bin_hdr; } } -static void dd_name(bin_hdr) -unsigned char *bin_hdr; +static void +dd_name (unsigned char *bin_hdr) { int nlength; unsigned char *extptr; @@ -316,10 +315,8 @@ unsigned char *bin_hdr; bin_hdr[I_NAMEOFF] = nlength; } -static int dd_filehdr(f, cf, skip) -struct fileHdr *f; -struct fileCHdr *cf; -int skip; +static int +dd_filehdr (struct dd_fileHdr *f, struct dd_fileCHdr *cf, int skip) { register int i; uint32_t crc; @@ -330,12 +327,12 @@ int skip; to_uncompress = DD_COPY; hdr = dd_data_ptr; - dd_data_ptr += FILEHDRSIZE; + dd_data_ptr += DD_FILEHDRSIZE; for(i = 0; i < INFOBYTES; i++) { info[i] = '\0'; } crc = INIT_CRC; - crc = (*updcrc)(crc, hdr, FILEHDRSIZE - 2); + crc = (*updcrc)(crc, hdr, DD_FILEHDRSIZE - 2); f->hdrcrc = get2((char *)hdr + D_HDRCRC); if(f->hdrcrc != crc) { @@ -425,18 +422,18 @@ int skip; return to_uncompress; } -static void dd_cfilehdr(f) -struct fileCHdr *f; +static void +dd_cfilehdr (struct dd_fileCHdr *f) { uint32_t crc; unsigned char *hdr; hdr = dd_data_ptr; - dd_data_ptr += CFILEHDRSIZE; + dd_data_ptr += CDD_FILEHDRSIZE; crc = INIT_CRC; - crc = (*updcrc)(crc, hdr, CFILEHDRSIZE - 2); + crc = (*updcrc)(crc, hdr, CDD_FILEHDRSIZE - 2); - f->hdrcrc = get2((char *)hdr + C_HDRCRC); + f->hdrcrc = get2((char *)hdr + DD_C_HDRCRC); if(f->hdrcrc != crc) { (void)fprintf(stderr, "Header CRC mismatch: got 0x%04x, need 0x%04x\n", f->hdrcrc & WORDMASK, (int)crc); @@ -474,14 +471,14 @@ struct fileCHdr *f; } } -static int dd_valid(dmethod, rmethod) -int dmethod, rmethod; +static int +dd_valid (int dmethod, int rmethod) { return dd_valid1(dmethod) | dd_valid1(rmethod); } -static int dd_valid1(method) -int method; +static int +dd_valid1 (int method) { switch(method) { case nocomp: @@ -499,8 +496,8 @@ int method; return 0; } -static char *dd_methname(n) -int n; +static char * +dd_methname (int n) { int i, nmeths; nmeths = sizeof(methods) / sizeof(struct methodinfo); @@ -512,10 +509,8 @@ int i, nmeths; return NULL; } -static unsigned long dd_checksum(init, buffer, length) -unsigned long init; -char *buffer; -unsigned long length; +static unsigned long +dd_checksum (unsigned long init, char *buffer, unsigned long length) { int i; unsigned long cks; @@ -527,14 +522,13 @@ unsigned long length; return cks & WORDMASK; } -static void dd_chksum(hdr, data) -struct fileHdr hdr; -unsigned char *data; +static void +dd_chksum (struct dd_fileHdr hdr, unsigned char *data) { unsigned long cks; if(write_it) { - cks = dd_checksum(INIT_CRC, (char *)data - CFILEHDRSIZE, + cks = dd_checksum(INIT_CRC, (char *)data - CDD_FILEHDRSIZE, hdr.dataLength); if(hdr.datacrc != cks) { (void)fprintf(stderr, @@ -548,10 +542,8 @@ unsigned char *data; } } -static unsigned long dd_checkor(init, buffer, length) -unsigned long init; -char *buffer; -unsigned long length; +static unsigned long +dd_checkor (unsigned long init, char *buffer, unsigned long length) { int i; unsigned long cks; @@ -563,10 +555,8 @@ unsigned long length; return cks & WORDMASK; } -static void dd_do_delta(out_ptr, nbytes, kind) -char *out_ptr; -unsigned long nbytes; -int kind; +static void +dd_do_delta (char *out_ptr, unsigned long nbytes, int kind) { switch(kind) { case 0: @@ -586,9 +576,8 @@ int kind; } } -static void dd_delta(out_ptr, nbytes) -char *out_ptr; -unsigned long nbytes; +static void +dd_delta (char *out_ptr, unsigned long nbytes) { int i, sum = 0; @@ -598,9 +587,8 @@ unsigned long nbytes; } } -static void dd_delta3(out_ptr, nbytes) -char *out_ptr; -unsigned long nbytes; +static void +dd_delta3 (char *out_ptr, unsigned long nbytes) { int i, sum1 = 0, sum2 = 0, sum3 = 0; @@ -621,9 +609,8 @@ unsigned long nbytes; /*---------------------------------------------------------------------------*/ /* Archive only, no compression */ /*---------------------------------------------------------------------------*/ -static void dd_copy(hdr, data) -struct fileHdr hdr; -unsigned char *data; +static void +dd_copy (struct dd_fileHdr hdr, unsigned char *data) { unsigned long cks; @@ -673,9 +660,8 @@ unsigned char *data; } } -static void dd_copyfile(obytes, data) -unsigned long obytes; -unsigned char *data; +static void +dd_copyfile (unsigned long obytes, unsigned char *data) { if(obytes == 0) { return; @@ -688,9 +674,8 @@ unsigned char *data; /*---------------------------------------------------------------------------*/ /* Possible compression, and perhaps in an archive */ /*---------------------------------------------------------------------------*/ -static void dd_expand(hdr, data) -struct fileCHdr hdr; -unsigned char *data; +static void +dd_expand (struct dd_fileCHdr hdr, unsigned char *data) { unsigned long cks; char *out_buf; @@ -754,10 +739,8 @@ unsigned char *data; } } -static void dd_expandfile(obytes, ibytes, method, kind, data, chksum) -unsigned long obytes, ibytes, chksum; -int method, kind; -unsigned char *data; +static void +dd_expandfile (unsigned long obytes, unsigned long ibytes, int method, int kind, unsigned char *data, unsigned long chksum) { int sub_method, m1, m2; char *optr = out_ptr; @@ -855,9 +838,8 @@ unsigned char *data; /*---------------------------------------------------------------------------*/ /* Method 0: no compression */ /*---------------------------------------------------------------------------*/ -static void dd_nocomp(obytes, data) -unsigned char *data; -unsigned long obytes; +static void +dd_nocomp (unsigned long obytes, unsigned char *data) { copy(out_ptr, (char *)data, (int)obytes); } @@ -865,10 +847,8 @@ unsigned long obytes; /*---------------------------------------------------------------------------*/ /* Method 1: LZC compressed */ /*---------------------------------------------------------------------------*/ -static void dd_lzc(ibytes, obytes, data, mb, chksum, ckinit) -unsigned char *data; -unsigned long ibytes, obytes, chksum, ckinit; -int mb; +static void +dd_lzc (unsigned long ibytes, unsigned long obytes, unsigned char *data, int mb, unsigned long chksum, unsigned long ckinit) { int i; char *out_buf; @@ -899,9 +879,8 @@ int mb; /*---------------------------------------------------------------------------*/ /* Method 3: Run length encoding */ /*---------------------------------------------------------------------------*/ -static void dd_rle(ibytes, data) -unsigned char *data; -unsigned long ibytes; +static void +dd_rle (unsigned long ibytes, unsigned char *data) { int ch, lastch, n, i; @@ -930,9 +909,8 @@ unsigned long ibytes; /*---------------------------------------------------------------------------*/ /* Method 4: Huffman encoding */ /*---------------------------------------------------------------------------*/ -static void dd_huffman(ibytes, data) -unsigned char *data; -unsigned long ibytes; +static void +dd_huffman (unsigned long ibytes, unsigned char *data) { } #endif /* NOTIMPLEMENTED */ @@ -940,9 +918,8 @@ unsigned long ibytes; /*---------------------------------------------------------------------------*/ /* Method 7: Slightly improved LZSS */ /*---------------------------------------------------------------------------*/ -static void dd_lzss(data, chksum) -unsigned char *data; -unsigned long chksum; +static void +dd_lzss (unsigned char *data, unsigned long chksum) { int i, LZptr, LZbptr, LZlength; char *optr = out_ptr; @@ -994,8 +971,8 @@ unsigned long chksum; } } -static int dd_getbits(n) -int n; +static int +dd_getbits (int n) { int r; @@ -1014,10 +991,8 @@ int n; /*---------------------------------------------------------------------------*/ /* Method 8: Compactor compatible compression */ /*---------------------------------------------------------------------------*/ -static void dd_cpt_compat(ibytes, obytes, data, sub_method, chksum) -unsigned char *data; -unsigned long ibytes, obytes, chksum; -int sub_method; +static void +dd_cpt_compat (unsigned long ibytes, unsigned long obytes, unsigned char *data, int sub_method, unsigned long chksum) { unsigned long cks; char *optr = out_buffer; diff --git a/macunpack/dd.h b/macunpack/dd.h index b608f6c..4464430 100644 --- a/macunpack/dd.h +++ b/macunpack/dd.h @@ -1,3 +1,8 @@ +#include "macunpack.h" + +#ifdef DD +#ifdef DD_INTERNAL + #define MAGIC1 "DDAR" #define MAGIC2 "\253\315\000\124" @@ -22,7 +27,7 @@ #define D_DATACRC 118 #define D_RSRCCRC 120 #define D_HDRCRC 122 -#define FILEHDRSIZE 124 +#define DD_FILEHDRSIZE 124 /* Compressed file header */ #define C_MAGIC 0 @@ -47,12 +52,12 @@ #define C_FILL2 58 #define C_DATACRC2 78 #define C_RSRCCRC2 80 -#define C_HDRCRC 82 -#define CFILEHDRSIZE 84 +#define DD_C_HDRCRC 82 +#define CDD_FILEHDRSIZE 84 typedef long OSType; -typedef struct fileHdr { /* 124 bytes */ +typedef struct dd_fileHdr { /* 124 bytes */ unsigned char magic[4]; /* "DDAR" */ unsigned char fill1[4]; /* ??? */ unsigned char fName[64]; /* a STR63 */ @@ -71,9 +76,9 @@ typedef struct fileHdr { /* 124 bytes */ unsigned short datacrc; /* checksum */ unsigned short rsrccrc; unsigned short hdrcrc; /* true crc */ -} fileHdr; +} dd_fileHdr; -typedef struct fileCHdr { /* 84 bytes */ +typedef struct dd_fileCHdr { /* 84 bytes */ unsigned char magic[4]; /* "\253\315\000\124" */ unsigned long dataLength; /* lengths */ unsigned long dataCLength; @@ -101,7 +106,7 @@ typedef struct fileCHdr { /* 84 bytes */ unsigned short datacrc2; /* other checksum */ unsigned short rsrccrc2; unsigned short hdrcrc; /* true crc */ -} fileCHdr; +} dd_fileCHdr; #define DD_FILE 0 #define DD_COPY 1 @@ -123,3 +128,7 @@ typedef struct fileCHdr { /* 84 bytes */ #define ESC 0x144 /* Repeat packing escape */ +#endif +void dd_file (unsigned char *bin_hdr); +void dd_arch (unsigned char *bin_hdr); +#endif \ No newline at end of file diff --git a/macunpack/de_compress.c b/macunpack/de_compress.c index a393a5a..3aa3324 100644 --- a/macunpack/de_compress.c +++ b/macunpack/de_compress.c @@ -1,3 +1,4 @@ +#include "de_compress.h" #include "macunpack.h" #ifdef SIT #define DECOMPRESS @@ -44,9 +45,7 @@ static int clear_flg = 0; static int toread; -void de_compress(ibytes, mb) -unsigned long ibytes; -int mb; +void de_compress(unsigned long ibytes, int mb) { register unsigned char *stackp; register int finchar; @@ -125,7 +124,8 @@ static char *core_ptr; static int file_bytes(); static int core_bytes(); -static long getcode() +static long +getcode (void) { register long code; static int offset = 0, size = 0; @@ -194,16 +194,14 @@ static long getcode() return code; } -static int file_bytes(buf, length) -char *buf; -int length; +static int +file_bytes (char *buf, int length) { return fread(buf, 1, length, infp); } -static int core_bytes(buf, length) -char *buf; -int length; +static int +core_bytes (char *buf, int length) { int i; @@ -213,8 +211,7 @@ int length; return length; } -void core_compress(ptr) -char *ptr; +void core_compress(char* ptr) { core_ptr = ptr; get_core_bytes = ptr != NULL; diff --git a/macunpack/de_compress.h b/macunpack/de_compress.h new file mode 100644 index 0000000..29fe23b --- /dev/null +++ b/macunpack/de_compress.h @@ -0,0 +1,2 @@ +void de_compress(unsigned long ibytes, int mb); +void core_compress(char* ptr); diff --git a/macunpack/de_huffman.c b/macunpack/de_huffman.c index 3242921..df120d6 100644 --- a/macunpack/de_huffman.c +++ b/macunpack/de_huffman.c @@ -1,3 +1,5 @@ +#include "de_huffman.h" + #include "macunpack.h" #ifdef JDW #define DEHUFFMAN @@ -60,7 +62,8 @@ void set_huffman(int endian) } } -void read_tree() +void +read_tree (void) { nodeptr = nodelist; bit = 0; /* put us on a boundary */ @@ -86,7 +89,8 @@ static node *read_sub_tree() } /* This routine returns the next bit in the input stream (MSB first) */ -static int getbit_be() +static int +getbit_be (void) { static int b; @@ -100,7 +104,8 @@ static int getbit_be() } /* This routine returns the next bit in the input stream (LSB first) */ -static int getbit_le() +static int +getbit_le (void) { static int b; @@ -113,7 +118,8 @@ static int getbit_le() return (b >> (7 - bit)) & 1; } -void clrhuff() +void +clrhuff (void) { bit = 0; } @@ -129,12 +135,14 @@ int gethuffbyte(node *l_nodelist) return np->byte; } -int getihuffbyte() +int +getihuffbyte (void) { return gethuffbyte(nodelist); } -static int getdecodebyte() +static int +getdecodebyte (void) { register int i, b; diff --git a/macunpack/de_huffman.h b/macunpack/de_huffman.h new file mode 100644 index 0000000..541bfa8 --- /dev/null +++ b/macunpack/de_huffman.h @@ -0,0 +1,4 @@ +void set_huffman(int endian); +void read_tree(); +void de_huffman(unsigned long obytes); +void de_huffman_end(unsigned int term); \ No newline at end of file diff --git a/macunpack/de_lzah.c b/macunpack/de_lzah.c index bfa28e7..ccdd47b 100644 --- a/macunpack/de_lzah.c +++ b/macunpack/de_lzah.c @@ -1,3 +1,5 @@ +#include "de_lzah.h" + #include "macunpack.h" #ifdef SIT #define DELZAH @@ -81,7 +83,7 @@ unsigned char (*lzah_getbyte)(); static void lzah_inithuf(); static void lzah_reorder(); -static void lzah_move(); +static void lzah_move(int *p, int *q, int n); static void lzah_getbit(); static void lzah_outchar(); @@ -93,8 +95,7 @@ static int Frequ[1000]; static int ForwTree[1000]; static int BackTree[1000]; -void de_lzah(obytes) -unsigned long obytes; +void de_lzah(unsigned long obytes) { int i, i1, j, ch, byte, offs, skip; @@ -180,7 +181,8 @@ unsigned long obytes; } } -static void lzah_inithuf() +static void +lzah_inithuf (void) { int i, j; @@ -199,7 +201,8 @@ static void lzah_inithuf() BackTree[T - 1] = 0; } -static void lzah_reorder() +static void +lzah_reorder (void) { int i, j, k, l; @@ -236,8 +239,8 @@ static void lzah_reorder() } } -static void lzah_move(p, q, n) -int *p, *q, n; +static void lzah_move(int *p, int *q, int n) + { if(p > q) { while(n-- > 0) { @@ -252,7 +255,8 @@ int *p, *q, n; } } -static void lzah_getbit() +static void +lzah_getbit (void) { if(lzah_bitsavail != 0) { lzah_bits = lzah_bits + lzah_bits; @@ -263,8 +267,8 @@ static void lzah_getbit() } } -static void lzah_outchar(ch) -char ch; +static void +lzah_outchar (int ch) { *out_ptr++ = ch; lzah_buf[lzah_bufptr++] = ch; diff --git a/macunpack/de_lzah.h b/macunpack/de_lzah.h new file mode 100644 index 0000000..d45894d --- /dev/null +++ b/macunpack/de_lzah.h @@ -0,0 +1,8 @@ +#ifndef DE_LZAH_H +#define DE_LZAH_H + +extern void de_lzah(unsigned long obytes); +extern unsigned char (*lzah_getbyte)(); +extern void de_lzh(long ibytes, long obytes, char **data, int bits); + +#endif diff --git a/macunpack/de_lzh.c b/macunpack/de_lzh.c index 9d16177..226f593 100644 --- a/macunpack/de_lzh.c +++ b/macunpack/de_lzh.c @@ -24,11 +24,7 @@ static unsigned int decode_p(); static void make_table(); /* lzh compression */ -void de_lzh(ibytes, obytes, data, bits) -long ibytes; -long obytes; -char **data; -int bits; +void de_lzh(long ibytes, long obytes, char **data, int bits) { unsigned int i, r, c; int remains; @@ -86,10 +82,8 @@ static unsigned int left[2 * NC - 1], right[2 * NC - 1]; static unsigned char c_len[NC], pt_len[NPT]; static unsigned int c_table[4096], pt_table[256]; -static void read_pt_len(nn, nbit, i_special) -int nn; -int nbit; -int i_special; +static void +read_pt_len (int nn, int nbit, int i_special) { int i, c, n; unsigned int mask; @@ -130,7 +124,8 @@ int i_special; } } -static void read_c_len() +static void +read_c_len (void) { int i, c, n; unsigned int mask; @@ -182,7 +177,8 @@ static void read_c_len() } } -static unsigned int decode_c() +static unsigned int +decode_c (void) { unsigned int j, mask; @@ -213,7 +209,8 @@ static unsigned int decode_c() return j; } -static unsigned int decode_p() +static unsigned int +decode_p (void) { unsigned int j, mask; @@ -236,11 +233,8 @@ static unsigned int decode_p() return j; } -static void make_table(nchar, bitlen, tablebits, table) -int nchar; -unsigned char bitlen[]; -int tablebits; -unsigned int table[]; +static void +make_table (int nchar, unsigned char bitlen[], int tablebits, unsigned int table[]) { unsigned int count[17], weight[17], start[18], *p; unsigned int i, k, len, ch, jutbits, avail, nextcode, mask; diff --git a/macunpack/dia.c b/macunpack/dia.c index 0ad0616..718ca9d 100644 --- a/macunpack/dia.c +++ b/macunpack/dia.c @@ -35,8 +35,8 @@ static void dia_getblock(); static int dia_decode(); static int dia_prevbit(); -void dia(bin_hdr) -unsigned char *bin_hdr; +void +dia (unsigned char *bin_hdr) { int i, folder, nlength; unsigned char hdr; @@ -109,11 +109,11 @@ unsigned char *bin_hdr; free((char *)header); } -static void dia_folder(name) -unsigned char *name; +static void +dia_folder (unsigned char *name) { unsigned char lname[32]; - int i, length, doit; + int i, length, doit = 0; unsigned char indicator, *old_ptr; if(name != NULL) { @@ -191,8 +191,8 @@ unsigned char *name; } } -static void dia_file(indicator, name) -unsigned char indicator, *name; +static void +dia_file (int indicator, unsigned char *name) { unsigned char lname[32]; int i, length, doit; @@ -346,8 +346,8 @@ unsigned char indicator, *name; } } -static void dia_getlength(nblocks) -int nblocks; +static void +dia_getlength (int nblocks) { int length; unsigned char *arch_ptr, *block_ptr; @@ -379,8 +379,8 @@ int nblocks; } } -static void dia_skipfork(nblocks) -int nblocks; +static void +dia_skipfork (int nblocks) { int length; @@ -393,16 +393,16 @@ int nblocks; } } -static void dia_getfork(nblocks) -int nblocks; +static void +dia_getfork (int nblocks) { while(nblocks-- > 0) { dia_getblock(&dia_archive_ptr, (unsigned char **)&out_ptr); } } -static void dia_getblock(archive_ptr, block_ptr) -unsigned char **archive_ptr, **block_ptr; +static void +dia_getblock (unsigned char **archive_ptr, unsigned char **block_ptr) { int length, i; unsigned char *arch_ptr, *bl_ptr; @@ -425,8 +425,8 @@ unsigned char **archive_ptr, **block_ptr; *archive_ptr += length + 2; } -static int dia_decode(ibuff, obuff, in_length) -unsigned char *ibuff, *obuff; int in_length; +static int +dia_decode (unsigned char *ibuff, unsigned char *obuff, int in_length) { int nbits, set_zero, i, j; unsigned char *bitbuf_ptr; @@ -539,7 +539,8 @@ unsigned char *ibuff, *obuff; int in_length; return out_ptr - obuff; } -static int dia_prevbit() +static int +dia_prevbit (void) { int c; diff --git a/macunpack/dir.c b/macunpack/dir.c index a1e3182..1d9ba6b 100644 --- a/macunpack/dir.c +++ b/macunpack/dir.c @@ -9,8 +9,8 @@ static char *dir_stack; static int dir_ptr = -64; static int dir_max; -void dir(hdr) -char *hdr; +void +dir (char *hdr) { int doit; diff --git a/macunpack/globals.c b/macunpack/globals.c index d878a7b..a2bf3de 100644 --- a/macunpack/globals.c +++ b/macunpack/globals.c @@ -13,8 +13,8 @@ int in_rsrc_size = -1; int in_ds, in_rs, ds_skip, rs_skip; #ifdef SCAN -void do_error(string) -char *string; +void +do_error (char *string) { do_idf(string, ERROR); } diff --git a/macunpack/jdw.c b/macunpack/jdw.c index e479994..ab5e3ec 100644 --- a/macunpack/jdw.c +++ b/macunpack/jdw.c @@ -3,22 +3,18 @@ #include "jdw.h" #include "globals.h" #include "huffman.h" +#include "de_huffman.h" #include "../fileio/wrfile.h" #include "../fileio/machdr.h" #include "../util/util.h" #include "../util/masks.h" -extern void de_huffman(); -extern void set_huffman(); -extern void read_tree(); -extern void clrhuff(); - static void jdw_wrfile(); static void jdw_wrfork(); static void jdw_block(); -void jdw(ibytes) -unsigned long ibytes; +void +jdw (unsigned long ibytes) { char fauth[5], ftype[5]; int filel, i; @@ -81,8 +77,8 @@ unsigned long ibytes; jdw_wrfile((unsigned long)rsrcLength, (unsigned long)dataLength); } -static void jdw_wrfile(rsrcLength, dataLength) -unsigned long rsrcLength, dataLength; +static void +jdw_wrfile (unsigned long rsrcLength, unsigned long dataLength) { if(write_it) { define_name(text); @@ -108,8 +104,8 @@ unsigned long rsrcLength, dataLength; } } -static void jdw_wrfork(length) -unsigned long length; +static void +jdw_wrfork (unsigned long length) { int olength, ilength, i; unsigned long origlength, comprlength; @@ -141,8 +137,8 @@ unsigned long length; } } -static void jdw_block(olength) -int olength; +static void +jdw_block (int olength) { bytesread = 0; read_tree(); diff --git a/macunpack/jdw.h b/macunpack/jdw.h index 05badff..c47b100 100644 --- a/macunpack/jdw.h +++ b/macunpack/jdw.h @@ -8,7 +8,7 @@ #define J_MTIME 34 #define J_FLENGTH 38 -typedef struct fileHdr { +typedef struct jdw_fileHdr { char magic[6]; unsigned long type; unsigned long auth; @@ -19,5 +19,5 @@ typedef struct fileHdr { unsigned long mtime; char flength; char fname[32]; /* actually flength */ -} fileHdr; +} jdw_fileHdr; diff --git a/macunpack/lzc.c b/macunpack/lzc.c index 5fa3c46..00d89a3 100644 --- a/macunpack/lzc.c +++ b/macunpack/lzc.c @@ -7,17 +7,15 @@ #include "../fileio/machdr.h" #include "../fileio/wrfile.h" #include "../util/masks.h" - -extern void de_compress(); -extern void core_compress(); -extern void mcb(); +#include "de_compress.h" +#include "mcb.h" static void lzc_zivm(); static void lzc_wrfile(); static void lzc_zivu(); -void lzc(ohdr) -char *ohdr; +void +lzc (char *ohdr) { core_compress((char *)NULL); if(!strncmp(ohdr + I_TYPEOFF, "ZIVM", 4)) { @@ -27,8 +25,8 @@ char *ohdr; } } -static void lzc_zivm(ohdr) -char *ohdr; +static void +lzc_zivm (char *ohdr) { char hdr[HEADERBYTES]; unsigned long dataLength, rsrcLength, dataCLength, rsrcCLength; @@ -109,8 +107,8 @@ char *ohdr; } } -static void lzc_wrfile(obytes, ibytes) -unsigned long obytes, ibytes; +static void +lzc_wrfile (unsigned long obytes, unsigned long ibytes) { int n, nbits; char subheader[3]; @@ -183,8 +181,8 @@ unsigned long obytes, ibytes; } } -static void lzc_zivu(ohdr) -char *ohdr; +static void +lzc_zivu (char *ohdr) { (void)fprintf(stderr, "\tMacCompress(Unix) not yet implemented, copied as MacBinary\n"); diff --git a/macunpack/lzc.h b/macunpack/lzc.h index c42eb2c..34d4604 100644 --- a/macunpack/lzc.h +++ b/macunpack/lzc.h @@ -12,7 +12,7 @@ #define C_AUTHOFF 36 #define C_FLAGOFF 40 -typedef struct fileHdr { +typedef struct lzc_fileHdr { unsigned long magic1; unsigned long dataLength; unsigned long dataCLength; @@ -25,4 +25,4 @@ typedef struct fileHdr { unsigned long fileauth; unsigned long flag1; unsigned long flag2; -} fileHdr; +} lzc_fileHdr; diff --git a/macunpack/lzh.c b/macunpack/lzh.c index 8273b79..300d008 100644 --- a/macunpack/lzh.c +++ b/macunpack/lzh.c @@ -72,10 +72,10 @@ static void lzh_lzh12(); #endif /* UNTESTED */ static void lzh_lzh13(); -void lzh(kind) -int kind; +void +lzh (int kind) { - struct fileHdr filehdr; + struct lzh_fileHdr filehdr; int m, i, j; char loc_name[64]; char dirinfo[INFOBYTES]; @@ -213,8 +213,8 @@ int kind; } } -static int lzh_filehdr(f) -struct fileHdr *f; +static int +lzh_filehdr (struct lzh_fileHdr *f) { register int i; char *hdr; @@ -335,8 +335,8 @@ struct fileHdr *f; return 1; } -static int lzh_checkm(f) -struct fileHdr *f; +static int +lzh_checkm (struct lzh_fileHdr *f) { int i, nummeth; char *meth; @@ -351,8 +351,8 @@ struct fileHdr *f; return -1; } -static char *lzh_methname(n) -int n; +static char * +lzh_methname (int n) { if(n > sizeof(methods) / sizeof(struct methodinfo)) { return NULL; @@ -360,9 +360,8 @@ int n; return methods[n].name; } -static void lzh_wrfile(filehdr, method) -struct fileHdr *filehdr; -int method; +static void +lzh_wrfile (struct lzh_fileHdr *filehdr, int method) { char ftype[5], fauth[5]; int rsrcLength, dataLength; @@ -579,8 +578,8 @@ int method; lzh_skip(filehdr); } -static void lzh_skip(filehdr) -struct fileHdr *filehdr; +static void +lzh_skip (struct lzh_fileHdr *filehdr) { lzh_pointer += filehdr->psize; in_data_size -= filehdr->psize; @@ -589,8 +588,8 @@ struct fileHdr *filehdr; /*---------------------------------------------------------------------------*/ /* -lz4- and -lh0: No compression */ /*---------------------------------------------------------------------------*/ -static void lzh_nocomp(obytes) -unsigned long obytes; +static void +lzh_nocomp (unsigned long obytes) { copy(lzh_file, lzh_data, (int)obytes); } @@ -599,8 +598,8 @@ unsigned long obytes; /*---------------------------------------------------------------------------*/ /* -lz5-: LZSS compression, variant 1 */ /*---------------------------------------------------------------------------*/ -static void lzh_lzss1(obytes) -unsigned long obytes; +static void +lzh_lzss1 (unsigned long obytes) { int mask, ch, lzcnt, lzptr, ptr, count; char *p = lzh_lzbuf; @@ -662,8 +661,8 @@ unsigned long obytes; /*---------------------------------------------------------------------------*/ /* -lzs-: LZSS compression, variant 2 */ /*---------------------------------------------------------------------------*/ -static void lzh_lzss2(obytes) -unsigned long obytes; +static void +lzh_lzss2 (unsigned long obytes) { int ch, lzcnt, lzptr, ptr, i; @@ -706,8 +705,8 @@ unsigned long obytes; /*---------------------------------------------------------------------------*/ /* -lh1-: LZ compression plus adaptive Huffman encoding */ /*---------------------------------------------------------------------------*/ -static void lzh_lzah(obytes) -unsigned long obytes; +static void +lzh_lzah (unsigned long obytes) { lzh_current = lzh_data + 2; /* SKIPPING BLOCKSIZE! */ tmp_out_ptr = out_ptr; @@ -717,7 +716,8 @@ unsigned long obytes; out_ptr = tmp_out_ptr; } -static unsigned char lzh_getbyte() +static unsigned char +lzh_getbyte (void) { return *lzh_current++; } @@ -726,16 +726,16 @@ static unsigned char lzh_getbyte() /*---------------------------------------------------------------------------*/ /* -lh2-: LZ** compression */ /*---------------------------------------------------------------------------*/ -static void lzh_lh2(obytes) -unsigned long obytes; +static void +lzh_lh2 (unsigned long obytes) { } /*---------------------------------------------------------------------------*/ /* -lh3-: LZ** compression */ /*---------------------------------------------------------------------------*/ -static void lzh_lh3(obytes) -unsigned long obytes; +static void +lzh_lh3 (unsigned long obytes) { } #endif /* UNDEF */ @@ -744,8 +744,8 @@ unsigned long obytes; /*---------------------------------------------------------------------------*/ /* -lh4-: LZ(12) compression plus Huffman encoding */ /*---------------------------------------------------------------------------*/ -static void lzh_lzh12(obytes) -unsigned long obytes; +static void +lzh_lzh12 (unsigned long obytes) { lzh_current = lzh_data; tmp_out_ptr = out_ptr; @@ -759,8 +759,8 @@ unsigned long obytes; /*---------------------------------------------------------------------------*/ /* -lh5-: LZ(13) compression plus Huffman encoding */ /*---------------------------------------------------------------------------*/ -static void lzh_lzh13(obytes) -unsigned long obytes; +static void +lzh_lzh13 (unsigned long obytes) { lzh_current = lzh_data; tmp_out_ptr = out_ptr; diff --git a/macunpack/lzh.h b/macunpack/lzh.h index 93ad340..df1dc76 100644 --- a/macunpack/lzh.h +++ b/macunpack/lzh.h @@ -30,7 +30,7 @@ #define L_EEXTENDSZ 0 #define L_EEXTEND 1 -typedef struct fileHdr { /* 58 bytes */ +typedef struct lzh_fileHdr { /* 58 bytes */ unsigned char hsize; unsigned char hcrc; char method[5]; @@ -45,7 +45,7 @@ typedef struct fileHdr { /* 58 bytes */ unsigned char extendsize; char *extend; char *data; -} fileHdr; +} lzh_fileHdr; /* Currently known methods: */ #define lh0 0 diff --git a/macunpack/macbinary.c b/macunpack/macbinary.c index 4142f31..6f0f678 100644 --- a/macunpack/macbinary.c +++ b/macunpack/macbinary.c @@ -6,18 +6,16 @@ #include "../fileio/kind.h" #include "zmahdr.h" #include "../util/util.h" +#include "stf.h" +#include "mcb.h" +#include "bin.h" +#include "dd.h" +#include "sit.h" -extern void dir(); -extern void mcb(); -#ifdef BIN -extern void bin(); -#endif /* BIN */ +extern void dir(char *hdr); #ifdef JDW extern void jdw(); #endif /* JDW */ -#ifdef STF -extern void stf(); -#endif /* STF */ #ifdef LZC extern void lzc(); #endif /* LZC */ @@ -30,9 +28,6 @@ extern void arc(); #ifdef PIT extern void pit(); #endif /* PIT */ -#ifdef SIT -extern void sit(); -#endif /* SIT */ #ifdef DIA extern void dia(); #endif /* DIA */ @@ -45,10 +40,6 @@ extern void zma(); #ifdef LZH extern void lzh(); #endif /* LZH */ -#ifdef DD -extern void dd_file(); -extern void dd_arch(); -#endif /* DD */ static void skip_file(); #ifdef SCAN @@ -59,7 +50,8 @@ static void get_idf(); static int info_given; -void macbinary() +void +macbinary (void) { char header[INFOBYTES]; int c; @@ -517,8 +509,8 @@ void macbinary() } } -static void skip_file(skip) -int skip; +static void +skip_file (int skip) { char buff[1024]; int n; @@ -537,8 +529,8 @@ int skip; } #ifdef SCAN -static void get_idf(kind) -int kind; +static void +get_idf (int kind) { char filename[255]; diff --git a/macunpack/macunpack.c b/macunpack/macunpack.c index bc6c28a..051f7d5 100644 --- a/macunpack/macunpack.c +++ b/macunpack/macunpack.c @@ -192,7 +192,8 @@ int main(int argc, char **argv) /* NOTREACHED */ } -static void usage() +static void +usage (void) { fprintf(stderr, "Usage: macunpack [-%s] [filename]\n", options); fprintf(stderr, "Use \"macunpack -H\" for help.\n"); diff --git a/macunpack/mcb.c b/macunpack/mcb.c index e025498..580ebda 100644 --- a/macunpack/mcb.c +++ b/macunpack/mcb.c @@ -8,10 +8,7 @@ static int mcb_read; static void mcb_wrfile(); -void mcb(hdr, rsrcLength, dataLength, toread) -char *hdr; -unsigned long rsrcLength, dataLength; -int toread; +void mcb(char *hdr, unsigned long rsrcLength, unsigned long dataLength, int toread) { register int i; int n; @@ -79,8 +76,8 @@ int toread; } } -static void mcb_wrfile(ibytes) -unsigned long ibytes; +static void +mcb_wrfile (unsigned long ibytes) { int n; diff --git a/macunpack/mcb.h b/macunpack/mcb.h new file mode 100644 index 0000000..4e46a7e --- /dev/null +++ b/macunpack/mcb.h @@ -0,0 +1 @@ +extern void mcb(char *hdr, unsigned long rsrcLength, unsigned long dataLength, int toread); diff --git a/macunpack/pit.c b/macunpack/pit.c index 81b1406..edb9058 100644 --- a/macunpack/pit.c +++ b/macunpack/pit.c @@ -11,17 +11,15 @@ #include "../util/masks.h" #include "../util/util.h" #include "huffman.h" - -extern void read_tree(); -extern void de_huffman(); -extern void set_huffman(); +#include "de_huffman.h" static int pit_filehdr(); static void pit_wrfile(); static void pit_nocomp(); static void pit_huffman(); -void pit() +void +pit (void) { struct pit_header filehdr; char pithdr[4]; @@ -159,9 +157,8 @@ void pit() } } -static int pit_filehdr(f, compr) -struct pit_header *f; -int compr; +static int +pit_filehdr (struct pit_header *f, int compr) { register int i; uint32_t crc; @@ -238,9 +235,8 @@ int compr; return 1; } -static void pit_wrfile(bytes, type) -unsigned long bytes; -int type; +static void +pit_wrfile (unsigned long bytes, int type) { if(bytes == 0) { return; @@ -257,8 +253,8 @@ int type; /*---------------------------------------------------------------------------*/ /* No compression */ /*---------------------------------------------------------------------------*/ -static void pit_nocomp(ibytes) -unsigned long ibytes; +static void +pit_nocomp (unsigned long ibytes) { int n; @@ -275,8 +271,8 @@ unsigned long ibytes; /*---------------------------------------------------------------------------*/ /* Huffman compression */ /*---------------------------------------------------------------------------*/ -static void pit_huffman(obytes) -unsigned long obytes; +static void +pit_huffman (unsigned long obytes) { de_huffman(obytes); } diff --git a/macunpack/sit.c b/macunpack/sit.c index 22559c9..88f15ec 100644 --- a/macunpack/sit.c +++ b/macunpack/sit.c @@ -1,8 +1,10 @@ #include "macunpack.h" +#define SIT_INTERNAL +#include "sit.h" + #ifdef SIT #include #include "globals.h" -#include "sit.h" #include "crc.h" #include "../util/util.h" #include "../fileio/machdr.h" @@ -10,15 +12,10 @@ #include "../fileio/kind.h" #include "../util/masks.h" #include "huffman.h" +#include "de_compress.h" +#include "de_huffman.h" +#include "de_lzah.h" -extern void de_compress(); -extern void core_compress(); -extern void de_huffman(); -extern void de_huffman_end(); -extern void read_tree(); -extern void set_huffman(); -extern void de_lzah(); -extern unsigned char (*lzah_getbyte)(); typedef struct methodinfo { char *name; @@ -96,10 +93,11 @@ static short sit_dict[16385]; static unsigned long sit_avail; static int sit_bits_avail; -void sit() +void +sit (void) { struct sitHdr sithdr; - struct fileHdr filehdr; + struct sit_fileHdr filehdr; int i; set_huffman(HUFF_BE); @@ -154,7 +152,7 @@ static int readsithdr(sitHdr *s) return 1; } -static int sit_filehdr(struct fileHdr *f, int skip) +static int sit_filehdr(struct sit_fileHdr *f, int skip) { register int i; uint32_t crc; @@ -239,8 +237,8 @@ static int sit_filehdr(struct fileHdr *f, int skip) return 1; } -static int sit_valid(f) -struct fileHdr f; +static int +sit_valid (struct sit_fileHdr f) { int fr = f.compRMethod, fd = f.compDMethod; @@ -283,8 +281,8 @@ struct fileHdr f; return 0; } -static int sit_checkm(f) -int f; +static int +sit_checkm (int f) { switch(f) { case nocomp: @@ -307,8 +305,8 @@ int f; /* NOTREACHED */ } -static char *sit_methname(n) -int n; +static char * +sit_methname (int n) { int i, nmeths; nmeths = sizeof(methods) / sizeof(struct methodinfo); @@ -320,12 +318,12 @@ int i, nmeths; return NULL; } -static void sit_folder(name) -char *name; +static void +sit_folder (char *name) { int i, recurse; char loc_name[64]; - struct fileHdr filehdr; + struct sit_fileHdr filehdr; for(i = 0; i < 64; i++) { loc_name[i] = name[i]; @@ -387,8 +385,8 @@ char *name; } } -static void sit_unstuff(filehdr) -struct fileHdr filehdr; +static void +sit_unstuff (struct sit_fileHdr filehdr) { uint32_t crc; @@ -439,9 +437,8 @@ struct fileHdr filehdr; } } -static void sit_wrfile(ibytes, obytes, type) -unsigned long ibytes, obytes; -unsigned char type; +static void +sit_wrfile (unsigned long ibytes, unsigned long obytes, int type) { if(ibytes == 0) { if(verbose) { @@ -536,8 +533,8 @@ unsigned char type; } /* skip stuffit file */ -static void sit_skip(ibytes) -unsigned long ibytes; +static void +sit_skip (unsigned long ibytes) { while(ibytes != 0) { if(getc(infp) == EOF) { @@ -554,8 +551,8 @@ unsigned long ibytes; /*---------------------------------------------------------------------------*/ /* Method 0: No compression */ /*---------------------------------------------------------------------------*/ -static void sit_nocomp(ibytes) -unsigned long ibytes; +static void +sit_nocomp (unsigned long ibytes) { int n; @@ -572,10 +569,10 @@ unsigned long ibytes; /*---------------------------------------------------------------------------*/ /* Method 1: Run length encoding */ /*---------------------------------------------------------------------------*/ -static void sit_rle(ibytes) -unsigned long ibytes; +static void +sit_rle (unsigned long ibytes) { - int ch, lastch, n, i; + int ch, lastch = 0, n, i; while(ibytes != 0) { ch = getb(infp) & BYTEMASK; @@ -602,8 +599,8 @@ unsigned long ibytes; /*---------------------------------------------------------------------------*/ /* Method 2: LZC compressed */ /*---------------------------------------------------------------------------*/ -static void sit_lzc(ibytes) -unsigned long ibytes; +static void +sit_lzc (unsigned long ibytes) { de_compress(ibytes, 14); } @@ -611,8 +608,8 @@ unsigned long ibytes; /*---------------------------------------------------------------------------*/ /* Method 3: Huffman compressed */ /*---------------------------------------------------------------------------*/ -static void sit_huffman(obytes) -unsigned long obytes; +static void +sit_huffman (unsigned long obytes) { read_tree(); de_huffman(obytes); @@ -621,14 +618,15 @@ unsigned long obytes; /*---------------------------------------------------------------------------*/ /* Method 5: LZ compression plus adaptive Huffman encoding */ /*---------------------------------------------------------------------------*/ -static void sit_lzah(obytes) -unsigned long obytes; +static void +sit_lzah (unsigned long obytes) { lzah_getbyte = sit_getbyte; de_lzah(obytes); } -static unsigned char sit_getbyte() +static unsigned char +sit_getbyte (void) { return getb(infp); } @@ -636,8 +634,8 @@ static unsigned char sit_getbyte() /*---------------------------------------------------------------------------*/ /* Method 6: Compression with a fixed Huffman encoding */ /*---------------------------------------------------------------------------*/ -static void sit_fixhuf(ibytes) -unsigned long ibytes; +static void +sit_fixhuf (unsigned long ibytes) { int i, sum, codes, sym, num; char byte_int[4], byte_short[2]; @@ -732,8 +730,8 @@ unsigned long ibytes; } } -static void sit_dosplit(ptr, sum, low, upp) -int ptr, sum, low, upp; +static void +sit_dosplit (int ptr, int sum, int low, int upp) { int i, locsum; @@ -760,8 +758,8 @@ int ptr, sum, low, upp; /*---------------------------------------------------------------------------*/ /* Method 8: Compression with a MW encoding */ /*---------------------------------------------------------------------------*/ -static void sit_mw(ibytes) -unsigned long ibytes; +static void +sit_mw (unsigned long ibytes) { int ptr; int max, max1, bits; @@ -802,8 +800,8 @@ start_over: } } -static void sit_mw_out(ptr) -int ptr; +static void +sit_mw_out (int ptr) { int stack_ptr; int stack[16384]; @@ -820,9 +818,8 @@ int ptr; } } -static int sit_mw_in(bits, ibytes) -int bits; -unsigned long *ibytes; +static int +sit_mw_in (int bits, unsigned long *ibytes) { int res, res1; diff --git a/macunpack/sit.h b/macunpack/sit.h index ce51332..06e439a 100644 --- a/macunpack/sit.h +++ b/macunpack/sit.h @@ -1,3 +1,7 @@ +#include "macunpack.h" +#ifdef SIT + +#ifdef SIT_INTERNAL #define S_SIGNATURE 0 #define S_NUMFILES 4 #define S_ARCLENGTH 6 @@ -34,7 +38,7 @@ typedef struct sitHdr { /* 22 bytes */ char reserved[7]; } sitHdr; -typedef struct fileHdr { /* 112 bytes */ +typedef struct sit_fileHdr { /* 112 bytes */ unsigned char compRMethod; /* rsrc fork compression method */ unsigned char compDMethod; /* data fork compression method */ unsigned char fName[64]; /* a STR63 */ @@ -53,7 +57,7 @@ typedef struct fileHdr { /* 112 bytes */ unsigned short dataCRC; /* crc of data fork */ char reserved[6]; unsigned short hdrCRC; /* crc of file header */ -} fileHdr; +} sit_fileHdr; /* file format is: sitArchiveHdr @@ -72,7 +76,6 @@ typedef struct fileHdr { /* 112 bytes */ */ - /* compression methods */ #define nocomp 0 /* just read each byte and write it to archive */ #define rle 1 /* RLE compression */ @@ -91,3 +94,9 @@ typedef struct fileHdr { /* 112 bytes */ /* all other numbers are reserved */ #define ESC 0x90 /* repeat packing escape */ + +#endif + +void sit (void); + +#endif \ No newline at end of file diff --git a/macunpack/stf.c b/macunpack/stf.c index b432e46..a42f11d 100644 --- a/macunpack/stf.c +++ b/macunpack/stf.c @@ -24,8 +24,8 @@ static void stf_wrfile(); static void stf_wrfork(); static void stf_construct(); -void stf(ibytes) -unsigned long ibytes; +void +stf (unsigned long ibytes) { char magic[3], fauth[5], ftype[5]; int filel, i; @@ -93,8 +93,8 @@ unsigned long ibytes; stf_wrfile((unsigned long)rsrcLength, (unsigned long)dataLength, ibytes); } -static void stf_wrfile(rsrcLength, dataLength, ibytes) -unsigned long rsrcLength, dataLength, ibytes; +static void +stf_wrfile (unsigned long rsrcLength, unsigned long dataLength, unsigned long ibytes) { unsigned long num = 0; @@ -117,9 +117,8 @@ unsigned long rsrcLength, dataLength, ibytes; } } -static void stf_wrfork(num, towrite, offs) -unsigned long *num, towrite; -int offs; +static void +stf_wrfork (unsigned long *num, unsigned long towrite, int offs) { int c, k, max, i, i1; char *tmp_out_ptr; @@ -187,8 +186,8 @@ int offs; } } -static void stf_construct(n) -int n; +static void +stf_construct (int n) { int i, i1, i2, j1, k; diff --git a/macunpack/stf.h b/macunpack/stf.h index 8fe1adb..839f3b9 100644 --- a/macunpack/stf.h +++ b/macunpack/stf.h @@ -1,3 +1,5 @@ +#include "macunpack.h" +#ifdef STF #define MAGIC "RTH" #define S_MAGIC 0 @@ -5,10 +7,13 @@ #define S_RSRCLNGTH 3 /* + NAMELENGTH */ #define S_DATALNGTH 7 /* + NAMELENGTH */ -typedef struct fileHdr { +typedef struct stf_fileHdr { char magic[3]; char flength; char fname[32]; /* actually flength */ unsigned long rsrcLength; unsigned long dataLength; -} fileHdr; +} stf_fileHdr; + +void stf (unsigned long ibytes); +#endif \ No newline at end of file diff --git a/macunpack/zma.c b/macunpack/zma.c index cf5466b..7756aed 100644 --- a/macunpack/zma.c +++ b/macunpack/zma.c @@ -27,11 +27,10 @@ static void zma_wrfile(); static void zma_nocomp(); static void zma_lzh(); -void zma(start, length) - char *start; - unsigned long length; +void +zma (char *start, unsigned long length) { - struct fileHdr filehdr; + struct zma_fileHdr filehdr; int i, toread; if(length != 0) { @@ -122,9 +121,8 @@ void zma(start, length) } } -static int zma_filehdr(f, skip) -struct fileHdr *f; -int skip; +static int +zma_filehdr (struct zma_fileHdr *f, int skip) { register int i; int n; @@ -228,12 +226,12 @@ int skip; return 1; } -static void zma_folder(fhdr) -struct fileHdr fhdr; +static void +zma_folder (struct zma_fileHdr fhdr) { int i; char loc_name[64]; - struct fileHdr filehdr; + struct zma_fileHdr filehdr; for(i = 0; i < 64; i++) { loc_name[i] = text[i]; @@ -271,8 +269,8 @@ struct fileHdr fhdr; } } -static void zma_mooz(filehdr) -struct fileHdr filehdr; +static void +zma_mooz (struct zma_fileHdr filehdr) { uint32_t crc; @@ -323,9 +321,8 @@ struct fileHdr filehdr; } } -static void zma_wrfile(ibytes, obytes, type) -unsigned long ibytes, obytes; -char type; +static void +zma_wrfile (unsigned long ibytes, unsigned long obytes, int type) { if(ibytes == 0) { if(verbose) { @@ -363,8 +360,8 @@ char type; /*---------------------------------------------------------------------------*/ /* No compression */ /*---------------------------------------------------------------------------*/ -static void zma_nocomp(ibytes) -unsigned long ibytes; +static void +zma_nocomp (unsigned long ibytes) { int n = ibytes; char *ptr = out_buffer; @@ -377,8 +374,8 @@ unsigned long ibytes; /*---------------------------------------------------------------------------*/ /* LZ compression plus Huffman encoding */ /*---------------------------------------------------------------------------*/ -static void zma_lzh(ibytes) -unsigned long ibytes; +static void +zma_lzh (unsigned long ibytes) { /* Controlled by ibutes only */ de_lzh((long)ibytes, (long)(-1), &zma_filestart, 13); diff --git a/macunpack/zma.h b/macunpack/zma.h index 8626942..297d8a2 100644 --- a/macunpack/zma.h +++ b/macunpack/zma.h @@ -20,7 +20,7 @@ #define Z_RCRC 44 /* Resource crc */ #define Z_FNAME 46 /* File name length and name */ -typedef struct fileHdr { /* 78 bytes */ +typedef struct zma_fileHdr { /* 78 bytes */ char deleted; /* Not in original, split off from: */ char what; /* What kind? Negative if deleted */ unsigned char hlen ; /* Header length */ @@ -42,7 +42,7 @@ typedef struct fileHdr { /* 78 bytes */ unsigned char fName[32]; /* a STR32 */ /* The following are overlayed in the original structure */ unsigned long conts; /* Pointer to directory contents */ -} fileHdr; +} zma_fileHdr; /* zma types (see what) */ #define z_noth 0 /* ??? */ diff --git a/mixed/macbinary.c b/mixed/macbinary.c index 5bf6bfd..f841b1c 100644 --- a/mixed/macbinary.c +++ b/mixed/macbinary.c @@ -12,7 +12,8 @@ static void skip_file(); static void get_idf(); #endif /* SCAN */ -void macbinary() +void +macbinary (void) { char header[INFOBYTES]; int c; @@ -58,8 +59,8 @@ void macbinary() } } -static void skip_file(skip) - int skip; +static void +skip_file (int skip) { char buff[1024]; int n; @@ -75,8 +76,8 @@ static void skip_file(skip) } #ifdef SCAN -static void get_idf(kind) - int kind; +static void +get_idf (int kind) { char filename[1024], filename1[255]; diff --git a/mixed/macsave.c b/mixed/macsave.c index b9d9dca..effecd0 100644 --- a/mixed/macsave.c +++ b/mixed/macsave.c @@ -87,7 +87,8 @@ int main(int argc, char **argv) /* NOTREACHED */ } -static void usage() +static void +usage (void) { (void)fprintf(stderr, "Usage: macsave [-%s]\n", options); (void)fprintf(stderr, "Use \"macsave -H\" for help.\n"); diff --git a/mixed/macstream.c b/mixed/macstream.c index c3ba4e6..85237af 100644 --- a/mixed/macstream.c +++ b/mixed/macstream.c @@ -6,9 +6,9 @@ #include "../fileio/rdfile.h" #include "../fileio/rdfileopt.h" #include "../util/patchlevel.h" +#include "../util/transname.h" #include "../util/util.h" -extern void transname(); extern void do_indent(); #define LOCALOPT "ilqVH" @@ -173,7 +173,8 @@ int main(int argc, char **argv) /* NOTREACHED */ } -static void usage() +static void +usage (void) { (void)fprintf(stderr, "Usage: macstream [-%s] files\n", options); (void)fprintf(stderr, "Use \"macstream -H\" for help.\n"); diff --git a/mixed/mcb.c b/mixed/mcb.c index 51b5987..688f4de 100644 --- a/mixed/mcb.c +++ b/mixed/mcb.c @@ -8,10 +8,8 @@ static int mcb_read; static void mcb_wrfile(); -void mcb(hdr, rsrcLength, dataLength, toread) -char *hdr; -unsigned long rsrcLength, dataLength; -int toread; +void +mcb (char *hdr, unsigned long rsrcLength, unsigned long dataLength, int toread) { register int i; int n; @@ -66,8 +64,8 @@ int toread; } } -static void mcb_wrfile(ibytes) -unsigned long ibytes; +static void +mcb_wrfile (unsigned long ibytes) { int n; diff --git a/util/transname.c b/util/transname.c index ef724b8..8c8ea70 100644 --- a/util/transname.c +++ b/util/transname.c @@ -1,8 +1,7 @@ +#include #include #include -char *strncpy(); - #ifdef MAXNAMLEN /* 4.2 BSD */ #define FNAMELEN MAXNAMLEN #else @@ -83,7 +82,7 @@ static char char_mapping[] = { '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_'}; -void transname(char *name, char *namebuf, int n) +void transname(char *name, char *namebuf, size_t n) { char *np; diff --git a/util/transname.h b/util/transname.h index 847a250..a694456 100644 --- a/util/transname.h +++ b/util/transname.h @@ -1 +1 @@ -void transname(char *name, char *namebuf, int n); +void transname(char *name, char *namebuf, size_t n); diff --git a/util/util.c b/util/util.c index 0dcc536..cab0e5e 100644 --- a/util/util.c +++ b/util/util.c @@ -4,7 +4,7 @@ #include "masks.h" #include "util.h" -extern void exit(); +#include #define MACTIMOFFS 1904 @@ -66,8 +66,8 @@ unsigned long get2i(char *bp) return value; } -unsigned char getb(fp) -FILE *fp; +unsigned char +getb (FILE *fp) { int c; @@ -80,16 +80,16 @@ FILE *fp; return c & BYTEMASK; } -void copy(d, s, n) -char *d, *s; -int n; +void +copy (char *d, char *s, int n) { while(--n >= 0) { *d++ = *s++; } } -int do_query() +int +do_query (void) { char *tp, temp[10]; @@ -108,9 +108,8 @@ int do_query() return 0; } -void put4(dest, value) -char *dest; -unsigned long value; +void +put4 (char *dest, unsigned long value) { *dest++ = (value >> 24) & BYTEMASK; *dest++ = (value >> 16) & BYTEMASK; @@ -118,16 +117,15 @@ unsigned long value; *dest++ = value & BYTEMASK; } -void put2(dest, value) -char *dest; -unsigned long value; +void +put2 (char *dest, unsigned long value) { *dest++ = (value >> 8) & BYTEMASK; *dest++ = value & BYTEMASK; } -void do_indent(indent) -int indent; +void +do_indent (int indent) { int i;