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) {
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;

View File

@ -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");

View File

@ -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;

View File

@ -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) {

View File

@ -31,6 +31,7 @@
/* ZIP used by COMPACTOR */
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@ -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, " ");

View File

@ -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 */

View File

@ -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) */

View File

@ -1,7 +1,9 @@
#include <stdint.h>
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);

View File

@ -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);

View File

@ -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");

View File

@ -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);

View File

@ -11,9 +11,9 @@
#include <stdlib.h>
static long dl_fork();
static int nchar();
static int nextc();
static int32_t dl_fork(void);
static int nchar(void);
static int nextc(void);
static char *icp = &line[0];
@ -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;

View File

@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#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;

View File

@ -13,7 +13,7 @@
#include <stdlib.h>
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) {

View File

@ -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 {

View File

@ -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();

View File

@ -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) {

View File

@ -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);
}
}

View File

@ -1,3 +1,5 @@
#include <stdint.h>
#define MAGIC1 0 /* Should be 0x1b, marks Mac extension */
#define KIND 1 /* KIND == 0 marks end of archive */
#define FNAME 2
@ -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

View File

@ -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;

View File

@ -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) {

View File

@ -1,3 +1,5 @@
#include <stdint.h>
#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);

View File

@ -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,

View File

@ -1,6 +1,9 @@
#include "macunpack.h"
#ifdef DD
#include <stdint.h>
#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

View File

@ -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<<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;
@ -45,11 +45,11 @@ static int clear_flg = 0;
static int toread;
void de_compress(unsigned long ibytes, int mb)
void de_compress(uint32_t ibytes, int mb)
{
register unsigned char *stackp;
register int finchar;
register long code, oldcode, incode;
register int32_t code, oldcode, incode;
toread = ibytes;
maxbits = mb;
@ -124,10 +124,10 @@ static char *core_ptr;
static int file_bytes();
static int core_bytes();
static long
static int32_t