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
all
macunpack/macunpack
/builddir

View File

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

View File

@ -1,10 +1,10 @@
#include "dofile.h"
#include <stdio.h>
#include "../fileio/machdr.h"
#include "../fileio/rdfile.h"
#include "../crc/crc.h"
extern int dorep;
extern unsigned long binhex_crcinit;
extern unsigned long binhex_updcrc();
#define RUNCHAR 0x90
@ -16,15 +16,16 @@ static int savebits;
static int rep_char;
static int rep_count;
void doheader();
void dofork();
void outbyte();
void finish();
void outbyte1();
void out6bit();
void outchar();
static void doheader();
static void dofork(char *fork, int size);
static void outbyte(int b);
static void finish(void);
static void outbyte1(int b);
static void out6bit(int c);
static void outchar(int c);
void dofile()
void
dofile (void)
{
(void)printf("(This file must be converted; you knew that already.)\n");
(void)printf("\n");
@ -41,37 +42,38 @@ void dofile()
(void)putchar('\n');
}
void doheader()
static void
doheader (void)
{
unsigned long crc;
uint32_t crc;
int i, n;
crc = binhex_crcinit;
n = file_info[I_NAMEOFF];
crc = binhex_updcrc(crc, file_info + I_NAMEOFF, n + 1);
crc = binhex_updcrc(crc, (unsigned char*)(file_info + I_NAMEOFF), n + 1);
for(i = 0; i <= n; i++) {
outbyte(file_info[I_NAMEOFF + i]);
}
n = 0;
crc = binhex_updcrc(crc, (char *)&n, 1);
crc = binhex_updcrc(crc, (unsigned char *)&n, 1);
outbyte(0);
crc = binhex_updcrc(crc, file_info + I_TYPEOFF, 4);
crc = binhex_updcrc(crc, (unsigned char*)(file_info + I_TYPEOFF), 4);
for(i = 0; i < 4; i++) {
outbyte(file_info[I_TYPEOFF + i]);
}
crc = binhex_updcrc(crc, file_info + I_AUTHOFF, 4);
crc = binhex_updcrc(crc, (unsigned char*)(file_info + I_AUTHOFF), 4);
for(i = 0; i < 4; i++) {
outbyte(file_info[I_AUTHOFF + i]);
}
crc = binhex_updcrc(crc, file_info + I_FLAGOFF, 2);
crc = binhex_updcrc(crc, (unsigned char*)(file_info + I_FLAGOFF), 2);
for(i = 0; i < 2; i++) {
outbyte(file_info[I_FLAGOFF + i]);
}
crc = binhex_updcrc(crc, file_info + I_DLENOFF, 4);
crc = binhex_updcrc(crc, (unsigned char*)(file_info + I_DLENOFF), 4);
for(i = 0; i < 4; i++) {
outbyte(file_info[I_DLENOFF + i]);
}
crc = binhex_updcrc(crc, file_info + I_RLENOFF, 4);
crc = binhex_updcrc(crc, (unsigned char*)(file_info + I_RLENOFF), 4);
for(i = 0; i < 4; i++) {
outbyte(file_info[I_RLENOFF + i]);
}
@ -79,14 +81,13 @@ int i, n;
outbyte((int)(crc & 0xff));
}
void dofork(fork, size)
char *fork;
int size;
void
dofork (char *fork, int size)
{
unsigned long crc;
uint32_t crc;
int i;
crc = binhex_updcrc(binhex_crcinit, fork, size);
crc = binhex_updcrc(binhex_crcinit, (unsigned char*)fork, size);
for(i = 0; i < size; i++) {
outbyte(fork[i]);
}
@ -94,8 +95,8 @@ int i;
outbyte((int)(crc & 0xff));
}
void outbyte(b)
int b;
static void
outbyte (int b)
{
b &= 0xff;
if(dorep && (b == rep_char)) {
@ -127,7 +128,8 @@ int b;
}
}
void finish()
static void
finish (void)
{
if(rep_count > 0) {
if(rep_count > 3) {
@ -151,8 +153,8 @@ void finish()
}
}
void outbyte1(b)
int b;
static void
outbyte1 (int b)
{
switch(state) {
case 0:
@ -175,14 +177,14 @@ int b;
}
}
void out6bit(c)
char c;
static void
out6bit (int c)
{
outchar(codes[c & 0x3f]);
}
void outchar(c)
char c;
static void
outchar (int c)
{
(void)putchar(c);
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 "../fileio/machdr.h"
#include "globals.h"
#include "tty.h"
#include "../fileio/fileglob.h"
#include "../fileio/wrfile.h"
#include "../fileio/wrfileopt.h"
@ -17,12 +18,9 @@
#define LOCALOPT "lmxyzoTVH"
extern void setup_tty();
extern void reset_tty();
extern char info[];
static void usage();
static void usage(void);
static char options[128];
static int multi_file = 0;
@ -30,8 +28,6 @@ static int listmode = 0;
int main(int argc, char **argv)
{
extern int optind;
extern char *optarg;
int errflg;
int c;
char tname[64];
@ -155,7 +151,7 @@ int main(int argc, char **argv)
transname(info + I_AUTHOFF, fauth, 4);
transname(info + I_TYPEOFF, ftype, 4);
(void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld",
"name=\"%s\", type=%4.4s, author=%4.4s, data=%u, rsrc=%u",
tname, ftype, fauth,
get4(info + I_DLENOFF), get4(info + I_RLENOFF));
(void)fprintf(stderr, "\n");
@ -165,7 +161,8 @@ int main(int argc, char **argv)
/* NOTREACHED */
}
static void usage()
static void
usage (void)
{
(void)fprintf(stderr, "Usage: frommac [-%s]\n", options);
(void)fprintf(stderr, "Use \"frommac -H\" for help.\n");

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

View File

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

View File

@ -1 +1,7 @@
void cleanup(int sig);
void reset_tty (void);
void setup_tty (void);
int tgetrec(char *buf, int count, int timeout);
int tgetc (int timeout);
void tputc(int c);
void tputrec (char *buf, int count);

View File

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

View File

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

View File

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

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,8 +9,8 @@ int data_size, rsrc_size;
static int max_data_size, max_rsrc_size;
static int do_data;
void put_byte(c)
char c;
void
put_byte (int c)
{
if(do_data) {
if(data_size >= max_data_size) {
@ -43,8 +43,8 @@ char c;
}
}
void set_put(data)
int data;
void
set_put (int data)
{
do_data = data;
if(do_data) {
@ -54,12 +54,13 @@ int data;
}
}
void end_put()
void
end_put (void)
{
if(info_only) {
return;
}
start_info(info, (unsigned long)rsrc_size, (unsigned long)data_size);
start_info(info, (uint32_t)rsrc_size, (uint32_t)data_size);
if(data_size != 0) {
start_data();
copy(out_ptr, data_fork, data_size);

View File

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

View File

@ -6,34 +6,34 @@
#include "../util/masks.h"
#include "globals.h"
extern void exit();
#include <stdlib.h>
unsigned long crc;
uint32_t crc;
#ifdef HQX
void comp_q_crc(c)
register unsigned int c;
void
comp_q_crc (register unsigned int c)
{
unsigned char cc = c;
crc = binhex_updcrc(crc, &cc, 1);
}
void comp_q_crc_n(s, e)
register unsigned char *s, *e;
void
comp_q_crc_n (register unsigned char *s, register unsigned char *e)
{
crc = binhex_updcrc(crc, s, e - s);
}
#endif /* HQX */
void verify_crc(calc_crc, file_crc)
unsigned long calc_crc, file_crc;
void
verify_crc (uint32_t calc_crc, uint32_t file_crc)
{
calc_crc &= WORDMASK;
file_crc &= WORDMASK;
if(calc_crc != file_crc) {
(void)fprintf(stderr, "CRC mismatch: got 0x%04lx, need 0x%04lx\n",
(void)fprintf(stderr, "CRC mismatch: got 0x%04x, need 0x%04x\n",
file_crc, calc_crc);
#ifdef SCAN
do_error("hexbin: CRC error");

View File

@ -1,10 +1,10 @@
#define INITCRC binhex_crcinit
extern unsigned long crc;
extern unsigned long binhex_crcinit;
extern unsigned long binhex_updcrc();
#include "../crc/crc.h"
extern void comp_q_crc();
extern void comp_q_crc_n();
extern void verify_crc();
extern uint32_t crc;
extern void comp_q_crc (register unsigned int c);
extern void comp_q_crc_n (register unsigned char *s, register unsigned char *e);
extern void verify_crc (uint32_t calc_crc, uint32_t file_crc);

View File

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

View File

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

View File

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

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

View File

@ -1,4 +1,5 @@
#include "hexbin.h"
#include "hqx.h"
#ifdef HQX
#include <stdlib.h>
#include "globals.h"
@ -8,14 +9,15 @@
#include "../fileio/machdr.h"
#include "../fileio/wrfile.h"
#include "../util/util.h"
#include "../util/transname.h"
#include "printhdr.h"
static void get_header();
static void oflush();
static int getq();
static long get2q();
static long get4q();
static void getqbuf();
static void get_header(void);
static void oflush(void);
static int getq(void);
static int32_t get2q(void);
static int32_t get4q(void);
static void getqbuf(char *buf, int n);
static char *g_macname;
@ -97,19 +99,19 @@ static unsigned char *oq;
static int ostate = S_HEADER;
static unsigned long calc_crc;
static unsigned long file_crc;
static uint32_t calc_crc;
static uint32_t file_crc;
static long todo;
static int32_t todo;
#define output(c) { *op++ = (c); if(op >= &obuf[BUFSIZ]) oflush(); }
void hqx(macname)
char *macname;
void
hqx (char *macname)
{
int n, normlen, c;
register char *in, *out;
register int b6, b8, data, lastc = 0;
register int b6, b8 = 0, data = 0, lastc = 0;
char state68 = 0, run = 0, linestate, first = 1;
g_macname = macname;
@ -231,10 +233,11 @@ done:
print_header2(verbose);
}
static void get_header()
static void
get_header (void)
{
int n;
unsigned long calc_crc, file_crc;
uint32_t calc_crc, file_crc;
crc = INITCRC; /* compute a crc for the header */
@ -275,14 +278,15 @@ static void get_header()
(void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n);
(void)strncpy(info + I_TYPEOFF, mh.m_type, 4);
(void)strncpy(info + I_AUTHOFF, mh.m_author, 4);
put2(info + I_FLAGOFF, (unsigned long)mh.m_flags);
put4(info + I_DLENOFF, (unsigned long)mh.m_datalen);
put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen);
put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime);
put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime);
put2(info + I_FLAGOFF, (uint32_t)mh.m_flags);
put4(info + I_DLENOFF, (uint32_t)mh.m_datalen);
put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen);
put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime);
put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime);
}
static void oflush()
static void
oflush (void)
{
int n, i;
@ -335,7 +339,7 @@ static void oflush()
++ostate;
break;
case S_EXCESS:
(void)fprintf(stderr, "%d excess bytes ignored\n", op-oq);
(void)fprintf(stderr, "%ld excess bytes ignored\n", op-oq);
oq = op;
break;
}
@ -343,7 +347,8 @@ static void oflush()
op = obuf;
}
static int getq()
static int
getq (void)
{
int c;
@ -360,17 +365,19 @@ static int getq()
}
/* get2q(); q format -- read 2 bytes from input, return short */
static long get2q()
static int32_t
get2q (void)
{
short high = getq() << 8;
return high | getq();
}
/* get4q(); q format -- read 4 bytes from input, return long */
static long get4q()
static int32_t
get4q (void)
{
int i;
long value = 0;
int32_t value = 0;
for(i = 0; i < 4; i++) {
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 "mu.h"
#ifdef MU
#include "globals.h"
#include "readline.h"
#include "../util/masks.h"
#include "../util/util.h"
#include "../util/transname.h"
#include "../fileio/machdr.h"
#include "../fileio/wrfile.h"
#include "buffer.h"
#include "printhdr.h"
extern void exit();
#include <stdlib.h>
static void do_mu_fork();
static int mu_comp_to_bin();
static int mu_convert();
static void do_mu_fork(void);
static int mu_comp_to_bin(void);
static int mu_convert(char *ibuf, char *obuf);
/* mu format -- process .mu files */
void mu(macname)
char *macname;
void
mu (char *macname)
{
int n;
@ -135,17 +137,18 @@ char *macname;
(void)strncpy(mh.m_type, info + I_TYPEOFF, 4);
(void)strncpy(mh.m_author, info + I_AUTHOFF, 4);
print_header1(0, 0);
put4(info + I_DLENOFF, (unsigned long)mh.m_datalen);
put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen);
put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime);
put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime);
put4(info + I_DLENOFF, (uint32_t)mh.m_datalen);
put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen);
put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime);
put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime);
print_header2(0);
end_put();
}
static void do_mu_fork()
static void
do_mu_fork (void)
{
long newbytes;
int32_t newbytes;
while(readline()) {
if(line[0] == 0) {
@ -179,7 +182,8 @@ static void do_mu_fork()
/*NOTREACHED*/
}
static int mu_comp_to_bin()
static int
mu_comp_to_bin (void)
{
char obuf[BUFSIZ];
int outcount, n;
@ -193,8 +197,8 @@ static int mu_comp_to_bin()
#define SIXB(c) (((c)-0x20) & 0x3f)
static int mu_convert(ibuf, obuf)
char *ibuf, *obuf;
static int
mu_convert (char *ibuf, char *obuf)
{
register char *ip = ibuf;
register char *op = obuf;

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

View File

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

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
a non-terminated line at end-of-file. Returns 1 if a line is read,
0 otherwise. */
int readline()
int
readline (void)
{
int ptr = 0, c;

View File

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

View File

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

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

View File

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

View File

@ -5,15 +5,19 @@
#endif /* CPT */
#endif /* DD */
#ifdef CPT
#define CPT_INTERNAL
#include "cpt.h"
#include <stdlib.h>
#include "globals.h"
#include "cpt.h"
#include "crc.h"
#include "../util/util.h"
#include "../fileio/machdr.h"
#include "../fileio/wrfile.h"
#include "../fileio/kind.h"
#include "../util/masks.h"
#include "../util/transname.h"
#include "huffman.h"
#define ESC1 0x81
@ -22,19 +26,18 @@
#define ESC1SEEN 1
#define ESC2SEEN 2
static void cpt_uncompact();
static unsigned char *cpt_data;
static unsigned long cpt_datamax;
static unsigned long cpt_datasize;
static uint32_t cpt_datamax;
static uint32_t cpt_datasize;
static unsigned char cpt_LZbuff[CIRCSIZE];
static unsigned int cpt_LZptr;
static unsigned char *cpt_char;
static unsigned long cpt_crc;
static unsigned long cpt_inlength;
static unsigned long cpt_outlength;
static uint32_t cpt_crc;
static uint32_t cpt_inlength;
static uint32_t cpt_outlength;
static int cpt_outstat;
static unsigned char cpt_savechar;
static unsigned long cpt_newbits;
static uint32_t cpt_newbits;
static int cpt_bitsavail;
static int cpt_blocksize;
/* Lengths is twice the max number of entries, and include slack. */
@ -42,23 +45,23 @@ static int cpt_blocksize;
static node cpt_Hufftree[512 + SLACK], cpt_LZlength[128 + SLACK],
cpt_LZoffs[256 + SLACK];
static int readcpthdr();
static int cpt_filehdr();
static void cpt_folder();
static void cpt_uncompact();
static void cpt_wrfile();
void cpt_wrfile1();
static void cpt_outch();
static void cpt_rle();
static void cpt_rle_lzh();
static void cpt_readHuff();
static int cpt_get6bits();
static int cpt_getbit();
static int readcpthdr(struct cptHdr *s);
static int cpt_filehdr(struct cpt_fileHdr *f, char *hdr);
static void cpt_folder(char *name, struct cpt_fileHdr fileh, char *cptptr);
static void cpt_uncompact(struct cpt_fileHdr filehdr);
static void cpt_wrfile(uint32_t ibytes, uint32_t obytes, int type);
static void cpt_outch(int ch);
static void cpt_rle(void);
static void cpt_rle_lzh(void);
static void cpt_readHuff(int size, struct node *Hufftree);
static int cpt_get6bits(void);
static int cpt_getbit(void);
void cpt()
void
cpt (void)
{
struct cptHdr cpthdr;
struct fileHdr filehdr;
struct cpt_fileHdr filehdr;
char *cptindex;
int cptindsize;
char *cptptr;
@ -75,7 +78,7 @@ void cpt()
exit(1);
}
cptindsize = cpthdr.entries * FILEHDRSIZE;
cptindsize = cpthdr.entries * CPT_FILEHDRSIZE;
if(cpthdr.commentsize > cptindsize) {
cptindsize = cpthdr.commentsize;
}
@ -92,11 +95,11 @@ void cpt()
#endif /* SCAN */
exit(1);
}
cpt_crc = (*updcrc)(cpt_crc, cptptr, cpthdr.commentsize);
cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)cptptr, cpthdr.commentsize);
for(i = 0; i < cpthdr.entries; i++) {
*cptptr = getc(infp);
cpt_crc = (*updcrc)(cpt_crc, cptptr, 1);
cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)cptptr, 1);
if(*cptptr & 0x80) {
cptptr[F_FOLDER] = 1;
*cptptr &= 0x3f;
@ -110,7 +113,7 @@ void cpt()
#endif /* SCAN */
exit(1);
}
cpt_crc = (*updcrc)(cpt_crc, cptptr + 1, *cptptr);
cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)(cptptr + 1), *cptptr);
if(cptptr[F_FOLDER]) {
if(fread(cptptr + F_FOLDERSIZE, 1, 2, infp) != 2) {
(void)fprintf(stderr, "Can't read file header #%d\n", i+1);
@ -119,20 +122,20 @@ void cpt()
#endif /* SCAN */
exit(1);
}
cpt_crc = (*updcrc)(cpt_crc, cptptr + F_FOLDERSIZE, 2);
cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)(cptptr + F_FOLDERSIZE), 2);
} else {
if(fread(cptptr + F_VOLUME, 1, FILEHDRSIZE - F_VOLUME, infp) !=
FILEHDRSIZE - F_VOLUME) {
if(fread(cptptr + F_VOLUME, 1, CPT_FILEHDRSIZE - F_VOLUME, infp) !=
CPT_FILEHDRSIZE - F_VOLUME) {
(void)fprintf(stderr, "Can't read file header #%d\n", i+1);
#ifdef SCAN
do_error("macunpack: Can't read file header");
#endif /* SCAN */
exit(1);
}
cpt_crc = (*updcrc)(cpt_crc, cptptr + F_VOLUME,
FILEHDRSIZE - F_VOLUME);
cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)(cptptr + F_VOLUME),
CPT_FILEHDRSIZE - F_VOLUME);
}
cptptr += FILEHDRSIZE;
cptptr += CPT_FILEHDRSIZE;
}
if(cpt_crc != cpthdr.hdrcrc) {
(void)fprintf(stderr, "Header CRC mismatch: got 0x%08x, need 0x%08x\n",
@ -155,17 +158,17 @@ void cpt()
if(filehdr.folder) {
cpt_folder(text, filehdr, cptptr);
i += filehdr.foldersize;
cptptr += filehdr.foldersize * FILEHDRSIZE;
cptptr += filehdr.foldersize * CPT_FILEHDRSIZE;
} else {
cpt_uncompact(filehdr);
}
cptptr += FILEHDRSIZE;
cptptr += CPT_FILEHDRSIZE;
}
(void)free(cptindex);
}
static int readcpthdr(s)
struct cptHdr *s;
static int
readcpthdr (struct cptHdr *s)
{
char temp[CHDRSIZE];
@ -203,17 +206,16 @@ struct cptHdr *s;
return 0;
}
cpt_crc = (*updcrc)(cpt_crc, temp + CPTHDRSIZE + C_ENTRIES, 3);
s->hdrcrc = get4(temp + CPTHDRSIZE + C_HDRCRC);
cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)(temp + CPTHDRSIZE + C_ENTRIES), 3);
s->hdrcrc = get4(temp + CPTHDRSIZE + CPT_C_HDRCRC);
s->entries = get2(temp + CPTHDRSIZE + C_ENTRIES);
s->commentsize = temp[CPTHDRSIZE + C_COMMENT];
return 1;
}
static int cpt_filehdr(f, hdr)
struct fileHdr *f;
char *hdr;
static int
cpt_filehdr (struct cpt_fileHdr *f, char *hdr)
{
register int i;
int n;
@ -255,9 +257,9 @@ char *hdr;
transname(hdr + F_FTYPE, ftype, 4);
transname(hdr + F_CREATOR, fauth, 4);
(void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld",
"name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth,
(long)f->dataLength, (long)f->rsrcLength);
(int32_t)f->dataLength, (int32_t)f->rsrcLength);
}
if(info_only) {
write_it = 0;
@ -286,20 +288,18 @@ char *hdr;
return 1;
}
static void cpt_folder(name, fileh, cptptr)
char *name;
struct fileHdr fileh;
char *cptptr;
static void
cpt_folder (char *name, struct cpt_fileHdr fileh, char *cptptr)
{
int i, nfiles;
char loc_name[64];
struct fileHdr filehdr;
struct cpt_fileHdr filehdr;
for(i = 0; i < 64; i++) {
loc_name[i] = name[i];
}
if(write_it || info_only) {
cptptr += FILEHDRSIZE;
cptptr += CPT_FILEHDRSIZE;
nfiles = fileh.foldersize;
if(write_it) {
do_mkdir(text, info);
@ -316,11 +316,11 @@ char *cptptr;
if(filehdr.folder) {
cpt_folder(text, filehdr, cptptr);
i += filehdr.foldersize;
cptptr += filehdr.foldersize * FILEHDRSIZE;
cptptr += filehdr.foldersize * CPT_FILEHDRSIZE;
} else {
cpt_uncompact(filehdr);
}
cptptr += FILEHDRSIZE;
cptptr += CPT_FILEHDRSIZE;
}
if(write_it) {
enddir();
@ -333,8 +333,8 @@ char *cptptr;
}
}
static void cpt_uncompact(filehdr)
struct fileHdr filehdr;
static void
cpt_uncompact (struct cpt_fileHdr filehdr)
{
if(filehdr.cptFlag & 1) {
(void)fprintf(stderr, "\tFile is password protected, skipping file\n");
@ -384,8 +384,8 @@ struct fileHdr filehdr;
filehdr.cptFlag & 4);
if(filehdr.fileCRC != cpt_crc) {
(void)fprintf(stderr,
"CRC error on file: need 0x%08lx, got 0x%08lx\n",
(long)filehdr.fileCRC, (long)cpt_crc);
"CRC error on file: need 0x%08x, got 0x%08x\n",
(int32_t)filehdr.fileCRC, (int32_t)cpt_crc);
#ifdef SCAN
do_error("macunpack: CRC error on file");
#endif /* SCAN */
@ -398,9 +398,8 @@ struct fileHdr filehdr;
}
}
static void cpt_wrfile(ibytes, obytes, type)
unsigned long ibytes, obytes;
unsigned short type;
static void
cpt_wrfile (uint32_t ibytes, uint32_t obytes, int type)
{
if(ibytes == 0) {
return;
@ -415,13 +414,11 @@ unsigned short type;
} else {
cpt_rle_lzh();
}
cpt_crc = (*updcrc)(cpt_crc, out_buffer, obytes);
cpt_crc = (*updcrc)(cpt_crc, (unsigned char*)out_buffer, obytes);
}
void cpt_wrfile1(in_char, ibytes, obytes, type, blocksize)
unsigned char *in_char;
unsigned long ibytes, obytes, blocksize;
int type;
void
cpt_wrfile1 (unsigned char *in_char, uint32_t ibytes, uint32_t obytes, int type, uint32_t blocksize)
{
cpt_char = in_char;
if(ibytes == 0) {
@ -439,8 +436,8 @@ int type;
}
}
static void cpt_outch(ch)
unsigned char ch;
static void
cpt_outch (int ch)
{
cpt_LZbuff[cpt_LZptr++ & (CIRCSIZE - 1)] = ch;
switch(cpt_outstat) {
@ -498,7 +495,8 @@ unsigned char ch;
/*---------------------------------------------------------------------------*/
/* Run length encoding */
/*---------------------------------------------------------------------------*/
static void cpt_rle()
static void
cpt_rle (void)
{
while(cpt_inlength-- > 0) {
cpt_outch(*cpt_char++);
@ -508,7 +506,8 @@ static void cpt_rle()
/*---------------------------------------------------------------------------*/
/* Run length encoding plus LZ compression plus Huffman encoding */
/*---------------------------------------------------------------------------*/
static void cpt_rle_lzh()
static void
cpt_rle_lzh (void)
{
int block_count;
unsigned int bptr;
@ -556,9 +555,8 @@ typedef struct sf_entry {
/* See routine LoadTree. The parameter tree (actually an array and
two integers) are only used locally in this version and hence locally
declared. The parameter nodes has been renamed Hufftree.... */
static void cpt_readHuff(size, Hufftree)
int size;
struct node *Hufftree;
static void
cpt_readHuff (int size, struct node *Hufftree)
{
sf_entry tree_entry[256 + SLACK]; /* maximal number of elements */
int tree_entries;
@ -680,7 +678,8 @@ struct node *Hufftree;
Hufftree[0].flag = 0;
}
static int cpt_get6bits()
static int
cpt_get6bits (void)
{
int b = 0, cn;
@ -696,7 +695,8 @@ int b = 0, cn;
return b;
}
static int cpt_getbit()
static int
cpt_getbit (void)
{
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_VOLUME 1
#define C_XMAGIC 2
#define C_IOFFSET 4
#define CPTHDRSIZE 8
#define C_HDRCRC 0
#define CPT_C_HDRCRC 0
#define C_ENTRIES 4
#define C_COMMENT 6
#define CPTHDR2SIZE 7
@ -27,58 +33,58 @@
#define F_DATALENGTH 68
#define F_COMPRLENGTH 72
#define F_COMPDLENGTH 76
#define FILEHDRSIZE 80
#define CPT_FILEHDRSIZE 80
typedef long OSType;
typedef int32_t OSType;
typedef struct cptHdr { /* 8 bytes */
unsigned char signature; /* = 1 -- for verification */
unsigned char volume; /* for multi-file archives */
unsigned short xmagic; /* verification multi-file consistency*/
unsigned long offset; /* index offset */
unsigned char signature; /* = 1 -- for verification */
unsigned char volume; /* for multi-file archives */
unsigned short xmagic; /* verification multi-file consistency*/
uint32_t offset; /* index offset */
/* The following are really in header2 at offset */
unsigned long hdrcrc; /* header crc */
unsigned short entries; /* number of index entries */
unsigned char commentsize; /* number of bytes comment that follow*/
uint32_t hdrcrc; /* header crc */
unsigned short entries; /* number of index entries */
unsigned char commentsize; /* number of bytes comment that follow*/
} cptHdr;
typedef struct fileHdr { /* 78 bytes */
unsigned char fName[32]; /* a STR32 */
unsigned char folder; /* set to 1 if a folder */
unsigned short foldersize; /* number of entries in folder */
unsigned char volume; /* for multi-file archives */
unsigned long filepos; /* position of data in file */
OSType fType; /* file type */
OSType fCreator; /* er... */
unsigned long creationDate;
unsigned long modDate; /* !restored-compat w/backup prgms */
unsigned short FndrFlags; /* copy of Finder flags. For our
purposes, we can clear:
busy,onDesk */
unsigned long fileCRC; /* crc on file */
unsigned short cptFlag; /* cpt flags */
unsigned long rsrcLength; /* decompressed lengths */
unsigned long dataLength;
unsigned long compRLength; /* compressed lengths */
unsigned long compDLength;
} fileHdr;
typedef struct cpt_fileHdr { /* 78 bytes */
unsigned char fName[32]; /* a STR32 */
unsigned char folder; /* set to 1 if a folder */
unsigned short foldersize; /* number of entries in folder */
unsigned char volume; /* for multi-file archives */
uint32_t filepos; /* position of data in file */
OSType fType; /* file type */
OSType fCreator; /* er... */
uint32_t creationDate;
uint32_t modDate; /* !restored-compat w/backup prgms */
unsigned short FndrFlags; /* copy of Finder flags. For our
purposes, we can clear:
busy,onDesk */
uint32_t fileCRC; /* crc on file */
unsigned short cptFlag; /* cpt flags */
uint32_t rsrcLength; /* decompressed lengths */
uint32_t dataLength;
uint32_t compRLength; /* compressed lengths */
uint32_t compDLength;
} cpt_fileHdr;
/* file format is:
cptArchiveHdr
file1data
file1RsrcFork
file1DataFork
file2data
file2RsrcFork
file2DataFork
.
.
.
fileNdata
fileNRsrcFork
fileNDataFork
cptIndex
cptArchiveHdr
file1data
file1RsrcFork
file1DataFork
file2data
file2RsrcFork
file2DataFork
.
.
.
fileNdata
fileNRsrcFork
fileNDataFork
cptIndex
*/
@ -91,3 +97,13 @@ typedef struct fileHdr { /* 78 bytes */
#define CIRCSIZE 8192
#endif
void
cpt_wrfile1 (unsigned char *in_char,
uint32_t ibytes,
uint32_t obytes,
int type,
uint32_t blocksize);
void cpt (void);
#endif

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
extern unsigned long arc_crcinit;
extern unsigned long binhex_crcinit;
extern unsigned long zip_crcinit;
extern unsigned long arc_updcrc();
extern unsigned long binhex_updcrc();
extern unsigned long zip_updcrc();
extern unsigned long crcinit;
extern unsigned long (*updcrc)();
#include "../crc/crc.h"
extern uint32_t crcinit;
extern uint32_t (*updcrc)(uint32_t icrc, unsigned char *icp, int32_t icnt);

View File

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

View File

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

View File

@ -1,3 +1,7 @@
#include "de_compress.h"
#include <stdlib.h>
#include "macunpack.h"
#ifdef SIT
#define DECOMPRESS
@ -18,20 +22,20 @@
static int n_bits; /* number of bits/code */
static int maxbits; /* user settable max # bits/code */
static long maxcode; /* maximum code, given n_bits */
static long maxmaxcode; /* should NEVER generate this code */
static int32_t maxcode; /* maximum code, given n_bits */
static int32_t maxmaxcode; /* should NEVER generate this code */
# define MAXCODE(n_bits) ((1 << (n_bits)) - 1)
static long htab [HSIZE];
static int32_t htab [HSIZE];
static unsigned short codetab [HSIZE];
#define tab_prefixof(i) codetab[i]
#define tab_suffixof(i) ((unsigned char *)(htab))[i]
#define de_stack ((unsigned char *)&tab_suffixof(1<<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;
@ -44,13 +48,11 @@ static int clear_flg = 0;
static int toread;
void de_compress(ibytes, mb)
unsigned long ibytes;
int mb;
void de_compress(uint32_t ibytes, int mb)
{
register unsigned char *stackp;
register int finchar;
register long code, oldcode, incode;
register int32_t code, oldcode, incode;
toread = ibytes;
maxbits = mb;
@ -122,12 +124,13 @@ static unsigned char rmask[9] =
static int get_core_bytes;
static char *core_ptr;
static int file_bytes();
static int core_bytes();
static int file_bytes(char *buf, int length);
static int core_bytes(char *buf, int length);
static long getcode()
static int32_t
getcode (void)
{
register long code;
register int32_t code;
static int offset = 0, size = 0;
static unsigned char buf[BITS];
register int r_off, bits;
@ -194,16 +197,14 @@ static long getcode()
return code;
}
static int file_bytes(buf, length)
char *buf;
int length;
static int
file_bytes (char *buf, int length)
{
return fread(buf, 1, length, infp);
}
static int core_bytes(buf, length)
char *buf;
int length;
static int
core_bytes (char *buf, int length)
{
int i;
@ -213,8 +214,7 @@ int length;
return length;
}
void core_compress(ptr)
char *ptr;
void core_compress(char* ptr)
{
core_ptr = ptr;
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"
#ifdef JDW
#define DEHUFFMAN
@ -21,19 +23,19 @@
#include "huffman.h"
#include "../util/util.h"
int (*get_bit)();
int (*get_bit)(void);
int bytesread;
/* 515 because StuffIt Classic needs more than the needed 511 */
struct node nodelist[515];
static int getbit_be();
static int getbit_le();
static int getdecodebyte();
static int getbit_be(void);
static int getbit_le(void);
static int getdecodebyte(void);
static node *nodeptr, *read_sub_tree();
static node *nodeptr, *read_sub_tree(void);
static int bit;
void de_huffman(unsigned long obytes)
void de_huffman(uint32_t obytes)
{
while(obytes != 0) {
*out_ptr++ = gethuffbyte(nodelist);
@ -60,7 +62,8 @@ void set_huffman(int endian)
}
}
void read_tree()
void
read_tree (void)
{
nodeptr = nodelist;
bit = 0; /* put us on a boundary */
@ -69,7 +72,7 @@ void read_tree()
/* This routine recursively reads the Huffman encoding table and builds
a decoding tree. */
static node *read_sub_tree()
static node *read_sub_tree(void)
{
node *np;
@ -86,7 +89,8 @@ static node *read_sub_tree()
}
/* This routine returns the next bit in the input stream (MSB first) */
static int getbit_be()
static int
getbit_be (void)
{
static int b;
@ -100,7 +104,8 @@ static int getbit_be()
}
/* This routine returns the next bit in the input stream (LSB first) */
static int getbit_le()
static int
getbit_le (void)
{
static int b;
@ -113,7 +118,8 @@ static int getbit_le()
return (b >> (7 - bit)) & 1;
}
void clrhuff()
void
clrhuff (void)
{
bit = 0;
}
@ -129,12 +135,14 @@ int gethuffbyte(node *l_nodelist)
return np->byte;
}
int getihuffbyte()
int
getihuffbyte (void)
{
return gethuffbyte(nodelist);
}
static int getdecodebyte()
static int
getdecodebyte (void)
{
register int i, b;

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

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

View File

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

View File

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

View File

@ -1,16 +1,19 @@
#include "dir.h"
#include <stdlib.h>
#include "globals.h"
#include "../fileio/machdr.h"
#include "../fileio/wrfile.h"
#include "../util/util.h"
#include "../util/masks.h"
#include "../util/transname.h"
static char *dir_stack;
static int dir_ptr = -64;
static int dir_max;
void dir(hdr)
char *hdr;
void
dir (char *hdr)
{
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;
#ifdef SCAN
void do_error(string)
char *string;
void
do_error (char *string)
{
do_idf(string, ERROR);
}

View File

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

View File

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

View File

@ -1,24 +1,23 @@
#include "macunpack.h"
#ifdef JDW
#define JDW_INTERNAL
#include "jdw.h"
#include "globals.h"
#include "huffman.h"
#include "de_huffman.h"
#include "../fileio/wrfile.h"
#include "../fileio/machdr.h"
#include "../util/util.h"
#include "../util/transname.h"
#include "../util/masks.h"
extern void de_huffman();
extern void set_huffman();
extern void read_tree();
extern void clrhuff();
static void jdw_wrfile(uint32_t rsrcLength, uint32_t dataLength);
static void jdw_wrfork(uint32_t length);
static void jdw_block(int olength);
static void jdw_wrfile();
static void jdw_wrfork();
static void jdw_block();
void jdw(ibytes)
unsigned long ibytes;
void
jdw (uint32_t ibytes)
{
char fauth[5], ftype[5];
int filel, i;
@ -67,8 +66,8 @@ unsigned long ibytes;
transname(info + I_AUTHOFF, fauth, 4);
do_indent(indent);
(void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld",
text, ftype, fauth, (long)dataLength, (long)rsrcLength);
"name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength);
if(info_only) {
write_it = 0;
}
@ -78,11 +77,11 @@ unsigned long ibytes;
(void)fputc('\n', stderr);
}
}
jdw_wrfile((unsigned long)rsrcLength, (unsigned long)dataLength);
jdw_wrfile((uint32_t)rsrcLength, (uint32_t)dataLength);
}
static void jdw_wrfile(rsrcLength, dataLength)
unsigned long rsrcLength, dataLength;
static void
jdw_wrfile (uint32_t rsrcLength, uint32_t dataLength)
{
if(write_it) {
define_name(text);
@ -108,11 +107,11 @@ unsigned long rsrcLength, dataLength;
}
}
static void jdw_wrfork(length)
unsigned long length;
static void
jdw_wrfork (uint32_t length)
{
int olength, ilength, i;
unsigned long origlength, comprlength;
uint32_t origlength, comprlength;
if(length == 0) {
(void)fprintf(stderr, "empty");
@ -141,8 +140,8 @@ unsigned long length;
}
}
static void jdw_block(olength)
int olength;
static void
jdw_block (int olength)
{
bytesread = 0;
read_tree();
@ -152,7 +151,7 @@ int olength;
bytesread++;
}
clrhuff();
de_huffman((unsigned long)olength);
de_huffman((uint32_t)olength);
}
#else /* JDW */
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_TYPE 6
#define J_AUTH 10
@ -8,16 +14,19 @@
#define J_MTIME 34
#define J_FLENGTH 38
typedef struct fileHdr {
typedef struct jdw_fileHdr {
char magic[6];
unsigned long type;
unsigned long auth;
uint32_t type;
uint32_t auth;
char finfo[8];
unsigned long dataLength;
unsigned long rsrcLength;
unsigned long ctime;
unsigned long mtime;
uint32_t dataLength;
uint32_t rsrcLength;
uint32_t ctime;
uint32_t mtime;
char flength;
char fname[32]; /* actually flength */
} fileHdr;
} jdw_fileHdr;
#endif
void jdw (uint32_t ibytes);
#endif

View File

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

View File

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

View File

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

View File

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

View File

@ -1,65 +1,46 @@
#include "macunpack.h"
#include "macbinary.h"
#include <stdlib.h>
#include <string.h>
#include "globals.h"
#include "../fileio/kind.h"
#include "../fileio/machdr.h"
#include "../fileio/wrfile.h"
#include "../fileio/kind.h"
#include "zmahdr.h"
#include "../util/util.h"
#include "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
extern void asq();
#endif /* ASQ */
#ifdef ARC
extern void 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
static void get_idf();
static void get_idf(int kind);
#endif /* SCAN */
#define Z (ZMAHDRS2 + 1)
static int info_given;
void macbinary()
void
macbinary (void)
{
char header[INFOBYTES];
int c;
@ -82,7 +63,7 @@ void macbinary()
if(verbose) {
(void)fprintf(stderr, "This is a \"Zoom\" archive.\n");
}
zma(header, (unsigned long)0);
zma(header, (uint32_t)0);
exit(0);
}
#endif /* ZMA */
@ -175,7 +156,7 @@ void macbinary()
#ifdef SCAN
do_idf(header + I_NAMEOFF + 1, PACK_NAME);
#endif /* SCAN */
jdw((unsigned long)in_data_size);
jdw((uint32_t)in_data_size);
skip_file(ds_skip + in_rs);
continue;
}
@ -191,7 +172,7 @@ void macbinary()
#ifdef SCAN
do_idf(header + I_NAMEOFF + 1, PACK_NAME);
#endif /* SCAN */
stf((unsigned long)in_data_size);
stf((uint32_t)in_data_size);
skip_file(ds_skip + in_rs);
continue;
}
@ -397,7 +378,7 @@ void macbinary()
#ifdef SCAN
do_idf(header + I_NAMEOFF + 1, ARCH_NAME);
#endif /* SCAN */
zma((char *)NULL, (unsigned long)in_data_size);
zma((char *)NULL, (uint32_t)in_data_size);
skip_file(ds_skip + in_rs);
continue;
}
@ -411,7 +392,7 @@ void macbinary()
#ifdef SCAN
do_idf(header + I_NAMEOFF + 1, ARCH_NAME);
#endif /* SCAN */
zma((char *)NULL, (unsigned long)in_data_size);
zma((char *)NULL, (uint32_t)in_data_size);
skip_file(ds_skip + in_rs);
continue;
}
@ -507,8 +488,8 @@ void macbinary()
}
#endif /* DD */
if(header[0] == 0 /* MORE CHECKS HERE! */) {
mcb(header, (unsigned long)in_rsrc_size,
(unsigned long)in_data_size, in_ds + in_rs);
mcb(header, (uint32_t)in_rsrc_size,
(uint32_t)in_data_size, in_ds + in_rs);
continue;
} else {
(void)fprintf(stderr, "Unrecognized archive type.\n");
@ -517,8 +498,8 @@ void macbinary()
}
}
static void skip_file(skip)
int skip;
static void
skip_file (int skip)
{
char buff[1024];
int n;
@ -537,8 +518,8 @@ int skip;
}
#ifdef SCAN
static void get_idf(kind)
int kind;
static void
get_idf (int kind)
{
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 <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "globals.h"
#include "../util/patchlevel.h"
@ -6,25 +9,15 @@
#include "../fileio/wrfileopt.h"
#include "../fileio/kind.h"
#include "../util/util.h"
#include "stf.h"
#include "pit.h"
#include "sit.h"
#include "cpt.h"
#include "macbinary.h"
#define LOCALOPT "ilvqVH"
extern char *strcat();
#ifdef STF
extern void stf();
#endif /* STF */
#ifdef PIT
extern void pit();
#endif /* PIT */
#ifdef SIT
extern void sit();
#endif /* SIT */
#ifdef CPT
extern void cpt();
#endif /* CPT */
void macbinary();
static void usage();
static void usage(void);
static char options[128];
@ -157,7 +150,7 @@ int main(int argc, char **argv)
if(verbose) {
fprintf(stderr, "This is a \"ShrinkToFit\" packed file.\n");
}
stf(~(unsigned long)1);
stf(~(uint32_t)1);
break;
#endif /* STF */
#ifdef PIT
@ -192,7 +185,8 @@ int main(int argc, char **argv)
/* NOTREACHED */
}
static void usage()
static void
usage (void)
{
fprintf(stderr, "Usage: macunpack [-%s] [filename]\n", options);
fprintf(stderr, "Use \"macunpack -H\" for help.\n");

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 "../fileio/machdr.h"
#include "../fileio/wrfile.h"
#include "../util/masks.h"
#include "../util/util.h"
#include "../util/transname.h"
static int mcb_read;
static void mcb_wrfile();
static void mcb_wrfile(uint32_t ibytes);
void mcb(hdr, rsrcLength, dataLength, toread)
char *hdr;
unsigned long rsrcLength, dataLength;
int toread;
void mcb(char *hdr, uint32_t rsrcLength, uint32_t dataLength, int toread)
{
register int i;
int n;
@ -39,8 +41,8 @@ int toread;
transname(hdr + I_AUTHOFF, fauth, 4);
do_indent(indent);
(void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld",
text, ftype, fauth, (long)dataLength, (long)rsrcLength);
"name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength);
if(info_only) {
write_it = 0;
}
@ -79,8 +81,8 @@ int toread;
}
}
static void mcb_wrfile(ibytes)
unsigned long ibytes;
static void
mcb_wrfile (uint32_t ibytes)
{
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"
#ifdef PIT
#define PIT_INTERNAL
#include "pit.h"
#include <stdlib.h>
#include <string.h>
#include "../fileio/wrfile.h"
#include "../fileio/fileglob.h"
#include "../fileio/kind.h"
#include "globals.h"
#include "pit.h"
#include "../fileio/machdr.h"
#include "crc.h"
#include "../fileio/wrfile.h"
#include "../util/masks.h"
#include "../util/transname.h"
#include "../util/util.h"
#include "crc.h"
#include "de_huffman.h"
#include "globals.h"
#include "huffman.h"
extern void read_tree();
extern void de_huffman();
extern void set_huffman();
static int pit_filehdr(struct pit_header *f, int compr);
static void pit_wrfile(uint32_t bytes, int type);
static void pit_nocomp(uint32_t ibytes);
static void pit_huffman(uint32_t obytes);
static int pit_filehdr();
static void pit_wrfile();
static void pit_nocomp();
static void pit_huffman();
void pit()
void
pit (void)
{
struct pit_header filehdr;
char pithdr[4];
int decode, synced, ch;
unsigned long data_crc, crc;
uint32_t data_crc, crc;
updcrc = binhex_updcrc;
crcinit = binhex_crcinit;
@ -122,10 +124,10 @@ void pit()
start_info(info, filehdr.rlen, filehdr.dlen);
start_data();
pit_wrfile(filehdr.dlen, decode);
data_crc = (*updcrc)(INIT_CRC, out_buffer, filehdr.dlen);
data_crc = (*updcrc)(INIT_CRC, (unsigned char*)out_buffer, filehdr.dlen);
start_rsrc();
pit_wrfile(filehdr.rlen, decode);
data_crc = (*updcrc)(data_crc, out_buffer, filehdr.rlen);
data_crc = (*updcrc)(data_crc, (unsigned char*)out_buffer, filehdr.rlen);
if(decode == nocomp) {
crc = getb(infp);
crc = (crc << 8) | getb(infp);
@ -159,12 +161,11 @@ void pit()
}
}
static int pit_filehdr(f, compr)
struct pit_header *f;
int compr;
static int
pit_filehdr (struct pit_header *f, int compr)
{
register int i;
unsigned long crc;
uint32_t crc;
int n;
char hdr[HDRBYTES];
char ftype[5], fauth[5];
@ -182,7 +183,7 @@ int compr;
}
}
crc = INIT_CRC;
crc = (*updcrc)(crc, hdr, HDRBYTES - 2);
crc = (*updcrc)(crc, (unsigned char*)hdr, HDRBYTES - 2);
f->hdrCRC = get2(hdr + H_HDRCRC);
if(f->hdrCRC != crc) {
@ -210,8 +211,8 @@ int compr;
transname(hdr + H_AUTHOFF, fauth, 4);
do_indent(indent);
(void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld",
text, ftype, fauth, (long)f->dlen, (long)f->rlen);
"name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, (int32_t)f->dlen, (int32_t)f->rlen);
if(info_only) {
write_it = 0;
}
@ -238,9 +239,8 @@ int compr;
return 1;
}
static void pit_wrfile(bytes, type)
unsigned long bytes;
int type;
static void
pit_wrfile (uint32_t bytes, int type)
{
if(bytes == 0) {
return;
@ -257,8 +257,8 @@ int type;
/*---------------------------------------------------------------------------*/
/* No compression */
/*---------------------------------------------------------------------------*/
static void pit_nocomp(ibytes)
unsigned long ibytes;
static void
pit_nocomp (uint32_t ibytes)
{
int n;
@ -275,8 +275,8 @@ unsigned long ibytes;
/*---------------------------------------------------------------------------*/
/* Huffman compression */
/*---------------------------------------------------------------------------*/
static void pit_huffman(obytes)
unsigned long obytes;
static void
pit_huffman (uint32_t 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_NLENOFF 0
@ -20,13 +26,18 @@ struct pit_header { /* Packit file header (92 bytes) */
char auth[4]; /* file creator */
unsigned short flags; /* file flags (?) */
unsigned short lock; /* unknown */
unsigned long dlen; /* number of bytes in data fork */
unsigned long rlen; /* number of bytes in resource fork */
unsigned long ctim; /* file creation time */
unsigned long mtim; /* file modified time */
uint32_t dlen; /* number of bytes in data fork */
uint32_t rlen; /* number of bytes in resource fork */
uint32_t ctim; /* file creation time */
uint32_t mtim; /* file modified time */
unsigned short hdrCRC; /* CRC */
};
#define nocomp 0
#define huffman 1
#endif
void pit (void);
#endif

View File

@ -1,24 +1,23 @@
#include "macunpack.h"
#define SIT_INTERNAL
#include "sit.h"
#ifdef SIT
#include <string.h>
#include <stdlib.h>
#include "globals.h"
#include "sit.h"
#include "crc.h"
#include "../util/util.h"
#include "../fileio/machdr.h"
#include "../fileio/wrfile.h"
#include "../fileio/kind.h"
#include "../util/masks.h"
#include "../util/transname.h"
#include "huffman.h"
#include "de_compress.h"
#include "de_huffman.h"
#include "de_lzah.h"
extern void de_compress();
extern void core_compress();
extern void de_huffman();
extern void de_huffman_end();
extern void read_tree();
extern void set_huffman();
extern void de_lzah();
extern unsigned char (*lzah_getbyte)();
typedef struct methodinfo {
char *name;
@ -36,26 +35,26 @@ static struct methodinfo methods[] = {
};
static int sit_nodeptr;
static int readsithdr();
static int sit_filehdr();
static int sit_valid();
static int sit_checkm();
static char *sit_methname();
static void sit_folder();
static void sit_unstuff();
static void sit_wrfile();
static void sit_skip();
static void sit_nocomp();
static void sit_rle();
static void sit_lzc();
static void sit_huffman();
static void sit_lzah();
static unsigned char sit_getbyte();
static void sit_fixhuf();
static void sit_dosplit();
static void sit_mw();
static void sit_mw_out();
static int sit_mw_in();
static int readsithdr(sitHdr *s);
static int sit_filehdr(struct sit_fileHdr *f, int skip);
static int sit_valid(struct sit_fileHdr f);
static int sit_checkm(int f);
static char *sit_methname(int n);
static void sit_folder(char *name);
static void sit_unstuff(struct sit_fileHdr filehdr);
static void sit_wrfile(uint32_t ibytes, uint32_t obytes, int type);
static void sit_skip(uint32_t ibytes);
static void sit_nocomp(uint32_t ibytes);
static void sit_rle(uint32_t ibytes);
static void sit_lzc(uint32_t ibytes);
static void sit_huffman(uint32_t obytes);
static void sit_lzah(uint32_t obytes);
static unsigned char sit_getbyte(void);
static void sit_fixhuf(uint32_t ibytes);
static void sit_dosplit(int ptr, int sum, int low, int upp);
static void sit_mw(uint32_t ibytes);
static void sit_mw_out(int ptr);
static int sit_mw_in(int bits, uint32_t *ibytes);
static short code6[258] = {
1024, 512, 256, 256, 256, 256, 128, 128,
@ -93,13 +92,14 @@ static short code6[258] = {
1, 1};
static char sit_buffer[32768];
static short sit_dict[16385];
static unsigned long sit_avail;
static uint32_t sit_avail;
static int sit_bits_avail;
void sit()
void
sit (void)
{
struct sitHdr sithdr;
struct fileHdr filehdr;
struct sit_fileHdr filehdr;
int i;
set_huffman(HUFF_BE);
@ -154,10 +154,10 @@ static int readsithdr(sitHdr *s)
return 1;
}
static int sit_filehdr(struct fileHdr *f, int skip)
static int sit_filehdr(struct sit_fileHdr *f, int skip)
{
register int i;
unsigned long crc;
uint32_t crc;
int n;
char hdr[FILEHDRSIZE];
char ftype[5], fauth[5];
@ -170,7 +170,7 @@ static int sit_filehdr(struct fileHdr *f, int skip)
return -1;
}
crc = INIT_CRC;
crc = (*updcrc)(crc, hdr, FILEHDRSIZE - 2);
crc = (*updcrc)(crc, (unsigned char*)hdr, FILEHDRSIZE - 2);
f->hdrCRC = get2(hdr + F_HDRCRC);
if(f->hdrCRC != crc) {
@ -207,9 +207,9 @@ static int sit_filehdr(struct fileHdr *f, int skip)
transname(hdr + F_FTYPE, ftype, 4);
transname(hdr + F_CREATOR, fauth, 4);
(void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld",
"name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth,
(long)f->dataLength, (long)f->rsrcLength);
(int32_t)f->dataLength, (int32_t)f->rsrcLength);
}
if(info_only) {
write_it = 0;
@ -239,8 +239,8 @@ static int sit_filehdr(struct fileHdr *f, int skip)
return 1;
}
static int sit_valid(f)
struct fileHdr f;
static int
sit_valid (struct sit_fileHdr f)
{
int fr = f.compRMethod, fd = f.compDMethod;
@ -283,8 +283,8 @@ struct fileHdr f;
return 0;
}
static int sit_checkm(f)
int f;
static int
sit_checkm (int f)
{
switch(f) {
case nocomp:
@ -307,8 +307,8 @@ int f;
/* NOTREACHED */
}
static char *sit_methname(n)
int n;
static char *
sit_methname (int n)
{
int i, nmeths;
nmeths = sizeof(methods) / sizeof(struct methodinfo);
@ -320,12 +320,12 @@ int i, nmeths;
return NULL;
}
static void sit_folder(name)
char *name;
static void
sit_folder (char *name)
{
int i, recurse;
char loc_name[64];
struct fileHdr filehdr;
struct sit_fileHdr filehdr;
for(i = 0; i < 64; i++) {
loc_name[i] = name[i];
@ -387,10 +387,10 @@ char *name;
}
}
static void sit_unstuff(filehdr)
struct fileHdr filehdr;
static void
sit_unstuff (struct sit_fileHdr filehdr)
{
unsigned long crc;
uint32_t crc;
if(write_it) {
start_info(info, filehdr.rsrcLength, filehdr.dataLength);
@ -403,7 +403,7 @@ struct fileHdr filehdr;
}
sit_wrfile(filehdr.compRLength, filehdr.rsrcLength, filehdr.compRMethod);
if(write_it) {
crc = (*updcrc)(INIT_CRC, out_buffer, filehdr.rsrcLength);
crc = (*updcrc)(INIT_CRC, (unsigned char*)out_buffer, filehdr.rsrcLength);
if(filehdr.rsrcCRC != crc) {
(void)fprintf(stderr,
"CRC error on resource fork: need 0x%04x, got 0x%04x\n",
@ -422,7 +422,7 @@ struct fileHdr filehdr;
}
sit_wrfile(filehdr.compDLength, filehdr.dataLength, filehdr.compDMethod);
if(write_it) {
crc = (*updcrc)(INIT_CRC, out_buffer, filehdr.dataLength);
crc = (*updcrc)(INIT_CRC, (unsigned char*)out_buffer, filehdr.dataLength);
if(filehdr.dataCRC != crc) {
(void)fprintf(stderr,
"CRC error on data fork: need 0x%04x, got 0x%04x\n",
@ -439,9 +439,8 @@ struct fileHdr filehdr;
}
}
static void sit_wrfile(ibytes, obytes, type)
unsigned long ibytes, obytes;
unsigned char type;
static void
sit_wrfile (uint32_t ibytes, uint32_t obytes, int type)
{
if(ibytes == 0) {
if(verbose) {
@ -536,8 +535,8 @@ unsigned char type;
}
/* skip stuffit file */
static void sit_skip(ibytes)
unsigned long ibytes;
static void
sit_skip (uint32_t ibytes)
{
while(ibytes != 0) {
if(getc(infp) == EOF) {
@ -554,8 +553,8 @@ unsigned long ibytes;
/*---------------------------------------------------------------------------*/
/* Method 0: No compression */
/*---------------------------------------------------------------------------*/
static void sit_nocomp(ibytes)
unsigned long ibytes;
static void
sit_nocomp (uint32_t ibytes)
{
int n;
@ -572,10 +571,10 @@ unsigned long ibytes;
/*---------------------------------------------------------------------------*/
/* Method 1: Run length encoding */
/*---------------------------------------------------------------------------*/
static void sit_rle(ibytes)
unsigned long ibytes;
static void
sit_rle (uint32_t ibytes)
{
int ch, lastch, n, i;
int ch, lastch = 0, n, i;
while(ibytes != 0) {
ch = getb(infp) & BYTEMASK;
@ -602,8 +601,8 @@ unsigned long ibytes;
/*---------------------------------------------------------------------------*/
/* Method 2: LZC compressed */
/*---------------------------------------------------------------------------*/
static void sit_lzc(ibytes)
unsigned long ibytes;
static void
sit_lzc (uint32_t ibytes)
{
de_compress(ibytes, 14);
}
@ -611,8 +610,8 @@ unsigned long ibytes;
/*---------------------------------------------------------------------------*/
/* Method 3: Huffman compressed */
/*---------------------------------------------------------------------------*/
static void sit_huffman(obytes)
unsigned long obytes;
static void
sit_huffman (uint32_t obytes)
{
read_tree();
de_huffman(obytes);
@ -621,14 +620,15 @@ unsigned long obytes;
/*---------------------------------------------------------------------------*/
/* Method 5: LZ compression plus adaptive Huffman encoding */
/*---------------------------------------------------------------------------*/
static void sit_lzah(obytes)
unsigned long obytes;
static void
sit_lzah (uint32_t obytes)
{
lzah_getbyte = sit_getbyte;
de_lzah(obytes);
}
static unsigned char sit_getbyte()
static unsigned char
sit_getbyte (void)
{
return getb(infp);
}
@ -636,12 +636,12 @@ static unsigned char sit_getbyte()
/*---------------------------------------------------------------------------*/
/* Method 6: Compression with a fixed Huffman encoding */
/*---------------------------------------------------------------------------*/
static void sit_fixhuf(ibytes)
unsigned long ibytes;
static void
sit_fixhuf (uint32_t ibytes)
{
int i, sum, codes, sym, num;
char byte_int[4], byte_short[2];
long size;
int32_t size;
int sign;
char *tmp_ptr, *ptr, *end_ptr;
@ -661,7 +661,7 @@ unsigned long ibytes;
exit(1);
}
ibytes -= 4;
size = (long)get4(byte_int);
size = (int32_t)get4(byte_int);
sign = 0;
if(size < 0) {
size = - size;
@ -732,8 +732,8 @@ unsigned long ibytes;
}
}
static void sit_dosplit(ptr, sum, low, upp)
int ptr, sum, low, upp;
static void
sit_dosplit (int ptr, int sum, int low, int upp)
{
int i, locsum;
@ -760,8 +760,8 @@ int ptr, sum, low, upp;
/*---------------------------------------------------------------------------*/
/* Method 8: Compression with a MW encoding */
/*---------------------------------------------------------------------------*/
static void sit_mw(ibytes)
unsigned long ibytes;
static void
sit_mw (uint32_t ibytes)
{
int ptr;
int max, max1, bits;
@ -802,8 +802,8 @@ start_over:
}
}
static void sit_mw_out(ptr)
int ptr;
static void
sit_mw_out (int ptr)
{
int stack_ptr;
int stack[16384];
@ -820,9 +820,8 @@ int ptr;
}
}
static int sit_mw_in(bits, ibytes)
int bits;
unsigned long *ibytes;
static int
sit_mw_in (int bits, uint32_t *ibytes)
{
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_NUMFILES 4
#define S_ARCLENGTH 6
@ -22,19 +28,19 @@
#define F_HDRCRC 110
#define FILEHDRSIZE 112
typedef long OSType;
typedef int32_t OSType;
typedef struct sitHdr { /* 22 bytes */
OSType signature; /* = 'SIT!' -- for verification */
unsigned short numFiles; /* number of files in archive */
unsigned long arcLength; /* length of entire archive incl.
uint32_t arcLength; /* length of entire archive incl.
hdr. -- for verification */
OSType signature2; /* = 'rLau' -- for verification */
unsigned char version; /* version number */
char reserved[7];
} sitHdr;
typedef struct fileHdr { /* 112 bytes */
typedef struct sit_fileHdr { /* 112 bytes */
unsigned char compRMethod; /* rsrc fork compression method */
unsigned char compDMethod; /* data fork compression method */
unsigned char fName[64]; /* a STR63 */
@ -43,17 +49,17 @@ typedef struct fileHdr { /* 112 bytes */
unsigned short FndrFlags; /* copy of Finder flags. For our
purposes, we can clear:
busy,onDesk */
unsigned long creationDate;
unsigned long modDate; /* !restored-compat w/backup prgms */
unsigned long rsrcLength; /* decompressed lengths */
unsigned long dataLength;
unsigned long compRLength; /* compressed lengths */
unsigned long compDLength;
uint32_t creationDate;
uint32_t modDate; /* !restored-compat w/backup prgms */
uint32_t rsrcLength; /* decompressed lengths */
uint32_t dataLength;
uint32_t compRLength; /* compressed lengths */
uint32_t compDLength;
unsigned short rsrcCRC; /* crc of rsrc fork */
unsigned short dataCRC; /* crc of data fork */
char reserved[6];
unsigned short hdrCRC; /* crc of file header */
} fileHdr;
} sit_fileHdr;
/* file format is:
sitArchiveHdr
@ -72,7 +78,6 @@ typedef struct fileHdr { /* 112 bytes */
*/
/* compression methods */
#define nocomp 0 /* just read each byte and write it to archive */
#define rle 1 /* RLE compression */
@ -91,3 +96,9 @@ typedef struct fileHdr { /* 112 bytes */
/* all other numbers are reserved */
#define ESC 0x90 /* repeat packing escape */
#endif
void sit (void);
#endif

View File

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

View File

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

View File

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

View File

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

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 "globals.h"
#include "../fileio/machdr.h"
#include "../fileio/wrfile.h"
#include "../util/util.h"
#include "../util/transname.h"
#include "../util/masks.h"
static char *dir_stack;

1
mixed/dir.h Normal file
View File

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

View File

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

View File

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

1
mixed/macbinary.h Normal file
View File

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

View File

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

View File

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

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