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