diff --git a/binhex/binhex.c b/binhex/binhex.c index 2577a28..4b8c0a0 100644 --- a/binhex/binhex.c +++ b/binhex/binhex.c @@ -103,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; diff --git a/comm/frommac.c b/comm/frommac.c index a0d0799..52f4cbe 100644 --- a/comm/frommac.c +++ b/comm/frommac.c @@ -151,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"); diff --git a/comm/tomac.c b/comm/tomac.c index afb39bb..0c74aad 100644 --- a/comm/tomac.c +++ b/comm/tomac.c @@ -154,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; diff --git a/comm/xm_from.c b/comm/xm_from.c index 988e4f0..f22f424 100644 --- a/comm/xm_from.c +++ b/comm/xm_from.c @@ -19,7 +19,7 @@ char info[INFOBYTES]; void xm_from (void) { -unsigned long data_size, rsrc_size; +uint32_t data_size, rsrc_size; char text[64]; if(receive_sync() == ACK) { diff --git a/crc/makecrc.c b/crc/makecrc.c index 941336e..eaefd2b 100644 --- a/crc/makecrc.c +++ b/crc/makecrc.c @@ -31,6 +31,7 @@ /* ZIP used by COMPACTOR */ #include +#include #include #include @@ -53,7 +54,7 @@ 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]; @@ -99,7 +100,7 @@ initcrctab (char *name, int poly, int init, int swapped, int bits) for(vv = b<<24, i = 8; --i >= 0;) 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) { (void)fprintf(fd, "\n"); if(b != 255) (void)fprintf(fd, " "); diff --git a/fileio/rdfile.c b/fileio/rdfile.c index 678e8d3..a2db0a2 100644 --- a/fileio/rdfile.c +++ b/fileio/rdfile.c @@ -358,8 +358,8 @@ read_file (void) } (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; @@ -381,7 +381,7 @@ read_file (void) } 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); @@ -412,7 +412,7 @@ read_file (void) } 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); @@ -555,7 +555,7 @@ read_file (void) (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) { @@ -578,7 +578,7 @@ read_file (void) } 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) { @@ -626,7 +626,7 @@ read_file (void) (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) { @@ -816,15 +816,15 @@ read_aufs_info (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 */ } @@ -864,7 +864,7 @@ read_appledouble_info (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 */ diff --git a/fileio/wrfile.c b/fileio/wrfile.c index d60c0b7..77f6a8a 100644 --- a/fileio/wrfile.c +++ b/fileio/wrfile.c @@ -101,7 +101,7 @@ 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 (char *text) @@ -120,7 +120,7 @@ define_name (char *text) } void -start_info (char *info, unsigned long rsize, unsigned long dsize) +start_info (char *info, uint32_t rsize, uint32_t dsize) { int rs, ds; @@ -338,7 +338,7 @@ do_idf (char *name, int kind) n = strlen(name); (void)bzero(buffer, INFOBYTES); buffer[I_NAMEOFF + 1] = kind; - put4(buffer + I_DLENOFF, (unsigned long)n); + put4(buffer + I_DLENOFF, (uint32_t)n); (void)fwrite(buffer, 1, INFOBYTES, stdout); if(n != 0) { (void)fwrite(name, 1, n, stdout); @@ -583,7 +583,7 @@ FILE *fp; theinfo.fi_datevalid = FI_CDATE | FI_MDATE; put4(theinfo.fi_ctime, get4(buffer + I_CTIMOFF) - TIMEDIFF); put4(theinfo.fi_mtime, get4(buffer + I_MTIMOFF) - TIMEDIFF); - put4(theinfo.fi_utime, (unsigned long)time((time_t *)0)); + put4(theinfo.fi_utime, (uint32_t)time((time_t *)0)); #endif /* AUFSPLUS */ bcopy(buffer + I_TYPEOFF, theinfo.fi_fndr, 4); bcopy(buffer + I_AUTHOFF, theinfo.fi_fndr + 4, 4); @@ -634,21 +634,21 @@ FILE *fp; int n; bzero((char *) &theinfo, sizeof theinfo); - put4(theinfo.fi_magic, (unsigned long)FI_MAGIC); - put2(theinfo.fi_version, (unsigned long)FI_VERSION); - put4(theinfo.fi_fill5, (unsigned long)FI_FILL5); - put4(theinfo.fi_fill6, (unsigned long)FI_FILL6); - put4(theinfo.fi_hlen, (unsigned long)FI_HLEN); - put4(theinfo.fi_fill7, (unsigned long)FI_FILL7); - put4(theinfo.fi_namptr, (unsigned long)FI_NAMPTR); - put4(theinfo.fi_fill9, (unsigned long)FI_FILL9); - put4(theinfo.fi_commptr, (unsigned long)FI_COMMPTR); - put4(theinfo.fi_fill12, (unsigned long)FI_FILL12); - put4(theinfo.fi_timeptr, (unsigned long)FI_TIMEPTR); - put4(theinfo.fi_timesize, (unsigned long)FI_TIMESIZE); - put4(theinfo.fi_fill15, (unsigned long)FI_FILL15); - put4(theinfo.fi_infoptr, (unsigned long)FI_INFOPTR); - put4(theinfo.fi_infosize, (unsigned long)FI_INFOSIZE); + put4(theinfo.fi_magic, (uint32_t)FI_MAGIC); + put2(theinfo.fi_version, (uint32_t)FI_VERSION); + put4(theinfo.fi_fill5, (uint32_t)FI_FILL5); + put4(theinfo.fi_fill6, (uint32_t)FI_FILL6); + put4(theinfo.fi_hlen, (uint32_t)FI_HLEN); + put4(theinfo.fi_fill7, (uint32_t)FI_FILL7); + put4(theinfo.fi_namptr, (uint32_t)FI_NAMPTR); + put4(theinfo.fi_fill9, (uint32_t)FI_FILL9); + put4(theinfo.fi_commptr, (uint32_t)FI_COMMPTR); + put4(theinfo.fi_fill12, (uint32_t)FI_FILL12); + put4(theinfo.fi_timeptr, (uint32_t)FI_TIMEPTR); + put4(theinfo.fi_timesize, (uint32_t)FI_TIMESIZE); + put4(theinfo.fi_fill15, (uint32_t)FI_FILL15); + put4(theinfo.fi_infoptr, (uint32_t)FI_INFOPTR); + put4(theinfo.fi_infosize, (uint32_t)FI_INFOSIZE); bcopy(buffer + I_TYPEOFF, theinfo.fi_type, 4); bcopy(buffer + I_AUTHOFF, theinfo.fi_auth, 4); @@ -659,13 +659,13 @@ FILE *fp; if((n = buffer[I_NAMEOFF] & 0xff) > F_NAMELEN) { n = F_NAMELEN; } - put4(theinfo.fi_namlen, (unsigned long)n); + put4(theinfo.fi_namlen, (uint32_t)n); (void)strncpy((char *)theinfo.fi_name, buffer + I_NAMEOFF + 1,n); /* theinfo.fi_macfilename[n] = '\0'; */ (void)strcpy((char *)theinfo.fi_comment, "Converted by Unix utility to AppleDouble format"); - put4(theinfo.fi_commsize, (unsigned long)strlen(theinfo.fi_comment)); - put4(theinfo.fi_rsrc, (unsigned long)rsz); + put4(theinfo.fi_commsize, (uint32_t)strlen(theinfo.fi_comment)); + put4(theinfo.fi_rsrc, (uint32_t)rsz); /* Still TODO */ /* char fi_ctime[4]; /* Creation time (Unix time) */ /* char fi_mtime[4]; /* Modification time (Unix time) */ diff --git a/fileio/wrfile.h b/fileio/wrfile.h index d8e4864..ac05b32 100644 --- a/fileio/wrfile.h +++ b/fileio/wrfile.h @@ -1,7 +1,9 @@ +#include + extern char *out_buffer, *out_ptr; 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_data(void); extern void end_file(void); diff --git a/hexbin/buffer.c b/hexbin/buffer.c index ed62110..79c711e 100644 --- a/hexbin/buffer.c +++ b/hexbin/buffer.c @@ -60,7 +60,7 @@ end_put (void) if(info_only) { return; } - start_info(info, (unsigned long)rsrc_size, (unsigned long)data_size); + start_info(info, (uint32_t)rsrc_size, (uint32_t)data_size); if(data_size != 0) { start_data(); copy(out_ptr, data_fork, data_size); diff --git a/hexbin/crc.c b/hexbin/crc.c index 968bcef..0fb2c0d 100644 --- a/hexbin/crc.c +++ b/hexbin/crc.c @@ -27,13 +27,13 @@ comp_q_crc_n (register unsigned char *s, register unsigned char *e) #endif /* HQX */ void -verify_crc (unsigned long calc_crc, unsigned long file_crc) +verify_crc (uint32_t calc_crc, uint32_t file_crc) { calc_crc &= WORDMASK; file_crc &= WORDMASK; if(calc_crc != file_crc) { - (void)fprintf(stderr, "CRC mismatch: got 0x%04lx, need 0x%04lx\n", + (void)fprintf(stderr, "CRC mismatch: got 0x%04x, need 0x%04x\n", file_crc, calc_crc); #ifdef SCAN do_error("hexbin: CRC error"); diff --git a/hexbin/crc.h b/hexbin/crc.h index f3e3fd4..e5df75d 100644 --- a/hexbin/crc.h +++ b/hexbin/crc.h @@ -6,5 +6,5 @@ extern uint32_t crc; extern void comp_q_crc (register unsigned int c); extern void comp_q_crc_n (register unsigned char *s, register unsigned char *e); -extern void verify_crc (unsigned long calc_crc, unsigned long file_crc); +extern void verify_crc (uint32_t calc_crc, uint32_t file_crc); diff --git a/hexbin/dl.c b/hexbin/dl.c index 87be82d..f0e0495 100644 --- a/hexbin/dl.c +++ b/hexbin/dl.c @@ -11,9 +11,9 @@ #include -static long dl_fork(); -static int nchar(); -static int nextc(); +static int32_t dl_fork(void); +static int nchar(void); +static int nextc(void); static char *icp = &line[0]; @@ -67,19 +67,19 @@ dl (char *macname, char *filename) (void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n); (void)strncpy(info + I_TYPEOFF, mh.m_type, 4); (void)strncpy(info + I_AUTHOFF, mh.m_author, 4); - put4(info + I_DLENOFF, (unsigned long)mh.m_datalen); - put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen); - put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime); - put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime); + put4(info + I_DLENOFF, (uint32_t)mh.m_datalen); + put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen); + put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime); + put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime); print_header2(0); end_put(); } -static long +static int32_t dl_fork (void) { - register unsigned long i, v, c; - register unsigned long n, bytes; + register uint32_t i, v, c; + register uint32_t n, bytes; n = 0; bytes = 0; diff --git a/hexbin/globals.h b/hexbin/globals.h index 5f757de..88c5110 100644 --- a/hexbin/globals.h +++ b/hexbin/globals.h @@ -1,4 +1,5 @@ #include +#include #include #ifdef BSD extern char *rindex(); @@ -18,10 +19,10 @@ typedef struct macheader { char m_type[4]; char m_author[4]; short m_flags; - long m_datalen; - long m_rsrclen; - long m_createtime; - long m_modifytime; + int32_t m_datalen; + int32_t m_rsrclen; + int32_t m_createtime; + int32_t m_modifytime; } macheader; extern struct macheader mh; diff --git a/hexbin/hecx.c b/hexbin/hecx.c index 98bd6da..7c7314f 100644 --- a/hexbin/hecx.c +++ b/hexbin/hecx.c @@ -13,7 +13,7 @@ #include static void do_o_forks(); -static long make_file(); +static int32_t make_file(); static void comp_c_crc(); static void comp_e_crc(); 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_TYPEOFF, mh.m_type, 4); (void)strncpy(info + I_AUTHOFF, mh.m_author, 4); - put2(info + I_FLAGOFF, (unsigned long)mh.m_flags); - put4(info + I_DLENOFF, (unsigned long)mh.m_datalen); - put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen); - put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime); - put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime); + put2(info + I_FLAGOFF, (uint32_t)mh.m_flags); + put4(info + I_DLENOFF, (uint32_t)mh.m_datalen); + put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen); + put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime); + put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime); print_header2(0); end_put(); } @@ -99,7 +99,7 @@ static void do_o_forks (void) { int forks = 0, found_crc = 0; - unsigned long calc_crc, file_crc; + uint32_t calc_crc, file_crc; crc = 0; /* calculate a crc for both forks */ @@ -128,13 +128,13 @@ do_o_forks (void) if(compressed && strncmp(line, "***CRC:", 7) == 0) { found_crc++; calc_crc = crc; - (void)sscanf(&line[7], "%lx", &file_crc); + (void)sscanf(&line[7], "%x", &file_crc); break; } if(!compressed && strncmp(line, "***CHECKSUM:", 12) == 0) { found_crc++; calc_crc = crc & BYTEMASK; - (void)sscanf(&line[12], "%lx", &file_crc); + (void)sscanf(&line[12], "%x", &file_crc); file_crc &= BYTEMASK; break; } @@ -151,10 +151,10 @@ do_o_forks (void) } } -static long +static int32_t make_file (int compressed) { - register long nbytes = 0L; + register int32_t nbytes = 0L; while(readline()) { if(line[0] == 0) { diff --git a/hexbin/hexbin.c b/hexbin/hexbin.c index e4561f2..03ac8f0 100644 --- a/hexbin/hexbin.c +++ b/hexbin/hexbin.c @@ -159,7 +159,7 @@ do_files ( char namebuf[256]; char **ep; struct stat stbuf; - long curtime; + int32_t curtime; int qformat; int again; @@ -187,7 +187,7 @@ do_files ( again = 0; nexttry: if(ifp == stdin) { - curtime = (long)time((time_t *)0) + TIMEDIFF; + curtime = (int32_t)time((time_t *)0) + TIMEDIFF; mh.m_createtime = curtime; mh.m_modifytime = curtime; } else { diff --git a/hexbin/hqx.c b/hexbin/hqx.c index b65a350..adc5255 100644 --- a/hexbin/hqx.c +++ b/hexbin/hqx.c @@ -11,12 +11,12 @@ #include "../util/util.h" #include "printhdr.h" -static void get_header(); -static void oflush(); -static int getq(); -static long get2q(); -static long get4q(); -static void getqbuf(); +static void get_header(void); +static void oflush(void); +static int getq(void); +static int32_t get2q(void); +static int32_t get4q(void); +static void getqbuf(char *buf, int n); static char *g_macname; @@ -98,10 +98,10 @@ static unsigned char *oq; static int ostate = S_HEADER; -static unsigned long calc_crc; -static unsigned long file_crc; +static uint32_t calc_crc; +static uint32_t file_crc; -static long todo; +static int32_t todo; #define output(c) { *op++ = (c); if(op >= &obuf[BUFSIZ]) oflush(); } @@ -236,7 +236,7 @@ static void get_header (void) { int n; - unsigned long calc_crc, file_crc; + uint32_t calc_crc, file_crc; crc = INITCRC; /* compute a crc for the header */ @@ -277,11 +277,11 @@ get_header (void) (void)strncpy(info + I_NAMEOFF + 1, mh.m_name, n); (void)strncpy(info + I_TYPEOFF, mh.m_type, 4); (void)strncpy(info + I_AUTHOFF, mh.m_author, 4); - put2(info + I_FLAGOFF, (unsigned long)mh.m_flags); - put4(info + I_DLENOFF, (unsigned long)mh.m_datalen); - put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen); - put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime); - put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime); + put2(info + I_FLAGOFF, (uint32_t)mh.m_flags); + put4(info + I_DLENOFF, (uint32_t)mh.m_datalen); + put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen); + put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime); + put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime); } static void @@ -364,7 +364,7 @@ getq (void) } /* get2q(); q format -- read 2 bytes from input, return short */ -static long +static int32_t get2q (void) { short high = getq() << 8; @@ -372,11 +372,11 @@ get2q (void) } /* get4q(); q format -- read 4 bytes from input, return long */ -static long +static int32_t get4q (void) { int i; - long value = 0; + int32_t value = 0; for(i = 0; i < 4; i++) { value = (value<<8) | getq(); diff --git a/hexbin/mu.c b/hexbin/mu.c index cd23639..4633379 100644 --- a/hexbin/mu.c +++ b/hexbin/mu.c @@ -136,10 +136,10 @@ mu (char *macname) (void)strncpy(mh.m_type, info + I_TYPEOFF, 4); (void)strncpy(mh.m_author, info + I_AUTHOFF, 4); print_header1(0, 0); - put4(info + I_DLENOFF, (unsigned long)mh.m_datalen); - put4(info + I_RLENOFF, (unsigned long)mh.m_rsrclen); - put4(info + I_CTIMOFF, (unsigned long)mh.m_createtime); - put4(info + I_MTIMOFF, (unsigned long)mh.m_modifytime); + put4(info + I_DLENOFF, (uint32_t)mh.m_datalen); + put4(info + I_RLENOFF, (uint32_t)mh.m_rsrclen); + put4(info + I_CTIMOFF, (uint32_t)mh.m_createtime); + put4(info + I_MTIMOFF, (uint32_t)mh.m_modifytime); print_header2(0); end_put(); } @@ -147,7 +147,7 @@ mu (char *macname) static void do_mu_fork (void) { - long newbytes; + int32_t newbytes; while(readline()) { if(line[0] == 0) { diff --git a/hexbin/printhdr.c b/hexbin/printhdr.c index 0141b79..d9ded7b 100644 --- a/hexbin/printhdr.c +++ b/hexbin/printhdr.c @@ -37,7 +37,7 @@ void print_header2(int skip) if (skip) { (void)fprintf(stderr, "\t"); } - (void)fprintf(stderr, "data=%ld, rsrc=%ld\n", + (void)fprintf(stderr, "data=%d, rsrc=%d\n", mh.m_datalen, mh.m_rsrclen); } } diff --git a/macunpack/arc.h b/macunpack/arc.h index d155df0..ff9f743 100644 --- a/macunpack/arc.h +++ b/macunpack/arc.h @@ -1,3 +1,5 @@ +#include + #define MAGIC1 0 /* Should be 0x1b, marks Mac extension */ #define KIND 1 /* KIND == 0 marks end of archive */ #define FNAME 2 @@ -26,17 +28,17 @@ typedef struct arc_fileHdr { /* 84 or 88 bytes */ char ftype[4]; char fauth[4]; char finfo[8]; - unsigned long dataLength; - unsigned long rsrcLength; + uint32_t dataLength; + uint32_t rsrcLength; char filler; char magic2; char kind2; char fname2[13]; - unsigned long size; - unsigned short date; - unsigned short time; - unsigned short crc; - unsigned long size2; /* Identical to size; this is wrong for Arc! */ + uint32_t size; + uint16_t date; + uint16_t time; + uint16_t crc; + uint32_t size2; /* Identical to size; this is wrong for Arc! */ }; #define smallstored 1 diff --git a/macunpack/bin.c b/macunpack/bin.c index 00e2750..8bc757e 100644 --- a/macunpack/bin.c +++ b/macunpack/bin.c @@ -14,7 +14,7 @@ void bin (char *header, int data_size, int UMcp) { char hdr[INFOBYTES]; - unsigned long rsrcLength, dataLength; + uint32_t rsrcLength, dataLength; hdr[0] = getb(infp); (void)ungetc(hdr[0], infp); @@ -38,7 +38,7 @@ bin (char *header, int data_size, int UMcp) #ifdef SCAN do_idf("", COPY); #endif /* SCAN */ - mcb(header, (unsigned long)in_data_size, (unsigned long)in_rsrc_size, + mcb(header, (uint32_t)in_data_size, (uint32_t)in_rsrc_size, in_ds + in_rs); ds_skip = 0; rs_skip = 0; diff --git a/macunpack/cpt.c b/macunpack/cpt.c index a788ff4..c6fdc24 100644 --- a/macunpack/cpt.c +++ b/macunpack/cpt.c @@ -24,17 +24,17 @@ static void cpt_uncompact(); static unsigned char *cpt_data; -static unsigned long cpt_datamax; -static unsigned long cpt_datasize; +static uint32_t cpt_datamax; +static uint32_t cpt_datasize; static unsigned char cpt_LZbuff[CIRCSIZE]; static unsigned int cpt_LZptr; static unsigned char *cpt_char; -static unsigned long cpt_crc; -static unsigned long cpt_inlength; -static unsigned long cpt_outlength; +static uint32_t cpt_crc; +static uint32_t cpt_inlength; +static uint32_t cpt_outlength; static int cpt_outstat; static unsigned char cpt_savechar; -static unsigned long cpt_newbits; +static uint32_t cpt_newbits; static int cpt_bitsavail; static int cpt_blocksize; /* Lengths is twice the max number of entries, and include slack. */ @@ -254,9 +254,9 @@ cpt_filehdr (struct cpt_fileHdr *f, char *hdr) transname(hdr + F_FTYPE, ftype, 4); transname(hdr + F_CREATOR, fauth, 4); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", text, ftype, fauth, - (long)f->dataLength, (long)f->rsrcLength); + (int32_t)f->dataLength, (int32_t)f->rsrcLength); } if(info_only) { write_it = 0; @@ -381,8 +381,8 @@ cpt_uncompact (struct cpt_fileHdr filehdr) filehdr.cptFlag & 4); if(filehdr.fileCRC != cpt_crc) { (void)fprintf(stderr, - "CRC error on file: need 0x%08lx, got 0x%08lx\n", - (long)filehdr.fileCRC, (long)cpt_crc); + "CRC error on file: need 0x%08x, got 0x%08x\n", + (int32_t)filehdr.fileCRC, (int32_t)cpt_crc); #ifdef SCAN do_error("macunpack: CRC error on file"); #endif /* SCAN */ @@ -396,7 +396,7 @@ cpt_uncompact (struct cpt_fileHdr filehdr) } 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) { return; @@ -415,7 +415,7 @@ cpt_wrfile (unsigned long ibytes, unsigned long obytes, int type) } 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; if(ibytes == 0) { diff --git a/macunpack/cpt.h b/macunpack/cpt.h index 75581d8..cf53a63 100644 --- a/macunpack/cpt.h +++ b/macunpack/cpt.h @@ -1,3 +1,5 @@ +#include + #define C_SIGNATURE 0 #define C_VOLUME 1 #define C_XMAGIC 2 @@ -29,15 +31,15 @@ #define F_COMPDLENGTH 76 #define CPT_FILEHDRSIZE 80 -typedef long OSType; +typedef int32_t OSType; typedef struct cptHdr { /* 8 bytes */ unsigned char signature; /* = 1 -- for verification */ unsigned char volume; /* for multi-file archives */ unsigned short xmagic; /* verification multi-file consistency*/ - unsigned long offset; /* index offset */ + uint32_t offset; /* index 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 char commentsize; /* number of bytes comment that follow*/ } cptHdr; @@ -47,20 +49,20 @@ typedef struct cpt_fileHdr { /* 78 bytes */ unsigned char folder; /* set to 1 if a folder */ unsigned short foldersize; /* number of entries in folder */ unsigned char volume; /* for multi-file archives */ - unsigned long filepos; /* position of data in file */ + uint32_t filepos; /* position of data in file */ OSType fType; /* file type */ OSType fCreator; /* er... */ - unsigned long creationDate; - unsigned long modDate; /* !restored-compat w/backup prgms */ + uint32_t creationDate; + uint32_t modDate; /* !restored-compat w/backup prgms */ unsigned short FndrFlags; /* copy of Finder flags. For our purposes, we can clear: busy,onDesk */ - unsigned long fileCRC; /* crc on file */ + uint32_t fileCRC; /* crc on file */ unsigned short cptFlag; /* cpt flags */ - unsigned long rsrcLength; /* decompressed lengths */ - unsigned long dataLength; - unsigned long compRLength; /* compressed lengths */ - unsigned long compDLength; + uint32_t rsrcLength; /* decompressed lengths */ + uint32_t dataLength; + uint32_t compRLength; /* compressed lengths */ + uint32_t compDLength; } cpt_fileHdr; @@ -93,7 +95,7 @@ typedef struct cpt_fileHdr { /* 78 bytes */ void cpt_wrfile1 (unsigned char *in_char, - unsigned long ibytes, - unsigned long obytes, + uint32_t ibytes, + uint32_t obytes, int type, - unsigned long blocksize); + uint32_t blocksize); diff --git a/macunpack/dd.c b/macunpack/dd.c index 53ee85f..fb58788 100644 --- a/macunpack/dd.c +++ b/macunpack/dd.c @@ -20,9 +20,9 @@ static void dd_cfilehdr(); static int dd_valid(); static int dd_valid1(); static char *dd_methname(); -static unsigned long dd_checksum(); +static uint32_t dd_checksum(); static void dd_chksum(); -static unsigned long dd_checkor(); +static uint32_t dd_checkor(); static void dd_do_delta(); static void dd_delta(); static void dd_delta3(); @@ -67,7 +67,7 @@ static unsigned char *dd_dirst; static int dd_dirstptr; static int dd_dirstmax; static int dd_xor; -static long dd_bitbuf; +static int32_t dd_bitbuf; static int dd_bitcount; static unsigned char *dd_bitptr; static char dd_LZbuff[2048]; @@ -75,7 +75,7 @@ static char dd_LZbuff[2048]; void dd_file (unsigned char *bin_hdr) { - unsigned long data_size; + uint32_t data_size; int i; struct dd_fileCHdr cf; char ftype[5], fauth[5]; @@ -117,9 +117,9 @@ dd_file (unsigned char *bin_hdr) transname(info + I_TYPEOFF, ftype, 4); transname(info + I_AUTHOFF, fauth, 4); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", text, ftype, fauth, - (long)get4(info + I_DLENOFF), (long)get4(info + I_RLENOFF)); + (int32_t)get4(info + I_DLENOFF), (int32_t)get4(info + I_RLENOFF)); if(info_only) { write_it = 0; } @@ -149,7 +149,7 @@ dd_file (unsigned char *bin_hdr) void dd_arch (unsigned char *bin_hdr) { - unsigned long data_size; + uint32_t data_size; uint32_t crc, filecrc; struct dd_fileHdr f; struct dd_fileCHdr cf; @@ -323,7 +323,7 @@ dd_filehdr (struct dd_fileHdr *f, struct dd_fileCHdr *cf, int skip) int n, to_uncompress; unsigned char *hdr; char ftype[5], fauth[5]; - unsigned long datalength, rsrclength; + uint32_t datalength, rsrclength; to_uncompress = DD_COPY; hdr = dd_data_ptr; @@ -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_AUTHOFF, fauth, 4); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)datalength, (long)rsrclength); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)datalength, (int32_t)rsrclength); } if(info_only) { write_it = 0; @@ -509,11 +509,11 @@ int i, nmeths; return NULL; } -static unsigned long -dd_checksum (unsigned long init, char *buffer, unsigned long length) +static uint32_t +dd_checksum (uint32_t init, char *buffer, uint32_t length) { int i; - unsigned long cks; + uint32_t cks; cks = init; for(i = 0; i < length; i++) { @@ -525,7 +525,7 @@ dd_checksum (unsigned long init, char *buffer, unsigned long length) static void dd_chksum (struct dd_fileHdr hdr, unsigned char *data) { - unsigned long cks; + uint32_t cks; if(write_it) { cks = dd_checksum(INIT_CRC, (char *)data - CDD_FILEHDRSIZE, @@ -542,11 +542,11 @@ dd_chksum (struct dd_fileHdr hdr, unsigned char *data) } } -static unsigned long -dd_checkor (unsigned long init, char *buffer, unsigned long length) +static uint32_t +dd_checkor (uint32_t init, char *buffer, uint32_t length) { int i; - unsigned long cks; + uint32_t cks; cks = init; for(i = 0; i < length; i++) { @@ -556,7 +556,7 @@ dd_checkor (unsigned long init, char *buffer, unsigned long length) } 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) { case 0: @@ -577,7 +577,7 @@ dd_do_delta (char *out_ptr, unsigned long nbytes, int kind) } static void -dd_delta (char *out_ptr, unsigned long nbytes) +dd_delta (char *out_ptr, uint32_t nbytes) { int i, sum = 0; @@ -588,7 +588,7 @@ dd_delta (char *out_ptr, unsigned long nbytes) } 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; @@ -612,7 +612,7 @@ dd_delta3 (char *out_ptr, unsigned long nbytes) static void dd_copy (struct dd_fileHdr hdr, unsigned char *data) { - unsigned long cks; + uint32_t cks; if(write_it) { start_info(info, hdr.rsrcLength, hdr.dataLength); @@ -661,7 +661,7 @@ dd_copy (struct dd_fileHdr hdr, unsigned char *data) } static void -dd_copyfile (unsigned long obytes, unsigned char *data) +dd_copyfile (uint32_t obytes, unsigned char *data) { if(obytes == 0) { return; @@ -677,7 +677,7 @@ dd_copyfile (unsigned long obytes, unsigned char *data) static void dd_expand (struct dd_fileCHdr hdr, unsigned char *data) { - unsigned long cks; + uint32_t cks; char *out_buf; if(write_it) { @@ -691,7 +691,7 @@ dd_expand (struct dd_fileCHdr hdr, unsigned char *data) } out_buf = out_buffer; dd_expandfile(hdr.dataLength, hdr.dataCLength, (int)hdr.datamethod, - (int)hdr.datainfo, data, (unsigned long)hdr.datacrc); + (int)hdr.datainfo, data, (uint32_t)hdr.datacrc); data += hdr.dataCLength; if(write_it) { if((hdr.info2 & 0x40) && (hdr.dataLength != 0)) { @@ -716,7 +716,7 @@ dd_expand (struct dd_fileCHdr hdr, unsigned char *data) } out_buf = out_buffer; dd_expandfile(hdr.rsrcLength, hdr.rsrcCLength, (int)hdr.rsrcmethod, - (int)hdr.rsrcinfo, data, (unsigned long)hdr.rsrccrc); + (int)hdr.rsrcinfo, data, (uint32_t)hdr.rsrccrc); data += hdr.rsrcCLength; if(write_it) { if((hdr.info2 & 0x40) && (hdr.rsrcLength != 0)) { @@ -740,11 +740,11 @@ dd_expand (struct dd_fileCHdr hdr, unsigned char *data) } 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; char *optr = out_ptr; - unsigned long cksinit; + uint32_t cksinit; if(obytes == 0) { if(verbose) { @@ -839,7 +839,7 @@ dd_expandfile (unsigned long obytes, unsigned long ibytes, int method, int kind, /* Method 0: no compression */ /*---------------------------------------------------------------------------*/ 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); } @@ -848,11 +848,11 @@ dd_nocomp (unsigned long obytes, unsigned char *data) /* Method 1: LZC compressed */ /*---------------------------------------------------------------------------*/ 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; char *out_buf; - unsigned long cks; + uint32_t cks; out_buf = out_buffer; 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 */ /*---------------------------------------------------------------------------*/ static void -dd_rle (unsigned long ibytes, unsigned char *data) +dd_rle (uint32_t ibytes, unsigned char *data) { int ch, lastch, n, i; @@ -910,7 +910,7 @@ dd_rle (unsigned long ibytes, unsigned char *data) /* Method 4: Huffman encoding */ /*---------------------------------------------------------------------------*/ static void -dd_huffman (unsigned long ibytes, unsigned char *data) +dd_huffman (uint32_t ibytes, unsigned char *data) { } #endif /* NOTIMPLEMENTED */ @@ -919,7 +919,7 @@ dd_huffman (unsigned long ibytes, unsigned char *data) /* Method 7: Slightly improved LZSS */ /*---------------------------------------------------------------------------*/ static void -dd_lzss (unsigned char *data, unsigned long chksum) +dd_lzss (unsigned char *data, uint32_t chksum) { int i, LZptr, LZbptr, LZlength; 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) { (void)fprintf(stderr, "Checksum error on fork: need 0x%04x, got 0x%04x\n", @@ -992,12 +992,12 @@ dd_getbits (int n) /* Method 8: Compactor compatible compression */ /*---------------------------------------------------------------------------*/ 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; - cpt_wrfile1(data, ibytes, obytes, sub_method, (unsigned long)0x0fff0); + cpt_wrfile1(data, ibytes, obytes, sub_method, (uint32_t)0x0fff0); cks = arc_updcrc(INIT_CRC, (unsigned char *)optr, (int)obytes); if(chksum != cks) { (void)fprintf(stderr, diff --git a/macunpack/dd.h b/macunpack/dd.h index 4464430..e8cfce4 100644 --- a/macunpack/dd.h +++ b/macunpack/dd.h @@ -1,6 +1,9 @@ #include "macunpack.h" #ifdef DD + +#include + #ifdef DD_INTERNAL #define MAGIC1 "DDAR" @@ -55,7 +58,7 @@ #define DD_C_HDRCRC 82 #define CDD_FILEHDRSIZE 84 -typedef long OSType; +typedef int32_t OSType; typedef struct dd_fileHdr { /* 124 bytes */ unsigned char magic[4]; /* "DDAR" */ @@ -63,10 +66,10 @@ typedef struct dd_fileHdr { /* 124 bytes */ unsigned char fName[64]; /* a STR63 */ unsigned char isdir; /* starts a directory? */ unsigned char enddir; /* terminates a directory? */ - unsigned long dataLength; /* lengths */ - unsigned long rsrcLength; - unsigned long creationDate; - unsigned long modDate; + uint32_t dataLength; /* lengths */ + uint32_t rsrcLength; + uint32_t creationDate; + uint32_t modDate; OSType fType; /* file type */ OSType fCreator; /* er... */ unsigned short FndrFlags; /* copy of Finder flags. For our @@ -80,16 +83,16 @@ typedef struct dd_fileHdr { /* 124 bytes */ typedef struct dd_fileCHdr { /* 84 bytes */ unsigned char magic[4]; /* "\253\315\000\124" */ - unsigned long dataLength; /* lengths */ - unsigned long dataCLength; - unsigned long rsrcLength; - unsigned long rsrcCLength; + uint32_t dataLength; /* lengths */ + uint32_t dataCLength; + uint32_t rsrcLength; + uint32_t rsrcCLength; unsigned char datamethod; /* compression method used */ unsigned char rsrcmethod; unsigned char info1; /* flags ??? */ unsigned char fill3; - unsigned long modDate; - unsigned long creationDate; + uint32_t modDate; + uint32_t creationDate; OSType fType; /* file type */ OSType fCreator; /* er... */ unsigned short FndrFlags; /* copy of Finder flags. For our diff --git a/macunpack/de_compress.c b/macunpack/de_compress.c index 3aa3324..f5129c1 100644 --- a/macunpack/de_compress.c +++ b/macunpack/de_compress.c @@ -19,20 +19,20 @@ static int n_bits; /* number of bits/code */ static int maxbits; /* user settable max # bits/code */ -static long maxcode; /* maximum code, given n_bits */ -static long maxmaxcode; /* should NEVER generate this code */ +static int32_t maxcode; /* maximum code, given n_bits */ +static int32_t maxmaxcode; /* should NEVER generate this code */ # define MAXCODE(n_bits) ((1 << (n_bits)) - 1) -static long htab [HSIZE]; +static int32_t htab [HSIZE]; static unsigned short codetab [HSIZE]; #define tab_prefixof(i) codetab[i] #define tab_suffixof(i) ((unsigned char *)(htab))[i] #define de_stack ((unsigned char *)&tab_suffixof(1< + +void de_compress(uint32_t ibytes, int mb); void core_compress(char* ptr); diff --git a/macunpack/de_huffman.c b/macunpack/de_huffman.c index df120d6..8f870b1 100644 --- a/macunpack/de_huffman.c +++ b/macunpack/de_huffman.c @@ -35,7 +35,7 @@ static node *nodeptr, *read_sub_tree(); static int bit; -void de_huffman(unsigned long obytes) +void de_huffman(uint32_t obytes) { while(obytes != 0) { *out_ptr++ = gethuffbyte(nodelist); diff --git a/macunpack/de_huffman.h b/macunpack/de_huffman.h index 541bfa8..5bc18bc 100644 --- a/macunpack/de_huffman.h +++ b/macunpack/de_huffman.h @@ -1,4 +1,6 @@ +#include + void set_huffman(int endian); void read_tree(); -void de_huffman(unsigned long obytes); +void de_huffman(uint32_t obytes); void de_huffman_end(unsigned int term); \ No newline at end of file diff --git a/macunpack/de_lzah.c b/macunpack/de_lzah.c index ccdd47b..5af542d 100644 --- a/macunpack/de_lzah.c +++ b/macunpack/de_lzah.c @@ -95,7 +95,7 @@ static int Frequ[1000]; static int ForwTree[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; diff --git a/macunpack/de_lzah.h b/macunpack/de_lzah.h index d45894d..4f326ad 100644 --- a/macunpack/de_lzah.h +++ b/macunpack/de_lzah.h @@ -1,8 +1,10 @@ #ifndef DE_LZAH_H #define DE_LZAH_H -extern void de_lzah(unsigned long obytes); +#include + +extern void de_lzah(uint32_t obytes); 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 diff --git a/macunpack/de_lzh.c b/macunpack/de_lzh.c index 226f593..182bafc 100644 --- a/macunpack/de_lzh.c +++ b/macunpack/de_lzh.c @@ -24,7 +24,7 @@ static unsigned int decode_p(); static void make_table(); /* 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; int remains; diff --git a/macunpack/dia.c b/macunpack/dia.c index 718ca9d..a3090ee 100644 --- a/macunpack/dia.c +++ b/macunpack/dia.c @@ -202,7 +202,7 @@ dia_file (int indicator, unsigned char *name) int dataLength, rsrcLength; int cdataLength, crsrcLength; int dataMethod, rsrcMethod; - unsigned long curtime; + uint32_t curtime; if(name != NULL) { for(i = 0; i < INFOBYTES; i++) { @@ -230,7 +230,7 @@ dia_file (int indicator, unsigned char *name) info[I_MTIMOFF + i] = *dia_header_ptr++; } } else { - curtime = (unsigned long)time((time_t *)0) + TIMEDIFF; + curtime = (uint32_t)time((time_t *)0) + TIMEDIFF; put4(info + I_CTIMOFF, curtime); put4(info + I_MTIMOFF, curtime); } @@ -266,16 +266,16 @@ dia_file (int indicator, unsigned char *name) crsrcLength = dia_cforklength; rsrcMethod = dia_method; dia_archive_ptr = old_archive_ptr; - put4(info + I_DLENOFF, (unsigned long)dataLength); - put4(info + I_RLENOFF, (unsigned long)rsrcLength); + put4(info + I_DLENOFF, (uint32_t)dataLength); + put4(info + I_RLENOFF, (uint32_t)rsrcLength); if(list) { transname(info + I_NAMEOFF + 1, (char *)lname, length); do_indent(indent); transname(info + I_TYPEOFF, ftype, 4); transname(info + I_AUTHOFF, fauth, 4); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - lname, ftype, fauth, (long)dataLength, (long)rsrcLength); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + lname, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength); if(info_only) { doit = 0; } else { @@ -296,7 +296,7 @@ dia_file (int indicator, unsigned char *name) } if(doit) { define_name((char *)lname); - start_info(info, (unsigned long)rsrcLength, (unsigned long)dataLength); + start_info(info, (uint32_t)rsrcLength, (uint32_t)dataLength); } if(verbose) { (void)fprintf(stderr, "\tData: "); diff --git a/macunpack/jdw.c b/macunpack/jdw.c index ab5e3ec..172502b 100644 --- a/macunpack/jdw.c +++ b/macunpack/jdw.c @@ -14,7 +14,7 @@ static void jdw_wrfork(); static void jdw_block(); void -jdw (unsigned long ibytes) +jdw (uint32_t ibytes) { char fauth[5], ftype[5]; int filel, i; @@ -63,8 +63,8 @@ jdw (unsigned long ibytes) transname(info + I_AUTHOFF, fauth, 4); do_indent(indent); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)dataLength, (long)rsrcLength); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength); if(info_only) { write_it = 0; } @@ -74,11 +74,11 @@ jdw (unsigned long ibytes) (void)fputc('\n', stderr); } } - jdw_wrfile((unsigned long)rsrcLength, (unsigned long)dataLength); + jdw_wrfile((uint32_t)rsrcLength, (uint32_t)dataLength); } static void -jdw_wrfile (unsigned long rsrcLength, unsigned long dataLength) +jdw_wrfile (uint32_t rsrcLength, uint32_t dataLength) { if(write_it) { define_name(text); @@ -105,10 +105,10 @@ jdw_wrfile (unsigned long rsrcLength, unsigned long dataLength) } static void -jdw_wrfork (unsigned long length) +jdw_wrfork (uint32_t length) { int olength, ilength, i; - unsigned long origlength, comprlength; + uint32_t origlength, comprlength; if(length == 0) { (void)fprintf(stderr, "empty"); @@ -148,7 +148,7 @@ jdw_block (int olength) bytesread++; } clrhuff(); - de_huffman((unsigned long)olength); + de_huffman((uint32_t)olength); } #else /* JDW */ int jdw; /* keep lint and some compilers happy */ diff --git a/macunpack/jdw.h b/macunpack/jdw.h index c47b100..88411d4 100644 --- a/macunpack/jdw.h +++ b/macunpack/jdw.h @@ -1,3 +1,5 @@ +#include + #define J_MAGIC 0 #define J_TYPE 6 #define J_AUTH 10 @@ -10,13 +12,13 @@ typedef struct jdw_fileHdr { char magic[6]; - unsigned long type; - unsigned long auth; + uint32_t type; + uint32_t auth; char finfo[8]; - unsigned long dataLength; - unsigned long rsrcLength; - unsigned long ctime; - unsigned long mtime; + uint32_t dataLength; + uint32_t rsrcLength; + uint32_t ctime; + uint32_t mtime; char flength; char fname[32]; /* actually flength */ } jdw_fileHdr; diff --git a/macunpack/lzc.c b/macunpack/lzc.c index 00d89a3..c349c99 100644 --- a/macunpack/lzc.c +++ b/macunpack/lzc.c @@ -29,7 +29,7 @@ static void lzc_zivm (char *ohdr) { char hdr[HEADERBYTES]; - unsigned long dataLength, rsrcLength, dataCLength, rsrcCLength; + uint32_t dataLength, rsrcLength, dataCLength, rsrcCLength; char ftype[5], fauth[5]; if(fread(hdr, 1, HEADERBYTES, infp) != HEADERBYTES) { @@ -67,8 +67,8 @@ lzc_zivm (char *ohdr) transname(hdr + C_AUTHOFF, fauth, 4); do_indent(indent); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)dataLength, (long)rsrcLength); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength); if(info_only) { write_it = 0; } @@ -108,7 +108,7 @@ lzc_zivm (char *ohdr) } static void -lzc_wrfile (unsigned long obytes, unsigned long ibytes) +lzc_wrfile (uint32_t obytes, uint32_t ibytes) { int n, nbits; char subheader[3]; @@ -186,7 +186,7 @@ lzc_zivu (char *ohdr) { (void)fprintf(stderr, "\tMacCompress(Unix) not yet implemented, copied as MacBinary\n"); - mcb(ohdr, (unsigned long)in_rsrc_size, (unsigned long)in_data_size, + mcb(ohdr, (uint32_t)in_rsrc_size, (uint32_t)in_data_size, in_ds + in_rs); } #else /* LZC */ diff --git a/macunpack/lzc.h b/macunpack/lzc.h index 34d4604..10f7b96 100644 --- a/macunpack/lzc.h +++ b/macunpack/lzc.h @@ -1,3 +1,5 @@ +#include + #define HEADERBYTES 48 #define MAGIC1 "\253\315\000\060" #define MAGIC2 "\037\235" @@ -13,16 +15,16 @@ #define C_FLAGOFF 40 typedef struct lzc_fileHdr { - unsigned long magic1; - unsigned long dataLength; - unsigned long dataCLength; - unsigned long rsrcLength; - unsigned long rsrcCLength; - unsigned long unknown1; - unsigned long mtime; - unsigned long ctime; - unsigned long filetype; - unsigned long fileauth; - unsigned long flag1; - unsigned long flag2; + uint32_t magic1; + uint32_t dataLength; + uint32_t dataCLength; + uint32_t rsrcLength; + uint32_t rsrcCLength; + uint32_t unknown1; + uint32_t mtime; + uint32_t ctime; + uint32_t filetype; + uint32_t fileauth; + uint32_t flag1; + uint32_t flag2; } lzc_fileHdr; diff --git a/macunpack/lzh.c b/macunpack/lzh.c index 300d008..26a637f 100644 --- a/macunpack/lzh.c +++ b/macunpack/lzh.c @@ -382,37 +382,37 @@ lzh_wrfile (struct lzh_fileHdr *filehdr, int method) } switch(method) { case lz4: - lzh_nocomp((unsigned long)128); + lzh_nocomp((uint32_t)128); break; #ifdef UNTESTED case lz5: - lzh_lzss1((unsigned long)128); + lzh_lzss1((uint32_t)128); break; case lzs: - lzh_lzss2((unsigned long)128); + lzh_lzss2((uint32_t)128); break; #endif /* UNTESTED */ case lh0: - lzh_nocomp((unsigned long)128); + lzh_nocomp((uint32_t)128); break; case lh1: - lzh_lzah((unsigned long)128); + lzh_lzah((uint32_t)128); break; #ifdef UNDEF case lh2: - lzh_lh2((unsigned long)128); + lzh_lh2((uint32_t)128); break; case lh3: - lzh_lh3((unsigned long)128); + lzh_lh3((uint32_t)128); break; #endif /* UNDEF */ #ifdef UNTESTED case lh4: - lzh_lzh12((unsigned long)128); + lzh_lzh12((uint32_t)128); break; #endif /* UNTESTED */ case lh5: - lzh_lzh13((unsigned long)128); + lzh_lzh13((uint32_t)128); break; default: mname = lzh_methname(method); @@ -452,8 +452,8 @@ lzh_wrfile (struct lzh_fileHdr *filehdr, int method) if(list) { do_indent(indent); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)dataLength, (long)rsrcLength); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength); } if(info_only) { doit = 0; @@ -467,7 +467,7 @@ lzh_wrfile (struct lzh_fileHdr *filehdr, int method) } if(doit) { define_name(text); - start_info(info, (unsigned long)rsrcLength, (unsigned long)dataLength); + start_info(info, (uint32_t)rsrcLength, (uint32_t)dataLength); } switch(method) { case lz4: @@ -589,7 +589,7 @@ lzh_skip (struct lzh_fileHdr *filehdr) /* -lz4- and -lh0: No compression */ /*---------------------------------------------------------------------------*/ static void -lzh_nocomp (unsigned long obytes) +lzh_nocomp (uint32_t obytes) { copy(lzh_file, lzh_data, (int)obytes); } @@ -599,7 +599,7 @@ lzh_nocomp (unsigned long obytes) /* -lz5-: LZSS compression, variant 1 */ /*---------------------------------------------------------------------------*/ static void -lzh_lzss1 (unsigned long obytes) +lzh_lzss1 (uint32_t obytes) { int mask, ch, lzcnt, lzptr, ptr, count; char *p = lzh_lzbuf; @@ -662,7 +662,7 @@ lzh_lzss1 (unsigned long obytes) /* -lzs-: LZSS compression, variant 2 */ /*---------------------------------------------------------------------------*/ static void -lzh_lzss2 (unsigned long obytes) +lzh_lzss2 (uint32_t obytes) { int ch, lzcnt, lzptr, ptr, i; @@ -706,7 +706,7 @@ lzh_lzss2 (unsigned long obytes) /* -lh1-: LZ compression plus adaptive Huffman encoding */ /*---------------------------------------------------------------------------*/ static void -lzh_lzah (unsigned long obytes) +lzh_lzah (uint32_t obytes) { lzh_current = lzh_data + 2; /* SKIPPING BLOCKSIZE! */ tmp_out_ptr = out_ptr; @@ -727,7 +727,7 @@ lzh_getbyte (void) /* -lh2-: LZ** compression */ /*---------------------------------------------------------------------------*/ static void -lzh_lh2 (unsigned long obytes) +lzh_lh2 (uint32_t obytes) { } @@ -735,7 +735,7 @@ lzh_lh2 (unsigned long obytes) /* -lh3-: LZ** compression */ /*---------------------------------------------------------------------------*/ static void -lzh_lh3 (unsigned long obytes) +lzh_lh3 (uint32_t obytes) { } #endif /* UNDEF */ @@ -745,13 +745,13 @@ lzh_lh3 (unsigned long obytes) /* -lh4-: LZ(12) compression plus Huffman encoding */ /*---------------------------------------------------------------------------*/ static void -lzh_lzh12 (unsigned long obytes) +lzh_lzh12 (uint32_t obytes) { lzh_current = lzh_data; tmp_out_ptr = out_ptr; out_ptr = lzh_file; /* Controlled by obytes only */ - de_lzh((long)(-1), (long)obytes, &lzh_current, 12); + de_lzh((int32_t)(-1), (int32_t)obytes, &lzh_current, 12); out_ptr = tmp_out_ptr; } #endif /* UNTESTED */ @@ -760,12 +760,12 @@ lzh_lzh12 (unsigned long obytes) /* -lh5-: LZ(13) compression plus Huffman encoding */ /*---------------------------------------------------------------------------*/ static void -lzh_lzh13 (unsigned long obytes) +lzh_lzh13 (uint32_t obytes) { lzh_current = lzh_data; tmp_out_ptr = out_ptr; out_ptr = lzh_file; /* Controlled by obytes only */ - de_lzh((long)(-1), (long)obytes, &lzh_current, 13); + de_lzh((int32_t)(-1), (int32_t)obytes, &lzh_current, 13); out_ptr = tmp_out_ptr; } diff --git a/macunpack/lzh.h b/macunpack/lzh.h index df1dc76..b572a56 100644 --- a/macunpack/lzh.h +++ b/macunpack/lzh.h @@ -1,3 +1,5 @@ +#include + #define FILEHDRSIZE 22 #define TOTALSIZE 64 #define L_HSIZE 0 @@ -34,9 +36,9 @@ typedef struct lzh_fileHdr { /* 58 bytes */ unsigned char hsize; unsigned char hcrc; char method[5]; - unsigned long psize; - unsigned long upsize; - unsigned long lastmod; + uint32_t psize; + uint32_t upsize; + uint32_t lastmod; unsigned short attribute; unsigned char nlength; char name[32]; diff --git a/macunpack/macbinary.c b/macunpack/macbinary.c index 6f0f678..08bf6eb 100644 --- a/macunpack/macbinary.c +++ b/macunpack/macbinary.c @@ -74,7 +74,7 @@ macbinary (void) if(verbose) { (void)fprintf(stderr, "This is a \"Zoom\" archive.\n"); } - zma(header, (unsigned long)0); + zma(header, (uint32_t)0); exit(0); } #endif /* ZMA */ @@ -167,7 +167,7 @@ macbinary (void) #ifdef SCAN do_idf(header + I_NAMEOFF + 1, PACK_NAME); #endif /* SCAN */ - jdw((unsigned long)in_data_size); + jdw((uint32_t)in_data_size); skip_file(ds_skip + in_rs); continue; } @@ -183,7 +183,7 @@ macbinary (void) #ifdef SCAN do_idf(header + I_NAMEOFF + 1, PACK_NAME); #endif /* SCAN */ - stf((unsigned long)in_data_size); + stf((uint32_t)in_data_size); skip_file(ds_skip + in_rs); continue; } @@ -389,7 +389,7 @@ macbinary (void) #ifdef SCAN do_idf(header + I_NAMEOFF + 1, ARCH_NAME); #endif /* SCAN */ - zma((char *)NULL, (unsigned long)in_data_size); + zma((char *)NULL, (uint32_t)in_data_size); skip_file(ds_skip + in_rs); continue; } @@ -403,7 +403,7 @@ macbinary (void) #ifdef SCAN do_idf(header + I_NAMEOFF + 1, ARCH_NAME); #endif /* SCAN */ - zma((char *)NULL, (unsigned long)in_data_size); + zma((char *)NULL, (uint32_t)in_data_size); skip_file(ds_skip + in_rs); continue; } @@ -499,8 +499,8 @@ macbinary (void) } #endif /* DD */ if(header[0] == 0 /* MORE CHECKS HERE! */) { - mcb(header, (unsigned long)in_rsrc_size, - (unsigned long)in_data_size, in_ds + in_rs); + mcb(header, (uint32_t)in_rsrc_size, + (uint32_t)in_data_size, in_ds + in_rs); continue; } else { (void)fprintf(stderr, "Unrecognized archive type.\n"); diff --git a/macunpack/macunpack.c b/macunpack/macunpack.c index 051f7d5..09546e4 100644 --- a/macunpack/macunpack.c +++ b/macunpack/macunpack.c @@ -157,7 +157,7 @@ int main(int argc, char **argv) if(verbose) { fprintf(stderr, "This is a \"ShrinkToFit\" packed file.\n"); } - stf(~(unsigned long)1); + stf(~(uint32_t)1); break; #endif /* STF */ #ifdef PIT diff --git a/macunpack/mcb.c b/macunpack/mcb.c index 580ebda..e713106 100644 --- a/macunpack/mcb.c +++ b/macunpack/mcb.c @@ -8,7 +8,7 @@ static int mcb_read; 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; int n; @@ -36,8 +36,8 @@ void mcb(char *hdr, unsigned long rsrcLength, unsigned long dataLength, int tore transname(hdr + I_AUTHOFF, fauth, 4); do_indent(indent); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)dataLength, (long)rsrcLength); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength); if(info_only) { write_it = 0; } @@ -77,7 +77,7 @@ void mcb(char *hdr, unsigned long rsrcLength, unsigned long dataLength, int tore } static void -mcb_wrfile (unsigned long ibytes) +mcb_wrfile (uint32_t ibytes) { int n; diff --git a/macunpack/mcb.h b/macunpack/mcb.h index 4e46a7e..c356c6a 100644 --- a/macunpack/mcb.h +++ b/macunpack/mcb.h @@ -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); diff --git a/macunpack/pit.c b/macunpack/pit.c index edb9058..17f594d 100644 --- a/macunpack/pit.c +++ b/macunpack/pit.c @@ -24,7 +24,7 @@ pit (void) struct pit_header filehdr; char pithdr[4]; int decode, synced, ch; - unsigned long data_crc, crc; + uint32_t data_crc, crc; updcrc = binhex_updcrc; crcinit = binhex_crcinit; @@ -207,8 +207,8 @@ pit_filehdr (struct pit_header *f, int compr) transname(hdr + H_AUTHOFF, fauth, 4); do_indent(indent); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)f->dlen, (long)f->rlen); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)f->dlen, (int32_t)f->rlen); if(info_only) { write_it = 0; } @@ -236,7 +236,7 @@ pit_filehdr (struct pit_header *f, int compr) } static void -pit_wrfile (unsigned long bytes, int type) +pit_wrfile (uint32_t bytes, int type) { if(bytes == 0) { return; @@ -254,7 +254,7 @@ pit_wrfile (unsigned long bytes, int type) /* No compression */ /*---------------------------------------------------------------------------*/ static void -pit_nocomp (unsigned long ibytes) +pit_nocomp (uint32_t ibytes) { int n; @@ -272,7 +272,7 @@ pit_nocomp (unsigned long ibytes) /* Huffman compression */ /*---------------------------------------------------------------------------*/ static void -pit_huffman (unsigned long obytes) +pit_huffman (uint32_t obytes) { de_huffman(obytes); } diff --git a/macunpack/pit.h b/macunpack/pit.h index f47caeb..0292b59 100644 --- a/macunpack/pit.h +++ b/macunpack/pit.h @@ -20,10 +20,10 @@ struct pit_header { /* Packit file header (92 bytes) */ char auth[4]; /* file creator */ unsigned short flags; /* file flags (?) */ unsigned short lock; /* unknown */ - unsigned long dlen; /* number of bytes in data fork */ - unsigned long rlen; /* number of bytes in resource fork */ - unsigned long ctim; /* file creation time */ - unsigned long mtim; /* file modified time */ + uint32_t dlen; /* number of bytes in data fork */ + uint32_t rlen; /* number of bytes in resource fork */ + uint32_t ctim; /* file creation time */ + uint32_t mtim; /* file modified time */ unsigned short hdrCRC; /* CRC */ }; diff --git a/macunpack/sit.c b/macunpack/sit.c index 88f15ec..2d8ea66 100644 --- a/macunpack/sit.c +++ b/macunpack/sit.c @@ -90,7 +90,7 @@ static short code6[258] = { 1, 1}; static char sit_buffer[32768]; static short sit_dict[16385]; -static unsigned long sit_avail; +static uint32_t sit_avail; static int sit_bits_avail; void @@ -205,9 +205,9 @@ static int sit_filehdr(struct sit_fileHdr *f, int skip) transname(hdr + F_FTYPE, ftype, 4); transname(hdr + F_CREATOR, fauth, 4); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", text, ftype, fauth, - (long)f->dataLength, (long)f->rsrcLength); + (int32_t)f->dataLength, (int32_t)f->rsrcLength); } if(info_only) { write_it = 0; @@ -438,7 +438,7 @@ sit_unstuff (struct sit_fileHdr filehdr) } 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(verbose) { @@ -534,7 +534,7 @@ sit_wrfile (unsigned long ibytes, unsigned long obytes, int type) /* skip stuffit file */ static void -sit_skip (unsigned long ibytes) +sit_skip (uint32_t ibytes) { while(ibytes != 0) { if(getc(infp) == EOF) { @@ -552,7 +552,7 @@ sit_skip (unsigned long ibytes) /* Method 0: No compression */ /*---------------------------------------------------------------------------*/ static void -sit_nocomp (unsigned long ibytes) +sit_nocomp (uint32_t ibytes) { int n; @@ -570,7 +570,7 @@ sit_nocomp (unsigned long ibytes) /* Method 1: Run length encoding */ /*---------------------------------------------------------------------------*/ static void -sit_rle (unsigned long ibytes) +sit_rle (uint32_t ibytes) { int ch, lastch = 0, n, i; @@ -600,7 +600,7 @@ sit_rle (unsigned long ibytes) /* Method 2: LZC compressed */ /*---------------------------------------------------------------------------*/ static void -sit_lzc (unsigned long ibytes) +sit_lzc (uint32_t ibytes) { de_compress(ibytes, 14); } @@ -609,7 +609,7 @@ sit_lzc (unsigned long ibytes) /* Method 3: Huffman compressed */ /*---------------------------------------------------------------------------*/ static void -sit_huffman (unsigned long obytes) +sit_huffman (uint32_t obytes) { read_tree(); de_huffman(obytes); @@ -619,7 +619,7 @@ sit_huffman (unsigned long obytes) /* Method 5: LZ compression plus adaptive Huffman encoding */ /*---------------------------------------------------------------------------*/ static void -sit_lzah (unsigned long obytes) +sit_lzah (uint32_t obytes) { lzah_getbyte = sit_getbyte; de_lzah(obytes); @@ -635,11 +635,11 @@ sit_getbyte (void) /* Method 6: Compression with a fixed Huffman encoding */ /*---------------------------------------------------------------------------*/ static void -sit_fixhuf (unsigned long ibytes) +sit_fixhuf (uint32_t ibytes) { int i, sum, codes, sym, num; char byte_int[4], byte_short[2]; - long size; + int32_t size; int sign; char *tmp_ptr, *ptr, *end_ptr; @@ -659,7 +659,7 @@ sit_fixhuf (unsigned long ibytes) exit(1); } ibytes -= 4; - size = (long)get4(byte_int); + size = (int32_t)get4(byte_int); sign = 0; if(size < 0) { size = - size; @@ -759,7 +759,7 @@ sit_dosplit (int ptr, int sum, int low, int upp) /* Method 8: Compression with a MW encoding */ /*---------------------------------------------------------------------------*/ static void -sit_mw (unsigned long ibytes) +sit_mw (uint32_t ibytes) { int ptr; int max, max1, bits; @@ -819,7 +819,7 @@ sit_mw_out (int ptr) } static int -sit_mw_in (int bits, unsigned long *ibytes) +sit_mw_in (int bits, uint32_t *ibytes) { int res, res1; diff --git a/macunpack/sit.h b/macunpack/sit.h index 06e439a..e36ff11 100644 --- a/macunpack/sit.h +++ b/macunpack/sit.h @@ -1,6 +1,8 @@ #include "macunpack.h" #ifdef SIT +#include + #ifdef SIT_INTERNAL #define S_SIGNATURE 0 #define S_NUMFILES 4 @@ -26,12 +28,12 @@ #define F_HDRCRC 110 #define FILEHDRSIZE 112 -typedef long OSType; +typedef int32_t OSType; typedef struct sitHdr { /* 22 bytes */ OSType signature; /* = 'SIT!' -- for verification */ unsigned short numFiles; /* number of files in archive */ - unsigned long arcLength; /* length of entire archive incl. + uint32_t arcLength; /* length of entire archive incl. hdr. -- for verification */ OSType signature2; /* = 'rLau' -- for verification */ unsigned char version; /* version number */ @@ -47,12 +49,12 @@ typedef struct sit_fileHdr { /* 112 bytes */ unsigned short FndrFlags; /* copy of Finder flags. For our purposes, we can clear: busy,onDesk */ - unsigned long creationDate; - unsigned long modDate; /* !restored-compat w/backup prgms */ - unsigned long rsrcLength; /* decompressed lengths */ - unsigned long dataLength; - unsigned long compRLength; /* compressed lengths */ - unsigned long compDLength; + uint32_t creationDate; + uint32_t modDate; /* !restored-compat w/backup prgms */ + uint32_t rsrcLength; /* decompressed lengths */ + uint32_t dataLength; + uint32_t compRLength; /* compressed lengths */ + uint32_t compDLength; unsigned short rsrcCRC; /* crc of rsrc fork */ unsigned short dataCRC; /* crc of data fork */ char reserved[6]; diff --git a/macunpack/stf.c b/macunpack/stf.c index a42f11d..c9f12a9 100644 --- a/macunpack/stf.c +++ b/macunpack/stf.c @@ -25,12 +25,12 @@ static void stf_wrfork(); static void stf_construct(); void -stf (unsigned long ibytes) +stf (uint32_t ibytes) { char magic[3], fauth[5], ftype[5]; int filel, i; unsigned int rsrcLength, dataLength; - unsigned long curtime; + uint32_t curtime; set_huffman(HUFF_LE); for(i = 0; i < 3; i++) { @@ -58,19 +58,19 @@ stf (unsigned long ibytes) for(i = 0; i < 4; i++) { info[I_AUTHOFF + i] = getb(infp); } - curtime = (unsigned long)time((time_t *)0) + TIMEDIFF; + curtime = (uint32_t)time((time_t *)0) + TIMEDIFF; put4(info + I_CTIMOFF, curtime); put4(info + I_MTIMOFF, curtime); rsrcLength = 0; for(i = 0; i < 4; i++) { rsrcLength = (rsrcLength << 8) + getb(infp); } - put4(info + I_RLENOFF, (unsigned long)rsrcLength); + put4(info + I_RLENOFF, (uint32_t)rsrcLength); dataLength = 0; for(i = 0; i < 4; i++) { dataLength = (dataLength << 8) + getb(infp); } - put4(info + I_DLENOFF, (unsigned long)dataLength); + put4(info + I_DLENOFF, (uint32_t)dataLength); ibytes -= filel + 20; write_it = 1; if(list) { @@ -79,8 +79,8 @@ stf (unsigned long ibytes) transname(info + I_AUTHOFF, fauth, 4); do_indent(indent); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)dataLength, (long)rsrcLength); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength); if(info_only) { write_it = 0; } @@ -90,13 +90,13 @@ stf (unsigned long ibytes) (void)fputc('\n', stderr); } } - stf_wrfile((unsigned long)rsrcLength, (unsigned long)dataLength, ibytes); + stf_wrfile((uint32_t)rsrcLength, (uint32_t)dataLength, ibytes); } static void -stf_wrfile (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) { define_name(text); @@ -118,7 +118,7 @@ stf_wrfile (unsigned long rsrcLength, unsigned long dataLength, unsigned long ib } 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; char *tmp_out_ptr; @@ -157,7 +157,7 @@ stf_wrfork (unsigned long *num, unsigned long towrite, int offs) stf_construct(32); tmp_out_ptr = out_ptr; out_ptr = length; - de_huffman((unsigned long)256); + de_huffman((uint32_t)256); out_ptr = tmp_out_ptr; for(i = 1; i < 257; i++) { table[i].num = 0x40000000 >> length[i - 1]; @@ -181,7 +181,7 @@ stf_wrfork (unsigned long *num, unsigned long towrite, int offs) if(i > towrite - *num) { i = towrite - *num; } - de_huffman((unsigned long)i); + de_huffman((uint32_t)i); *num += i; } } diff --git a/macunpack/stf.h b/macunpack/stf.h index 839f3b9..df669d8 100644 --- a/macunpack/stf.h +++ b/macunpack/stf.h @@ -1,5 +1,8 @@ #include "macunpack.h" #ifdef STF + +#include + #define MAGIC "RTH" #define S_MAGIC 0 @@ -11,9 +14,9 @@ typedef struct stf_fileHdr { char magic[3]; char flength; char fname[32]; /* actually flength */ - unsigned long rsrcLength; - unsigned long dataLength; + uint32_t rsrcLength; + uint32_t dataLength; } stf_fileHdr; -void stf (unsigned long ibytes); +void stf (uint32_t ibytes); #endif \ No newline at end of file diff --git a/macunpack/zma.c b/macunpack/zma.c index 7756aed..dbf5b62 100644 --- a/macunpack/zma.c +++ b/macunpack/zma.c @@ -17,8 +17,8 @@ extern void de_lzh(); static char *zma_archive; static char *zma_current; static char *zma_filestart; -static unsigned long zma_length; -static long zma_archlength; +static uint32_t zma_length; +static int32_t zma_archlength; static int zma_filehdr(); static void zma_folder(); @@ -28,7 +28,7 @@ static void zma_nocomp(); static void zma_lzh(); void -zma (char *start, unsigned long length) +zma (char *start, uint32_t length) { struct zma_fileHdr filehdr; 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_AUTH, fauth, 4); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", text, ftype, fauth, - (long)f->dataLength, (long)f->rsrcLength); + (int32_t)f->dataLength, (int32_t)f->rsrcLength); } switch(f->what) { case z_plug: @@ -322,7 +322,7 @@ zma_mooz (struct zma_fileHdr filehdr) } 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(verbose) { @@ -361,7 +361,7 @@ zma_wrfile (unsigned long ibytes, unsigned long obytes, int type) /* No compression */ /*---------------------------------------------------------------------------*/ static void -zma_nocomp (unsigned long ibytes) +zma_nocomp (uint32_t ibytes) { int n = ibytes; char *ptr = out_buffer; @@ -375,10 +375,10 @@ zma_nocomp (unsigned long ibytes) /* LZ compression plus Huffman encoding */ /*---------------------------------------------------------------------------*/ static void -zma_lzh (unsigned long ibytes) +zma_lzh (uint32_t ibytes) { /* Controlled by ibutes only */ - de_lzh((long)ibytes, (long)(-1), &zma_filestart, 13); + de_lzh((int32_t)ibytes, (int32_t)(-1), &zma_filestart, 13); } #else /* ZMA */ int zma; /* keep lint and some compilers happy */ diff --git a/macunpack/zma.h b/macunpack/zma.h index 297d8a2..02e23da 100644 --- a/macunpack/zma.h +++ b/macunpack/zma.h @@ -1,5 +1,7 @@ #include "zmahdr.h" +#include + #define Z_HDRSIZE 78 #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 */ unsigned char hlen ; /* Header length */ unsigned short boolFlags; /* Boolean flags */ - unsigned long next; /* Next entry */ - unsigned long compRLength; /* The compressed lengths. */ - unsigned long compDLength; /* For dirs, the second is # entries */ - unsigned long rsrcLength; /* The uncompressed lengths. */ - unsigned long dataLength; - unsigned long fType; /* file type */ - unsigned long fCreator; /* er... */ - unsigned long modDate; /* !restored-compat w/backup prgms */ - unsigned long comment; /* Comment offset */ + uint32_t next; /* Next entry */ + uint32_t compRLength; /* The compressed lengths. */ + uint32_t compDLength; /* For dirs, the second is # entries */ + uint32_t rsrcLength; /* The uncompressed lengths. */ + uint32_t dataLength; + uint32_t fType; /* file type */ + uint32_t fCreator; /* er... */ + uint32_t modDate; /* !restored-compat w/backup prgms */ + uint32_t comment; /* Comment offset */ unsigned short FndrFlags; /* copy of Finder flags. For our purposes, we can clear: busy,onDesk */ @@ -41,7 +43,7 @@ typedef struct zma_fileHdr { /* 78 bytes */ unsigned short rsrcCRC; /* Resource fork crc */ unsigned char fName[32]; /* a STR32 */ /* The following are overlayed in the original structure */ - unsigned long conts; /* Pointer to directory contents */ + uint32_t conts; /* Pointer to directory contents */ } zma_fileHdr; /* zma types (see what) */ diff --git a/mixed/macbinary.c b/mixed/macbinary.c index f841b1c..12e5f7e 100644 --- a/mixed/macbinary.c +++ b/mixed/macbinary.c @@ -49,8 +49,8 @@ macbinary (void) } #endif /* SCAN */ if(header[0] == 0 /* MORE CHECKS HERE! */) { - mcb(header, (unsigned long)in_rsrc_size, - (unsigned long)in_data_size, in_ds + in_rs); + mcb(header, (uint32_t)in_rsrc_size, + (uint32_t)in_data_size, in_ds + in_rs); continue; } else { (void)fprintf(stderr, "Unrecognized header.\n"); diff --git a/mixed/macstream.c b/mixed/macstream.c index 85237af..344d35e 100644 --- a/mixed/macstream.c +++ b/mixed/macstream.c @@ -101,8 +101,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; diff --git a/mixed/mcb.c b/mixed/mcb.c index 688f4de..016a1f4 100644 --- a/mixed/mcb.c +++ b/mixed/mcb.c @@ -9,7 +9,7 @@ static int mcb_read; static void mcb_wrfile(); 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; int n; @@ -37,8 +37,8 @@ mcb (char *hdr, unsigned long rsrcLength, unsigned long dataLength, int toread) transname(hdr + I_AUTHOFF, fauth, 4); do_indent(indent); (void)fprintf(stderr, - "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld", - text, ftype, fauth, (long)dataLength, (long)rsrcLength); + "name=\"%s\", type=%4.4s, author=%4.4s, data=%d, rsrc=%d", + text, ftype, fauth, (int32_t)dataLength, (int32_t)rsrcLength); if(info_only) { write_it = 0; } @@ -65,7 +65,7 @@ mcb (char *hdr, unsigned long rsrcLength, unsigned long dataLength, int toread) } static void -mcb_wrfile (unsigned long ibytes) +mcb_wrfile (uint32_t ibytes) { int n; diff --git a/util/util.c b/util/util.c index cab0e5e..c230e44 100644 --- a/util/util.c +++ b/util/util.c @@ -10,10 +10,10 @@ 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; - long value = 0; + int32_t value = 0; for(i = 0; i < 4; i++) { value <<= 8; @@ -24,10 +24,10 @@ unsigned long get4(char *bp) } /* For if integers are stored wrong-endian. */ -unsigned long get4i(char *bp) +uint32_t get4i(char *bp) { register int i; - long value = 0; + int32_t value = 0; bp += 3; for (i = 0; i < 4; i++) { @@ -38,7 +38,7 @@ unsigned long get4i(char *bp) return value; } -unsigned long get2(char *bp) +uint32_t get2(char *bp) { register int i; int value = 0; @@ -52,10 +52,10 @@ unsigned long get2(char *bp) } /* For if integers are stored wrong-endian. */ -unsigned long get2i(char *bp) +uint32_t get2i(char *bp) { register int i; - long value = 0; + int32_t value = 0; bp += 1; for(i = 0; i < 2; i++) { @@ -109,7 +109,7 @@ do_query (void) } void -put4 (char *dest, unsigned long value) +put4 (char *dest, uint32_t value) { *dest++ = (value >> 24) & BYTEMASK; *dest++ = (value >> 16) & BYTEMASK; @@ -118,7 +118,7 @@ put4 (char *dest, unsigned long value) } void -put2 (char *dest, unsigned long value) +put2 (char *dest, uint32_t value) { *dest++ = (value >> 8) & BYTEMASK; *dest++ = value & BYTEMASK; @@ -134,8 +134,8 @@ do_indent (int indent) } } -real_time set_time(year, month, day, hours, minutes, seconds) -int year, month, day, hours, minutes, seconds; +real_time +set_time (int year, int month, int day, int hours, int minutes, int seconds) { real_time toset; @@ -148,10 +148,10 @@ int year, month, day, hours, minutes, seconds; return toset; } -unsigned long tomactime(time) -real_time time; +uint32_t +tomactime (real_time time) { - long accum; + int32_t accum; int year; accum = time.month - 3; @@ -166,10 +166,10 @@ real_time time; return (unsigned)accum; } -real_time frommactime(accum) -unsigned long accum; +real_time +frommactime (uint32_t accum) { -long tmp1, tmp2; +int32_t tmp1, tmp2; real_time time; time.seconds = tmp1 = accum % 60; @@ -178,7 +178,7 @@ real_time time; accum /= 60; time.hours = tmp1 = accum % 24; accum /= 24; - tmp1 = (long)accum - 60; + tmp1 = (int32_t)accum - 60; tmp2 = tmp1 % 1461; if(tmp2 < 0) { tmp2 += 1461; diff --git a/util/util.h b/util/util.h index 90112be..4dbbec9 100644 --- a/util/util.h +++ b/util/util.h @@ -1,3 +1,5 @@ +#include + typedef struct real_time { int year; int month; @@ -7,17 +9,17 @@ typedef struct real_time { int seconds; } real_time; -extern unsigned long get4(); -extern unsigned long get4i(); -extern unsigned long get2(); -extern unsigned long get2i(); -extern unsigned char getb(); -extern void copy(); -extern int do_query(); -extern void put4(); -extern void put2(); -extern void do_indent(); -extern real_time set_time(); -extern unsigned long tomactime(); -extern real_time frommactime(); +extern uint32_t get4(char *bp); +extern uint32_t get4i(char *bp); +extern uint32_t get2(char *bp); +extern uint32_t get2i(char *bp); +extern unsigned char getb(FILE *fp); +extern void copy(char *d, char *s, int n); +extern int do_query(void); +extern void put4(char *dest, uint32_t value); +extern void put2(char *dest, uint32_t value); +extern void do_indent(int indent); +extern real_time set_time(int year, int month, int day, int hours, int minutes, int seconds); +extern uint32_t tomactime(real_time time); +extern real_time frommactime(uint32_t accum);