64-bit: Convcert all uses of long/unsigned long to int32_t/uint32_t.

Some of these may not be needed, but none of them should be incorrect.
This commit is contained in:
Arvid Norlander 2022-09-29 19:52:53 +02:00
parent 84b38a61b5
commit 926f4a694d
No known key found for this signature in database
GPG Key ID: E824A8E5D8D29AA0
55 changed files with 412 additions and 380 deletions

View File

@ -103,8 +103,8 @@ int main(int argc, char **argv)
if(i == ISFILE) { if(i == ISFILE) {
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, (long)data_size, (long)rsrc_size); text, ftype, fauth, (int32_t)data_size, (int32_t)rsrc_size);
} else if(i == ISDIR) { } else if(i == ISDIR) {
do_indent(indent); do_indent(indent);
dir_ptr += 64; dir_ptr += 64;

View File

@ -151,7 +151,7 @@ int main(int argc, char **argv)
transname(info + I_AUTHOFF, fauth, 4); transname(info + I_AUTHOFF, fauth, 4);
transname(info + I_TYPEOFF, ftype, 4); transname(info + I_TYPEOFF, ftype, 4);
(void)fprintf(stderr, (void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", "name=\"%s\", type=%4.4s, author=%4.4s, data=%u, rsrc=%u",
tname, ftype, fauth, tname, ftype, fauth,
get4(info + I_DLENOFF), get4(info + I_RLENOFF)); get4(info + I_DLENOFF), get4(info + I_RLENOFF));
(void)fprintf(stderr, "\n"); (void)fprintf(stderr, "\n");

View File

@ -154,8 +154,8 @@ int main(int argc, char **argv)
if(i == ISFILE) { if(i == ISFILE) {
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, (long)data_size, (long)rsrc_size); text, ftype, fauth, (int32_t)data_size, (int32_t)rsrc_size);
} else if(i == ISDIR) { } else if(i == ISDIR) {
do_indent(indent); do_indent(indent);
dir_ptr += 64; dir_ptr += 64;

View File

@ -19,7 +19,7 @@ char info[INFOBYTES];
void void
xm_from (void) xm_from (void)
{ {
unsigned long data_size, rsrc_size; uint32_t data_size, rsrc_size;
char text[64]; char text[64];
if(receive_sync() == ACK) { if(receive_sync() == ACK) {

View File

@ -31,6 +31,7 @@
/* ZIP used by COMPACTOR */ /* ZIP used by COMPACTOR */
#include <stdio.h> #include <stdio.h>
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -53,7 +54,7 @@ initcrctab (char *name, int poly, int init, int swapped, int bits)
{ {
register int b, i; register int b, i;
unsigned short v; unsigned short v;
unsigned long vv; uint32_t vv;
FILE *fd; FILE *fd;
char buf[20]; char buf[20];
@ -99,7 +100,7 @@ initcrctab (char *name, int poly, int init, int swapped, int 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%.8lx,", vv & 0xffffffff); (void)fprintf(fd, "0x%.8x,", 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, " ");

View File

@ -358,8 +358,8 @@ read_file (void)
} }
(void)strcpy(file_info + I_NAMEOFF + 1, filename); (void)strcpy(file_info + I_NAMEOFF + 1, filename);
file_info[I_NAMEOFF] = strlen(filename); file_info[I_NAMEOFF] = strlen(filename);
put4(file_info + I_CTIMOFF, (unsigned long)stbuf.st_ctime + TIMEDIFF); put4(file_info + I_CTIMOFF, (uint32_t)stbuf.st_ctime + TIMEDIFF);
put4(file_info + I_MTIMOFF, (unsigned long)stbuf.st_mtime + TIMEDIFF); put4(file_info + I_MTIMOFF, (uint32_t)stbuf.st_mtime + TIMEDIFF);
if(data_only == RSRC_FORMAT) { if(data_only == RSRC_FORMAT) {
rsrc_size = stbuf.st_size; rsrc_size = stbuf.st_size;
data_size = 0; data_size = 0;
@ -381,7 +381,7 @@ read_file (void)
} else { } else {
(void)strncpy(file_info + I_AUTHOFF, f_auth, 4); (void)strncpy(file_info + I_AUTHOFF, f_auth, 4);
} }
put4(file_info + I_RLENOFF, (unsigned long)rsrc_size); put4(file_info + I_RLENOFF, (uint32_t)rsrc_size);
if((fd = fopen(filename, "r")) == NULL) { if((fd = fopen(filename, "r")) == NULL) {
(void)fprintf(stderr, "Cannot open file %s\n", filename); (void)fprintf(stderr, "Cannot open file %s\n", filename);
exit(1); exit(1);
@ -412,7 +412,7 @@ read_file (void)
} else { } else {
(void)strncpy(file_info + I_AUTHOFF, f_auth, 4); (void)strncpy(file_info + I_AUTHOFF, f_auth, 4);
} }
put4(file_info + I_DLENOFF, (unsigned long)data_size); put4(file_info + I_DLENOFF, (uint32_t)data_size);
if((fd = fopen(filename, "r")) == NULL) { if((fd = fopen(filename, "r")) == NULL) {
(void)fprintf(stderr, "Cannot open file %s\n", filename); (void)fprintf(stderr, "Cannot open file %s\n", filename);
exit(1); exit(1);
@ -555,7 +555,7 @@ read_file (void)
(void)strcat(filename1, filename); (void)strcat(filename1, filename);
if(stat(filename1, &stbuf) >= 0) { if(stat(filename1, &stbuf) >= 0) {
rsrc_size = stbuf.st_size; rsrc_size = stbuf.st_size;
put4(file_info + I_RLENOFF, (unsigned long)rsrc_size); put4(file_info + I_RLENOFF, (uint32_t)rsrc_size);
if(rsrc_size > 0) { if(rsrc_size > 0) {
if(rsrc_size > max_rsrc_size) { if(rsrc_size > max_rsrc_size) {
if(rsrc_fork == NULL) { if(rsrc_fork == NULL) {
@ -578,7 +578,7 @@ read_file (void)
} }
if(stat(filename, &stbuf) >= 0) { if(stat(filename, &stbuf) >= 0) {
data_size = stbuf.st_size; data_size = stbuf.st_size;
put4(file_info + I_DLENOFF, (unsigned long)data_size); put4(file_info + I_DLENOFF, (uint32_t)data_size);
if(data_size > 0) { if(data_size > 0) {
if(data_size > max_data_size) { if(data_size > max_data_size) {
if(data_fork == NULL) { if(data_fork == NULL) {
@ -626,7 +626,7 @@ read_file (void)
(void)fclose(fd); (void)fclose(fd);
if(stat(filename, &stbuf) >= 0) { if(stat(filename, &stbuf) >= 0) {
data_size = stbuf.st_size; data_size = stbuf.st_size;
put4(file_info + I_DLENOFF, (unsigned long)data_size); put4(file_info + I_DLENOFF, (uint32_t)data_size);
if(data_size > 0) { if(data_size > 0) {
if(data_size > max_data_size) { if(data_size > max_data_size) {
if(data_fork == NULL) { if(data_fork == NULL) {
@ -816,15 +816,15 @@ read_aufs_info (FILE *fd)
} else { } else {
if(fstat(fileno(fd), &stbuf) >= 0) { if(fstat(fileno(fd), &stbuf) >= 0) {
put4(file_info + I_CTIMOFF, put4(file_info + I_CTIMOFF,
(unsigned long)stbuf.st_ctime + TIMEDIFF); (uint32_t)stbuf.st_ctime + TIMEDIFF);
put4(file_info + I_MTIMOFF, put4(file_info + I_MTIMOFF,
(unsigned long)stbuf.st_mtime + TIMEDIFF); (uint32_t)stbuf.st_mtime + TIMEDIFF);
} }
} }
#else /* AUFSPLUS */ #else /* AUFSPLUS */
if(fstat(fileno(fd), &stbuf) >= 0) { if(fstat(fileno(fd), &stbuf) >= 0) {
put4(file_info + I_CTIMOFF, (unsigned long)stbuf.st_ctime + TIMEDIFF); put4(file_info + I_CTIMOFF, (uint32_t)stbuf.st_ctime + TIMEDIFF);
put4(file_info + I_MTIMOFF, (unsigned long)stbuf.st_mtime + TIMEDIFF); put4(file_info + I_MTIMOFF, (uint32_t)stbuf.st_mtime + TIMEDIFF);
} }
#endif /* AUFSPLUS */ #endif /* AUFSPLUS */
} }
@ -864,7 +864,7 @@ read_appledouble_info (FILE *fd)
put4(file_info + I_CTIMOFF, get4(theinfo.fi_ctime) + TIMEDIFF); put4(file_info + I_CTIMOFF, get4(theinfo.fi_ctime) + TIMEDIFF);
put4(file_info + I_MTIMOFF, get4(theinfo.fi_mtime) + TIMEDIFF); put4(file_info + I_MTIMOFF, get4(theinfo.fi_mtime) + TIMEDIFF);
rsrc_size = get4(theinfo.fi_rsrc); rsrc_size = get4(theinfo.fi_rsrc);
put4(file_info + I_RLENOFF, (unsigned long)rsrc_size); put4(file_info + I_RLENOFF, (uint32_t)rsrc_size);
} }
#endif /* APPLEDOUBLE */ #endif /* APPLEDOUBLE */
#endif /* APPLESHARE */ #endif /* APPLESHARE */

View File

@ -101,7 +101,7 @@ static char init_buffer[128];
static char *buffer = &(init_buffer[0]); static char *buffer = &(init_buffer[0]);
static char *rbuffer = NULL, *dbuffer = NULL; static char *rbuffer = NULL, *dbuffer = NULL;
static char *ptr; static char *ptr;
static unsigned long rsz, dsz, totsize, maxsize; static uint32_t rsz, dsz, totsize, maxsize;
void void
define_name (char *text) define_name (char *text)
@ -120,7 +120,7 @@ define_name (char *text)
} }
void void
start_info (char *info, unsigned long rsize, unsigned long dsize) start_info (char *info, uint32_t rsize, uint32_t dsize)
{ {
int rs, ds; int rs, ds;
@ -338,7 +338,7 @@ do_idf (char *name, int kind)
n = strlen(name); n = strlen(name);
(void)bzero(buffer, INFOBYTES); (void)bzero(buffer, INFOBYTES);
buffer[I_NAMEOFF + 1] = kind; buffer[I_NAMEOFF + 1] = kind;
put4(buffer + I_DLENOFF, (unsigned long)n); put4(buffer + I_DLENOFF, (uint32_t)n);
(void)fwrite(buffer, 1, INFOBYTES, stdout); (void)fwrite(buffer, 1, INFOBYTES, stdout);
if(n != 0) { if(n != 0) {
(void)fwrite(name, 1, n, stdout); (void)fwrite(name, 1, n, stdout);
@ -583,7 +583,7 @@ FILE *fp;
theinfo.fi_datevalid = FI_CDATE | FI_MDATE; theinfo.fi_datevalid = FI_CDATE | FI_MDATE;
put4(theinfo.fi_ctime, get4(buffer + I_CTIMOFF) - TIMEDIFF); put4(theinfo.fi_ctime, get4(buffer + I_CTIMOFF) - TIMEDIFF);
put4(theinfo.fi_mtime, get4(buffer + I_MTIMOFF) - TIMEDIFF); put4(theinfo.fi_mtime, get4(buffer + I_MTIMOFF) - TIMEDIFF);
put4(theinfo.fi_utime, (unsigned long)time((time_t *)0)); put4(theinfo.fi_utime, (uint32_t)time((time_t *)0));
#endif /* AUFSPLUS */ #endif /* AUFSPLUS */
bcopy(buffer + I_TYPEOFF, theinfo.fi_fndr, 4); bcopy(buffer + I_TYPEOFF, theinfo.fi_fndr, 4);
bcopy(buffer + I_AUTHOFF, theinfo.fi_fndr + 4, 4); bcopy(buffer + I_AUTHOFF, theinfo.fi_fndr + 4, 4);
@ -634,21 +634,21 @@ FILE *fp;
int n; int n;
bzero((char *) &theinfo, sizeof theinfo); bzero((char *) &theinfo, sizeof theinfo);
put4(theinfo.fi_magic, (unsigned long)FI_MAGIC); put4(theinfo.fi_magic, (uint32_t)FI_MAGIC);
put2(theinfo.fi_version, (unsigned long)FI_VERSION); put2(theinfo.fi_version, (uint32_t)FI_VERSION);
put4(theinfo.fi_fill5, (unsigned long)FI_FILL5); put4(theinfo.fi_fill5, (uint32_t)FI_FILL5);
put4(theinfo.fi_fill6, (unsigned long)FI_FILL6); put4(theinfo.fi_fill6, (uint32_t)FI_FILL6);
put4(theinfo.fi_hlen, (unsigned long)FI_HLEN); put4(theinfo.fi_hlen, (uint32_t)FI_HLEN);
put4(theinfo.fi_fill7, (unsigned long)FI_FILL7); put4(theinfo.fi_fill7, (uint32_t)FI_FILL7);
put4(theinfo.fi_namptr, (unsigned long)FI_NAMPTR); put4(theinfo.fi_namptr, (uint32_t)FI_NAMPTR);
put4(theinfo.fi_fill9, (unsigned long)FI_FILL9); put4(theinfo.fi_fill9, (uint32_t)FI_FILL9);
put4(theinfo.fi_commptr, (unsigned long)FI_COMMPTR); put4(theinfo.fi_commptr, (uint32_t)FI_COMMPTR);
put4(theinfo.fi_fill12, (unsigned long)FI_FILL12); put4(theinfo.fi_fill12, (uint32_t)FI_FILL12);
put4(theinfo.fi_timeptr, (unsigned long)FI_TIMEPTR); put4(theinfo.fi_timeptr, (uint32_t)FI_TIMEPTR);
put4(theinfo.fi_timesize, (unsigned long)FI_TIMESIZE); put4(theinfo.fi_timesize, (uint32_t)FI_TIMESIZE);
put4(theinfo.fi_fill15, (unsigned long)FI_FILL15); put4(theinfo.fi_fill15, (uint32_t)FI_FILL15);
put4(theinfo.fi_infoptr, (unsigned long)FI_INFOPTR); put4(theinfo.fi_infoptr, (uint32_t)FI_INFOPTR);
put4(theinfo.fi_infosize, (unsigned long)FI_INFOSIZE); put4(theinfo.fi_infosize, (uint32_t)FI_INFOSIZE);
bcopy(buffer + I_TYPEOFF, theinfo.fi_type, 4); bcopy(buffer + I_TYPEOFF, theinfo.fi_type, 4);
bcopy(buffer + I_AUTHOFF, theinfo.fi_auth, 4); bcopy(buffer + I_AUTHOFF, theinfo.fi_auth, 4);
@ -659,13 +659,13 @@ FILE *fp;
if((n = buffer[I_NAMEOFF] & 0xff) > F_NAMELEN) { if((n = buffer[I_NAMEOFF] & 0xff) > F_NAMELEN) {
n = F_NAMELEN; n = F_NAMELEN;
} }
put4(theinfo.fi_namlen, (unsigned long)n); put4(theinfo.fi_namlen, (uint32_t)n);
(void)strncpy((char *)theinfo.fi_name, buffer + I_NAMEOFF + 1,n); (void)strncpy((char *)theinfo.fi_name, buffer + I_NAMEOFF + 1,n);
/* theinfo.fi_macfilename[n] = '\0'; */ /* theinfo.fi_macfilename[n] = '\0'; */
(void)strcpy((char *)theinfo.fi_comment, (void)strcpy((char *)theinfo.fi_comment,
"Converted by Unix utility to AppleDouble format"); "Converted by Unix utility to AppleDouble format");
put4(theinfo.fi_commsize, (unsigned long)strlen(theinfo.fi_comment)); put4(theinfo.fi_commsize, (uint32_t)strlen(theinfo.fi_comment));
put4(theinfo.fi_rsrc, (unsigned long)rsz); put4(theinfo.fi_rsrc, (uint32_t)rsz);
/* Still TODO */ /* Still TODO */
/* char fi_ctime[4]; /* Creation time (Unix time) */ /* char fi_ctime[4]; /* Creation time (Unix time) */
/* char fi_mtime[4]; /* Modification time (Unix time) */ /* char fi_mtime[4]; /* Modification time (Unix time) */

View File

@ -1,7 +1,9 @@
#include <stdint.h>
extern char *out_buffer, *out_ptr; extern char *out_buffer, *out_ptr;
extern void define_name(char *text); extern void define_name(char *text);
void start_info(char *info, unsigned long rsize, unsigned long dsize); void start_info(char *info, uint32_t rsize, uint32_t dsize);
extern void start_rsrc(void); extern void start_rsrc(void);
extern void start_data(void); extern void start_data(void);
extern void end_file(void); extern void end_file(void);

View File

@ -60,7 +60,7 @@ end_put (void)
if(info_only) { if(info_only) {
return; return;
} }
start_info(info, (unsigned long)rsrc_size, (unsigned long)data_size); start_info(info, (uint32_t)rsrc_size, (uint32_t)data_size);
if(data_size != 0) { if(data_size != 0) {
start_data(); start_data();
copy(out_ptr, data_fork, data_size); copy(out_ptr, data_fork, data_size);

View File

@ -27,13 +27,13 @@ comp_q_crc_n (register unsigned char *s, register unsigned char *e)
#endif /* HQX */ #endif /* HQX */
void void
verify_crc (unsigned long calc_crc, unsigned long file_crc) verify_crc (uint32_t calc_crc, uint32_t file_crc)
{ {
calc_crc &= WORDMASK; calc_crc &= WORDMASK;
file_crc &= WORDMASK; file_crc &= WORDMASK;
if(calc_crc != file_crc) { if(calc_crc != file_crc) {
(void)fprintf(stderr, "CRC mismatch: got 0x%04lx, need 0x%04lx\n", (void)fprintf(stderr, "CRC mismatch: got 0x%04x, need 0x%04x\n",
file_crc, calc_crc); file_crc, calc_crc);
#ifdef SCAN #ifdef SCAN
do_error("hexbin: CRC error"); do_error("hexbin: CRC error");

View File

@ -6,5 +6,5 @@ extern uint32_t crc;
extern void comp_q_crc (register unsigned int c); extern void comp_q_crc (register unsigned int c);
extern void comp_q_crc_n (register unsigned char *s, register unsigned char *e); extern void comp_q_crc_n (register unsigned char *s, register unsigned char *e);
extern void verify_crc (unsigned long calc_crc, unsigned long file_crc); extern void verify_crc (uint32_t calc_crc, uint32_t file_crc);

View File

@ -11,9 +11,9 @@
#include <stdlib.h> #include <stdlib.h>
static long dl_fork(); static int32_t dl_fork(void);
static int nchar(); static int nchar(void);
static int nextc(); static int nextc(void);
static char *icp = &line[0]; static char *icp = &line[0];
@ -67,19 +67,19 @@ dl (char *macname, char *filename)
(void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n); (void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n);
(void)strncpy(info + I_TYPEOFF, mh.m_type, 4); (void)strncpy(info + I_TYPEOFF, mh.m_type, 4);
(void)strncpy(info + I_AUTHOFF, mh.m_author, 4); (void)strncpy(info + I_AUTHOFF, mh.m_author, 4);
put4(info + I_DLENOFF, (unsigned long)mh.m_datalen); put4(info + I_DLENOFF, (uint32_t)mh.m_datalen);
put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen); put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen);
put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime); put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime);
put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime); put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime);
print_header2(0); print_header2(0);
end_put(); end_put();
} }
static long static int32_t
dl_fork (void) dl_fork (void)
{ {
register unsigned long i, v, c; register uint32_t i, v, c;
register unsigned long n, bytes; register uint32_t n, bytes;
n = 0; n = 0;
bytes = 0; bytes = 0;

View File

@ -1,4 +1,5 @@
#include <stdio.h> #include <stdio.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#ifdef BSD #ifdef BSD
extern char *rindex(); extern char *rindex();
@ -18,10 +19,10 @@ typedef struct macheader {
char m_type[4]; char m_type[4];
char m_author[4]; char m_author[4];
short m_flags; short m_flags;
long m_datalen; int32_t m_datalen;
long m_rsrclen; int32_t m_rsrclen;
long m_createtime; int32_t m_createtime;
long m_modifytime; int32_t m_modifytime;
} macheader; } macheader;
extern struct macheader mh; extern struct macheader mh;

View File

@ -13,7 +13,7 @@
#include <stdlib.h> #include <stdlib.h>
static void do_o_forks(); static void do_o_forks();
static long make_file(); static int32_t make_file();
static void comp_c_crc(); static void comp_c_crc();
static void comp_e_crc(); static void comp_e_crc();
static int comp_to_bin(); static int comp_to_bin();
@ -86,11 +86,11 @@ hecx (char *macname, char *filename)
(void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n); (void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n);
(void)strncpy(info + I_TYPEOFF, mh.m_type, 4); (void)strncpy(info + I_TYPEOFF, mh.m_type, 4);
(void)strncpy(info + I_AUTHOFF, mh.m_author, 4); (void)strncpy(info + I_AUTHOFF, mh.m_author, 4);
put2(info + I_FLAGOFF, (unsigned long)mh.m_flags); put2(info + I_FLAGOFF, (uint32_t)mh.m_flags);
put4(info + I_DLENOFF, (unsigned long)mh.m_datalen); put4(info + I_DLENOFF, (uint32_t)mh.m_datalen);
put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen); put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen);
put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime); put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime);
put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime); put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime);
print_header2(0); print_header2(0);
end_put(); end_put();
} }
@ -99,7 +99,7 @@ static void
do_o_forks (void) do_o_forks (void)
{ {
int forks = 0, found_crc = 0; int forks = 0, found_crc = 0;
unsigned long calc_crc, file_crc; uint32_t calc_crc, file_crc;
crc = 0; /* calculate a crc for both forks */ crc = 0; /* calculate a crc for both forks */
@ -128,13 +128,13 @@ do_o_forks (void)
if(compressed && strncmp(line, "***CRC:", 7) == 0) { if(compressed && strncmp(line, "***CRC:", 7) == 0) {
found_crc++; found_crc++;
calc_crc = crc; calc_crc = crc;
(void)sscanf(&line[7], "%lx", &file_crc); (void)sscanf(&line[7], "%x", &file_crc);
break; break;
} }
if(!compressed && strncmp(line, "***CHECKSUM:", 12) == 0) { if(!compressed && strncmp(line, "***CHECKSUM:", 12) == 0) {
found_crc++; found_crc++;
calc_crc = crc & BYTEMASK; calc_crc = crc & BYTEMASK;
(void)sscanf(&line[12], "%lx", &file_crc); (void)sscanf(&line[12], "%x", &file_crc);
file_crc &= BYTEMASK; file_crc &= BYTEMASK;
break; break;
} }
@ -151,10 +151,10 @@ do_o_forks (void)
} }
} }
static long static int32_t
make_file (int compressed) make_file (int compressed)
{ {
register long nbytes = 0L; register int32_t nbytes = 0L;
while(readline()) { while(readline()) {
if(line[0] == 0) { if(line[0] == 0) {

View File

@ -159,7 +159,7 @@ do_files (
char namebuf[256]; char namebuf[256];
char **ep; char **ep;
struct stat stbuf; struct stat stbuf;
long curtime; int32_t curtime;
int qformat; int qformat;
int again; int again;
@ -187,7 +187,7 @@ do_files (
again = 0; again = 0;
nexttry: nexttry:
if(ifp == stdin) { if(ifp == stdin) {
curtime = (long)time((time_t *)0) + TIMEDIFF; curtime = (int32_t)time((time_t *)0) + TIMEDIFF;
mh.m_createtime = curtime; mh.m_createtime = curtime;
mh.m_modifytime = curtime; mh.m_modifytime = curtime;
} else { } else {

View File

@ -11,12 +11,12 @@
#include "../util/util.h" #include "../util/util.h"
#include "printhdr.h" #include "printhdr.h"
static void get_header(); static void get_header(void);
static void oflush(); static void oflush(void);
static int getq(); static int getq(void);
static long get2q(); static int32_t get2q(void);
static long get4q(); static int32_t get4q(void);
static void getqbuf(); static void getqbuf(char *buf, int n);
static char *g_macname; static char *g_macname;
@ -98,10 +98,10 @@ static unsigned char *oq;
static int ostate = S_HEADER; static int ostate = S_HEADER;
static unsigned long calc_crc; static uint32_t calc_crc;
static unsigned long file_crc; static uint32_t file_crc;
static long todo; static int32_t todo;
#define output(c) { *op++ = (c); if(op >= &obuf[BUFSIZ]) oflush(); } #define output(c) { *op++ = (c); if(op >= &obuf[BUFSIZ]) oflush(); }
@ -236,7 +236,7 @@ static void
get_header (void) get_header (void)
{ {
int n; int n;
unsigned long calc_crc, file_crc; uint32_t calc_crc, file_crc;
crc = INITCRC; /* compute a crc for the header */ crc = INITCRC; /* compute a crc for the header */
@ -277,11 +277,11 @@ get_header (void)
(void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n); (void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n);
(void)strncpy(info + I_TYPEOFF, mh.m_type, 4); (void)strncpy(info + I_TYPEOFF, mh.m_type, 4);
(void)strncpy(info + I_AUTHOFF, mh.m_author, 4); (void)strncpy(info + I_AUTHOFF, mh.m_author, 4);
put2(info + I_FLAGOFF, (unsigned long)mh.m_flags); put2(info + I_FLAGOFF, (uint32_t)mh.m_flags);
put4(info + I_DLENOFF, (unsigned long)mh.m_datalen); put4(info + I_DLENOFF, (uint32_t)mh.m_datalen);
put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen); put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen);
put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime); put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime);
put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime); put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime);
} }
static void static void
@ -364,7 +364,7 @@ getq (void)
} }
/* get2q(); q format -- read 2 bytes from input, return short */ /* get2q(); q format -- read 2 bytes from input, return short */
static long static int32_t
get2q (void) get2q (void)
{ {
short high = getq() << 8; short high = getq() << 8;
@ -372,11 +372,11 @@ get2q (void)
} }
/* get4q(); q format -- read 4 bytes from input, return long */ /* get4q(); q format -- read 4 bytes from input, return long */
static long static int32_t
get4q (void) get4q (void)
{ {
int i; int i;
long value = 0; int32_t value = 0;
for(i = 0; i < 4; i++) { for(i = 0; i < 4; i++) {
value = (value<<8) | getq(); value = (value<<8) | getq();

View File

@ -136,10 +136,10 @@ mu (char *macname)
(void)strncpy(mh.m_type, info + I_TYPEOFF, 4); (void)strncpy(mh.m_type, info + I_TYPEOFF, 4);
(void)strncpy(mh.m_author, info + I_AUTHOFF, 4); (void)strncpy(mh.m_author, info + I_AUTHOFF, 4);
print_header1(0, 0); print_header1(0, 0);
put4(info + I_DLENOFF, (unsigned long)mh.m_datalen); put4(info + I_DLENOFF, (uint32_t)mh.m_datalen);
put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen); put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen);
put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime); put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime);
put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime); put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime);
print_header2(0); print_header2(0);
end_put(); end_put();
} }
@ -147,7 +147,7 @@ mu (char *macname)
static void static void
do_mu_fork (void) do_mu_fork (void)
{ {
long newbytes; int32_t newbytes;
while(readline()) { while(readline()) {
if(line[0] == 0) { if(line[0] == 0) {

View File

@ -37,7 +37,7 @@ void print_header2(int skip)
if (skip) { if (skip) {
(void)fprintf(stderr, "\t"); (void)fprintf(stderr, "\t");
} }
(void)fprintf(stderr, "data=%ld, rsrc=%ld\n", (void)fprintf(stderr, "data=%d, rsrc=%d\n",
mh.m_datalen, mh.m_rsrclen); mh.m_datalen, mh.m_rsrclen);
} }
} }

View File

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

View File

@ -14,7 +14,7 @@ void
bin (char *header, int data_size, int UMcp) bin (char *header, int data_size, int UMcp)
{ {
char hdr[INFOBYTES]; char hdr[INFOBYTES];
unsigned long rsrcLength, dataLength; uint32_t rsrcLength, dataLength;
hdr[0] = getb(infp); hdr[0] = getb(infp);
(void)ungetc(hdr[0], infp); (void)ungetc(hdr[0], infp);
@ -38,7 +38,7 @@ bin (char *header, int data_size, int UMcp)
#ifdef SCAN #ifdef SCAN
do_idf("", COPY); do_idf("", COPY);
#endif /* SCAN */ #endif /* SCAN */
mcb(header, (unsigned long)in_data_size, (unsigned long)in_rsrc_size, mcb(header, (uint32_t)in_data_size, (uint32_t)in_rsrc_size,
in_ds + in_rs); in_ds + in_rs);
ds_skip = 0; ds_skip = 0;
rs_skip = 0; rs_skip = 0;

View File

@ -24,17 +24,17 @@
static void cpt_uncompact(); static void cpt_uncompact();
static unsigned char *cpt_data; static unsigned char *cpt_data;
static unsigned long cpt_datamax; static uint32_t cpt_datamax;
static unsigned long cpt_datasize; static uint32_t cpt_datasize;
static unsigned char cpt_LZbuff[CIRCSIZE]; static unsigned char cpt_LZbuff[CIRCSIZE];
static unsigned int cpt_LZptr; static unsigned int cpt_LZptr;
static unsigned char *cpt_char; static unsigned char *cpt_char;
static unsigned long cpt_crc; static uint32_t cpt_crc;
static unsigned long cpt_inlength; static uint32_t cpt_inlength;
static unsigned long cpt_outlength; static uint32_t cpt_outlength;
static int cpt_outstat; static int cpt_outstat;
static unsigned char cpt_savechar; static unsigned char cpt_savechar;
static unsigned long cpt_newbits; static uint32_t cpt_newbits;
static int cpt_bitsavail; static int cpt_bitsavail;
static int cpt_blocksize; static int cpt_blocksize;
/* Lengths is twice the max number of entries, and include slack. */ /* Lengths is twice the max number of entries, and include slack. */
@ -254,9 +254,9 @@ cpt_filehdr (struct cpt_fileHdr *f, char *hdr)
transname(hdr + F_FTYPE, ftype, 4); transname(hdr + F_FTYPE, ftype, 4);
transname(hdr + F_CREATOR, fauth, 4); transname(hdr + F_CREATOR, fauth, 4);
(void)fprintf(stderr, (void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, text, ftype, fauth,
(long)f->dataLength, (long)f->rsrcLength); (int32_t)f->dataLength, (int32_t)f->rsrcLength);
} }
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
@ -381,8 +381,8 @@ cpt_uncompact (struct cpt_fileHdr filehdr)
filehdr.cptFlag & 4); filehdr.cptFlag & 4);
if(filehdr.fileCRC != cpt_crc) { if(filehdr.fileCRC != cpt_crc) {
(void)fprintf(stderr, (void)fprintf(stderr,
"CRC error on file: need 0x%08lx, got 0x%08lx\n", "CRC error on file: need 0x%08x, got 0x%08x\n",
(long)filehdr.fileCRC, (long)cpt_crc); (int32_t)filehdr.fileCRC, (int32_t)cpt_crc);
#ifdef SCAN #ifdef SCAN
do_error("macunpack: CRC error on file"); do_error("macunpack: CRC error on file");
#endif /* SCAN */ #endif /* SCAN */
@ -396,7 +396,7 @@ cpt_uncompact (struct cpt_fileHdr filehdr)
} }
static void static void
cpt_wrfile (unsigned long ibytes, unsigned long obytes, int type) cpt_wrfile (uint32_t ibytes, uint32_t obytes, int type)
{ {
if(ibytes == 0) { if(ibytes == 0) {
return; return;
@ -415,7 +415,7 @@ cpt_wrfile (unsigned long ibytes, unsigned long obytes, int type)
} }
void void
cpt_wrfile1 (unsigned char *in_char, unsigned long ibytes, unsigned long obytes, int type, unsigned long blocksize) cpt_wrfile1 (unsigned char *in_char, uint32_t ibytes, uint32_t obytes, int type, uint32_t blocksize)
{ {
cpt_char = in_char; cpt_char = in_char;
if(ibytes == 0) { if(ibytes == 0) {

View File

@ -1,3 +1,5 @@
#include <stdint.h>
#define C_SIGNATURE 0 #define C_SIGNATURE 0
#define C_VOLUME 1 #define C_VOLUME 1
#define C_XMAGIC 2 #define C_XMAGIC 2
@ -29,15 +31,15 @@
#define F_COMPDLENGTH 76 #define F_COMPDLENGTH 76
#define CPT_FILEHDRSIZE 80 #define CPT_FILEHDRSIZE 80
typedef long OSType; typedef int32_t OSType;
typedef struct cptHdr { /* 8 bytes */ typedef struct cptHdr { /* 8 bytes */
unsigned char signature; /* = 1 -- for verification */ unsigned char signature; /* = 1 -- for verification */
unsigned char volume; /* for multi-file archives */ unsigned char volume; /* for multi-file archives */
unsigned short xmagic; /* verification multi-file consistency*/ unsigned short xmagic; /* verification multi-file consistency*/
unsigned long offset; /* index offset */ uint32_t offset; /* index offset */
/* The following are really in header2 at offset */ /* The following are really in header2 at offset */
unsigned long hdrcrc; /* header crc */ uint32_t hdrcrc; /* header crc */
unsigned short entries; /* number of index entries */ unsigned short entries; /* number of index entries */
unsigned char commentsize; /* number of bytes comment that follow*/ unsigned char commentsize; /* number of bytes comment that follow*/
} cptHdr; } cptHdr;
@ -47,20 +49,20 @@ typedef struct cpt_fileHdr { /* 78 bytes */
unsigned char folder; /* set to 1 if a folder */ unsigned char folder; /* set to 1 if a folder */
unsigned short foldersize; /* number of entries in folder */ unsigned short foldersize; /* number of entries in folder */
unsigned char volume; /* for multi-file archives */ unsigned char volume; /* for multi-file archives */
unsigned long filepos; /* position of data in file */ uint32_t filepos; /* position of data in file */
OSType fType; /* file type */ OSType fType; /* file type */
OSType fCreator; /* er... */ OSType fCreator; /* er... */
unsigned long creationDate; uint32_t creationDate;
unsigned long modDate; /* !restored-compat w/backup prgms */ uint32_t modDate; /* !restored-compat w/backup prgms */
unsigned short FndrFlags; /* copy of Finder flags. For our unsigned short FndrFlags; /* copy of Finder flags. For our
purposes, we can clear: purposes, we can clear:
busy,onDesk */ busy,onDesk */
unsigned long fileCRC; /* crc on file */ uint32_t fileCRC; /* crc on file */
unsigned short cptFlag; /* cpt flags */ unsigned short cptFlag; /* cpt flags */
unsigned long rsrcLength; /* decompressed lengths */ uint32_t rsrcLength; /* decompressed lengths */
unsigned long dataLength; uint32_t dataLength;
unsigned long compRLength; /* compressed lengths */ uint32_t compRLength; /* compressed lengths */
unsigned long compDLength; uint32_t compDLength;
} cpt_fileHdr; } cpt_fileHdr;
@ -93,7 +95,7 @@ typedef struct cpt_fileHdr { /* 78 bytes */
void void
cpt_wrfile1 (unsigned char *in_char, cpt_wrfile1 (unsigned char *in_char,
unsigned long ibytes, uint32_t ibytes,
unsigned long obytes, uint32_t obytes,
int type, int type,
unsigned long blocksize); uint32_t blocksize);

View File

@ -20,9 +20,9 @@ static void dd_cfilehdr();
static int dd_valid(); static int dd_valid();
static int dd_valid1(); static int dd_valid1();
static char *dd_methname(); static char *dd_methname();
static unsigned long dd_checksum(); static uint32_t dd_checksum();
static void dd_chksum(); static void dd_chksum();
static unsigned long dd_checkor(); static uint32_t dd_checkor();
static void dd_do_delta(); static void dd_do_delta();
static void dd_delta(); static void dd_delta();
static void dd_delta3(); static void dd_delta3();
@ -67,7 +67,7 @@ static unsigned char *dd_dirst;
static int dd_dirstptr; static int dd_dirstptr;
static int dd_dirstmax; static int dd_dirstmax;
static int dd_xor; static int dd_xor;
static long dd_bitbuf; static int32_t dd_bitbuf;
static int dd_bitcount; static int dd_bitcount;
static unsigned char *dd_bitptr; static unsigned char *dd_bitptr;
static char dd_LZbuff[2048]; static char dd_LZbuff[2048];
@ -75,7 +75,7 @@ static char dd_LZbuff[2048];
void void
dd_file (unsigned char *bin_hdr) dd_file (unsigned char *bin_hdr)
{ {
unsigned long data_size; uint32_t data_size;
int i; int i;
struct dd_fileCHdr cf; struct dd_fileCHdr cf;
char ftype[5], fauth[5]; char ftype[5], fauth[5];
@ -117,9 +117,9 @@ dd_file (unsigned char *bin_hdr)
transname(info + I_TYPEOFF, ftype, 4); transname(info + I_TYPEOFF, ftype, 4);
transname(info + I_AUTHOFF, fauth, 4); transname(info + I_AUTHOFF, fauth, 4);
(void)fprintf(stderr, (void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, text, ftype, fauth,
(long)get4(info + I_DLENOFF), (long)get4(info + I_RLENOFF)); (int32_t)get4(info + I_DLENOFF), (int32_t)get4(info + I_RLENOFF));
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
} }
@ -149,7 +149,7 @@ dd_file (unsigned char *bin_hdr)
void void
dd_arch (unsigned char *bin_hdr) dd_arch (unsigned char *bin_hdr)
{ {
unsigned long data_size; uint32_t data_size;
uint32_t crc, filecrc; uint32_t crc, filecrc;
struct dd_fileHdr f; struct dd_fileHdr f;
struct dd_fileCHdr cf; struct dd_fileCHdr cf;
@ -323,7 +323,7 @@ dd_filehdr (struct dd_fileHdr *f, struct dd_fileCHdr *cf, int skip)
int n, to_uncompress; int n, to_uncompress;
unsigned char *hdr; unsigned char *hdr;
char ftype[5], fauth[5]; char ftype[5], fauth[5];
unsigned long datalength, rsrclength; uint32_t datalength, rsrclength;
to_uncompress = DD_COPY; to_uncompress = DD_COPY;
hdr = dd_data_ptr; hdr = dd_data_ptr;
@ -391,8 +391,8 @@ dd_filehdr (struct dd_fileHdr *f, struct dd_fileCHdr *cf, int skip)
transname(info + I_TYPEOFF, ftype, 4); transname(info + I_TYPEOFF, ftype, 4);
transname(info + I_AUTHOFF, fauth, 4); transname(info + I_AUTHOFF, fauth, 4);
(void)fprintf(stderr, (void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, (long)datalength, (long)rsrclength); text, ftype, fauth, (int32_t)datalength, (int32_t)rsrclength);
} }
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
@ -509,11 +509,11 @@ int i, nmeths;
return NULL; return NULL;
} }
static unsigned long static uint32_t
dd_checksum (unsigned long init, char *buffer, unsigned long length) dd_checksum (uint32_t init, char *buffer, uint32_t length)
{ {
int i; int i;
unsigned long cks; uint32_t cks;
cks = init; cks = init;
for(i = 0; i < length; i++) { for(i = 0; i < length; i++) {
@ -525,7 +525,7 @@ dd_checksum (unsigned long init, char *buffer, unsigned long length)
static void static void
dd_chksum (struct dd_fileHdr hdr, unsigned char *data) dd_chksum (struct dd_fileHdr hdr, unsigned char *data)
{ {
unsigned long cks; uint32_t cks;
if(write_it) { if(write_it) {
cks = dd_checksum(INIT_CRC, (char *)data - CDD_FILEHDRSIZE, cks = dd_checksum(INIT_CRC, (char *)data - CDD_FILEHDRSIZE,
@ -542,11 +542,11 @@ dd_chksum (struct dd_fileHdr hdr, unsigned char *data)
} }
} }
static unsigned long static uint32_t
dd_checkor (unsigned long init, char *buffer, unsigned long length) dd_checkor (uint32_t init, char *buffer, uint32_t length)
{ {
int i; int i;
unsigned long cks; uint32_t cks;
cks = init; cks = init;
for(i = 0; i < length; i++) { for(i = 0; i < length; i++) {
@ -556,7 +556,7 @@ dd_checkor (unsigned long init, char *buffer, unsigned long length)
} }
static void static void
dd_do_delta (char *out_ptr, unsigned long nbytes, int kind) dd_do_delta (char *out_ptr, uint32_t nbytes, int kind)
{ {
switch(kind) { switch(kind) {
case 0: case 0:
@ -577,7 +577,7 @@ dd_do_delta (char *out_ptr, unsigned long nbytes, int kind)
} }
static void static void
dd_delta (char *out_ptr, unsigned long nbytes) dd_delta (char *out_ptr, uint32_t nbytes)
{ {
int i, sum = 0; int i, sum = 0;
@ -588,7 +588,7 @@ dd_delta (char *out_ptr, unsigned long nbytes)
} }
static void static void
dd_delta3 (char *out_ptr, unsigned long nbytes) dd_delta3 (char *out_ptr, uint32_t nbytes)
{ {
int i, sum1 = 0, sum2 = 0, sum3 = 0; int i, sum1 = 0, sum2 = 0, sum3 = 0;
@ -612,7 +612,7 @@ dd_delta3 (char *out_ptr, unsigned long nbytes)
static void static void
dd_copy (struct dd_fileHdr hdr, unsigned char *data) dd_copy (struct dd_fileHdr hdr, unsigned char *data)
{ {
unsigned long cks; uint32_t cks;
if(write_it) { if(write_it) {
start_info(info, hdr.rsrcLength, hdr.dataLength); start_info(info, hdr.rsrcLength, hdr.dataLength);
@ -661,7 +661,7 @@ dd_copy (struct dd_fileHdr hdr, unsigned char *data)
} }
static void static void
dd_copyfile (unsigned long obytes, unsigned char *data) dd_copyfile (uint32_t obytes, unsigned char *data)
{ {
if(obytes == 0) { if(obytes == 0) {
return; return;
@ -677,7 +677,7 @@ dd_copyfile (unsigned long obytes, unsigned char *data)
static void static void
dd_expand (struct dd_fileCHdr hdr, unsigned char *data) dd_expand (struct dd_fileCHdr hdr, unsigned char *data)
{ {
unsigned long cks; uint32_t cks;
char *out_buf; char *out_buf;
if(write_it) { if(write_it) {
@ -691,7 +691,7 @@ dd_expand (struct dd_fileCHdr hdr, unsigned char *data)
} }
out_buf = out_buffer; out_buf = out_buffer;
dd_expandfile(hdr.dataLength, hdr.dataCLength, (int)hdr.datamethod, dd_expandfile(hdr.dataLength, hdr.dataCLength, (int)hdr.datamethod,
(int)hdr.datainfo, data, (unsigned long)hdr.datacrc); (int)hdr.datainfo, data, (uint32_t)hdr.datacrc);
data += hdr.dataCLength; data += hdr.dataCLength;
if(write_it) { if(write_it) {
if((hdr.info2 & 0x40) && (hdr.dataLength != 0)) { if((hdr.info2 & 0x40) && (hdr.dataLength != 0)) {
@ -716,7 +716,7 @@ dd_expand (struct dd_fileCHdr hdr, unsigned char *data)
} }
out_buf = out_buffer; out_buf = out_buffer;
dd_expandfile(hdr.rsrcLength, hdr.rsrcCLength, (int)hdr.rsrcmethod, dd_expandfile(hdr.rsrcLength, hdr.rsrcCLength, (int)hdr.rsrcmethod,
(int)hdr.rsrcinfo, data, (unsigned long)hdr.rsrccrc); (int)hdr.rsrcinfo, data, (uint32_t)hdr.rsrccrc);
data += hdr.rsrcCLength; data += hdr.rsrcCLength;
if(write_it) { if(write_it) {
if((hdr.info2 & 0x40) && (hdr.rsrcLength != 0)) { if((hdr.info2 & 0x40) && (hdr.rsrcLength != 0)) {
@ -740,11 +740,11 @@ dd_expand (struct dd_fileCHdr hdr, unsigned char *data)
} }
static void static void
dd_expandfile (unsigned long obytes, unsigned long ibytes, int method, int kind, unsigned char *data, unsigned long chksum) dd_expandfile (uint32_t obytes, uint32_t ibytes, int method, int kind, unsigned char *data, uint32_t chksum)
{ {
int sub_method, m1, m2; int sub_method, m1, m2;
char *optr = out_ptr; char *optr = out_ptr;
unsigned long cksinit; uint32_t cksinit;
if(obytes == 0) { if(obytes == 0) {
if(verbose) { if(verbose) {
@ -839,7 +839,7 @@ dd_expandfile (unsigned long obytes, unsigned long ibytes, int method, int kind,
/* Method 0: no compression */ /* Method 0: no compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
dd_nocomp (unsigned long obytes, unsigned char *data) dd_nocomp (uint32_t obytes, unsigned char *data)
{ {
copy(out_ptr, (char *)data, (int)obytes); copy(out_ptr, (char *)data, (int)obytes);
} }
@ -848,11 +848,11 @@ dd_nocomp (unsigned long obytes, unsigned char *data)
/* Method 1: LZC compressed */ /* Method 1: LZC compressed */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
dd_lzc (unsigned long ibytes, unsigned long obytes, unsigned char *data, int mb, unsigned long chksum, unsigned long ckinit) dd_lzc (uint32_t ibytes, uint32_t obytes, unsigned char *data, int mb, uint32_t chksum, uint32_t ckinit)
{ {
int i; int i;
char *out_buf; char *out_buf;
unsigned long cks; uint32_t cks;
out_buf = out_buffer; out_buf = out_buffer;
core_compress((char *)data); core_compress((char *)data);
@ -880,7 +880,7 @@ dd_lzc (unsigned long ibytes, unsigned long obytes, unsigned char *data, int mb,
/* Method 3: Run length encoding */ /* Method 3: Run length encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
dd_rle (unsigned long ibytes, unsigned char *data) dd_rle (uint32_t ibytes, unsigned char *data)
{ {
int ch, lastch, n, i; int ch, lastch, n, i;
@ -910,7 +910,7 @@ dd_rle (unsigned long ibytes, unsigned char *data)
/* Method 4: Huffman encoding */ /* Method 4: Huffman encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
dd_huffman (unsigned long ibytes, unsigned char *data) dd_huffman (uint32_t ibytes, unsigned char *data)
{ {
} }
#endif /* NOTIMPLEMENTED */ #endif /* NOTIMPLEMENTED */
@ -919,7 +919,7 @@ dd_huffman (unsigned long ibytes, unsigned char *data)
/* Method 7: Slightly improved LZSS */ /* Method 7: Slightly improved LZSS */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
dd_lzss (unsigned char *data, unsigned long chksum) dd_lzss (unsigned char *data, uint32_t chksum)
{ {
int i, LZptr, LZbptr, LZlength; int i, LZptr, LZbptr, LZlength;
char *optr = out_ptr; char *optr = out_ptr;
@ -959,7 +959,7 @@ dd_lzss (unsigned char *data, unsigned long chksum)
} }
} }
} }
cks = dd_checkor(INIT_CRC, optr, (unsigned long)(out_ptr - optr)); cks = dd_checkor(INIT_CRC, optr, (uint32_t)(out_ptr - optr));
if(chksum != cks) { if(chksum != cks) {
(void)fprintf(stderr, (void)fprintf(stderr,
"Checksum error on fork: need 0x%04x, got 0x%04x\n", "Checksum error on fork: need 0x%04x, got 0x%04x\n",
@ -992,12 +992,12 @@ dd_getbits (int n)
/* Method 8: Compactor compatible compression */ /* Method 8: Compactor compatible compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
dd_cpt_compat (unsigned long ibytes, unsigned long obytes, unsigned char *data, int sub_method, unsigned long chksum) dd_cpt_compat (uint32_t ibytes, uint32_t obytes, unsigned char *data, int sub_method, uint32_t chksum)
{ {
unsigned long cks; uint32_t cks;
char *optr = out_buffer; char *optr = out_buffer;
cpt_wrfile1(data, ibytes, obytes, sub_method, (unsigned long)0x0fff0); cpt_wrfile1(data, ibytes, obytes, sub_method, (uint32_t)0x0fff0);
cks = arc_updcrc(INIT_CRC, (unsigned char *)optr, (int)obytes); cks = arc_updcrc(INIT_CRC, (unsigned char *)optr, (int)obytes);
if(chksum != cks) { if(chksum != cks) {
(void)fprintf(stderr, (void)fprintf(stderr,

View File

@ -1,6 +1,9 @@
#include "macunpack.h" #include "macunpack.h"
#ifdef DD #ifdef DD
#include <stdint.h>
#ifdef DD_INTERNAL #ifdef DD_INTERNAL
#define MAGIC1 "DDAR" #define MAGIC1 "DDAR"
@ -55,7 +58,7 @@
#define DD_C_HDRCRC 82 #define DD_C_HDRCRC 82
#define CDD_FILEHDRSIZE 84 #define CDD_FILEHDRSIZE 84
typedef long OSType; typedef int32_t OSType;
typedef struct dd_fileHdr { /* 124 bytes */ typedef struct dd_fileHdr { /* 124 bytes */
unsigned char magic[4]; /* "DDAR" */ unsigned char magic[4]; /* "DDAR" */
@ -63,10 +66,10 @@ typedef struct dd_fileHdr { /* 124 bytes */
unsigned char fName[64]; /* a STR63 */ unsigned char fName[64]; /* a STR63 */
unsigned char isdir; /* starts a directory? */ unsigned char isdir; /* starts a directory? */
unsigned char enddir; /* terminates a directory? */ unsigned char enddir; /* terminates a directory? */
unsigned long dataLength; /* lengths */ uint32_t dataLength; /* lengths */
unsigned long rsrcLength; uint32_t rsrcLength;
unsigned long creationDate; uint32_t creationDate;
unsigned long modDate; uint32_t modDate;
OSType fType; /* file type */ OSType fType; /* file type */
OSType fCreator; /* er... */ OSType fCreator; /* er... */
unsigned short FndrFlags; /* copy of Finder flags. For our unsigned short FndrFlags; /* copy of Finder flags. For our
@ -80,16 +83,16 @@ typedef struct dd_fileHdr { /* 124 bytes */
typedef struct dd_fileCHdr { /* 84 bytes */ typedef struct dd_fileCHdr { /* 84 bytes */
unsigned char magic[4]; /* "\253\315\000\124" */ unsigned char magic[4]; /* "\253\315\000\124" */
unsigned long dataLength; /* lengths */ uint32_t dataLength; /* lengths */
unsigned long dataCLength; uint32_t dataCLength;
unsigned long rsrcLength; uint32_t rsrcLength;
unsigned long rsrcCLength; uint32_t rsrcCLength;
unsigned char datamethod; /* compression method used */ unsigned char datamethod; /* compression method used */
unsigned char rsrcmethod; unsigned char rsrcmethod;
unsigned char info1; /* flags ??? */ unsigned char info1; /* flags ??? */
unsigned char fill3; unsigned char fill3;
unsigned long modDate; uint32_t modDate;
unsigned long creationDate; uint32_t creationDate;
OSType fType; /* file type */ OSType fType; /* file type */
OSType fCreator; /* er... */ OSType fCreator; /* er... */
unsigned short FndrFlags; /* copy of Finder flags. For our unsigned short FndrFlags; /* copy of Finder flags. For our

View File

@ -19,20 +19,20 @@
static int n_bits; /* number of bits/code */ static int n_bits; /* number of bits/code */
static int maxbits; /* user settable max # bits/code */ static int maxbits; /* user settable max # bits/code */
static long maxcode; /* maximum code, given n_bits */ static int32_t maxcode; /* maximum code, given n_bits */
static long maxmaxcode; /* should NEVER generate this code */ static int32_t maxmaxcode; /* should NEVER generate this code */
# define MAXCODE(n_bits) ((1 << (n_bits)) - 1) # define MAXCODE(n_bits) ((1 << (n_bits)) - 1)
static long htab [HSIZE]; static int32_t htab [HSIZE];
static unsigned short codetab [HSIZE]; static unsigned short codetab [HSIZE];
#define tab_prefixof(i) codetab[i] #define tab_prefixof(i) codetab[i]
#define tab_suffixof(i) ((unsigned char *)(htab))[i] #define tab_suffixof(i) ((unsigned char *)(htab))[i]
#define de_stack ((unsigned char *)&tab_suffixof(1<<BITS)) #define de_stack ((unsigned char *)&tab_suffixof(1<<BITS))
static long free_ent = 0; /* first unused entry */ static int32_t free_ent = 0; /* first unused entry */
static long getcode(); static int32_t getcode();
static int clear_flg = 0; static int clear_flg = 0;
@ -45,11 +45,11 @@ static int clear_flg = 0;
static int toread; static int toread;
void de_compress(unsigned long ibytes, int mb) void de_compress(uint32_t ibytes, int mb)
{ {
register unsigned char *stackp; register unsigned char *stackp;
register int finchar; register int finchar;
register long code, oldcode, incode; register int32_t code, oldcode, incode;
toread = ibytes; toread = ibytes;
maxbits = mb; maxbits = mb;
@ -124,10 +124,10 @@ static char *core_ptr;
static int file_bytes(); static int file_bytes();
static int core_bytes(); static int core_bytes();
static long static int32_t
getcode (void) getcode (void)
{ {
register long code; register int32_t code;
static int offset = 0, size = 0; static int offset = 0, size = 0;
static unsigned char buf[BITS]; static unsigned char buf[BITS];
register int r_off, bits; register int r_off, bits;

View File

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

View File

@ -35,7 +35,7 @@ static node *nodeptr, *read_sub_tree();
static int bit; static int bit;
void de_huffman(unsigned long obytes) void de_huffman(uint32_t obytes)
{ {
while(obytes != 0) { while(obytes != 0) {
*out_ptr++ = gethuffbyte(nodelist); *out_ptr++ = gethuffbyte(nodelist);

View File

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

View File

@ -95,7 +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(unsigned long obytes) void de_lzah(uint32_t obytes)
{ {
int i, i1, j, ch, byte, offs, skip; int i, i1, j, ch, byte, offs, skip;

View File

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

View File

@ -24,7 +24,7 @@ static unsigned int decode_p();
static void make_table(); static void make_table();
/* lzh compression */ /* lzh compression */
void de_lzh(long ibytes, long obytes, char **data, int bits) void de_lzh(int32_t ibytes, int32_t obytes, char **data, int bits)
{ {
unsigned int i, r, c; unsigned int i, r, c;
int remains; int remains;

View File

@ -202,7 +202,7 @@ dia_file (int indicator, unsigned char *name)
int dataLength, rsrcLength; int dataLength, rsrcLength;
int cdataLength, crsrcLength; int cdataLength, crsrcLength;
int dataMethod, rsrcMethod; int dataMethod, rsrcMethod;
unsigned long curtime; uint32_t curtime;
if(name != NULL) { if(name != NULL) {
for(i = 0; i < INFOBYTES; i++) { for(i = 0; i < INFOBYTES; i++) {
@ -230,7 +230,7 @@ dia_file (int indicator, unsigned char *name)
info[I_MTIMOFF + i] = *dia_header_ptr++; info[I_MTIMOFF + i] = *dia_header_ptr++;
} }
} else { } else {
curtime = (unsigned long)time((time_t *)0) + TIMEDIFF; curtime = (uint32_t)time((time_t *)0) + TIMEDIFF;
put4(info + I_CTIMOFF, curtime); put4(info + I_CTIMOFF, curtime);
put4(info + I_MTIMOFF, curtime); put4(info + I_MTIMOFF, curtime);
} }
@ -266,16 +266,16 @@ dia_file (int indicator, unsigned char *name)
crsrcLength = dia_cforklength; crsrcLength = dia_cforklength;
rsrcMethod = dia_method; rsrcMethod = dia_method;
dia_archive_ptr = old_archive_ptr; dia_archive_ptr = old_archive_ptr;
put4(info + I_DLENOFF, (unsigned long)dataLength); put4(info + I_DLENOFF, (uint32_t)dataLength);
put4(info + I_RLENOFF, (unsigned long)rsrcLength); put4(info + I_RLENOFF, (uint32_t)rsrcLength);
if(list) { if(list) {
transname(info + I_NAMEOFF + 1, (char *)lname, length); transname(info + I_NAMEOFF + 1, (char *)lname, length);
do_indent(indent); do_indent(indent);
transname(info + I_TYPEOFF, ftype, 4); transname(info + I_TYPEOFF, ftype, 4);
transname(info + I_AUTHOFF, fauth, 4); transname(info + I_AUTHOFF, fauth, 4);
(void)fprintf(stderr, (void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
lname, ftype, fauth, (long)dataLength, (long)rsrcLength); lname, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength);
if(info_only) { if(info_only) {
doit = 0; doit = 0;
} else { } else {
@ -296,7 +296,7 @@ dia_file (int indicator, unsigned char *name)
} }
if(doit) { if(doit) {
define_name((char *)lname); define_name((char *)lname);
start_info(info, (unsigned long)rsrcLength, (unsigned long)dataLength); start_info(info, (uint32_t)rsrcLength, (uint32_t)dataLength);
} }
if(verbose) { if(verbose) {
(void)fprintf(stderr, "\tData: "); (void)fprintf(stderr, "\tData: ");

View File

@ -14,7 +14,7 @@ static void jdw_wrfork();
static void jdw_block(); static void jdw_block();
void void
jdw (unsigned long ibytes) jdw (uint32_t ibytes)
{ {
char fauth[5], ftype[5]; char fauth[5], ftype[5];
int filel, i; int filel, i;
@ -63,8 +63,8 @@ jdw (unsigned long ibytes)
transname(info + I_AUTHOFF, fauth, 4); transname(info + I_AUTHOFF, fauth, 4);
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, (long)dataLength, (long)rsrcLength); text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength);
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
} }
@ -74,11 +74,11 @@ jdw (unsigned long ibytes)
(void)fputc('\n', stderr); (void)fputc('\n', stderr);
} }
} }
jdw_wrfile((unsigned long)rsrcLength, (unsigned long)dataLength); jdw_wrfile((uint32_t)rsrcLength, (uint32_t)dataLength);
} }
static void static void
jdw_wrfile (unsigned long rsrcLength, unsigned long dataLength) jdw_wrfile (uint32_t rsrcLength, uint32_t dataLength)
{ {
if(write_it) { if(write_it) {
define_name(text); define_name(text);
@ -105,10 +105,10 @@ jdw_wrfile (unsigned long rsrcLength, unsigned long dataLength)
} }
static void static void
jdw_wrfork (unsigned long length) jdw_wrfork (uint32_t length)
{ {
int olength, ilength, i; int olength, ilength, i;
unsigned long origlength, comprlength; uint32_t origlength, comprlength;
if(length == 0) { if(length == 0) {
(void)fprintf(stderr, "empty"); (void)fprintf(stderr, "empty");
@ -148,7 +148,7 @@ jdw_block (int olength)
bytesread++; bytesread++;
} }
clrhuff(); clrhuff();
de_huffman((unsigned long)olength); de_huffman((uint32_t)olength);
} }
#else /* JDW */ #else /* JDW */
int jdw; /* keep lint and some compilers happy */ int jdw; /* keep lint and some compilers happy */

View File

@ -1,3 +1,5 @@
#include <stdint.h>
#define J_MAGIC 0 #define J_MAGIC 0
#define J_TYPE 6 #define J_TYPE 6
#define J_AUTH 10 #define J_AUTH 10
@ -10,13 +12,13 @@
typedef struct jdw_fileHdr { typedef struct jdw_fileHdr {
char magic[6]; char magic[6];
unsigned long type; uint32_t type;
unsigned long auth; uint32_t auth;
char finfo[8]; char finfo[8];
unsigned long dataLength; uint32_t dataLength;
unsigned long rsrcLength; uint32_t rsrcLength;
unsigned long ctime; uint32_t ctime;
unsigned long mtime; uint32_t mtime;
char flength; char flength;
char fname[32]; /* actually flength */ char fname[32]; /* actually flength */
} jdw_fileHdr; } jdw_fileHdr;

View File

@ -29,7 +29,7 @@ static void
lzc_zivm (char *ohdr) lzc_zivm (char *ohdr)
{ {
char hdr[HEADERBYTES]; char hdr[HEADERBYTES];
unsigned long dataLength, rsrcLength, dataCLength, rsrcCLength; uint32_t dataLength, rsrcLength, dataCLength, rsrcCLength;
char ftype[5], fauth[5]; char ftype[5], fauth[5];
if(fread(hdr, 1, HEADERBYTES, infp) != HEADERBYTES) { if(fread(hdr, 1, HEADERBYTES, infp) != HEADERBYTES) {
@ -67,8 +67,8 @@ lzc_zivm (char *ohdr)
transname(hdr + C_AUTHOFF, fauth, 4); transname(hdr + C_AUTHOFF, fauth, 4);
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, (long)dataLength, (long)rsrcLength); text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength);
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
} }
@ -108,7 +108,7 @@ lzc_zivm (char *ohdr)
} }
static void static void
lzc_wrfile (unsigned long obytes, unsigned long ibytes) lzc_wrfile (uint32_t obytes, uint32_t ibytes)
{ {
int n, nbits; int n, nbits;
char subheader[3]; char subheader[3];
@ -186,7 +186,7 @@ lzc_zivu (char *ohdr)
{ {
(void)fprintf(stderr, (void)fprintf(stderr,
"\tMacCompress(Unix) not yet implemented, copied as MacBinary\n"); "\tMacCompress(Unix) not yet implemented, copied as MacBinary\n");
mcb(ohdr, (unsigned long)in_rsrc_size, (unsigned long)in_data_size, mcb(ohdr, (uint32_t)in_rsrc_size, (uint32_t)in_data_size,
in_ds + in_rs); in_ds + in_rs);
} }
#else /* LZC */ #else /* LZC */

View File

@ -1,3 +1,5 @@
#include <stdint.h>
#define HEADERBYTES 48 #define HEADERBYTES 48
#define MAGIC1 "\253\315\000\060" #define MAGIC1 "\253\315\000\060"
#define MAGIC2 "\037\235" #define MAGIC2 "\037\235"
@ -13,16 +15,16 @@
#define C_FLAGOFF 40 #define C_FLAGOFF 40
typedef struct lzc_fileHdr { typedef struct lzc_fileHdr {
unsigned long magic1; uint32_t magic1;
unsigned long dataLength; uint32_t dataLength;
unsigned long dataCLength; uint32_t dataCLength;
unsigned long rsrcLength; uint32_t rsrcLength;
unsigned long rsrcCLength; uint32_t rsrcCLength;
unsigned long unknown1; uint32_t unknown1;
unsigned long mtime; uint32_t mtime;
unsigned long ctime; uint32_t ctime;
unsigned long filetype; uint32_t filetype;
unsigned long fileauth; uint32_t fileauth;
unsigned long flag1; uint32_t flag1;
unsigned long flag2; uint32_t flag2;
} lzc_fileHdr; } lzc_fileHdr;

View File

@ -382,37 +382,37 @@ lzh_wrfile (struct lzh_fileHdr *filehdr, int method)
} }
switch(method) { switch(method) {
case lz4: case lz4:
lzh_nocomp((unsigned long)128); lzh_nocomp((uint32_t)128);
break; break;
#ifdef UNTESTED #ifdef UNTESTED
case lz5: case lz5:
lzh_lzss1((unsigned long)128); lzh_lzss1((uint32_t)128);
break; break;
case lzs: case lzs:
lzh_lzss2((unsigned long)128); lzh_lzss2((uint32_t)128);
break; break;
#endif /* UNTESTED */ #endif /* UNTESTED */
case lh0: case lh0:
lzh_nocomp((unsigned long)128); lzh_nocomp((uint32_t)128);
break; break;
case lh1: case lh1:
lzh_lzah((unsigned long)128); lzh_lzah((uint32_t)128);
break; break;
#ifdef UNDEF #ifdef UNDEF
case lh2: case lh2:
lzh_lh2((unsigned long)128); lzh_lh2((uint32_t)128);
break; break;
case lh3: case lh3:
lzh_lh3((unsigned long)128); lzh_lh3((uint32_t)128);
break; break;
#endif /* UNDEF */ #endif /* UNDEF */
#ifdef UNTESTED #ifdef UNTESTED
case lh4: case lh4:
lzh_lzh12((unsigned long)128); lzh_lzh12((uint32_t)128);
break; break;
#endif /* UNTESTED */ #endif /* UNTESTED */
case lh5: case lh5:
lzh_lzh13((unsigned long)128); lzh_lzh13((uint32_t)128);
break; break;
default: default:
mname = lzh_methname(method); mname = lzh_methname(method);
@ -452,8 +452,8 @@ lzh_wrfile (struct lzh_fileHdr *filehdr, int method)
if(list) { if(list) {
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, (long)dataLength, (long)rsrcLength); text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength);
} }
if(info_only) { if(info_only) {
doit = 0; doit = 0;
@ -467,7 +467,7 @@ lzh_wrfile (struct lzh_fileHdr *filehdr, int method)
} }
if(doit) { if(doit) {
define_name(text); define_name(text);
start_info(info, (unsigned long)rsrcLength, (unsigned long)dataLength); start_info(info, (uint32_t)rsrcLength, (uint32_t)dataLength);
} }
switch(method) { switch(method) {
case lz4: case lz4:
@ -589,7 +589,7 @@ lzh_skip (struct lzh_fileHdr *filehdr)
/* -lz4- and -lh0: No compression */ /* -lz4- and -lh0: No compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
lzh_nocomp (unsigned long obytes) lzh_nocomp (uint32_t obytes)
{ {
copy(lzh_file, lzh_data, (int)obytes); copy(lzh_file, lzh_data, (int)obytes);
} }
@ -599,7 +599,7 @@ lzh_nocomp (unsigned long obytes)
/* -lz5-: LZSS compression, variant 1 */ /* -lz5-: LZSS compression, variant 1 */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
lzh_lzss1 (unsigned long obytes) lzh_lzss1 (uint32_t obytes)
{ {
int mask, ch, lzcnt, lzptr, ptr, count; int mask, ch, lzcnt, lzptr, ptr, count;
char *p = lzh_lzbuf; char *p = lzh_lzbuf;
@ -662,7 +662,7 @@ lzh_lzss1 (unsigned long obytes)
/* -lzs-: LZSS compression, variant 2 */ /* -lzs-: LZSS compression, variant 2 */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
lzh_lzss2 (unsigned long obytes) lzh_lzss2 (uint32_t obytes)
{ {
int ch, lzcnt, lzptr, ptr, i; int ch, lzcnt, lzptr, ptr, i;
@ -706,7 +706,7 @@ lzh_lzss2 (unsigned long obytes)
/* -lh1-: LZ compression plus adaptive Huffman encoding */ /* -lh1-: LZ compression plus adaptive Huffman encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
lzh_lzah (unsigned long obytes) lzh_lzah (uint32_t obytes)
{ {
lzh_current = lzh_data + 2; /* SKIPPING BLOCKSIZE! */ lzh_current = lzh_data + 2; /* SKIPPING BLOCKSIZE! */
tmp_out_ptr = out_ptr; tmp_out_ptr = out_ptr;
@ -727,7 +727,7 @@ lzh_getbyte (void)
/* -lh2-: LZ** compression */ /* -lh2-: LZ** compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
lzh_lh2 (unsigned long obytes) lzh_lh2 (uint32_t obytes)
{ {
} }
@ -735,7 +735,7 @@ lzh_lh2 (unsigned long obytes)
/* -lh3-: LZ** compression */ /* -lh3-: LZ** compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
lzh_lh3 (unsigned long obytes) lzh_lh3 (uint32_t obytes)
{ {
} }
#endif /* UNDEF */ #endif /* UNDEF */
@ -745,13 +745,13 @@ lzh_lh3 (unsigned long obytes)
/* -lh4-: LZ(12) compression plus Huffman encoding */ /* -lh4-: LZ(12) compression plus Huffman encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
lzh_lzh12 (unsigned long obytes) lzh_lzh12 (uint32_t obytes)
{ {
lzh_current = lzh_data; lzh_current = lzh_data;
tmp_out_ptr = out_ptr; tmp_out_ptr = out_ptr;
out_ptr = lzh_file; out_ptr = lzh_file;
/* Controlled by obytes only */ /* Controlled by obytes only */
de_lzh((long)(-1), (long)obytes, &lzh_current, 12); de_lzh((int32_t)(-1), (int32_t)obytes, &lzh_current, 12);
out_ptr = tmp_out_ptr; out_ptr = tmp_out_ptr;
} }
#endif /* UNTESTED */ #endif /* UNTESTED */
@ -760,12 +760,12 @@ lzh_lzh12 (unsigned long obytes)
/* -lh5-: LZ(13) compression plus Huffman encoding */ /* -lh5-: LZ(13) compression plus Huffman encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
lzh_lzh13 (unsigned long obytes) lzh_lzh13 (uint32_t obytes)
{ {
lzh_current = lzh_data; lzh_current = lzh_data;
tmp_out_ptr = out_ptr; tmp_out_ptr = out_ptr;
out_ptr = lzh_file; out_ptr = lzh_file;
/* Controlled by obytes only */ /* Controlled by obytes only */
de_lzh((long)(-1), (long)obytes, &lzh_current, 13); de_lzh((int32_t)(-1), (int32_t)obytes, &lzh_current, 13);
out_ptr = tmp_out_ptr; out_ptr = tmp_out_ptr;
} }

View File

@ -1,3 +1,5 @@
#include <stdint.h>
#define FILEHDRSIZE 22 #define FILEHDRSIZE 22
#define TOTALSIZE 64 #define TOTALSIZE 64
#define L_HSIZE 0 #define L_HSIZE 0
@ -34,9 +36,9 @@ typedef struct lzh_fileHdr { /* 58 bytes */
unsigned char hsize; unsigned char hsize;
unsigned char hcrc; unsigned char hcrc;
char method[5]; char method[5];
unsigned long psize; uint32_t psize;
unsigned long upsize; uint32_t upsize;
unsigned long lastmod; uint32_t lastmod;
unsigned short attribute; unsigned short attribute;
unsigned char nlength; unsigned char nlength;
char name[32]; char name[32];

View File

@ -74,7 +74,7 @@ macbinary (void)
if(verbose) { if(verbose) {
(void)fprintf(stderr, "This is a \"Zoom\" archive.\n"); (void)fprintf(stderr, "This is a \"Zoom\" archive.\n");
} }
zma(header, (unsigned long)0); zma(header, (uint32_t)0);
exit(0); exit(0);
} }
#endif /* ZMA */ #endif /* ZMA */
@ -167,7 +167,7 @@ macbinary (void)
#ifdef SCAN #ifdef SCAN
do_idf(header + I_NAMEOFF + 1, PACK_NAME); do_idf(header + I_NAMEOFF + 1, PACK_NAME);
#endif /* SCAN */ #endif /* SCAN */
jdw((unsigned long)in_data_size); jdw((uint32_t)in_data_size);
skip_file(ds_skip + in_rs); skip_file(ds_skip + in_rs);
continue; continue;
} }
@ -183,7 +183,7 @@ macbinary (void)
#ifdef SCAN #ifdef SCAN
do_idf(header + I_NAMEOFF + 1, PACK_NAME); do_idf(header + I_NAMEOFF + 1, PACK_NAME);
#endif /* SCAN */ #endif /* SCAN */
stf((unsigned long)in_data_size); stf((uint32_t)in_data_size);
skip_file(ds_skip + in_rs); skip_file(ds_skip + in_rs);
continue; continue;
} }
@ -389,7 +389,7 @@ macbinary (void)
#ifdef SCAN #ifdef SCAN
do_idf(header + I_NAMEOFF + 1, ARCH_NAME); do_idf(header + I_NAMEOFF + 1, ARCH_NAME);
#endif /* SCAN */ #endif /* SCAN */
zma((char *)NULL, (unsigned long)in_data_size); zma((char *)NULL, (uint32_t)in_data_size);
skip_file(ds_skip + in_rs); skip_file(ds_skip + in_rs);
continue; continue;
} }
@ -403,7 +403,7 @@ macbinary (void)
#ifdef SCAN #ifdef SCAN
do_idf(header + I_NAMEOFF + 1, ARCH_NAME); do_idf(header + I_NAMEOFF + 1, ARCH_NAME);
#endif /* SCAN */ #endif /* SCAN */
zma((char *)NULL, (unsigned long)in_data_size); zma((char *)NULL, (uint32_t)in_data_size);
skip_file(ds_skip + in_rs); skip_file(ds_skip + in_rs);
continue; continue;
} }
@ -499,8 +499,8 @@ macbinary (void)
} }
#endif /* DD */ #endif /* DD */
if(header[0] == 0 /* MORE CHECKS HERE! */) { if(header[0] == 0 /* MORE CHECKS HERE! */) {
mcb(header, (unsigned long)in_rsrc_size, mcb(header, (uint32_t)in_rsrc_size,
(unsigned long)in_data_size, in_ds + in_rs); (uint32_t)in_data_size, in_ds + in_rs);
continue; continue;
} else { } else {
(void)fprintf(stderr, "Unrecognized archive type.\n"); (void)fprintf(stderr, "Unrecognized archive type.\n");

View File

@ -157,7 +157,7 @@ int main(int argc, char **argv)
if(verbose) { if(verbose) {
fprintf(stderr, "This is a \"ShrinkToFit\" packed file.\n"); fprintf(stderr, "This is a \"ShrinkToFit\" packed file.\n");
} }
stf(~(unsigned long)1); stf(~(uint32_t)1);
break; break;
#endif /* STF */ #endif /* STF */
#ifdef PIT #ifdef PIT

View File

@ -8,7 +8,7 @@ static int mcb_read;
static void mcb_wrfile(); static void mcb_wrfile();
void mcb(char *hdr, unsigned long rsrcLength, unsigned long dataLength, int toread) void mcb(char *hdr, uint32_t rsrcLength, uint32_t dataLength, int toread)
{ {
register int i; register int i;
int n; int n;
@ -36,8 +36,8 @@ void mcb(char *hdr, unsigned long rsrcLength, unsigned long dataLength, int tore
transname(hdr + I_AUTHOFF, fauth, 4); transname(hdr + I_AUTHOFF, fauth, 4);
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, (long)dataLength, (long)rsrcLength); text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength);
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
} }
@ -77,7 +77,7 @@ void mcb(char *hdr, unsigned long rsrcLength, unsigned long dataLength, int tore
} }
static void static void
mcb_wrfile (unsigned long ibytes) mcb_wrfile (uint32_t ibytes)
{ {
int n; int n;

View File

@ -1 +1 @@
extern void mcb(char *hdr, unsigned long rsrcLength, unsigned long dataLength, int toread); extern void mcb(char *hdr, uint32_t rsrcLength, uint32_t dataLength, int toread);

View File

@ -24,7 +24,7 @@ pit (void)
struct pit_header filehdr; struct pit_header filehdr;
char pithdr[4]; char pithdr[4];
int decode, synced, ch; int decode, synced, ch;
unsigned long data_crc, crc; uint32_t data_crc, crc;
updcrc = binhex_updcrc; updcrc = binhex_updcrc;
crcinit = binhex_crcinit; crcinit = binhex_crcinit;
@ -207,8 +207,8 @@ pit_filehdr (struct pit_header *f, int compr)
transname(hdr + H_AUTHOFF, fauth, 4); transname(hdr + H_AUTHOFF, fauth, 4);
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, (long)f->dlen, (long)f->rlen); text, ftype, fauth, (int32_t)f->dlen, (int32_t)f->rlen);
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
} }
@ -236,7 +236,7 @@ pit_filehdr (struct pit_header *f, int compr)
} }
static void static void
pit_wrfile (unsigned long bytes, int type) pit_wrfile (uint32_t bytes, int type)
{ {
if(bytes == 0) { if(bytes == 0) {
return; return;
@ -254,7 +254,7 @@ pit_wrfile (unsigned long bytes, int type)
/* No compression */ /* No compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
pit_nocomp (unsigned long ibytes) pit_nocomp (uint32_t ibytes)
{ {
int n; int n;
@ -272,7 +272,7 @@ pit_nocomp (unsigned long ibytes)
/* Huffman compression */ /* Huffman compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
pit_huffman (unsigned long obytes) pit_huffman (uint32_t obytes)
{ {
de_huffman(obytes); de_huffman(obytes);
} }

View File

@ -20,10 +20,10 @@ struct pit_header { /* Packit file header (92 bytes) */
char auth[4]; /* file creator */ char auth[4]; /* file creator */
unsigned short flags; /* file flags (?) */ unsigned short flags; /* file flags (?) */
unsigned short lock; /* unknown */ unsigned short lock; /* unknown */
unsigned long dlen; /* number of bytes in data fork */ uint32_t dlen; /* number of bytes in data fork */
unsigned long rlen; /* number of bytes in resource fork */ uint32_t rlen; /* number of bytes in resource fork */
unsigned long ctim; /* file creation time */ uint32_t ctim; /* file creation time */
unsigned long mtim; /* file modified time */ uint32_t mtim; /* file modified time */
unsigned short hdrCRC; /* CRC */ unsigned short hdrCRC; /* CRC */
}; };

View File

@ -90,7 +90,7 @@ static short code6[258] = {
1, 1}; 1, 1};
static char sit_buffer[32768]; static char sit_buffer[32768];
static short sit_dict[16385]; static short sit_dict[16385];
static unsigned long sit_avail; static uint32_t sit_avail;
static int sit_bits_avail; static int sit_bits_avail;
void void
@ -205,9 +205,9 @@ static int sit_filehdr(struct sit_fileHdr *f, int skip)
transname(hdr + F_FTYPE, ftype, 4); transname(hdr + F_FTYPE, ftype, 4);
transname(hdr + F_CREATOR, fauth, 4); transname(hdr + F_CREATOR, fauth, 4);
(void)fprintf(stderr, (void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, text, ftype, fauth,
(long)f->dataLength, (long)f->rsrcLength); (int32_t)f->dataLength, (int32_t)f->rsrcLength);
} }
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
@ -438,7 +438,7 @@ sit_unstuff (struct sit_fileHdr filehdr)
} }
static void static void
sit_wrfile (unsigned long ibytes, unsigned long obytes, int type) sit_wrfile (uint32_t ibytes, uint32_t obytes, int type)
{ {
if(ibytes == 0) { if(ibytes == 0) {
if(verbose) { if(verbose) {
@ -534,7 +534,7 @@ sit_wrfile (unsigned long ibytes, unsigned long obytes, int type)
/* skip stuffit file */ /* skip stuffit file */
static void static void
sit_skip (unsigned long ibytes) sit_skip (uint32_t ibytes)
{ {
while(ibytes != 0) { while(ibytes != 0) {
if(getc(infp) == EOF) { if(getc(infp) == EOF) {
@ -552,7 +552,7 @@ sit_skip (unsigned long ibytes)
/* Method 0: No compression */ /* Method 0: No compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
sit_nocomp (unsigned long ibytes) sit_nocomp (uint32_t ibytes)
{ {
int n; int n;
@ -570,7 +570,7 @@ sit_nocomp (unsigned long ibytes)
/* Method 1: Run length encoding */ /* Method 1: Run length encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
sit_rle (unsigned long ibytes) sit_rle (uint32_t ibytes)
{ {
int ch, lastch = 0, n, i; int ch, lastch = 0, n, i;
@ -600,7 +600,7 @@ sit_rle (unsigned long ibytes)
/* Method 2: LZC compressed */ /* Method 2: LZC compressed */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
sit_lzc (unsigned long ibytes) sit_lzc (uint32_t ibytes)
{ {
de_compress(ibytes, 14); de_compress(ibytes, 14);
} }
@ -609,7 +609,7 @@ sit_lzc (unsigned long ibytes)
/* Method 3: Huffman compressed */ /* Method 3: Huffman compressed */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
sit_huffman (unsigned long obytes) sit_huffman (uint32_t obytes)
{ {
read_tree(); read_tree();
de_huffman(obytes); de_huffman(obytes);
@ -619,7 +619,7 @@ sit_huffman (unsigned long obytes)
/* Method 5: LZ compression plus adaptive Huffman encoding */ /* Method 5: LZ compression plus adaptive Huffman encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
sit_lzah (unsigned long obytes) sit_lzah (uint32_t obytes)
{ {
lzah_getbyte = sit_getbyte; lzah_getbyte = sit_getbyte;
de_lzah(obytes); de_lzah(obytes);
@ -635,11 +635,11 @@ sit_getbyte (void)
/* Method 6: Compression with a fixed Huffman encoding */ /* Method 6: Compression with a fixed Huffman encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
sit_fixhuf (unsigned long ibytes) sit_fixhuf (uint32_t ibytes)
{ {
int i, sum, codes, sym, num; int i, sum, codes, sym, num;
char byte_int[4], byte_short[2]; char byte_int[4], byte_short[2];
long size; int32_t size;
int sign; int sign;
char *tmp_ptr, *ptr, *end_ptr; char *tmp_ptr, *ptr, *end_ptr;
@ -659,7 +659,7 @@ sit_fixhuf (unsigned long ibytes)
exit(1); exit(1);
} }
ibytes -= 4; ibytes -= 4;
size = (long)get4(byte_int); size = (int32_t)get4(byte_int);
sign = 0; sign = 0;
if(size < 0) { if(size < 0) {
size = - size; size = - size;
@ -759,7 +759,7 @@ sit_dosplit (int ptr, int sum, int low, int upp)
/* Method 8: Compression with a MW encoding */ /* Method 8: Compression with a MW encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
sit_mw (unsigned long ibytes) sit_mw (uint32_t ibytes)
{ {
int ptr; int ptr;
int max, max1, bits; int max, max1, bits;
@ -819,7 +819,7 @@ sit_mw_out (int ptr)
} }
static int static int
sit_mw_in (int bits, unsigned long *ibytes) sit_mw_in (int bits, uint32_t *ibytes)
{ {
int res, res1; int res, res1;

View File

@ -1,6 +1,8 @@
#include "macunpack.h" #include "macunpack.h"
#ifdef SIT #ifdef SIT
#include <stdint.h>
#ifdef SIT_INTERNAL #ifdef SIT_INTERNAL
#define S_SIGNATURE 0 #define S_SIGNATURE 0
#define S_NUMFILES 4 #define S_NUMFILES 4
@ -26,12 +28,12 @@
#define F_HDRCRC 110 #define F_HDRCRC 110
#define FILEHDRSIZE 112 #define FILEHDRSIZE 112
typedef long OSType; typedef int32_t OSType;
typedef struct sitHdr { /* 22 bytes */ typedef struct sitHdr { /* 22 bytes */
OSType signature; /* = 'SIT!' -- for verification */ OSType signature; /* = 'SIT!' -- for verification */
unsigned short numFiles; /* number of files in archive */ unsigned short numFiles; /* number of files in archive */
unsigned long arcLength; /* length of entire archive incl. uint32_t arcLength; /* length of entire archive incl.
hdr. -- for verification */ hdr. -- for verification */
OSType signature2; /* = 'rLau' -- for verification */ OSType signature2; /* = 'rLau' -- for verification */
unsigned char version; /* version number */ unsigned char version; /* version number */
@ -47,12 +49,12 @@ typedef struct sit_fileHdr { /* 112 bytes */
unsigned short FndrFlags; /* copy of Finder flags. For our unsigned short FndrFlags; /* copy of Finder flags. For our
purposes, we can clear: purposes, we can clear:
busy,onDesk */ busy,onDesk */
unsigned long creationDate; uint32_t creationDate;
unsigned long modDate; /* !restored-compat w/backup prgms */ uint32_t modDate; /* !restored-compat w/backup prgms */
unsigned long rsrcLength; /* decompressed lengths */ uint32_t rsrcLength; /* decompressed lengths */
unsigned long dataLength; uint32_t dataLength;
unsigned long compRLength; /* compressed lengths */ uint32_t compRLength; /* compressed lengths */
unsigned long compDLength; uint32_t compDLength;
unsigned short rsrcCRC; /* crc of rsrc fork */ unsigned short rsrcCRC; /* crc of rsrc fork */
unsigned short dataCRC; /* crc of data fork */ unsigned short dataCRC; /* crc of data fork */
char reserved[6]; char reserved[6];

View File

@ -25,12 +25,12 @@ static void stf_wrfork();
static void stf_construct(); static void stf_construct();
void void
stf (unsigned long ibytes) stf (uint32_t ibytes)
{ {
char magic[3], fauth[5], ftype[5]; char magic[3], fauth[5], ftype[5];
int filel, i; int filel, i;
unsigned int rsrcLength, dataLength; unsigned int rsrcLength, dataLength;
unsigned long curtime; uint32_t curtime;
set_huffman(HUFF_LE); set_huffman(HUFF_LE);
for(i = 0; i < 3; i++) { for(i = 0; i < 3; i++) {
@ -58,19 +58,19 @@ stf (unsigned long ibytes)
for(i = 0; i < 4; i++) { for(i = 0; i < 4; i++) {
info[I_AUTHOFF + i] = getb(infp); info[I_AUTHOFF + i] = getb(infp);
} }
curtime = (unsigned long)time((time_t *)0) + TIMEDIFF; curtime = (uint32_t)time((time_t *)0) + TIMEDIFF;
put4(info + I_CTIMOFF, curtime); put4(info + I_CTIMOFF, curtime);
put4(info + I_MTIMOFF, curtime); put4(info + I_MTIMOFF, curtime);
rsrcLength = 0; rsrcLength = 0;
for(i = 0; i < 4; i++) { for(i = 0; i < 4; i++) {
rsrcLength = (rsrcLength << 8) + getb(infp); rsrcLength = (rsrcLength << 8) + getb(infp);
} }
put4(info + I_RLENOFF, (unsigned long)rsrcLength); put4(info + I_RLENOFF, (uint32_t)rsrcLength);
dataLength = 0; dataLength = 0;
for(i = 0; i < 4; i++) { for(i = 0; i < 4; i++) {
dataLength = (dataLength << 8) + getb(infp); dataLength = (dataLength << 8) + getb(infp);
} }
put4(info + I_DLENOFF, (unsigned long)dataLength); put4(info + I_DLENOFF, (uint32_t)dataLength);
ibytes -= filel + 20; ibytes -= filel + 20;
write_it = 1; write_it = 1;
if(list) { if(list) {
@ -79,8 +79,8 @@ stf (unsigned long ibytes)
transname(info + I_AUTHOFF, fauth, 4); transname(info + I_AUTHOFF, fauth, 4);
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, (long)dataLength, (long)rsrcLength); text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength);
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
} }
@ -90,13 +90,13 @@ stf (unsigned long ibytes)
(void)fputc('\n', stderr); (void)fputc('\n', stderr);
} }
} }
stf_wrfile((unsigned long)rsrcLength, (unsigned long)dataLength, ibytes); stf_wrfile((uint32_t)rsrcLength, (uint32_t)dataLength, ibytes);
} }
static void static void
stf_wrfile (unsigned long rsrcLength, unsigned long dataLength, unsigned long ibytes) stf_wrfile (uint32_t rsrcLength, uint32_t dataLength, uint32_t ibytes)
{ {
unsigned long num = 0; uint32_t num = 0;
if(write_it) { if(write_it) {
define_name(text); define_name(text);
@ -118,7 +118,7 @@ stf_wrfile (unsigned long rsrcLength, unsigned long dataLength, unsigned long ib
} }
static void static void
stf_wrfork (unsigned long *num, unsigned long towrite, int offs) stf_wrfork (uint32_t *num, uint32_t towrite, int offs)
{ {
int c, k, max, i, i1; int c, k, max, i, i1;
char *tmp_out_ptr; char *tmp_out_ptr;
@ -157,7 +157,7 @@ stf_wrfork (unsigned long *num, unsigned long towrite, int offs)
stf_construct(32); stf_construct(32);
tmp_out_ptr = out_ptr; tmp_out_ptr = out_ptr;
out_ptr = length; out_ptr = length;
de_huffman((unsigned long)256); de_huffman((uint32_t)256);
out_ptr = tmp_out_ptr; out_ptr = tmp_out_ptr;
for(i = 1; i < 257; i++) { for(i = 1; i < 257; i++) {
table[i].num = 0x40000000 >> length[i - 1]; table[i].num = 0x40000000 >> length[i - 1];
@ -181,7 +181,7 @@ stf_wrfork (unsigned long *num, unsigned long towrite, int offs)
if(i > towrite - *num) { if(i > towrite - *num) {
i = towrite - *num; i = towrite - *num;
} }
de_huffman((unsigned long)i); de_huffman((uint32_t)i);
*num += i; *num += i;
} }
} }

View File

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

View File

@ -17,8 +17,8 @@ extern void de_lzh();
static char *zma_archive; static char *zma_archive;
static char *zma_current; static char *zma_current;
static char *zma_filestart; static char *zma_filestart;
static unsigned long zma_length; static uint32_t zma_length;
static long zma_archlength; static int32_t zma_archlength;
static int zma_filehdr(); static int zma_filehdr();
static void zma_folder(); static void zma_folder();
@ -28,7 +28,7 @@ static void zma_nocomp();
static void zma_lzh(); static void zma_lzh();
void void
zma (char *start, unsigned long length) zma (char *start, uint32_t length)
{ {
struct zma_fileHdr filehdr; struct zma_fileHdr filehdr;
int i, toread; int i, toread;
@ -175,9 +175,9 @@ zma_filehdr (struct zma_fileHdr *f, int skip)
transname(zma_current + Z_TYPE, ftype, 4); transname(zma_current + Z_TYPE, ftype, 4);
transname(zma_current + Z_AUTH, fauth, 4); transname(zma_current + Z_AUTH, fauth, 4);
(void)fprintf(stderr, (void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, text, ftype, fauth,
(long)f->dataLength, (long)f->rsrcLength); (int32_t)f->dataLength, (int32_t)f->rsrcLength);
} }
switch(f->what) { switch(f->what) {
case z_plug: case z_plug:
@ -322,7 +322,7 @@ zma_mooz (struct zma_fileHdr filehdr)
} }
static void static void
zma_wrfile (unsigned long ibytes, unsigned long obytes, int type) zma_wrfile (uint32_t ibytes, uint32_t obytes, int type)
{ {
if(ibytes == 0) { if(ibytes == 0) {
if(verbose) { if(verbose) {
@ -361,7 +361,7 @@ zma_wrfile (unsigned long ibytes, unsigned long obytes, int type)
/* No compression */ /* No compression */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
zma_nocomp (unsigned long ibytes) zma_nocomp (uint32_t ibytes)
{ {
int n = ibytes; int n = ibytes;
char *ptr = out_buffer; char *ptr = out_buffer;
@ -375,10 +375,10 @@ zma_nocomp (unsigned long ibytes)
/* LZ compression plus Huffman encoding */ /* LZ compression plus Huffman encoding */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
zma_lzh (unsigned long ibytes) zma_lzh (uint32_t ibytes)
{ {
/* Controlled by ibutes only */ /* Controlled by ibutes only */
de_lzh((long)ibytes, (long)(-1), &zma_filestart, 13); de_lzh((int32_t)ibytes, (int32_t)(-1), &zma_filestart, 13);
} }
#else /* ZMA */ #else /* ZMA */
int zma; /* keep lint and some compilers happy */ int zma; /* keep lint and some compilers happy */

View File

@ -1,5 +1,7 @@
#include "zmahdr.h" #include "zmahdr.h"
#include <stdint.h>
#define Z_HDRSIZE 78 #define Z_HDRSIZE 78
#define Z_WHAT 0 /* What kind of data? */ #define Z_WHAT 0 /* What kind of data? */
@ -25,15 +27,15 @@ typedef struct zma_fileHdr { /* 78 bytes */
char what; /* What kind? Negative if deleted */ char what; /* What kind? Negative if deleted */
unsigned char hlen ; /* Header length */ unsigned char hlen ; /* Header length */
unsigned short boolFlags; /* Boolean flags */ unsigned short boolFlags; /* Boolean flags */
unsigned long next; /* Next entry */ uint32_t next; /* Next entry */
unsigned long compRLength; /* The compressed lengths. */ uint32_t compRLength; /* The compressed lengths. */
unsigned long compDLength; /* For dirs, the second is # entries */ uint32_t compDLength; /* For dirs, the second is # entries */
unsigned long rsrcLength; /* The uncompressed lengths. */ uint32_t rsrcLength; /* The uncompressed lengths. */
unsigned long dataLength; uint32_t dataLength;
unsigned long fType; /* file type */ uint32_t fType; /* file type */
unsigned long fCreator; /* er... */ uint32_t fCreator; /* er... */
unsigned long modDate; /* !restored-compat w/backup prgms */ uint32_t modDate; /* !restored-compat w/backup prgms */
unsigned long comment; /* Comment offset */ uint32_t comment; /* Comment offset */
unsigned short FndrFlags; /* copy of Finder flags. For our unsigned short FndrFlags; /* copy of Finder flags. For our
purposes, we can clear: purposes, we can clear:
busy,onDesk */ busy,onDesk */
@ -41,7 +43,7 @@ typedef struct zma_fileHdr { /* 78 bytes */
unsigned short rsrcCRC; /* Resource fork crc */ unsigned short rsrcCRC; /* Resource fork crc */
unsigned char fName[32]; /* a STR32 */ unsigned char fName[32]; /* a STR32 */
/* The following are overlayed in the original structure */ /* The following are overlayed in the original structure */
unsigned long conts; /* Pointer to directory contents */ uint32_t conts; /* Pointer to directory contents */
} zma_fileHdr; } zma_fileHdr;
/* zma types (see what) */ /* zma types (see what) */

View File

@ -49,8 +49,8 @@ macbinary (void)
} }
#endif /* SCAN */ #endif /* SCAN */
if(header[0] == 0 /* MORE CHECKS HERE! */) { if(header[0] == 0 /* MORE CHECKS HERE! */) {
mcb(header, (unsigned long)in_rsrc_size, mcb(header, (uint32_t)in_rsrc_size,
(unsigned long)in_data_size, in_ds + in_rs); (uint32_t)in_data_size, in_ds + in_rs);
continue; continue;
} else { } else {
(void)fprintf(stderr, "Unrecognized header.\n"); (void)fprintf(stderr, "Unrecognized header.\n");

View File

@ -101,8 +101,8 @@ int main(int argc, char **argv)
if(i == ISFILE) { if(i == ISFILE) {
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, (long)data_size, (long)rsrc_size); text, ftype, fauth, (int32_t)data_size, (int32_t)rsrc_size);
} else if(i == ISDIR) { } else if(i == ISDIR) {
do_indent(indent); do_indent(indent);
dir_ptr += 64; dir_ptr += 64;

View File

@ -9,7 +9,7 @@ static int mcb_read;
static void mcb_wrfile(); static void mcb_wrfile();
void void
mcb (char *hdr, unsigned long rsrcLength, unsigned long dataLength, int toread) mcb (char *hdr, uint32_t rsrcLength, uint32_t dataLength, int toread)
{ {
register int i; register int i;
int n; int n;
@ -37,8 +37,8 @@ mcb (char *hdr, unsigned long rsrcLength, unsigned long dataLength, int toread)
transname(hdr + I_AUTHOFF, fauth, 4); transname(hdr + I_AUTHOFF, fauth, 4);
do_indent(indent); do_indent(indent);
(void)fprintf(stderr, (void)fprintf(stderr,
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d",
text, ftype, fauth, (long)dataLength, (long)rsrcLength); text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength);
if(info_only) { if(info_only) {
write_it = 0; write_it = 0;
} }
@ -65,7 +65,7 @@ mcb (char *hdr, unsigned long rsrcLength, unsigned long dataLength, int toread)
} }
static void static void
mcb_wrfile (unsigned long ibytes) mcb_wrfile (uint32_t ibytes)
{ {
int n; int n;

View File

@ -10,10 +10,10 @@
static int mlength[] = {0, 31, 61, 92, 122, 153, 184, 214, 245, 275, 306, 337}; static int mlength[] = {0, 31, 61, 92, 122, 153, 184, 214, 245, 275, 306, 337};
unsigned long get4(char *bp) uint32_t get4(char *bp)
{ {
register int i; register int i;
long value = 0; int32_t value = 0;
for(i = 0; i < 4; i++) { for(i = 0; i < 4; i++) {
value <<= 8; value <<= 8;
@ -24,10 +24,10 @@ unsigned long get4(char *bp)
} }
/* For if integers are stored wrong-endian. */ /* For if integers are stored wrong-endian. */
unsigned long get4i(char *bp) uint32_t get4i(char *bp)
{ {
register int i; register int i;
long value = 0; int32_t value = 0;
bp += 3; bp += 3;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
@ -38,7 +38,7 @@ unsigned long get4i(char *bp)
return value; return value;
} }
unsigned long get2(char *bp) uint32_t get2(char *bp)
{ {
register int i; register int i;
int value = 0; int value = 0;
@ -52,10 +52,10 @@ unsigned long get2(char *bp)
} }
/* For if integers are stored wrong-endian. */ /* For if integers are stored wrong-endian. */
unsigned long get2i(char *bp) uint32_t get2i(char *bp)
{ {
register int i; register int i;
long value = 0; int32_t value = 0;
bp += 1; bp += 1;
for(i = 0; i < 2; i++) { for(i = 0; i < 2; i++) {
@ -109,7 +109,7 @@ do_query (void)
} }
void void
put4 (char *dest, unsigned long value) put4 (char *dest, uint32_t value)
{ {
*dest++ = (value >> 24) & BYTEMASK; *dest++ = (value >> 24) & BYTEMASK;
*dest++ = (value >> 16) & BYTEMASK; *dest++ = (value >> 16) & BYTEMASK;
@ -118,7 +118,7 @@ put4 (char *dest, unsigned long value)
} }
void void
put2 (char *dest, unsigned long value) put2 (char *dest, uint32_t value)
{ {
*dest++ = (value >> 8) & BYTEMASK; *dest++ = (value >> 8) & BYTEMASK;
*dest++ = value & BYTEMASK; *dest++ = value & BYTEMASK;
@ -134,8 +134,8 @@ do_indent (int indent)
} }
} }
real_time set_time(year, month, day, hours, minutes, seconds) real_time
int year, month, day, hours, minutes, seconds; set_time (int year, int month, int day, int hours, int minutes, int seconds)
{ {
real_time toset; real_time toset;
@ -148,10 +148,10 @@ int year, month, day, hours, minutes, seconds;
return toset; return toset;
} }
unsigned long tomactime(time) uint32_t
real_time time; tomactime (real_time time)
{ {
long accum; int32_t accum;
int year; int year;
accum = time.month - 3; accum = time.month - 3;
@ -166,10 +166,10 @@ real_time time;
return (unsigned)accum; return (unsigned)accum;
} }
real_time frommactime(accum) real_time
unsigned long accum; frommactime (uint32_t accum)
{ {
long tmp1, tmp2; int32_t tmp1, tmp2;
real_time time; real_time time;
time.seconds = tmp1 = accum % 60; time.seconds = tmp1 = accum % 60;
@ -178,7 +178,7 @@ real_time time;
accum /= 60; accum /= 60;
time.hours = tmp1 = accum % 24; time.hours = tmp1 = accum % 24;
accum /= 24; accum /= 24;
tmp1 = (long)accum - 60; tmp1 = (int32_t)accum - 60;
tmp2 = tmp1 % 1461; tmp2 = tmp1 % 1461;
if(tmp2 < 0) { if(tmp2 < 0) {
tmp2 += 1461; tmp2 += 1461;

View File

@ -1,3 +1,5 @@
#include <stdint.h>
typedef struct real_time { typedef struct real_time {
int year; int year;
int month; int month;
@ -7,17 +9,17 @@ typedef struct real_time {
int seconds; int seconds;
} real_time; } real_time;
extern unsigned long get4(); extern uint32_t get4(char *bp);
extern unsigned long get4i(); extern uint32_t get4i(char *bp);
extern unsigned long get2(); extern uint32_t get2(char *bp);
extern unsigned long get2i(); extern uint32_t get2i(char *bp);
extern unsigned char getb(); extern unsigned char getb(FILE *fp);
extern void copy(); extern void copy(char *d, char *s, int n);
extern int do_query(); extern int do_query(void);
extern void put4(); extern void put4(char *dest, uint32_t value);
extern void put2(); extern void put2(char *dest, uint32_t value);
extern void do_indent(); extern void do_indent(int indent);
extern real_time set_time(); extern real_time set_time(int year, int month, int day, int hours, int minutes, int seconds);
extern unsigned long tomactime(); extern uint32_t tomactime(real_time time);
extern real_time frommactime(); extern real_time frommactime(uint32_t accum);