From f374ae6ab24e4661d3f2fdc256e356c56f0425f1 Mon Sep 17 00:00:00 2001 From: Arvid Norlander Date: Thu, 29 Sep 2022 17:45:52 +0200 Subject: [PATCH 01/12] Build system: Allow override on command line. --- makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/makefile b/makefile index 85208fa..2b484f6 100644 --- a/makefile +++ b/makefile @@ -1,4 +1,4 @@ -BINDIR = bin +BINDIR ?= bin # Use the following flags on the CF macro definition as needed. # # -DBSD if you are on a BSD system @@ -23,7 +23,7 @@ BINDIR = bin # # -DAPPLEDOUBLE if you want to be able to use an AppleDouble file system # -CF = -DBSD -DTYPES_H -DDIRENT_H -DTERMIOS_H -DNODOT -DAPPLEDOUBLE +CF ?= -DBSD -DTYPES_H -DDIRENT_H -DTERMIOS_H -DNODOT -DAPPLEDOUBLE all: (cd crc; make CF='$(CF)') From 767b94478047b763e51f01444bd9caa3a5e26b00 Mon Sep 17 00:00:00 2001 From: Arvid Norlander Date: Thu, 29 Sep 2022 17:47:12 +0200 Subject: [PATCH 02/12] Build system: Fix install target --- makefile | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/makefile b/makefile index 2b484f6..c70d388 100644 --- a/makefile +++ b/makefile @@ -63,13 +63,14 @@ lint: (cd comm; make CF='$(CF)' lint) install: - cp macunpack/macunpack $(BINDIR)/. - cp hexbin/hexbin $(BINDIR)/. - cp mixed/macsave $(BINDIR)/. - cp mixed/macstream $(BINDIR)/. - cp binhex/binhex $(BINDIR)/. - cp comm/tomac $(BINDIR)/. - cp comm/frommac $(BINDIR)/. + mkdir -p "$(BINDIR)" + install macunpack/macunpack "$(BINDIR)/." + install hexbin/hexbin "$(BINDIR)/." + install mixed/macsave "$(BINDIR)/." + install mixed/macstream "$(BINDIR)/." + install binhex/binhex "$(BINDIR)/." + install comm/tomac "$(BINDIR)/." + install comm/frommac "$(BINDIR)/." distr: shar -a README makefile crc util fileio macunpack hexbin mixed binhex \ From 0acf7bc35484584529d8429e0a6a25f998833dd1 Mon Sep 17 00:00:00 2001 From: Arvid Norlander Date: Thu, 29 Sep 2022 17:54:32 +0200 Subject: [PATCH 03/12] Build system: Fix parallel builds --- makefile | 58 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/makefile b/makefile index c70d388..cf22e8a 100644 --- a/makefile +++ b/makefile @@ -26,41 +26,41 @@ BINDIR ?= bin CF ?= -DBSD -DTYPES_H -DDIRENT_H -DTERMIOS_H -DNODOT -DAPPLEDOUBLE all: - (cd crc; make CF='$(CF)') - (cd util; make CF='$(CF)') - (cd fileio; make CF='$(CF)') - (cd macunpack; make CF='$(CF)') - (cd hexbin; make CF='$(CF)') - (cd mixed; make CF='$(CF)') - (cd binhex; make CF='$(CF)') - (cd comm; make CF='$(CF)') + (cd crc; $(MAKE) CF='$(CF)') + (cd util; $(MAKE) CF='$(CF)') + (cd fileio; $(MAKE) CF='$(CF)') + (cd macunpack; $(MAKE) CF='$(CF)') + (cd hexbin; $(MAKE) CF='$(CF)') + (cd mixed; $(MAKE) CF='$(CF)') + (cd binhex; $(MAKE) CF='$(CF)') + (cd comm; $(MAKE) CF='$(CF)') clean: - (cd crc; make clean) - (cd util; make clean) - (cd fileio; make clean) - (cd macunpack; make clean) - (cd hexbin; make clean) - (cd mixed; make clean) - (cd binhex; make clean) - (cd comm; make clean) + (cd crc; $(MAKE) clean) + (cd util; $(MAKE) clean) + (cd fileio; $(MAKE) clean) + (cd macunpack; $(MAKE) clean) + (cd hexbin; $(MAKE) clean) + (cd mixed; $(MAKE) clean) + (cd binhex; $(MAKE) clean) + (cd comm; $(MAKE) clean) clobber: - (cd crc; make clean) - (cd util; make clean) - (cd fileio; make clean) - (cd macunpack; make clobber) - (cd hexbin; make clobber) - (cd mixed; make clobber) - (cd binhex; make clobber) - (cd comm; make clobber) + (cd crc; $(MAKE) clean) + (cd util; $(MAKE) clean) + (cd fileio; $(MAKE) clean) + (cd macunpack; $(MAKE) clobber) + (cd hexbin; $(MAKE) clobber) + (cd mixed; $(MAKE) clobber) + (cd binhex; $(MAKE) clobber) + (cd comm; $(MAKE) clobber) lint: - (cd macunpack; make CF='$(CF)' lint) - (cd hexbin; make CF='$(CF)' lint) - (cd mixed; make CF='$(CF)' lint) - (cd binhex; make CF='$(CF)' lint) - (cd comm; make CF='$(CF)' lint) + (cd macunpack; $(MAKE) CF='$(CF)' lint) + (cd hexbin; $(MAKE) CF='$(CF)' lint) + (cd mixed; $(MAKE) CF='$(CF)' lint) + (cd binhex; $(MAKE) CF='$(CF)' lint) + (cd comm; $(MAKE) CF='$(CF)' lint) install: mkdir -p "$(BINDIR)" From 5031969eb4c25d0c6dc6ee69ce34be5686510ec7 Mon Sep 17 00:00:00 2001 From: Arvid Norlander Date: Thu, 29 Sep 2022 20:02:38 +0200 Subject: [PATCH 04/12] Build system: Fix -m32 builds --- crc/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crc/makefile b/crc/makefile index f67a795..f8f4c4a 100644 --- a/crc/makefile +++ b/crc/makefile @@ -16,7 +16,7 @@ $(CRCC): makecrc ./makecrc makecrc: makecrc.o - cc -O -o makecrc makecrc.o + cc $(CFLAGS) -O -o makecrc makecrc.o arc.o: arc.c ccitt.o: ccitt.c From 02673a985097d8f66fd1a70b5b13e373cade4dbd Mon Sep 17 00:00:00 2001 From: Arvid Norlander Date: Thu, 29 Sep 2022 22:44:22 +0200 Subject: [PATCH 05/12] Fixes to .gitignore --- .gitignore | 9 ++++++++- makefile | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a9e06b7..5d37d28 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,11 @@ +.vscode *.o all +binhex/binhex +comm/frommac +comm/tomac +frommac/frommac +hexbin/hexbin macunpack/macunpack - +mixed/macsave +mixed/macstream \ No newline at end of file diff --git a/makefile b/makefile index cf22e8a..2931527 100644 --- a/makefile +++ b/makefile @@ -23,7 +23,7 @@ BINDIR ?= bin # # -DAPPLEDOUBLE if you want to be able to use an AppleDouble file system # -CF ?= -DBSD -DTYPES_H -DDIRENT_H -DTERMIOS_H -DNODOT -DAPPLEDOUBLE +CF ?= -DBSD -DTYPES_H -DDIRENT_H -DTERMIOS_H -DNODOT -DAPPLEDOUBLE all: (cd crc; $(MAKE) CF='$(CF)') From f980b8a9a9d285b79a5c577570eae0ea24c655a3 Mon Sep 17 00:00:00 2001 From: Arvid Norlander Date: Thu, 29 Sep 2022 18:57:39 +0200 Subject: [PATCH 06/12] CRC modernisation --- crc/.gitignore | 8 ++++++++ crc/makecrc.c | 5 +---- macunpack/crc.h | 6 +++--- 3 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 crc/.gitignore diff --git a/crc/.gitignore b/crc/.gitignore new file mode 100644 index 0000000..6d63654 --- /dev/null +++ b/crc/.gitignore @@ -0,0 +1,8 @@ +arc.c +binhex.c +ccitt.c +ccitt32.c +kermit.c +libcrc.a +makecrc +zip.c diff --git a/crc/makecrc.c b/crc/makecrc.c index a1ca573..d65f073 100644 --- a/crc/makecrc.c +++ b/crc/makecrc.c @@ -109,10 +109,7 @@ int poly, init, swapped, bits; } (void)fprintf(fd, "};\n"); (void)fprintf(fd, "\n"); - (void)fprintf(fd, "unsigned long %s_updcrc(icrc, icp, icnt)\n", name); - (void)fprintf(fd, " unsigned long icrc;\n"); - (void)fprintf(fd, " unsigned char *icp;\n"); - (void)fprintf(fd, " int icnt;\n"); + (void)fprintf(fd, "unsigned long %s_updcrc(unsigned long icrc, unsigned char *icp, int icnt)\n", name); (void)fprintf(fd, "{\n"); if(bits == 16) { (void)fprintf(fd, "#define M1 0xff\n"); diff --git a/macunpack/crc.h b/macunpack/crc.h index b339d36..bcbd2bc 100644 --- a/macunpack/crc.h +++ b/macunpack/crc.h @@ -4,9 +4,9 @@ extern unsigned long arc_crcinit; extern unsigned long binhex_crcinit; extern unsigned long zip_crcinit; -extern unsigned long arc_updcrc(); -extern unsigned long binhex_updcrc(); -extern unsigned long zip_updcrc(); +extern unsigned long arc_updcrc(unsigned long icrc, unsigned char *icp, int icnt); +extern unsigned long binhex_updcrc(unsigned long icrc, unsigned char *icp, int icnt); +extern unsigned long zip_updcrc(unsigned long icrc, unsigned char *icp, int icnt); extern unsigned long crcinit; extern unsigned long (*updcrc)(); From 0b9ba9ae5deb68ca92e3704f37d9cd70e4a7ade4 Mon Sep 17 00:00:00 2001 From: Arvid Norlander Date: Thu, 29 Sep 2022 22:37:48 +0200 Subject: [PATCH 07/12] 64-bit: Fix CRC on 64-bit systems by using 32-bit types. --- binhex/dofile.c | 23 +++++++++++------------ crc/crc.h | 14 ++++++++++++++ crc/makecrc.c | 13 +++++++------ hexbin/crc.c | 2 +- hexbin/crc.h | 12 ++++++------ macunpack/cpt.c | 14 +++++++------- macunpack/crc.c | 6 ++++-- macunpack/crc.h | 13 +++---------- macunpack/dd.c | 6 +++--- macunpack/lzh.c | 4 ++-- macunpack/pit.c | 8 ++++---- macunpack/sit.c | 10 +++++----- macunpack/zma.c | 6 +++--- 13 files changed, 70 insertions(+), 61 deletions(-) create mode 100644 crc/crc.h diff --git a/binhex/dofile.c b/binhex/dofile.c index a1b79ec..03cca60 100644 --- a/binhex/dofile.c +++ b/binhex/dofile.c @@ -1,10 +1,9 @@ #include #include "../fileio/machdr.h" #include "../fileio/rdfile.h" +#include "../crc/crc.h" extern int dorep; -extern unsigned long binhex_crcinit; -extern unsigned long binhex_updcrc(); #define RUNCHAR 0x90 @@ -43,35 +42,35 @@ void dofile() void doheader() { -unsigned long crc; +uint32_t crc; int i, n; crc = binhex_crcinit; n = file_info[I_NAMEOFF]; - crc = binhex_updcrc(crc, file_info + I_NAMEOFF, n + 1); + crc = binhex_updcrc(crc, (unsigned char*)(file_info + I_NAMEOFF), n + 1); for(i = 0; i <= n; i++) { outbyte(file_info[I_NAMEOFF + i]); } n = 0; - crc = binhex_updcrc(crc, (char *)&n, 1); + crc = binhex_updcrc(crc, (unsigned char *)&n, 1); outbyte(0); - crc = binhex_updcrc(crc, file_info + I_TYPEOFF, 4); + crc = binhex_updcrc(crc, (unsigned char*)(file_info + I_TYPEOFF), 4); for(i = 0; i < 4; i++) { outbyte(file_info[I_TYPEOFF + i]); } - crc = binhex_updcrc(crc, file_info + I_AUTHOFF, 4); + crc = binhex_updcrc(crc, (unsigned char*)(file_info + I_AUTHOFF), 4); for(i = 0; i < 4; i++) { outbyte(file_info[I_AUTHOFF + i]); } - crc = binhex_updcrc(crc, file_info + I_FLAGOFF, 2); + crc = binhex_updcrc(crc, (unsigned char*)(file_info + I_FLAGOFF), 2); for(i = 0; i < 2; i++) { outbyte(file_info[I_FLAGOFF + i]); } - crc = binhex_updcrc(crc, file_info + I_DLENOFF, 4); + crc = binhex_updcrc(crc, (unsigned char*)(file_info + I_DLENOFF), 4); for(i = 0; i < 4; i++) { outbyte(file_info[I_DLENOFF + i]); } - crc = binhex_updcrc(crc, file_info + I_RLENOFF, 4); + crc = binhex_updcrc(crc, (unsigned char*)(file_info + I_RLENOFF), 4); for(i = 0; i < 4; i++) { outbyte(file_info[I_RLENOFF + i]); } @@ -83,10 +82,10 @@ void dofork(fork, size) char *fork; int size; { -unsigned long crc; +uint32_t crc; int i; - crc = binhex_updcrc(binhex_crcinit, fork, size); + crc = binhex_updcrc(binhex_crcinit, (unsigned char*)fork, size); for(i = 0; i < size; i++) { outbyte(fork[i]); } diff --git a/crc/crc.h b/crc/crc.h new file mode 100644 index 0000000..d93d19a --- /dev/null +++ b/crc/crc.h @@ -0,0 +1,14 @@ +#ifndef CRC_CRC_H +#define CRC_CRC_H + +#include + +extern uint32_t arc_crcinit; +extern uint32_t binhex_crcinit; +extern uint32_t zip_crcinit; + +extern uint32_t arc_updcrc(uint32_t icrc, unsigned char *icp, int32_t icnt); +extern uint32_t binhex_updcrc(uint32_t icrc, unsigned char *icp, int32_t icnt); +extern uint32_t zip_updcrc(uint32_t icrc, unsigned char *icp, int32_t icnt); + +#endif \ No newline at end of file diff --git a/crc/makecrc.c b/crc/makecrc.c index d65f073..3fa13dc 100644 --- a/crc/makecrc.c +++ b/crc/makecrc.c @@ -64,12 +64,13 @@ int poly, init, swapped, bits; (void)fprintf(stderr, "Cannot open %s for writing\n", buf); exit(1); } - (void)fprintf(fd, "unsigned long %s_crcinit = %d;\n", name, init); + (void)fprintf(fd, "#include \"crc.h\"\n"); + (void)fprintf(fd, "uint32_t %s_crcinit = %d;\n", name, init); (void)fprintf(fd, "\n"); if(bits == 16) { - (void)fprintf(fd, "static unsigned short crctab[256] = {\n"); + (void)fprintf(fd, "static uint16_t crctab[256] = {\n"); } else { - (void)fprintf(fd, "static unsigned long crctab[256] = {\n"); + (void)fprintf(fd, "static uint32_t crctab[256] = {\n"); } (void)fprintf(fd, " "); if(bits == 16) { @@ -109,7 +110,7 @@ int poly, init, swapped, bits; } (void)fprintf(fd, "};\n"); (void)fprintf(fd, "\n"); - (void)fprintf(fd, "unsigned long %s_updcrc(unsigned long icrc, unsigned char *icp, int icnt)\n", name); + (void)fprintf(fd, "uint32_t %s_updcrc(uint32_t icrc, unsigned char *icp, int32_t icnt)\n", name); (void)fprintf(fd, "{\n"); if(bits == 16) { (void)fprintf(fd, "#define M1 0xff\n"); @@ -118,9 +119,9 @@ int poly, init, swapped, bits; (void)fprintf(fd, "#define M1 0xffffff\n"); (void)fprintf(fd, "#define M2 0xffffff00\n"); } - (void)fprintf(fd, " register unsigned long crc = icrc;\n"); + (void)fprintf(fd, " register uint32_t crc = icrc;\n"); (void)fprintf(fd, " register unsigned char *cp = icp;\n"); - (void)fprintf(fd, " register int cnt = icnt;\n"); + (void)fprintf(fd, " register int32_t cnt = icnt;\n"); (void)fprintf(fd, "\n"); (void)fprintf(fd, " while(cnt--) {\n"); if(bits == 16) { diff --git a/hexbin/crc.c b/hexbin/crc.c index e5e59c0..121c5a7 100644 --- a/hexbin/crc.c +++ b/hexbin/crc.c @@ -8,7 +8,7 @@ extern void exit(); -unsigned long crc; +uint32_t crc; #ifdef HQX void comp_q_crc(c) diff --git a/hexbin/crc.h b/hexbin/crc.h index 67e49fb..f3e3fd4 100644 --- a/hexbin/crc.h +++ b/hexbin/crc.h @@ -1,10 +1,10 @@ #define INITCRC binhex_crcinit -extern unsigned long crc; -extern unsigned long binhex_crcinit; -extern unsigned long binhex_updcrc(); +#include "../crc/crc.h" -extern void comp_q_crc(); -extern void comp_q_crc_n(); -extern void verify_crc(); +extern uint32_t crc; + +extern void comp_q_crc (register unsigned int c); +extern void comp_q_crc_n (register unsigned char *s, register unsigned char *e); +extern void verify_crc (unsigned long calc_crc, unsigned long file_crc); diff --git a/macunpack/cpt.c b/macunpack/cpt.c index bdeb8d4..af44e5c 100644 --- a/macunpack/cpt.c +++ b/macunpack/cpt.c @@ -92,11 +92,11 @@ void cpt() #endif /* SCAN */ exit(1); } - cpt_crc = (*updcrc)(cpt_crc, cptptr, cpthdr.commentsize); + cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)cptptr, cpthdr.commentsize); for(i = 0; i < cpthdr.entries; i++) { *cptptr = getc(infp); - cpt_crc = (*updcrc)(cpt_crc, cptptr, 1); + cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)cptptr, 1); if(*cptptr & 0x80) { cptptr[F_FOLDER] = 1; *cptptr &= 0x3f; @@ -110,7 +110,7 @@ void cpt() #endif /* SCAN */ exit(1); } - cpt_crc = (*updcrc)(cpt_crc, cptptr + 1, *cptptr); + cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)(cptptr + 1), *cptptr); if(cptptr[F_FOLDER]) { if(fread(cptptr + F_FOLDERSIZE, 1, 2, infp) != 2) { (void)fprintf(stderr, "Can't read file header #%d\n", i+1); @@ -119,7 +119,7 @@ void cpt() #endif /* SCAN */ exit(1); } - cpt_crc = (*updcrc)(cpt_crc, cptptr + F_FOLDERSIZE, 2); + 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) { @@ -129,7 +129,7 @@ void cpt() #endif /* SCAN */ exit(1); } - cpt_crc = (*updcrc)(cpt_crc, cptptr + F_VOLUME, + cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)(cptptr + F_VOLUME), FILEHDRSIZE - F_VOLUME); } cptptr += FILEHDRSIZE; @@ -203,7 +203,7 @@ struct cptHdr *s; return 0; } - cpt_crc = (*updcrc)(cpt_crc, temp + CPTHDRSIZE + C_ENTRIES, 3); + cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)(temp + CPTHDRSIZE + C_ENTRIES), 3); s->hdrcrc = get4(temp + CPTHDRSIZE + C_HDRCRC); s->entries = get2(temp + CPTHDRSIZE + C_ENTRIES); s->commentsize = temp[CPTHDRSIZE + C_COMMENT]; @@ -415,7 +415,7 @@ unsigned short type; } else { cpt_rle_lzh(); } - cpt_crc = (*updcrc)(cpt_crc, out_buffer, obytes); + cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)out_buffer, obytes); } void cpt_wrfile1(in_char, ibytes, obytes, type, blocksize) diff --git a/macunpack/crc.c b/macunpack/crc.c index 0e0baf3..830eb10 100644 --- a/macunpack/crc.c +++ b/macunpack/crc.c @@ -1,4 +1,6 @@ -unsigned long crcinit; +#include "crc.h" -unsigned long (*updcrc)(); +uint32_t crcinit; + +uint32_t (*updcrc)(uint32_t icrc, unsigned char *icp, int32_t icnt); diff --git a/macunpack/crc.h b/macunpack/crc.h index bcbd2bc..adc7119 100644 --- a/macunpack/crc.h +++ b/macunpack/crc.h @@ -1,13 +1,6 @@ #define INIT_CRC crcinit -extern unsigned long arc_crcinit; -extern unsigned long binhex_crcinit; -extern unsigned long zip_crcinit; - -extern unsigned long arc_updcrc(unsigned long icrc, unsigned char *icp, int icnt); -extern unsigned long binhex_updcrc(unsigned long icrc, unsigned char *icp, int icnt); -extern unsigned long zip_updcrc(unsigned long icrc, unsigned char *icp, int icnt); - -extern unsigned long crcinit; -extern unsigned long (*updcrc)(); +#include "../crc/crc.h" +extern uint32_t crcinit; +extern uint32_t (*updcrc)(uint32_t icrc, unsigned char *icp, int32_t icnt); diff --git a/macunpack/dd.c b/macunpack/dd.c index fd16f99..df7126d 100644 --- a/macunpack/dd.c +++ b/macunpack/dd.c @@ -151,7 +151,7 @@ void dd_arch(bin_hdr) unsigned char *bin_hdr; { unsigned long data_size; - unsigned long crc, filecrc; + uint32_t crc, filecrc; struct fileHdr f; struct fileCHdr cf; char locname[64]; @@ -322,7 +322,7 @@ struct fileCHdr *cf; int skip; { register int i; - unsigned long crc; + uint32_t crc; int n, to_uncompress; unsigned char *hdr; char ftype[5], fauth[5]; @@ -428,7 +428,7 @@ int skip; static void dd_cfilehdr(f) struct fileCHdr *f; { - unsigned long crc; + uint32_t crc; unsigned char *hdr; hdr = dd_data_ptr; diff --git a/macunpack/lzh.c b/macunpack/lzh.c index 552cd19..8273b79 100644 --- a/macunpack/lzh.c +++ b/macunpack/lzh.c @@ -368,7 +368,7 @@ int method; int rsrcLength, dataLength; int doit; char *mname; - unsigned long crc; + uint32_t crc; if(filehdr->upsize > lzh_filesize) { if(lzh_filesize == 0) { @@ -557,7 +557,7 @@ int method; } } if(doit) { - crc = (*updcrc)(INIT_CRC, lzh_file, filehdr->upsize); + crc = (*updcrc)(INIT_CRC, (unsigned char*)lzh_file, filehdr->upsize); if(filehdr->crc != crc) { (void)fprintf(stderr, "CRC error on file: need 0x%04x, got 0x%04x\n", diff --git a/macunpack/pit.c b/macunpack/pit.c index 5f42fb8..81b1406 100644 --- a/macunpack/pit.c +++ b/macunpack/pit.c @@ -122,10 +122,10 @@ void pit() start_info(info, filehdr.rlen, filehdr.dlen); start_data(); pit_wrfile(filehdr.dlen, decode); - data_crc = (*updcrc)(INIT_CRC, out_buffer, filehdr.dlen); + data_crc = (*updcrc)(INIT_CRC, (unsigned char*)out_buffer, filehdr.dlen); start_rsrc(); pit_wrfile(filehdr.rlen, decode); - data_crc = (*updcrc)(data_crc, out_buffer, filehdr.rlen); + data_crc = (*updcrc)(data_crc, (unsigned char*)out_buffer, filehdr.rlen); if(decode == nocomp) { crc = getb(infp); crc = (crc << 8) | getb(infp); @@ -164,7 +164,7 @@ struct pit_header *f; int compr; { register int i; - unsigned long crc; + uint32_t crc; int n; char hdr[HDRBYTES]; char ftype[5], fauth[5]; @@ -182,7 +182,7 @@ int compr; } } crc = INIT_CRC; - crc = (*updcrc)(crc, hdr, HDRBYTES - 2); + crc = (*updcrc)(crc, (unsigned char*)hdr, HDRBYTES - 2); f->hdrCRC = get2(hdr + H_HDRCRC); if(f->hdrCRC != crc) { diff --git a/macunpack/sit.c b/macunpack/sit.c index 7a65f9f..22559c9 100644 --- a/macunpack/sit.c +++ b/macunpack/sit.c @@ -157,7 +157,7 @@ static int readsithdr(sitHdr *s) static int sit_filehdr(struct fileHdr *f, int skip) { register int i; - unsigned long crc; + uint32_t crc; int n; char hdr[FILEHDRSIZE]; char ftype[5], fauth[5]; @@ -170,7 +170,7 @@ static int sit_filehdr(struct fileHdr *f, int skip) return -1; } crc = INIT_CRC; - crc = (*updcrc)(crc, hdr, FILEHDRSIZE - 2); + crc = (*updcrc)(crc, (unsigned char*)hdr, FILEHDRSIZE - 2); f->hdrCRC = get2(hdr + F_HDRCRC); if(f->hdrCRC != crc) { @@ -390,7 +390,7 @@ char *name; static void sit_unstuff(filehdr) struct fileHdr filehdr; { - unsigned long crc; + uint32_t crc; if(write_it) { start_info(info, filehdr.rsrcLength, filehdr.dataLength); @@ -403,7 +403,7 @@ struct fileHdr filehdr; } sit_wrfile(filehdr.compRLength, filehdr.rsrcLength, filehdr.compRMethod); if(write_it) { - crc = (*updcrc)(INIT_CRC, out_buffer, filehdr.rsrcLength); + crc = (*updcrc)(INIT_CRC, (unsigned char*)out_buffer, filehdr.rsrcLength); if(filehdr.rsrcCRC != crc) { (void)fprintf(stderr, "CRC error on resource fork: need 0x%04x, got 0x%04x\n", @@ -422,7 +422,7 @@ struct fileHdr filehdr; } sit_wrfile(filehdr.compDLength, filehdr.dataLength, filehdr.compDMethod); if(write_it) { - crc = (*updcrc)(INIT_CRC, out_buffer, filehdr.dataLength); + crc = (*updcrc)(INIT_CRC, (unsigned char*)out_buffer, filehdr.dataLength); if(filehdr.dataCRC != crc) { (void)fprintf(stderr, "CRC error on data fork: need 0x%04x, got 0x%04x\n", diff --git a/macunpack/zma.c b/macunpack/zma.c index ba9d2f7..cf5466b 100644 --- a/macunpack/zma.c +++ b/macunpack/zma.c @@ -274,7 +274,7 @@ struct fileHdr fhdr; static void zma_mooz(filehdr) struct fileHdr filehdr; { - unsigned long crc; + uint32_t crc; if(write_it) { start_info(info, filehdr.rsrcLength, filehdr.dataLength); @@ -287,7 +287,7 @@ struct fileHdr filehdr; } zma_wrfile(filehdr.compDLength, filehdr.dataLength, filehdr.what); if(write_it) { - crc = (*updcrc)(INIT_CRC, out_buffer, filehdr.dataLength); + crc = (*updcrc)(INIT_CRC, (unsigned char*)out_buffer, filehdr.dataLength); if(filehdr.dataCRC != crc) { (void)fprintf(stderr, "CRC error on data fork: need 0x%04x, got 0x%04x\n", @@ -306,7 +306,7 @@ struct fileHdr filehdr; } zma_wrfile(filehdr.compRLength, filehdr.rsrcLength, filehdr.what); if(write_it) { - crc = (*updcrc)(INIT_CRC, out_buffer, filehdr.rsrcLength); + crc = (*updcrc)(INIT_CRC, (unsigned char*)out_buffer, filehdr.rsrcLength); if(filehdr.rsrcCRC != crc) { (void)fprintf(stderr, "CRC error on resource fork: need 0x%04x, got 0x%04x\n", From a07435fd95efbd01f551f04ede9bde3092365cd0 Mon Sep 17 00:00:00 2001 From: Arvid Norlander Date: Thu, 29 Sep 2022 18:59:24 +0200 Subject: [PATCH 08/12] Fix typo --- macunpack/arc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macunpack/arc.h b/macunpack/arc.h index 59c7f8e..67443ba 100644 --- a/macunpack/arc.h +++ b/macunpack/arc.h @@ -35,7 +35,7 @@ typedef struct fileHdr { /* 84 or 88 bytes */ unsigned long size; unsigned short date; unsigned short time; - unsigend short crc; + unsigned short crc; unsigned long size2; /* Identical to size; this is wrong for Arc! */ }; From 84b38a61b51d1348d92531ef23a5a88f5a3a0a6c Mon Sep 17 00:00:00 2001 From: Arvid Norlander Date: Thu, 29 Sep 2022 22:41:24 +0200 Subject: [PATCH 09/12] First batch of conversion to using prototypes --- binhex/binhex.c | 11 ++- binhex/dofile.c | 31 ++++---- binhex/dofile.h | 1 + comm/frommac.c | 9 +-- comm/tomac.c | 13 ++-- comm/tty.c | 24 +++---- comm/tty.h | 6 ++ comm/xm_from.c | 22 +++--- comm/xm_to.c | 20 +++--- crc/makecrc.c | 10 +-- fileio/rdfile.c | 49 +++++++------ fileio/rdfile.h | 6 +- fileio/wrfile.c | 40 ++++++----- fileio/wrfile.h | 16 ++--- hexbin/buffer.c | 11 +-- hexbin/crc.c | 14 ++-- hexbin/dl.c | 15 ++-- hexbin/dl.h | 7 ++ hexbin/globals.c | 4 +- hexbin/hecx.c | 31 ++++---- hexbin/hecx.h | 7 ++ hexbin/hexbin.c | 47 +++++------- hexbin/hqx.c | 24 ++++--- hexbin/hqx.h | 7 ++ hexbin/mu.c | 17 +++-- hexbin/mu.h | 7 ++ hexbin/readline.c | 3 +- macunpack/arc.h | 2 +- macunpack/bin.c | 9 ++- macunpack/bin.h | 4 ++ macunpack/bits_be.c | 13 ++-- macunpack/cpt.c | 81 ++++++++++----------- macunpack/cpt.h | 92 +++++++++++++----------- macunpack/dd.c | 153 +++++++++++++++++----------------------- macunpack/dd.h | 23 ++++-- macunpack/de_compress.c | 21 +++--- macunpack/de_compress.h | 2 + macunpack/de_huffman.c | 20 ++++-- macunpack/de_huffman.h | 4 ++ macunpack/de_lzah.c | 24 ++++--- macunpack/de_lzah.h | 8 +++ macunpack/de_lzh.c | 28 +++----- macunpack/dia.c | 37 +++++----- macunpack/dir.c | 4 +- macunpack/globals.c | 4 +- macunpack/jdw.c | 22 +++--- macunpack/jdw.h | 4 +- macunpack/lzc.c | 22 +++--- macunpack/lzc.h | 4 +- macunpack/lzh.c | 62 ++++++++-------- macunpack/lzh.h | 4 +- macunpack/macbinary.c | 32 ++++----- macunpack/macunpack.c | 3 +- macunpack/mcb.c | 9 +-- macunpack/mcb.h | 1 + macunpack/pit.c | 26 +++---- macunpack/sit.c | 99 +++++++++++++------------- macunpack/sit.h | 15 +++- macunpack/stf.c | 17 +++-- macunpack/stf.h | 9 ++- macunpack/zma.c | 35 +++++---- macunpack/zma.h | 4 +- mixed/macbinary.c | 11 +-- mixed/macsave.c | 3 +- mixed/macstream.c | 5 +- mixed/mcb.c | 10 ++- util/transname.c | 5 +- util/transname.h | 2 +- util/util.c | 28 ++++---- 69 files changed, 723 insertions(+), 690 deletions(-) create mode 100644 binhex/dofile.h create mode 100644 hexbin/dl.h create mode 100644 hexbin/hecx.h create mode 100644 hexbin/hqx.h create mode 100644 hexbin/mu.h create mode 100644 macunpack/bin.h create mode 100644 macunpack/de_compress.h create mode 100644 macunpack/de_huffman.h create mode 100644 macunpack/de_lzah.h create mode 100644 macunpack/mcb.h 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; From 926f4a694d655dd69fc7709dda85975fd008e344 Mon Sep 17 00:00:00 2001 From: Arvid Norlander Date: Thu, 29 Sep 2022 19:52:53 +0200 Subject: [PATCH 10/12] 64-bit: Convcert all uses of long/unsigned long to int32_t/uint32_t. Some of these may not be needed, but none of them should be incorrect. --- binhex/binhex.c | 4 +-- comm/frommac.c | 2 +- comm/tomac.c | 4 +-- comm/xm_from.c | 2 +- crc/makecrc.c | 5 +-- fileio/rdfile.c | 24 ++++++------- fileio/wrfile.c | 44 ++++++++++++------------ fileio/wrfile.h | 4 ++- hexbin/buffer.c | 2 +- hexbin/crc.c | 4 +-- hexbin/crc.h | 2 +- hexbin/dl.c | 20 +++++------ hexbin/globals.h | 9 ++--- hexbin/hecx.c | 22 ++++++------ hexbin/hexbin.c | 4 +-- hexbin/hqx.c | 36 ++++++++++---------- hexbin/mu.c | 10 +++--- hexbin/printhdr.c | 2 +- macunpack/arc.h | 16 +++++---- macunpack/bin.c | 4 +-- macunpack/cpt.c | 24 ++++++------- macunpack/cpt.h | 30 +++++++++-------- macunpack/dd.c | 74 ++++++++++++++++++++--------------------- macunpack/dd.h | 25 ++++++++------ macunpack/de_compress.c | 18 +++++----- macunpack/de_compress.h | 4 ++- macunpack/de_huffman.c | 2 +- macunpack/de_huffman.h | 4 ++- macunpack/de_lzah.c | 2 +- macunpack/de_lzah.h | 6 ++-- macunpack/de_lzh.c | 2 +- macunpack/dia.c | 14 ++++---- macunpack/jdw.c | 16 ++++----- macunpack/jdw.h | 14 ++++---- macunpack/lzc.c | 10 +++--- macunpack/lzc.h | 26 ++++++++------- macunpack/lzh.c | 44 ++++++++++++------------ macunpack/lzh.h | 8 +++-- macunpack/macbinary.c | 14 ++++---- macunpack/macunpack.c | 2 +- macunpack/mcb.c | 8 ++--- macunpack/mcb.h | 2 +- macunpack/pit.c | 12 +++---- macunpack/pit.h | 8 ++--- macunpack/sit.c | 30 ++++++++--------- macunpack/sit.h | 18 +++++----- macunpack/stf.c | 26 +++++++-------- macunpack/stf.h | 9 +++-- macunpack/zma.c | 18 +++++----- macunpack/zma.h | 22 ++++++------ mixed/macbinary.c | 4 +-- mixed/macstream.c | 4 +-- mixed/mcb.c | 8 ++--- util/util.c | 36 ++++++++++---------- util/util.h | 28 ++++++++-------- 55 files changed, 412 insertions(+), 380 deletions(-) diff --git a/binhex/binhex.c b/binhex/binhex.c index 2577a28..4b8c0a0 100644 --- a/binhex/binhex.c +++ b/binhex/binhex.c @@ -103,8 +103,8 @@ int main(int argc, char **argv) if(i == ISFILE) { do_indent(indent); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)data_size, (long)rsrc_size); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)data_size, (int32_t)rsrc_size); } else if(i == ISDIR) { do_indent(indent); dir_ptr += 64; diff --git a/comm/frommac.c b/comm/frommac.c index a0d0799..52f4cbe 100644 --- a/comm/frommac.c +++ b/comm/frommac.c @@ -151,7 +151,7 @@ int main(int argc, char **argv) transname(info + I_AUTHOFF, fauth, 4); transname(info + I_TYPEOFF, ftype, 4); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", + "name=\"%s\", type=%4.4s, author=%4.4s, data=%u, rsrc=%u", tname, ftype, fauth, get4(info + I_DLENOFF), get4(info + I_RLENOFF)); (void)fprintf(stderr, "\n"); diff --git a/comm/tomac.c b/comm/tomac.c index afb39bb..0c74aad 100644 --- a/comm/tomac.c +++ b/comm/tomac.c @@ -154,8 +154,8 @@ int main(int argc, char **argv) if(i == ISFILE) { do_indent(indent); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)data_size, (long)rsrc_size); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)data_size, (int32_t)rsrc_size); } else if(i == ISDIR) { do_indent(indent); dir_ptr += 64; diff --git a/comm/xm_from.c b/comm/xm_from.c index 988e4f0..f22f424 100644 --- a/comm/xm_from.c +++ b/comm/xm_from.c @@ -19,7 +19,7 @@ char info[INFOBYTES]; void xm_from (void) { -unsigned long data_size, rsrc_size; +uint32_t data_size, rsrc_size; char text[64]; if(receive_sync() == ACK) { diff --git a/crc/makecrc.c b/crc/makecrc.c index 941336e..eaefd2b 100644 --- a/crc/makecrc.c +++ b/crc/makecrc.c @@ -31,6 +31,7 @@ /* ZIP used by COMPACTOR */ #include +#include #include #include @@ -53,7 +54,7 @@ initcrctab (char *name, int poly, int init, int swapped, int bits) { register int b, i; unsigned short v; - unsigned long vv; + uint32_t vv; FILE *fd; char buf[20]; @@ -99,7 +100,7 @@ initcrctab (char *name, int poly, int init, int swapped, int bits) for(vv = b<<24, i = 8; --i >= 0;) vv = vv & 0x80000000 ? (vv<<1)^poly : vv<<1; } - (void)fprintf(fd, "0x%.8lx,", vv & 0xffffffff); + (void)fprintf(fd, "0x%.8x,", 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 678e8d3..a2db0a2 100644 --- a/fileio/rdfile.c +++ b/fileio/rdfile.c @@ -358,8 +358,8 @@ read_file (void) } (void)strcpy(file_info + I_NAMEOFF + 1, filename); file_info[I_NAMEOFF] = strlen(filename); - put4(file_info + I_CTIMOFF, (unsigned long)stbuf.st_ctime + TIMEDIFF); - put4(file_info + I_MTIMOFF, (unsigned long)stbuf.st_mtime + TIMEDIFF); + put4(file_info + I_CTIMOFF, (uint32_t)stbuf.st_ctime + TIMEDIFF); + put4(file_info + I_MTIMOFF, (uint32_t)stbuf.st_mtime + TIMEDIFF); if(data_only == RSRC_FORMAT) { rsrc_size = stbuf.st_size; data_size = 0; @@ -381,7 +381,7 @@ read_file (void) } else { (void)strncpy(file_info + I_AUTHOFF, f_auth, 4); } - put4(file_info + I_RLENOFF, (unsigned long)rsrc_size); + put4(file_info + I_RLENOFF, (uint32_t)rsrc_size); if((fd = fopen(filename, "r")) == NULL) { (void)fprintf(stderr, "Cannot open file %s\n", filename); exit(1); @@ -412,7 +412,7 @@ read_file (void) } else { (void)strncpy(file_info + I_AUTHOFF, f_auth, 4); } - put4(file_info + I_DLENOFF, (unsigned long)data_size); + put4(file_info + I_DLENOFF, (uint32_t)data_size); if((fd = fopen(filename, "r")) == NULL) { (void)fprintf(stderr, "Cannot open file %s\n", filename); exit(1); @@ -555,7 +555,7 @@ read_file (void) (void)strcat(filename1, filename); if(stat(filename1, &stbuf) >= 0) { rsrc_size = stbuf.st_size; - put4(file_info + I_RLENOFF, (unsigned long)rsrc_size); + put4(file_info + I_RLENOFF, (uint32_t)rsrc_size); if(rsrc_size > 0) { if(rsrc_size > max_rsrc_size) { if(rsrc_fork == NULL) { @@ -578,7 +578,7 @@ read_file (void) } if(stat(filename, &stbuf) >= 0) { data_size = stbuf.st_size; - put4(file_info + I_DLENOFF, (unsigned long)data_size); + put4(file_info + I_DLENOFF, (uint32_t)data_size); if(data_size > 0) { if(data_size > max_data_size) { if(data_fork == NULL) { @@ -626,7 +626,7 @@ read_file (void) (void)fclose(fd); if(stat(filename, &stbuf) >= 0) { data_size = stbuf.st_size; - put4(file_info + I_DLENOFF, (unsigned long)data_size); + put4(file_info + I_DLENOFF, (uint32_t)data_size); if(data_size > 0) { if(data_size > max_data_size) { if(data_fork == NULL) { @@ -816,15 +816,15 @@ read_aufs_info (FILE *fd) } else { if(fstat(fileno(fd), &stbuf) >= 0) { put4(file_info + I_CTIMOFF, - (unsigned long)stbuf.st_ctime + TIMEDIFF); + (uint32_t)stbuf.st_ctime + TIMEDIFF); put4(file_info + I_MTIMOFF, - (unsigned long)stbuf.st_mtime + TIMEDIFF); + (uint32_t)stbuf.st_mtime + TIMEDIFF); } } #else /* AUFSPLUS */ if(fstat(fileno(fd), &stbuf) >= 0) { - put4(file_info + I_CTIMOFF, (unsigned long)stbuf.st_ctime + TIMEDIFF); - put4(file_info + I_MTIMOFF, (unsigned long)stbuf.st_mtime + TIMEDIFF); + put4(file_info + I_CTIMOFF, (uint32_t)stbuf.st_ctime + TIMEDIFF); + put4(file_info + I_MTIMOFF, (uint32_t)stbuf.st_mtime + TIMEDIFF); } #endif /* AUFSPLUS */ } @@ -864,7 +864,7 @@ read_appledouble_info (FILE *fd) put4(file_info + I_CTIMOFF, get4(theinfo.fi_ctime) + TIMEDIFF); put4(file_info + I_MTIMOFF, get4(theinfo.fi_mtime) + TIMEDIFF); rsrc_size = get4(theinfo.fi_rsrc); - put4(file_info + I_RLENOFF, (unsigned long)rsrc_size); + put4(file_info + I_RLENOFF, (uint32_t)rsrc_size); } #endif /* APPLEDOUBLE */ #endif /* APPLESHARE */ diff --git a/fileio/wrfile.c b/fileio/wrfile.c index d60c0b7..77f6a8a 100644 --- a/fileio/wrfile.c +++ b/fileio/wrfile.c @@ -101,7 +101,7 @@ static char init_buffer[128]; static char *buffer = &(init_buffer[0]); static char *rbuffer = NULL, *dbuffer = NULL; static char *ptr; -static unsigned long rsz, dsz, totsize, maxsize; +static uint32_t rsz, dsz, totsize, maxsize; void define_name (char *text) @@ -120,7 +120,7 @@ define_name (char *text) } void -start_info (char *info, unsigned long rsize, unsigned long dsize) +start_info (char *info, uint32_t rsize, uint32_t dsize) { int rs, ds; @@ -338,7 +338,7 @@ do_idf (char *name, int kind) n = strlen(name); (void)bzero(buffer, INFOBYTES); buffer[I_NAMEOFF + 1] = kind; - put4(buffer + I_DLENOFF, (unsigned long)n); + put4(buffer + I_DLENOFF, (uint32_t)n); (void)fwrite(buffer, 1, INFOBYTES, stdout); if(n != 0) { (void)fwrite(name, 1, n, stdout); @@ -583,7 +583,7 @@ FILE *fp; theinfo.fi_datevalid = FI_CDATE | FI_MDATE; put4(theinfo.fi_ctime, get4(buffer + I_CTIMOFF) - TIMEDIFF); put4(theinfo.fi_mtime, get4(buffer + I_MTIMOFF) - TIMEDIFF); - put4(theinfo.fi_utime, (unsigned long)time((time_t *)0)); + put4(theinfo.fi_utime, (uint32_t)time((time_t *)0)); #endif /* AUFSPLUS */ bcopy(buffer + I_TYPEOFF, theinfo.fi_fndr, 4); bcopy(buffer + I_AUTHOFF, theinfo.fi_fndr + 4, 4); @@ -634,21 +634,21 @@ FILE *fp; int n; bzero((char *) &theinfo, sizeof theinfo); - put4(theinfo.fi_magic, (unsigned long)FI_MAGIC); - put2(theinfo.fi_version, (unsigned long)FI_VERSION); - put4(theinfo.fi_fill5, (unsigned long)FI_FILL5); - put4(theinfo.fi_fill6, (unsigned long)FI_FILL6); - put4(theinfo.fi_hlen, (unsigned long)FI_HLEN); - put4(theinfo.fi_fill7, (unsigned long)FI_FILL7); - put4(theinfo.fi_namptr, (unsigned long)FI_NAMPTR); - put4(theinfo.fi_fill9, (unsigned long)FI_FILL9); - put4(theinfo.fi_commptr, (unsigned long)FI_COMMPTR); - put4(theinfo.fi_fill12, (unsigned long)FI_FILL12); - put4(theinfo.fi_timeptr, (unsigned long)FI_TIMEPTR); - put4(theinfo.fi_timesize, (unsigned long)FI_TIMESIZE); - put4(theinfo.fi_fill15, (unsigned long)FI_FILL15); - put4(theinfo.fi_infoptr, (unsigned long)FI_INFOPTR); - put4(theinfo.fi_infosize, (unsigned long)FI_INFOSIZE); + put4(theinfo.fi_magic, (uint32_t)FI_MAGIC); + put2(theinfo.fi_version, (uint32_t)FI_VERSION); + put4(theinfo.fi_fill5, (uint32_t)FI_FILL5); + put4(theinfo.fi_fill6, (uint32_t)FI_FILL6); + put4(theinfo.fi_hlen, (uint32_t)FI_HLEN); + put4(theinfo.fi_fill7, (uint32_t)FI_FILL7); + put4(theinfo.fi_namptr, (uint32_t)FI_NAMPTR); + put4(theinfo.fi_fill9, (uint32_t)FI_FILL9); + put4(theinfo.fi_commptr, (uint32_t)FI_COMMPTR); + put4(theinfo.fi_fill12, (uint32_t)FI_FILL12); + put4(theinfo.fi_timeptr, (uint32_t)FI_TIMEPTR); + put4(theinfo.fi_timesize, (uint32_t)FI_TIMESIZE); + put4(theinfo.fi_fill15, (uint32_t)FI_FILL15); + put4(theinfo.fi_infoptr, (uint32_t)FI_INFOPTR); + put4(theinfo.fi_infosize, (uint32_t)FI_INFOSIZE); bcopy(buffer + I_TYPEOFF, theinfo.fi_type, 4); bcopy(buffer + I_AUTHOFF, theinfo.fi_auth, 4); @@ -659,13 +659,13 @@ FILE *fp; if((n = buffer[I_NAMEOFF] & 0xff) > F_NAMELEN) { n = F_NAMELEN; } - put4(theinfo.fi_namlen, (unsigned long)n); + put4(theinfo.fi_namlen, (uint32_t)n); (void)strncpy((char *)theinfo.fi_name, buffer + I_NAMEOFF + 1,n); /* theinfo.fi_macfilename[n] = '\0'; */ (void)strcpy((char *)theinfo.fi_comment, "Converted by Unix utility to AppleDouble format"); - put4(theinfo.fi_commsize, (unsigned long)strlen(theinfo.fi_comment)); - put4(theinfo.fi_rsrc, (unsigned long)rsz); + put4(theinfo.fi_commsize, (uint32_t)strlen(theinfo.fi_comment)); + put4(theinfo.fi_rsrc, (uint32_t)rsz); /* Still TODO */ /* char fi_ctime[4]; /* Creation time (Unix time) */ /* char fi_mtime[4]; /* Modification time (Unix time) */ diff --git a/fileio/wrfile.h b/fileio/wrfile.h index d8e4864..ac05b32 100644 --- a/fileio/wrfile.h +++ b/fileio/wrfile.h @@ -1,7 +1,9 @@ +#include + extern char *out_buffer, *out_ptr; extern void define_name(char *text); -void start_info(char *info, unsigned long rsize, unsigned long dsize); +void start_info(char *info, uint32_t rsize, uint32_t dsize); extern void start_rsrc(void); extern void start_data(void); extern void end_file(void); diff --git a/hexbin/buffer.c b/hexbin/buffer.c index ed62110..79c711e 100644 --- a/hexbin/buffer.c +++ b/hexbin/buffer.c @@ -60,7 +60,7 @@ end_put (void) if(info_only) { return; } - start_info(info, (unsigned long)rsrc_size, (unsigned long)data_size); + start_info(info, (uint32_t)rsrc_size, (uint32_t)data_size); if(data_size != 0) { start_data(); copy(out_ptr, data_fork, data_size); diff --git a/hexbin/crc.c b/hexbin/crc.c index 968bcef..0fb2c0d 100644 --- a/hexbin/crc.c +++ b/hexbin/crc.c @@ -27,13 +27,13 @@ comp_q_crc_n (register unsigned char *s, register unsigned char *e) #endif /* HQX */ void -verify_crc (unsigned long calc_crc, unsigned long file_crc) +verify_crc (uint32_t calc_crc, uint32_t file_crc) { calc_crc &= WORDMASK; file_crc &= WORDMASK; if(calc_crc != file_crc) { - (void)fprintf(stderr, "CRC mismatch: got 0x%04lx, need 0x%04lx\n", + (void)fprintf(stderr, "CRC mismatch: got 0x%04x, need 0x%04x\n", file_crc, calc_crc); #ifdef SCAN do_error("hexbin: CRC error"); diff --git a/hexbin/crc.h b/hexbin/crc.h index f3e3fd4..e5df75d 100644 --- a/hexbin/crc.h +++ b/hexbin/crc.h @@ -6,5 +6,5 @@ extern uint32_t crc; extern void comp_q_crc (register unsigned int c); extern void comp_q_crc_n (register unsigned char *s, register unsigned char *e); -extern void verify_crc (unsigned long calc_crc, unsigned long file_crc); +extern void verify_crc (uint32_t calc_crc, uint32_t file_crc); diff --git a/hexbin/dl.c b/hexbin/dl.c index 87be82d..f0e0495 100644 --- a/hexbin/dl.c +++ b/hexbin/dl.c @@ -11,9 +11,9 @@ #include -static long dl_fork(); -static int nchar(); -static int nextc(); +static int32_t dl_fork(void); +static int nchar(void); +static int nextc(void); static char *icp = &line[0]; @@ -67,19 +67,19 @@ dl (char *macname, char *filename) (void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n); (void)strncpy(info + I_TYPEOFF, mh.m_type, 4); (void)strncpy(info + I_AUTHOFF, mh.m_author, 4); - put4(info + I_DLENOFF, (unsigned long)mh.m_datalen); - put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen); - put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime); - put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime); + put4(info + I_DLENOFF, (uint32_t)mh.m_datalen); + put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen); + put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime); + put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime); print_header2(0); end_put(); } -static long +static int32_t dl_fork (void) { - register unsigned long i, v, c; - register unsigned long n, bytes; + register uint32_t i, v, c; + register uint32_t n, bytes; n = 0; bytes = 0; diff --git a/hexbin/globals.h b/hexbin/globals.h index 5f757de..88c5110 100644 --- a/hexbin/globals.h +++ b/hexbin/globals.h @@ -1,4 +1,5 @@ #include +#include #include #ifdef BSD extern char *rindex(); @@ -18,10 +19,10 @@ typedef struct macheader { char m_type[4]; char m_author[4]; short m_flags; - long m_datalen; - long m_rsrclen; - long m_createtime; - long m_modifytime; + int32_t m_datalen; + int32_t m_rsrclen; + int32_t m_createtime; + int32_t m_modifytime; } macheader; extern struct macheader mh; diff --git a/hexbin/hecx.c b/hexbin/hecx.c index 98bd6da..7c7314f 100644 --- a/hexbin/hecx.c +++ b/hexbin/hecx.c @@ -13,7 +13,7 @@ #include static void do_o_forks(); -static long make_file(); +static int32_t make_file(); static void comp_c_crc(); static void comp_e_crc(); static int comp_to_bin(); @@ -86,11 +86,11 @@ hecx (char *macname, char *filename) (void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n); (void)strncpy(info + I_TYPEOFF, mh.m_type, 4); (void)strncpy(info + I_AUTHOFF, mh.m_author, 4); - put2(info + I_FLAGOFF, (unsigned long)mh.m_flags); - put4(info + I_DLENOFF, (unsigned long)mh.m_datalen); - put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen); - put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime); - put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime); + put2(info + I_FLAGOFF, (uint32_t)mh.m_flags); + put4(info + I_DLENOFF, (uint32_t)mh.m_datalen); + put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen); + put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime); + put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime); print_header2(0); end_put(); } @@ -99,7 +99,7 @@ static void do_o_forks (void) { int forks = 0, found_crc = 0; - unsigned long calc_crc, file_crc; + uint32_t calc_crc, file_crc; crc = 0; /* calculate a crc for both forks */ @@ -128,13 +128,13 @@ do_o_forks (void) if(compressed && strncmp(line, "***CRC:", 7) == 0) { found_crc++; calc_crc = crc; - (void)sscanf(&line[7], "%lx", &file_crc); + (void)sscanf(&line[7], "%x", &file_crc); break; } if(!compressed && strncmp(line, "***CHECKSUM:", 12) == 0) { found_crc++; calc_crc = crc & BYTEMASK; - (void)sscanf(&line[12], "%lx", &file_crc); + (void)sscanf(&line[12], "%x", &file_crc); file_crc &= BYTEMASK; break; } @@ -151,10 +151,10 @@ do_o_forks (void) } } -static long +static int32_t make_file (int compressed) { - register long nbytes = 0L; + register int32_t nbytes = 0L; while(readline()) { if(line[0] == 0) { diff --git a/hexbin/hexbin.c b/hexbin/hexbin.c index e4561f2..03ac8f0 100644 --- a/hexbin/hexbin.c +++ b/hexbin/hexbin.c @@ -159,7 +159,7 @@ do_files ( char namebuf[256]; char **ep; struct stat stbuf; - long curtime; + int32_t curtime; int qformat; int again; @@ -187,7 +187,7 @@ do_files ( again = 0; nexttry: if(ifp == stdin) { - curtime = (long)time((time_t *)0) + TIMEDIFF; + curtime = (int32_t)time((time_t *)0) + TIMEDIFF; mh.m_createtime = curtime; mh.m_modifytime = curtime; } else { diff --git a/hexbin/hqx.c b/hexbin/hqx.c index b65a350..adc5255 100644 --- a/hexbin/hqx.c +++ b/hexbin/hqx.c @@ -11,12 +11,12 @@ #include "../util/util.h" #include "printhdr.h" -static void get_header(); -static void oflush(); -static int getq(); -static long get2q(); -static long get4q(); -static void getqbuf(); +static void get_header(void); +static void oflush(void); +static int getq(void); +static int32_t get2q(void); +static int32_t get4q(void); +static void getqbuf(char *buf, int n); static char *g_macname; @@ -98,10 +98,10 @@ static unsigned char *oq; static int ostate = S_HEADER; -static unsigned long calc_crc; -static unsigned long file_crc; +static uint32_t calc_crc; +static uint32_t file_crc; -static long todo; +static int32_t todo; #define output(c) { *op++ = (c); if(op >= &obuf[BUFSIZ]) oflush(); } @@ -236,7 +236,7 @@ static void get_header (void) { int n; - unsigned long calc_crc, file_crc; + uint32_t calc_crc, file_crc; crc = INITCRC; /* compute a crc for the header */ @@ -277,11 +277,11 @@ get_header (void) (void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n); (void)strncpy(info + I_TYPEOFF, mh.m_type, 4); (void)strncpy(info + I_AUTHOFF, mh.m_author, 4); - put2(info + I_FLAGOFF, (unsigned long)mh.m_flags); - put4(info + I_DLENOFF, (unsigned long)mh.m_datalen); - put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen); - put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime); - put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime); + put2(info + I_FLAGOFF, (uint32_t)mh.m_flags); + put4(info + I_DLENOFF, (uint32_t)mh.m_datalen); + put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen); + put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime); + put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime); } static void @@ -364,7 +364,7 @@ getq (void) } /* get2q(); q format -- read 2 bytes from input, return short */ -static long +static int32_t get2q (void) { short high = getq() << 8; @@ -372,11 +372,11 @@ get2q (void) } /* get4q(); q format -- read 4 bytes from input, return long */ -static long +static int32_t get4q (void) { int i; - long value = 0; + int32_t value = 0; for(i = 0; i < 4; i++) { value = (value<<8) | getq(); diff --git a/hexbin/mu.c b/hexbin/mu.c index cd23639..4633379 100644 --- a/hexbin/mu.c +++ b/hexbin/mu.c @@ -136,10 +136,10 @@ mu (char *macname) (void)strncpy(mh.m_type, info + I_TYPEOFF, 4); (void)strncpy(mh.m_author, info + I_AUTHOFF, 4); print_header1(0, 0); - put4(info + I_DLENOFF, (unsigned long)mh.m_datalen); - put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen); - put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime); - put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime); + put4(info + I_DLENOFF, (uint32_t)mh.m_datalen); + put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen); + put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime); + put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime); print_header2(0); end_put(); } @@ -147,7 +147,7 @@ mu (char *macname) static void do_mu_fork (void) { - long newbytes; + int32_t newbytes; while(readline()) { if(line[0] == 0) { diff --git a/hexbin/printhdr.c b/hexbin/printhdr.c index 0141b79..d9ded7b 100644 --- a/hexbin/printhdr.c +++ b/hexbin/printhdr.c @@ -37,7 +37,7 @@ void print_header2(int skip) if (skip) { (void)fprintf(stderr, "\t"); } - (void)fprintf(stderr, "data=%ld, rsrc=%ld\n", + (void)fprintf(stderr, "data=%d, rsrc=%d\n", mh.m_datalen, mh.m_rsrclen); } } diff --git a/macunpack/arc.h b/macunpack/arc.h index d155df0..ff9f743 100644 --- a/macunpack/arc.h +++ b/macunpack/arc.h @@ -1,3 +1,5 @@ +#include + #define MAGIC1 0 /* Should be 0x1b, marks Mac extension */ #define KIND 1 /* KIND == 0 marks end of archive */ #define FNAME 2 @@ -26,17 +28,17 @@ typedef struct arc_fileHdr { /* 84 or 88 bytes */ char ftype[4]; char fauth[4]; char finfo[8]; - unsigned long dataLength; - unsigned long rsrcLength; + uint32_t dataLength; + uint32_t rsrcLength; char filler; char magic2; char kind2; char fname2[13]; - unsigned long size; - unsigned short date; - unsigned short time; - unsigned short crc; - unsigned long size2; /* Identical to size; this is wrong for Arc! */ + uint32_t size; + uint16_t date; + uint16_t time; + uint16_t crc; + uint32_t size2; /* Identical to size; this is wrong for Arc! */ }; #define smallstored 1 diff --git a/macunpack/bin.c b/macunpack/bin.c index 00e2750..8bc757e 100644 --- a/macunpack/bin.c +++ b/macunpack/bin.c @@ -14,7 +14,7 @@ void bin (char *header, int data_size, int UMcp) { char hdr[INFOBYTES]; - unsigned long rsrcLength, dataLength; + uint32_t rsrcLength, dataLength; hdr[0] = getb(infp); (void)ungetc(hdr[0], infp); @@ -38,7 +38,7 @@ bin (char *header, int data_size, int UMcp) #ifdef SCAN do_idf("", COPY); #endif /* SCAN */ - mcb(header, (unsigned long)in_data_size, (unsigned long)in_rsrc_size, + mcb(header, (uint32_t)in_data_size, (uint32_t)in_rsrc_size, in_ds + in_rs); ds_skip = 0; rs_skip = 0; diff --git a/macunpack/cpt.c b/macunpack/cpt.c index a788ff4..c6fdc24 100644 --- a/macunpack/cpt.c +++ b/macunpack/cpt.c @@ -24,17 +24,17 @@ static void cpt_uncompact(); static unsigned char *cpt_data; -static unsigned long cpt_datamax; -static unsigned long cpt_datasize; +static uint32_t cpt_datamax; +static uint32_t cpt_datasize; static unsigned char cpt_LZbuff[CIRCSIZE]; static unsigned int cpt_LZptr; static unsigned char *cpt_char; -static unsigned long cpt_crc; -static unsigned long cpt_inlength; -static unsigned long cpt_outlength; +static uint32_t cpt_crc; +static uint32_t cpt_inlength; +static uint32_t cpt_outlength; static int cpt_outstat; static unsigned char cpt_savechar; -static unsigned long cpt_newbits; +static uint32_t cpt_newbits; static int cpt_bitsavail; static int cpt_blocksize; /* Lengths is twice the max number of entries, and include slack. */ @@ -254,9 +254,9 @@ cpt_filehdr (struct cpt_fileHdr *f, char *hdr) transname(hdr + F_FTYPE, ftype, 4); transname(hdr + F_CREATOR, fauth, 4); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", text, ftype, fauth, - (long)f->dataLength, (long)f->rsrcLength); + (int32_t)f->dataLength, (int32_t)f->rsrcLength); } if(info_only) { write_it = 0; @@ -381,8 +381,8 @@ cpt_uncompact (struct cpt_fileHdr filehdr) filehdr.cptFlag & 4); if(filehdr.fileCRC != cpt_crc) { (void)fprintf(stderr, - "CRC error on file: need 0x%08lx, got 0x%08lx\n", - (long)filehdr.fileCRC, (long)cpt_crc); + "CRC error on file: need 0x%08x, got 0x%08x\n", + (int32_t)filehdr.fileCRC, (int32_t)cpt_crc); #ifdef SCAN do_error("macunpack: CRC error on file"); #endif /* SCAN */ @@ -396,7 +396,7 @@ cpt_uncompact (struct cpt_fileHdr filehdr) } static void -cpt_wrfile (unsigned long ibytes, unsigned long obytes, int type) +cpt_wrfile (uint32_t ibytes, uint32_t obytes, int type) { if(ibytes == 0) { return; @@ -415,7 +415,7 @@ cpt_wrfile (unsigned long ibytes, unsigned long obytes, int type) } void -cpt_wrfile1 (unsigned char *in_char, unsigned long ibytes, unsigned long obytes, int type, unsigned long blocksize) +cpt_wrfile1 (unsigned char *in_char, uint32_t ibytes, uint32_t obytes, int type, uint32_t blocksize) { cpt_char = in_char; if(ibytes == 0) { diff --git a/macunpack/cpt.h b/macunpack/cpt.h index 75581d8..cf53a63 100644 --- a/macunpack/cpt.h +++ b/macunpack/cpt.h @@ -1,3 +1,5 @@ +#include + #define C_SIGNATURE 0 #define C_VOLUME 1 #define C_XMAGIC 2 @@ -29,15 +31,15 @@ #define F_COMPDLENGTH 76 #define CPT_FILEHDRSIZE 80 -typedef long OSType; +typedef int32_t 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 */ + uint32_t offset; /* index offset */ /* The following are really in header2 at offset */ - unsigned long hdrcrc; /* header crc */ + uint32_t hdrcrc; /* header crc */ unsigned short entries; /* number of index entries */ unsigned char commentsize; /* number of bytes comment that follow*/ } cptHdr; @@ -47,20 +49,20 @@ typedef struct cpt_fileHdr { /* 78 bytes */ 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 */ + uint32_t filepos; /* position of data in file */ OSType fType; /* file type */ OSType fCreator; /* er... */ - unsigned long creationDate; - unsigned long modDate; /* !restored-compat w/backup prgms */ + uint32_t creationDate; + uint32_t 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 */ + uint32_t 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; + uint32_t rsrcLength; /* decompressed lengths */ + uint32_t dataLength; + uint32_t compRLength; /* compressed lengths */ + uint32_t compDLength; } cpt_fileHdr; @@ -93,7 +95,7 @@ typedef struct cpt_fileHdr { /* 78 bytes */ void cpt_wrfile1 (unsigned char *in_char, - unsigned long ibytes, - unsigned long obytes, + uint32_t ibytes, + uint32_t obytes, int type, - unsigned long blocksize); + uint32_t blocksize); diff --git a/macunpack/dd.c b/macunpack/dd.c index 53ee85f..fb58788 100644 --- a/macunpack/dd.c +++ b/macunpack/dd.c @@ -20,9 +20,9 @@ static void dd_cfilehdr(); static int dd_valid(); static int dd_valid1(); static char *dd_methname(); -static unsigned long dd_checksum(); +static uint32_t dd_checksum(); static void dd_chksum(); -static unsigned long dd_checkor(); +static uint32_t dd_checkor(); static void dd_do_delta(); static void dd_delta(); static void dd_delta3(); @@ -67,7 +67,7 @@ static unsigned char *dd_dirst; static int dd_dirstptr; static int dd_dirstmax; static int dd_xor; -static long dd_bitbuf; +static int32_t dd_bitbuf; static int dd_bitcount; static unsigned char *dd_bitptr; static char dd_LZbuff[2048]; @@ -75,7 +75,7 @@ static char dd_LZbuff[2048]; void dd_file (unsigned char *bin_hdr) { - unsigned long data_size; + uint32_t data_size; int i; struct dd_fileCHdr cf; char ftype[5], fauth[5]; @@ -117,9 +117,9 @@ dd_file (unsigned char *bin_hdr) transname(info + I_TYPEOFF, ftype, 4); transname(info + I_AUTHOFF, fauth, 4); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", text, ftype, fauth, - (long)get4(info + I_DLENOFF), (long)get4(info + I_RLENOFF)); + (int32_t)get4(info + I_DLENOFF), (int32_t)get4(info + I_RLENOFF)); if(info_only) { write_it = 0; } @@ -149,7 +149,7 @@ dd_file (unsigned char *bin_hdr) void dd_arch (unsigned char *bin_hdr) { - unsigned long data_size; + uint32_t data_size; uint32_t crc, filecrc; struct dd_fileHdr f; struct dd_fileCHdr cf; @@ -323,7 +323,7 @@ dd_filehdr (struct dd_fileHdr *f, struct dd_fileCHdr *cf, int skip) int n, to_uncompress; unsigned char *hdr; char ftype[5], fauth[5]; - unsigned long datalength, rsrclength; + uint32_t datalength, rsrclength; to_uncompress = DD_COPY; hdr = dd_data_ptr; @@ -391,8 +391,8 @@ dd_filehdr (struct dd_fileHdr *f, struct dd_fileCHdr *cf, int skip) transname(info + I_TYPEOFF, ftype, 4); transname(info + I_AUTHOFF, fauth, 4); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)datalength, (long)rsrclength); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)datalength, (int32_t)rsrclength); } if(info_only) { write_it = 0; @@ -509,11 +509,11 @@ int i, nmeths; return NULL; } -static unsigned long -dd_checksum (unsigned long init, char *buffer, unsigned long length) +static uint32_t +dd_checksum (uint32_t init, char *buffer, uint32_t length) { int i; - unsigned long cks; + uint32_t cks; cks = init; for(i = 0; i < length; i++) { @@ -525,7 +525,7 @@ dd_checksum (unsigned long init, char *buffer, unsigned long length) static void dd_chksum (struct dd_fileHdr hdr, unsigned char *data) { - unsigned long cks; + uint32_t cks; if(write_it) { cks = dd_checksum(INIT_CRC, (char *)data - CDD_FILEHDRSIZE, @@ -542,11 +542,11 @@ dd_chksum (struct dd_fileHdr hdr, unsigned char *data) } } -static unsigned long -dd_checkor (unsigned long init, char *buffer, unsigned long length) +static uint32_t +dd_checkor (uint32_t init, char *buffer, uint32_t length) { int i; - unsigned long cks; + uint32_t cks; cks = init; for(i = 0; i < length; i++) { @@ -556,7 +556,7 @@ dd_checkor (unsigned long init, char *buffer, unsigned long length) } static void -dd_do_delta (char *out_ptr, unsigned long nbytes, int kind) +dd_do_delta (char *out_ptr, uint32_t nbytes, int kind) { switch(kind) { case 0: @@ -577,7 +577,7 @@ dd_do_delta (char *out_ptr, unsigned long nbytes, int kind) } static void -dd_delta (char *out_ptr, unsigned long nbytes) +dd_delta (char *out_ptr, uint32_t nbytes) { int i, sum = 0; @@ -588,7 +588,7 @@ dd_delta (char *out_ptr, unsigned long nbytes) } static void -dd_delta3 (char *out_ptr, unsigned long nbytes) +dd_delta3 (char *out_ptr, uint32_t nbytes) { int i, sum1 = 0, sum2 = 0, sum3 = 0; @@ -612,7 +612,7 @@ dd_delta3 (char *out_ptr, unsigned long nbytes) static void dd_copy (struct dd_fileHdr hdr, unsigned char *data) { - unsigned long cks; + uint32_t cks; if(write_it) { start_info(info, hdr.rsrcLength, hdr.dataLength); @@ -661,7 +661,7 @@ dd_copy (struct dd_fileHdr hdr, unsigned char *data) } static void -dd_copyfile (unsigned long obytes, unsigned char *data) +dd_copyfile (uint32_t obytes, unsigned char *data) { if(obytes == 0) { return; @@ -677,7 +677,7 @@ dd_copyfile (unsigned long obytes, unsigned char *data) static void dd_expand (struct dd_fileCHdr hdr, unsigned char *data) { - unsigned long cks; + uint32_t cks; char *out_buf; if(write_it) { @@ -691,7 +691,7 @@ dd_expand (struct dd_fileCHdr hdr, unsigned char *data) } out_buf = out_buffer; dd_expandfile(hdr.dataLength, hdr.dataCLength, (int)hdr.datamethod, - (int)hdr.datainfo, data, (unsigned long)hdr.datacrc); + (int)hdr.datainfo, data, (uint32_t)hdr.datacrc); data += hdr.dataCLength; if(write_it) { if((hdr.info2 & 0x40) && (hdr.dataLength != 0)) { @@ -716,7 +716,7 @@ dd_expand (struct dd_fileCHdr hdr, unsigned char *data) } out_buf = out_buffer; dd_expandfile(hdr.rsrcLength, hdr.rsrcCLength, (int)hdr.rsrcmethod, - (int)hdr.rsrcinfo, data, (unsigned long)hdr.rsrccrc); + (int)hdr.rsrcinfo, data, (uint32_t)hdr.rsrccrc); data += hdr.rsrcCLength; if(write_it) { if((hdr.info2 & 0x40) && (hdr.rsrcLength != 0)) { @@ -740,11 +740,11 @@ dd_expand (struct dd_fileCHdr hdr, unsigned char *data) } static void -dd_expandfile (unsigned long obytes, unsigned long ibytes, int method, int kind, unsigned char *data, unsigned long chksum) +dd_expandfile (uint32_t obytes, uint32_t ibytes, int method, int kind, unsigned char *data, uint32_t chksum) { int sub_method, m1, m2; char *optr = out_ptr; - unsigned long cksinit; + uint32_t cksinit; if(obytes == 0) { if(verbose) { @@ -839,7 +839,7 @@ dd_expandfile (unsigned long obytes, unsigned long ibytes, int method, int kind, /* Method 0: no compression */ /*---------------------------------------------------------------------------*/ static void -dd_nocomp (unsigned long obytes, unsigned char *data) +dd_nocomp (uint32_t obytes, unsigned char *data) { copy(out_ptr, (char *)data, (int)obytes); } @@ -848,11 +848,11 @@ dd_nocomp (unsigned long obytes, unsigned char *data) /* Method 1: LZC compressed */ /*---------------------------------------------------------------------------*/ static void -dd_lzc (unsigned long ibytes, unsigned long obytes, unsigned char *data, int mb, unsigned long chksum, unsigned long ckinit) +dd_lzc (uint32_t ibytes, uint32_t obytes, unsigned char *data, int mb, uint32_t chksum, uint32_t ckinit) { int i; char *out_buf; - unsigned long cks; + uint32_t cks; out_buf = out_buffer; core_compress((char *)data); @@ -880,7 +880,7 @@ dd_lzc (unsigned long ibytes, unsigned long obytes, unsigned char *data, int mb, /* Method 3: Run length encoding */ /*---------------------------------------------------------------------------*/ static void -dd_rle (unsigned long ibytes, unsigned char *data) +dd_rle (uint32_t ibytes, unsigned char *data) { int ch, lastch, n, i; @@ -910,7 +910,7 @@ dd_rle (unsigned long ibytes, unsigned char *data) /* Method 4: Huffman encoding */ /*---------------------------------------------------------------------------*/ static void -dd_huffman (unsigned long ibytes, unsigned char *data) +dd_huffman (uint32_t ibytes, unsigned char *data) { } #endif /* NOTIMPLEMENTED */ @@ -919,7 +919,7 @@ dd_huffman (unsigned long ibytes, unsigned char *data) /* Method 7: Slightly improved LZSS */ /*---------------------------------------------------------------------------*/ static void -dd_lzss (unsigned char *data, unsigned long chksum) +dd_lzss (unsigned char *data, uint32_t chksum) { int i, LZptr, LZbptr, LZlength; char *optr = out_ptr; @@ -959,7 +959,7 @@ dd_lzss (unsigned char *data, unsigned long chksum) } } } - cks = dd_checkor(INIT_CRC, optr, (unsigned long)(out_ptr - optr)); + cks = dd_checkor(INIT_CRC, optr, (uint32_t)(out_ptr - optr)); if(chksum != cks) { (void)fprintf(stderr, "Checksum error on fork: need 0x%04x, got 0x%04x\n", @@ -992,12 +992,12 @@ dd_getbits (int n) /* Method 8: Compactor compatible compression */ /*---------------------------------------------------------------------------*/ static void -dd_cpt_compat (unsigned long ibytes, unsigned long obytes, unsigned char *data, int sub_method, unsigned long chksum) +dd_cpt_compat (uint32_t ibytes, uint32_t obytes, unsigned char *data, int sub_method, uint32_t chksum) { - unsigned long cks; + uint32_t cks; char *optr = out_buffer; - cpt_wrfile1(data, ibytes, obytes, sub_method, (unsigned long)0x0fff0); + cpt_wrfile1(data, ibytes, obytes, sub_method, (uint32_t)0x0fff0); cks = arc_updcrc(INIT_CRC, (unsigned char *)optr, (int)obytes); if(chksum != cks) { (void)fprintf(stderr, diff --git a/macunpack/dd.h b/macunpack/dd.h index 4464430..e8cfce4 100644 --- a/macunpack/dd.h +++ b/macunpack/dd.h @@ -1,6 +1,9 @@ #include "macunpack.h" #ifdef DD + +#include + #ifdef DD_INTERNAL #define MAGIC1 "DDAR" @@ -55,7 +58,7 @@ #define DD_C_HDRCRC 82 #define CDD_FILEHDRSIZE 84 -typedef long OSType; +typedef int32_t OSType; typedef struct dd_fileHdr { /* 124 bytes */ unsigned char magic[4]; /* "DDAR" */ @@ -63,10 +66,10 @@ typedef struct dd_fileHdr { /* 124 bytes */ unsigned char fName[64]; /* a STR63 */ unsigned char isdir; /* starts a directory? */ unsigned char enddir; /* terminates a directory? */ - unsigned long dataLength; /* lengths */ - unsigned long rsrcLength; - unsigned long creationDate; - unsigned long modDate; + uint32_t dataLength; /* lengths */ + uint32_t rsrcLength; + uint32_t creationDate; + uint32_t modDate; OSType fType; /* file type */ OSType fCreator; /* er... */ unsigned short FndrFlags; /* copy of Finder flags. For our @@ -80,16 +83,16 @@ typedef struct dd_fileHdr { /* 124 bytes */ typedef struct dd_fileCHdr { /* 84 bytes */ unsigned char magic[4]; /* "\253\315\000\124" */ - unsigned long dataLength; /* lengths */ - unsigned long dataCLength; - unsigned long rsrcLength; - unsigned long rsrcCLength; + uint32_t dataLength; /* lengths */ + uint32_t dataCLength; + uint32_t rsrcLength; + uint32_t rsrcCLength; unsigned char datamethod; /* compression method used */ unsigned char rsrcmethod; unsigned char info1; /* flags ??? */ unsigned char fill3; - unsigned long modDate; - unsigned long creationDate; + uint32_t modDate; + uint32_t creationDate; OSType fType; /* file type */ OSType fCreator; /* er... */ unsigned short FndrFlags; /* copy of Finder flags. For our diff --git a/macunpack/de_compress.c b/macunpack/de_compress.c index 3aa3324..f5129c1 100644 --- a/macunpack/de_compress.c +++ b/macunpack/de_compress.c @@ -19,20 +19,20 @@ static int n_bits; /* number of bits/code */ static int maxbits; /* user settable max # bits/code */ -static long maxcode; /* maximum code, given n_bits */ -static long maxmaxcode; /* should NEVER generate this code */ +static int32_t maxcode; /* maximum code, given n_bits */ +static int32_t maxmaxcode; /* should NEVER generate this code */ # define MAXCODE(n_bits) ((1 << (n_bits)) - 1) -static long htab [HSIZE]; +static int32_t htab [HSIZE]; static unsigned short codetab [HSIZE]; #define tab_prefixof(i) codetab[i] #define tab_suffixof(i) ((unsigned char *)(htab))[i] #define de_stack ((unsigned char *)&tab_suffixof(1< + +void de_compress(uint32_t ibytes, int mb); void core_compress(char* ptr); diff --git a/macunpack/de_huffman.c b/macunpack/de_huffman.c index df120d6..8f870b1 100644 --- a/macunpack/de_huffman.c +++ b/macunpack/de_huffman.c @@ -35,7 +35,7 @@ static node *nodeptr, *read_sub_tree(); static int bit; -void de_huffman(unsigned long obytes) +void de_huffman(uint32_t obytes) { while(obytes != 0) { *out_ptr++ = gethuffbyte(nodelist); diff --git a/macunpack/de_huffman.h b/macunpack/de_huffman.h index 541bfa8..5bc18bc 100644 --- a/macunpack/de_huffman.h +++ b/macunpack/de_huffman.h @@ -1,4 +1,6 @@ +#include + void set_huffman(int endian); void read_tree(); -void de_huffman(unsigned long obytes); +void de_huffman(uint32_t 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 ccdd47b..5af542d 100644 --- a/macunpack/de_lzah.c +++ b/macunpack/de_lzah.c @@ -95,7 +95,7 @@ static int Frequ[1000]; static int ForwTree[1000]; static int BackTree[1000]; -void de_lzah(unsigned long obytes) +void de_lzah(uint32_t obytes) { int i, i1, j, ch, byte, offs, skip; diff --git a/macunpack/de_lzah.h b/macunpack/de_lzah.h index d45894d..4f326ad 100644 --- a/macunpack/de_lzah.h +++ b/macunpack/de_lzah.h @@ -1,8 +1,10 @@ #ifndef DE_LZAH_H #define DE_LZAH_H -extern void de_lzah(unsigned long obytes); +#include + +extern void de_lzah(uint32_t obytes); extern unsigned char (*lzah_getbyte)(); -extern void de_lzh(long ibytes, long obytes, char **data, int bits); +extern void de_lzh(int32_t ibytes, int32_t obytes, char **data, int bits); #endif diff --git a/macunpack/de_lzh.c b/macunpack/de_lzh.c index 226f593..182bafc 100644 --- a/macunpack/de_lzh.c +++ b/macunpack/de_lzh.c @@ -24,7 +24,7 @@ static unsigned int decode_p(); static void make_table(); /* lzh compression */ -void de_lzh(long ibytes, long obytes, char **data, int bits) +void de_lzh(int32_t ibytes, int32_t obytes, char **data, int bits) { unsigned int i, r, c; int remains; diff --git a/macunpack/dia.c b/macunpack/dia.c index 718ca9d..a3090ee 100644 --- a/macunpack/dia.c +++ b/macunpack/dia.c @@ -202,7 +202,7 @@ dia_file (int indicator, unsigned char *name) int dataLength, rsrcLength; int cdataLength, crsrcLength; int dataMethod, rsrcMethod; - unsigned long curtime; + uint32_t curtime; if(name != NULL) { for(i = 0; i < INFOBYTES; i++) { @@ -230,7 +230,7 @@ dia_file (int indicator, unsigned char *name) info[I_MTIMOFF + i] = *dia_header_ptr++; } } else { - curtime = (unsigned long)time((time_t *)0) + TIMEDIFF; + curtime = (uint32_t)time((time_t *)0) + TIMEDIFF; put4(info + I_CTIMOFF, curtime); put4(info + I_MTIMOFF, curtime); } @@ -266,16 +266,16 @@ dia_file (int indicator, unsigned char *name) crsrcLength = dia_cforklength; rsrcMethod = dia_method; dia_archive_ptr = old_archive_ptr; - put4(info + I_DLENOFF, (unsigned long)dataLength); - put4(info + I_RLENOFF, (unsigned long)rsrcLength); + put4(info + I_DLENOFF, (uint32_t)dataLength); + put4(info + I_RLENOFF, (uint32_t)rsrcLength); if(list) { transname(info + I_NAMEOFF + 1, (char *)lname, length); do_indent(indent); transname(info + I_TYPEOFF, ftype, 4); transname(info + I_AUTHOFF, fauth, 4); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - lname, ftype, fauth, (long)dataLength, (long)rsrcLength); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + lname, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength); if(info_only) { doit = 0; } else { @@ -296,7 +296,7 @@ dia_file (int indicator, unsigned char *name) } if(doit) { define_name((char *)lname); - start_info(info, (unsigned long)rsrcLength, (unsigned long)dataLength); + start_info(info, (uint32_t)rsrcLength, (uint32_t)dataLength); } if(verbose) { (void)fprintf(stderr, "\tData: "); diff --git a/macunpack/jdw.c b/macunpack/jdw.c index ab5e3ec..172502b 100644 --- a/macunpack/jdw.c +++ b/macunpack/jdw.c @@ -14,7 +14,7 @@ static void jdw_wrfork(); static void jdw_block(); void -jdw (unsigned long ibytes) +jdw (uint32_t ibytes) { char fauth[5], ftype[5]; int filel, i; @@ -63,8 +63,8 @@ jdw (unsigned long ibytes) transname(info + I_AUTHOFF, fauth, 4); do_indent(indent); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)dataLength, (long)rsrcLength); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength); if(info_only) { write_it = 0; } @@ -74,11 +74,11 @@ jdw (unsigned long ibytes) (void)fputc('\n', stderr); } } - jdw_wrfile((unsigned long)rsrcLength, (unsigned long)dataLength); + jdw_wrfile((uint32_t)rsrcLength, (uint32_t)dataLength); } static void -jdw_wrfile (unsigned long rsrcLength, unsigned long dataLength) +jdw_wrfile (uint32_t rsrcLength, uint32_t dataLength) { if(write_it) { define_name(text); @@ -105,10 +105,10 @@ jdw_wrfile (unsigned long rsrcLength, unsigned long dataLength) } static void -jdw_wrfork (unsigned long length) +jdw_wrfork (uint32_t length) { int olength, ilength, i; - unsigned long origlength, comprlength; + uint32_t origlength, comprlength; if(length == 0) { (void)fprintf(stderr, "empty"); @@ -148,7 +148,7 @@ jdw_block (int olength) bytesread++; } clrhuff(); - de_huffman((unsigned long)olength); + de_huffman((uint32_t)olength); } #else /* JDW */ int jdw; /* keep lint and some compilers happy */ diff --git a/macunpack/jdw.h b/macunpack/jdw.h index c47b100..88411d4 100644 --- a/macunpack/jdw.h +++ b/macunpack/jdw.h @@ -1,3 +1,5 @@ +#include + #define J_MAGIC 0 #define J_TYPE 6 #define J_AUTH 10 @@ -10,13 +12,13 @@ typedef struct jdw_fileHdr { char magic[6]; - unsigned long type; - unsigned long auth; + uint32_t type; + uint32_t auth; char finfo[8]; - unsigned long dataLength; - unsigned long rsrcLength; - unsigned long ctime; - unsigned long mtime; + uint32_t dataLength; + uint32_t rsrcLength; + uint32_t ctime; + uint32_t mtime; char flength; char fname[32]; /* actually flength */ } jdw_fileHdr; diff --git a/macunpack/lzc.c b/macunpack/lzc.c index 00d89a3..c349c99 100644 --- a/macunpack/lzc.c +++ b/macunpack/lzc.c @@ -29,7 +29,7 @@ static void lzc_zivm (char *ohdr) { char hdr[HEADERBYTES]; - unsigned long dataLength, rsrcLength, dataCLength, rsrcCLength; + uint32_t dataLength, rsrcLength, dataCLength, rsrcCLength; char ftype[5], fauth[5]; if(fread(hdr, 1, HEADERBYTES, infp) != HEADERBYTES) { @@ -67,8 +67,8 @@ lzc_zivm (char *ohdr) transname(hdr + C_AUTHOFF, fauth, 4); do_indent(indent); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)dataLength, (long)rsrcLength); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength); if(info_only) { write_it = 0; } @@ -108,7 +108,7 @@ lzc_zivm (char *ohdr) } static void -lzc_wrfile (unsigned long obytes, unsigned long ibytes) +lzc_wrfile (uint32_t obytes, uint32_t ibytes) { int n, nbits; char subheader[3]; @@ -186,7 +186,7 @@ lzc_zivu (char *ohdr) { (void)fprintf(stderr, "\tMacCompress(Unix) not yet implemented, copied as MacBinary\n"); - mcb(ohdr, (unsigned long)in_rsrc_size, (unsigned long)in_data_size, + mcb(ohdr, (uint32_t)in_rsrc_size, (uint32_t)in_data_size, in_ds + in_rs); } #else /* LZC */ diff --git a/macunpack/lzc.h b/macunpack/lzc.h index 34d4604..10f7b96 100644 --- a/macunpack/lzc.h +++ b/macunpack/lzc.h @@ -1,3 +1,5 @@ +#include + #define HEADERBYTES 48 #define MAGIC1 "\253\315\000\060" #define MAGIC2 "\037\235" @@ -13,16 +15,16 @@ #define C_FLAGOFF 40 typedef struct lzc_fileHdr { - unsigned long magic1; - unsigned long dataLength; - unsigned long dataCLength; - unsigned long rsrcLength; - unsigned long rsrcCLength; - unsigned long unknown1; - unsigned long mtime; - unsigned long ctime; - unsigned long filetype; - unsigned long fileauth; - unsigned long flag1; - unsigned long flag2; + uint32_t magic1; + uint32_t dataLength; + uint32_t dataCLength; + uint32_t rsrcLength; + uint32_t rsrcCLength; + uint32_t unknown1; + uint32_t mtime; + uint32_t ctime; + uint32_t filetype; + uint32_t fileauth; + uint32_t flag1; + uint32_t flag2; } lzc_fileHdr; diff --git a/macunpack/lzh.c b/macunpack/lzh.c index 300d008..26a637f 100644 --- a/macunpack/lzh.c +++ b/macunpack/lzh.c @@ -382,37 +382,37 @@ lzh_wrfile (struct lzh_fileHdr *filehdr, int method) } switch(method) { case lz4: - lzh_nocomp((unsigned long)128); + lzh_nocomp((uint32_t)128); break; #ifdef UNTESTED case lz5: - lzh_lzss1((unsigned long)128); + lzh_lzss1((uint32_t)128); break; case lzs: - lzh_lzss2((unsigned long)128); + lzh_lzss2((uint32_t)128); break; #endif /* UNTESTED */ case lh0: - lzh_nocomp((unsigned long)128); + lzh_nocomp((uint32_t)128); break; case lh1: - lzh_lzah((unsigned long)128); + lzh_lzah((uint32_t)128); break; #ifdef UNDEF case lh2: - lzh_lh2((unsigned long)128); + lzh_lh2((uint32_t)128); break; case lh3: - lzh_lh3((unsigned long)128); + lzh_lh3((uint32_t)128); break; #endif /* UNDEF */ #ifdef UNTESTED case lh4: - lzh_lzh12((unsigned long)128); + lzh_lzh12((uint32_t)128); break; #endif /* UNTESTED */ case lh5: - lzh_lzh13((unsigned long)128); + lzh_lzh13((uint32_t)128); break; default: mname = lzh_methname(method); @@ -452,8 +452,8 @@ lzh_wrfile (struct lzh_fileHdr *filehdr, int method) if(list) { do_indent(indent); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)dataLength, (long)rsrcLength); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength); } if(info_only) { doit = 0; @@ -467,7 +467,7 @@ lzh_wrfile (struct lzh_fileHdr *filehdr, int method) } if(doit) { define_name(text); - start_info(info, (unsigned long)rsrcLength, (unsigned long)dataLength); + start_info(info, (uint32_t)rsrcLength, (uint32_t)dataLength); } switch(method) { case lz4: @@ -589,7 +589,7 @@ lzh_skip (struct lzh_fileHdr *filehdr) /* -lz4- and -lh0: No compression */ /*---------------------------------------------------------------------------*/ static void -lzh_nocomp (unsigned long obytes) +lzh_nocomp (uint32_t obytes) { copy(lzh_file, lzh_data, (int)obytes); } @@ -599,7 +599,7 @@ lzh_nocomp (unsigned long obytes) /* -lz5-: LZSS compression, variant 1 */ /*---------------------------------------------------------------------------*/ static void -lzh_lzss1 (unsigned long obytes) +lzh_lzss1 (uint32_t obytes) { int mask, ch, lzcnt, lzptr, ptr, count; char *p = lzh_lzbuf; @@ -662,7 +662,7 @@ lzh_lzss1 (unsigned long obytes) /* -lzs-: LZSS compression, variant 2 */ /*---------------------------------------------------------------------------*/ static void -lzh_lzss2 (unsigned long obytes) +lzh_lzss2 (uint32_t obytes) { int ch, lzcnt, lzptr, ptr, i; @@ -706,7 +706,7 @@ lzh_lzss2 (unsigned long obytes) /* -lh1-: LZ compression plus adaptive Huffman encoding */ /*---------------------------------------------------------------------------*/ static void -lzh_lzah (unsigned long obytes) +lzh_lzah (uint32_t obytes) { lzh_current = lzh_data + 2; /* SKIPPING BLOCKSIZE! */ tmp_out_ptr = out_ptr; @@ -727,7 +727,7 @@ lzh_getbyte (void) /* -lh2-: LZ** compression */ /*---------------------------------------------------------------------------*/ static void -lzh_lh2 (unsigned long obytes) +lzh_lh2 (uint32_t obytes) { } @@ -735,7 +735,7 @@ lzh_lh2 (unsigned long obytes) /* -lh3-: LZ** compression */ /*---------------------------------------------------------------------------*/ static void -lzh_lh3 (unsigned long obytes) +lzh_lh3 (uint32_t obytes) { } #endif /* UNDEF */ @@ -745,13 +745,13 @@ lzh_lh3 (unsigned long obytes) /* -lh4-: LZ(12) compression plus Huffman encoding */ /*---------------------------------------------------------------------------*/ static void -lzh_lzh12 (unsigned long obytes) +lzh_lzh12 (uint32_t obytes) { lzh_current = lzh_data; tmp_out_ptr = out_ptr; out_ptr = lzh_file; /* Controlled by obytes only */ - de_lzh((long)(-1), (long)obytes, &lzh_current, 12); + de_lzh((int32_t)(-1), (int32_t)obytes, &lzh_current, 12); out_ptr = tmp_out_ptr; } #endif /* UNTESTED */ @@ -760,12 +760,12 @@ lzh_lzh12 (unsigned long obytes) /* -lh5-: LZ(13) compression plus Huffman encoding */ /*---------------------------------------------------------------------------*/ static void -lzh_lzh13 (unsigned long obytes) +lzh_lzh13 (uint32_t obytes) { lzh_current = lzh_data; tmp_out_ptr = out_ptr; out_ptr = lzh_file; /* Controlled by obytes only */ - de_lzh((long)(-1), (long)obytes, &lzh_current, 13); + de_lzh((int32_t)(-1), (int32_t)obytes, &lzh_current, 13); out_ptr = tmp_out_ptr; } diff --git a/macunpack/lzh.h b/macunpack/lzh.h index df1dc76..b572a56 100644 --- a/macunpack/lzh.h +++ b/macunpack/lzh.h @@ -1,3 +1,5 @@ +#include + #define FILEHDRSIZE 22 #define TOTALSIZE 64 #define L_HSIZE 0 @@ -34,9 +36,9 @@ typedef struct lzh_fileHdr { /* 58 bytes */ unsigned char hsize; unsigned char hcrc; char method[5]; - unsigned long psize; - unsigned long upsize; - unsigned long lastmod; + uint32_t psize; + uint32_t upsize; + uint32_t lastmod; unsigned short attribute; unsigned char nlength; char name[32]; diff --git a/macunpack/macbinary.c b/macunpack/macbinary.c index 6f0f678..08bf6eb 100644 --- a/macunpack/macbinary.c +++ b/macunpack/macbinary.c @@ -74,7 +74,7 @@ macbinary (void) if(verbose) { (void)fprintf(stderr, "This is a \"Zoom\" archive.\n"); } - zma(header, (unsigned long)0); + zma(header, (uint32_t)0); exit(0); } #endif /* ZMA */ @@ -167,7 +167,7 @@ macbinary (void) #ifdef SCAN do_idf(header + I_NAMEOFF + 1, PACK_NAME); #endif /* SCAN */ - jdw((unsigned long)in_data_size); + jdw((uint32_t)in_data_size); skip_file(ds_skip + in_rs); continue; } @@ -183,7 +183,7 @@ macbinary (void) #ifdef SCAN do_idf(header + I_NAMEOFF + 1, PACK_NAME); #endif /* SCAN */ - stf((unsigned long)in_data_size); + stf((uint32_t)in_data_size); skip_file(ds_skip + in_rs); continue; } @@ -389,7 +389,7 @@ macbinary (void) #ifdef SCAN do_idf(header + I_NAMEOFF + 1, ARCH_NAME); #endif /* SCAN */ - zma((char *)NULL, (unsigned long)in_data_size); + zma((char *)NULL, (uint32_t)in_data_size); skip_file(ds_skip + in_rs); continue; } @@ -403,7 +403,7 @@ macbinary (void) #ifdef SCAN do_idf(header + I_NAMEOFF + 1, ARCH_NAME); #endif /* SCAN */ - zma((char *)NULL, (unsigned long)in_data_size); + zma((char *)NULL, (uint32_t)in_data_size); skip_file(ds_skip + in_rs); continue; } @@ -499,8 +499,8 @@ macbinary (void) } #endif /* DD */ if(header[0] == 0 /* MORE CHECKS HERE! */) { - mcb(header, (unsigned long)in_rsrc_size, - (unsigned long)in_data_size, in_ds + in_rs); + mcb(header, (uint32_t)in_rsrc_size, + (uint32_t)in_data_size, in_ds + in_rs); continue; } else { (void)fprintf(stderr, "Unrecognized archive type.\n"); diff --git a/macunpack/macunpack.c b/macunpack/macunpack.c index 051f7d5..09546e4 100644 --- a/macunpack/macunpack.c +++ b/macunpack/macunpack.c @@ -157,7 +157,7 @@ int main(int argc, char **argv) if(verbose) { fprintf(stderr, "This is a \"ShrinkToFit\" packed file.\n"); } - stf(~(unsigned long)1); + stf(~(uint32_t)1); break; #endif /* STF */ #ifdef PIT diff --git a/macunpack/mcb.c b/macunpack/mcb.c index 580ebda..e713106 100644 --- a/macunpack/mcb.c +++ b/macunpack/mcb.c @@ -8,7 +8,7 @@ static int mcb_read; static void mcb_wrfile(); -void mcb(char *hdr, unsigned long rsrcLength, unsigned long dataLength, int toread) +void mcb(char *hdr, uint32_t rsrcLength, uint32_t dataLength, int toread) { register int i; int n; @@ -36,8 +36,8 @@ void mcb(char *hdr, unsigned long rsrcLength, unsigned long dataLength, int tore transname(hdr + I_AUTHOFF, fauth, 4); do_indent(indent); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)dataLength, (long)rsrcLength); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength); if(info_only) { write_it = 0; } @@ -77,7 +77,7 @@ void mcb(char *hdr, unsigned long rsrcLength, unsigned long dataLength, int tore } static void -mcb_wrfile (unsigned long ibytes) +mcb_wrfile (uint32_t ibytes) { int n; diff --git a/macunpack/mcb.h b/macunpack/mcb.h index 4e46a7e..c356c6a 100644 --- a/macunpack/mcb.h +++ b/macunpack/mcb.h @@ -1 +1 @@ -extern void mcb(char *hdr, unsigned long rsrcLength, unsigned long dataLength, int toread); +extern void mcb(char *hdr, uint32_t rsrcLength, uint32_t dataLength, int toread); diff --git a/macunpack/pit.c b/macunpack/pit.c index edb9058..17f594d 100644 --- a/macunpack/pit.c +++ b/macunpack/pit.c @@ -24,7 +24,7 @@ pit (void) struct pit_header filehdr; char pithdr[4]; int decode, synced, ch; - unsigned long data_crc, crc; + uint32_t data_crc, crc; updcrc = binhex_updcrc; crcinit = binhex_crcinit; @@ -207,8 +207,8 @@ pit_filehdr (struct pit_header *f, int compr) transname(hdr + H_AUTHOFF, fauth, 4); do_indent(indent); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)f->dlen, (long)f->rlen); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)f->dlen, (int32_t)f->rlen); if(info_only) { write_it = 0; } @@ -236,7 +236,7 @@ pit_filehdr (struct pit_header *f, int compr) } static void -pit_wrfile (unsigned long bytes, int type) +pit_wrfile (uint32_t bytes, int type) { if(bytes == 0) { return; @@ -254,7 +254,7 @@ pit_wrfile (unsigned long bytes, int type) /* No compression */ /*---------------------------------------------------------------------------*/ static void -pit_nocomp (unsigned long ibytes) +pit_nocomp (uint32_t ibytes) { int n; @@ -272,7 +272,7 @@ pit_nocomp (unsigned long ibytes) /* Huffman compression */ /*---------------------------------------------------------------------------*/ static void -pit_huffman (unsigned long obytes) +pit_huffman (uint32_t obytes) { de_huffman(obytes); } diff --git a/macunpack/pit.h b/macunpack/pit.h index f47caeb..0292b59 100644 --- a/macunpack/pit.h +++ b/macunpack/pit.h @@ -20,10 +20,10 @@ struct pit_header { /* Packit file header (92 bytes) */ char auth[4]; /* file creator */ unsigned short flags; /* file flags (?) */ unsigned short lock; /* unknown */ - unsigned long dlen; /* number of bytes in data fork */ - unsigned long rlen; /* number of bytes in resource fork */ - unsigned long ctim; /* file creation time */ - unsigned long mtim; /* file modified time */ + uint32_t dlen; /* number of bytes in data fork */ + uint32_t rlen; /* number of bytes in resource fork */ + uint32_t ctim; /* file creation time */ + uint32_t mtim; /* file modified time */ unsigned short hdrCRC; /* CRC */ }; diff --git a/macunpack/sit.c b/macunpack/sit.c index 88f15ec..2d8ea66 100644 --- a/macunpack/sit.c +++ b/macunpack/sit.c @@ -90,7 +90,7 @@ static short code6[258] = { 1, 1}; static char sit_buffer[32768]; static short sit_dict[16385]; -static unsigned long sit_avail; +static uint32_t sit_avail; static int sit_bits_avail; void @@ -205,9 +205,9 @@ static int sit_filehdr(struct sit_fileHdr *f, int skip) transname(hdr + F_FTYPE, ftype, 4); transname(hdr + F_CREATOR, fauth, 4); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", text, ftype, fauth, - (long)f->dataLength, (long)f->rsrcLength); + (int32_t)f->dataLength, (int32_t)f->rsrcLength); } if(info_only) { write_it = 0; @@ -438,7 +438,7 @@ sit_unstuff (struct sit_fileHdr filehdr) } static void -sit_wrfile (unsigned long ibytes, unsigned long obytes, int type) +sit_wrfile (uint32_t ibytes, uint32_t obytes, int type) { if(ibytes == 0) { if(verbose) { @@ -534,7 +534,7 @@ sit_wrfile (unsigned long ibytes, unsigned long obytes, int type) /* skip stuffit file */ static void -sit_skip (unsigned long ibytes) +sit_skip (uint32_t ibytes) { while(ibytes != 0) { if(getc(infp) == EOF) { @@ -552,7 +552,7 @@ sit_skip (unsigned long ibytes) /* Method 0: No compression */ /*---------------------------------------------------------------------------*/ static void -sit_nocomp (unsigned long ibytes) +sit_nocomp (uint32_t ibytes) { int n; @@ -570,7 +570,7 @@ sit_nocomp (unsigned long ibytes) /* Method 1: Run length encoding */ /*---------------------------------------------------------------------------*/ static void -sit_rle (unsigned long ibytes) +sit_rle (uint32_t ibytes) { int ch, lastch = 0, n, i; @@ -600,7 +600,7 @@ sit_rle (unsigned long ibytes) /* Method 2: LZC compressed */ /*---------------------------------------------------------------------------*/ static void -sit_lzc (unsigned long ibytes) +sit_lzc (uint32_t ibytes) { de_compress(ibytes, 14); } @@ -609,7 +609,7 @@ sit_lzc (unsigned long ibytes) /* Method 3: Huffman compressed */ /*---------------------------------------------------------------------------*/ static void -sit_huffman (unsigned long obytes) +sit_huffman (uint32_t obytes) { read_tree(); de_huffman(obytes); @@ -619,7 +619,7 @@ sit_huffman (unsigned long obytes) /* Method 5: LZ compression plus adaptive Huffman encoding */ /*---------------------------------------------------------------------------*/ static void -sit_lzah (unsigned long obytes) +sit_lzah (uint32_t obytes) { lzah_getbyte = sit_getbyte; de_lzah(obytes); @@ -635,11 +635,11 @@ sit_getbyte (void) /* Method 6: Compression with a fixed Huffman encoding */ /*---------------------------------------------------------------------------*/ static void -sit_fixhuf (unsigned long ibytes) +sit_fixhuf (uint32_t ibytes) { int i, sum, codes, sym, num; char byte_int[4], byte_short[2]; - long size; + int32_t size; int sign; char *tmp_ptr, *ptr, *end_ptr; @@ -659,7 +659,7 @@ sit_fixhuf (unsigned long ibytes) exit(1); } ibytes -= 4; - size = (long)get4(byte_int); + size = (int32_t)get4(byte_int); sign = 0; if(size < 0) { size = - size; @@ -759,7 +759,7 @@ sit_dosplit (int ptr, int sum, int low, int upp) /* Method 8: Compression with a MW encoding */ /*---------------------------------------------------------------------------*/ static void -sit_mw (unsigned long ibytes) +sit_mw (uint32_t ibytes) { int ptr; int max, max1, bits; @@ -819,7 +819,7 @@ sit_mw_out (int ptr) } static int -sit_mw_in (int bits, unsigned long *ibytes) +sit_mw_in (int bits, uint32_t *ibytes) { int res, res1; diff --git a/macunpack/sit.h b/macunpack/sit.h index 06e439a..e36ff11 100644 --- a/macunpack/sit.h +++ b/macunpack/sit.h @@ -1,6 +1,8 @@ #include "macunpack.h" #ifdef SIT +#include + #ifdef SIT_INTERNAL #define S_SIGNATURE 0 #define S_NUMFILES 4 @@ -26,12 +28,12 @@ #define F_HDRCRC 110 #define FILEHDRSIZE 112 -typedef long OSType; +typedef int32_t OSType; typedef struct sitHdr { /* 22 bytes */ OSType signature; /* = 'SIT!' -- for verification */ unsigned short numFiles; /* number of files in archive */ - unsigned long arcLength; /* length of entire archive incl. + uint32_t arcLength; /* length of entire archive incl. hdr. -- for verification */ OSType signature2; /* = 'rLau' -- for verification */ unsigned char version; /* version number */ @@ -47,12 +49,12 @@ typedef struct sit_fileHdr { /* 112 bytes */ unsigned short FndrFlags; /* copy of Finder flags. For our purposes, we can clear: busy,onDesk */ - unsigned long creationDate; - unsigned long modDate; /* !restored-compat w/backup prgms */ - unsigned long rsrcLength; /* decompressed lengths */ - unsigned long dataLength; - unsigned long compRLength; /* compressed lengths */ - unsigned long compDLength; + uint32_t creationDate; + uint32_t modDate; /* !restored-compat w/backup prgms */ + uint32_t rsrcLength; /* decompressed lengths */ + uint32_t dataLength; + uint32_t compRLength; /* compressed lengths */ + uint32_t compDLength; unsigned short rsrcCRC; /* crc of rsrc fork */ unsigned short dataCRC; /* crc of data fork */ char reserved[6]; diff --git a/macunpack/stf.c b/macunpack/stf.c index a42f11d..c9f12a9 100644 --- a/macunpack/stf.c +++ b/macunpack/stf.c @@ -25,12 +25,12 @@ static void stf_wrfork(); static void stf_construct(); void -stf (unsigned long ibytes) +stf (uint32_t ibytes) { char magic[3], fauth[5], ftype[5]; int filel, i; unsigned int rsrcLength, dataLength; - unsigned long curtime; + uint32_t curtime; set_huffman(HUFF_LE); for(i = 0; i < 3; i++) { @@ -58,19 +58,19 @@ stf (unsigned long ibytes) for(i = 0; i < 4; i++) { info[I_AUTHOFF + i] = getb(infp); } - curtime = (unsigned long)time((time_t *)0) + TIMEDIFF; + curtime = (uint32_t)time((time_t *)0) + TIMEDIFF; put4(info + I_CTIMOFF, curtime); put4(info + I_MTIMOFF, curtime); rsrcLength = 0; for(i = 0; i < 4; i++) { rsrcLength = (rsrcLength << 8) + getb(infp); } - put4(info + I_RLENOFF, (unsigned long)rsrcLength); + put4(info + I_RLENOFF, (uint32_t)rsrcLength); dataLength = 0; for(i = 0; i < 4; i++) { dataLength = (dataLength << 8) + getb(infp); } - put4(info + I_DLENOFF, (unsigned long)dataLength); + put4(info + I_DLENOFF, (uint32_t)dataLength); ibytes -= filel + 20; write_it = 1; if(list) { @@ -79,8 +79,8 @@ stf (unsigned long ibytes) transname(info + I_AUTHOFF, fauth, 4); do_indent(indent); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)dataLength, (long)rsrcLength); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength); if(info_only) { write_it = 0; } @@ -90,13 +90,13 @@ stf (unsigned long ibytes) (void)fputc('\n', stderr); } } - stf_wrfile((unsigned long)rsrcLength, (unsigned long)dataLength, ibytes); + stf_wrfile((uint32_t)rsrcLength, (uint32_t)dataLength, ibytes); } static void -stf_wrfile (unsigned long rsrcLength, unsigned long dataLength, unsigned long ibytes) +stf_wrfile (uint32_t rsrcLength, uint32_t dataLength, uint32_t ibytes) { - unsigned long num = 0; + uint32_t num = 0; if(write_it) { define_name(text); @@ -118,7 +118,7 @@ stf_wrfile (unsigned long rsrcLength, unsigned long dataLength, unsigned long ib } static void -stf_wrfork (unsigned long *num, unsigned long towrite, int offs) +stf_wrfork (uint32_t *num, uint32_t towrite, int offs) { int c, k, max, i, i1; char *tmp_out_ptr; @@ -157,7 +157,7 @@ stf_wrfork (unsigned long *num, unsigned long towrite, int offs) stf_construct(32); tmp_out_ptr = out_ptr; out_ptr = length; - de_huffman((unsigned long)256); + de_huffman((uint32_t)256); out_ptr = tmp_out_ptr; for(i = 1; i < 257; i++) { table[i].num = 0x40000000 >> length[i - 1]; @@ -181,7 +181,7 @@ stf_wrfork (unsigned long *num, unsigned long towrite, int offs) if(i > towrite - *num) { i = towrite - *num; } - de_huffman((unsigned long)i); + de_huffman((uint32_t)i); *num += i; } } diff --git a/macunpack/stf.h b/macunpack/stf.h index 839f3b9..df669d8 100644 --- a/macunpack/stf.h +++ b/macunpack/stf.h @@ -1,5 +1,8 @@ #include "macunpack.h" #ifdef STF + +#include + #define MAGIC "RTH" #define S_MAGIC 0 @@ -11,9 +14,9 @@ typedef struct stf_fileHdr { char magic[3]; char flength; char fname[32]; /* actually flength */ - unsigned long rsrcLength; - unsigned long dataLength; + uint32_t rsrcLength; + uint32_t dataLength; } stf_fileHdr; -void stf (unsigned long ibytes); +void stf (uint32_t ibytes); #endif \ No newline at end of file diff --git a/macunpack/zma.c b/macunpack/zma.c index 7756aed..dbf5b62 100644 --- a/macunpack/zma.c +++ b/macunpack/zma.c @@ -17,8 +17,8 @@ extern void de_lzh(); static char *zma_archive; static char *zma_current; static char *zma_filestart; -static unsigned long zma_length; -static long zma_archlength; +static uint32_t zma_length; +static int32_t zma_archlength; static int zma_filehdr(); static void zma_folder(); @@ -28,7 +28,7 @@ static void zma_nocomp(); static void zma_lzh(); void -zma (char *start, unsigned long length) +zma (char *start, uint32_t length) { struct zma_fileHdr filehdr; int i, toread; @@ -175,9 +175,9 @@ zma_filehdr (struct zma_fileHdr *f, int skip) transname(zma_current + Z_TYPE, ftype, 4); transname(zma_current + Z_AUTH, fauth, 4); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", text, ftype, fauth, - (long)f->dataLength, (long)f->rsrcLength); + (int32_t)f->dataLength, (int32_t)f->rsrcLength); } switch(f->what) { case z_plug: @@ -322,7 +322,7 @@ zma_mooz (struct zma_fileHdr filehdr) } static void -zma_wrfile (unsigned long ibytes, unsigned long obytes, int type) +zma_wrfile (uint32_t ibytes, uint32_t obytes, int type) { if(ibytes == 0) { if(verbose) { @@ -361,7 +361,7 @@ zma_wrfile (unsigned long ibytes, unsigned long obytes, int type) /* No compression */ /*---------------------------------------------------------------------------*/ static void -zma_nocomp (unsigned long ibytes) +zma_nocomp (uint32_t ibytes) { int n = ibytes; char *ptr = out_buffer; @@ -375,10 +375,10 @@ zma_nocomp (unsigned long ibytes) /* LZ compression plus Huffman encoding */ /*---------------------------------------------------------------------------*/ static void -zma_lzh (unsigned long ibytes) +zma_lzh (uint32_t ibytes) { /* Controlled by ibutes only */ - de_lzh((long)ibytes, (long)(-1), &zma_filestart, 13); + de_lzh((int32_t)ibytes, (int32_t)(-1), &zma_filestart, 13); } #else /* ZMA */ int zma; /* keep lint and some compilers happy */ diff --git a/macunpack/zma.h b/macunpack/zma.h index 297d8a2..02e23da 100644 --- a/macunpack/zma.h +++ b/macunpack/zma.h @@ -1,5 +1,7 @@ #include "zmahdr.h" +#include + #define Z_HDRSIZE 78 #define Z_WHAT 0 /* What kind of data? */ @@ -25,15 +27,15 @@ typedef struct zma_fileHdr { /* 78 bytes */ char what; /* What kind? Negative if deleted */ unsigned char hlen ; /* Header length */ unsigned short boolFlags; /* Boolean flags */ - unsigned long next; /* Next entry */ - unsigned long compRLength; /* The compressed lengths. */ - unsigned long compDLength; /* For dirs, the second is # entries */ - unsigned long rsrcLength; /* The uncompressed lengths. */ - unsigned long dataLength; - unsigned long fType; /* file type */ - unsigned long fCreator; /* er... */ - unsigned long modDate; /* !restored-compat w/backup prgms */ - unsigned long comment; /* Comment offset */ + uint32_t next; /* Next entry */ + uint32_t compRLength; /* The compressed lengths. */ + uint32_t compDLength; /* For dirs, the second is # entries */ + uint32_t rsrcLength; /* The uncompressed lengths. */ + uint32_t dataLength; + uint32_t fType; /* file type */ + uint32_t fCreator; /* er... */ + uint32_t modDate; /* !restored-compat w/backup prgms */ + uint32_t comment; /* Comment offset */ unsigned short FndrFlags; /* copy of Finder flags. For our purposes, we can clear: busy,onDesk */ @@ -41,7 +43,7 @@ typedef struct zma_fileHdr { /* 78 bytes */ unsigned short rsrcCRC; /* Resource fork crc */ unsigned char fName[32]; /* a STR32 */ /* The following are overlayed in the original structure */ - unsigned long conts; /* Pointer to directory contents */ + uint32_t conts; /* Pointer to directory contents */ } zma_fileHdr; /* zma types (see what) */ diff --git a/mixed/macbinary.c b/mixed/macbinary.c index f841b1c..12e5f7e 100644 --- a/mixed/macbinary.c +++ b/mixed/macbinary.c @@ -49,8 +49,8 @@ macbinary (void) } #endif /* SCAN */ if(header[0] == 0 /* MORE CHECKS HERE! */) { - mcb(header, (unsigned long)in_rsrc_size, - (unsigned long)in_data_size, in_ds + in_rs); + mcb(header, (uint32_t)in_rsrc_size, + (uint32_t)in_data_size, in_ds + in_rs); continue; } else { (void)fprintf(stderr, "Unrecognized header.\n"); diff --git a/mixed/macstream.c b/mixed/macstream.c index 85237af..344d35e 100644 --- a/mixed/macstream.c +++ b/mixed/macstream.c @@ -101,8 +101,8 @@ int main(int argc, char **argv) if(i == ISFILE) { do_indent(indent); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)data_size, (long)rsrc_size); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)data_size, (int32_t)rsrc_size); } else if(i == ISDIR) { do_indent(indent); dir_ptr += 64; diff --git a/mixed/mcb.c b/mixed/mcb.c index 688f4de..016a1f4 100644 --- a/mixed/mcb.c +++ b/mixed/mcb.c @@ -9,7 +9,7 @@ static int mcb_read; static void mcb_wrfile(); void -mcb (char *hdr, unsigned long rsrcLength, unsigned long dataLength, int toread) +mcb (char *hdr, uint32_t rsrcLength, uint32_t dataLength, int toread) { register int i; int n; @@ -37,8 +37,8 @@ mcb (char *hdr, unsigned long rsrcLength, unsigned long dataLength, int toread) transname(hdr + I_AUTHOFF, fauth, 4); do_indent(indent); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)dataLength, (long)rsrcLength); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength); if(info_only) { write_it = 0; } @@ -65,7 +65,7 @@ mcb (char *hdr, unsigned long rsrcLength, unsigned long dataLength, int toread) } static void -mcb_wrfile (unsigned long ibytes) +mcb_wrfile (uint32_t ibytes) { int n; diff --git a/util/util.c b/util/util.c index cab0e5e..c230e44 100644 --- a/util/util.c +++ b/util/util.c @@ -10,10 +10,10 @@ static int mlength[] = {0, 31, 61, 92, 122, 153, 184, 214, 245, 275, 306, 337}; -unsigned long get4(char *bp) +uint32_t get4(char *bp) { register int i; - long value = 0; + int32_t value = 0; for(i = 0; i < 4; i++) { value <<= 8; @@ -24,10 +24,10 @@ unsigned long get4(char *bp) } /* For if integers are stored wrong-endian. */ -unsigned long get4i(char *bp) +uint32_t get4i(char *bp) { register int i; - long value = 0; + int32_t value = 0; bp += 3; for (i = 0; i < 4; i++) { @@ -38,7 +38,7 @@ unsigned long get4i(char *bp) return value; } -unsigned long get2(char *bp) +uint32_t get2(char *bp) { register int i; int value = 0; @@ -52,10 +52,10 @@ unsigned long get2(char *bp) } /* For if integers are stored wrong-endian. */ -unsigned long get2i(char *bp) +uint32_t get2i(char *bp) { register int i; - long value = 0; + int32_t value = 0; bp += 1; for(i = 0; i < 2; i++) { @@ -109,7 +109,7 @@ do_query (void) } void -put4 (char *dest, unsigned long value) +put4 (char *dest, uint32_t value) { *dest++ = (value >> 24) & BYTEMASK; *dest++ = (value >> 16) & BYTEMASK; @@ -118,7 +118,7 @@ put4 (char *dest, unsigned long value) } void -put2 (char *dest, unsigned long value) +put2 (char *dest, uint32_t value) { *dest++ = (value >> 8) & BYTEMASK; *dest++ = value & BYTEMASK; @@ -134,8 +134,8 @@ do_indent (int indent) } } -real_time set_time(year, month, day, hours, minutes, seconds) -int year, month, day, hours, minutes, seconds; +real_time +set_time (int year, int month, int day, int hours, int minutes, int seconds) { real_time toset; @@ -148,10 +148,10 @@ int year, month, day, hours, minutes, seconds; return toset; } -unsigned long tomactime(time) -real_time time; +uint32_t +tomactime (real_time time) { - long accum; + int32_t accum; int year; accum = time.month - 3; @@ -166,10 +166,10 @@ real_time time; return (unsigned)accum; } -real_time frommactime(accum) -unsigned long accum; +real_time +frommactime (uint32_t accum) { -long tmp1, tmp2; +int32_t tmp1, tmp2; real_time time; time.seconds = tmp1 = accum % 60; @@ -178,7 +178,7 @@ real_time time; accum /= 60; time.hours = tmp1 = accum % 24; accum /= 24; - tmp1 = (long)accum - 60; + tmp1 = (int32_t)accum - 60; tmp2 = tmp1 % 1461; if(tmp2 < 0) { tmp2 += 1461; diff --git a/util/util.h b/util/util.h index 90112be..4dbbec9 100644 --- a/util/util.h +++ b/util/util.h @@ -1,3 +1,5 @@ +#include + typedef struct real_time { int year; int month; @@ -7,17 +9,17 @@ typedef struct real_time { int seconds; } real_time; -extern unsigned long get4(); -extern unsigned long get4i(); -extern unsigned long get2(); -extern unsigned long get2i(); -extern unsigned char getb(); -extern void copy(); -extern int do_query(); -extern void put4(); -extern void put2(); -extern void do_indent(); -extern real_time set_time(); -extern unsigned long tomactime(); -extern real_time frommactime(); +extern uint32_t get4(char *bp); +extern uint32_t get4i(char *bp); +extern uint32_t get2(char *bp); +extern uint32_t get2i(char *bp); +extern unsigned char getb(FILE *fp); +extern void copy(char *d, char *s, int n); +extern int do_query(void); +extern void put4(char *dest, uint32_t value); +extern void put2(char *dest, uint32_t value); +extern void do_indent(int indent); +extern real_time set_time(int year, int month, int day, int hours, int minutes, int seconds); +extern uint32_t tomactime(real_time time); +extern real_time frommactime(uint32_t accum); From a5e3a5e59cb78e0f8b67b9467f3480588464fda0 Mon Sep 17 00:00:00 2001 From: Arvid Norlander Date: Thu, 29 Sep 2022 22:13:16 +0200 Subject: [PATCH 11/12] Convert remaining code to use prototypes. --- binhex/binhex.c | 2 +- binhex/dofile.c | 26 +++++++++++------------ comm/frommac.c | 2 +- comm/tomac.c | 2 +- comm/xm_from.c | 6 +++--- comm/xm_from.h | 2 +- comm/xm_to.c | 6 +++--- comm/xm_to.h | 2 +- crc/makecrc.c | 2 +- fileio/rdfile.c | 17 ++++++++------- fileio/rdfile.h | 2 ++ fileio/rdfileopt.h | 8 +++---- fileio/wrfile.c | 38 ++++++++++++++++----------------- fileio/wrfile.h | 2 +- fileio/wrfileopt.h | 10 ++++----- hexbin/buffer.h | 6 +++--- hexbin/dl.c | 1 + hexbin/globals.h | 7 ++---- hexbin/hecx.c | 15 +++++++------ hexbin/hqx.c | 1 + hexbin/mu.c | 7 +++--- hexbin/printhdr.c | 1 + hexbin/printhdr.h | 6 +++--- hexbin/readline.h | 2 +- macunpack/bin.c | 1 + macunpack/bits_be.h | 6 +++--- macunpack/cpt.c | 29 +++++++++++++------------ macunpack/cpt.h | 8 +++++++ macunpack/dd.c | 47 +++++++++++++++++++++-------------------- macunpack/de_compress.c | 9 +++++--- macunpack/de_huffman.c | 12 +++++------ macunpack/de_huffman.h | 2 +- macunpack/de_lzah.c | 10 ++++----- macunpack/de_lzah.h | 2 +- macunpack/de_lzh.c | 6 +++--- macunpack/dia.c | 21 ++++++++++-------- macunpack/dia.h | 9 ++++++++ macunpack/dir.c | 3 +++ macunpack/dir.h | 1 + macunpack/globals.h | 4 +--- macunpack/huffman.h | 6 +++--- macunpack/jdw.c | 9 +++++--- macunpack/jdw.h | 7 ++++++ macunpack/lzc.c | 14 +++++++----- macunpack/lzc.h | 7 ++++++ macunpack/lzh.c | 37 ++++++++++++++++---------------- macunpack/lzh.h | 10 +++++++++ macunpack/macbinary.c | 47 ++++++++++++++++------------------------- macunpack/macbinary.h | 1 + macunpack/macunpack.c | 25 ++++++++-------------- macunpack/mcb.c | 7 +++++- macunpack/mcb.h | 2 ++ macunpack/pit.c | 22 +++++++++++-------- macunpack/pit.h | 11 ++++++++++ macunpack/sit.c | 42 ++++++++++++++++++------------------ macunpack/stf.c | 12 +++++------ macunpack/zma.c | 21 ++++++++++-------- macunpack/zma.h | 9 ++++++++ mixed/dir.c | 3 +++ mixed/dir.h | 1 + mixed/globals.h | 3 --- mixed/macbinary.c | 14 +++++++----- mixed/macbinary.h | 1 + mixed/macsave.c | 7 +++--- mixed/macstream.c | 4 +--- mixed/mcb.c | 7 +++++- mixed/mcb.h | 3 +++ util/curtime.h | 1 - util/util.h | 1 + 69 files changed, 387 insertions(+), 290 deletions(-) create mode 100644 macunpack/dir.h create mode 100644 macunpack/macbinary.h create mode 100644 mixed/dir.h create mode 100644 mixed/macbinary.h create mode 100644 mixed/mcb.h diff --git a/binhex/binhex.c b/binhex/binhex.c index 4b8c0a0..7287373 100644 --- a/binhex/binhex.c +++ b/binhex/binhex.c @@ -12,7 +12,7 @@ #define LOCALOPT "RilqVH" -static void usage(); +static void usage(void); static char options[128]; static char *dir_stack; diff --git a/binhex/dofile.c b/binhex/dofile.c index 1abfd9e..dd815d0 100644 --- a/binhex/dofile.c +++ b/binhex/dofile.c @@ -16,13 +16,13 @@ static int savebits; static int rep_char; static int rep_count; -void doheader(); -void dofork(); -void outbyte(); -void finish(); -void outbyte1(); -void out6bit(); -void outchar(); +static void doheader(); +static void dofork(char *fork, int size); +static void outbyte(int b); +static void finish(void); +static void outbyte1(int b); +static void out6bit(int c); +static void outchar(int c); void dofile (void) @@ -42,7 +42,7 @@ dofile (void) (void)putchar('\n'); } -void +static void doheader (void) { uint32_t crc; @@ -95,7 +95,7 @@ int i; outbyte((int)(crc & 0xff)); } -void +static void outbyte (int b) { b &= 0xff; @@ -128,7 +128,7 @@ outbyte (int b) } } -void +static void finish (void) { if(rep_count > 0) { @@ -153,7 +153,7 @@ finish (void) } } -void +static void outbyte1 (int b) { switch(state) { @@ -177,13 +177,13 @@ outbyte1 (int b) } } -void +static void out6bit (int c) { outchar(codes[c & 0x3f]); } -void +static void outchar (int c) { (void)putchar(c); diff --git a/comm/frommac.c b/comm/frommac.c index 52f4cbe..55125c7 100644 --- a/comm/frommac.c +++ b/comm/frommac.c @@ -20,7 +20,7 @@ extern char info[]; -static void usage(); +static void usage(void); static char options[128]; static int multi_file = 0; diff --git a/comm/tomac.c b/comm/tomac.c index 0c74aad..aa796ff 100644 --- a/comm/tomac.c +++ b/comm/tomac.c @@ -17,7 +17,7 @@ #define LOCALOPT "ilqxyzoTVH" -static void usage(); +static void usage(void); static char options[128]; static char *dir_stack; diff --git a/comm/xm_from.c b/comm/xm_from.c index f22f424..c1f64a8 100644 --- a/comm/xm_from.c +++ b/comm/xm_from.c @@ -10,9 +10,9 @@ #include "protocol.h" #include "tty.h" -static void receive_part(); -static int receive_sync(); -static int receive_rec(); +static void receive_part(char *info, int size, int more); +static int receive_sync(void); +static int receive_rec(char *buf, int bufsize, int recno); char info[INFOBYTES]; diff --git a/comm/xm_from.h b/comm/xm_from.h index 95bc0fe..23c53a7 100644 --- a/comm/xm_from.h +++ b/comm/xm_from.h @@ -1 +1 @@ -void xm_from(); +void xm_from(void); diff --git a/comm/xm_to.c b/comm/xm_to.c index b34cc21..d8345cd 100644 --- a/comm/xm_to.c +++ b/comm/xm_to.c @@ -7,9 +7,9 @@ #include "protocol.h" #include "tty.h" -static void send_part(); -static int send_sync(); -static void send_rec(); +static void send_part(char *info, int size, int more); +static int send_sync(void); +static void send_rec(char *buf, int bufsize, int recno); void xm_to (void) diff --git a/comm/xm_to.h b/comm/xm_to.h index 7ebe8ae..de54df9 100644 --- a/comm/xm_to.h +++ b/comm/xm_to.h @@ -1 +1 @@ -void xm_to(); +void xm_to(void); diff --git a/crc/makecrc.c b/crc/makecrc.c index eaefd2b..9d153de 100644 --- a/crc/makecrc.c +++ b/crc/makecrc.c @@ -35,7 +35,7 @@ #include #include -static void initcrctab(); +static void initcrctab(char *name, int poly, int init, int swapped, int bits); int main (void) diff --git a/fileio/rdfile.c b/fileio/rdfile.c index a2db0a2..353d062 100644 --- a/fileio/rdfile.c +++ b/fileio/rdfile.c @@ -1,3 +1,5 @@ +#include "rdfile.h" + #include #include #include @@ -7,7 +9,6 @@ #endif /* TYPES_H */ #include #include "machdr.h" -#include "rdfile.h" #include "rdfileopt.h" #ifndef DIRENT_H #include @@ -46,11 +47,11 @@ #define RSRC_FORMAT 2 #define UNIX_FORMAT 3 -static void check_files(); -static void read_file(); -static void enter_dir(); -static void exit_dir(); -static int get_stdin_file(); +static void check_files(int initial); +static void read_file(void); +static void enter_dir(void); +static void exit_dir(void); +static int get_stdin_file(void); char file_info[INFOBYTES]; char *data_fork, *rsrc_fork; @@ -81,12 +82,12 @@ static char f_name[] = ".foldername"; #include "aufs.h" static char infodir[] = ".finderinfo"; static char rsrcdir[] = ".resource"; -static void read_aufs_info(); +static void read_aufs_info(FILE *fd); #endif /* AUFS */ #ifdef APPLEDOUBLE #include "appledouble.h" static char infodir[] = ".AppleDouble"; -static void read_appledouble_info(); +static void read_appledouble_info(FILE *fd); #endif /* APPLEDOUBLE */ #endif /* APPLESHARE */ static char filename[255]; diff --git a/fileio/rdfile.h b/fileio/rdfile.h index c8d8695..aa7ff0d 100644 --- a/fileio/rdfile.h +++ b/fileio/rdfile.h @@ -1,3 +1,5 @@ +#include "machdr.h" + #define ISATEND 0 #define ISFILE 1 #define ISDIR 2 diff --git a/fileio/rdfileopt.h b/fileio/rdfileopt.h index 74cafa1..cb1248f 100644 --- a/fileio/rdfileopt.h +++ b/fileio/rdfileopt.h @@ -1,5 +1,5 @@ -extern int rdfileopt(); -extern void give_rdfileopt(); -extern void set_norecurse(); -extern char *get_rdfileopt(); +extern int rdfileopt(int c); +extern void give_rdfileopt(void); +extern void set_norecurse(void); +extern char *get_rdfileopt(void); diff --git a/fileio/wrfile.c b/fileio/wrfile.c index 77f6a8a..2539fa3 100644 --- a/fileio/wrfile.c +++ b/fileio/wrfile.c @@ -4,6 +4,7 @@ #include #endif /* TYPES_H */ #include +#include #include #include #include @@ -44,17 +45,17 @@ char *sprintf(); #endif /* UNDEF */ #ifdef AUFS -static void check_aufs(); -static void aufs_namings(); -static void wr_aufs_info(); +static void check_aufs(void); +static void aufs_namings(void); +static void wr_aufs_info(FILE* fp); #endif /* AUFS */ #ifdef APPLEDOUBLE -static void check_appledouble(); -static void appledouble_namings(); -static void wr_appledouble_info(); +static void check_appledouble(void); +static void appledouble_namings(void); +static void wr_appledouble_info(FILE* fp); #endif /* APPLEDOUBLE */ #ifdef APPLESHARE -static void mk_share_name(); +static void mk_share_name(void); #endif /* APPLESHARE */ #ifndef BSD @@ -531,7 +532,7 @@ int i; #ifdef APPLESHARE #ifdef AUFS -static void check_aufs() +static void check_aufs(void) { /* check for .resource/ and .finderinfo/ */ struct stat stbuf; @@ -557,7 +558,7 @@ static void check_aufs() } } -static void aufs_namings() +static void aufs_namings(void) { mk_share_name(); (void)sprintf(f_info_aufs, "%s/%s", infodir, share_name); @@ -565,8 +566,7 @@ static void aufs_namings() (void)sprintf(f_data, "%s", share_name); } -static void wr_aufs_info(fp) -FILE *fp; +static void wr_aufs_info(FILE* fp) { FileInfo theinfo; int n; @@ -601,7 +601,7 @@ FILE *fp; #endif /* AUFS */ #ifdef APPLEDOUBLE -static void check_appledouble() +static void check_appledouble(void) { /* check for .AppleDouble/ */ struct stat stbuf; @@ -620,15 +620,14 @@ static void check_appledouble() } } -static void appledouble_namings() +static void appledouble_namings(void) { mk_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) -FILE *fp; +static void wr_appledouble_info(FILE* fp) { FileInfo theinfo; int n; @@ -673,7 +672,7 @@ FILE *fp; } #endif /* APPLEDOUBLE */ -static void mk_share_name() +static void mk_share_name(void) { int ch; char *mp, *up; @@ -693,8 +692,7 @@ static void mk_share_name() } #endif /* APPLESHARE */ -int wrfileopt(c) -char c; +int wrfileopt(char c) { switch(c) { case 'b': @@ -767,7 +765,7 @@ char c; return 1; } -void give_wrfileopt() +void give_wrfileopt(void) { (void)fprintf(stderr, "File output options:\n"); (void)fprintf(stderr, "-b:\tMacBinary (default)\n"); @@ -810,7 +808,7 @@ void set_s_wrfileopt(int restricted) mode_s_restricted = restricted; } -char *get_wrfileopt() +char *get_wrfileopt(void) { static char options[20]; diff --git a/fileio/wrfile.h b/fileio/wrfile.h index ac05b32..f050750 100644 --- a/fileio/wrfile.h +++ b/fileio/wrfile.h @@ -8,7 +8,7 @@ extern void start_rsrc(void); extern void start_data(void); extern void end_file(void); #ifdef SCAN -extern void do_idf(); +extern void do_idf(char *name, int kind); #endif /* SCAN */ extern void do_mkdir(char *name, char *header); extern void enddir(void); diff --git a/fileio/wrfileopt.h b/fileio/wrfileopt.h index da3083a..0011909 100644 --- a/fileio/wrfileopt.h +++ b/fileio/wrfileopt.h @@ -1,6 +1,6 @@ -extern int wrfileopt(); -extern void give_wrfileopt(); -extern void set_wrfileopt(); -extern void set_s_wrfileopt(); -extern char *get_wrfileopt(); +extern int wrfileopt(char c); +extern void give_wrfileopt(void); +extern void set_wrfileopt(int restricted); +extern void set_s_wrfileopt(int restricted); +extern char *get_wrfileopt(void); diff --git a/hexbin/buffer.h b/hexbin/buffer.h index 1bd2dfa..77ad455 100644 --- a/hexbin/buffer.h +++ b/hexbin/buffer.h @@ -1,6 +1,6 @@ extern char *data_fork, *rsrc_fork; extern int data_size, rsrc_size; -extern void put_byte(); -extern void set_put(); -extern void end_put(); +extern void put_byte(int c); +extern void set_put(int data); +extern void end_put(void); diff --git a/hexbin/dl.c b/hexbin/dl.c index f0e0495..f1f8d6d 100644 --- a/hexbin/dl.c +++ b/hexbin/dl.c @@ -6,6 +6,7 @@ #include "../fileio/machdr.h" #include "../fileio/wrfile.h" #include "../util/util.h" +#include "../util/transname.h" #include "buffer.h" #include "printhdr.h" diff --git a/hexbin/globals.h b/hexbin/globals.h index 88c5110..0dd7655 100644 --- a/hexbin/globals.h +++ b/hexbin/globals.h @@ -2,15 +2,12 @@ #include #include #ifdef BSD -extern char *rindex(); +#include #define search_last rindex #else /* BSD */ -extern char *strrchr(); #define search_last strrchr #endif /* BSD */ -extern void transname(); - extern char info[]; extern char trname[]; @@ -36,5 +33,5 @@ extern int was_macbin; extern FILE *ifp; -extern void do_error(); +extern void do_error(char *string); diff --git a/hexbin/hecx.c b/hexbin/hecx.c index 7c7314f..a05c85b 100644 --- a/hexbin/hecx.c +++ b/hexbin/hecx.c @@ -4,6 +4,7 @@ #include "crc.h" #include "readline.h" #include "../util/masks.h" +#include "../util/transname.h" #include "../util/util.h" #include "../fileio/machdr.h" #include "../fileio/wrfile.h" @@ -12,13 +13,13 @@ #include -static void do_o_forks(); -static int32_t make_file(); -static void comp_c_crc(); -static void comp_e_crc(); -static int comp_to_bin(); -static int hex_to_bin(); -static int hexit(); +static void do_o_forks(void); +static int32_t make_file(int compressed); +static void comp_c_crc(int c); +static void comp_e_crc(int c); +static int comp_to_bin(void); +static int hex_to_bin(void); +static int hexit(int c); static int compressed; diff --git a/hexbin/hqx.c b/hexbin/hqx.c index adc5255..c0e8a6b 100644 --- a/hexbin/hqx.c +++ b/hexbin/hqx.c @@ -9,6 +9,7 @@ #include "../fileio/machdr.h" #include "../fileio/wrfile.h" #include "../util/util.h" +#include "../util/transname.h" #include "printhdr.h" static void get_header(void); diff --git a/hexbin/mu.c b/hexbin/mu.c index 4633379..939f20d 100644 --- a/hexbin/mu.c +++ b/hexbin/mu.c @@ -5,6 +5,7 @@ #include "readline.h" #include "../util/masks.h" #include "../util/util.h" +#include "../util/transname.h" #include "../fileio/machdr.h" #include "../fileio/wrfile.h" #include "buffer.h" @@ -12,9 +13,9 @@ #include -static void do_mu_fork(); -static int mu_comp_to_bin(); -static int mu_convert(); +static void do_mu_fork(void); +static int mu_comp_to_bin(void); +static int mu_convert(char *ibuf, char *obuf); /* mu format -- process .mu files */ void diff --git a/hexbin/printhdr.c b/hexbin/printhdr.c index d9ded7b..e8bd634 100644 --- a/hexbin/printhdr.c +++ b/hexbin/printhdr.c @@ -1,5 +1,6 @@ #include "printhdr.h" #include "globals.h" +#include "../util/transname.h" /* print out header information in human-readable format */ void print_header0(int skip) diff --git a/hexbin/printhdr.h b/hexbin/printhdr.h index 2cda600..4a8a667 100644 --- a/hexbin/printhdr.h +++ b/hexbin/printhdr.h @@ -1,4 +1,4 @@ -extern void print_header0(); -extern void print_header1(); -extern void print_header2(); +extern void print_header0(int skip); +extern void print_header1(int skip1, int skip2); +extern void print_header2(int skip); diff --git a/hexbin/readline.h b/hexbin/readline.h index bebe741..18d4b20 100644 --- a/hexbin/readline.h +++ b/hexbin/readline.h @@ -1,3 +1,3 @@ extern char line[]; -int readline(); +int readline(void); diff --git a/macunpack/bin.c b/macunpack/bin.c index 8bc757e..cef10f6 100644 --- a/macunpack/bin.c +++ b/macunpack/bin.c @@ -1,6 +1,7 @@ #include "macunpack.h" #include "bin.h" #ifdef BIN +#include #include #include "globals.h" #include "../fileio/machdr.h" diff --git a/macunpack/bits_be.h b/macunpack/bits_be.h index 3f8e549..18abbf9 100644 --- a/macunpack/bits_be.h +++ b/macunpack/bits_be.h @@ -4,7 +4,7 @@ extern unsigned int bit_be_bitbuf; extern char *bit_be_filestart; extern int bit_be_inbytes; -extern void bit_be_fillbuf(); -extern unsigned int bit_be_getbits(); -extern void bit_be_init_getbits(); +extern void bit_be_fillbuf(int n); +extern unsigned int bit_be_getbits(int n); +extern void bit_be_init_getbits(void); diff --git a/macunpack/cpt.c b/macunpack/cpt.c index c6fdc24..a830d32 100644 --- a/macunpack/cpt.c +++ b/macunpack/cpt.c @@ -5,15 +5,19 @@ #endif /* CPT */ #endif /* DD */ #ifdef CPT + +#define CPT_INTERNAL +#include "cpt.h" + #include #include "globals.h" -#include "cpt.h" #include "crc.h" #include "../util/util.h" #include "../fileio/machdr.h" #include "../fileio/wrfile.h" #include "../fileio/kind.h" #include "../util/masks.h" +#include "../util/transname.h" #include "huffman.h" #define ESC1 0x81 @@ -22,7 +26,6 @@ #define ESC1SEEN 1 #define ESC2SEEN 2 -static void cpt_uncompact(); static unsigned char *cpt_data; static uint32_t cpt_datamax; static uint32_t cpt_datasize; @@ -42,17 +45,17 @@ static int cpt_blocksize; static node cpt_Hufftree[512 + SLACK], cpt_LZlength[128 + SLACK], cpt_LZoffs[256 + SLACK]; -static int readcpthdr(); -static int cpt_filehdr(); -static void cpt_folder(); -static void cpt_uncompact(); -static void cpt_wrfile(); -static void cpt_outch(); -static void cpt_rle(); -static void cpt_rle_lzh(); -static void cpt_readHuff(); -static int cpt_get6bits(); -static int cpt_getbit(); +static int readcpthdr(struct cptHdr *s); +static int cpt_filehdr(struct cpt_fileHdr *f, char *hdr); +static void cpt_folder(char *name, struct cpt_fileHdr fileh, char *cptptr); +static void cpt_uncompact(struct cpt_fileHdr filehdr); +static void cpt_wrfile(uint32_t ibytes, uint32_t obytes, int type); +static void cpt_outch(int ch); +static void cpt_rle(void); +static void cpt_rle_lzh(void); +static void cpt_readHuff(int size, struct node *Hufftree); +static int cpt_get6bits(void); +static int cpt_getbit(void); void cpt (void) diff --git a/macunpack/cpt.h b/macunpack/cpt.h index cf53a63..0994eae 100644 --- a/macunpack/cpt.h +++ b/macunpack/cpt.h @@ -1,3 +1,7 @@ +#include "macunpack.h" +#ifdef CPT +#ifdef CPT_INTERNAL + #include #define C_SIGNATURE 0 @@ -93,9 +97,13 @@ typedef struct cpt_fileHdr { /* 78 bytes */ #define CIRCSIZE 8192 +#endif void cpt_wrfile1 (unsigned char *in_char, uint32_t ibytes, uint32_t obytes, int type, uint32_t blocksize); +void cpt (void); + +#endif diff --git a/macunpack/dd.c b/macunpack/dd.c index fb58788..cedc922 100644 --- a/macunpack/dd.c +++ b/macunpack/dd.c @@ -13,34 +13,35 @@ #include "../fileio/fileglob.h" #include "../util/masks.h" #include "../util/util.h" +#include "../util/transname.h" -static void dd_name(); -static int dd_filehdr(); -static void dd_cfilehdr(); -static int dd_valid(); -static int dd_valid1(); -static char *dd_methname(); -static uint32_t dd_checksum(); -static void dd_chksum(); -static uint32_t dd_checkor(); -static void dd_do_delta(); -static void dd_delta(); -static void dd_delta3(); -static void dd_copy(); -static void dd_copyfile(); -static void dd_expand(); -static void dd_expandfile(); -static void dd_nocomp(); -static void dd_lzc(); +static void dd_name(unsigned char *bin_hdr); +static int dd_filehdr(struct dd_fileHdr *f, struct dd_fileCHdr *cf, int skip); +static void dd_cfilehdr(struct dd_fileCHdr *f); +static int dd_valid(int dmethod, int rmethod); +static int dd_valid1(int method); +static char *dd_methname(int n); +static uint32_t dd_checksum(uint32_t init, char *buffer, uint32_t length); +static void dd_chksum(struct dd_fileHdr hdr, unsigned char *data); +static uint32_t dd_checkor(uint32_t init, char *buffer, uint32_t length); +static void dd_do_delta(char *out_ptr, uint32_t nbytes, int kind); +static void dd_delta(char *out_ptr, uint32_t nbytes); +static void dd_delta3(char *out_ptr, uint32_t nbytes); +static void dd_copy(struct dd_fileHdr hdr, unsigned char *data); +static void dd_copyfile(uint32_t obytes, unsigned char *data); +static void dd_expand(struct dd_fileCHdr hdr, unsigned char *data); +static void dd_expandfile(uint32_t obytes, uint32_t ibytes, int method, int kind, unsigned char *data, uint32_t chksum); +static void dd_nocomp(uint32_t obytes, unsigned char *data); +static void dd_lzc(uint32_t ibytes, uint32_t obytes, unsigned char *data, int mb, uint32_t chksum, uint32_t ckinit); #ifdef UNTESTED -static void dd_rle(); +static void dd_rle(uint32_t ibytes, unsigned char *data); #ifdef NOTIMPLEMENTED -static void dd_huffman(); +static void dd_huffman(uint32_t ibytes, unsigned char *data); #endif /* NOTIMPLEMENTED */ -static void dd_lzss(); -static int dd_getbits(); +static void dd_lzss(unsigned char *data, uint32_t chksum); +static int dd_getbits(int n); #endif /* UNTESTED */ -static void dd_cpt_compat(); +static void dd_cpt_compat(uint32_t ibytes, uint32_t obytes, unsigned char *data, int sub_method, uint32_t chksum); typedef struct methodinfo { char *name; diff --git a/macunpack/de_compress.c b/macunpack/de_compress.c index f5129c1..255d23c 100644 --- a/macunpack/de_compress.c +++ b/macunpack/de_compress.c @@ -1,4 +1,7 @@ #include "de_compress.h" + +#include + #include "macunpack.h" #ifdef SIT #define DECOMPRESS @@ -32,7 +35,7 @@ static unsigned short codetab [HSIZE]; static int32_t free_ent = 0; /* first unused entry */ -static int32_t getcode(); +static int32_t getcode(void); static int clear_flg = 0; @@ -121,8 +124,8 @@ static unsigned char rmask[9] = static int get_core_bytes; static char *core_ptr; -static int file_bytes(); -static int core_bytes(); +static int file_bytes(char *buf, int length); +static int core_bytes(char *buf, int length); static int32_t getcode (void) diff --git a/macunpack/de_huffman.c b/macunpack/de_huffman.c index 8f870b1..36d300c 100644 --- a/macunpack/de_huffman.c +++ b/macunpack/de_huffman.c @@ -23,15 +23,15 @@ #include "huffman.h" #include "../util/util.h" -int (*get_bit)(); +int (*get_bit)(void); int bytesread; /* 515 because StuffIt Classic needs more than the needed 511 */ struct node nodelist[515]; -static int getbit_be(); -static int getbit_le(); -static int getdecodebyte(); +static int getbit_be(void); +static int getbit_le(void); +static int getdecodebyte(void); -static node *nodeptr, *read_sub_tree(); +static node *nodeptr, *read_sub_tree(void); static int bit; @@ -72,7 +72,7 @@ read_tree (void) /* This routine recursively reads the Huffman encoding table and builds a decoding tree. */ -static node *read_sub_tree() +static node *read_sub_tree(void) { node *np; diff --git a/macunpack/de_huffman.h b/macunpack/de_huffman.h index 5bc18bc..746b6bc 100644 --- a/macunpack/de_huffman.h +++ b/macunpack/de_huffman.h @@ -1,6 +1,6 @@ #include void set_huffman(int endian); -void read_tree(); +void read_tree(void); void de_huffman(uint32_t 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 5af542d..fec324c 100644 --- a/macunpack/de_lzah.c +++ b/macunpack/de_lzah.c @@ -79,13 +79,13 @@ static short HuffLength[] = { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}; -unsigned char (*lzah_getbyte)(); +unsigned char (*lzah_getbyte)(void); -static void lzah_inithuf(); -static void lzah_reorder(); +static void lzah_inithuf(void); +static void lzah_reorder(void); static void lzah_move(int *p, int *q, int n); -static void lzah_getbit(); -static void lzah_outchar(); +static void lzah_getbit(void); +static void lzah_outchar(int ch); static char lzah_buf[4096]; static int lzah_bufptr; diff --git a/macunpack/de_lzah.h b/macunpack/de_lzah.h index 4f326ad..06606ff 100644 --- a/macunpack/de_lzah.h +++ b/macunpack/de_lzah.h @@ -4,7 +4,7 @@ #include extern void de_lzah(uint32_t obytes); -extern unsigned char (*lzah_getbyte)(); +extern unsigned char (*lzah_getbyte)(void); extern void de_lzh(int32_t ibytes, int32_t obytes, char **data, int bits); #endif diff --git a/macunpack/de_lzh.c b/macunpack/de_lzh.c index 182bafc..9a7d92e 100644 --- a/macunpack/de_lzh.c +++ b/macunpack/de_lzh.c @@ -19,9 +19,9 @@ static int decoded; static int bitsused; static unsigned int blocksize; -static unsigned int decode_c(); -static unsigned int decode_p(); -static void make_table(); +static unsigned int decode_c(void); +static unsigned int decode_p(void); +static void make_table(int nchar, unsigned char bitlen[], int tablebits, unsigned int table[]); /* lzh compression */ void de_lzh(int32_t ibytes, int32_t obytes, char **data, int bits) diff --git a/macunpack/dia.c b/macunpack/dia.c index a3090ee..ba37e5c 100644 --- a/macunpack/dia.c +++ b/macunpack/dia.c @@ -1,11 +1,14 @@ #include "macunpack.h" #ifdef DIA +#define DIA_INTERNAL +#include "dia.h" + #include #include #include "globals.h" -#include "dia.h" #include "../util/curtime.h" #include "../util/masks.h" +#include "../util/transname.h" #include "../fileio/machdr.h" #include "../fileio/wrfile.h" #include "../fileio/kind.h" @@ -26,14 +29,14 @@ static int dia_LZtab[BCHUNKSIZE]; static unsigned char *dia_bit_base; static int dia_imask; -static void dia_folder(); -static void dia_file(); -static void dia_getlength(); -static void dia_skipfork(); -static void dia_getfork(); -static void dia_getblock(); -static int dia_decode(); -static int dia_prevbit(); +static void dia_folder(unsigned char *name); +static void dia_file(int indicator, unsigned char *name); +static void dia_getlength(int nblocks); +static void dia_skipfork(int nblocks); +static void dia_getfork(int nblocks); +static void dia_getblock(unsigned char **archive_ptr, unsigned char **block_ptr); +static int dia_decode(unsigned char *ibuff, unsigned char *obuff, int in_length); +static int dia_prevbit(void); void dia (unsigned char *bin_hdr) diff --git a/macunpack/dia.h b/macunpack/dia.h index 10c73e2..d63930f 100644 --- a/macunpack/dia.h +++ b/macunpack/dia.h @@ -1,3 +1,7 @@ +#include "macunpack.h" +#ifdef DIA +#ifdef DIA_INTERNAL + #define IS_FOLDER 0x80 #define F_INFO 0x40 #define VOLUME 0x30 @@ -20,3 +24,8 @@ #define NOCOMP 1 #define COMP 2 + +#endif +void dia (unsigned char *bin_hdr); + +#endif diff --git a/macunpack/dir.c b/macunpack/dir.c index 1d9ba6b..90f8ad5 100644 --- a/macunpack/dir.c +++ b/macunpack/dir.c @@ -1,9 +1,12 @@ +#include "dir.h" + #include #include "globals.h" #include "../fileio/machdr.h" #include "../fileio/wrfile.h" #include "../util/util.h" #include "../util/masks.h" +#include "../util/transname.h" static char *dir_stack; static int dir_ptr = -64; diff --git a/macunpack/dir.h b/macunpack/dir.h new file mode 100644 index 0000000..3cddc0e --- /dev/null +++ b/macunpack/dir.h @@ -0,0 +1 @@ +void dir (char *hdr); \ No newline at end of file diff --git a/macunpack/globals.h b/macunpack/globals.h index e431048..502d2c2 100644 --- a/macunpack/globals.h +++ b/macunpack/globals.h @@ -1,8 +1,6 @@ #include -extern void exit(); -extern void transname(); -extern void do_error(); +void do_error (char *string); extern char info[]; extern char text[]; diff --git a/macunpack/huffman.h b/macunpack/huffman.h index 30bafe8..7a1f397 100644 --- a/macunpack/huffman.h +++ b/macunpack/huffman.h @@ -6,10 +6,10 @@ typedef struct node { struct node *one, *zero; } node; -extern int (*get_bit)(); -extern void clrhuff(); +extern int (*get_bit)(void); +extern void clrhuff(void); int gethuffbyte(node *l_nodelist); -int getihuffbyte(); +int getihuffbyte(void); extern struct node nodelist[]; extern int bytesread; diff --git a/macunpack/jdw.c b/macunpack/jdw.c index 172502b..5b163a4 100644 --- a/macunpack/jdw.c +++ b/macunpack/jdw.c @@ -1,17 +1,20 @@ #include "macunpack.h" #ifdef JDW +#define JDW_INTERNAL #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/transname.h" #include "../util/masks.h" -static void jdw_wrfile(); -static void jdw_wrfork(); -static void jdw_block(); +static void jdw_wrfile(uint32_t rsrcLength, uint32_t dataLength); +static void jdw_wrfork(uint32_t length); +static void jdw_block(int olength); void jdw (uint32_t ibytes) diff --git a/macunpack/jdw.h b/macunpack/jdw.h index 88411d4..6ac7783 100644 --- a/macunpack/jdw.h +++ b/macunpack/jdw.h @@ -1,3 +1,7 @@ +#include "macunpack.h" +#ifdef JDW +#ifdef JDW_INTERNAL + #include #define J_MAGIC 0 @@ -23,3 +27,6 @@ typedef struct jdw_fileHdr { char fname[32]; /* actually flength */ } jdw_fileHdr; +#endif +void jdw (uint32_t ibytes); +#endif \ No newline at end of file diff --git a/macunpack/lzc.c b/macunpack/lzc.c index c349c99..5095e30 100644 --- a/macunpack/lzc.c +++ b/macunpack/lzc.c @@ -1,18 +1,22 @@ #include "macunpack.h" #ifdef LZC -#include -#include "globals.h" +#define LZC_INTERNAL #include "lzc.h" + +#include +#include +#include "globals.h" #include "../util/util.h" #include "../fileio/machdr.h" #include "../fileio/wrfile.h" #include "../util/masks.h" +#include "../util/transname.h" #include "de_compress.h" #include "mcb.h" -static void lzc_zivm(); -static void lzc_wrfile(); -static void lzc_zivu(); +static void lzc_zivm(char *ohdr); +static void lzc_wrfile(uint32_t obytes, uint32_t ibytes); +static void lzc_zivu(char *ohdr); void lzc (char *ohdr) diff --git a/macunpack/lzc.h b/macunpack/lzc.h index 10f7b96..b3d112a 100644 --- a/macunpack/lzc.h +++ b/macunpack/lzc.h @@ -1,3 +1,7 @@ +#include "macunpack.h" +#ifdef LZC +#ifdef LZC_INTERNAL + #include #define HEADERBYTES 48 @@ -28,3 +32,6 @@ typedef struct lzc_fileHdr { uint32_t flag1; uint32_t flag2; } lzc_fileHdr; +#endif +void lzc (char *ohdr); +#endif diff --git a/macunpack/lzh.c b/macunpack/lzh.c index 26a637f..83a884a 100644 --- a/macunpack/lzh.c +++ b/macunpack/lzh.c @@ -1,4 +1,7 @@ #include "macunpack.h" + +#define LZH_INTERNAL + #include #include #include "globals.h" @@ -7,8 +10,10 @@ #include "../fileio/wrfile.h" #include "../fileio/machdr.h" #include "../util/masks.h" +#include "../util/transname.h" #include "../util/util.h" #include "bits_be.h" +#include "de_lzah.h" #define LZ5LOOKAHEAD 18 /* look ahead buffer size for LArc */ #define LZ5BUFFSIZE 8192 @@ -18,10 +23,6 @@ #define LZSMASK 4095 #define LZBUFFSIZE 8192 /* Max of above buffsizes */ -extern void de_lzah(); -extern unsigned char (*lzah_getbyte)(); -extern void de_lzh(); - typedef struct methodinfo { char *name; int number; @@ -51,26 +52,26 @@ static char *lzh_current; static char *tmp_out_ptr; static char lzh_lzbuf[LZBUFFSIZE]; -static int lzh_filehdr(); -static int lzh_checkm(); -static char *lzh_methname(); -static void lzh_wrfile(); -static void lzh_skip(); -static void lzh_nocomp(); +static int lzh_filehdr(struct lzh_fileHdr *f); +static int lzh_checkm(struct lzh_fileHdr *f); +static char *lzh_methname(int n); +static void lzh_wrfile(struct lzh_fileHdr *filehdr, int method); +static void lzh_skip(struct lzh_fileHdr *filehdr); +static void lzh_nocomp(uint32_t obytes); #ifdef UNTESTED -static void lzh_lzss1(); -static void lzh_lzss2(); +static void lzh_lzss1(uint32_t obytes); +static void lzh_lzss2(uint32_t obytes); #endif /* UNTESTED */ -static void lzh_lzah(); -static unsigned char lzh_getbyte(); +static void lzh_lzah(uint32_t obytes); +static unsigned char lzh_getbyte(void); #ifdef UNDEF -static void lzh_lh2(); -static void lzh_lh3(); +static void lzh_lh2(uint32_t obytes); +static void lzh_lh3(uint32_t obytes); #endif /* UNDEF */ #ifdef UNTESTED -static void lzh_lzh12(); +static void lzh_lzh12(uint32_t obytes); #endif /* UNTESTED */ -static void lzh_lzh13(); +static void lzh_lzh13(uint32_t obytes); void lzh (int kind) diff --git a/macunpack/lzh.h b/macunpack/lzh.h index b572a56..7cbcd95 100644 --- a/macunpack/lzh.h +++ b/macunpack/lzh.h @@ -1,3 +1,7 @@ +#include "macunpack.h" +#ifdef LZH +#ifdef LZH_INTERNAL + #include #define FILEHDRSIZE 22 @@ -59,3 +63,9 @@ typedef struct lzh_fileHdr { /* 58 bytes */ #define lz4 6 #define lz5 7 #define lzs 8 + +#endif + +void lzh (int kind); + +#endif diff --git a/macunpack/macbinary.c b/macunpack/macbinary.c index 08bf6eb..986ee85 100644 --- a/macunpack/macbinary.c +++ b/macunpack/macbinary.c @@ -1,49 +1,38 @@ #include "macunpack.h" +#include "macbinary.h" + +#include #include -#include "globals.h" +#include "../fileio/kind.h" #include "../fileio/machdr.h" #include "../fileio/wrfile.h" -#include "../fileio/kind.h" -#include "zmahdr.h" #include "../util/util.h" -#include "stf.h" -#include "mcb.h" #include "bin.h" #include "dd.h" +#include "dir.h" +#include "globals.h" +#include "mcb.h" #include "sit.h" +#include "stf.h" +#include "zmahdr.h" +#include "jdw.h" +#include "lzc.h" +#include "pit.h" +#include "dia.h" +#include "cpt.h" +#include "zma.h" +#include "lzh.h" -extern void dir(char *hdr); -#ifdef JDW -extern void jdw(); -#endif /* JDW */ -#ifdef LZC -extern void lzc(); -#endif /* LZC */ #ifdef ASQ extern void asq(); #endif /* ASQ */ #ifdef ARC extern void arc(); #endif /* ARC */ -#ifdef PIT -extern void pit(); -#endif /* PIT */ -#ifdef DIA -extern void dia(); -#endif /* DIA */ -#ifdef CPT -extern void cpt(); -#endif /* CPT */ -#ifdef ZMA -extern void zma(); -#endif /* ZMA */ -#ifdef LZH -extern void lzh(); -#endif /* LZH */ -static void skip_file(); +static void skip_file(int skip); #ifdef SCAN -static void get_idf(); +static void get_idf(int kind); #endif /* SCAN */ #define Z (ZMAHDRS2 + 1) diff --git a/macunpack/macbinary.h b/macunpack/macbinary.h new file mode 100644 index 0000000..9d8049e --- /dev/null +++ b/macunpack/macbinary.h @@ -0,0 +1 @@ +void macbinary (void); diff --git a/macunpack/macunpack.c b/macunpack/macunpack.c index 09546e4..7e7a40a 100644 --- a/macunpack/macunpack.c +++ b/macunpack/macunpack.c @@ -1,4 +1,7 @@ #include "macunpack.h" + +#include +#include #include #include "globals.h" #include "../util/patchlevel.h" @@ -6,25 +9,15 @@ #include "../fileio/wrfileopt.h" #include "../fileio/kind.h" #include "../util/util.h" +#include "stf.h" +#include "pit.h" +#include "sit.h" +#include "cpt.h" +#include "macbinary.h" #define LOCALOPT "ilvqVH" -extern char *strcat(); -#ifdef STF -extern void stf(); -#endif /* STF */ -#ifdef PIT -extern void pit(); -#endif /* PIT */ -#ifdef SIT -extern void sit(); -#endif /* SIT */ -#ifdef CPT -extern void cpt(); -#endif /* CPT */ -void macbinary(); - -static void usage(); +static void usage(void); static char options[128]; diff --git a/macunpack/mcb.c b/macunpack/mcb.c index e713106..5d49c87 100644 --- a/macunpack/mcb.c +++ b/macunpack/mcb.c @@ -1,12 +1,17 @@ +#include "mcb.h" + +#include + #include "globals.h" #include "../fileio/machdr.h" #include "../fileio/wrfile.h" #include "../util/masks.h" #include "../util/util.h" +#include "../util/transname.h" static int mcb_read; -static void mcb_wrfile(); +static void mcb_wrfile(uint32_t ibytes); void mcb(char *hdr, uint32_t rsrcLength, uint32_t dataLength, int toread) { diff --git a/macunpack/mcb.h b/macunpack/mcb.h index c356c6a..1fc86e6 100644 --- a/macunpack/mcb.h +++ b/macunpack/mcb.h @@ -1 +1,3 @@ +#include + extern void mcb(char *hdr, uint32_t rsrcLength, uint32_t dataLength, int toread); diff --git a/macunpack/pit.c b/macunpack/pit.c index 17f594d..85dab1d 100644 --- a/macunpack/pit.c +++ b/macunpack/pit.c @@ -1,22 +1,26 @@ #include "macunpack.h" #ifdef PIT +#define PIT_INTERNAL +#include "pit.h" + +#include #include -#include "../fileio/wrfile.h" #include "../fileio/fileglob.h" #include "../fileio/kind.h" -#include "globals.h" -#include "pit.h" #include "../fileio/machdr.h" -#include "crc.h" +#include "../fileio/wrfile.h" #include "../util/masks.h" +#include "../util/transname.h" #include "../util/util.h" -#include "huffman.h" +#include "crc.h" #include "de_huffman.h" +#include "globals.h" +#include "huffman.h" -static int pit_filehdr(); -static void pit_wrfile(); -static void pit_nocomp(); -static void pit_huffman(); +static int pit_filehdr(struct pit_header *f, int compr); +static void pit_wrfile(uint32_t bytes, int type); +static void pit_nocomp(uint32_t ibytes); +static void pit_huffman(uint32_t obytes); void pit (void) diff --git a/macunpack/pit.h b/macunpack/pit.h index 0292b59..cdf0958 100644 --- a/macunpack/pit.h +++ b/macunpack/pit.h @@ -1,3 +1,9 @@ +#include "macunpack.h" +#ifdef PIT +#ifdef PIT_INTERNAL + +#include + #define H_NAMELEN 63 #define H_NLENOFF 0 @@ -30,3 +36,8 @@ struct pit_header { /* Packit file header (92 bytes) */ #define nocomp 0 #define huffman 1 +#endif + +void pit (void); + +#endif diff --git a/macunpack/sit.c b/macunpack/sit.c index 2d8ea66..ad5f61e 100644 --- a/macunpack/sit.c +++ b/macunpack/sit.c @@ -4,6 +4,7 @@ #ifdef SIT #include +#include #include "globals.h" #include "crc.h" #include "../util/util.h" @@ -11,6 +12,7 @@ #include "../fileio/wrfile.h" #include "../fileio/kind.h" #include "../util/masks.h" +#include "../util/transname.h" #include "huffman.h" #include "de_compress.h" #include "de_huffman.h" @@ -33,26 +35,26 @@ static struct methodinfo methods[] = { }; static int sit_nodeptr; -static int readsithdr(); -static int sit_filehdr(); -static int sit_valid(); -static int sit_checkm(); -static char *sit_methname(); -static void sit_folder(); -static void sit_unstuff(); -static void sit_wrfile(); -static void sit_skip(); -static void sit_nocomp(); -static void sit_rle(); -static void sit_lzc(); -static void sit_huffman(); -static void sit_lzah(); -static unsigned char sit_getbyte(); -static void sit_fixhuf(); -static void sit_dosplit(); -static void sit_mw(); -static void sit_mw_out(); -static int sit_mw_in(); +static int readsithdr(sitHdr *s); +static int sit_filehdr(struct sit_fileHdr *f, int skip); +static int sit_valid(struct sit_fileHdr f); +static int sit_checkm(int f); +static char *sit_methname(int n); +static void sit_folder(char *name); +static void sit_unstuff(struct sit_fileHdr filehdr); +static void sit_wrfile(uint32_t ibytes, uint32_t obytes, int type); +static void sit_skip(uint32_t ibytes); +static void sit_nocomp(uint32_t ibytes); +static void sit_rle(uint32_t ibytes); +static void sit_lzc(uint32_t ibytes); +static void sit_huffman(uint32_t obytes); +static void sit_lzah(uint32_t obytes); +static unsigned char sit_getbyte(void); +static void sit_fixhuf(uint32_t ibytes); +static void sit_dosplit(int ptr, int sum, int low, int upp); +static void sit_mw(uint32_t ibytes); +static void sit_mw_out(int ptr); +static int sit_mw_in(int bits, uint32_t *ibytes); static short code6[258] = { 1024, 512, 256, 256, 256, 256, 128, 128, diff --git a/macunpack/stf.c b/macunpack/stf.c index c9f12a9..973e13e 100644 --- a/macunpack/stf.c +++ b/macunpack/stf.c @@ -1,16 +1,16 @@ #include "macunpack.h" #ifdef STF #include +#include #include "stf.h" #include "globals.h" #include "huffman.h" #include "../util/curtime.h" #include "../fileio/wrfile.h" #include "../fileio/machdr.h" +#include "../util/transname.h" #include "../util/util.h" - -extern void de_huffman(); -extern void set_huffman(); +#include "de_huffman.h" typedef struct{ int num; @@ -20,9 +20,9 @@ typedef struct{ static table_struct table[511]; static char length[256]; -static void stf_wrfile(); -static void stf_wrfork(); -static void stf_construct(); +static void stf_wrfile(uint32_t rsrcLength, uint32_t dataLength, uint32_t ibytes); +static void stf_wrfork(uint32_t *num, uint32_t towrite, int offs); +static void stf_construct(int n); void stf (uint32_t ibytes) diff --git a/macunpack/zma.c b/macunpack/zma.c index dbf5b62..82bb91a 100644 --- a/macunpack/zma.c +++ b/macunpack/zma.c @@ -1,17 +1,20 @@ #include "macunpack.h" #ifdef ZMA +#define ZMA_INTERNAL +#include "zma.h" + #include #include #include "globals.h" -#include "zma.h" + #include "crc.h" #include "../fileio/machdr.h" #include "../fileio/wrfile.h" #include "../fileio/kind.h" #include "../util/masks.h" +#include "../util/transname.h" #include "../util/util.h" - -extern void de_lzh(); +#include "de_lzah.h" /* We do allow for possible backpointing, so we allocate the archive in core */ static char *zma_archive; @@ -20,12 +23,12 @@ static char *zma_filestart; static uint32_t zma_length; static int32_t zma_archlength; -static int zma_filehdr(); -static void zma_folder(); -static void zma_mooz(); -static void zma_wrfile(); -static void zma_nocomp(); -static void zma_lzh(); +static int zma_filehdr(struct zma_fileHdr *f, int skip); +static void zma_folder(struct zma_fileHdr fhdr); +static void zma_mooz(struct zma_fileHdr filehdr); +static void zma_wrfile(uint32_t ibytes, uint32_t obytes, int type); +static void zma_nocomp(uint32_t ibytes); +static void zma_lzh(uint32_t ibytes); void zma (char *start, uint32_t length) diff --git a/macunpack/zma.h b/macunpack/zma.h index 02e23da..759291d 100644 --- a/macunpack/zma.h +++ b/macunpack/zma.h @@ -1,3 +1,7 @@ +#include "macunpack.h" +#ifdef ZMA +#ifdef ZMA_INTERNAL + #include "zmahdr.h" #include @@ -53,3 +57,8 @@ typedef struct zma_fileHdr { /* 78 bytes */ #define z_dir 3 /* directory */ #define z_plug 4 /* for plug in, not supported */ +#endif + +void zma (char *start, uint32_t length); + +#endif diff --git a/mixed/dir.c b/mixed/dir.c index 276fb34..dfa7206 100644 --- a/mixed/dir.c +++ b/mixed/dir.c @@ -1,8 +1,11 @@ +#include "dir.h" + #include #include "globals.h" #include "../fileio/machdr.h" #include "../fileio/wrfile.h" #include "../util/util.h" +#include "../util/transname.h" #include "../util/masks.h" static char *dir_stack; diff --git a/mixed/dir.h b/mixed/dir.h new file mode 100644 index 0000000..ea9aa45 --- /dev/null +++ b/mixed/dir.h @@ -0,0 +1 @@ +void dir(char *hdr); diff --git a/mixed/globals.h b/mixed/globals.h index 6c058e8..71cb2e6 100644 --- a/mixed/globals.h +++ b/mixed/globals.h @@ -1,8 +1,5 @@ #include -extern void exit(); -extern void transname(); - extern char info[]; extern char text[]; diff --git a/mixed/macbinary.c b/mixed/macbinary.c index 12e5f7e..5e2de54 100644 --- a/mixed/macbinary.c +++ b/mixed/macbinary.c @@ -1,15 +1,19 @@ +#include "macbinary.h" + #include "globals.h" + +#include + #include "../fileio/machdr.h" #include "../fileio/kind.h" #include "../util/util.h" +#include "dir.h" +#include "mcb.h" -extern void dir(); -extern void mcb(); -extern void do_indent(); -static void skip_file(); +static void skip_file(int skip); #ifdef SCAN -static void get_idf(); +static void get_idf(int kind); #endif /* SCAN */ void diff --git a/mixed/macbinary.h b/mixed/macbinary.h new file mode 100644 index 0000000..11e3148 --- /dev/null +++ b/mixed/macbinary.h @@ -0,0 +1 @@ +void macbinary (void); \ No newline at end of file diff --git a/mixed/macsave.c b/mixed/macsave.c index effecd0..85c929a 100644 --- a/mixed/macsave.c +++ b/mixed/macsave.c @@ -1,16 +1,17 @@ #include #include +#include + #include "globals.h" #include "../util/patchlevel.h" #include "../fileio/wrfile.h" #include "../fileio/wrfileopt.h" #include "../util/util.h" +#include "macbinary.h" #define LOCALOPT "ilqVH" -void macbinary(); - -static void usage(); +static void usage(void); static char options[128]; diff --git a/mixed/macstream.c b/mixed/macstream.c index 344d35e..22837c6 100644 --- a/mixed/macstream.c +++ b/mixed/macstream.c @@ -9,11 +9,9 @@ #include "../util/transname.h" #include "../util/util.h" -extern void do_indent(); - #define LOCALOPT "ilqVH" -static void usage(); +static void usage(void); static char options[128]; static char *dir_stack; diff --git a/mixed/mcb.c b/mixed/mcb.c index 016a1f4..3712057 100644 --- a/mixed/mcb.c +++ b/mixed/mcb.c @@ -1,12 +1,17 @@ +#include "mcb.h" + +#include + #include "globals.h" #include "../fileio/machdr.h" #include "../fileio/wrfile.h" #include "../util/masks.h" #include "../util/util.h" +#include "../util/transname.h" static int mcb_read; -static void mcb_wrfile(); +static void mcb_wrfile(uint32_t ibytes); void mcb (char *hdr, uint32_t rsrcLength, uint32_t dataLength, int toread) diff --git a/mixed/mcb.h b/mixed/mcb.h new file mode 100644 index 0000000..7eb528e --- /dev/null +++ b/mixed/mcb.h @@ -0,0 +1,3 @@ +#include + +void mcb (char *hdr, uint32_t rsrcLength, uint32_t dataLength, int toread); \ No newline at end of file diff --git a/util/curtime.h b/util/curtime.h index f3533ca..095e14e 100644 --- a/util/curtime.h +++ b/util/curtime.h @@ -4,7 +4,6 @@ #ifdef BSD #include -extern time_t time(); #else /* BSD */ #include #endif /* BSD */ diff --git a/util/util.h b/util/util.h index 4dbbec9..69a7fb5 100644 --- a/util/util.h +++ b/util/util.h @@ -1,4 +1,5 @@ #include +#include typedef struct real_time { int year; From d4ec9442631a3bd2f82a6b8ae91bd0b09b6379c1 Mon Sep 17 00:00:00 2001 From: Arvid Norlander Date: Thu, 29 Sep 2022 23:17:22 +0200 Subject: [PATCH 12/12] Build system: Replace make files with meson --- .gitignore | 10 +- binhex/makefile | 51 ---------- comm/makefile | 90 ------------------ crc/makefile | 27 ------ fileio/makefile | 33 ------- hexbin/makefile | 130 ------------------------- macunpack/makefile | 230 --------------------------------------------- makefile | 78 --------------- meson.build | 87 +++++++++++++++++ mixed/makefile | 91 ------------------ util/makefile | 22 ----- 11 files changed, 88 insertions(+), 761 deletions(-) delete mode 100644 binhex/makefile delete mode 100644 comm/makefile delete mode 100644 crc/makefile delete mode 100644 fileio/makefile delete mode 100644 hexbin/makefile delete mode 100644 macunpack/makefile delete mode 100644 makefile create mode 100644 meson.build delete mode 100644 mixed/makefile delete mode 100644 util/makefile diff --git a/.gitignore b/.gitignore index 5d37d28..f0fdcee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,3 @@ .vscode *.o -all -binhex/binhex -comm/frommac -comm/tomac -frommac/frommac -hexbin/hexbin -macunpack/macunpack -mixed/macsave -mixed/macstream \ No newline at end of file +/builddir diff --git a/binhex/makefile b/binhex/makefile deleted file mode 100644 index 899c79e..0000000 --- a/binhex/makefile +++ /dev/null @@ -1,51 +0,0 @@ -CFLAGS = -O $(CF) - -SRCS = binhex.c dofile.c - -OBJS = binhex.o dofile.o - -LIB = ../crc/libcrc.a -TNAME = ../util/transname -BNAME = ../util/backtrans -UNAME = ../util/util -INAME = ../fileio/rdfile -GNAME = ../fileio/fileglob -XOBJS = $(TNAME).o $(BNAME).o $(UNAME).o $(INAME).o $(GNAME).o -XSRCS = $(TNAME).c $(BNAME).c $(UNAME).c $(INAME).c $(GNAME).c - -binhex: $(OBJS) $(XOBJS) $(LIB) - $(CC) $(CFLAGS) -o binhex $(OBJS) $(XOBJS) $(LIB) - -$(LIB): ../crc/makecrc.c - (cd ../crc; make CC=$(CC) CF="$(CF)" ) - -$(TNAME).o: $(TNAME).c - (cd ../util; make CC=$(CC) CF="$(CF)" ) - -$(BNAME).o: $(BNAME).c - (cd ../util; make CC=$(CC) CF="$(CF)" ) - -$(UNAME).o: $(UNAME).c - (cd ../util; make CC=$(CC) CF="$(CF)" ) - -$(INAME).o: $(INAME).c - (cd ../fileio; make CC=$(CC) CF="$(CF)" ) - -$(GNAME).o: $(GNAME).c - (cd ../fileio; make CC=$(CC) CF="$(CF)" ) - -lint: - lint $(CF) $(LFLAGS) $(SRCS) $(XSRCS) - -clean: - rm -f *.o - -clobber:clean - rm -f binhex - -binhex.o: ../fileio/machdr.h -binhex.o: ../fileio/rdfile.h -binhex.o: ../util/patchlevel.h -dofile.o: ../fileio/machdr.h -dofile.o: ../fileio/rdfile.h - diff --git a/comm/makefile b/comm/makefile deleted file mode 100644 index 7028d95..0000000 --- a/comm/makefile +++ /dev/null @@ -1,90 +0,0 @@ -CFLAGS = -O $(CF) - -SRCS1 = tomac.c xm_to.c ym_to.c zm_to.c tty.c globals.c -SRCS2 = frommac.c xm_from.c ym_from.c zm_from.c tty.c globals.c - -OBJS1 = tomac.o xm_to.o ym_to.o zm_to.o tty.o globals.o -OBJS2 = frommac.o xm_from.o ym_from.o zm_from.o tty.o globals.o - -LIB = ../crc/libcrc.a -TNAME = ../util/transname -BNAME = ../util/backtrans -UNAME = ../util/util -INAME = ../fileio/rdfile -ONAME = ../fileio/wrfile -GNAME = ../fileio/fileglob -XOBJS1 = $(TNAME).o $(BNAME).o $(UNAME).o $(INAME).o $(GNAME).o -XOBJS2 = $(TNAME).o $(UNAME).o $(ONAME).o $(GNAME).o -XSRCS1 = $(TNAME).c $(BNAME).c $(UNAME).c $(INAME).c $(GNAME).c -XSRCS2 = $(TNAME).c $(UNAME).c $(ONAME).c $(GNAME).c - -all: tomac frommac - touch all - -tomac: $(OBJS1) $(XOBJS1) - $(CC) $(CFLAGS) -o tomac $(OBJS1) $(XOBJS1) - -frommac: $(OBJS2) $(XOBJS2) - $(CC) $(CFLAGS) -o frommac $(OBJS2) $(XOBJS2) - -$(LIB): ../crc/makecrc.c - (cd ../crc; make CC=$(CC) CF="$(CF)" ) - -$(TNAME).o: $(TNAME).c - (cd ../util; make CC=$(CC) CF="$(CF)" ) - -$(BNAME).o: $(BNAME).c - (cd ../util; make CC=$(CC) CF="$(CF)" ) - -$(UNAME).o: $(UNAME).c - (cd ../util; make CC=$(CC) CF="$(CF)" ) - -$(INAME).o: $(INAME).c - (cd ../fileio; make CC=$(CC) CF="$(CF)" ) - -$(ONAME).o: $(ONAME).c - (cd ../fileio; make CC=$(CC) CF="$(CF)" ) - -$(GNAME).o: $(GNAME).c - (cd ../fileio; make CC=$(CC) CF="$(CF)" ) - -lint: - lint $(CF) $(LFLAGS) $(SRCS1) $(XSRCS) - -clean: - rm -f *.o - -clobber:clean - rm -f all tomac frommac - -tomac.o: comm.h -tomac.o: ../fileio/machdr.h -tomac.o: ../fileio/rdfile.h -tomac.o: ../util/patchlevel.h -tomac.o: globals.h -xm_to.o: comm.h -xm_to.o: ../fileio/machdr.h -xm_to.o: ../fileio/rdfile.h -xm_to.o: ../util/masks.h -xm_to.o: globals.h -xm_to.o: protocol.h -ym_to.o: comm.h -zm_to.o: comm.h -frommac.o: comm.h -frommac.o: ../util/patchlevel.h -frommac.o: ../fileio/machdr.h -frommac.o: globals.h -frommac.o: ../fileio/fileglob.h -frommac.o: ../fileio/wrfile.h -xm_from.o: comm.h -xm_from.o: ../fileio/machdr.h -xm_from.o: ../fileio/wrfile.h -xm_from.o: ../util/masks.h -xm_from.o: globals.h -xm_from.o: protocol.h -ym_from.o: comm.h -zm_from.o: comm.h -globals.o: globals.h -tty.o: ../util/masks.h -tty.o: protocol.h -tty.o: globals.h diff --git a/crc/makefile b/crc/makefile deleted file mode 100644 index f8f4c4a..0000000 --- a/crc/makefile +++ /dev/null @@ -1,27 +0,0 @@ -CFLAGS = -O $(CF) -CRCC = arc.c ccitt.c kermit.c binhex.c ccitt32.c zip.c -CRCO = arc.o ccitt.o kermit.o binhex.o ccitt32.o zip.o - -libcrc.a: $(CRCO) - ar r libcrc.a $(CRCO) - if test -f /usr/bin/ranlib ;\ - then \ - ranlib libcrc.a ;\ - fi - -clean: - rm -f $(CRCC) $(CRCO) libcrc.a makecrc makecrc.o - -$(CRCC): makecrc - ./makecrc - -makecrc: makecrc.o - cc $(CFLAGS) -O -o makecrc makecrc.o - -arc.o: arc.c -ccitt.o: ccitt.c -kermit.o: kermit.c -binhex.o: binhex.c -ccitt32.o: ccitt32.c -zip.o: zip.c - diff --git a/fileio/makefile b/fileio/makefile deleted file mode 100644 index 3b12545..0000000 --- a/fileio/makefile +++ /dev/null @@ -1,33 +0,0 @@ -CFLAGS= -O $(CF) - -all: wrfile.o rdfile.o fileglob.o - touch all - -wrfile.o: wrfile.c - -rdfile.o: rdfile.c - -clean: - rm -f wrfile.o - rm -f rdfile.o - rm -f fileglob.o - rm -f all - -wrfile.o: machdr.h -wrfile.o: wrfile.h -wrfile.o: wrfileopt.h -wrfile.o: fileglob.h -wrfile.o: aufs.h -wrfile.o: appledouble.h -wrfile.o: ../util/util.h -wrfile.o: ../util/curtime.h -rdfile.o: machdr.h -rdfile.o: rdfile.h -rdfile.o: rdfileopt.h -rdfile.o: ../util/util.h -rdfile.o: ../util/curtime.h -rdfile.o: ../util/masks.h -rdfile.o: aufs.h -rdfile.o: appledouble.h -fileglob.o: fileglob.h - diff --git a/hexbin/makefile b/hexbin/makefile deleted file mode 100644 index 4e319bb..0000000 --- a/hexbin/makefile +++ /dev/null @@ -1,130 +0,0 @@ -CFLAGS= -O $(CF) - -SRCS = hexbin.c \ - dl.c \ - hecx.c \ - hqx.c \ - mu.c \ - buffer.c \ - crc.c \ - readline.c \ - printhdr.c \ - globals.c - -OBJS = hexbin.o \ - dl.o \ - hecx.o \ - hqx.o \ - mu.o \ - buffer.o \ - crc.o \ - readline.o \ - printhdr.o \ - globals.o - -LIB = ../crc/libcrc.a -TNAME = ../util/transname -BNAME = ../util/backtrans -UNAME = ../util/util -ONAME = ../fileio/wrfile -GNAME = ../fileio/fileglob -XOBJS = $(TNAME).o $(BNAME).o $(UNAME).o $(ONAME).o $(GNAME).o -XSRCS = $(TNAME).c $(BNAME).c $(UNAME).c $(ONAME).c $(GNAME).c -CRCS = ../crc/binhex.c - -hexbin: $(OBJS) $(LIB) $(XOBJS) - $(CC) $(CFLAGS) -o hexbin $(OBJS) $(XOBJS) $(LIB) - -$(LIB): ../crc/makecrc.c - (cd ../crc; make CC=$(CC) CF="$(CF)" ) - -$(TNAME).o: $(TNAME).c - (cd ../util; make CC=$(CC) CF="$(CF)" ) - -$(BNAME).o: $(BNAME).c - (cd ../util; make CC=$(CC) CF="$(CF)" ) - -$(UNAME).o: $(UNAME).c - (cd ../util; make CC=$(CC) CF="$(CF)" ) - -$(ONAME).o: $(ONAME).c - (cd ../fileio; make CC=$(CC) CF="$(CF)" ) - -$(GNAME).o: $(GNAME).c - (cd ../fileio; make CC=$(CC) CF="$(CF)" ) - -lint: - lint $(CF) $(LFLAGS) $(SRCS) $(XSRCS) $(CRCS) - -clean: - rm -f *.o - -clobber:clean - rm -f hexbin - -hexbin.o: globals.h -hexbin.o: crc.h -hexbin.o: readline.h -hexbin.o: ../util/masks.h -hexbin.o: ../util/util.h -hexbin.o: ../util/patchlevel.h -hexbin.o: ../fileio/wrfile.h -hexbin.o: ../fileio/wrfileopt.h -hexbin.o: ../fileio/machdr.h -hexbin.o: ../fileio/kind.h -hexbin.o: ../util/curtime.h -hexbin.o: hexbin.h -dl.o: hexbin.h -dl.o: globals.h -dl.o: crc.h -dl.o: readline.h -dl.o: ../fileio/machdr.h -dl.o: ../fileio/wrfile.h -dl.o: ../util/util.h -dl.o: buffer.h -dl.o: printhdr.h -hecx.o: hexbin.h -hecx.o: globals.h -hecx.o: crc.h -hecx.o: readline.h -hecx.o: ../util/masks.h -hecx.o: ../util/util.h -hecx.o: ../fileio/machdr.h -hecx.o: ../fileio/wrfile.h -hecx.o: buffer.h -hecx.o: printhdr.h -hqx.o: hexbin.h -hqx.o: globals.h -hqx.o: readline.h -hqx.o: crc.h -hqx.o: buffer.h -hqx.o: ../fileio/machdr.h -hqx.o: ../fileio/wrfile.h -hqx.o: ../util/util.h -hqx.o: printhdr.h -mu.o: hexbin.h -mu.o: globals.h -mu.o: readline.h -mu.o: ../util/masks.h -mu.o: ../util/util.h -mu.o: ../fileio/machdr.h -mu.o: ../fileio/wrfile.h -mu.o: buffer.h -mu.o: printhdr.h -buffer.o: globals.h -buffer.o: ../util/util.h -buffer.o: buffer.h -buffer.o: ../fileio/wrfile.h -crc.o: hexbin.h -crc.o: crc.h -crc.o: ../util/masks.h -crc.o: globals.h -readline.o: readline.h -readline.o: globals.h -printhdr.o: printhdr.h -printhdr.o: globals.h -globals.o: globals.h -globals.o: ../fileio/machdr.h -globals.o: ../fileio/wrfile.h -globals.o: ../fileio/kind.h - diff --git a/macunpack/makefile b/macunpack/makefile deleted file mode 100644 index fe07910..0000000 --- a/macunpack/makefile +++ /dev/null @@ -1,230 +0,0 @@ -CFLAGS = -O $(CF) - -SRCS = macunpack.c \ - globals.c \ - macbinary.c \ - dir.c \ - mcb.c \ - bin.c \ - jdw.c \ - stf.c \ - lzc.c \ - pit.c \ - sit.c \ - dia.c \ - cpt.c \ - zma.c \ - lzh.c \ - dd.c \ - de_huffman.c \ - de_compress.c \ - de_lzah.c \ - de_lzh.c \ - crc.c \ - bits_be.c - -OBJS = macunpack.o \ - globals.o \ - macbinary.o \ - dir.o \ - mcb.o \ - bin.o \ - jdw.o \ - stf.o \ - lzc.o \ - pit.o \ - sit.o \ - dia.o \ - cpt.o \ - zma.o \ - lzh.o \ - dd.o \ - de_huffman.o \ - de_compress.o \ - de_lzah.o \ - de_lzh.o \ - crc.o \ - bits_be.o - -LIB = ../crc/libcrc.a -TNAME = ../util/transname -UNAME = ../util/util -ONAME = ../fileio/wrfile -GNAME = ../fileio/fileglob -XOBJS = $(TNAME).o $(UNAME).o $(ONAME).o $(GNAME).o -XSRCS = $(TNAME).c $(UNAME).c $(ONAME).c $(GNAME).c -CRCS = ../crc/arc.c ../crc/binhex.c ../crc/zip.c - -macunpack: $(OBJS) $(LIB) $(XOBJS) - $(CC) $(CFLAGS) -o macunpack $(OBJS) $(XOBJS) $(LIB) - -$(LIB): ../crc/makecrc.c - (cd ../crc; make CC=$(CC) CF="$(CF)" ) - -$(TNAME).o: $(TNAME).c - (cd ../util; make CC=$(CC) CF="$(CF)" ) - -$(UNAME).o: $(UNAME).c - (cd ../util; make CC=$(CC) CF="$(CF)" ) - -$(ONAME).o: $(ONAME).c - (cd ../fileio; make CC=$(CC) CF="$(CF)" ) - -$(GNAME).o: $(GNAME).c - (cd ../fileio; make CC=$(CC) CF="$(CF)" ) - -lint: - lint $(CF) $(LFLAGS) $(SRCS) $(XSRCS) $(CRCS) - -clean: - rm -f *.o - -clobber:clean - rm -f macunpack - -macunpack.o: macunpack.h -macunpack.o: globals.h -macunpack.o: ../util/patchlevel.h -macunpack.o: ../fileio/wrfile.h -macunpack.o: ../fileio/wrfileopt.h -macunpack.o: ../fileio/kind.h -macunpack.o: ../util/util.h -globals.o: globals.h -globals.o: ../fileio/machdr.h -globals.o: ../fileio/wrfile.h -globals.o: ../fileio/kind.h -macbinary.o: macunpack.h -macbinary.o: globals.h -macbinary.o: zmahdr.h -macbinary.o: ../fileio/machdr.h -macbinary.o: ../fileio/wrfile.h -macbinary.o: ../fileio/kind.h -macbinary.o: ../util/util.h -dir.o: globals.h -dir.o: ../fileio/machdr.h -dir.o: ../fileio/wrfile.h -dir.o: ../util/util.h -dir.o: ../util/masks.h -mcb.o: globals.h -mcb.o: ../fileio/machdr.h -mcb.o: ../fileio/wrfile.h -mcb.o: ../util/masks.h -mcb.o: ../util/util.h -bin.o: macunpack.h -bin.o: globals.h -bin.o: ../fileio/machdr.h -bin.o: ../fileio/wrfile.h -bin.o: ../fileio/kind.h -bin.o: ../util/util.h -bin.o: ../util/masks.h -jdw.o: macunpack.h -jdw.o: jdw.h -jdw.o: globals.h -jdw.o: huffman.h -jdw.o: ../fileio/wrfile.h -jdw.o: ../fileio/machdr.h -jdw.o: ../util/util.h -jdw.o: ../util/masks.h -stf.o: macunpack.h -stf.o: stf.h -stf.o: globals.h -stf.o: huffman.h -stf.o: ../util/curtime.h -stf.o: ../fileio/wrfile.h -stf.o: ../fileio/machdr.h -stf.o: ../util/util.h -lzc.o: macunpack.h -lzc.o: globals.h -lzc.o: lzc.h -lzc.o: ../util/util.h -lzc.o: ../fileio/machdr.h -lzc.o: ../fileio/wrfile.h -lzc.o: ../util/masks.h -pit.o: macunpack.h -pit.o: ../fileio/fileglob.h -pit.o: ../fileio/wrfile.h -pit.o: ../fileio/kind.h -pit.o: globals.h -pit.o: pit.h -pit.o: ../fileio/machdr.h -pit.o: crc.h -pit.o: ../util/masks.h -pit.o: ../util/util.h -pit.o: huffman.h -sit.o: macunpack.h -sit.o: globals.h -sit.o: sit.h -sit.o: crc.h -sit.o: ../util/util.h -sit.o: ../fileio/machdr.h -sit.o: ../fileio/wrfile.h -sit.o: ../fileio/kind.h -sit.o: ../util/masks.h -sit.o: huffman.h -dia.o: macunpack.h -dia.o: globals.h -dia.o: dia.h -dia.o: ../util/curtime.h -dia.o: ../util/masks.h -dia.o: ../fileio/machdr.h -dia.o: ../fileio/wrfile.h -dia.o: ../fileio/kind.h -dia.o: ../util/util.h -cpt.o: macunpack.h -cpt.o: globals.h -cpt.o: cpt.h -cpt.o: crc.h -cpt.o: ../util/util.h -cpt.o: ../fileio/machdr.h -cpt.o: ../fileio/wrfile.h -cpt.o: ../fileio/kind.h -cpt.o: ../util/masks.h -cpt.o: huffman.h -zma.o: macunpack.h -zma.o: globals.h -zma.o: zma.h -zma.o: crc.h -zma.o: ../fileio/machdr.h -zma.o: ../fileio/wrfile.h -zma.o: ../fileio/kind.h -zma.o: ../util/masks.h -zma.o: ../util/util.h -lzh.o: macunpack.h -lzh.o: globals.h -lzh.o: lzh.h -lzh.o: crc.h -lzh.o: ../fileio/wrfile.h -lzh.o: ../fileio/machdr.h -lzh.o: ../util/masks.h -lzh.o: ../util/util.h -lzh.o: bits_be.h -dd.o: macunpack.h -dd.o: globals.h -dd.o: dd.h -dd.o: crc.h -dd.o: ../fileio/machdr.h -dd.o: ../fileio/wrfile.h -dd.o: ../fileio/fileglob.h -dd.o: ../util/masks.h -dd.o: ../util/util.h -de_huffman.o: macunpack.h -de_huffman.o: globals.h -de_huffman.o: ../util/masks.h -de_huffman.o: huffman.h -de_huffman.o: ../fileio/wrfile.h -de_huffman.o: ../util/util.h -de_compress.o: macunpack.h -de_compress.o: globals.h -de_compress.o: ../fileio/wrfile.h -de_lzah.o: macunpack.h -de_lzah.o: globals.h -de_lzah.o: ../util/masks.h -de_lzah.o: ../fileio/wrfile.h -de_lzh.o: macunpack.h -de_lzh.o: globals.h -de_lzh.o: ../util/masks.h -de_lzh.o: ../fileio/wrfile.h -de_lzh.o: bits_be.h -bits_be.o: ../util/masks.h -bits_be.o: bits_be.h - diff --git a/makefile b/makefile deleted file mode 100644 index 2931527..0000000 --- a/makefile +++ /dev/null @@ -1,78 +0,0 @@ -BINDIR ?= bin -# Use the following flags on the CF macro definition as needed. -# -# -DBSD if you are on a BSD system -# -# -DTYPES_H if your system has /usr/include/sys/types.h -# -# -DDIRENT_H if your system has /usr/include/dirent.h -# -# -DTERMIOS_H if your system has /usr/include/sys/termios.h -# -# -DNODOT if you do not want to create files with an initial period -# -# -DLATIN1 if your system supports LATIN-1 and you want to use it -# -# Note you can use at most one of the following four! -# -# -DNOMKDIR if your system does not have the mkdir system call -# -# -DAUFS if you want to use an AUFS file system -# -# -DAUFSPLUS if you use CAP 6.0 and want to use times on files -# -# -DAPPLEDOUBLE if you want to be able to use an AppleDouble file system -# -CF ?= -DBSD -DTYPES_H -DDIRENT_H -DTERMIOS_H -DNODOT -DAPPLEDOUBLE - -all: - (cd crc; $(MAKE) CF='$(CF)') - (cd util; $(MAKE) CF='$(CF)') - (cd fileio; $(MAKE) CF='$(CF)') - (cd macunpack; $(MAKE) CF='$(CF)') - (cd hexbin; $(MAKE) CF='$(CF)') - (cd mixed; $(MAKE) CF='$(CF)') - (cd binhex; $(MAKE) CF='$(CF)') - (cd comm; $(MAKE) CF='$(CF)') - -clean: - (cd crc; $(MAKE) clean) - (cd util; $(MAKE) clean) - (cd fileio; $(MAKE) clean) - (cd macunpack; $(MAKE) clean) - (cd hexbin; $(MAKE) clean) - (cd mixed; $(MAKE) clean) - (cd binhex; $(MAKE) clean) - (cd comm; $(MAKE) clean) - -clobber: - (cd crc; $(MAKE) clean) - (cd util; $(MAKE) clean) - (cd fileio; $(MAKE) clean) - (cd macunpack; $(MAKE) clobber) - (cd hexbin; $(MAKE) clobber) - (cd mixed; $(MAKE) clobber) - (cd binhex; $(MAKE) clobber) - (cd comm; $(MAKE) clobber) - -lint: - (cd macunpack; $(MAKE) CF='$(CF)' lint) - (cd hexbin; $(MAKE) CF='$(CF)' lint) - (cd mixed; $(MAKE) CF='$(CF)' lint) - (cd binhex; $(MAKE) CF='$(CF)' lint) - (cd comm; $(MAKE) CF='$(CF)' lint) - -install: - mkdir -p "$(BINDIR)" - install macunpack/macunpack "$(BINDIR)/." - install hexbin/hexbin "$(BINDIR)/." - install mixed/macsave "$(BINDIR)/." - install mixed/macstream "$(BINDIR)/." - install binhex/binhex "$(BINDIR)/." - install comm/tomac "$(BINDIR)/." - install comm/frommac "$(BINDIR)/." - -distr: - shar -a README makefile crc util fileio macunpack hexbin mixed binhex \ - comm doc man >macutil.shar - diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..51223ce --- /dev/null +++ b/meson.build @@ -0,0 +1,87 @@ +project('macutils', 'c') +# Use the following flags on the CF macro definition as needed. +# +# -DBSD if you are on a BSD system +# +# -DTYPES_H if your system has /usr/include/sys/types.h +# +# -DDIRENT_H if your system has /usr/include/dirent.h +# +# -DTERMIOS_H if your system has /usr/include/sys/termios.h +# +# -DNODOT if you do not want to create files with an initial period +# +# -DLATIN1 if your system supports LATIN-1 and you want to use it +# +# Note you can use at most one of the following four! +# +# -DNOMKDIR if your system does not have the mkdir system call +# +# -DAUFS if you want to use an AUFS file system +# +# -DAUFSPLUS if you use CAP 6.0 and want to use times on files +# +# -DAPPLEDOUBLE if you want to be able to use an AppleDouble file system +# +add_global_arguments([ + '-DNODOT', + '-DAPPLEDOUBLE'], + language: 'c') +add_global_arguments(['-Wall'], language: 'c') + +compiler = meson.get_compiler('c') + +if compiler.has_header('sys/types.h') + add_global_arguments('-DTYPES_H', language: 'c') +endif +if compiler.has_header('dirent.h') + add_global_arguments('-DDIRENT_H', language: 'c') +endif +if compiler.has_header('sys/termios.h') + add_global_arguments('-DTERMIOS_H', language: 'c') +endif + + +# Static libraries + +src_libutil = ['util/backtrans.c', 'util/transname.c', 'util/util.c'] +src_libfileio = ['fileio/fileglob.c', 'fileio/rdfile.c', 'fileio/wrfile.c'] + +libutil = static_library('util', src_libutil) +libfileio = static_library('fileio', src_libfileio) + +# CRC +makecrc = executable('makecrc', 'crc/makecrc.c', install: false) +crc_generated = ['arc.c', 'ccitt.c', 'kermit.c', 'binhex.c', 'ccitt32.c', 'zip.c'] + +gen_crc = custom_target('gen-crc', + output: crc_generated, + command: [makecrc]) + +libcrc = static_library('crc', gen_crc, include_directories: 'crc') + + +# Executables +binhex = ['binhex/binhex.c', 'binhex/dofile.c'] +hexbin = ['hexbin/buffer.c', 'hexbin/crc.c', 'hexbin/dl.c', 'hexbin/globals.c', 'hexbin/hecx.c', 'hexbin/hexbin.c', 'hexbin/hqx.c', 'hexbin/mu.c', 'hexbin/printhdr.c', 'hexbin/readline.c'] +macunpack = ['macunpack/bin.c', 'macunpack/bits_be.c', 'macunpack/cpt.c', 'macunpack/crc.c', 'macunpack/dd.c', 'macunpack/de_compress.c', 'macunpack/de_huffman.c', 'macunpack/de_lzah.c', 'macunpack/de_lzh.c', 'macunpack/dia.c', 'macunpack/dir.c', 'macunpack/globals.c', 'macunpack/jdw.c', 'macunpack/lzc.c', 'macunpack/lzh.c', 'macunpack/macbinary.c', 'macunpack/macunpack.c', 'macunpack/mcb.c', 'macunpack/pit.c', 'macunpack/sit.c', 'macunpack/stf.c', 'macunpack/zma.c'] +mixed_macsave = ['mixed/dir.c', 'mixed/globals.c', 'mixed/globals.h', 'mixed/macbinary.c', 'mixed/macsave.c', 'mixed/mcb.c'] +mixed_macstream = ['mixed/macstream.c'] + +executable('binhex', binhex, link_with: [libcrc, libutil, libfileio], install: true) +executable('hexbin', hexbin, link_with: [libcrc, libutil, libfileio], install: true) +executable('macunpack', macunpack, link_with: [libcrc, libutil, libfileio], install: true) +executable('macsave', mixed_macsave, link_with: [libutil, libfileio], install: true) +executable('macstream', mixed_macstream, link_with: [libutil, libfileio], install: true) + +src_libcomm = ['comm/globals.c', 'comm/tty.c'] +libcomm = static_library('comm', src_libcomm) +comm_frommac = ['comm/frommac.c', 'comm/xm_from.c', 'comm/ym_from.c', 'comm/zm_from.c'] +comm_tomac = ['comm/tomac.c', 'comm/xm_to.c', 'comm/ym_to.c', 'comm/zm_to.c'] +executable('frommac', comm_frommac, link_with: [libcomm, libcrc, libutil, libfileio], install: true) +executable('tomac', comm_tomac, link_with: [libcomm, libcrc, libutil, libfileio], install: true) + +# Install + +man_pages = ['man/binhex.1','man/frommac.1','man/hexbin.1','man/macsave.1','man/macstream.1','man/macunpack.1','man/macutil.1','man/tomac.1'] +install_man(man_pages) diff --git a/mixed/makefile b/mixed/makefile deleted file mode 100644 index f228c04..0000000 --- a/mixed/makefile +++ /dev/null @@ -1,91 +0,0 @@ -CFLAGS = -O $(CF) - -SRCS1 = macsave.c \ - globals.c \ - macbinary.c \ - dir.c \ - mcb.c - -SRCS2 = macstream.c - -OBJS1 = macsave.o \ - globals.o \ - macbinary.o \ - dir.o \ - mcb.o - -OBJS2 = macstream.o - -TNAME = ../util/transname -BNAME = ../util/backtrans -UNAME = ../util/util -ONAME = ../fileio/wrfile -INAME = ../fileio/rdfile -GNAME = ../fileio/fileglob -XOBJS1= $(TNAME).o $(UNAME).o $(ONAME).o $(GNAME).o -XSRCS1= $(TNAME).c $(UNAME).c $(ONAME).c $(GNAME).c -XOBJS2= $(TNAME).o $(BNAME).o $(UNAME).o $(INAME).o $(GNAME).o -XSRCS2= $(TNAME).c $(BNAME).c $(UNAME).c $(INAME).c $(GNAME).c - -all: macsave macstream - touch all - -macsave: $(OBJS1) $(XOBJS1) - $(CC) $(CFLAGS) -o macsave $(OBJS1) $(XOBJS1) - -macstream: $(OBJS2) $(XOBJS2) - $(CC) $(CFLAGS) -o macstream $(OBJS2) $(XOBJS2) - -$(TNAME).o: $(TNAME).c - (cd ../util; make CC=$(CC) CF="$(CF)" ) - -$(BNAME).o: $(BNAME).c - (cd ../util; make CC=$(CC) CF="$(CF)" ) - -$(UNAME).o: $(UNAME).c - (cd ../util; make CC=$(CC) CF="$(CF)" ) - -$(ONAME).o: $(ONAME).c - (cd ../fileio; make CC=$(CC) CF="$(CF)" ) - -$(INAME).o: $(INAME).c - (cd ../fileio; make CC=$(CC) CF="$(CF)" ) - -$(GNAME).o: $(GNAME).c - (cd ../fileio; make CC=$(CC) CF="$(CF)" ) - -lint: - lint $(CF) $(LFLAGS) $(SRCS1) $(XSRCS1) - lint $(CF) $(LFLAGS) $(SRCS2) $(XSRCS2) - -clean: - rm -f *.o - -clobber:clean - rm -f all macsave macstream - -macsave.o: globals.h -macsave.o: ../util/patchlevel.h -macsave.o: ../fileio/wrfile.h -macsave.o: ../fileio/wrfileopt.h -macsave.o: ../util/util.h -globals.o: globals.h -globals.o: ../fileio/machdr.h -macbinary.o: globals.h -macbinary.o: ../fileio/machdr.h -macbinary.o: ../fileio/kind.h -macbinary.o: ../util/util.h -dir.o: globals.h -dir.o: ../fileio/machdr.h -dir.o: ../fileio/wrfile.h -dir.o: ../util/util.h -dir.o: ../util/masks.h -mcb.o: globals.h -mcb.o: ../fileio/machdr.h -mcb.o: ../fileio/wrfile.h -mcb.o: ../util/masks.h -mcb.o: ../util/util.h -macstream.o: ../fileio/machdr.h -macstream.o: ../fileio/rdfile.h -macstream.o: ../fileio/rdfileopt.h -macstream.o: ../util/patchlevel.h diff --git a/util/makefile b/util/makefile deleted file mode 100644 index 92647f5..0000000 --- a/util/makefile +++ /dev/null @@ -1,22 +0,0 @@ -CFLAGS= -O $(CF) - -all: util.o transname.o backtrans.o - touch all - -util.o: util.c - -transname.o: transname.c - -backtrans.o: backtrans.c - -clean: - -rm -f util.o - -rm -f transname.o - -rm -f backtrans.o - -rm -f all - -util.o: ../fileio/fileglob.h -util.o: masks.h -util.o: util.h -backtrans.o: masks.h -