Merge pull request #1 from VorpalBlade/fixes

Fixes for 64-bit, compiler warnings, code modernisation and new build system
This commit is contained in:
Will Nayes 2022-10-01 20:56:37 -05:00 committed by GitHub
commit fdced4c716
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
108 changed files with 1585 additions and 2074 deletions

5
.gitignore vendored
View File

@ -1,4 +1,3 @@
.vscode
*.o *.o
all /builddir
macunpack/macunpack

View File

@ -7,14 +7,12 @@
#include "../fileio/rdfileopt.h" #include "../fileio/rdfileopt.h"
#include "../util/patchlevel.h" #include "../util/patchlevel.h"
#include "../util/util.h" #include "../util/util.h"
#include "../util/transname.h"
extern void transname(); #include "dofile.h"
extern void do_indent();
extern void dofile();
#define LOCALOPT "RilqVH" #define LOCALOPT "RilqVH"
static void usage(); static void usage(void);
static char options[128]; static char options[128];
static char *dir_stack; static char *dir_stack;
@ -25,8 +23,6 @@ int dorep = 1;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int c, i, j, n; int c, i, j, n;
extern int optind;
extern char *optarg;
int errflg; int errflg;
char text[32], ftype[5], fauth[5]; char text[32], ftype[5], fauth[5];
int dir_skip = 0, write_it, query = 0, list = 0, info_only = 0; int dir_skip = 0, write_it, query = 0, list = 0, info_only = 0;
@ -107,8 +103,8 @@ int main(int argc, char **argv)
if(i == ISFILE) { if(i == ISFILE) {
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (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)data_size, (long)rsrc_size); text, ftype, fauth, (int32_t)data_size, (int32_t)rsrc_size);
} else if(i == ISDIR) { } else if(i == ISDIR) {
do_indent(indent); do_indent(indent);
dir_ptr += 64; dir_ptr += 64;
@ -165,7 +161,8 @@ int main(int argc, char **argv)
/* NOTREACHED */ /* NOTREACHED */
} }
static void usage() static void
usage (void)
{ {
(void)fprintf(stderr, "Usage: binhex [-%s] [files]\n", options); (void)fprintf(stderr, "Usage: binhex [-%s] [files]\n", options);
(void)fprintf(stderr, "Use \"binhex -H\" for help.\n"); (void)fprintf(stderr, "Use \"binhex -H\" for help.\n");

View File

@ -1,10 +1,10 @@
#include "dofile.h"
#include <stdio.h> #include <stdio.h>
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../fileio/rdfile.h" #include "../fileio/rdfile.h"
#include "../crc/crc.h"
extern int dorep; extern int dorep;
extern unsigned long binhex_crcinit;
extern unsigned long binhex_updcrc();
#define RUNCHAR 0x90 #define RUNCHAR 0x90
@ -16,15 +16,16 @@ static int savebits;
static int rep_char; static int rep_char;
static int rep_count; static int rep_count;
void doheader(); static void doheader();
void dofork(); static void dofork(char *fork, int size);
void outbyte(); static void outbyte(int b);
void finish(); static void finish(void);
void outbyte1(); static void outbyte1(int b);
void out6bit(); static void out6bit(int c);
void outchar(); static void outchar(int c);
void dofile() void
dofile (void)
{ {
(void)printf("(This file must be converted; you knew that already.)\n"); (void)printf("(This file must be converted; you knew that already.)\n");
(void)printf("\n"); (void)printf("\n");
@ -41,37 +42,38 @@ void dofile()
(void)putchar('\n'); (void)putchar('\n');
} }
void doheader() static void
doheader (void)
{ {
unsigned long crc; uint32_t crc;
int i, n; int i, n;
crc = binhex_crcinit; crc = binhex_crcinit;
n = file_info[I_NAMEOFF]; 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++) { for(i = 0; i <= n; i++) {
outbyte(file_info[I_NAMEOFF + i]); outbyte(file_info[I_NAMEOFF + i]);
} }
n = 0; n = 0;
crc = binhex_updcrc(crc, (char *)&n, 1); crc = binhex_updcrc(crc, (unsigned char *)&n, 1);
outbyte(0); 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++) { for(i = 0; i < 4; i++) {
outbyte(file_info[I_TYPEOFF + 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++) { for(i = 0; i < 4; i++) {
outbyte(file_info[I_AUTHOFF + 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++) { for(i = 0; i < 2; i++) {
outbyte(file_info[I_FLAGOFF + 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++) { for(i = 0; i < 4; i++) {
outbyte(file_info[I_DLENOFF + 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++) { for(i = 0; i < 4; i++) {
outbyte(file_info[I_RLENOFF + i]); outbyte(file_info[I_RLENOFF + i]);
} }
@ -79,14 +81,13 @@ int i, n;
outbyte((int)(crc & 0xff)); outbyte((int)(crc & 0xff));
} }
void dofork(fork, size) void
char *fork; dofork (char *fork, int size)
int size;
{ {
unsigned long crc; uint32_t crc;
int i; int i;
crc = binhex_updcrc(binhex_crcinit, fork, size); crc = binhex_updcrc(binhex_crcinit, (unsigned char*)fork, size);
for(i = 0; i < size; i++) { for(i = 0; i < size; i++) {
outbyte(fork[i]); outbyte(fork[i]);
} }
@ -94,8 +95,8 @@ int i;
outbyte((int)(crc & 0xff)); outbyte((int)(crc & 0xff));
} }
void outbyte(b) static void
int b; outbyte (int b)
{ {
b &= 0xff; b &= 0xff;
if(dorep && (b == rep_char)) { if(dorep && (b == rep_char)) {
@ -127,7 +128,8 @@ int b;
} }
} }
void finish() static void
finish (void)
{ {
if(rep_count > 0) { if(rep_count > 0) {
if(rep_count > 3) { if(rep_count > 3) {
@ -151,8 +153,8 @@ void finish()
} }
} }
void outbyte1(b) static void
int b; outbyte1 (int b)
{ {
switch(state) { switch(state) {
case 0: case 0:
@ -175,14 +177,14 @@ int b;
} }
} }
void out6bit(c) static void
char c; out6bit (int c)
{ {
outchar(codes[c & 0x3f]); outchar(codes[c & 0x3f]);
} }
void outchar(c) static void
char c; outchar (int c)
{ {
(void)putchar(c); (void)putchar(c);
if(++pos_ptr > 64) { if(++pos_ptr > 64) {

1
binhex/dofile.h Normal file
View File

@ -0,0 +1 @@
void dofile (void);

View File

@ -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

View File

@ -8,6 +8,7 @@
#include "../util/util.h" #include "../util/util.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "globals.h" #include "globals.h"
#include "tty.h"
#include "../fileio/fileglob.h" #include "../fileio/fileglob.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "../fileio/wrfileopt.h" #include "../fileio/wrfileopt.h"
@ -17,12 +18,9 @@
#define LOCALOPT "lmxyzoTVH" #define LOCALOPT "lmxyzoTVH"
extern void setup_tty();
extern void reset_tty();
extern char info[]; extern char info[];
static void usage(); static void usage(void);
static char options[128]; static char options[128];
static int multi_file = 0; static int multi_file = 0;
@ -30,8 +28,6 @@ static int listmode = 0;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
extern int optind;
extern char *optarg;
int errflg; int errflg;
int c; int c;
char tname[64]; char tname[64];
@ -155,7 +151,7 @@ int main(int argc, char **argv)
transname(info + I_AUTHOFF, fauth, 4); transname(info + I_AUTHOFF, fauth, 4);
transname(info + I_TYPEOFF, ftype, 4); transname(info + I_TYPEOFF, ftype, 4);
(void)fprintf(stderr, (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, tname, ftype, fauth,
get4(info + I_DLENOFF), get4(info + I_RLENOFF)); get4(info + I_DLENOFF), get4(info + I_RLENOFF));
(void)fprintf(stderr, "\n"); (void)fprintf(stderr, "\n");
@ -165,7 +161,8 @@ int main(int argc, char **argv)
/* NOTREACHED */ /* NOTREACHED */
} }
static void usage() static void
usage (void)
{ {
(void)fprintf(stderr, "Usage: frommac [-%s]\n", options); (void)fprintf(stderr, "Usage: frommac [-%s]\n", options);
(void)fprintf(stderr, "Use \"frommac -H\" for help.\n"); (void)fprintf(stderr, "Use \"frommac -H\" for help.\n");

View File

@ -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

View File

@ -8,20 +8,16 @@
#include "../fileio/rdfileopt.h" #include "../fileio/rdfileopt.h"
#include "../util/patchlevel.h" #include "../util/patchlevel.h"
#include "../util/util.h" #include "../util/util.h"
#include "../util/transname.h"
#include "globals.h" #include "globals.h"
#include "tty.h"
#ifdef XM #ifdef XM
#include "xm_to.h" #include "xm_to.h"
#endif /* XM */ #endif /* XM */
extern void transname();
extern void do_indent();
extern void dofile();
extern void setup_tty();
extern void reset_tty();
#define LOCALOPT "ilqxyzoTVH" #define LOCALOPT "ilqxyzoTVH"
static void usage(); static void usage(void);
static char options[128]; static char options[128];
static char *dir_stack; static char *dir_stack;
@ -31,8 +27,6 @@ static int dir_max;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int c, i, j, n; int c, i, j, n;
extern int optind;
extern char *optarg;
int errflg; int errflg;
char text[32], ftype[5], fauth[5]; char text[32], ftype[5], fauth[5];
int dir_skip = 0, write_it, query = 0, list = 0, info_only = 0; int dir_skip = 0, write_it, query = 0, list = 0, info_only = 0;
@ -160,8 +154,8 @@ int main(int argc, char **argv)
if(i == ISFILE) { if(i == ISFILE) {
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (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)data_size, (long)rsrc_size); text, ftype, fauth, (int32_t)data_size, (int32_t)rsrc_size);
} else if(i == ISDIR) { } else if(i == ISDIR) {
do_indent(indent); do_indent(indent);
dir_ptr += 64; dir_ptr += 64;
@ -236,7 +230,8 @@ int main(int argc, char **argv)
/* NOTREACHED */ /* NOTREACHED */
} }
static void usage() static void
usage (void)
{ {
(void)fprintf(stderr, "Usage: tomac [-%s] [files]\n", options); (void)fprintf(stderr, "Usage: tomac [-%s] [files]\n", options);
(void)fprintf(stderr, "Use \"tomac -H\" for help.\n"); (void)fprintf(stderr, "Use \"tomac -H\" for help.\n");

View File

@ -1,3 +1,4 @@
#include "tty.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <signal.h>
@ -12,10 +13,7 @@
#include "protocol.h" #include "protocol.h"
#include "globals.h" #include "globals.h"
void cleanup(); void timedout(int);
void timedout();
int tgetc();
void tputc();
static jmp_buf timobuf; static jmp_buf timobuf;
@ -27,7 +25,8 @@ static struct termios otty, ntty;
static int ttyfd; static int ttyfd;
static int signal_set; static int signal_set;
void setup_tty() void
setup_tty (void)
{ {
ttyfd = fileno(stderr); ttyfd = fileno(stderr);
if(!signal_set) { if(!signal_set) {
@ -58,7 +57,8 @@ void setup_tty()
#endif /* TERMIOS_H */ #endif /* TERMIOS_H */
} }
void reset_tty() void
reset_tty (void)
{ {
(void)sleep(1); /* Wait for output to drain */ (void)sleep(1); /* Wait for output to drain */
#ifndef TERMIOS_H #ifndef TERMIOS_H
@ -74,14 +74,15 @@ void cleanup(int sig)
exit(sig); exit(sig);
} }
void timedout() void
timedout (int)
{ {
(void)signal(SIGALRM, timedout); (void)signal(SIGALRM, timedout);
longjmp(timobuf, 1); longjmp(timobuf, 1);
} }
int tgetc(timeout) int
int timeout; tgetc (int timeout)
{ {
char c; char c;
int i; int i;
@ -136,9 +137,8 @@ void tputc(int c)
(void)write(ttyfd, &cc, 1); (void)write(ttyfd, &cc, 1);
} }
void tputrec(buf, count) void
char *buf; tputrec (char *buf, int count)
int count;
{ {
(void)write(ttyfd, buf, count); (void)write(ttyfd, buf, count);
} }

View File

@ -1 +1,7 @@
void cleanup(int sig); 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);

View File

@ -10,19 +10,16 @@
#include "protocol.h" #include "protocol.h"
#include "tty.h" #include "tty.h"
extern int tgetc(); static void receive_part(char *info, int size, int more);
extern int tgetrec(); static int receive_sync(void);
extern void tputc(); static int receive_rec(char *buf, int bufsize, int recno);
static void receive_part();
static int receive_sync();
static int receive_rec();
char info[INFOBYTES]; char info[INFOBYTES];
void xm_from() void
xm_from (void)
{ {
unsigned long data_size, rsrc_size; uint32_t data_size, rsrc_size;
char text[64]; char text[64];
if(receive_sync() == ACK) { if(receive_sync() == ACK) {
@ -40,11 +37,10 @@ char text[64];
} }
} }
static void receive_part(info, size, more) static void
char *info; receive_part (char *info, int size, int more)
int size, more;
{ {
int recno = 1, i, status, naks = 0; int recno = 1, status, naks = 0;
status = 0; status = 0;
while(status != EOT) { 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; int c;
@ -109,9 +106,8 @@ int c;
return ACK; return ACK;
} }
static int receive_rec(buf, bufsize, recno) static int
char *buf; receive_rec (char *buf, int bufsize, int recno)
int bufsize, recno;
{ {
int i, cksum, c, rec, recbar; int i, cksum, c, rec, recbar;
char *bp; char *bp;

View File

@ -1 +1 @@
void xm_from(); void xm_from(void);

View File

@ -7,15 +7,12 @@
#include "protocol.h" #include "protocol.h"
#include "tty.h" #include "tty.h"
extern int tgetc(); static void send_part(char *info, int size, int more);
extern void tputc(); static int send_sync(void);
extern void tputrec(); static void send_rec(char *buf, int bufsize, int recno);
static void send_part(); void
static int send_sync(); xm_to (void)
static void send_rec();
void xm_to()
{ {
if(send_sync() == ACK) { if(send_sync() == ACK) {
send_part(file_info, DATABYTES, 1); send_part(file_info, DATABYTES, 1);
@ -24,9 +21,8 @@ void xm_to()
} }
} }
static void send_part(info, size, more) static void
char *info; send_part (char *info, int size, int more)
int size, more;
{ {
int recno = 1, i, status; 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; int c, i;
@ -75,9 +72,8 @@ int c, i;
return CAN; return CAN;
} }
static void send_rec(buf, bufsize, recno) static void
char *buf; send_rec (char *buf, int bufsize, int recno)
int bufsize, recno;
{ {
int i, cksum; int i, cksum;
char *bp; char *bp;

View File

@ -1 +1 @@
void xm_to(); void xm_to(void);

8
crc/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
arc.c
binhex.c
ccitt.c
ccitt32.c
kermit.c
libcrc.a
makecrc
zip.c

14
crc/crc.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef CRC_CRC_H
#define CRC_CRC_H
#include <stdint.h>
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

View File

@ -31,12 +31,14 @@
/* ZIP used by COMPACTOR */ /* ZIP used by COMPACTOR */
#include <stdio.h> #include <stdio.h>
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
static void initcrctab(); static void initcrctab(char *name, int poly, int init, int swapped, int bits);
int main() int
main (void)
{ {
initcrctab("ccitt", 0x1021, 0xffff, 0, 16); initcrctab("ccitt", 0x1021, 0xffff, 0, 16);
initcrctab("kermit", 0x8408, 0, 1, 16); initcrctab("kermit", 0x8408, 0, 1, 16);
@ -47,13 +49,12 @@ int main()
exit(0); exit(0);
} }
static void initcrctab(name, poly, init, swapped, bits) static void
char *name; initcrctab (char *name, int poly, int init, int swapped, int bits)
int poly, init, swapped, bits;
{ {
register int b, i; register int b, i;
unsigned short v; unsigned short v;
unsigned long vv; uint32_t vv;
FILE *fd; FILE *fd;
char buf[20]; char buf[20];
@ -64,12 +65,13 @@ int poly, init, swapped, bits;
(void)fprintf(stderr, "Cannot open %s for writing\n", buf); (void)fprintf(stderr, "Cannot open %s for writing\n", buf);
exit(1); 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"); (void)fprintf(fd, "\n");
if(bits == 16) { if(bits == 16) {
(void)fprintf(fd, "static unsigned short crctab[256] = {\n"); (void)fprintf(fd, "static uint16_t crctab[256] = {\n");
} else { } else {
(void)fprintf(fd, "static unsigned long crctab[256] = {\n"); (void)fprintf(fd, "static uint32_t crctab[256] = {\n");
} }
(void)fprintf(fd, " "); (void)fprintf(fd, " ");
if(bits == 16) { if(bits == 16) {
@ -109,10 +111,7 @@ int poly, init, swapped, bits;
} }
(void)fprintf(fd, "};\n"); (void)fprintf(fd, "};\n");
(void)fprintf(fd, "\n"); (void)fprintf(fd, "\n");
(void)fprintf(fd, "unsigned long %s_updcrc(icrc, icp, icnt)\n", name); (void)fprintf(fd, "uint32_t %s_updcrc(uint32_t icrc, unsigned char *icp, int32_t 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, "{\n"); (void)fprintf(fd, "{\n");
if(bits == 16) { if(bits == 16) {
(void)fprintf(fd, "#define M1 0xff\n"); (void)fprintf(fd, "#define M1 0xff\n");
@ -121,9 +120,9 @@ int poly, init, swapped, bits;
(void)fprintf(fd, "#define M1 0xffffff\n"); (void)fprintf(fd, "#define M1 0xffffff\n");
(void)fprintf(fd, "#define M2 0xffffff00\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 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, "\n");
(void)fprintf(fd, " while(cnt--) {\n"); (void)fprintf(fd, " while(cnt--) {\n");
if(bits == 16) { if(bits == 16) {

View File

@ -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 -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

View File

@ -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

View File

@ -1,3 +1,5 @@
#include "rdfile.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -7,7 +9,6 @@
#endif /* TYPES_H */ #endif /* TYPES_H */
#include <sys/stat.h> #include <sys/stat.h>
#include "machdr.h" #include "machdr.h"
#include "rdfile.h"
#include "rdfileopt.h" #include "rdfileopt.h"
#ifndef DIRENT_H #ifndef DIRENT_H
#include <sys/dir.h> #include <sys/dir.h>
@ -46,11 +47,11 @@
#define RSRC_FORMAT 2 #define RSRC_FORMAT 2
#define UNIX_FORMAT 3 #define UNIX_FORMAT 3
static void check_files(); static void check_files(int initial);
static void read_file(); static void read_file(void);
static void enter_dir(); static void enter_dir(void);
static void exit_dir(); static void exit_dir(void);
static int get_stdin_file(); static int get_stdin_file(void);
char file_info[INFOBYTES]; char file_info[INFOBYTES];
char *data_fork, *rsrc_fork; char *data_fork, *rsrc_fork;
@ -81,20 +82,19 @@ static char f_name[] = ".foldername";
#include "aufs.h" #include "aufs.h"
static char infodir[] = ".finderinfo"; static char infodir[] = ".finderinfo";
static char rsrcdir[] = ".resource"; static char rsrcdir[] = ".resource";
static void read_aufs_info(); static void read_aufs_info(FILE *fd);
#endif /* AUFS */ #endif /* AUFS */
#ifdef APPLEDOUBLE #ifdef APPLEDOUBLE
#include "appledouble.h" #include "appledouble.h"
static char infodir[] = ".AppleDouble"; static char infodir[] = ".AppleDouble";
static void read_appledouble_info(); static void read_appledouble_info(FILE *fd);
#endif /* APPLEDOUBLE */ #endif /* APPLEDOUBLE */
#endif /* APPLESHARE */ #endif /* APPLESHARE */
static char filename[255]; static char filename[255];
static int filekind; static int filekind;
void setup(argc, argv) void
int argc; setup (int argc, char **argv)
char **argv;
{ {
if(argc == 0) { if(argc == 0) {
read_stdin = 1; read_stdin = 1;
@ -109,8 +109,8 @@ char **argv;
} }
} }
static void check_files(initial) static void
int initial; check_files (int initial)
{ {
struct stat stbuf; struct stat stbuf;
int i, j, n; int i, j, n;
@ -292,7 +292,8 @@ int initial;
} }
} }
int nextfile() int
nextfile (void)
{ {
int i; int i;
@ -337,7 +338,8 @@ again:
} }
} }
static void read_file() static void
read_file (void)
{ {
FILE *fd; FILE *fd;
int c, j, lname, skip; int c, j, lname, skip;
@ -357,8 +359,8 @@ static void read_file()
} }
(void)strcpy(file_info + I_NAMEOFF + 1, filename); (void)strcpy(file_info + I_NAMEOFF + 1, filename);
file_info[I_NAMEOFF] = strlen(filename); file_info[I_NAMEOFF] = strlen(filename);
put4(file_info + I_CTIMOFF, (unsigned long)stbuf.st_ctime + TIMEDIFF); put4(file_info + I_CTIMOFF, (uint32_t)stbuf.st_ctime + TIMEDIFF);
put4(file_info + I_MTIMOFF, (unsigned long)stbuf.st_mtime + TIMEDIFF); put4(file_info + I_MTIMOFF, (uint32_t)stbuf.st_mtime + TIMEDIFF);
if(data_only == RSRC_FORMAT) { if(data_only == RSRC_FORMAT) {
rsrc_size = stbuf.st_size; rsrc_size = stbuf.st_size;
data_size = 0; data_size = 0;
@ -380,7 +382,7 @@ static void read_file()
} else { } else {
(void)strncpy(file_info + I_AUTHOFF, f_auth, 4); (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) { if((fd = fopen(filename, "r")) == NULL) {
(void)fprintf(stderr, "Cannot open file %s\n", filename); (void)fprintf(stderr, "Cannot open file %s\n", filename);
exit(1); exit(1);
@ -411,7 +413,7 @@ static void read_file()
} else { } else {
(void)strncpy(file_info + I_AUTHOFF, f_auth, 4); (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) { if((fd = fopen(filename, "r")) == NULL) {
(void)fprintf(stderr, "Cannot open file %s\n", filename); (void)fprintf(stderr, "Cannot open file %s\n", filename);
exit(1); exit(1);
@ -554,7 +556,7 @@ static void read_file()
(void)strcat(filename1, filename); (void)strcat(filename1, filename);
if(stat(filename1, &stbuf) >= 0) { if(stat(filename1, &stbuf) >= 0) {
rsrc_size = stbuf.st_size; 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 > 0) {
if(rsrc_size > max_rsrc_size) { if(rsrc_size > max_rsrc_size) {
if(rsrc_fork == NULL) { if(rsrc_fork == NULL) {
@ -577,7 +579,7 @@ static void read_file()
} }
if(stat(filename, &stbuf) >= 0) { if(stat(filename, &stbuf) >= 0) {
data_size = stbuf.st_size; 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 > 0) {
if(data_size > max_data_size) { if(data_size > max_data_size) {
if(data_fork == NULL) { if(data_fork == NULL) {
@ -625,7 +627,7 @@ static void read_file()
(void)fclose(fd); (void)fclose(fd);
if(stat(filename, &stbuf) >= 0) { if(stat(filename, &stbuf) >= 0) {
data_size = stbuf.st_size; 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 > 0) {
if(data_size > max_data_size) { if(data_size > max_data_size) {
if(data_fork == NULL) { if(data_fork == NULL) {
@ -652,7 +654,8 @@ static void read_file()
} }
} }
static void enter_dir() static void
enter_dir (void)
{ {
DIR *directory; DIR *directory;
struct dirstruct *curentry; struct dirstruct *curentry;
@ -746,7 +749,8 @@ static void enter_dir()
check_files(0); check_files(0);
} }
static void exit_dir() static void
exit_dir (void)
{ {
filelist *old_files; filelist *old_files;
int i; int i;
@ -767,8 +771,8 @@ static void exit_dir()
#ifdef APPLESHARE #ifdef APPLESHARE
#ifdef AUFS #ifdef AUFS
static void read_aufs_info(fd) static void
FILE *fd; read_aufs_info (FILE *fd)
{ {
FileInfo theinfo; FileInfo theinfo;
int i, n; int i, n;
@ -813,15 +817,15 @@ FILE *fd;
} else { } else {
if(fstat(fileno(fd), &stbuf) >= 0) { if(fstat(fileno(fd), &stbuf) >= 0) {
put4(file_info + I_CTIMOFF, put4(file_info + I_CTIMOFF,
(unsigned long)stbuf.st_ctime + TIMEDIFF); (uint32_t)stbuf.st_ctime + TIMEDIFF);
put4(file_info + I_MTIMOFF, put4(file_info + I_MTIMOFF,
(unsigned long)stbuf.st_mtime + TIMEDIFF); (uint32_t)stbuf.st_mtime + TIMEDIFF);
} }
} }
#else /* AUFSPLUS */ #else /* AUFSPLUS */
if(fstat(fileno(fd), &stbuf) >= 0) { if(fstat(fileno(fd), &stbuf) >= 0) {
put4(file_info + I_CTIMOFF, (unsigned long)stbuf.st_ctime + TIMEDIFF); put4(file_info + I_CTIMOFF, (uint32_t)stbuf.st_ctime + TIMEDIFF);
put4(file_info + I_MTIMOFF, (unsigned long)stbuf.st_mtime + TIMEDIFF); put4(file_info + I_MTIMOFF, (uint32_t)stbuf.st_mtime + TIMEDIFF);
} }
#endif /* AUFSPLUS */ #endif /* AUFSPLUS */
} }
@ -832,8 +836,8 @@ FILE *fd;
size and format. I have not yet seen something that will lead me to size and format. I have not yet seen something that will lead me to
believe different. believe different.
*/ */
static void read_appledouble_info(fd) static void
FILE *fd; read_appledouble_info (FILE *fd)
{ {
FileInfo theinfo; FileInfo theinfo;
int i, n; int i, n;
@ -861,12 +865,13 @@ FILE *fd;
put4(file_info + I_CTIMOFF, get4(theinfo.fi_ctime) + TIMEDIFF); put4(file_info + I_CTIMOFF, get4(theinfo.fi_ctime) + TIMEDIFF);
put4(file_info + I_MTIMOFF, get4(theinfo.fi_mtime) + TIMEDIFF); put4(file_info + I_MTIMOFF, get4(theinfo.fi_mtime) + TIMEDIFF);
rsrc_size = get4(theinfo.fi_rsrc); 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 /* APPLEDOUBLE */
#endif /* APPLESHARE */ #endif /* APPLESHARE */
static int get_stdin_file() static int
get_stdin_file (void)
{ {
int i, skip; int i, skip;
@ -934,10 +939,9 @@ static int get_stdin_file()
return ISFILE; return ISFILE;
} }
int rdfileopt(c) int
char c; rdfileopt (int c)
{ {
extern char *optarg;
char name[32]; char name[32];
switch(c) { switch(c) {
@ -965,7 +969,8 @@ char name[32];
return 1; return 1;
} }
void give_rdfileopt() void
give_rdfileopt (void)
{ {
(void)fprintf(stderr, "File input options:\n"); (void)fprintf(stderr, "File input options:\n");
(void)fprintf(stderr, "-r:\tread as resource files\n"); (void)fprintf(stderr, "-r:\tread as resource files\n");
@ -979,19 +984,22 @@ void give_rdfileopt()
"-t ty:\tfiletype if one of the above options is used\n"); "-t ty:\tfiletype if one of the above options is used\n");
} }
void set_norecurse() void
set_norecurse (void)
{ {
no_recurse = 1; no_recurse = 1;
} }
char *get_rdfileopt() char *
get_rdfileopt (void)
{ {
static char options[] = "rduUc:t:"; static char options[] = "rduUc:t:";
return options; return options;
} }
char *get_minb() char *
get_minb (void)
{ {
#ifdef APPLESHARE #ifdef APPLESHARE
#ifdef AUFS #ifdef AUFS

View File

@ -1,3 +1,5 @@
#include "machdr.h"
#define ISATEND 0 #define ISATEND 0
#define ISFILE 1 #define ISFILE 1
#define ISDIR 2 #define ISDIR 2
@ -7,6 +9,6 @@ extern char file_info[INFOBYTES];
extern char *data_fork, *rsrc_fork; extern char *data_fork, *rsrc_fork;
extern int data_size, rsrc_size; extern int data_size, rsrc_size;
extern void setup(); extern void setup(int argc, char **argv);
extern int nextfile(); extern int nextfile(void);
extern char *get_minb(); extern char *get_minb(void);

View File

@ -1,5 +1,5 @@
extern int rdfileopt(); extern int rdfileopt(int c);
extern void give_rdfileopt(); extern void give_rdfileopt(void);
extern void set_norecurse(); extern void set_norecurse(void);
extern char *get_rdfileopt(); extern char *get_rdfileopt(void);

View File

@ -1,14 +1,16 @@
#include "wrfile.h"
#ifdef TYPES_H #ifdef TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif /* TYPES_H */ #endif /* TYPES_H */
#include <sys/stat.h> #include <sys/stat.h>
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include "machdr.h" #include "machdr.h"
#include "wrfile.h"
#include "wrfileopt.h" #include "wrfileopt.h"
#include "../util/util.h" #include "../util/util.h"
#ifdef AUFSPLUS #ifdef AUFSPLUS
@ -43,17 +45,17 @@ char *sprintf();
#endif /* UNDEF */ #endif /* UNDEF */
#ifdef AUFS #ifdef AUFS
static void check_aufs(); static void check_aufs(void);
static void aufs_namings(); static void aufs_namings(void);
static void wr_aufs_info(); static void wr_aufs_info(FILE* fp);
#endif /* AUFS */ #endif /* AUFS */
#ifdef APPLEDOUBLE #ifdef APPLEDOUBLE
static void check_appledouble(); static void check_appledouble(void);
static void appledouble_namings(); static void appledouble_namings(void);
static void wr_appledouble_info(); static void wr_appledouble_info(FILE* fp);
#endif /* APPLEDOUBLE */ #endif /* APPLEDOUBLE */
#ifdef APPLESHARE #ifdef APPLESHARE
static void mk_share_name(); static void mk_share_name(void);
#endif /* APPLESHARE */ #endif /* APPLESHARE */
#ifndef BSD #ifndef BSD
@ -100,10 +102,10 @@ static char init_buffer[128];
static char *buffer = &(init_buffer[0]); static char *buffer = &(init_buffer[0]);
static char *rbuffer = NULL, *dbuffer = NULL; static char *rbuffer = NULL, *dbuffer = NULL;
static char *ptr; static char *ptr;
static unsigned long rsz, dsz, totsize, maxsize; static uint32_t rsz, dsz, totsize, maxsize;
void define_name(text) void
char *text; define_name (char *text)
{ {
(void)sprintf(f_info, "%s.info", text); (void)sprintf(f_info, "%s.info", text);
(void)sprintf(f_rsrc, "%s.rsrc", text); (void)sprintf(f_rsrc, "%s.rsrc", text);
@ -118,9 +120,8 @@ char *text;
#endif /* APPLESHARE */ #endif /* APPLESHARE */
} }
void start_info(info, rsize, dsize) void
char *info; start_info (char *info, uint32_t rsize, uint32_t dsize)
unsigned long rsize, dsize;
{ {
int rs, ds; int rs, ds;
@ -158,17 +159,20 @@ unsigned long rsize, dsize;
#endif /* APPLEDOUBLE */ #endif /* APPLEDOUBLE */
} }
void start_rsrc() void
start_rsrc (void)
{ {
out_buffer = out_ptr = rbuffer; out_buffer = out_ptr = rbuffer;
} }
void start_data() void
start_data (void)
{ {
out_buffer = out_ptr = dbuffer; out_buffer = out_ptr = dbuffer;
} }
void end_file() void
end_file (void)
{ {
FILE *fp; FILE *fp;
int i, c; int i, c;
@ -324,9 +328,8 @@ void end_file()
} }
#ifdef SCAN #ifdef SCAN
void do_idf(name, kind) void
char *name; do_idf (char *name, int kind)
int kind;
{ {
int n; int n;
@ -336,7 +339,7 @@ int kind;
n = strlen(name); n = strlen(name);
(void)bzero(buffer, INFOBYTES); (void)bzero(buffer, INFOBYTES);
buffer[I_NAMEOFF + 1] = kind; 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); (void)fwrite(buffer, 1, INFOBYTES, stdout);
if(n != 0) { if(n != 0) {
(void)fwrite(name, 1, n, stdout); (void)fwrite(name, 1, n, stdout);
@ -348,8 +351,8 @@ int kind;
} }
#endif /* SCAN */ #endif /* SCAN */
void do_mkdir(name, header) void
char *name, *header; do_mkdir (char *name, char *header)
{ {
struct stat sbuf; struct stat sbuf;
FILE *fp; FILE *fp;
@ -507,7 +510,7 @@ char dirinfo[I_NAMELEN*3+INFOSZ+10];
#endif /* APPLESHARE */ #endif /* APPLESHARE */
} }
void enddir() void enddir(void)
{ {
char header[INFOBYTES]; char header[INFOBYTES];
int i; int i;
@ -529,7 +532,7 @@ int i;
#ifdef APPLESHARE #ifdef APPLESHARE
#ifdef AUFS #ifdef AUFS
static void check_aufs() static void check_aufs(void)
{ {
/* check for .resource/ and .finderinfo/ */ /* check for .resource/ and .finderinfo/ */
struct stat stbuf; struct stat stbuf;
@ -555,7 +558,7 @@ static void check_aufs()
} }
} }
static void aufs_namings() static void aufs_namings(void)
{ {
mk_share_name(); mk_share_name();
(void)sprintf(f_info_aufs, "%s/%s", infodir, share_name); (void)sprintf(f_info_aufs, "%s/%s", infodir, share_name);
@ -563,8 +566,7 @@ static void aufs_namings()
(void)sprintf(f_data, "%s", share_name); (void)sprintf(f_data, "%s", share_name);
} }
static void wr_aufs_info(fp) static void wr_aufs_info(FILE* fp)
FILE *fp;
{ {
FileInfo theinfo; FileInfo theinfo;
int n; int n;
@ -581,7 +583,7 @@ FILE *fp;
theinfo.fi_datevalid = FI_CDATE | FI_MDATE; theinfo.fi_datevalid = FI_CDATE | FI_MDATE;
put4(theinfo.fi_ctime, get4(buffer + I_CTIMOFF) - TIMEDIFF); put4(theinfo.fi_ctime, get4(buffer + I_CTIMOFF) - TIMEDIFF);
put4(theinfo.fi_mtime, get4(buffer + I_MTIMOFF) - 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 */ #endif /* AUFSPLUS */
bcopy(buffer + I_TYPEOFF, theinfo.fi_fndr, 4); bcopy(buffer + I_TYPEOFF, theinfo.fi_fndr, 4);
bcopy(buffer + I_AUTHOFF, theinfo.fi_fndr + 4, 4); bcopy(buffer + I_AUTHOFF, theinfo.fi_fndr + 4, 4);
@ -599,7 +601,7 @@ FILE *fp;
#endif /* AUFS */ #endif /* AUFS */
#ifdef APPLEDOUBLE #ifdef APPLEDOUBLE
static void check_appledouble() static void check_appledouble(void)
{ {
/* check for .AppleDouble/ */ /* check for .AppleDouble/ */
struct stat stbuf; struct stat stbuf;
@ -618,35 +620,34 @@ static void check_appledouble()
} }
} }
static void appledouble_namings() static void appledouble_namings(void)
{ {
mk_share_name(); mk_share_name();
(void)sprintf(f_info_appledouble, "%s/%s", infodir, share_name); (void)snprintf(f_info_appledouble, sizeof(f_info_appledouble), "%s/%s", infodir, share_name);
(void)sprintf(f_data, "%s", share_name); (void)snprintf(f_data, sizeof(f_data), "%s", share_name);
} }
static void wr_appledouble_info(fp) static void wr_appledouble_info(FILE* fp)
FILE *fp;
{ {
FileInfo theinfo; FileInfo theinfo;
int n; int n;
bzero((char *) &theinfo, sizeof theinfo); bzero((char *) &theinfo, sizeof theinfo);
put4(theinfo.fi_magic, (unsigned long)FI_MAGIC); put4(theinfo.fi_magic, (uint32_t)FI_MAGIC);
put2(theinfo.fi_version, (unsigned long)FI_VERSION); put2(theinfo.fi_version, (uint32_t)FI_VERSION);
put4(theinfo.fi_fill5, (unsigned long)FI_FILL5); put4(theinfo.fi_fill5, (uint32_t)FI_FILL5);
put4(theinfo.fi_fill6, (unsigned long)FI_FILL6); put4(theinfo.fi_fill6, (uint32_t)FI_FILL6);
put4(theinfo.fi_hlen, (unsigned long)FI_HLEN); put4(theinfo.fi_hlen, (uint32_t)FI_HLEN);
put4(theinfo.fi_fill7, (unsigned long)FI_FILL7); put4(theinfo.fi_fill7, (uint32_t)FI_FILL7);
put4(theinfo.fi_namptr, (unsigned long)FI_NAMPTR); put4(theinfo.fi_namptr, (uint32_t)FI_NAMPTR);
put4(theinfo.fi_fill9, (unsigned long)FI_FILL9); put4(theinfo.fi_fill9, (uint32_t)FI_FILL9);
put4(theinfo.fi_commptr, (unsigned long)FI_COMMPTR); put4(theinfo.fi_commptr, (uint32_t)FI_COMMPTR);
put4(theinfo.fi_fill12, (unsigned long)FI_FILL12); put4(theinfo.fi_fill12, (uint32_t)FI_FILL12);
put4(theinfo.fi_timeptr, (unsigned long)FI_TIMEPTR); put4(theinfo.fi_timeptr, (uint32_t)FI_TIMEPTR);
put4(theinfo.fi_timesize, (unsigned long)FI_TIMESIZE); put4(theinfo.fi_timesize, (uint32_t)FI_TIMESIZE);
put4(theinfo.fi_fill15, (unsigned long)FI_FILL15); put4(theinfo.fi_fill15, (uint32_t)FI_FILL15);
put4(theinfo.fi_infoptr, (unsigned long)FI_INFOPTR); put4(theinfo.fi_infoptr, (uint32_t)FI_INFOPTR);
put4(theinfo.fi_infosize, (unsigned long)FI_INFOSIZE); put4(theinfo.fi_infosize, (uint32_t)FI_INFOSIZE);
bcopy(buffer + I_TYPEOFF, theinfo.fi_type, 4); bcopy(buffer + I_TYPEOFF, theinfo.fi_type, 4);
bcopy(buffer + I_AUTHOFF, theinfo.fi_auth, 4); bcopy(buffer + I_AUTHOFF, theinfo.fi_auth, 4);
@ -657,13 +658,13 @@ FILE *fp;
if((n = buffer[I_NAMEOFF] & 0xff) > F_NAMELEN) { if((n = buffer[I_NAMEOFF] & 0xff) > F_NAMELEN) {
n = 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); (void)strncpy((char *)theinfo.fi_name, buffer + I_NAMEOFF + 1,n);
/* theinfo.fi_macfilename[n] = '\0'; */ /* theinfo.fi_macfilename[n] = '\0'; */
(void)strcpy((char *)theinfo.fi_comment, (void)strcpy((char *)theinfo.fi_comment,
"Converted by Unix utility to AppleDouble format"); "Converted by Unix utility to AppleDouble format");
put4(theinfo.fi_commsize, (unsigned long)strlen(theinfo.fi_comment)); put4(theinfo.fi_commsize, (uint32_t)strlen(theinfo.fi_comment));
put4(theinfo.fi_rsrc, (unsigned long)rsz); put4(theinfo.fi_rsrc, (uint32_t)rsz);
/* Still TODO */ /* Still TODO */
/* char fi_ctime[4]; /* Creation time (Unix time) */ /* char fi_ctime[4]; /* Creation time (Unix time) */
/* char fi_mtime[4]; /* Modification time (Unix time) */ /* char fi_mtime[4]; /* Modification time (Unix time) */
@ -671,14 +672,14 @@ FILE *fp;
} }
#endif /* APPLEDOUBLE */ #endif /* APPLEDOUBLE */
static void mk_share_name() static void mk_share_name(void)
{ {
int ch; int ch;
char *mp, *up; char *mp, *up;
mp = buffer + 2; mp = buffer + 2;
up = &(share_name[0]); up = &(share_name[0]);
while(ch = *mp++) { while((ch = *mp++)) {
if(isascii(ch) && ! iscntrl(ch) && isprint(ch) && ch != '/') { if(isascii(ch) && ! iscntrl(ch) && isprint(ch) && ch != '/') {
*up++ = ch; *up++ = ch;
} else { } else {
@ -691,8 +692,7 @@ static void mk_share_name()
} }
#endif /* APPLESHARE */ #endif /* APPLESHARE */
int wrfileopt(c) int wrfileopt(char c)
char c;
{ {
switch(c) { switch(c) {
case 'b': case 'b':
@ -765,7 +765,7 @@ char c;
return 1; return 1;
} }
void give_wrfileopt() void give_wrfileopt(void)
{ {
(void)fprintf(stderr, "File output options:\n"); (void)fprintf(stderr, "File output options:\n");
(void)fprintf(stderr, "-b:\tMacBinary (default)\n"); (void)fprintf(stderr, "-b:\tMacBinary (default)\n");
@ -808,7 +808,7 @@ void set_s_wrfileopt(int restricted)
mode_s_restricted = restricted; mode_s_restricted = restricted;
} }
char *get_wrfileopt() char *get_wrfileopt(void)
{ {
static char options[20]; static char options[20];
@ -827,7 +827,7 @@ char *get_wrfileopt()
return options; return options;
} }
char *get_mina() char *get_mina(void)
{ {
#ifdef APPLESHARE #ifdef APPLESHARE
#ifdef AUFS #ifdef AUFS

View File

@ -1,14 +1,16 @@
#include <stdint.h>
extern char *out_buffer, *out_ptr; extern char *out_buffer, *out_ptr;
extern void define_name(); extern void define_name(char *text);
extern void start_info(); void start_info(char *info, uint32_t rsize, uint32_t dsize);
extern void start_rsrc(); extern void start_rsrc(void);
extern void start_data(); extern void start_data(void);
extern void end_file(); extern void end_file(void);
#ifdef SCAN #ifdef SCAN
extern void do_idf(); extern void do_idf(char *name, int kind);
#endif /* SCAN */ #endif /* SCAN */
extern void do_mkdir(); extern void do_mkdir(char *name, char *header);
extern void enddir(); extern void enddir(void);
extern char *get_mina(); extern char *get_mina(void);

View File

@ -1,6 +1,6 @@
extern int wrfileopt(); extern int wrfileopt(char c);
extern void give_wrfileopt(); extern void give_wrfileopt(void);
extern void set_wrfileopt(); extern void set_wrfileopt(int restricted);
extern void set_s_wrfileopt(); extern void set_s_wrfileopt(int restricted);
extern char *get_wrfileopt(); extern char *get_wrfileopt(void);

View File

@ -9,8 +9,8 @@ int data_size, rsrc_size;
static int max_data_size, max_rsrc_size; static int max_data_size, max_rsrc_size;
static int do_data; static int do_data;
void put_byte(c) void
char c; put_byte (int c)
{ {
if(do_data) { if(do_data) {
if(data_size >= max_data_size) { if(data_size >= max_data_size) {
@ -43,8 +43,8 @@ char c;
} }
} }
void set_put(data) void
int data; set_put (int data)
{ {
do_data = data; do_data = data;
if(do_data) { if(do_data) {
@ -54,12 +54,13 @@ int data;
} }
} }
void end_put() void
end_put (void)
{ {
if(info_only) { if(info_only) {
return; 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) { if(data_size != 0) {
start_data(); start_data();
copy(out_ptr, data_fork, data_size); copy(out_ptr, data_fork, data_size);

View File

@ -1,6 +1,6 @@
extern char *data_fork, *rsrc_fork; extern char *data_fork, *rsrc_fork;
extern int data_size, rsrc_size; extern int data_size, rsrc_size;
extern void put_byte(); extern void put_byte(int c);
extern void set_put(); extern void set_put(int data);
extern void end_put(); extern void end_put(void);

View File

@ -6,34 +6,34 @@
#include "../util/masks.h" #include "../util/masks.h"
#include "globals.h" #include "globals.h"
extern void exit(); #include <stdlib.h>
unsigned long crc; uint32_t crc;
#ifdef HQX #ifdef HQX
void comp_q_crc(c) void
register unsigned int c; comp_q_crc (register unsigned int c)
{ {
unsigned char cc = c; unsigned char cc = c;
crc = binhex_updcrc(crc, &cc, 1); crc = binhex_updcrc(crc, &cc, 1);
} }
void comp_q_crc_n(s, e) void
register unsigned char *s, *e; comp_q_crc_n (register unsigned char *s, register unsigned char *e)
{ {
crc = binhex_updcrc(crc, s, e - s); crc = binhex_updcrc(crc, s, e - s);
} }
#endif /* HQX */ #endif /* HQX */
void verify_crc(calc_crc, file_crc) void
unsigned long calc_crc, file_crc; verify_crc (uint32_t calc_crc, uint32_t file_crc)
{ {
calc_crc &= WORDMASK; calc_crc &= WORDMASK;
file_crc &= WORDMASK; file_crc &= WORDMASK;
if(calc_crc != file_crc) { 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); file_crc, calc_crc);
#ifdef SCAN #ifdef SCAN
do_error("hexbin: CRC error"); do_error("hexbin: CRC error");

View File

@ -1,10 +1,10 @@
#define INITCRC binhex_crcinit #define INITCRC binhex_crcinit
extern unsigned long crc; #include "../crc/crc.h"
extern unsigned long binhex_crcinit;
extern unsigned long binhex_updcrc();
extern void comp_q_crc(); extern uint32_t crc;
extern void comp_q_crc_n();
extern void verify_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 (uint32_t calc_crc, uint32_t file_crc);

View File

@ -6,20 +6,21 @@
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "../util/util.h" #include "../util/util.h"
#include "../util/transname.h"
#include "buffer.h" #include "buffer.h"
#include "printhdr.h" #include "printhdr.h"
extern void exit(); #include <stdlib.h>
static long dl_fork(); static int32_t dl_fork(void);
static int nchar(); static int nchar(void);
static int nextc(); static int nextc(void);
static char *icp = &line[0]; static char *icp = &line[0];
/* oldest format -- process .dl files */ /* oldest format -- process .dl files */
void dl(macname, filename) void
char *macname, *filename; dl (char *macname, char *filename)
{ {
int n; int n;
@ -67,18 +68,19 @@ char *macname, *filename;
(void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n); (void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n);
(void)strncpy(info + I_TYPEOFF, mh.m_type, 4); (void)strncpy(info + I_TYPEOFF, mh.m_type, 4);
(void)strncpy(info + I_AUTHOFF, mh.m_author, 4); (void)strncpy(info + I_AUTHOFF, mh.m_author, 4);
put4(info + I_DLENOFF, (unsigned long)mh.m_datalen); put4(info + I_DLENOFF, (uint32_t)mh.m_datalen);
put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen); put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen);
put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime); put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime);
put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime); put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime);
print_header2(0); print_header2(0);
end_put(); end_put();
} }
static long dl_fork() static int32_t
dl_fork (void)
{ {
register unsigned long i, v, c; register uint32_t i, v, c;
register unsigned long n, bytes; register uint32_t n, bytes;
n = 0; n = 0;
bytes = 0; bytes = 0;
@ -104,7 +106,8 @@ static long dl_fork()
return bytes; return bytes;
} }
static int nchar() static int
nchar (void)
{ {
int i; int i;
@ -118,7 +121,8 @@ static int nchar()
return i & 0177; return i & 0177;
} }
static int nextc() static int
nextc (void)
{ {
while(*icp == 0) { while(*icp == 0) {
if(readline() == 0) { if(readline() == 0) {

7
hexbin/dl.h Normal file
View File

@ -0,0 +1,7 @@
#include "hexbin.h"
#ifdef DL
void dl (char *macname, char *filename);
#endif

View File

@ -18,8 +18,8 @@ int was_macbin;
FILE *ifp; FILE *ifp;
#ifdef SCAN #ifdef SCAN
void do_error(string) void
char *string; do_error (char *string)
{ {
do_idf(string, ERROR); do_idf(string, ERROR);
} }

View File

@ -1,15 +1,13 @@
#include <stdio.h> #include <stdio.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#ifdef BSD #ifdef BSD
extern char *rindex(); #include <strings.h>
#define search_last rindex #define search_last rindex
#else /* BSD */ #else /* BSD */
extern char *strrchr();
#define search_last strrchr #define search_last strrchr
#endif /* BSD */ #endif /* BSD */
extern void transname();
extern char info[]; extern char info[];
extern char trname[]; extern char trname[];
@ -18,10 +16,10 @@ typedef struct macheader {
char m_type[4]; char m_type[4];
char m_author[4]; char m_author[4];
short m_flags; short m_flags;
long m_datalen; int32_t m_datalen;
long m_rsrclen; int32_t m_rsrclen;
long m_createtime; int32_t m_createtime;
long m_modifytime; int32_t m_modifytime;
} macheader; } macheader;
extern struct macheader mh; extern struct macheader mh;
@ -35,5 +33,5 @@ extern int was_macbin;
extern FILE *ifp; extern FILE *ifp;
extern void do_error(); extern void do_error(char *string);

View File

@ -4,27 +4,28 @@
#include "crc.h" #include "crc.h"
#include "readline.h" #include "readline.h"
#include "../util/masks.h" #include "../util/masks.h"
#include "../util/transname.h"
#include "../util/util.h" #include "../util/util.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "buffer.h" #include "buffer.h"
#include "printhdr.h" #include "printhdr.h"
extern void exit(); #include <stdlib.h>
static void do_o_forks(); static void do_o_forks(void);
static long make_file(); static int32_t make_file(int compressed);
static void comp_c_crc(); static void comp_c_crc(int c);
static void comp_e_crc(); static void comp_e_crc(int c);
static int comp_to_bin(); static int comp_to_bin(void);
static int hex_to_bin(); static int hex_to_bin(void);
static int hexit(); static int hexit(int c);
static int compressed; static int compressed;
/* old format -- process .hex and .hcx files */ /* old format -- process .hex and .hcx files */
void hecx(macname, filename) void
char *macname, *filename; hecx (char *macname, char *filename)
{ {
int n; int n;
@ -86,19 +87,20 @@ char *macname, *filename;
(void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n); (void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n);
(void)strncpy(info + I_TYPEOFF, mh.m_type, 4); (void)strncpy(info + I_TYPEOFF, mh.m_type, 4);
(void)strncpy(info + I_AUTHOFF, mh.m_author, 4); (void)strncpy(info + I_AUTHOFF, mh.m_author, 4);
put2(info + I_FLAGOFF, (unsigned long)mh.m_flags); put2(info + I_FLAGOFF, (uint32_t)mh.m_flags);
put4(info + I_DLENOFF, (unsigned long)mh.m_datalen); put4(info + I_DLENOFF, (uint32_t)mh.m_datalen);
put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen); put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen);
put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime); put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime);
put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime); put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime);
print_header2(0); print_header2(0);
end_put(); end_put();
} }
static void do_o_forks() static void
do_o_forks (void)
{ {
int forks = 0, found_crc = 0; 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 */ crc = 0; /* calculate a crc for both forks */
@ -127,13 +129,13 @@ static void do_o_forks()
if(compressed && strncmp(line, "***CRC:", 7) == 0) { if(compressed && strncmp(line, "***CRC:", 7) == 0) {
found_crc++; found_crc++;
calc_crc = crc; calc_crc = crc;
(void)sscanf(&line[7], "%lx", &file_crc); (void)sscanf(&line[7], "%x", &file_crc);
break; break;
} }
if(!compressed && strncmp(line, "***CHECKSUM:", 12) == 0) { if(!compressed && strncmp(line, "***CHECKSUM:", 12) == 0) {
found_crc++; found_crc++;
calc_crc = crc & BYTEMASK; calc_crc = crc & BYTEMASK;
(void)sscanf(&line[12], "%lx", &file_crc); (void)sscanf(&line[12], "%x", &file_crc);
file_crc &= BYTEMASK; file_crc &= BYTEMASK;
break; break;
} }
@ -150,10 +152,10 @@ static void do_o_forks()
} }
} }
static long make_file(compressed) static int32_t
int compressed; make_file (int compressed)
{ {
register long nbytes = 0L; register int32_t nbytes = 0L;
while(readline()) { while(readline()) {
if(line[0] == 0) { if(line[0] == 0) {
@ -171,22 +173,23 @@ int compressed;
return nbytes; return nbytes;
} }
static void comp_c_crc(c) static void
unsigned char c; comp_c_crc (int c)
{ {
crc = (crc + c) & WORDMASK; crc = (crc + c) & WORDMASK;
crc = ((crc << 3) & WORDMASK) | (crc >> 13); crc = ((crc << 3) & WORDMASK) | (crc >> 13);
} }
static void comp_e_crc(c) static void
unsigned char c; comp_e_crc (int c)
{ {
crc += c; crc += c;
} }
#define SIXB(c) (((c)-0x20) & 0x3f) #define SIXB(c) (((c)-0x20) & 0x3f)
static int comp_to_bin() static int
comp_to_bin (void)
{ {
char obuf[BUFSIZ]; char obuf[BUFSIZ];
register char *ip = line; register char *ip = line;
@ -217,7 +220,8 @@ static int comp_to_bin()
return outcount; return outcount;
} }
static int hex_to_bin() static int
hex_to_bin (void)
{ {
register char *ip = line; register char *ip = line;
register int n, outcount; register int n, outcount;
@ -233,8 +237,8 @@ static int hex_to_bin()
return outcount; return outcount;
} }
static int hexit(c) static int
int c; hexit (int c)
{ {
if('0' <= c && c <= '9') { if('0' <= c && c <= '9') {
return c - '0'; return c - '0';

7
hexbin/hecx.h Normal file
View File

@ -0,0 +1,7 @@
#include "hexbin.h"
#ifdef HECX
void hecx (char *macname, char *filename);
#endif

View File

@ -16,38 +16,26 @@
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../fileio/kind.h" #include "../fileio/kind.h"
#include "../util/curtime.h" #include "../util/curtime.h"
#include "../util/backtrans.h"
#include "hexbin.h" #include "hexbin.h"
#include "dl.h"
#include "hecx.h"
#include "hqx.h"
#include "mu.h"
#define LOCALOPT "ilvcn:qVH" #define LOCALOPT "ilvcn:qVH"
extern void backtrans(); static void usage(void);
#ifdef DL static void do_files(char *filename, char *macname);
extern void dl(); static int find_header(int again);
#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 char options[128]; static char options[128];
int main(argc, argv) int
int argc; main (int argc, char **argv)
char **argv;
{ {
char *filename; char *filename;
char macname[32]; char macname[32];
extern int optind;
extern char *optarg;
int errflg; int errflg;
int c; int c;
@ -162,14 +150,16 @@ static char *extensions[] = {
NULL NULL
}; };
static void do_files(filename, macname) static void
char *filename; /* input file name -- extension optional */ do_files (
char *macname; /* name to use on the mac side of things */ char *filename, /* input file name -- extension optional */
char *macname /* name to use on the mac side of things */
)
{ {
char namebuf[256]; char namebuf[256];
char **ep; char **ep;
struct stat stbuf; struct stat stbuf;
long curtime; int32_t curtime;
int qformat; int qformat;
int again; int again;
@ -197,7 +187,7 @@ char *macname; /* name to use on the mac side of things */
again = 0; again = 0;
nexttry: nexttry:
if(ifp == stdin) { if(ifp == stdin) {
curtime = (long)time((time_t *)0) + TIMEDIFF; curtime = (int32_t)time((time_t *)0) + TIMEDIFF;
mh.m_createtime = curtime; mh.m_createtime = curtime;
mh.m_modifytime = curtime; mh.m_modifytime = curtime;
} else { } else {
@ -237,8 +227,8 @@ nexttry:
} }
/* eat characters until header detected, return which format */ /* eat characters until header detected, return which format */
static int find_header(again) static int
int again; find_header (int again)
{ {
int c, dl_start, llen; int c, dl_start, llen;
char *cp; char *cp;
@ -356,7 +346,8 @@ int again;
return form_none; return form_none;
} }
static void usage() static void
usage (void)
{ {
(void)fprintf(stderr, "Usage: hexbin [-%s] [filenames]\n", options); (void)fprintf(stderr, "Usage: hexbin [-%s] [filenames]\n", options);
(void)fprintf(stderr, "Use \"hexbin -H\" for help.\n"); (void)fprintf(stderr, "Use \"hexbin -H\" for help.\n");

View File

@ -1,4 +1,5 @@
#include "hexbin.h" #include "hexbin.h"
#include "hqx.h"
#ifdef HQX #ifdef HQX
#include <stdlib.h> #include <stdlib.h>
#include "globals.h" #include "globals.h"
@ -8,14 +9,15 @@
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "../util/util.h" #include "../util/util.h"
#include "../util/transname.h"
#include "printhdr.h" #include "printhdr.h"
static void get_header(); static void get_header(void);
static void oflush(); static void oflush(void);
static int getq(); static int getq(void);
static long get2q(); static int32_t get2q(void);
static long get4q(); static int32_t get4q(void);
static void getqbuf(); static void getqbuf(char *buf, int n);
static char *g_macname; static char *g_macname;
@ -97,19 +99,19 @@ static unsigned char *oq;
static int ostate = S_HEADER; static int ostate = S_HEADER;
static unsigned long calc_crc; static uint32_t calc_crc;
static unsigned long file_crc; static uint32_t file_crc;
static long todo; static int32_t todo;
#define output(c) { *op++ = (c); if(op >= &obuf[BUFSIZ]) oflush(); } #define output(c) { *op++ = (c); if(op >= &obuf[BUFSIZ]) oflush(); }
void hqx(macname) void
char *macname; hqx (char *macname)
{ {
int n, normlen, c; int n, normlen, c;
register char *in, *out; 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; char state68 = 0, run = 0, linestate, first = 1;
g_macname = macname; g_macname = macname;
@ -231,10 +233,11 @@ done:
print_header2(verbose); print_header2(verbose);
} }
static void get_header() static void
get_header (void)
{ {
int n; int n;
unsigned long calc_crc, file_crc; uint32_t calc_crc, file_crc;
crc = INITCRC; /* compute a crc for the header */ crc = INITCRC; /* compute a crc for the header */
@ -275,14 +278,15 @@ static void get_header()
(void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n); (void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n);
(void)strncpy(info + I_TYPEOFF, mh.m_type, 4); (void)strncpy(info + I_TYPEOFF, mh.m_type, 4);
(void)strncpy(info + I_AUTHOFF, mh.m_author, 4); (void)strncpy(info + I_AUTHOFF, mh.m_author, 4);
put2(info + I_FLAGOFF, (unsigned long)mh.m_flags); put2(info + I_FLAGOFF, (uint32_t)mh.m_flags);
put4(info + I_DLENOFF, (unsigned long)mh.m_datalen); put4(info + I_DLENOFF, (uint32_t)mh.m_datalen);
put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen); put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen);
put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime); put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime);
put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime); put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime);
} }
static void oflush() static void
oflush (void)
{ {
int n, i; int n, i;
@ -335,7 +339,7 @@ static void oflush()
++ostate; ++ostate;
break; break;
case S_EXCESS: 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; oq = op;
break; break;
} }
@ -343,7 +347,8 @@ static void oflush()
op = obuf; op = obuf;
} }
static int getq() static int
getq (void)
{ {
int c; int c;
@ -360,17 +365,19 @@ static int getq()
} }
/* get2q(); q format -- read 2 bytes from input, return short */ /* get2q(); q format -- read 2 bytes from input, return short */
static long get2q() static int32_t
get2q (void)
{ {
short high = getq() << 8; short high = getq() << 8;
return high | getq(); return high | getq();
} }
/* get4q(); q format -- read 4 bytes from input, return long */ /* get4q(); q format -- read 4 bytes from input, return long */
static long get4q() static int32_t
get4q (void)
{ {
int i; int i;
long value = 0; int32_t value = 0;
for(i = 0; i < 4; i++) { for(i = 0; i < 4; i++) {
value = (value<<8) | getq(); value = (value<<8) | getq();

7
hexbin/hqx.h Normal file
View File

@ -0,0 +1,7 @@
#include "hexbin.h"
#ifdef HQX
void hqx (char *macname);
#endif

View File

@ -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

View File

@ -1,23 +1,25 @@
#include "hexbin.h" #include "hexbin.h"
#include "mu.h"
#ifdef MU #ifdef MU
#include "globals.h" #include "globals.h"
#include "readline.h" #include "readline.h"
#include "../util/masks.h" #include "../util/masks.h"
#include "../util/util.h" #include "../util/util.h"
#include "../util/transname.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "buffer.h" #include "buffer.h"
#include "printhdr.h" #include "printhdr.h"
extern void exit(); #include <stdlib.h>
static void do_mu_fork(); static void do_mu_fork(void);
static int mu_comp_to_bin(); static int mu_comp_to_bin(void);
static int mu_convert(); static int mu_convert(char *ibuf, char *obuf);
/* mu format -- process .mu files */ /* mu format -- process .mu files */
void mu(macname) void
char *macname; mu (char *macname)
{ {
int n; int n;
@ -135,17 +137,18 @@ char *macname;
(void)strncpy(mh.m_type, info + I_TYPEOFF, 4); (void)strncpy(mh.m_type, info + I_TYPEOFF, 4);
(void)strncpy(mh.m_author, info + I_AUTHOFF, 4); (void)strncpy(mh.m_author, info + I_AUTHOFF, 4);
print_header1(0, 0); print_header1(0, 0);
put4(info + I_DLENOFF, (unsigned long)mh.m_datalen); put4(info + I_DLENOFF, (uint32_t)mh.m_datalen);
put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen); put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen);
put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime); put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime);
put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime); put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime);
print_header2(0); print_header2(0);
end_put(); end_put();
} }
static void do_mu_fork() static void
do_mu_fork (void)
{ {
long newbytes; int32_t newbytes;
while(readline()) { while(readline()) {
if(line[0] == 0) { if(line[0] == 0) {
@ -179,7 +182,8 @@ static void do_mu_fork()
/*NOTREACHED*/ /*NOTREACHED*/
} }
static int mu_comp_to_bin() static int
mu_comp_to_bin (void)
{ {
char obuf[BUFSIZ]; char obuf[BUFSIZ];
int outcount, n; int outcount, n;
@ -193,8 +197,8 @@ static int mu_comp_to_bin()
#define SIXB(c) (((c)-0x20) & 0x3f) #define SIXB(c) (((c)-0x20) & 0x3f)
static int mu_convert(ibuf, obuf) static int
char *ibuf, *obuf; mu_convert (char *ibuf, char *obuf)
{ {
register char *ip = ibuf; register char *ip = ibuf;
register char *op = obuf; register char *op = obuf;

7
hexbin/mu.h Normal file
View File

@ -0,0 +1,7 @@
#include "hexbin.h"
#ifdef MU
void mu (char *macname);
#endif

View File

@ -1,5 +1,6 @@
#include "printhdr.h" #include "printhdr.h"
#include "globals.h" #include "globals.h"
#include "../util/transname.h"
/* print out header information in human-readable format */ /* print out header information in human-readable format */
void print_header0(int skip) void print_header0(int skip)
@ -37,7 +38,7 @@ void print_header2(int skip)
if (skip) { if (skip) {
(void)fprintf(stderr, "\t"); (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); mh.m_datalen, mh.m_rsrclen);
} }
} }

View File

@ -1,4 +1,4 @@
extern void print_header0(); extern void print_header0(int skip);
extern void print_header1(); extern void print_header1(int skip1, int skip2);
extern void print_header2(); extern void print_header2(int skip);

View File

@ -6,7 +6,8 @@ char line[1024]; /* Allow a lot! */
/* Read a line. Allow termination by CR or LF or both. Also allow for /* 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, a non-terminated line at end-of-file. Returns 1 if a line is read,
0 otherwise. */ 0 otherwise. */
int readline() int
readline (void)
{ {
int ptr = 0, c; int ptr = 0, c;

View File

@ -1,3 +1,3 @@
extern char line[]; extern char line[];
int readline(); int readline(void);

View File

@ -1,3 +1,5 @@
#include <stdint.h>
#define MAGIC1 0 /* Should be 0x1b, marks Mac extension */ #define MAGIC1 0 /* Should be 0x1b, marks Mac extension */
#define KIND 1 /* KIND == 0 marks end of archive */ #define KIND 1 /* KIND == 0 marks end of archive */
#define FNAME 2 #define FNAME 2
@ -18,7 +20,7 @@
#define SIZE2 84 /* Not present if KIND == 1 */ #define SIZE2 84 /* Not present if KIND == 1 */
#define HEADERBYTES 88 #define HEADERBYTES 88
typedef struct fileHdr { /* 84 or 88 bytes */ typedef struct arc_fileHdr { /* 84 or 88 bytes */
char magic1; char magic1;
char kind; char kind;
char fname[31]; char fname[31];
@ -26,17 +28,17 @@ typedef struct fileHdr { /* 84 or 88 bytes */
char ftype[4]; char ftype[4];
char fauth[4]; char fauth[4];
char finfo[8]; char finfo[8];
unsigned long dataLength; uint32_t dataLength;
unsigned long rsrcLength; uint32_t rsrcLength;
char filler; char filler;
char magic2; char magic2;
char kind2; char kind2;
char fname2[13]; char fname2[13];
unsigned long size; uint32_t size;
unsigned short date; uint16_t date;
unsigned short time; uint16_t time;
unsigend short crc; uint16_t crc;
unsigned long size2; /* Identical to size; this is wrong for Arc! */ uint32_t size2; /* Identical to size; this is wrong for Arc! */
}; };
#define smallstored 1 #define smallstored 1

View File

@ -1,5 +1,7 @@
#include "macunpack.h" #include "macunpack.h"
#include "bin.h"
#ifdef BIN #ifdef BIN
#include <stdlib.h>
#include <string.h> #include <string.h>
#include "globals.h" #include "globals.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
@ -7,15 +9,13 @@
#include "../fileio/kind.h" #include "../fileio/kind.h"
#include "../util/util.h" #include "../util/util.h"
#include "../util/masks.h" #include "../util/masks.h"
#include "mcb.h"
extern void mcb(); void
bin (char *header, int data_size, int UMcp)
void bin(header, data_size, UMcp)
char *header;
int data_size, UMcp;
{ {
char hdr[INFOBYTES]; char hdr[INFOBYTES];
unsigned long rsrcLength, dataLength; uint32_t rsrcLength, dataLength;
hdr[0] = getb(infp); hdr[0] = getb(infp);
(void)ungetc(hdr[0], infp); (void)ungetc(hdr[0], infp);
@ -39,7 +39,7 @@ int data_size, UMcp;
#ifdef SCAN #ifdef SCAN
do_idf("", COPY); do_idf("", COPY);
#endif /* SCAN */ #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); in_ds + in_rs);
ds_skip = 0; ds_skip = 0;
rs_skip = 0; rs_skip = 0;

4
macunpack/bin.h Normal file
View File

@ -0,0 +1,4 @@
#include "macunpack.h"
#ifdef BIN
void bin (char *header, int data_size, int UMcp);
#endif

View File

@ -8,8 +8,10 @@ int bit_be_inbytes;
static unsigned int bit_be_subbitbuf; static unsigned int bit_be_subbitbuf;
static int bit_be_bitcount; static int bit_be_bitcount;
void bit_be_fillbuf(n) /* Shift bit_be_bitbuf n bits left, read n bits */ void
int n; bit_be_fillbuf ( /* Shift bit_be_bitbuf n bits left, read n bits */
int n
)
{ {
bit_be_bitbuf <<= n; bit_be_bitbuf <<= n;
while (n > bit_be_bitcount) { while (n > bit_be_bitcount) {
@ -26,8 +28,8 @@ int n;
bit_be_bitbuf &= WORDMASK; bit_be_bitbuf &= WORDMASK;
} }
unsigned int bit_be_getbits(n) unsigned int
int n; bit_be_getbits (int n)
{ {
unsigned int x; unsigned int x;
@ -36,7 +38,8 @@ int n;
return x; return x;
} }
void bit_be_init_getbits() void
bit_be_init_getbits (void)
{ {
bit_be_bitbuf = 0; bit_be_bitbuf = 0;
bit_be_subbitbuf = 0; bit_be_subbitbuf = 0;

View File

@ -4,7 +4,7 @@ extern unsigned int bit_be_bitbuf;
extern char *bit_be_filestart; extern char *bit_be_filestart;
extern int bit_be_inbytes; extern int bit_be_inbytes;
extern void bit_be_fillbuf(); extern void bit_be_fillbuf(int n);
extern unsigned int bit_be_getbits(); extern unsigned int bit_be_getbits(int n);
extern void bit_be_init_getbits(); extern void bit_be_init_getbits(void);

View File

@ -5,15 +5,19 @@
#endif /* CPT */ #endif /* CPT */
#endif /* DD */ #endif /* DD */
#ifdef CPT #ifdef CPT
#define CPT_INTERNAL
#include "cpt.h"
#include <stdlib.h> #include <stdlib.h>
#include "globals.h" #include "globals.h"
#include "cpt.h"
#include "crc.h" #include "crc.h"
#include "../util/util.h" #include "../util/util.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "../fileio/kind.h" #include "../fileio/kind.h"
#include "../util/masks.h" #include "../util/masks.h"
#include "../util/transname.h"
#include "huffman.h" #include "huffman.h"
#define ESC1 0x81 #define ESC1 0x81
@ -22,19 +26,18 @@
#define ESC1SEEN 1 #define ESC1SEEN 1
#define ESC2SEEN 2 #define ESC2SEEN 2
static void cpt_uncompact();
static unsigned char *cpt_data; static unsigned char *cpt_data;
static unsigned long cpt_datamax; static uint32_t cpt_datamax;
static unsigned long cpt_datasize; static uint32_t cpt_datasize;
static unsigned char cpt_LZbuff[CIRCSIZE]; static unsigned char cpt_LZbuff[CIRCSIZE];
static unsigned int cpt_LZptr; static unsigned int cpt_LZptr;
static unsigned char *cpt_char; static unsigned char *cpt_char;
static unsigned long cpt_crc; static uint32_t cpt_crc;
static unsigned long cpt_inlength; static uint32_t cpt_inlength;
static unsigned long cpt_outlength; static uint32_t cpt_outlength;
static int cpt_outstat; static int cpt_outstat;
static unsigned char cpt_savechar; static unsigned char cpt_savechar;
static unsigned long cpt_newbits; static uint32_t cpt_newbits;
static int cpt_bitsavail; static int cpt_bitsavail;
static int cpt_blocksize; static int cpt_blocksize;
/* Lengths is twice the max number of entries, and include slack. */ /* Lengths is twice the max number of entries, and include slack. */
@ -42,23 +45,23 @@ static int cpt_blocksize;
static node cpt_Hufftree[512 + SLACK], cpt_LZlength[128 + SLACK], static node cpt_Hufftree[512 + SLACK], cpt_LZlength[128 + SLACK],
cpt_LZoffs[256 + SLACK]; cpt_LZoffs[256 + SLACK];
static int readcpthdr(); static int readcpthdr(struct cptHdr *s);
static int cpt_filehdr(); static int cpt_filehdr(struct cpt_fileHdr *f, char *hdr);
static void cpt_folder(); static void cpt_folder(char *name, struct cpt_fileHdr fileh, char *cptptr);
static void cpt_uncompact(); static void cpt_uncompact(struct cpt_fileHdr filehdr);
static void cpt_wrfile(); static void cpt_wrfile(uint32_t ibytes, uint32_t obytes, int type);
void cpt_wrfile1(); static void cpt_outch(int ch);
static void cpt_outch(); static void cpt_rle(void);
static void cpt_rle(); static void cpt_rle_lzh(void);
static void cpt_rle_lzh(); static void cpt_readHuff(int size, struct node *Hufftree);
static void cpt_readHuff(); static int cpt_get6bits(void);
static int cpt_get6bits(); static int cpt_getbit(void);
static int cpt_getbit();
void cpt() void
cpt (void)
{ {
struct cptHdr cpthdr; struct cptHdr cpthdr;
struct fileHdr filehdr; struct cpt_fileHdr filehdr;
char *cptindex; char *cptindex;
int cptindsize; int cptindsize;
char *cptptr; char *cptptr;
@ -75,7 +78,7 @@ void cpt()
exit(1); exit(1);
} }
cptindsize = cpthdr.entries * FILEHDRSIZE; cptindsize = cpthdr.entries * CPT_FILEHDRSIZE;
if(cpthdr.commentsize > cptindsize) { if(cpthdr.commentsize > cptindsize) {
cptindsize = cpthdr.commentsize; cptindsize = cpthdr.commentsize;
} }
@ -92,11 +95,11 @@ void cpt()
#endif /* SCAN */ #endif /* SCAN */
exit(1); 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++) { for(i = 0; i < cpthdr.entries; i++) {
*cptptr = getc(infp); *cptptr = getc(infp);
cpt_crc = (*updcrc)(cpt_crc, cptptr, 1); cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)cptptr, 1);
if(*cptptr & 0x80) { if(*cptptr & 0x80) {
cptptr[F_FOLDER] = 1; cptptr[F_FOLDER] = 1;
*cptptr &= 0x3f; *cptptr &= 0x3f;
@ -110,7 +113,7 @@ void cpt()
#endif /* SCAN */ #endif /* SCAN */
exit(1); 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(cptptr[F_FOLDER]) {
if(fread(cptptr + F_FOLDERSIZE, 1, 2, infp) != 2) { if(fread(cptptr + F_FOLDERSIZE, 1, 2, infp) != 2) {
(void)fprintf(stderr, "Can't read file header #%d\n", i+1); (void)fprintf(stderr, "Can't read file header #%d\n", i+1);
@ -119,20 +122,20 @@ void cpt()
#endif /* SCAN */ #endif /* SCAN */
exit(1); exit(1);
} }
cpt_crc = (*updcrc)(cpt_crc, cptptr + F_FOLDERSIZE, 2); cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)(cptptr + F_FOLDERSIZE), 2);
} else { } else {
if(fread(cptptr + F_VOLUME, 1, FILEHDRSIZE - F_VOLUME, infp) != if(fread(cptptr + F_VOLUME, 1, CPT_FILEHDRSIZE - F_VOLUME, infp) !=
FILEHDRSIZE - F_VOLUME) { CPT_FILEHDRSIZE - F_VOLUME) {
(void)fprintf(stderr, "Can't read file header #%d\n", i+1); (void)fprintf(stderr, "Can't read file header #%d\n", i+1);
#ifdef SCAN #ifdef SCAN
do_error("macunpack: Can't read file header"); do_error("macunpack: Can't read file header");
#endif /* SCAN */ #endif /* SCAN */
exit(1); exit(1);
} }
cpt_crc = (*updcrc)(cpt_crc, cptptr + F_VOLUME, 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) { if(cpt_crc != cpthdr.hdrcrc) {
(void)fprintf(stderr, "Header CRC mismatch: got 0x%08x, need 0x%08x\n", (void)fprintf(stderr, "Header CRC mismatch: got 0x%08x, need 0x%08x\n",
@ -155,17 +158,17 @@ void cpt()
if(filehdr.folder) { if(filehdr.folder) {
cpt_folder(text, filehdr, cptptr); cpt_folder(text, filehdr, cptptr);
i += filehdr.foldersize; i += filehdr.foldersize;
cptptr += filehdr.foldersize * FILEHDRSIZE; cptptr += filehdr.foldersize * CPT_FILEHDRSIZE;
} else { } else {
cpt_uncompact(filehdr); cpt_uncompact(filehdr);
} }
cptptr += FILEHDRSIZE; cptptr += CPT_FILEHDRSIZE;
} }
(void)free(cptindex); (void)free(cptindex);
} }
static int readcpthdr(s) static int
struct cptHdr *s; readcpthdr (struct cptHdr *s)
{ {
char temp[CHDRSIZE]; char temp[CHDRSIZE];
@ -203,17 +206,16 @@ struct cptHdr *s;
return 0; 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->hdrcrc = get4(temp + CPTHDRSIZE + CPT_C_HDRCRC);
s->entries = get2(temp + CPTHDRSIZE + C_ENTRIES); s->entries = get2(temp + CPTHDRSIZE + C_ENTRIES);
s->commentsize = temp[CPTHDRSIZE + C_COMMENT]; s->commentsize = temp[CPTHDRSIZE + C_COMMENT];
return 1; return 1;
} }
static int cpt_filehdr(f, hdr) static int
struct fileHdr *f; cpt_filehdr (struct cpt_fileHdr *f, char *hdr)
char *hdr;
{ {
register int i; register int i;
int n; int n;
@ -255,9 +257,9 @@ char *hdr;
transname(hdr + F_FTYPE, ftype, 4); transname(hdr + F_FTYPE, ftype, 4);
transname(hdr + F_CREATOR, fauth, 4); transname(hdr + F_CREATOR, fauth, 4);
(void)fprintf(stderr, (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, text, ftype, fauth,
(long)f->dataLength, (long)f->rsrcLength); (int32_t)f->dataLength, (int32_t)f->rsrcLength);
} }
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
@ -286,20 +288,18 @@ char *hdr;
return 1; return 1;
} }
static void cpt_folder(name, fileh, cptptr) static void
char *name; cpt_folder (char *name, struct cpt_fileHdr fileh, char *cptptr)
struct fileHdr fileh;
char *cptptr;
{ {
int i, nfiles; int i, nfiles;
char loc_name[64]; char loc_name[64];
struct fileHdr filehdr; struct cpt_fileHdr filehdr;
for(i = 0; i < 64; i++) { for(i = 0; i < 64; i++) {
loc_name[i] = name[i]; loc_name[i] = name[i];
} }
if(write_it || info_only) { if(write_it || info_only) {
cptptr += FILEHDRSIZE; cptptr += CPT_FILEHDRSIZE;
nfiles = fileh.foldersize; nfiles = fileh.foldersize;
if(write_it) { if(write_it) {
do_mkdir(text, info); do_mkdir(text, info);
@ -316,11 +316,11 @@ char *cptptr;
if(filehdr.folder) { if(filehdr.folder) {
cpt_folder(text, filehdr, cptptr); cpt_folder(text, filehdr, cptptr);
i += filehdr.foldersize; i += filehdr.foldersize;
cptptr += filehdr.foldersize * FILEHDRSIZE; cptptr += filehdr.foldersize * CPT_FILEHDRSIZE;
} else { } else {
cpt_uncompact(filehdr); cpt_uncompact(filehdr);
} }
cptptr += FILEHDRSIZE; cptptr += CPT_FILEHDRSIZE;
} }
if(write_it) { if(write_it) {
enddir(); enddir();
@ -333,8 +333,8 @@ char *cptptr;
} }
} }
static void cpt_uncompact(filehdr) static void
struct fileHdr filehdr; cpt_uncompact (struct cpt_fileHdr filehdr)
{ {
if(filehdr.cptFlag & 1) { if(filehdr.cptFlag & 1) {
(void)fprintf(stderr, "\tFile is password protected, skipping file\n"); (void)fprintf(stderr, "\tFile is password protected, skipping file\n");
@ -384,8 +384,8 @@ struct fileHdr filehdr;
filehdr.cptFlag & 4); filehdr.cptFlag & 4);
if(filehdr.fileCRC != cpt_crc) { if(filehdr.fileCRC != cpt_crc) {
(void)fprintf(stderr, (void)fprintf(stderr,
"CRC error on file: need 0x%08lx, got 0x%08lx\n", "CRC error on file: need 0x%08x, got 0x%08x\n",
(long)filehdr.fileCRC, (long)cpt_crc); (int32_t)filehdr.fileCRC, (int32_t)cpt_crc);
#ifdef SCAN #ifdef SCAN
do_error("macunpack: CRC error on file"); do_error("macunpack: CRC error on file");
#endif /* SCAN */ #endif /* SCAN */
@ -398,9 +398,8 @@ struct fileHdr filehdr;
} }
} }
static void cpt_wrfile(ibytes, obytes, type) static void
unsigned long ibytes, obytes; cpt_wrfile (uint32_t ibytes, uint32_t obytes, int type)
unsigned short type;
{ {
if(ibytes == 0) { if(ibytes == 0) {
return; return;
@ -415,13 +414,11 @@ unsigned short type;
} else { } else {
cpt_rle_lzh(); 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) void
unsigned char *in_char; cpt_wrfile1 (unsigned char *in_char, uint32_t ibytes, uint32_t obytes, int type, uint32_t blocksize)
unsigned long ibytes, obytes, blocksize;
int type;
{ {
cpt_char = in_char; cpt_char = in_char;
if(ibytes == 0) { if(ibytes == 0) {
@ -439,8 +436,8 @@ int type;
} }
} }
static void cpt_outch(ch) static void
unsigned char ch; cpt_outch (int ch)
{ {
cpt_LZbuff[cpt_LZptr++ & (CIRCSIZE - 1)] = ch; cpt_LZbuff[cpt_LZptr++ & (CIRCSIZE - 1)] = ch;
switch(cpt_outstat) { switch(cpt_outstat) {
@ -498,7 +495,8 @@ unsigned char ch;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Run length encoding */ /* Run length encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void cpt_rle() static void
cpt_rle (void)
{ {
while(cpt_inlength-- > 0) { while(cpt_inlength-- > 0) {
cpt_outch(*cpt_char++); cpt_outch(*cpt_char++);
@ -508,7 +506,8 @@ static void cpt_rle()
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Run length encoding plus LZ compression plus Huffman encoding */ /* Run length encoding plus LZ compression plus Huffman encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void cpt_rle_lzh() static void
cpt_rle_lzh (void)
{ {
int block_count; int block_count;
unsigned int bptr; unsigned int bptr;
@ -556,9 +555,8 @@ typedef struct sf_entry {
/* See routine LoadTree. The parameter tree (actually an array and /* See routine LoadTree. The parameter tree (actually an array and
two integers) are only used locally in this version and hence locally two integers) are only used locally in this version and hence locally
declared. The parameter nodes has been renamed Hufftree.... */ declared. The parameter nodes has been renamed Hufftree.... */
static void cpt_readHuff(size, Hufftree) static void
int size; cpt_readHuff (int size, struct node *Hufftree)
struct node *Hufftree;
{ {
sf_entry tree_entry[256 + SLACK]; /* maximal number of elements */ sf_entry tree_entry[256 + SLACK]; /* maximal number of elements */
int tree_entries; int tree_entries;
@ -680,7 +678,8 @@ struct node *Hufftree;
Hufftree[0].flag = 0; Hufftree[0].flag = 0;
} }
static int cpt_get6bits() static int
cpt_get6bits (void)
{ {
int b = 0, cn; int b = 0, cn;
@ -696,7 +695,8 @@ int b = 0, cn;
return b; return b;
} }
static int cpt_getbit() static int
cpt_getbit (void)
{ {
int b; int b;

View File

@ -1,10 +1,16 @@
#include "macunpack.h"
#ifdef CPT
#ifdef CPT_INTERNAL
#include <stdint.h>
#define C_SIGNATURE 0 #define C_SIGNATURE 0
#define C_VOLUME 1 #define C_VOLUME 1
#define C_XMAGIC 2 #define C_XMAGIC 2
#define C_IOFFSET 4 #define C_IOFFSET 4
#define CPTHDRSIZE 8 #define CPTHDRSIZE 8
#define C_HDRCRC 0 #define CPT_C_HDRCRC 0
#define C_ENTRIES 4 #define C_ENTRIES 4
#define C_COMMENT 6 #define C_COMMENT 6
#define CPTHDR2SIZE 7 #define CPTHDR2SIZE 7
@ -27,58 +33,58 @@
#define F_DATALENGTH 68 #define F_DATALENGTH 68
#define F_COMPRLENGTH 72 #define F_COMPRLENGTH 72
#define F_COMPDLENGTH 76 #define F_COMPDLENGTH 76
#define FILEHDRSIZE 80 #define CPT_FILEHDRSIZE 80
typedef long OSType; typedef int32_t OSType;
typedef struct cptHdr { /* 8 bytes */ typedef struct cptHdr { /* 8 bytes */
unsigned char signature; /* = 1 -- for verification */ unsigned char signature; /* = 1 -- for verification */
unsigned char volume; /* for multi-file archives */ unsigned char volume; /* for multi-file archives */
unsigned short xmagic; /* verification multi-file consistency*/ 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 */ /* 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 short entries; /* number of index entries */
unsigned char commentsize; /* number of bytes comment that follow*/ unsigned char commentsize; /* number of bytes comment that follow*/
} cptHdr; } cptHdr;
typedef struct fileHdr { /* 78 bytes */ typedef struct cpt_fileHdr { /* 78 bytes */
unsigned char fName[32]; /* a STR32 */ unsigned char fName[32]; /* a STR32 */
unsigned char folder; /* set to 1 if a folder */ unsigned char folder; /* set to 1 if a folder */
unsigned short foldersize; /* number of entries in folder */ unsigned short foldersize; /* number of entries in folder */
unsigned char volume; /* for multi-file archives */ 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 fType; /* file type */
OSType fCreator; /* er... */ OSType fCreator; /* er... */
unsigned long creationDate; uint32_t creationDate;
unsigned long modDate; /* !restored-compat w/backup prgms */ uint32_t modDate; /* !restored-compat w/backup prgms */
unsigned short FndrFlags; /* copy of Finder flags. For our unsigned short FndrFlags; /* copy of Finder flags. For our
purposes, we can clear: purposes, we can clear:
busy,onDesk */ busy,onDesk */
unsigned long fileCRC; /* crc on file */ uint32_t fileCRC; /* crc on file */
unsigned short cptFlag; /* cpt flags */ unsigned short cptFlag; /* cpt flags */
unsigned long rsrcLength; /* decompressed lengths */ uint32_t rsrcLength; /* decompressed lengths */
unsigned long dataLength; uint32_t dataLength;
unsigned long compRLength; /* compressed lengths */ uint32_t compRLength; /* compressed lengths */
unsigned long compDLength; uint32_t compDLength;
} fileHdr; } cpt_fileHdr;
/* file format is: /* file format is:
cptArchiveHdr cptArchiveHdr
file1data file1data
file1RsrcFork file1RsrcFork
file1DataFork file1DataFork
file2data file2data
file2RsrcFork file2RsrcFork
file2DataFork file2DataFork
. .
. .
. .
fileNdata fileNdata
fileNRsrcFork fileNRsrcFork
fileNDataFork fileNDataFork
cptIndex cptIndex
*/ */
@ -91,3 +97,13 @@ typedef struct fileHdr { /* 78 bytes */
#define CIRCSIZE 8192 #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

View File

@ -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);

View File

@ -1,13 +1,6 @@
#define INIT_CRC crcinit #define INIT_CRC crcinit
extern unsigned long arc_crcinit; #include "../crc/crc.h"
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 crcinit;
extern unsigned long (*updcrc)();
extern uint32_t crcinit;
extern uint32_t (*updcrc)(uint32_t icrc, unsigned char *icp, int32_t icnt);

View File

@ -1,47 +1,47 @@
#include "macunpack.h" #include "macunpack.h"
#define DD_INTERNAL
#include "dd.h"
#ifdef DD #ifdef DD
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "globals.h" #include "globals.h"
#include "dd.h"
#include "crc.h" #include "crc.h"
#include "cpt.h"
#include "de_compress.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "../fileio/fileglob.h" #include "../fileio/fileglob.h"
#include "../util/masks.h" #include "../util/masks.h"
#include "../util/util.h" #include "../util/util.h"
#include "../util/transname.h"
extern void cpt_wrfile1(); static void dd_name(unsigned char *bin_hdr);
extern void core_compress(); static int dd_filehdr(struct dd_fileHdr *f, struct dd_fileCHdr *cf, int skip);
extern void de_compress(); static void dd_cfilehdr(struct dd_fileCHdr *f);
static int dd_valid(int dmethod, int rmethod);
static void dd_name(); static int dd_valid1(int method);
static int dd_filehdr(); static char *dd_methname(int n);
static void dd_cfilehdr(); static uint32_t dd_checksum(uint32_t init, char *buffer, uint32_t length);
static int dd_valid(); static void dd_chksum(struct dd_fileHdr hdr, unsigned char *data);
static int dd_valid1(); static uint32_t dd_checkor(uint32_t init, char *buffer, uint32_t length);
static char *dd_methname(); static void dd_do_delta(char *out_ptr, uint32_t nbytes, int kind);
static unsigned long dd_checksum(); static void dd_delta(char *out_ptr, uint32_t nbytes);
static void dd_chksum(); static void dd_delta3(char *out_ptr, uint32_t nbytes);
static unsigned long dd_checkor(); static void dd_copy(struct dd_fileHdr hdr, unsigned char *data);
static void dd_do_delta(); static void dd_copyfile(uint32_t obytes, unsigned char *data);
static void dd_delta(); static void dd_expand(struct dd_fileCHdr hdr, unsigned char *data);
static void dd_delta3(); static void dd_expandfile(uint32_t obytes, uint32_t ibytes, int method, int kind, unsigned char *data, uint32_t chksum);
static void dd_copy(); static void dd_nocomp(uint32_t obytes, unsigned char *data);
static void dd_copyfile(); static void dd_lzc(uint32_t ibytes, uint32_t obytes, unsigned char *data, int mb, uint32_t chksum, uint32_t ckinit);
static void dd_expand();
static void dd_expandfile();
static void dd_nocomp();
static void dd_lzc();
#ifdef UNTESTED #ifdef UNTESTED
static void dd_rle(); static void dd_rle(uint32_t ibytes, unsigned char *data);
#ifdef NOTIMPLEMENTED #ifdef NOTIMPLEMENTED
static void dd_huffman(); static void dd_huffman(uint32_t ibytes, unsigned char *data);
#endif /* NOTIMPLEMENTED */ #endif /* NOTIMPLEMENTED */
static void dd_lzss(); static void dd_lzss(unsigned char *data, uint32_t chksum);
static int dd_getbits(); static int dd_getbits(int n);
#endif /* UNTESTED */ #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 { typedef struct methodinfo {
char *name; char *name;
@ -68,17 +68,17 @@ static unsigned char *dd_dirst;
static int dd_dirstptr; static int dd_dirstptr;
static int dd_dirstmax; static int dd_dirstmax;
static int dd_xor; static int dd_xor;
static long dd_bitbuf; static int32_t dd_bitbuf;
static int dd_bitcount; static int dd_bitcount;
static unsigned char *dd_bitptr; static unsigned char *dd_bitptr;
static char dd_LZbuff[2048]; static char dd_LZbuff[2048];
void dd_file(bin_hdr) void
unsigned char *bin_hdr; dd_file (unsigned char *bin_hdr)
{ {
unsigned long data_size; uint32_t data_size;
int i; int i;
struct fileCHdr cf; struct dd_fileCHdr cf;
char ftype[5], fauth[5]; char ftype[5], fauth[5];
updcrc = binhex_updcrc; updcrc = binhex_updcrc;
@ -118,9 +118,9 @@ unsigned char *bin_hdr;
transname(info + I_TYPEOFF, ftype, 4); transname(info + I_TYPEOFF, ftype, 4);
transname(info + I_AUTHOFF, fauth, 4); transname(info + I_AUTHOFF, fauth, 4);
(void)fprintf(stderr, (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, 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) { if(info_only) {
write_it = 0; write_it = 0;
} }
@ -147,13 +147,13 @@ unsigned char *bin_hdr;
} }
} }
void dd_arch(bin_hdr) void
unsigned char *bin_hdr; dd_arch (unsigned char *bin_hdr)
{ {
unsigned long data_size; uint32_t data_size;
unsigned long crc, filecrc; uint32_t crc, filecrc;
struct fileHdr f; struct dd_fileHdr f;
struct fileCHdr cf; struct dd_fileCHdr cf;
char locname[64]; char locname[64];
int i, nlength; int i, nlength;
@ -225,7 +225,7 @@ unsigned char *bin_hdr;
dd_chksum(f, dd_data_ptr); dd_chksum(f, dd_data_ptr);
dd_expand(cf, dd_data_ptr); dd_expand(cf, dd_data_ptr);
case DD_IVAL: case DD_IVAL:
dd_data_ptr += f.dataLength - CFILEHDRSIZE; dd_data_ptr += f.dataLength - CDD_FILEHDRSIZE;
break; break;
case DD_COPY: case DD_COPY:
dd_copy(f, dd_data_ptr); dd_copy(f, dd_data_ptr);
@ -281,8 +281,8 @@ unsigned char *bin_hdr;
} }
} }
static void dd_name(bin_hdr) static void
unsigned char *bin_hdr; dd_name (unsigned char *bin_hdr)
{ {
int nlength; int nlength;
unsigned char *extptr; unsigned char *extptr;
@ -316,26 +316,24 @@ unsigned char *bin_hdr;
bin_hdr[I_NAMEOFF] = nlength; bin_hdr[I_NAMEOFF] = nlength;
} }
static int dd_filehdr(f, cf, skip) static int
struct fileHdr *f; dd_filehdr (struct dd_fileHdr *f, struct dd_fileCHdr *cf, int skip)
struct fileCHdr *cf;
int skip;
{ {
register int i; register int i;
unsigned long crc; uint32_t crc;
int n, to_uncompress; int n, to_uncompress;
unsigned char *hdr; unsigned char *hdr;
char ftype[5], fauth[5]; char ftype[5], fauth[5];
unsigned long datalength, rsrclength; uint32_t datalength, rsrclength;
to_uncompress = DD_COPY; to_uncompress = DD_COPY;
hdr = dd_data_ptr; hdr = dd_data_ptr;
dd_data_ptr += FILEHDRSIZE; dd_data_ptr += DD_FILEHDRSIZE;
for(i = 0; i < INFOBYTES; i++) { for(i = 0; i < INFOBYTES; i++) {
info[i] = '\0'; info[i] = '\0';
} }
crc = INIT_CRC; crc = INIT_CRC;
crc = (*updcrc)(crc, hdr, FILEHDRSIZE - 2); crc = (*updcrc)(crc, hdr, DD_FILEHDRSIZE - 2);
f->hdrcrc = get2((char *)hdr + D_HDRCRC); f->hdrcrc = get2((char *)hdr + D_HDRCRC);
if(f->hdrcrc != crc) { if(f->hdrcrc != crc) {
@ -394,8 +392,8 @@ int skip;
transname(info + I_TYPEOFF, ftype, 4); transname(info + I_TYPEOFF, ftype, 4);
transname(info + I_AUTHOFF, fauth, 4); transname(info + I_AUTHOFF, fauth, 4);
(void)fprintf(stderr, (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)datalength, (long)rsrclength); text, ftype, fauth, (int32_t)datalength, (int32_t)rsrclength);
} }
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
@ -425,18 +423,18 @@ int skip;
return to_uncompress; return to_uncompress;
} }
static void dd_cfilehdr(f) static void
struct fileCHdr *f; dd_cfilehdr (struct dd_fileCHdr *f)
{ {
unsigned long crc; uint32_t crc;
unsigned char *hdr; unsigned char *hdr;
hdr = dd_data_ptr; hdr = dd_data_ptr;
dd_data_ptr += CFILEHDRSIZE; dd_data_ptr += CDD_FILEHDRSIZE;
crc = INIT_CRC; 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) { if(f->hdrcrc != crc) {
(void)fprintf(stderr, "Header CRC mismatch: got 0x%04x, need 0x%04x\n", (void)fprintf(stderr, "Header CRC mismatch: got 0x%04x, need 0x%04x\n",
f->hdrcrc & WORDMASK, (int)crc); f->hdrcrc & WORDMASK, (int)crc);
@ -474,14 +472,14 @@ struct fileCHdr *f;
} }
} }
static int dd_valid(dmethod, rmethod) static int
int dmethod, rmethod; dd_valid (int dmethod, int rmethod)
{ {
return dd_valid1(dmethod) | dd_valid1(rmethod); return dd_valid1(dmethod) | dd_valid1(rmethod);
} }
static int dd_valid1(method) static int
int method; dd_valid1 (int method)
{ {
switch(method) { switch(method) {
case nocomp: case nocomp:
@ -499,8 +497,8 @@ int method;
return 0; return 0;
} }
static char *dd_methname(n) static char *
int n; dd_methname (int n)
{ {
int i, nmeths; int i, nmeths;
nmeths = sizeof(methods) / sizeof(struct methodinfo); nmeths = sizeof(methods) / sizeof(struct methodinfo);
@ -512,13 +510,11 @@ int i, nmeths;
return NULL; return NULL;
} }
static unsigned long dd_checksum(init, buffer, length) static uint32_t
unsigned long init; dd_checksum (uint32_t init, char *buffer, uint32_t length)
char *buffer;
unsigned long length;
{ {
int i; int i;
unsigned long cks; uint32_t cks;
cks = init; cks = init;
for(i = 0; i < length; i++) { for(i = 0; i < length; i++) {
@ -527,14 +523,13 @@ unsigned long length;
return cks & WORDMASK; return cks & WORDMASK;
} }
static void dd_chksum(hdr, data) static void
struct fileHdr hdr; dd_chksum (struct dd_fileHdr hdr, unsigned char *data)
unsigned char *data;
{ {
unsigned long cks; uint32_t cks;
if(write_it) { if(write_it) {
cks = dd_checksum(INIT_CRC, (char *)data - CFILEHDRSIZE, cks = dd_checksum(INIT_CRC, (char *)data - CDD_FILEHDRSIZE,
hdr.dataLength); hdr.dataLength);
if(hdr.datacrc != cks) { if(hdr.datacrc != cks) {
(void)fprintf(stderr, (void)fprintf(stderr,
@ -548,13 +543,11 @@ unsigned char *data;
} }
} }
static unsigned long dd_checkor(init, buffer, length) static uint32_t
unsigned long init; dd_checkor (uint32_t init, char *buffer, uint32_t length)
char *buffer;
unsigned long length;
{ {
int i; int i;
unsigned long cks; uint32_t cks;
cks = init; cks = init;
for(i = 0; i < length; i++) { for(i = 0; i < length; i++) {
@ -563,10 +556,8 @@ unsigned long length;
return cks & WORDMASK; return cks & WORDMASK;
} }
static void dd_do_delta(out_ptr, nbytes, kind) static void
char *out_ptr; dd_do_delta (char *out_ptr, uint32_t nbytes, int kind)
unsigned long nbytes;
int kind;
{ {
switch(kind) { switch(kind) {
case 0: case 0:
@ -586,9 +577,8 @@ int kind;
} }
} }
static void dd_delta(out_ptr, nbytes) static void
char *out_ptr; dd_delta (char *out_ptr, uint32_t nbytes)
unsigned long nbytes;
{ {
int i, sum = 0; int i, sum = 0;
@ -598,9 +588,8 @@ unsigned long nbytes;
} }
} }
static void dd_delta3(out_ptr, nbytes) static void
char *out_ptr; dd_delta3 (char *out_ptr, uint32_t nbytes)
unsigned long nbytes;
{ {
int i, sum1 = 0, sum2 = 0, sum3 = 0; int i, sum1 = 0, sum2 = 0, sum3 = 0;
@ -621,11 +610,10 @@ unsigned long nbytes;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Archive only, no compression */ /* Archive only, no compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void dd_copy(hdr, data) static void
struct fileHdr hdr; dd_copy (struct dd_fileHdr hdr, unsigned char *data)
unsigned char *data;
{ {
unsigned long cks; uint32_t cks;
if(write_it) { if(write_it) {
start_info(info, hdr.rsrcLength, hdr.dataLength); start_info(info, hdr.rsrcLength, hdr.dataLength);
@ -673,9 +661,8 @@ unsigned char *data;
} }
} }
static void dd_copyfile(obytes, data) static void
unsigned long obytes; dd_copyfile (uint32_t obytes, unsigned char *data)
unsigned char *data;
{ {
if(obytes == 0) { if(obytes == 0) {
return; return;
@ -688,11 +675,10 @@ unsigned char *data;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Possible compression, and perhaps in an archive */ /* Possible compression, and perhaps in an archive */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void dd_expand(hdr, data) static void
struct fileCHdr hdr; dd_expand (struct dd_fileCHdr hdr, unsigned char *data)
unsigned char *data;
{ {
unsigned long cks; uint32_t cks;
char *out_buf; char *out_buf;
if(write_it) { if(write_it) {
@ -706,7 +692,7 @@ unsigned char *data;
} }
out_buf = out_buffer; out_buf = out_buffer;
dd_expandfile(hdr.dataLength, hdr.dataCLength, (int)hdr.datamethod, 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; data += hdr.dataCLength;
if(write_it) { if(write_it) {
if((hdr.info2 & 0x40) && (hdr.dataLength != 0)) { if((hdr.info2 & 0x40) && (hdr.dataLength != 0)) {
@ -731,7 +717,7 @@ unsigned char *data;
} }
out_buf = out_buffer; out_buf = out_buffer;
dd_expandfile(hdr.rsrcLength, hdr.rsrcCLength, (int)hdr.rsrcmethod, 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; data += hdr.rsrcCLength;
if(write_it) { if(write_it) {
if((hdr.info2 & 0x40) && (hdr.rsrcLength != 0)) { if((hdr.info2 & 0x40) && (hdr.rsrcLength != 0)) {
@ -754,14 +740,12 @@ unsigned char *data;
} }
} }
static void dd_expandfile(obytes, ibytes, method, kind, data, chksum) static void
unsigned long obytes, ibytes, chksum; dd_expandfile (uint32_t obytes, uint32_t ibytes, int method, int kind, unsigned char *data, uint32_t chksum)
int method, kind;
unsigned char *data;
{ {
int sub_method, m1, m2; int sub_method, m1, m2;
char *optr = out_ptr; char *optr = out_ptr;
unsigned long cksinit; uint32_t cksinit;
if(obytes == 0) { if(obytes == 0) {
if(verbose) { if(verbose) {
@ -855,9 +839,8 @@ unsigned char *data;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Method 0: no compression */ /* Method 0: no compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void dd_nocomp(obytes, data) static void
unsigned char *data; dd_nocomp (uint32_t obytes, unsigned char *data)
unsigned long obytes;
{ {
copy(out_ptr, (char *)data, (int)obytes); copy(out_ptr, (char *)data, (int)obytes);
} }
@ -865,14 +848,12 @@ unsigned long obytes;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Method 1: LZC compressed */ /* Method 1: LZC compressed */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void dd_lzc(ibytes, obytes, data, mb, chksum, ckinit) static void
unsigned char *data; dd_lzc (uint32_t ibytes, uint32_t obytes, unsigned char *data, int mb, uint32_t chksum, uint32_t ckinit)
unsigned long ibytes, obytes, chksum, ckinit;
int mb;
{ {
int i; int i;
char *out_buf; char *out_buf;
unsigned long cks; uint32_t cks;
out_buf = out_buffer; out_buf = out_buffer;
core_compress((char *)data); core_compress((char *)data);
@ -899,9 +880,8 @@ int mb;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Method 3: Run length encoding */ /* Method 3: Run length encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void dd_rle(ibytes, data) static void
unsigned char *data; dd_rle (uint32_t ibytes, unsigned char *data)
unsigned long ibytes;
{ {
int ch, lastch, n, i; int ch, lastch, n, i;
@ -930,9 +910,8 @@ unsigned long ibytes;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Method 4: Huffman encoding */ /* Method 4: Huffman encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void dd_huffman(ibytes, data) static void
unsigned char *data; dd_huffman (uint32_t ibytes, unsigned char *data)
unsigned long ibytes;
{ {
} }
#endif /* NOTIMPLEMENTED */ #endif /* NOTIMPLEMENTED */
@ -940,9 +919,8 @@ unsigned long ibytes;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Method 7: Slightly improved LZSS */ /* Method 7: Slightly improved LZSS */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void dd_lzss(data, chksum) static void
unsigned char *data; dd_lzss (unsigned char *data, uint32_t chksum)
unsigned long chksum;
{ {
int i, LZptr, LZbptr, LZlength; int i, LZptr, LZbptr, LZlength;
char *optr = out_ptr; char *optr = out_ptr;
@ -982,7 +960,7 @@ 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) { if(chksum != cks) {
(void)fprintf(stderr, (void)fprintf(stderr,
"Checksum error on fork: need 0x%04x, got 0x%04x\n", "Checksum error on fork: need 0x%04x, got 0x%04x\n",
@ -994,8 +972,8 @@ unsigned long chksum;
} }
} }
static int dd_getbits(n) static int
int n; dd_getbits (int n)
{ {
int r; int r;
@ -1014,15 +992,13 @@ int n;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Method 8: Compactor compatible compression */ /* Method 8: Compactor compatible compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void dd_cpt_compat(ibytes, obytes, data, sub_method, chksum) static void
unsigned char *data; dd_cpt_compat (uint32_t ibytes, uint32_t obytes, unsigned char *data, int sub_method, uint32_t chksum)
unsigned long ibytes, obytes, chksum;
int sub_method;
{ {
unsigned long cks; uint32_t cks;
char *optr = out_buffer; 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); cks = arc_updcrc(INIT_CRC, (unsigned char *)optr, (int)obytes);
if(chksum != cks) { if(chksum != cks) {
(void)fprintf(stderr, (void)fprintf(stderr,

View File

@ -1,3 +1,11 @@
#include "macunpack.h"
#ifdef DD
#include <stdint.h>
#ifdef DD_INTERNAL
#define MAGIC1 "DDAR" #define MAGIC1 "DDAR"
#define MAGIC2 "\253\315\000\124" #define MAGIC2 "\253\315\000\124"
@ -22,7 +30,7 @@
#define D_DATACRC 118 #define D_DATACRC 118
#define D_RSRCCRC 120 #define D_RSRCCRC 120
#define D_HDRCRC 122 #define D_HDRCRC 122
#define FILEHDRSIZE 124 #define DD_FILEHDRSIZE 124
/* Compressed file header */ /* Compressed file header */
#define C_MAGIC 0 #define C_MAGIC 0
@ -47,21 +55,21 @@
#define C_FILL2 58 #define C_FILL2 58
#define C_DATACRC2 78 #define C_DATACRC2 78
#define C_RSRCCRC2 80 #define C_RSRCCRC2 80
#define C_HDRCRC 82 #define DD_C_HDRCRC 82
#define CFILEHDRSIZE 84 #define CDD_FILEHDRSIZE 84
typedef long OSType; typedef int32_t OSType;
typedef struct fileHdr { /* 124 bytes */ typedef struct dd_fileHdr { /* 124 bytes */
unsigned char magic[4]; /* "DDAR" */ unsigned char magic[4]; /* "DDAR" */
unsigned char fill1[4]; /* ??? */ unsigned char fill1[4]; /* ??? */
unsigned char fName[64]; /* a STR63 */ unsigned char fName[64]; /* a STR63 */
unsigned char isdir; /* starts a directory? */ unsigned char isdir; /* starts a directory? */
unsigned char enddir; /* terminates a directory? */ unsigned char enddir; /* terminates a directory? */
unsigned long dataLength; /* lengths */ uint32_t dataLength; /* lengths */
unsigned long rsrcLength; uint32_t rsrcLength;
unsigned long creationDate; uint32_t creationDate;
unsigned long modDate; uint32_t modDate;
OSType fType; /* file type */ OSType fType; /* file type */
OSType fCreator; /* er... */ OSType fCreator; /* er... */
unsigned short FndrFlags; /* copy of Finder flags. For our unsigned short FndrFlags; /* copy of Finder flags. For our
@ -71,20 +79,20 @@ typedef struct fileHdr { /* 124 bytes */
unsigned short datacrc; /* checksum */ unsigned short datacrc; /* checksum */
unsigned short rsrccrc; unsigned short rsrccrc;
unsigned short hdrcrc; /* true crc */ 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 char magic[4]; /* "\253\315\000\124" */
unsigned long dataLength; /* lengths */ uint32_t dataLength; /* lengths */
unsigned long dataCLength; uint32_t dataCLength;
unsigned long rsrcLength; uint32_t rsrcLength;
unsigned long rsrcCLength; uint32_t rsrcCLength;
unsigned char datamethod; /* compression method used */ unsigned char datamethod; /* compression method used */
unsigned char rsrcmethod; unsigned char rsrcmethod;
unsigned char info1; /* flags ??? */ unsigned char info1; /* flags ??? */
unsigned char fill3; unsigned char fill3;
unsigned long modDate; uint32_t modDate;
unsigned long creationDate; uint32_t creationDate;
OSType fType; /* file type */ OSType fType; /* file type */
OSType fCreator; /* er... */ OSType fCreator; /* er... */
unsigned short FndrFlags; /* copy of Finder flags. For our unsigned short FndrFlags; /* copy of Finder flags. For our
@ -101,7 +109,7 @@ typedef struct fileCHdr { /* 84 bytes */
unsigned short datacrc2; /* other checksum */ unsigned short datacrc2; /* other checksum */
unsigned short rsrccrc2; unsigned short rsrccrc2;
unsigned short hdrcrc; /* true crc */ unsigned short hdrcrc; /* true crc */
} fileCHdr; } dd_fileCHdr;
#define DD_FILE 0 #define DD_FILE 0
#define DD_COPY 1 #define DD_COPY 1
@ -123,3 +131,7 @@ typedef struct fileCHdr { /* 84 bytes */
#define ESC 0x144 /* Repeat packing escape */ #define ESC 0x144 /* Repeat packing escape */
#endif
void dd_file (unsigned char *bin_hdr);
void dd_arch (unsigned char *bin_hdr);
#endif

View File

@ -1,3 +1,7 @@
#include "de_compress.h"
#include <stdlib.h>
#include "macunpack.h" #include "macunpack.h"
#ifdef SIT #ifdef SIT
#define DECOMPRESS #define DECOMPRESS
@ -18,20 +22,20 @@
static int n_bits; /* number of bits/code */ static int n_bits; /* number of bits/code */
static int maxbits; /* user settable max # bits/code */ static int maxbits; /* user settable max # bits/code */
static long maxcode; /* maximum code, given n_bits */ static int32_t maxcode; /* maximum code, given n_bits */
static long maxmaxcode; /* should NEVER generate this code */ static int32_t maxmaxcode; /* should NEVER generate this code */
# define MAXCODE(n_bits) ((1 << (n_bits)) - 1) # define MAXCODE(n_bits) ((1 << (n_bits)) - 1)
static long htab [HSIZE]; static int32_t htab [HSIZE];
static unsigned short codetab [HSIZE]; static unsigned short codetab [HSIZE];
#define tab_prefixof(i) codetab[i] #define tab_prefixof(i) codetab[i]
#define tab_suffixof(i) ((unsigned char *)(htab))[i] #define tab_suffixof(i) ((unsigned char *)(htab))[i]
#define de_stack ((unsigned char *)&tab_suffixof(1<<BITS)) #define de_stack ((unsigned char *)&tab_suffixof(1<<BITS))
static long free_ent = 0; /* first unused entry */ static int32_t free_ent = 0; /* first unused entry */
static long getcode(); static int32_t getcode(void);
static int clear_flg = 0; static int clear_flg = 0;
@ -44,13 +48,11 @@ static int clear_flg = 0;
static int toread; static int toread;
void de_compress(ibytes, mb) void de_compress(uint32_t ibytes, int mb)
unsigned long ibytes;
int mb;
{ {
register unsigned char *stackp; register unsigned char *stackp;
register int finchar; register int finchar;
register long code, oldcode, incode; register int32_t code, oldcode, incode;
toread = ibytes; toread = ibytes;
maxbits = mb; maxbits = mb;
@ -122,12 +124,13 @@ static unsigned char rmask[9] =
static int get_core_bytes; static int get_core_bytes;
static char *core_ptr; static char *core_ptr;
static int file_bytes(); static int file_bytes(char *buf, int length);
static int core_bytes(); static int core_bytes(char *buf, int length);
static long getcode() static int32_t
getcode (void)
{ {
register long code; register int32_t code;
static int offset = 0, size = 0; static int offset = 0, size = 0;
static unsigned char buf[BITS]; static unsigned char buf[BITS];
register int r_off, bits; register int r_off, bits;
@ -194,16 +197,14 @@ static long getcode()
return code; return code;
} }
static int file_bytes(buf, length) static int
char *buf; file_bytes (char *buf, int length)
int length;
{ {
return fread(buf, 1, length, infp); return fread(buf, 1, length, infp);
} }
static int core_bytes(buf, length) static int
char *buf; core_bytes (char *buf, int length)
int length;
{ {
int i; int i;
@ -213,8 +214,7 @@ int length;
return length; return length;
} }
void core_compress(ptr) void core_compress(char* ptr)
char *ptr;
{ {
core_ptr = ptr; core_ptr = ptr;
get_core_bytes = ptr != NULL; get_core_bytes = ptr != NULL;

4
macunpack/de_compress.h Normal file
View File

@ -0,0 +1,4 @@
#include <stdint.h>
void de_compress(uint32_t ibytes, int mb);
void core_compress(char* ptr);

View File

@ -1,3 +1,5 @@
#include "de_huffman.h"
#include "macunpack.h" #include "macunpack.h"
#ifdef JDW #ifdef JDW
#define DEHUFFMAN #define DEHUFFMAN
@ -21,19 +23,19 @@
#include "huffman.h" #include "huffman.h"
#include "../util/util.h" #include "../util/util.h"
int (*get_bit)(); int (*get_bit)(void);
int bytesread; int bytesread;
/* 515 because StuffIt Classic needs more than the needed 511 */ /* 515 because StuffIt Classic needs more than the needed 511 */
struct node nodelist[515]; struct node nodelist[515];
static int getbit_be(); static int getbit_be(void);
static int getbit_le(); static int getbit_le(void);
static int getdecodebyte(); static int getdecodebyte(void);
static node *nodeptr, *read_sub_tree(); static node *nodeptr, *read_sub_tree(void);
static int bit; static int bit;
void de_huffman(unsigned long obytes) void de_huffman(uint32_t obytes)
{ {
while(obytes != 0) { while(obytes != 0) {
*out_ptr++ = gethuffbyte(nodelist); *out_ptr++ = gethuffbyte(nodelist);
@ -60,7 +62,8 @@ void set_huffman(int endian)
} }
} }
void read_tree() void
read_tree (void)
{ {
nodeptr = nodelist; nodeptr = nodelist;
bit = 0; /* put us on a boundary */ bit = 0; /* put us on a boundary */
@ -69,7 +72,7 @@ void read_tree()
/* This routine recursively reads the Huffman encoding table and builds /* This routine recursively reads the Huffman encoding table and builds
a decoding tree. */ a decoding tree. */
static node *read_sub_tree() static node *read_sub_tree(void)
{ {
node *np; node *np;
@ -86,7 +89,8 @@ static node *read_sub_tree()
} }
/* This routine returns the next bit in the input stream (MSB first) */ /* This routine returns the next bit in the input stream (MSB first) */
static int getbit_be() static int
getbit_be (void)
{ {
static int b; static int b;
@ -100,7 +104,8 @@ static int getbit_be()
} }
/* This routine returns the next bit in the input stream (LSB first) */ /* This routine returns the next bit in the input stream (LSB first) */
static int getbit_le() static int
getbit_le (void)
{ {
static int b; static int b;
@ -113,7 +118,8 @@ static int getbit_le()
return (b >> (7 - bit)) & 1; return (b >> (7 - bit)) & 1;
} }
void clrhuff() void
clrhuff (void)
{ {
bit = 0; bit = 0;
} }
@ -129,12 +135,14 @@ int gethuffbyte(node *l_nodelist)
return np->byte; return np->byte;
} }
int getihuffbyte() int
getihuffbyte (void)
{ {
return gethuffbyte(nodelist); return gethuffbyte(nodelist);
} }
static int getdecodebyte() static int
getdecodebyte (void)
{ {
register int i, b; register int i, b;

6
macunpack/de_huffman.h Normal file
View File

@ -0,0 +1,6 @@
#include <stdint.h>
void set_huffman(int endian);
void read_tree(void);
void de_huffman(uint32_t obytes);
void de_huffman_end(unsigned int term);

View File

@ -1,3 +1,5 @@
#include "de_lzah.h"
#include "macunpack.h" #include "macunpack.h"
#ifdef SIT #ifdef SIT
#define DELZAH #define DELZAH
@ -77,13 +79,13 @@ static short HuffLength[] = {
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 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}; 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_inithuf(void);
static void lzah_reorder(); static void lzah_reorder(void);
static void lzah_move(); static void lzah_move(int *p, int *q, int n);
static void lzah_getbit(); static void lzah_getbit(void);
static void lzah_outchar(); static void lzah_outchar(int ch);
static char lzah_buf[4096]; static char lzah_buf[4096];
static int lzah_bufptr; static int lzah_bufptr;
@ -93,8 +95,7 @@ static int Frequ[1000];
static int ForwTree[1000]; static int ForwTree[1000];
static int BackTree[1000]; static int BackTree[1000];
void de_lzah(obytes) void de_lzah(uint32_t obytes)
unsigned long obytes;
{ {
int i, i1, j, ch, byte, offs, skip; 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; int i, j;
@ -199,7 +201,8 @@ static void lzah_inithuf()
BackTree[T - 1] = 0; BackTree[T - 1] = 0;
} }
static void lzah_reorder() static void
lzah_reorder (void)
{ {
int i, j, k, l; int i, j, k, l;
@ -236,8 +239,8 @@ static void lzah_reorder()
} }
} }
static void lzah_move(p, q, n) static void lzah_move(int *p, int *q, int n)
int *p, *q, n;
{ {
if(p > q) { if(p > q) {
while(n-- > 0) { while(n-- > 0) {
@ -252,7 +255,8 @@ int *p, *q, n;
} }
} }
static void lzah_getbit() static void
lzah_getbit (void)
{ {
if(lzah_bitsavail != 0) { if(lzah_bitsavail != 0) {
lzah_bits = lzah_bits + lzah_bits; lzah_bits = lzah_bits + lzah_bits;
@ -263,8 +267,8 @@ static void lzah_getbit()
} }
} }
static void lzah_outchar(ch) static void
char ch; lzah_outchar (int ch)
{ {
*out_ptr++ = ch; *out_ptr++ = ch;
lzah_buf[lzah_bufptr++] = ch; lzah_buf[lzah_bufptr++] = ch;

10
macunpack/de_lzah.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef DE_LZAH_H
#define DE_LZAH_H
#include <stdint.h>
extern void de_lzah(uint32_t obytes);
extern unsigned char (*lzah_getbyte)(void);
extern void de_lzh(int32_t ibytes, int32_t obytes, char **data, int bits);
#endif

View File

@ -19,16 +19,12 @@
static int decoded; static int decoded;
static int bitsused; static int bitsused;
static unsigned int blocksize; static unsigned int blocksize;
static unsigned int decode_c(); static unsigned int decode_c(void);
static unsigned int decode_p(); static unsigned int decode_p(void);
static void make_table(); static void make_table(int nchar, unsigned char bitlen[], int tablebits, unsigned int table[]);
/* lzh compression */ /* lzh compression */
void de_lzh(ibytes, obytes, data, bits) void de_lzh(int32_t ibytes, int32_t obytes, char **data, int bits)
long ibytes;
long obytes;
char **data;
int bits;
{ {
unsigned int i, r, c; unsigned int i, r, c;
int remains; 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 char c_len[NC], pt_len[NPT];
static unsigned int c_table[4096], pt_table[256]; static unsigned int c_table[4096], pt_table[256];
static void read_pt_len(nn, nbit, i_special) static void
int nn; read_pt_len (int nn, int nbit, int i_special)
int nbit;
int i_special;
{ {
int i, c, n; int i, c, n;
unsigned int mask; 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; int i, c, n;
unsigned int mask; 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; unsigned int j, mask;
@ -213,7 +209,8 @@ static unsigned int decode_c()
return j; return j;
} }
static unsigned int decode_p() static unsigned int
decode_p (void)
{ {
unsigned int j, mask; unsigned int j, mask;
@ -236,11 +233,8 @@ static unsigned int decode_p()
return j; return j;
} }
static void make_table(nchar, bitlen, tablebits, table) static void
int nchar; make_table (int nchar, unsigned char bitlen[], int tablebits, unsigned int table[])
unsigned char bitlen[];
int tablebits;
unsigned int table[];
{ {
unsigned int count[17], weight[17], start[18], *p; unsigned int count[17], weight[17], start[18], *p;
unsigned int i, k, len, ch, jutbits, avail, nextcode, mask; unsigned int i, k, len, ch, jutbits, avail, nextcode, mask;

View File

@ -1,11 +1,14 @@
#include "macunpack.h" #include "macunpack.h"
#ifdef DIA #ifdef DIA
#define DIA_INTERNAL
#include "dia.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "globals.h" #include "globals.h"
#include "dia.h"
#include "../util/curtime.h" #include "../util/curtime.h"
#include "../util/masks.h" #include "../util/masks.h"
#include "../util/transname.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "../fileio/kind.h" #include "../fileio/kind.h"
@ -26,17 +29,17 @@ static int dia_LZtab[BCHUNKSIZE];
static unsigned char *dia_bit_base; static unsigned char *dia_bit_base;
static int dia_imask; static int dia_imask;
static void dia_folder(); static void dia_folder(unsigned char *name);
static void dia_file(); static void dia_file(int indicator, unsigned char *name);
static void dia_getlength(); static void dia_getlength(int nblocks);
static void dia_skipfork(); static void dia_skipfork(int nblocks);
static void dia_getfork(); static void dia_getfork(int nblocks);
static void dia_getblock(); static void dia_getblock(unsigned char **archive_ptr, unsigned char **block_ptr);
static int dia_decode(); static int dia_decode(unsigned char *ibuff, unsigned char *obuff, int in_length);
static int dia_prevbit(); static int dia_prevbit(void);
void dia(bin_hdr) void
unsigned char *bin_hdr; dia (unsigned char *bin_hdr)
{ {
int i, folder, nlength; int i, folder, nlength;
unsigned char hdr; unsigned char hdr;
@ -109,11 +112,11 @@ unsigned char *bin_hdr;
free((char *)header); free((char *)header);
} }
static void dia_folder(name) static void
unsigned char *name; dia_folder (unsigned char *name)
{ {
unsigned char lname[32]; unsigned char lname[32];
int i, length, doit; int i, length, doit = 0;
unsigned char indicator, *old_ptr; unsigned char indicator, *old_ptr;
if(name != NULL) { if(name != NULL) {
@ -191,8 +194,8 @@ unsigned char *name;
} }
} }
static void dia_file(indicator, name) static void
unsigned char indicator, *name; dia_file (int indicator, unsigned char *name)
{ {
unsigned char lname[32]; unsigned char lname[32];
int i, length, doit; int i, length, doit;
@ -202,7 +205,7 @@ unsigned char indicator, *name;
int dataLength, rsrcLength; int dataLength, rsrcLength;
int cdataLength, crsrcLength; int cdataLength, crsrcLength;
int dataMethod, rsrcMethod; int dataMethod, rsrcMethod;
unsigned long curtime; uint32_t curtime;
if(name != NULL) { if(name != NULL) {
for(i = 0; i < INFOBYTES; i++) { for(i = 0; i < INFOBYTES; i++) {
@ -230,7 +233,7 @@ unsigned char indicator, *name;
info[I_MTIMOFF + i] = *dia_header_ptr++; info[I_MTIMOFF + i] = *dia_header_ptr++;
} }
} else { } 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_CTIMOFF, curtime);
put4(info + I_MTIMOFF, curtime); put4(info + I_MTIMOFF, curtime);
} }
@ -266,16 +269,16 @@ unsigned char indicator, *name;
crsrcLength = dia_cforklength; crsrcLength = dia_cforklength;
rsrcMethod = dia_method; rsrcMethod = dia_method;
dia_archive_ptr = old_archive_ptr; dia_archive_ptr = old_archive_ptr;
put4(info + I_DLENOFF, (unsigned long)dataLength); put4(info + I_DLENOFF, (uint32_t)dataLength);
put4(info + I_RLENOFF, (unsigned long)rsrcLength); put4(info + I_RLENOFF, (uint32_t)rsrcLength);
if(list) { if(list) {
transname(info + I_NAMEOFF + 1, (char *)lname, length); transname(info + I_NAMEOFF + 1, (char *)lname, length);
do_indent(indent); do_indent(indent);
transname(info + I_TYPEOFF, ftype, 4); transname(info + I_TYPEOFF, ftype, 4);
transname(info + I_AUTHOFF, fauth, 4); transname(info + I_AUTHOFF, fauth, 4);
(void)fprintf(stderr, (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",
lname, ftype, fauth, (long)dataLength, (long)rsrcLength); lname, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength);
if(info_only) { if(info_only) {
doit = 0; doit = 0;
} else { } else {
@ -296,7 +299,7 @@ unsigned char indicator, *name;
} }
if(doit) { if(doit) {
define_name((char *)lname); define_name((char *)lname);
start_info(info, (unsigned long)rsrcLength, (unsigned long)dataLength); start_info(info, (uint32_t)rsrcLength, (uint32_t)dataLength);
} }
if(verbose) { if(verbose) {
(void)fprintf(stderr, "\tData: "); (void)fprintf(stderr, "\tData: ");
@ -346,8 +349,8 @@ unsigned char indicator, *name;
} }
} }
static void dia_getlength(nblocks) static void
int nblocks; dia_getlength (int nblocks)
{ {
int length; int length;
unsigned char *arch_ptr, *block_ptr; unsigned char *arch_ptr, *block_ptr;
@ -379,8 +382,8 @@ int nblocks;
} }
} }
static void dia_skipfork(nblocks) static void
int nblocks; dia_skipfork (int nblocks)
{ {
int length; int length;
@ -393,16 +396,16 @@ int nblocks;
} }
} }
static void dia_getfork(nblocks) static void
int nblocks; dia_getfork (int nblocks)
{ {
while(nblocks-- > 0) { while(nblocks-- > 0) {
dia_getblock(&dia_archive_ptr, (unsigned char **)&out_ptr); dia_getblock(&dia_archive_ptr, (unsigned char **)&out_ptr);
} }
} }
static void dia_getblock(archive_ptr, block_ptr) static void
unsigned char **archive_ptr, **block_ptr; dia_getblock (unsigned char **archive_ptr, unsigned char **block_ptr)
{ {
int length, i; int length, i;
unsigned char *arch_ptr, *bl_ptr; unsigned char *arch_ptr, *bl_ptr;
@ -425,8 +428,8 @@ unsigned char **archive_ptr, **block_ptr;
*archive_ptr += length + 2; *archive_ptr += length + 2;
} }
static int dia_decode(ibuff, obuff, in_length) static int
unsigned char *ibuff, *obuff; int in_length; dia_decode (unsigned char *ibuff, unsigned char *obuff, int in_length)
{ {
int nbits, set_zero, i, j; int nbits, set_zero, i, j;
unsigned char *bitbuf_ptr; unsigned char *bitbuf_ptr;
@ -539,7 +542,8 @@ unsigned char *ibuff, *obuff; int in_length;
return out_ptr - obuff; return out_ptr - obuff;
} }
static int dia_prevbit() static int
dia_prevbit (void)
{ {
int c; int c;

View File

@ -1,3 +1,7 @@
#include "macunpack.h"
#ifdef DIA
#ifdef DIA_INTERNAL
#define IS_FOLDER 0x80 #define IS_FOLDER 0x80
#define F_INFO 0x40 #define F_INFO 0x40
#define VOLUME 0x30 #define VOLUME 0x30
@ -20,3 +24,8 @@
#define NOCOMP 1 #define NOCOMP 1
#define COMP 2 #define COMP 2
#endif
void dia (unsigned char *bin_hdr);
#endif

View File

@ -1,16 +1,19 @@
#include "dir.h"
#include <stdlib.h> #include <stdlib.h>
#include "globals.h" #include "globals.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "../util/util.h" #include "../util/util.h"
#include "../util/masks.h" #include "../util/masks.h"
#include "../util/transname.h"
static char *dir_stack; static char *dir_stack;
static int dir_ptr = -64; static int dir_ptr = -64;
static int dir_max; static int dir_max;
void dir(hdr) void
char *hdr; dir (char *hdr)
{ {
int doit; int doit;

1
macunpack/dir.h Normal file
View File

@ -0,0 +1 @@
void dir (char *hdr);

View File

@ -13,8 +13,8 @@ int in_rsrc_size = -1;
int in_ds, in_rs, ds_skip, rs_skip; int in_ds, in_rs, ds_skip, rs_skip;
#ifdef SCAN #ifdef SCAN
void do_error(string) void
char *string; do_error (char *string)
{ {
do_idf(string, ERROR); do_idf(string, ERROR);
} }

View File

@ -1,8 +1,6 @@
#include <stdio.h> #include <stdio.h>
extern void exit(); void do_error (char *string);
extern void transname();
extern void do_error();
extern char info[]; extern char info[];
extern char text[]; extern char text[];

View File

@ -6,10 +6,10 @@ typedef struct node {
struct node *one, *zero; struct node *one, *zero;
} node; } node;
extern int (*get_bit)(); extern int (*get_bit)(void);
extern void clrhuff(); extern void clrhuff(void);
int gethuffbyte(node *l_nodelist); int gethuffbyte(node *l_nodelist);
int getihuffbyte(); int getihuffbyte(void);
extern struct node nodelist[]; extern struct node nodelist[];
extern int bytesread; extern int bytesread;

View File

@ -1,24 +1,23 @@
#include "macunpack.h" #include "macunpack.h"
#ifdef JDW #ifdef JDW
#define JDW_INTERNAL
#include "jdw.h" #include "jdw.h"
#include "globals.h" #include "globals.h"
#include "huffman.h" #include "huffman.h"
#include "de_huffman.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../util/util.h" #include "../util/util.h"
#include "../util/transname.h"
#include "../util/masks.h" #include "../util/masks.h"
extern void de_huffman(); static void jdw_wrfile(uint32_t rsrcLength, uint32_t dataLength);
extern void set_huffman(); static void jdw_wrfork(uint32_t length);
extern void read_tree(); static void jdw_block(int olength);
extern void clrhuff();
static void jdw_wrfile(); void
static void jdw_wrfork(); jdw (uint32_t ibytes)
static void jdw_block();
void jdw(ibytes)
unsigned long ibytes;
{ {
char fauth[5], ftype[5]; char fauth[5], ftype[5];
int filel, i; int filel, i;
@ -67,8 +66,8 @@ unsigned long ibytes;
transname(info + I_AUTHOFF, fauth, 4); transname(info + I_AUTHOFF, fauth, 4);
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (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)dataLength, (long)rsrcLength); text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength);
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
} }
@ -78,11 +77,11 @@ unsigned long ibytes;
(void)fputc('\n', stderr); (void)fputc('\n', stderr);
} }
} }
jdw_wrfile((unsigned long)rsrcLength, (unsigned long)dataLength); jdw_wrfile((uint32_t)rsrcLength, (uint32_t)dataLength);
} }
static void jdw_wrfile(rsrcLength, dataLength) static void
unsigned long rsrcLength, dataLength; jdw_wrfile (uint32_t rsrcLength, uint32_t dataLength)
{ {
if(write_it) { if(write_it) {
define_name(text); define_name(text);
@ -108,11 +107,11 @@ unsigned long rsrcLength, dataLength;
} }
} }
static void jdw_wrfork(length) static void
unsigned long length; jdw_wrfork (uint32_t length)
{ {
int olength, ilength, i; int olength, ilength, i;
unsigned long origlength, comprlength; uint32_t origlength, comprlength;
if(length == 0) { if(length == 0) {
(void)fprintf(stderr, "empty"); (void)fprintf(stderr, "empty");
@ -141,8 +140,8 @@ unsigned long length;
} }
} }
static void jdw_block(olength) static void
int olength; jdw_block (int olength)
{ {
bytesread = 0; bytesread = 0;
read_tree(); read_tree();
@ -152,7 +151,7 @@ int olength;
bytesread++; bytesread++;
} }
clrhuff(); clrhuff();
de_huffman((unsigned long)olength); de_huffman((uint32_t)olength);
} }
#else /* JDW */ #else /* JDW */
int jdw; /* keep lint and some compilers happy */ int jdw; /* keep lint and some compilers happy */

View File

@ -1,3 +1,9 @@
#include "macunpack.h"
#ifdef JDW
#ifdef JDW_INTERNAL
#include <stdint.h>
#define J_MAGIC 0 #define J_MAGIC 0
#define J_TYPE 6 #define J_TYPE 6
#define J_AUTH 10 #define J_AUTH 10
@ -8,16 +14,19 @@
#define J_MTIME 34 #define J_MTIME 34
#define J_FLENGTH 38 #define J_FLENGTH 38
typedef struct fileHdr { typedef struct jdw_fileHdr {
char magic[6]; char magic[6];
unsigned long type; uint32_t type;
unsigned long auth; uint32_t auth;
char finfo[8]; char finfo[8];
unsigned long dataLength; uint32_t dataLength;
unsigned long rsrcLength; uint32_t rsrcLength;
unsigned long ctime; uint32_t ctime;
unsigned long mtime; uint32_t mtime;
char flength; char flength;
char fname[32]; /* actually flength */ char fname[32]; /* actually flength */
} fileHdr; } jdw_fileHdr;
#endif
void jdw (uint32_t ibytes);
#endif

View File

@ -1,23 +1,25 @@
#include "macunpack.h" #include "macunpack.h"
#ifdef LZC #ifdef LZC
#include <string.h> #define LZC_INTERNAL
#include "globals.h"
#include "lzc.h" #include "lzc.h"
#include <string.h>
#include <stdlib.h>
#include "globals.h"
#include "../util/util.h" #include "../util/util.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "../util/masks.h" #include "../util/masks.h"
#include "../util/transname.h"
#include "de_compress.h"
#include "mcb.h"
extern void de_compress(); static void lzc_zivm(char *ohdr);
extern void core_compress(); static void lzc_wrfile(uint32_t obytes, uint32_t ibytes);
extern void mcb(); static void lzc_zivu(char *ohdr);
static void lzc_zivm(); void
static void lzc_wrfile(); lzc (char *ohdr)
static void lzc_zivu();
void lzc(ohdr)
char *ohdr;
{ {
core_compress((char *)NULL); core_compress((char *)NULL);
if(!strncmp(ohdr + I_TYPEOFF, "ZIVM", 4)) { if(!strncmp(ohdr + I_TYPEOFF, "ZIVM", 4)) {
@ -27,11 +29,11 @@ char *ohdr;
} }
} }
static void lzc_zivm(ohdr) static void
char *ohdr; lzc_zivm (char *ohdr)
{ {
char hdr[HEADERBYTES]; char hdr[HEADERBYTES];
unsigned long dataLength, rsrcLength, dataCLength, rsrcCLength; uint32_t dataLength, rsrcLength, dataCLength, rsrcCLength;
char ftype[5], fauth[5]; char ftype[5], fauth[5];
if(fread(hdr, 1, HEADERBYTES, infp) != HEADERBYTES) { if(fread(hdr, 1, HEADERBYTES, infp) != HEADERBYTES) {
@ -69,8 +71,8 @@ char *ohdr;
transname(hdr + C_AUTHOFF, fauth, 4); transname(hdr + C_AUTHOFF, fauth, 4);
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (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)dataLength, (long)rsrcLength); text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength);
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
} }
@ -109,8 +111,8 @@ char *ohdr;
} }
} }
static void lzc_wrfile(obytes, ibytes) static void
unsigned long obytes, ibytes; lzc_wrfile (uint32_t obytes, uint32_t ibytes)
{ {
int n, nbits; int n, nbits;
char subheader[3]; char subheader[3];
@ -183,12 +185,12 @@ unsigned long obytes, ibytes;
} }
} }
static void lzc_zivu(ohdr) static void
char *ohdr; lzc_zivu (char *ohdr)
{ {
(void)fprintf(stderr, (void)fprintf(stderr,
"\tMacCompress(Unix) not yet implemented, copied as MacBinary\n"); "\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); in_ds + in_rs);
} }
#else /* LZC */ #else /* LZC */

View File

@ -1,3 +1,9 @@
#include "macunpack.h"
#ifdef LZC
#ifdef LZC_INTERNAL
#include <stdint.h>
#define HEADERBYTES 48 #define HEADERBYTES 48
#define MAGIC1 "\253\315\000\060" #define MAGIC1 "\253\315\000\060"
#define MAGIC2 "\037\235" #define MAGIC2 "\037\235"
@ -12,17 +18,20 @@
#define C_AUTHOFF 36 #define C_AUTHOFF 36
#define C_FLAGOFF 40 #define C_FLAGOFF 40
typedef struct fileHdr { typedef struct lzc_fileHdr {
unsigned long magic1; uint32_t magic1;
unsigned long dataLength; uint32_t dataLength;
unsigned long dataCLength; uint32_t dataCLength;
unsigned long rsrcLength; uint32_t rsrcLength;
unsigned long rsrcCLength; uint32_t rsrcCLength;
unsigned long unknown1; uint32_t unknown1;
unsigned long mtime; uint32_t mtime;
unsigned long ctime; uint32_t ctime;
unsigned long filetype; uint32_t filetype;
unsigned long fileauth; uint32_t fileauth;
unsigned long flag1; uint32_t flag1;
unsigned long flag2; uint32_t flag2;
} fileHdr; } lzc_fileHdr;
#endif
void lzc (char *ohdr);
#endif

View File

@ -1,4 +1,7 @@
#include "macunpack.h" #include "macunpack.h"
#define LZH_INTERNAL
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "globals.h" #include "globals.h"
@ -7,8 +10,10 @@
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../util/masks.h" #include "../util/masks.h"
#include "../util/transname.h"
#include "../util/util.h" #include "../util/util.h"
#include "bits_be.h" #include "bits_be.h"
#include "de_lzah.h"
#define LZ5LOOKAHEAD 18 /* look ahead buffer size for LArc */ #define LZ5LOOKAHEAD 18 /* look ahead buffer size for LArc */
#define LZ5BUFFSIZE 8192 #define LZ5BUFFSIZE 8192
@ -18,10 +23,6 @@
#define LZSMASK 4095 #define LZSMASK 4095
#define LZBUFFSIZE 8192 /* Max of above buffsizes */ #define LZBUFFSIZE 8192 /* Max of above buffsizes */
extern void de_lzah();
extern unsigned char (*lzah_getbyte)();
extern void de_lzh();
typedef struct methodinfo { typedef struct methodinfo {
char *name; char *name;
int number; int number;
@ -51,31 +52,31 @@ static char *lzh_current;
static char *tmp_out_ptr; static char *tmp_out_ptr;
static char lzh_lzbuf[LZBUFFSIZE]; static char lzh_lzbuf[LZBUFFSIZE];
static int lzh_filehdr(); static int lzh_filehdr(struct lzh_fileHdr *f);
static int lzh_checkm(); static int lzh_checkm(struct lzh_fileHdr *f);
static char *lzh_methname(); static char *lzh_methname(int n);
static void lzh_wrfile(); static void lzh_wrfile(struct lzh_fileHdr *filehdr, int method);
static void lzh_skip(); static void lzh_skip(struct lzh_fileHdr *filehdr);
static void lzh_nocomp(); static void lzh_nocomp(uint32_t obytes);
#ifdef UNTESTED #ifdef UNTESTED
static void lzh_lzss1(); static void lzh_lzss1(uint32_t obytes);
static void lzh_lzss2(); static void lzh_lzss2(uint32_t obytes);
#endif /* UNTESTED */ #endif /* UNTESTED */
static void lzh_lzah(); static void lzh_lzah(uint32_t obytes);
static unsigned char lzh_getbyte(); static unsigned char lzh_getbyte(void);
#ifdef UNDEF #ifdef UNDEF
static void lzh_lh2(); static void lzh_lh2(uint32_t obytes);
static void lzh_lh3(); static void lzh_lh3(uint32_t obytes);
#endif /* UNDEF */ #endif /* UNDEF */
#ifdef UNTESTED #ifdef UNTESTED
static void lzh_lzh12(); static void lzh_lzh12(uint32_t obytes);
#endif /* UNTESTED */ #endif /* UNTESTED */
static void lzh_lzh13(); static void lzh_lzh13(uint32_t obytes);
void lzh(kind) void
int kind; lzh (int kind)
{ {
struct fileHdr filehdr; struct lzh_fileHdr filehdr;
int m, i, j; int m, i, j;
char loc_name[64]; char loc_name[64];
char dirinfo[INFOBYTES]; char dirinfo[INFOBYTES];
@ -213,8 +214,8 @@ int kind;
} }
} }
static int lzh_filehdr(f) static int
struct fileHdr *f; lzh_filehdr (struct lzh_fileHdr *f)
{ {
register int i; register int i;
char *hdr; char *hdr;
@ -335,8 +336,8 @@ struct fileHdr *f;
return 1; return 1;
} }
static int lzh_checkm(f) static int
struct fileHdr *f; lzh_checkm (struct lzh_fileHdr *f)
{ {
int i, nummeth; int i, nummeth;
char *meth; char *meth;
@ -351,8 +352,8 @@ struct fileHdr *f;
return -1; return -1;
} }
static char *lzh_methname(n) static char *
int n; lzh_methname (int n)
{ {
if(n > sizeof(methods) / sizeof(struct methodinfo)) { if(n > sizeof(methods) / sizeof(struct methodinfo)) {
return NULL; return NULL;
@ -360,15 +361,14 @@ int n;
return methods[n].name; return methods[n].name;
} }
static void lzh_wrfile(filehdr, method) static void
struct fileHdr *filehdr; lzh_wrfile (struct lzh_fileHdr *filehdr, int method)
int method;
{ {
char ftype[5], fauth[5]; char ftype[5], fauth[5];
int rsrcLength, dataLength; int rsrcLength, dataLength;
int doit; int doit;
char *mname; char *mname;
unsigned long crc; uint32_t crc;
if(filehdr->upsize > lzh_filesize) { if(filehdr->upsize > lzh_filesize) {
if(lzh_filesize == 0) { if(lzh_filesize == 0) {
@ -383,37 +383,37 @@ int method;
} }
switch(method) { switch(method) {
case lz4: case lz4:
lzh_nocomp((unsigned long)128); lzh_nocomp((uint32_t)128);
break; break;
#ifdef UNTESTED #ifdef UNTESTED
case lz5: case lz5:
lzh_lzss1((unsigned long)128); lzh_lzss1((uint32_t)128);
break; break;
case lzs: case lzs:
lzh_lzss2((unsigned long)128); lzh_lzss2((uint32_t)128);
break; break;
#endif /* UNTESTED */ #endif /* UNTESTED */
case lh0: case lh0:
lzh_nocomp((unsigned long)128); lzh_nocomp((uint32_t)128);
break; break;
case lh1: case lh1:
lzh_lzah((unsigned long)128); lzh_lzah((uint32_t)128);
break; break;
#ifdef UNDEF #ifdef UNDEF
case lh2: case lh2:
lzh_lh2((unsigned long)128); lzh_lh2((uint32_t)128);
break; break;
case lh3: case lh3:
lzh_lh3((unsigned long)128); lzh_lh3((uint32_t)128);
break; break;
#endif /* UNDEF */ #endif /* UNDEF */
#ifdef UNTESTED #ifdef UNTESTED
case lh4: case lh4:
lzh_lzh12((unsigned long)128); lzh_lzh12((uint32_t)128);
break; break;
#endif /* UNTESTED */ #endif /* UNTESTED */
case lh5: case lh5:
lzh_lzh13((unsigned long)128); lzh_lzh13((uint32_t)128);
break; break;
default: default:
mname = lzh_methname(method); mname = lzh_methname(method);
@ -453,8 +453,8 @@ int method;
if(list) { if(list) {
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (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)dataLength, (long)rsrcLength); text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength);
} }
if(info_only) { if(info_only) {
doit = 0; doit = 0;
@ -468,7 +468,7 @@ int method;
} }
if(doit) { if(doit) {
define_name(text); define_name(text);
start_info(info, (unsigned long)rsrcLength, (unsigned long)dataLength); start_info(info, (uint32_t)rsrcLength, (uint32_t)dataLength);
} }
switch(method) { switch(method) {
case lz4: case lz4:
@ -557,7 +557,7 @@ int method;
} }
} }
if(doit) { if(doit) {
crc = (*updcrc)(INIT_CRC, lzh_file, filehdr->upsize); crc = (*updcrc)(INIT_CRC, (unsigned char*)lzh_file, filehdr->upsize);
if(filehdr->crc != crc) { if(filehdr->crc != crc) {
(void)fprintf(stderr, (void)fprintf(stderr,
"CRC error on file: need 0x%04x, got 0x%04x\n", "CRC error on file: need 0x%04x, got 0x%04x\n",
@ -579,8 +579,8 @@ int method;
lzh_skip(filehdr); lzh_skip(filehdr);
} }
static void lzh_skip(filehdr) static void
struct fileHdr *filehdr; lzh_skip (struct lzh_fileHdr *filehdr)
{ {
lzh_pointer += filehdr->psize; lzh_pointer += filehdr->psize;
in_data_size -= filehdr->psize; in_data_size -= filehdr->psize;
@ -589,8 +589,8 @@ struct fileHdr *filehdr;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* -lz4- and -lh0: No compression */ /* -lz4- and -lh0: No compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void lzh_nocomp(obytes) static void
unsigned long obytes; lzh_nocomp (uint32_t obytes)
{ {
copy(lzh_file, lzh_data, (int)obytes); copy(lzh_file, lzh_data, (int)obytes);
} }
@ -599,8 +599,8 @@ unsigned long obytes;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* -lz5-: LZSS compression, variant 1 */ /* -lz5-: LZSS compression, variant 1 */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void lzh_lzss1(obytes) static void
unsigned long obytes; lzh_lzss1 (uint32_t obytes)
{ {
int mask, ch, lzcnt, lzptr, ptr, count; int mask, ch, lzcnt, lzptr, ptr, count;
char *p = lzh_lzbuf; char *p = lzh_lzbuf;
@ -662,8 +662,8 @@ unsigned long obytes;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* -lzs-: LZSS compression, variant 2 */ /* -lzs-: LZSS compression, variant 2 */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void lzh_lzss2(obytes) static void
unsigned long obytes; lzh_lzss2 (uint32_t obytes)
{ {
int ch, lzcnt, lzptr, ptr, i; int ch, lzcnt, lzptr, ptr, i;
@ -706,8 +706,8 @@ unsigned long obytes;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* -lh1-: LZ compression plus adaptive Huffman encoding */ /* -lh1-: LZ compression plus adaptive Huffman encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void lzh_lzah(obytes) static void
unsigned long obytes; lzh_lzah (uint32_t obytes)
{ {
lzh_current = lzh_data + 2; /* SKIPPING BLOCKSIZE! */ lzh_current = lzh_data + 2; /* SKIPPING BLOCKSIZE! */
tmp_out_ptr = out_ptr; tmp_out_ptr = out_ptr;
@ -717,7 +717,8 @@ unsigned long obytes;
out_ptr = tmp_out_ptr; out_ptr = tmp_out_ptr;
} }
static unsigned char lzh_getbyte() static unsigned char
lzh_getbyte (void)
{ {
return *lzh_current++; return *lzh_current++;
} }
@ -726,16 +727,16 @@ static unsigned char lzh_getbyte()
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* -lh2-: LZ** compression */ /* -lh2-: LZ** compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void lzh_lh2(obytes) static void
unsigned long obytes; lzh_lh2 (uint32_t obytes)
{ {
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* -lh3-: LZ** compression */ /* -lh3-: LZ** compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void lzh_lh3(obytes) static void
unsigned long obytes; lzh_lh3 (uint32_t obytes)
{ {
} }
#endif /* UNDEF */ #endif /* UNDEF */
@ -744,14 +745,14 @@ unsigned long obytes;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* -lh4-: LZ(12) compression plus Huffman encoding */ /* -lh4-: LZ(12) compression plus Huffman encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void lzh_lzh12(obytes) static void
unsigned long obytes; lzh_lzh12 (uint32_t obytes)
{ {
lzh_current = lzh_data; lzh_current = lzh_data;
tmp_out_ptr = out_ptr; tmp_out_ptr = out_ptr;
out_ptr = lzh_file; out_ptr = lzh_file;
/* Controlled by obytes only */ /* 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; out_ptr = tmp_out_ptr;
} }
#endif /* UNTESTED */ #endif /* UNTESTED */
@ -759,13 +760,13 @@ unsigned long obytes;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* -lh5-: LZ(13) compression plus Huffman encoding */ /* -lh5-: LZ(13) compression plus Huffman encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void lzh_lzh13(obytes) static void
unsigned long obytes; lzh_lzh13 (uint32_t obytes)
{ {
lzh_current = lzh_data; lzh_current = lzh_data;
tmp_out_ptr = out_ptr; tmp_out_ptr = out_ptr;
out_ptr = lzh_file; out_ptr = lzh_file;
/* Controlled by obytes only */ /* 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; out_ptr = tmp_out_ptr;
} }

View File

@ -1,3 +1,9 @@
#include "macunpack.h"
#ifdef LZH
#ifdef LZH_INTERNAL
#include <stdint.h>
#define FILEHDRSIZE 22 #define FILEHDRSIZE 22
#define TOTALSIZE 64 #define TOTALSIZE 64
#define L_HSIZE 0 #define L_HSIZE 0
@ -30,13 +36,13 @@
#define L_EEXTENDSZ 0 #define L_EEXTENDSZ 0
#define L_EEXTEND 1 #define L_EEXTEND 1
typedef struct fileHdr { /* 58 bytes */ typedef struct lzh_fileHdr { /* 58 bytes */
unsigned char hsize; unsigned char hsize;
unsigned char hcrc; unsigned char hcrc;
char method[5]; char method[5];
unsigned long psize; uint32_t psize;
unsigned long upsize; uint32_t upsize;
unsigned long lastmod; uint32_t lastmod;
unsigned short attribute; unsigned short attribute;
unsigned char nlength; unsigned char nlength;
char name[32]; char name[32];
@ -45,7 +51,7 @@ typedef struct fileHdr { /* 58 bytes */
unsigned char extendsize; unsigned char extendsize;
char *extend; char *extend;
char *data; char *data;
} fileHdr; } lzh_fileHdr;
/* Currently known methods: */ /* Currently known methods: */
#define lh0 0 #define lh0 0
@ -57,3 +63,9 @@ typedef struct fileHdr { /* 58 bytes */
#define lz4 6 #define lz4 6
#define lz5 7 #define lz5 7
#define lzs 8 #define lzs 8
#endif
void lzh (int kind);
#endif

View File

@ -1,65 +1,46 @@
#include "macunpack.h" #include "macunpack.h"
#include "macbinary.h"
#include <stdlib.h>
#include <string.h> #include <string.h>
#include "globals.h" #include "../fileio/kind.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "../fileio/kind.h"
#include "zmahdr.h"
#include "../util/util.h" #include "../util/util.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();
extern void mcb();
#ifdef BIN
extern void bin();
#endif /* BIN */
#ifdef JDW
extern void jdw();
#endif /* JDW */
#ifdef STF
extern void stf();
#endif /* STF */
#ifdef LZC
extern void lzc();
#endif /* LZC */
#ifdef ASQ #ifdef ASQ
extern void asq(); extern void asq();
#endif /* ASQ */ #endif /* ASQ */
#ifdef ARC #ifdef ARC
extern void arc(); extern void arc();
#endif /* ARC */ #endif /* ARC */
#ifdef PIT
extern void pit();
#endif /* PIT */
#ifdef SIT
extern void sit();
#endif /* SIT */
#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 */
#ifdef DD
extern void dd_file();
extern void dd_arch();
#endif /* DD */
static void skip_file(); static void skip_file(int skip);
#ifdef SCAN #ifdef SCAN
static void get_idf(); static void get_idf(int kind);
#endif /* SCAN */ #endif /* SCAN */
#define Z (ZMAHDRS2 + 1) #define Z (ZMAHDRS2 + 1)
static int info_given; static int info_given;
void macbinary() void
macbinary (void)
{ {
char header[INFOBYTES]; char header[INFOBYTES];
int c; int c;
@ -82,7 +63,7 @@ void macbinary()
if(verbose) { if(verbose) {
(void)fprintf(stderr, "This is a \"Zoom\" archive.\n"); (void)fprintf(stderr, "This is a \"Zoom\" archive.\n");
} }
zma(header, (unsigned long)0); zma(header, (uint32_t)0);
exit(0); exit(0);
} }
#endif /* ZMA */ #endif /* ZMA */
@ -175,7 +156,7 @@ void macbinary()
#ifdef SCAN #ifdef SCAN
do_idf(header + I_NAMEOFF + 1, PACK_NAME); do_idf(header + I_NAMEOFF + 1, PACK_NAME);
#endif /* SCAN */ #endif /* SCAN */
jdw((unsigned long)in_data_size); jdw((uint32_t)in_data_size);
skip_file(ds_skip + in_rs); skip_file(ds_skip + in_rs);
continue; continue;
} }
@ -191,7 +172,7 @@ void macbinary()
#ifdef SCAN #ifdef SCAN
do_idf(header + I_NAMEOFF + 1, PACK_NAME); do_idf(header + I_NAMEOFF + 1, PACK_NAME);
#endif /* SCAN */ #endif /* SCAN */
stf((unsigned long)in_data_size); stf((uint32_t)in_data_size);
skip_file(ds_skip + in_rs); skip_file(ds_skip + in_rs);
continue; continue;
} }
@ -397,7 +378,7 @@ void macbinary()
#ifdef SCAN #ifdef SCAN
do_idf(header + I_NAMEOFF + 1, ARCH_NAME); do_idf(header + I_NAMEOFF + 1, ARCH_NAME);
#endif /* SCAN */ #endif /* SCAN */
zma((char *)NULL, (unsigned long)in_data_size); zma((char *)NULL, (uint32_t)in_data_size);
skip_file(ds_skip + in_rs); skip_file(ds_skip + in_rs);
continue; continue;
} }
@ -411,7 +392,7 @@ void macbinary()
#ifdef SCAN #ifdef SCAN
do_idf(header + I_NAMEOFF + 1, ARCH_NAME); do_idf(header + I_NAMEOFF + 1, ARCH_NAME);
#endif /* SCAN */ #endif /* SCAN */
zma((char *)NULL, (unsigned long)in_data_size); zma((char *)NULL, (uint32_t)in_data_size);
skip_file(ds_skip + in_rs); skip_file(ds_skip + in_rs);
continue; continue;
} }
@ -507,8 +488,8 @@ void macbinary()
} }
#endif /* DD */ #endif /* DD */
if(header[0] == 0 /* MORE CHECKS HERE! */) { if(header[0] == 0 /* MORE CHECKS HERE! */) {
mcb(header, (unsigned long)in_rsrc_size, mcb(header, (uint32_t)in_rsrc_size,
(unsigned long)in_data_size, in_ds + in_rs); (uint32_t)in_data_size, in_ds + in_rs);
continue; continue;
} else { } else {
(void)fprintf(stderr, "Unrecognized archive type.\n"); (void)fprintf(stderr, "Unrecognized archive type.\n");
@ -517,8 +498,8 @@ void macbinary()
} }
} }
static void skip_file(skip) static void
int skip; skip_file (int skip)
{ {
char buff[1024]; char buff[1024];
int n; int n;
@ -537,8 +518,8 @@ int skip;
} }
#ifdef SCAN #ifdef SCAN
static void get_idf(kind) static void
int kind; get_idf (int kind)
{ {
char filename[255]; char filename[255];

1
macunpack/macbinary.h Normal file
View File

@ -0,0 +1 @@
void macbinary (void);

View File

@ -1,4 +1,7 @@
#include "macunpack.h" #include "macunpack.h"
#include <stdlib.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
#include "globals.h" #include "globals.h"
#include "../util/patchlevel.h" #include "../util/patchlevel.h"
@ -6,25 +9,15 @@
#include "../fileio/wrfileopt.h" #include "../fileio/wrfileopt.h"
#include "../fileio/kind.h" #include "../fileio/kind.h"
#include "../util/util.h" #include "../util/util.h"
#include "stf.h"
#include "pit.h"
#include "sit.h"
#include "cpt.h"
#include "macbinary.h"
#define LOCALOPT "ilvqVH" #define LOCALOPT "ilvqVH"
extern char *strcat(); static void usage(void);
#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 char options[128]; static char options[128];
@ -157,7 +150,7 @@ int main(int argc, char **argv)
if(verbose) { if(verbose) {
fprintf(stderr, "This is a \"ShrinkToFit\" packed file.\n"); fprintf(stderr, "This is a \"ShrinkToFit\" packed file.\n");
} }
stf(~(unsigned long)1); stf(~(uint32_t)1);
break; break;
#endif /* STF */ #endif /* STF */
#ifdef PIT #ifdef PIT
@ -192,7 +185,8 @@ int main(int argc, char **argv)
/* NOTREACHED */ /* NOTREACHED */
} }
static void usage() static void
usage (void)
{ {
fprintf(stderr, "Usage: macunpack [-%s] [filename]\n", options); fprintf(stderr, "Usage: macunpack [-%s] [filename]\n", options);
fprintf(stderr, "Use \"macunpack -H\" for help.\n"); fprintf(stderr, "Use \"macunpack -H\" for help.\n");

View File

@ -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

View File

@ -1,17 +1,19 @@
#include "mcb.h"
#include <stdlib.h>
#include "globals.h" #include "globals.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "../util/masks.h" #include "../util/masks.h"
#include "../util/util.h" #include "../util/util.h"
#include "../util/transname.h"
static int mcb_read; static int mcb_read;
static void mcb_wrfile(); static void mcb_wrfile(uint32_t ibytes);
void mcb(hdr, rsrcLength, dataLength, toread) void mcb(char *hdr, uint32_t rsrcLength, uint32_t dataLength, int toread)
char *hdr;
unsigned long rsrcLength, dataLength;
int toread;
{ {
register int i; register int i;
int n; int n;
@ -39,8 +41,8 @@ int toread;
transname(hdr + I_AUTHOFF, fauth, 4); transname(hdr + I_AUTHOFF, fauth, 4);
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (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)dataLength, (long)rsrcLength); text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength);
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
} }
@ -79,8 +81,8 @@ int toread;
} }
} }
static void mcb_wrfile(ibytes) static void
unsigned long ibytes; mcb_wrfile (uint32_t ibytes)
{ {
int n; int n;

3
macunpack/mcb.h Normal file
View File

@ -0,0 +1,3 @@
#include <stdint.h>
extern void mcb(char *hdr, uint32_t rsrcLength, uint32_t dataLength, int toread);

View File

@ -1,32 +1,34 @@
#include "macunpack.h" #include "macunpack.h"
#ifdef PIT #ifdef PIT
#define PIT_INTERNAL
#include "pit.h"
#include <stdlib.h>
#include <string.h> #include <string.h>
#include "../fileio/wrfile.h"
#include "../fileio/fileglob.h" #include "../fileio/fileglob.h"
#include "../fileio/kind.h" #include "../fileio/kind.h"
#include "globals.h"
#include "pit.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "crc.h" #include "../fileio/wrfile.h"
#include "../util/masks.h" #include "../util/masks.h"
#include "../util/transname.h"
#include "../util/util.h" #include "../util/util.h"
#include "crc.h"
#include "de_huffman.h"
#include "globals.h"
#include "huffman.h" #include "huffman.h"
extern void read_tree(); static int pit_filehdr(struct pit_header *f, int compr);
extern void de_huffman(); static void pit_wrfile(uint32_t bytes, int type);
extern void set_huffman(); static void pit_nocomp(uint32_t ibytes);
static void pit_huffman(uint32_t obytes);
static int pit_filehdr(); void
static void pit_wrfile(); pit (void)
static void pit_nocomp();
static void pit_huffman();
void pit()
{ {
struct pit_header filehdr; struct pit_header filehdr;
char pithdr[4]; char pithdr[4];
int decode, synced, ch; int decode, synced, ch;
unsigned long data_crc, crc; uint32_t data_crc, crc;
updcrc = binhex_updcrc; updcrc = binhex_updcrc;
crcinit = binhex_crcinit; crcinit = binhex_crcinit;
@ -122,10 +124,10 @@ void pit()
start_info(info, filehdr.rlen, filehdr.dlen); start_info(info, filehdr.rlen, filehdr.dlen);
start_data(); start_data();
pit_wrfile(filehdr.dlen, decode); 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(); start_rsrc();
pit_wrfile(filehdr.rlen, decode); 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) { if(decode == nocomp) {
crc = getb(infp); crc = getb(infp);
crc = (crc << 8) | getb(infp); crc = (crc << 8) | getb(infp);
@ -159,12 +161,11 @@ void pit()
} }
} }
static int pit_filehdr(f, compr) static int
struct pit_header *f; pit_filehdr (struct pit_header *f, int compr)
int compr;
{ {
register int i; register int i;
unsigned long crc; uint32_t crc;
int n; int n;
char hdr[HDRBYTES]; char hdr[HDRBYTES];
char ftype[5], fauth[5]; char ftype[5], fauth[5];
@ -182,7 +183,7 @@ int compr;
} }
} }
crc = INIT_CRC; crc = INIT_CRC;
crc = (*updcrc)(crc, hdr, HDRBYTES - 2); crc = (*updcrc)(crc, (unsigned char*)hdr, HDRBYTES - 2);
f->hdrCRC = get2(hdr + H_HDRCRC); f->hdrCRC = get2(hdr + H_HDRCRC);
if(f->hdrCRC != crc) { if(f->hdrCRC != crc) {
@ -210,8 +211,8 @@ int compr;
transname(hdr + H_AUTHOFF, fauth, 4); transname(hdr + H_AUTHOFF, fauth, 4);
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (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->dlen, (long)f->rlen); text, ftype, fauth, (int32_t)f->dlen, (int32_t)f->rlen);
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
} }
@ -238,9 +239,8 @@ int compr;
return 1; return 1;
} }
static void pit_wrfile(bytes, type) static void
unsigned long bytes; pit_wrfile (uint32_t bytes, int type)
int type;
{ {
if(bytes == 0) { if(bytes == 0) {
return; return;
@ -257,8 +257,8 @@ int type;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* No compression */ /* No compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void pit_nocomp(ibytes) static void
unsigned long ibytes; pit_nocomp (uint32_t ibytes)
{ {
int n; int n;
@ -275,8 +275,8 @@ unsigned long ibytes;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Huffman compression */ /* Huffman compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void pit_huffman(obytes) static void
unsigned long obytes; pit_huffman (uint32_t obytes)
{ {
de_huffman(obytes); de_huffman(obytes);
} }

View File

@ -1,3 +1,9 @@
#include "macunpack.h"
#ifdef PIT
#ifdef PIT_INTERNAL
#include <stdint.h>
#define H_NAMELEN 63 #define H_NAMELEN 63
#define H_NLENOFF 0 #define H_NLENOFF 0
@ -20,13 +26,18 @@ struct pit_header { /* Packit file header (92 bytes) */
char auth[4]; /* file creator */ char auth[4]; /* file creator */
unsigned short flags; /* file flags (?) */ unsigned short flags; /* file flags (?) */
unsigned short lock; /* unknown */ unsigned short lock; /* unknown */
unsigned long dlen; /* number of bytes in data fork */ uint32_t dlen; /* number of bytes in data fork */
unsigned long rlen; /* number of bytes in resource fork */ uint32_t rlen; /* number of bytes in resource fork */
unsigned long ctim; /* file creation time */ uint32_t ctim; /* file creation time */
unsigned long mtim; /* file modified time */ uint32_t mtim; /* file modified time */
unsigned short hdrCRC; /* CRC */ unsigned short hdrCRC; /* CRC */
}; };
#define nocomp 0 #define nocomp 0
#define huffman 1 #define huffman 1
#endif
void pit (void);
#endif

View File

@ -1,24 +1,23 @@
#include "macunpack.h" #include "macunpack.h"
#define SIT_INTERNAL
#include "sit.h"
#ifdef SIT #ifdef SIT
#include <string.h> #include <string.h>
#include <stdlib.h>
#include "globals.h" #include "globals.h"
#include "sit.h"
#include "crc.h" #include "crc.h"
#include "../util/util.h" #include "../util/util.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "../fileio/kind.h" #include "../fileio/kind.h"
#include "../util/masks.h" #include "../util/masks.h"
#include "../util/transname.h"
#include "huffman.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 { typedef struct methodinfo {
char *name; char *name;
@ -36,26 +35,26 @@ static struct methodinfo methods[] = {
}; };
static int sit_nodeptr; static int sit_nodeptr;
static int readsithdr(); static int readsithdr(sitHdr *s);
static int sit_filehdr(); static int sit_filehdr(struct sit_fileHdr *f, int skip);
static int sit_valid(); static int sit_valid(struct sit_fileHdr f);
static int sit_checkm(); static int sit_checkm(int f);
static char *sit_methname(); static char *sit_methname(int n);
static void sit_folder(); static void sit_folder(char *name);
static void sit_unstuff(); static void sit_unstuff(struct sit_fileHdr filehdr);
static void sit_wrfile(); static void sit_wrfile(uint32_t ibytes, uint32_t obytes, int type);
static void sit_skip(); static void sit_skip(uint32_t ibytes);
static void sit_nocomp(); static void sit_nocomp(uint32_t ibytes);
static void sit_rle(); static void sit_rle(uint32_t ibytes);
static void sit_lzc(); static void sit_lzc(uint32_t ibytes);
static void sit_huffman(); static void sit_huffman(uint32_t obytes);
static void sit_lzah(); static void sit_lzah(uint32_t obytes);
static unsigned char sit_getbyte(); static unsigned char sit_getbyte(void);
static void sit_fixhuf(); static void sit_fixhuf(uint32_t ibytes);
static void sit_dosplit(); static void sit_dosplit(int ptr, int sum, int low, int upp);
static void sit_mw(); static void sit_mw(uint32_t ibytes);
static void sit_mw_out(); static void sit_mw_out(int ptr);
static int sit_mw_in(); static int sit_mw_in(int bits, uint32_t *ibytes);
static short code6[258] = { static short code6[258] = {
1024, 512, 256, 256, 256, 256, 128, 128, 1024, 512, 256, 256, 256, 256, 128, 128,
@ -93,13 +92,14 @@ static short code6[258] = {
1, 1}; 1, 1};
static char sit_buffer[32768]; static char sit_buffer[32768];
static short sit_dict[16385]; static short sit_dict[16385];
static unsigned long sit_avail; static uint32_t sit_avail;
static int sit_bits_avail; static int sit_bits_avail;
void sit() void
sit (void)
{ {
struct sitHdr sithdr; struct sitHdr sithdr;
struct fileHdr filehdr; struct sit_fileHdr filehdr;
int i; int i;
set_huffman(HUFF_BE); set_huffman(HUFF_BE);
@ -154,10 +154,10 @@ static int readsithdr(sitHdr *s)
return 1; return 1;
} }
static int sit_filehdr(struct fileHdr *f, int skip) static int sit_filehdr(struct sit_fileHdr *f, int skip)
{ {
register int i; register int i;
unsigned long crc; uint32_t crc;
int n; int n;
char hdr[FILEHDRSIZE]; char hdr[FILEHDRSIZE];
char ftype[5], fauth[5]; char ftype[5], fauth[5];
@ -170,7 +170,7 @@ static int sit_filehdr(struct fileHdr *f, int skip)
return -1; return -1;
} }
crc = INIT_CRC; crc = INIT_CRC;
crc = (*updcrc)(crc, hdr, FILEHDRSIZE - 2); crc = (*updcrc)(crc, (unsigned char*)hdr, FILEHDRSIZE - 2);
f->hdrCRC = get2(hdr + F_HDRCRC); f->hdrCRC = get2(hdr + F_HDRCRC);
if(f->hdrCRC != crc) { if(f->hdrCRC != crc) {
@ -207,9 +207,9 @@ static int sit_filehdr(struct fileHdr *f, int skip)
transname(hdr + F_FTYPE, ftype, 4); transname(hdr + F_FTYPE, ftype, 4);
transname(hdr + F_CREATOR, fauth, 4); transname(hdr + F_CREATOR, fauth, 4);
(void)fprintf(stderr, (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, text, ftype, fauth,
(long)f->dataLength, (long)f->rsrcLength); (int32_t)f->dataLength, (int32_t)f->rsrcLength);
} }
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
@ -239,8 +239,8 @@ static int sit_filehdr(struct fileHdr *f, int skip)
return 1; return 1;
} }
static int sit_valid(f) static int
struct fileHdr f; sit_valid (struct sit_fileHdr f)
{ {
int fr = f.compRMethod, fd = f.compDMethod; int fr = f.compRMethod, fd = f.compDMethod;
@ -283,8 +283,8 @@ struct fileHdr f;
return 0; return 0;
} }
static int sit_checkm(f) static int
int f; sit_checkm (int f)
{ {
switch(f) { switch(f) {
case nocomp: case nocomp:
@ -307,8 +307,8 @@ int f;
/* NOTREACHED */ /* NOTREACHED */
} }
static char *sit_methname(n) static char *
int n; sit_methname (int n)
{ {
int i, nmeths; int i, nmeths;
nmeths = sizeof(methods) / sizeof(struct methodinfo); nmeths = sizeof(methods) / sizeof(struct methodinfo);
@ -320,12 +320,12 @@ int i, nmeths;
return NULL; return NULL;
} }
static void sit_folder(name) static void
char *name; sit_folder (char *name)
{ {
int i, recurse; int i, recurse;
char loc_name[64]; char loc_name[64];
struct fileHdr filehdr; struct sit_fileHdr filehdr;
for(i = 0; i < 64; i++) { for(i = 0; i < 64; i++) {
loc_name[i] = name[i]; loc_name[i] = name[i];
@ -387,10 +387,10 @@ char *name;
} }
} }
static void sit_unstuff(filehdr) static void
struct fileHdr filehdr; sit_unstuff (struct sit_fileHdr filehdr)
{ {
unsigned long crc; uint32_t crc;
if(write_it) { if(write_it) {
start_info(info, filehdr.rsrcLength, filehdr.dataLength); start_info(info, filehdr.rsrcLength, filehdr.dataLength);
@ -403,7 +403,7 @@ struct fileHdr filehdr;
} }
sit_wrfile(filehdr.compRLength, filehdr.rsrcLength, filehdr.compRMethod); sit_wrfile(filehdr.compRLength, filehdr.rsrcLength, filehdr.compRMethod);
if(write_it) { 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) { if(filehdr.rsrcCRC != crc) {
(void)fprintf(stderr, (void)fprintf(stderr,
"CRC error on resource fork: need 0x%04x, got 0x%04x\n", "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); sit_wrfile(filehdr.compDLength, filehdr.dataLength, filehdr.compDMethod);
if(write_it) { 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) { if(filehdr.dataCRC != crc) {
(void)fprintf(stderr, (void)fprintf(stderr,
"CRC error on data fork: need 0x%04x, got 0x%04x\n", "CRC error on data fork: need 0x%04x, got 0x%04x\n",
@ -439,9 +439,8 @@ struct fileHdr filehdr;
} }
} }
static void sit_wrfile(ibytes, obytes, type) static void
unsigned long ibytes, obytes; sit_wrfile (uint32_t ibytes, uint32_t obytes, int type)
unsigned char type;
{ {
if(ibytes == 0) { if(ibytes == 0) {
if(verbose) { if(verbose) {
@ -536,8 +535,8 @@ unsigned char type;
} }
/* skip stuffit file */ /* skip stuffit file */
static void sit_skip(ibytes) static void
unsigned long ibytes; sit_skip (uint32_t ibytes)
{ {
while(ibytes != 0) { while(ibytes != 0) {
if(getc(infp) == EOF) { if(getc(infp) == EOF) {
@ -554,8 +553,8 @@ unsigned long ibytes;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Method 0: No compression */ /* Method 0: No compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void sit_nocomp(ibytes) static void
unsigned long ibytes; sit_nocomp (uint32_t ibytes)
{ {
int n; int n;
@ -572,10 +571,10 @@ unsigned long ibytes;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Method 1: Run length encoding */ /* Method 1: Run length encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void sit_rle(ibytes) static void
unsigned long ibytes; sit_rle (uint32_t ibytes)
{ {
int ch, lastch, n, i; int ch, lastch = 0, n, i;
while(ibytes != 0) { while(ibytes != 0) {
ch = getb(infp) & BYTEMASK; ch = getb(infp) & BYTEMASK;
@ -602,8 +601,8 @@ unsigned long ibytes;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Method 2: LZC compressed */ /* Method 2: LZC compressed */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void sit_lzc(ibytes) static void
unsigned long ibytes; sit_lzc (uint32_t ibytes)
{ {
de_compress(ibytes, 14); de_compress(ibytes, 14);
} }
@ -611,8 +610,8 @@ unsigned long ibytes;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Method 3: Huffman compressed */ /* Method 3: Huffman compressed */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void sit_huffman(obytes) static void
unsigned long obytes; sit_huffman (uint32_t obytes)
{ {
read_tree(); read_tree();
de_huffman(obytes); de_huffman(obytes);
@ -621,14 +620,15 @@ unsigned long obytes;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Method 5: LZ compression plus adaptive Huffman encoding */ /* Method 5: LZ compression plus adaptive Huffman encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void sit_lzah(obytes) static void
unsigned long obytes; sit_lzah (uint32_t obytes)
{ {
lzah_getbyte = sit_getbyte; lzah_getbyte = sit_getbyte;
de_lzah(obytes); de_lzah(obytes);
} }
static unsigned char sit_getbyte() static unsigned char
sit_getbyte (void)
{ {
return getb(infp); return getb(infp);
} }
@ -636,12 +636,12 @@ static unsigned char sit_getbyte()
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Method 6: Compression with a fixed Huffman encoding */ /* Method 6: Compression with a fixed Huffman encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void sit_fixhuf(ibytes) static void
unsigned long ibytes; sit_fixhuf (uint32_t ibytes)
{ {
int i, sum, codes, sym, num; int i, sum, codes, sym, num;
char byte_int[4], byte_short[2]; char byte_int[4], byte_short[2];
long size; int32_t size;
int sign; int sign;
char *tmp_ptr, *ptr, *end_ptr; char *tmp_ptr, *ptr, *end_ptr;
@ -661,7 +661,7 @@ unsigned long ibytes;
exit(1); exit(1);
} }
ibytes -= 4; ibytes -= 4;
size = (long)get4(byte_int); size = (int32_t)get4(byte_int);
sign = 0; sign = 0;
if(size < 0) { if(size < 0) {
size = - size; size = - size;
@ -732,8 +732,8 @@ unsigned long ibytes;
} }
} }
static void sit_dosplit(ptr, sum, low, upp) static void
int ptr, sum, low, upp; sit_dosplit (int ptr, int sum, int low, int upp)
{ {
int i, locsum; int i, locsum;
@ -760,8 +760,8 @@ int ptr, sum, low, upp;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Method 8: Compression with a MW encoding */ /* Method 8: Compression with a MW encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void sit_mw(ibytes) static void
unsigned long ibytes; sit_mw (uint32_t ibytes)
{ {
int ptr; int ptr;
int max, max1, bits; int max, max1, bits;
@ -802,8 +802,8 @@ start_over:
} }
} }
static void sit_mw_out(ptr) static void
int ptr; sit_mw_out (int ptr)
{ {
int stack_ptr; int stack_ptr;
int stack[16384]; int stack[16384];
@ -820,9 +820,8 @@ int ptr;
} }
} }
static int sit_mw_in(bits, ibytes) static int
int bits; sit_mw_in (int bits, uint32_t *ibytes)
unsigned long *ibytes;
{ {
int res, res1; int res, res1;

View File

@ -1,3 +1,9 @@
#include "macunpack.h"
#ifdef SIT
#include <stdint.h>
#ifdef SIT_INTERNAL
#define S_SIGNATURE 0 #define S_SIGNATURE 0
#define S_NUMFILES 4 #define S_NUMFILES 4
#define S_ARCLENGTH 6 #define S_ARCLENGTH 6
@ -22,19 +28,19 @@
#define F_HDRCRC 110 #define F_HDRCRC 110
#define FILEHDRSIZE 112 #define FILEHDRSIZE 112
typedef long OSType; typedef int32_t OSType;
typedef struct sitHdr { /* 22 bytes */ typedef struct sitHdr { /* 22 bytes */
OSType signature; /* = 'SIT!' -- for verification */ OSType signature; /* = 'SIT!' -- for verification */
unsigned short numFiles; /* number of files in archive */ 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 */ hdr. -- for verification */
OSType signature2; /* = 'rLau' -- for verification */ OSType signature2; /* = 'rLau' -- for verification */
unsigned char version; /* version number */ unsigned char version; /* version number */
char reserved[7]; char reserved[7];
} sitHdr; } sitHdr;
typedef struct fileHdr { /* 112 bytes */ typedef struct sit_fileHdr { /* 112 bytes */
unsigned char compRMethod; /* rsrc fork compression method */ unsigned char compRMethod; /* rsrc fork compression method */
unsigned char compDMethod; /* data fork compression method */ unsigned char compDMethod; /* data fork compression method */
unsigned char fName[64]; /* a STR63 */ unsigned char fName[64]; /* a STR63 */
@ -43,17 +49,17 @@ typedef struct fileHdr { /* 112 bytes */
unsigned short FndrFlags; /* copy of Finder flags. For our unsigned short FndrFlags; /* copy of Finder flags. For our
purposes, we can clear: purposes, we can clear:
busy,onDesk */ busy,onDesk */
unsigned long creationDate; uint32_t creationDate;
unsigned long modDate; /* !restored-compat w/backup prgms */ uint32_t modDate; /* !restored-compat w/backup prgms */
unsigned long rsrcLength; /* decompressed lengths */ uint32_t rsrcLength; /* decompressed lengths */
unsigned long dataLength; uint32_t dataLength;
unsigned long compRLength; /* compressed lengths */ uint32_t compRLength; /* compressed lengths */
unsigned long compDLength; uint32_t compDLength;
unsigned short rsrcCRC; /* crc of rsrc fork */ unsigned short rsrcCRC; /* crc of rsrc fork */
unsigned short dataCRC; /* crc of data fork */ unsigned short dataCRC; /* crc of data fork */
char reserved[6]; char reserved[6];
unsigned short hdrCRC; /* crc of file header */ unsigned short hdrCRC; /* crc of file header */
} fileHdr; } sit_fileHdr;
/* file format is: /* file format is:
sitArchiveHdr sitArchiveHdr
@ -72,7 +78,6 @@ typedef struct fileHdr { /* 112 bytes */
*/ */
/* compression methods */ /* compression methods */
#define nocomp 0 /* just read each byte and write it to archive */ #define nocomp 0 /* just read each byte and write it to archive */
#define rle 1 /* RLE compression */ #define rle 1 /* RLE compression */
@ -91,3 +96,9 @@ typedef struct fileHdr { /* 112 bytes */
/* all other numbers are reserved */ /* all other numbers are reserved */
#define ESC 0x90 /* repeat packing escape */ #define ESC 0x90 /* repeat packing escape */
#endif
void sit (void);
#endif

View File

@ -1,16 +1,16 @@
#include "macunpack.h" #include "macunpack.h"
#ifdef STF #ifdef STF
#include <string.h> #include <string.h>
#include <stdlib.h>
#include "stf.h" #include "stf.h"
#include "globals.h" #include "globals.h"
#include "huffman.h" #include "huffman.h"
#include "../util/curtime.h" #include "../util/curtime.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../util/transname.h"
#include "../util/util.h" #include "../util/util.h"
#include "de_huffman.h"
extern void de_huffman();
extern void set_huffman();
typedef struct{ typedef struct{
int num; int num;
@ -20,17 +20,17 @@ typedef struct{
static table_struct table[511]; static table_struct table[511];
static char length[256]; static char length[256];
static void stf_wrfile(); static void stf_wrfile(uint32_t rsrcLength, uint32_t dataLength, uint32_t ibytes);
static void stf_wrfork(); static void stf_wrfork(uint32_t *num, uint32_t towrite, int offs);
static void stf_construct(); static void stf_construct(int n);
void stf(ibytes) void
unsigned long ibytes; stf (uint32_t ibytes)
{ {
char magic[3], fauth[5], ftype[5]; char magic[3], fauth[5], ftype[5];
int filel, i; int filel, i;
unsigned int rsrcLength, dataLength; unsigned int rsrcLength, dataLength;
unsigned long curtime; uint32_t curtime;
set_huffman(HUFF_LE); set_huffman(HUFF_LE);
for(i = 0; i < 3; i++) { for(i = 0; i < 3; i++) {
@ -58,19 +58,19 @@ unsigned long ibytes;
for(i = 0; i < 4; i++) { for(i = 0; i < 4; i++) {
info[I_AUTHOFF + i] = getb(infp); 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_CTIMOFF, curtime);
put4(info + I_MTIMOFF, curtime); put4(info + I_MTIMOFF, curtime);
rsrcLength = 0; rsrcLength = 0;
for(i = 0; i < 4; i++) { for(i = 0; i < 4; i++) {
rsrcLength = (rsrcLength << 8) + getb(infp); rsrcLength = (rsrcLength << 8) + getb(infp);
} }
put4(info + I_RLENOFF, (unsigned long)rsrcLength); put4(info + I_RLENOFF, (uint32_t)rsrcLength);
dataLength = 0; dataLength = 0;
for(i = 0; i < 4; i++) { for(i = 0; i < 4; i++) {
dataLength = (dataLength << 8) + getb(infp); dataLength = (dataLength << 8) + getb(infp);
} }
put4(info + I_DLENOFF, (unsigned long)dataLength); put4(info + I_DLENOFF, (uint32_t)dataLength);
ibytes -= filel + 20; ibytes -= filel + 20;
write_it = 1; write_it = 1;
if(list) { if(list) {
@ -79,8 +79,8 @@ unsigned long ibytes;
transname(info + I_AUTHOFF, fauth, 4); transname(info + I_AUTHOFF, fauth, 4);
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (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)dataLength, (long)rsrcLength); text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength);
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
} }
@ -90,13 +90,13 @@ unsigned long ibytes;
(void)fputc('\n', stderr); (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(rsrcLength, dataLength, ibytes) static void
unsigned long rsrcLength, dataLength, ibytes; stf_wrfile (uint32_t rsrcLength, uint32_t dataLength, uint32_t ibytes)
{ {
unsigned long num = 0; uint32_t num = 0;
if(write_it) { if(write_it) {
define_name(text); define_name(text);
@ -117,9 +117,8 @@ unsigned long rsrcLength, dataLength, ibytes;
} }
} }
static void stf_wrfork(num, towrite, offs) static void
unsigned long *num, towrite; stf_wrfork (uint32_t *num, uint32_t towrite, int offs)
int offs;
{ {
int c, k, max, i, i1; int c, k, max, i, i1;
char *tmp_out_ptr; char *tmp_out_ptr;
@ -158,7 +157,7 @@ int offs;
stf_construct(32); stf_construct(32);
tmp_out_ptr = out_ptr; tmp_out_ptr = out_ptr;
out_ptr = length; out_ptr = length;
de_huffman((unsigned long)256); de_huffman((uint32_t)256);
out_ptr = tmp_out_ptr; out_ptr = tmp_out_ptr;
for(i = 1; i < 257; i++) { for(i = 1; i < 257; i++) {
table[i].num = 0x40000000 >> length[i - 1]; table[i].num = 0x40000000 >> length[i - 1];
@ -182,13 +181,13 @@ int offs;
if(i > towrite - *num) { if(i > towrite - *num) {
i = towrite - *num; i = towrite - *num;
} }
de_huffman((unsigned long)i); de_huffman((uint32_t)i);
*num += i; *num += i;
} }
} }
static void stf_construct(n) static void
int n; stf_construct (int n)
{ {
int i, i1, i2, j1, k; int i, i1, i2, j1, k;

View File

@ -1,3 +1,8 @@
#include "macunpack.h"
#ifdef STF
#include <stdint.h>
#define MAGIC "RTH" #define MAGIC "RTH"
#define S_MAGIC 0 #define S_MAGIC 0
@ -5,10 +10,13 @@
#define S_RSRCLNGTH 3 /* + NAMELENGTH */ #define S_RSRCLNGTH 3 /* + NAMELENGTH */
#define S_DATALNGTH 7 /* + NAMELENGTH */ #define S_DATALNGTH 7 /* + NAMELENGTH */
typedef struct fileHdr { typedef struct stf_fileHdr {
char magic[3]; char magic[3];
char flength; char flength;
char fname[32]; /* actually flength */ char fname[32]; /* actually flength */
unsigned long rsrcLength; uint32_t rsrcLength;
unsigned long dataLength; uint32_t dataLength;
} fileHdr; } stf_fileHdr;
void stf (uint32_t ibytes);
#endif

View File

@ -1,37 +1,39 @@
#include "macunpack.h" #include "macunpack.h"
#ifdef ZMA #ifdef ZMA
#define ZMA_INTERNAL
#include "zma.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "globals.h" #include "globals.h"
#include "zma.h"
#include "crc.h" #include "crc.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "../fileio/kind.h" #include "../fileio/kind.h"
#include "../util/masks.h" #include "../util/masks.h"
#include "../util/transname.h"
#include "../util/util.h" #include "../util/util.h"
#include "de_lzah.h"
extern void de_lzh();
/* We do allow for possible backpointing, so we allocate the archive in core */ /* We do allow for possible backpointing, so we allocate the archive in core */
static char *zma_archive; static char *zma_archive;
static char *zma_current; static char *zma_current;
static char *zma_filestart; static char *zma_filestart;
static unsigned long zma_length; static uint32_t zma_length;
static long zma_archlength; static int32_t zma_archlength;
static int zma_filehdr(); static int zma_filehdr(struct zma_fileHdr *f, int skip);
static void zma_folder(); static void zma_folder(struct zma_fileHdr fhdr);
static void zma_mooz(); static void zma_mooz(struct zma_fileHdr filehdr);
static void zma_wrfile(); static void zma_wrfile(uint32_t ibytes, uint32_t obytes, int type);
static void zma_nocomp(); static void zma_nocomp(uint32_t ibytes);
static void zma_lzh(); static void zma_lzh(uint32_t ibytes);
void zma(start, length) void
char *start; zma (char *start, uint32_t length)
unsigned long length;
{ {
struct fileHdr filehdr; struct zma_fileHdr filehdr;
int i, toread; int i, toread;
if(length != 0) { if(length != 0) {
@ -122,9 +124,8 @@ void zma(start, length)
} }
} }
static int zma_filehdr(f, skip) static int
struct fileHdr *f; zma_filehdr (struct zma_fileHdr *f, int skip)
int skip;
{ {
register int i; register int i;
int n; int n;
@ -177,9 +178,9 @@ int skip;
transname(zma_current + Z_TYPE, ftype, 4); transname(zma_current + Z_TYPE, ftype, 4);
transname(zma_current + Z_AUTH, fauth, 4); transname(zma_current + Z_AUTH, fauth, 4);
(void)fprintf(stderr, (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, text, ftype, fauth,
(long)f->dataLength, (long)f->rsrcLength); (int32_t)f->dataLength, (int32_t)f->rsrcLength);
} }
switch(f->what) { switch(f->what) {
case z_plug: case z_plug:
@ -228,12 +229,12 @@ int skip;
return 1; return 1;
} }
static void zma_folder(fhdr) static void
struct fileHdr fhdr; zma_folder (struct zma_fileHdr fhdr)
{ {
int i; int i;
char loc_name[64]; char loc_name[64];
struct fileHdr filehdr; struct zma_fileHdr filehdr;
for(i = 0; i < 64; i++) { for(i = 0; i < 64; i++) {
loc_name[i] = text[i]; loc_name[i] = text[i];
@ -271,10 +272,10 @@ struct fileHdr fhdr;
} }
} }
static void zma_mooz(filehdr) static void
struct fileHdr filehdr; zma_mooz (struct zma_fileHdr filehdr)
{ {
unsigned long crc; uint32_t crc;
if(write_it) { if(write_it) {
start_info(info, filehdr.rsrcLength, filehdr.dataLength); start_info(info, filehdr.rsrcLength, filehdr.dataLength);
@ -287,7 +288,7 @@ struct fileHdr filehdr;
} }
zma_wrfile(filehdr.compDLength, filehdr.dataLength, filehdr.what); zma_wrfile(filehdr.compDLength, filehdr.dataLength, filehdr.what);
if(write_it) { 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) { if(filehdr.dataCRC != crc) {
(void)fprintf(stderr, (void)fprintf(stderr,
"CRC error on data fork: need 0x%04x, got 0x%04x\n", "CRC error on data fork: need 0x%04x, got 0x%04x\n",
@ -306,7 +307,7 @@ struct fileHdr filehdr;
} }
zma_wrfile(filehdr.compRLength, filehdr.rsrcLength, filehdr.what); zma_wrfile(filehdr.compRLength, filehdr.rsrcLength, filehdr.what);
if(write_it) { 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) { if(filehdr.rsrcCRC != crc) {
(void)fprintf(stderr, (void)fprintf(stderr,
"CRC error on resource fork: need 0x%04x, got 0x%04x\n", "CRC error on resource fork: need 0x%04x, got 0x%04x\n",
@ -323,9 +324,8 @@ struct fileHdr filehdr;
} }
} }
static void zma_wrfile(ibytes, obytes, type) static void
unsigned long ibytes, obytes; zma_wrfile (uint32_t ibytes, uint32_t obytes, int type)
char type;
{ {
if(ibytes == 0) { if(ibytes == 0) {
if(verbose) { if(verbose) {
@ -363,8 +363,8 @@ char type;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* No compression */ /* No compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void zma_nocomp(ibytes) static void
unsigned long ibytes; zma_nocomp (uint32_t ibytes)
{ {
int n = ibytes; int n = ibytes;
char *ptr = out_buffer; char *ptr = out_buffer;
@ -377,11 +377,11 @@ unsigned long ibytes;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* LZ compression plus Huffman encoding */ /* LZ compression plus Huffman encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void zma_lzh(ibytes) static void
unsigned long ibytes; zma_lzh (uint32_t ibytes)
{ {
/* Controlled by ibutes only */ /* 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 */ #else /* ZMA */
int zma; /* keep lint and some compilers happy */ int zma; /* keep lint and some compilers happy */

View File

@ -1,5 +1,11 @@
#include "macunpack.h"
#ifdef ZMA
#ifdef ZMA_INTERNAL
#include "zmahdr.h" #include "zmahdr.h"
#include <stdint.h>
#define Z_HDRSIZE 78 #define Z_HDRSIZE 78
#define Z_WHAT 0 /* What kind of data? */ #define Z_WHAT 0 /* What kind of data? */
@ -20,20 +26,20 @@
#define Z_RCRC 44 /* Resource crc */ #define Z_RCRC 44 /* Resource crc */
#define Z_FNAME 46 /* File name length and name */ #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 deleted; /* Not in original, split off from: */
char what; /* What kind? Negative if deleted */ char what; /* What kind? Negative if deleted */
unsigned char hlen ; /* Header length */ unsigned char hlen ; /* Header length */
unsigned short boolFlags; /* Boolean flags */ unsigned short boolFlags; /* Boolean flags */
unsigned long next; /* Next entry */ uint32_t next; /* Next entry */
unsigned long compRLength; /* The compressed lengths. */ uint32_t compRLength; /* The compressed lengths. */
unsigned long compDLength; /* For dirs, the second is # entries */ uint32_t compDLength; /* For dirs, the second is # entries */
unsigned long rsrcLength; /* The uncompressed lengths. */ uint32_t rsrcLength; /* The uncompressed lengths. */
unsigned long dataLength; uint32_t dataLength;
unsigned long fType; /* file type */ uint32_t fType; /* file type */
unsigned long fCreator; /* er... */ uint32_t fCreator; /* er... */
unsigned long modDate; /* !restored-compat w/backup prgms */ uint32_t modDate; /* !restored-compat w/backup prgms */
unsigned long comment; /* Comment offset */ uint32_t comment; /* Comment offset */
unsigned short FndrFlags; /* copy of Finder flags. For our unsigned short FndrFlags; /* copy of Finder flags. For our
purposes, we can clear: purposes, we can clear:
busy,onDesk */ busy,onDesk */
@ -41,8 +47,8 @@ typedef struct fileHdr { /* 78 bytes */
unsigned short rsrcCRC; /* Resource fork crc */ unsigned short rsrcCRC; /* Resource fork crc */
unsigned char fName[32]; /* a STR32 */ unsigned char fName[32]; /* a STR32 */
/* The following are overlayed in the original structure */ /* The following are overlayed in the original structure */
unsigned long conts; /* Pointer to directory contents */ uint32_t conts; /* Pointer to directory contents */
} fileHdr; } zma_fileHdr;
/* zma types (see what) */ /* zma types (see what) */
#define z_noth 0 /* ??? */ #define z_noth 0 /* ??? */
@ -51,3 +57,8 @@ typedef struct fileHdr { /* 78 bytes */
#define z_dir 3 /* directory */ #define z_dir 3 /* directory */
#define z_plug 4 /* for plug in, not supported */ #define z_plug 4 /* for plug in, not supported */
#endif
void zma (char *start, uint32_t length);
#endif

View File

@ -1,77 +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:
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)/.
distr:
shar -a README makefile crc util fileio macunpack hexbin mixed binhex \
comm doc man >macutil.shar

87
meson.build Normal file
View File

@ -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)

View File

@ -1,8 +1,11 @@
#include "dir.h"
#include <stdlib.h> #include <stdlib.h>
#include "globals.h" #include "globals.h"
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "../util/util.h" #include "../util/util.h"
#include "../util/transname.h"
#include "../util/masks.h" #include "../util/masks.h"
static char *dir_stack; static char *dir_stack;

1
mixed/dir.h Normal file
View File

@ -0,0 +1 @@
void dir(char *hdr);

View File

@ -1,8 +1,5 @@
#include <stdio.h> #include <stdio.h>
extern void exit();
extern void transname();
extern char info[]; extern char info[];
extern char text[]; extern char text[];

View File

@ -1,18 +1,23 @@
#include "macbinary.h"
#include "globals.h" #include "globals.h"
#include <stdlib.h>
#include "../fileio/machdr.h" #include "../fileio/machdr.h"
#include "../fileio/kind.h" #include "../fileio/kind.h"
#include "../util/util.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 #ifdef SCAN
static void get_idf(); static void get_idf(int kind);
#endif /* SCAN */ #endif /* SCAN */
void macbinary() void
macbinary (void)
{ {
char header[INFOBYTES]; char header[INFOBYTES];
int c; int c;
@ -48,8 +53,8 @@ void macbinary()
} }
#endif /* SCAN */ #endif /* SCAN */
if(header[0] == 0 /* MORE CHECKS HERE! */) { if(header[0] == 0 /* MORE CHECKS HERE! */) {
mcb(header, (unsigned long)in_rsrc_size, mcb(header, (uint32_t)in_rsrc_size,
(unsigned long)in_data_size, in_ds + in_rs); (uint32_t)in_data_size, in_ds + in_rs);
continue; continue;
} else { } else {
(void)fprintf(stderr, "Unrecognized header.\n"); (void)fprintf(stderr, "Unrecognized header.\n");
@ -58,8 +63,8 @@ void macbinary()
} }
} }
static void skip_file(skip) static void
int skip; skip_file (int skip)
{ {
char buff[1024]; char buff[1024];
int n; int n;
@ -75,8 +80,8 @@ static void skip_file(skip)
} }
#ifdef SCAN #ifdef SCAN
static void get_idf(kind) static void
int kind; get_idf (int kind)
{ {
char filename[1024], filename1[255]; char filename[1024], filename1[255];

1
mixed/macbinary.h Normal file
View File

@ -0,0 +1 @@
void macbinary (void);

View File

@ -1,16 +1,17 @@
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
#include "globals.h" #include "globals.h"
#include "../util/patchlevel.h" #include "../util/patchlevel.h"
#include "../fileio/wrfile.h" #include "../fileio/wrfile.h"
#include "../fileio/wrfileopt.h" #include "../fileio/wrfileopt.h"
#include "../util/util.h" #include "../util/util.h"
#include "macbinary.h"
#define LOCALOPT "ilqVH" #define LOCALOPT "ilqVH"
void macbinary(); static void usage(void);
static void usage();
static char options[128]; static char options[128];
@ -87,7 +88,8 @@ int main(int argc, char **argv)
/* NOTREACHED */ /* NOTREACHED */
} }
static void usage() static void
usage (void)
{ {
(void)fprintf(stderr, "Usage: macsave [-%s]\n", options); (void)fprintf(stderr, "Usage: macsave [-%s]\n", options);
(void)fprintf(stderr, "Use \"macsave -H\" for help.\n"); (void)fprintf(stderr, "Use \"macsave -H\" for help.\n");

View File

@ -6,14 +6,12 @@
#include "../fileio/rdfile.h" #include "../fileio/rdfile.h"
#include "../fileio/rdfileopt.h" #include "../fileio/rdfileopt.h"
#include "../util/patchlevel.h" #include "../util/patchlevel.h"
#include "../util/transname.h"
#include "../util/util.h" #include "../util/util.h"
extern void transname();
extern void do_indent();
#define LOCALOPT "ilqVH" #define LOCALOPT "ilqVH"
static void usage(); static void usage(void);
static char options[128]; static char options[128];
static char *dir_stack; static char *dir_stack;
@ -101,8 +99,8 @@ int main(int argc, char **argv)
if(i == ISFILE) { if(i == ISFILE) {
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (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)data_size, (long)rsrc_size); text, ftype, fauth, (int32_t)data_size, (int32_t)rsrc_size);
} else if(i == ISDIR) { } else if(i == ISDIR) {
do_indent(indent); do_indent(indent);
dir_ptr += 64; dir_ptr += 64;
@ -173,7 +171,8 @@ int main(int argc, char **argv)
/* NOTREACHED */ /* NOTREACHED */
} }
static void usage() static void
usage (void)
{ {
(void)fprintf(stderr, "Usage: macstream [-%s] files\n", options); (void)fprintf(stderr, "Usage: macstream [-%s] files\n", options);
(void)fprintf(stderr, "Use \"macstream -H\" for help.\n"); (void)fprintf(stderr, "Use \"macstream -H\" for help.\n");

View File

@ -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

Some files were not shown because too many files have changed in this diff Show More