Merge pull request #1 from VorpalBlade/fixes

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

5
.gitignore vendored
View File

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

View File

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

View File

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

1
binhex/dofile.h Normal file
View File

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

View File

@ -1,51 +0,0 @@
CFLAGS = -O $(CF)
SRCS = binhex.c dofile.c
OBJS = binhex.o dofile.o
LIB = ../crc/libcrc.a
TNAME = ../util/transname
BNAME = ../util/backtrans
UNAME = ../util/util
INAME = ../fileio/rdfile
GNAME = ../fileio/fileglob
XOBJS = $(TNAME).o $(BNAME).o $(UNAME).o $(INAME).o $(GNAME).o
XSRCS = $(TNAME).c $(BNAME).c $(UNAME).c $(INAME).c $(GNAME).c
binhex: $(OBJS) $(XOBJS) $(LIB)
$(CC) $(CFLAGS) -o binhex $(OBJS) $(XOBJS) $(LIB)
$(LIB): ../crc/makecrc.c
(cd ../crc; make CC=$(CC) CF="$(CF)" )
$(TNAME).o: $(TNAME).c
(cd ../util; make CC=$(CC) CF="$(CF)" )
$(BNAME).o: $(BNAME).c
(cd ../util; make CC=$(CC) CF="$(CF)" )
$(UNAME).o: $(UNAME).c
(cd ../util; make CC=$(CC) CF="$(CF)" )
$(INAME).o: $(INAME).c
(cd ../fileio; make CC=$(CC) CF="$(CF)" )
$(GNAME).o: $(GNAME).c
(cd ../fileio; make CC=$(CC) CF="$(CF)" )
lint:
lint $(CF) $(LFLAGS) $(SRCS) $(XSRCS)
clean:
rm -f *.o
clobber:clean
rm -f binhex
binhex.o: ../fileio/machdr.h
binhex.o: ../fileio/rdfile.h
binhex.o: ../util/patchlevel.h
dofile.o: ../fileio/machdr.h
dofile.o: ../fileio/rdfile.h

View File

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

View File

@ -1,90 +0,0 @@
CFLAGS = -O $(CF)
SRCS1 = tomac.c xm_to.c ym_to.c zm_to.c tty.c globals.c
SRCS2 = frommac.c xm_from.c ym_from.c zm_from.c tty.c globals.c
OBJS1 = tomac.o xm_to.o ym_to.o zm_to.o tty.o globals.o
OBJS2 = frommac.o xm_from.o ym_from.o zm_from.o tty.o globals.o
LIB = ../crc/libcrc.a
TNAME = ../util/transname
BNAME = ../util/backtrans
UNAME = ../util/util
INAME = ../fileio/rdfile
ONAME = ../fileio/wrfile
GNAME = ../fileio/fileglob
XOBJS1 = $(TNAME).o $(BNAME).o $(UNAME).o $(INAME).o $(GNAME).o
XOBJS2 = $(TNAME).o $(UNAME).o $(ONAME).o $(GNAME).o
XSRCS1 = $(TNAME).c $(BNAME).c $(UNAME).c $(INAME).c $(GNAME).c
XSRCS2 = $(TNAME).c $(UNAME).c $(ONAME).c $(GNAME).c
all: tomac frommac
touch all
tomac: $(OBJS1) $(XOBJS1)
$(CC) $(CFLAGS) -o tomac $(OBJS1) $(XOBJS1)
frommac: $(OBJS2) $(XOBJS2)
$(CC) $(CFLAGS) -o frommac $(OBJS2) $(XOBJS2)
$(LIB): ../crc/makecrc.c
(cd ../crc; make CC=$(CC) CF="$(CF)" )
$(TNAME).o: $(TNAME).c
(cd ../util; make CC=$(CC) CF="$(CF)" )
$(BNAME).o: $(BNAME).c
(cd ../util; make CC=$(CC) CF="$(CF)" )
$(UNAME).o: $(UNAME).c
(cd ../util; make CC=$(CC) CF="$(CF)" )
$(INAME).o: $(INAME).c
(cd ../fileio; make CC=$(CC) CF="$(CF)" )
$(ONAME).o: $(ONAME).c
(cd ../fileio; make CC=$(CC) CF="$(CF)" )
$(GNAME).o: $(GNAME).c
(cd ../fileio; make CC=$(CC) CF="$(CF)" )
lint:
lint $(CF) $(LFLAGS) $(SRCS1) $(XSRCS)
clean:
rm -f *.o
clobber:clean
rm -f all tomac frommac
tomac.o: comm.h
tomac.o: ../fileio/machdr.h
tomac.o: ../fileio/rdfile.h
tomac.o: ../util/patchlevel.h
tomac.o: globals.h
xm_to.o: comm.h
xm_to.o: ../fileio/machdr.h
xm_to.o: ../fileio/rdfile.h
xm_to.o: ../util/masks.h
xm_to.o: globals.h
xm_to.o: protocol.h
ym_to.o: comm.h
zm_to.o: comm.h
frommac.o: comm.h
frommac.o: ../util/patchlevel.h
frommac.o: ../fileio/machdr.h
frommac.o: globals.h
frommac.o: ../fileio/fileglob.h
frommac.o: ../fileio/wrfile.h
xm_from.o: comm.h
xm_from.o: ../fileio/machdr.h
xm_from.o: ../fileio/wrfile.h
xm_from.o: ../util/masks.h
xm_from.o: globals.h
xm_from.o: protocol.h
ym_from.o: comm.h
zm_from.o: comm.h
globals.o: globals.h
tty.o: ../util/masks.h
tty.o: protocol.h
tty.o: globals.h

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

8
crc/.gitignore vendored Normal file
View File

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

14
crc/crc.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef CRC_CRC_H
#define CRC_CRC_H
#include <stdint.h>
extern uint32_t arc_crcinit;
extern uint32_t binhex_crcinit;
extern uint32_t zip_crcinit;
extern uint32_t arc_updcrc(uint32_t icrc, unsigned char *icp, int32_t icnt);
extern uint32_t binhex_updcrc(uint32_t icrc, unsigned char *icp, int32_t icnt);
extern uint32_t zip_updcrc(uint32_t icrc, unsigned char *icp, int32_t icnt);
#endif

View File

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

View File

@ -1,27 +0,0 @@
CFLAGS = -O $(CF)
CRCC = arc.c ccitt.c kermit.c binhex.c ccitt32.c zip.c
CRCO = arc.o ccitt.o kermit.o binhex.o ccitt32.o zip.o
libcrc.a: $(CRCO)
ar r libcrc.a $(CRCO)
if test -f /usr/bin/ranlib ;\
then \
ranlib libcrc.a ;\
fi
clean:
rm -f $(CRCC) $(CRCO) libcrc.a makecrc makecrc.o
$(CRCC): makecrc
./makecrc
makecrc: makecrc.o
cc -O -o makecrc makecrc.o
arc.o: arc.c
ccitt.o: ccitt.c
kermit.o: kermit.c
binhex.o: binhex.c
ccitt32.o: ccitt32.c
zip.o: zip.c

View File

@ -1,33 +0,0 @@
CFLAGS= -O $(CF)
all: wrfile.o rdfile.o fileglob.o
touch all
wrfile.o: wrfile.c
rdfile.o: rdfile.c
clean:
rm -f wrfile.o
rm -f rdfile.o
rm -f fileglob.o
rm -f all
wrfile.o: machdr.h
wrfile.o: wrfile.h
wrfile.o: wrfileopt.h
wrfile.o: fileglob.h
wrfile.o: aufs.h
wrfile.o: appledouble.h
wrfile.o: ../util/util.h
wrfile.o: ../util/curtime.h
rdfile.o: machdr.h
rdfile.o: rdfile.h
rdfile.o: rdfileopt.h
rdfile.o: ../util/util.h
rdfile.o: ../util/curtime.h
rdfile.o: ../util/masks.h
rdfile.o: aufs.h
rdfile.o: appledouble.h
fileglob.o: fileglob.h

View File

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

View File

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

View File

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

View File

@ -1,14 +1,16 @@
#include "wrfile.h"
#ifdef TYPES_H
#include <sys/types.h>
#endif /* TYPES_H */
#include <sys/stat.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <unistd.h>
#include "machdr.h"
#include "wrfile.h"
#include "wrfileopt.h"
#include "../util/util.h"
#ifdef AUFSPLUS
@ -43,17 +45,17 @@ char *sprintf();
#endif /* UNDEF */
#ifdef AUFS
static void check_aufs();
static void aufs_namings();
static void wr_aufs_info();
static void check_aufs(void);
static void aufs_namings(void);
static void wr_aufs_info(FILE* fp);
#endif /* AUFS */
#ifdef APPLEDOUBLE
static void check_appledouble();
static void appledouble_namings();
static void wr_appledouble_info();
static void check_appledouble(void);
static void appledouble_namings(void);
static void wr_appledouble_info(FILE* fp);
#endif /* APPLEDOUBLE */
#ifdef APPLESHARE
static void mk_share_name();
static void mk_share_name(void);
#endif /* APPLESHARE */
#ifndef BSD
@ -100,10 +102,10 @@ static char init_buffer[128];
static char *buffer = &(init_buffer[0]);
static char *rbuffer = NULL, *dbuffer = NULL;
static char *ptr;
static unsigned long rsz, dsz, totsize, maxsize;
static uint32_t rsz, dsz, totsize, maxsize;
void define_name(text)
char *text;
void
define_name (char *text)
{
(void)sprintf(f_info, "%s.info", text);
(void)sprintf(f_rsrc, "%s.rsrc", text);
@ -118,9 +120,8 @@ char *text;
#endif /* APPLESHARE */
}
void start_info(info, rsize, dsize)
char *info;
unsigned long rsize, dsize;
void
start_info (char *info, uint32_t rsize, uint32_t dsize)
{
int rs, ds;
@ -158,17 +159,20 @@ unsigned long rsize, dsize;
#endif /* APPLEDOUBLE */
}
void start_rsrc()
void
start_rsrc (void)
{
out_buffer = out_ptr = rbuffer;
}
void start_data()
void
start_data (void)
{
out_buffer = out_ptr = dbuffer;
}
void end_file()
void
end_file (void)
{
FILE *fp;
int i, c;
@ -324,9 +328,8 @@ void end_file()
}
#ifdef SCAN
void do_idf(name, kind)
char *name;
int kind;
void
do_idf (char *name, int kind)
{
int n;