mirror of
https://github.com/LIV2/WinUAE.git
synced 2025-12-06 00:12:52 +00:00
imported winuaesrc2020b11.zip
This commit is contained in:
parent
2c0212330b
commit
dddda49513
@ -515,7 +515,7 @@ static void chip_init (void)
|
||||
uaenet_close (sysdata);
|
||||
if (td != NULL) {
|
||||
if (!sysdata)
|
||||
sysdata = xcalloc (uaenet_getdatalenght(), 1);
|
||||
sysdata = xcalloc (uae_u8, uaenet_getdatalenght());
|
||||
if (!uaenet_open (sysdata, td, NULL, gotfunc, getfunc, prom)) {
|
||||
write_log (L"A2065: failed to initialize winpcap driver\n");
|
||||
}
|
||||
@ -719,7 +719,7 @@ static void REGPARAM2 a2065_lput (uaecptr addr, uae_u32 l)
|
||||
a2065_wput (addr + 2, l);
|
||||
}
|
||||
|
||||
static addrbank a2065_bank;
|
||||
extern addrbank a2065_bank;
|
||||
|
||||
static void REGPARAM2 a2065_bput (uaecptr addr, uae_u32 b)
|
||||
{
|
||||
@ -1205,7 +1205,7 @@ int addscsi (int ch, TCHAR *path, int blocksize, int readonly,
|
||||
|
||||
freescsi (scsis[ch]);
|
||||
scsis[ch] = NULL;
|
||||
hfd = xcalloc (sizeof (struct hd_hardfiledata), 1);
|
||||
hfd = xcalloc (struct hd_hardfiledata, 1);
|
||||
if (!hdf_hd_open (hfd, path, blocksize, readonly, devname, sectors, surfaces, reserved, bootpri, filesys))
|
||||
return 0;
|
||||
hfd->ansi_version = scsi_level;
|
||||
@ -1350,7 +1350,7 @@ void a2091_init (void)
|
||||
if (z) {
|
||||
write_log (L"A590/A2091 BOOT ROM %d.%d ", rd->ver, rd->rev);
|
||||
rom_size = rd->size;
|
||||
rom = xmalloc (rom_size);
|
||||
rom = xmalloc (uae_u8, rom_size);
|
||||
if (rl->rd->id == 56)
|
||||
rombankswitcher = 1;
|
||||
zfile_fread (rom, rom_size, 1, z);
|
||||
@ -800,7 +800,7 @@ static int cdrom_command_status (void)
|
||||
if (unitnum >= 0)
|
||||
cdrom_toc ();
|
||||
/* firmware info */
|
||||
strcpy (cdrom_result_buffer + 2, FIRMWAREVERSION);
|
||||
memcpy (cdrom_result_buffer + 2, FIRMWAREVERSION, sizeof FIRMWAREVERSION);
|
||||
cdrom_result_buffer[0] = cdrom_command;
|
||||
cd_initialized = 1;
|
||||
return 20;
|
||||
@ -1694,10 +1694,10 @@ int akiko_init (void)
|
||||
}
|
||||
if (!sys_cddev_open ()) {
|
||||
cdromok = 1;
|
||||
sector_buffer_1 = xmalloc (SECTOR_BUFFER_SIZE * 2048);
|
||||
sector_buffer_2 = xmalloc (SECTOR_BUFFER_SIZE * 2048);
|
||||
sector_buffer_info_1 = xmalloc (SECTOR_BUFFER_SIZE);
|
||||
sector_buffer_info_2 = xmalloc (SECTOR_BUFFER_SIZE);
|
||||
sector_buffer_1 = xmalloc (uae_u8, SECTOR_BUFFER_SIZE * 2048);
|
||||
sector_buffer_2 = xmalloc (uae_u8, SECTOR_BUFFER_SIZE * 2048);
|
||||
sector_buffer_info_1 = xmalloc (uae_u8, SECTOR_BUFFER_SIZE);
|
||||
sector_buffer_info_2 = xmalloc (uae_u8, SECTOR_BUFFER_SIZE);
|
||||
sector_buffer_sector_1 = -1;
|
||||
sector_buffer_sector_2 = -1;
|
||||
}
|
||||
@ -1725,7 +1725,7 @@ uae_u8 *save_akiko(int *len)
|
||||
if (!currprefs.cs_cd32cd)
|
||||
return NULL;
|
||||
|
||||
dstbak = dst = malloc (1000);
|
||||
dstbak = dst = xmalloc (uae_u8, 1000);
|
||||
save_u16 (0);
|
||||
save_u16 (0xCAFE);
|
||||
save_u32 (cdrom_intreq);
|
||||
@ -147,7 +147,7 @@ void amax_init (void)
|
||||
zfile_fseek (z, 0, SEEK_END);
|
||||
rom_size = zfile_ftell (z);
|
||||
zfile_fseek (z, 0, SEEK_SET);
|
||||
rom = xmalloc (rom_size);
|
||||
rom = xmalloc (uae_u8, rom_size);
|
||||
zfile_fread (rom, rom_size, 1, z);
|
||||
zfile_fclose (z);
|
||||
write_log (L"AMAX: '%s' loaded, %d bytes\n", currprefs.amaxromfile, rom_size);
|
||||
@ -1662,7 +1662,7 @@ int action_replay_load (void)
|
||||
return 0;
|
||||
}
|
||||
action_replay_flag = ACTION_REPLAY_INACTIVE;
|
||||
armemory_rom = xmalloc (ar_rom_file_size);
|
||||
armemory_rom = xmalloc (uae_u8, ar_rom_file_size);
|
||||
zfile_fread (armemory_rom, 1, ar_rom_file_size, f);
|
||||
zfile_fclose (f);
|
||||
if (ar_rom_file_size == 65536) {
|
||||
@ -1681,7 +1681,7 @@ int action_replay_load (void)
|
||||
}
|
||||
arram_mask = arram_size - 1;
|
||||
arrom_mask = arrom_size - 1;
|
||||
armemory_ram = xcalloc (arram_size, 1);
|
||||
armemory_ram = xcalloc (uae_u8, arram_size);
|
||||
write_log (L"Action Replay %d installed at %08X, size %08X\n", armodel, arrom_start, arrom_size);
|
||||
action_replay_version();
|
||||
return armodel;
|
||||
@ -1739,7 +1739,7 @@ void action_replay_cleanup()
|
||||
#endif
|
||||
|
||||
#ifdef ACTION_REPLAY_HRTMON
|
||||
#include "hrtmon.rom.c"
|
||||
#include "hrtmon.rom.cpp"
|
||||
#endif
|
||||
|
||||
int hrtmon_lang = 0;
|
||||
@ -2072,7 +2072,7 @@ uae_u8 *save_action_replay (int *len, uae_u8 *dstptr)
|
||||
if (dstptr)
|
||||
dstbak = dst = dstptr;
|
||||
else
|
||||
dstbak = dst = malloc (arram_size + sizeof ar_custom + sizeof ar_ciaa + sizeof ar_ciab + 1024);
|
||||
dstbak = dst = xmalloc (uae_u8, arram_size + sizeof ar_custom + sizeof ar_ciaa + sizeof ar_ciab + 1024);
|
||||
save_u8 (0);
|
||||
save_u8 (armodel);
|
||||
save_u32 (get_crc32 (armemory_rom + 4, arrom_size - 4));
|
||||
@ -38,7 +38,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
static void multigame(int);
|
||||
static void multigame (int);
|
||||
|
||||
int arcadia_flag, arcadia_coin[2];
|
||||
struct arcadiarom *arcadia_bios, *arcadia_game;
|
||||
@ -91,7 +91,7 @@ static int load_rom8 (TCHAR *xpath, uae_u8 *mem, int extra)
|
||||
struct zfile *zf;
|
||||
TCHAR path[MAX_DPATH];
|
||||
int i;
|
||||
uae_u8 *tmp = xmalloc (131072);
|
||||
uae_u8 *tmp = xmalloc (uae_u8, 131072);
|
||||
TCHAR *bin = extra == 1 ? L".bin" : L"";
|
||||
|
||||
memset (tmp, 0, 131072);
|
||||
@ -397,7 +397,7 @@ int arcadia_map_banks (void)
|
||||
{
|
||||
if (!arcadia_bios)
|
||||
return 0;
|
||||
arbmemory = (uae_u8*)xmalloc (allocated_arbmemory);
|
||||
arbmemory = xmalloc (uae_u8, allocated_arbmemory);
|
||||
arbbmemory = arbmemory + bios_offset;
|
||||
memset (arbmemory, 0, allocated_arbmemory);
|
||||
if (!load_roms (arcadia_bios)) {
|
||||
@ -47,7 +47,7 @@ static int passfound, passretries;
|
||||
static TCHAR modes[7][7]={L"NOCOMP",L"SIMPLE",L"QUICK ",L"MEDIUM",L"DEEP ",L"HEAVY1",L"HEAVY2"};
|
||||
static USHORT PWDCRC;
|
||||
|
||||
UCHAR *text;
|
||||
static UCHAR *text;
|
||||
|
||||
static void log_error(int track)
|
||||
{
|
||||
@ -84,14 +84,14 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o
|
||||
|
||||
passfound = 0;
|
||||
passretries = 2;
|
||||
b1 = (UCHAR *)calloc((size_t)TRACK_BUFFER_LEN,1);
|
||||
b1 = xcalloc(UCHAR,TRACK_BUFFER_LEN);
|
||||
if (!b1) return ERR_NOMEMORY;
|
||||
b2 = (UCHAR *)calloc((size_t)TRACK_BUFFER_LEN,1);
|
||||
b2 = xcalloc(UCHAR,TRACK_BUFFER_LEN);
|
||||
if (!b2) {
|
||||
free(b1);
|
||||
return ERR_NOMEMORY;
|
||||
}
|
||||
text = (UCHAR *)calloc((size_t)TEMP_BUFFER_LEN,1);
|
||||
text = xcalloc(UCHAR,TEMP_BUFFER_LEN);
|
||||
if (!text) {
|
||||
free(b1);
|
||||
free(b2);
|
||||
@ -365,7 +365,7 @@ static USHORT Process_Track(struct zfile *fi, struct zfile *fo, UCHAR *b1, UCHAR
|
||||
// did we have another cylinder 0 already?
|
||||
uae_u8 *p;
|
||||
zfile_fseek (fo, 0, SEEK_SET);
|
||||
p = xcalloc (512 * 22, 1);
|
||||
p = xcalloc (uae_u8, 512 * 22);
|
||||
zfile_fread (p, 512 * 22, 1, fo);
|
||||
addextra(L"BigFakeBootBlock", extra, p, 512 * 22);
|
||||
xfree (p);
|
||||
@ -535,7 +535,7 @@ static void printbandiz(UCHAR *m, USHORT len){
|
||||
if (*i == 10) {
|
||||
TCHAR *u;
|
||||
*i=0;
|
||||
u = au (j);
|
||||
u = au ((char*)j);
|
||||
write_log (L"%s\n",u);
|
||||
xfree (u);
|
||||
j=i+1;
|
||||
@ -38,13 +38,13 @@ int init_deep_tabs=1;
|
||||
#define MAX_FREQ 0x8000 /* updates tree when the */
|
||||
|
||||
|
||||
USHORT freq[T + 1]; /* frequency table */
|
||||
static USHORT freq[T + 1]; /* frequency table */
|
||||
|
||||
USHORT prnt[T + N_CHAR]; /* pointers to parent nodes, except for the */
|
||||
static USHORT prnt[T + N_CHAR]; /* pointers to parent nodes, except for the */
|
||||
/* elements [T..T + N_CHAR - 1] which are used to get */
|
||||
/* the positions of leaves corresponding to the codes. */
|
||||
|
||||
USHORT son[T]; /* pointers to child nodes (son[], son[] + 1) */
|
||||
static USHORT son[T]; /* pointers to child nodes (son[], son[] + 1) */
|
||||
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
#define N1 510
|
||||
#define OFFSET 253
|
||||
|
||||
USHORT left[2 * NC - 1], right[2 * NC - 1 + 9];
|
||||
static USHORT left[2 * NC - 1], right[2 * NC - 1 + 9];
|
||||
static UCHAR c_len[NC], pt_len[NPT];
|
||||
static USHORT c_table[4096], pt_table[256];
|
||||
USHORT lastlen, np;
|
||||
@ -51,9 +51,7 @@ put_indicator(count)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
unsigned short
|
||||
calccrc(p, n)
|
||||
unsigned char *p;
|
||||
unsigned int n;
|
||||
calccrc(unsigned char *p, unsigned int n)
|
||||
{
|
||||
reading_size += n;
|
||||
#ifdef NEED_INCREMENTAL_INDICATOR
|
||||
@ -66,8 +64,7 @@ calccrc(p, n)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
void
|
||||
fillbuf(n) /* Shift bitbuf n bits left, read n bits */
|
||||
unsigned char n;
|
||||
fillbuf(unsigned char n) /* Shift bitbuf n bits left, read n bits */
|
||||
{
|
||||
while (n > bitcount) {
|
||||
n -= bitcount;
|
||||
@ -87,8 +84,7 @@ fillbuf(n) /* Shift bitbuf n bits left, read n bits */
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
unsigned short
|
||||
getbits(n)
|
||||
unsigned char n;
|
||||
getbits(unsigned char n)
|
||||
{
|
||||
unsigned short x;
|
||||
|
||||
@ -154,10 +150,7 @@ putbits(n, x) /* Write rightmost n bits of x */
|
||||
#endif
|
||||
/* ------------------------------------------------------------------------ */
|
||||
int
|
||||
fread_crc(p, n, fp)
|
||||
unsigned char *p;
|
||||
int n;
|
||||
struct zfile *fp;
|
||||
fread_crc(unsigned char *p, int n, struct zfile *fp)
|
||||
{
|
||||
n = zfile_fread(p, 1, n, fp);
|
||||
|
||||
@ -167,10 +160,7 @@ fread_crc(p, n, fp)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
void
|
||||
fwrite_crc(p, n, fp)
|
||||
unsigned char *p;
|
||||
int n;
|
||||
struct zfile *fp;
|
||||
fwrite_crc(unsigned char *p, int n, struct zfile *fp)
|
||||
{
|
||||
calccrc(p, n);
|
||||
if (verify_mode)
|
||||
@ -183,7 +173,7 @@ fwrite_crc(p, n, fp)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
void
|
||||
init_code_cache( /* void */ )
|
||||
init_code_cache(void)
|
||||
{ /* called from copyfile() in util.c */
|
||||
#ifdef EUC
|
||||
putc_euc_cache = EOF;
|
||||
@ -192,7 +182,7 @@ init_code_cache( /* void */ )
|
||||
}
|
||||
|
||||
void
|
||||
init_getbits( /* void */ )
|
||||
init_getbits(void)
|
||||
{
|
||||
lhabitbuf = 0;
|
||||
subbitbuf = 0;
|
||||
@ -255,10 +245,7 @@ putc_euc(c, fd)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
int
|
||||
fwrite_txt(p, n, fp)
|
||||
unsigned char *p;
|
||||
int n;
|
||||
FILE *fp;
|
||||
fwrite_txt(unsigned char *p, int n, FILE *fp)
|
||||
{
|
||||
while (--n >= 0) {
|
||||
if (*p != '\015' && *p != '\032') {
|
||||
@ -276,10 +263,7 @@ fwrite_txt(p, n, fp)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
int
|
||||
fread_txt(p, n, fp)
|
||||
unsigned char *p;
|
||||
int n;
|
||||
FILE *fp;
|
||||
fread_txt(unsigned char *p, int n, FILE *fp)
|
||||
{
|
||||
int c;
|
||||
int cnt = 0;
|
||||
@ -337,9 +321,7 @@ fread_txt(p, n, fp)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
unsigned short
|
||||
calc_header_crc(p, n) /* Thanks T.Okamoto */
|
||||
unsigned char *p;
|
||||
unsigned int n;
|
||||
calc_header_crc(unsigned char *p, unsigned int n) /* Thanks T.Okamoto */
|
||||
{
|
||||
crc = 0;
|
||||
while (n-- > 0)
|
||||
@ -21,7 +21,7 @@ static int most_p, nn;
|
||||
static unsigned long nextcount;
|
||||
/* ------------------------------------------------------------------------ */
|
||||
void
|
||||
start_c_dyn( /* void */ )
|
||||
start_c_dyn(void)
|
||||
{
|
||||
int i, j, f;
|
||||
|
||||
@ -56,7 +56,7 @@ start_c_dyn( /* void */ )
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static void
|
||||
start_p_dyn( /* void */ )
|
||||
start_p_dyn(void)
|
||||
{
|
||||
freq[ROOT_P] = 1;
|
||||
child[ROOT_P] = ~(N_CHAR);
|
||||
@ -70,7 +70,7 @@ start_p_dyn( /* void */ )
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
void
|
||||
decode_start_dyn( /* void */ )
|
||||
decode_start_dyn(void)
|
||||
{
|
||||
n_max = 286;
|
||||
maxmatch = MAXMATCH;
|
||||
@ -81,9 +81,7 @@ decode_start_dyn( /* void */ )
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static void
|
||||
reconst(start, end)
|
||||
int start;
|
||||
int end;
|
||||
reconst(int start, int end)
|
||||
{
|
||||
int i, j, k, l, b;
|
||||
unsigned int f, g;
|
||||
@ -137,8 +135,7 @@ reconst(start, end)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static int
|
||||
swap_inc(p)
|
||||
int p;
|
||||
swap_inc(int p)
|
||||
{
|
||||
int b, q, r, s;
|
||||
|
||||
@ -178,8 +175,7 @@ Adjust:
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static void
|
||||
update_c(p)
|
||||
int p;
|
||||
update_c(int p)
|
||||
{
|
||||
int q;
|
||||
|
||||
@ -195,8 +191,7 @@ update_c(p)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static void
|
||||
update_p(p)
|
||||
int p;
|
||||
update_p(int p)
|
||||
{
|
||||
int q;
|
||||
|
||||
@ -214,8 +209,7 @@ update_p(p)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static void
|
||||
make_new_node(p)
|
||||
int p;
|
||||
make_new_node(int p)
|
||||
{
|
||||
int q, r;
|
||||
|
||||
@ -269,7 +263,7 @@ encode_c_dyn(c)
|
||||
#endif
|
||||
/* ------------------------------------------------------------------------ */
|
||||
unsigned short
|
||||
decode_c_dyn( /* void */ )
|
||||
decode_c_dyn(void)
|
||||
{
|
||||
int c;
|
||||
short buf, cnt;
|
||||
@ -296,7 +290,7 @@ decode_c_dyn( /* void */ )
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
unsigned short
|
||||
decode_p_dyn( /* void */ )
|
||||
decode_p_dyn(void)
|
||||
{
|
||||
int c;
|
||||
short buf, cnt;
|
||||
@ -16,10 +16,7 @@
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static char *get_ptr;
|
||||
/* ------------------------------------------------------------------------ */
|
||||
int
|
||||
calc_sum(p, len)
|
||||
register char *p;
|
||||
register int len;
|
||||
int calc_sum(char *p, int len)
|
||||
{
|
||||
register int sum;
|
||||
|
||||
@ -30,8 +27,7 @@ calc_sum(p, len)
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static unsigned short
|
||||
get_word ()
|
||||
static unsigned short get_word (void)
|
||||
{
|
||||
int b0, b1;
|
||||
|
||||
@ -41,17 +37,14 @@ get_word ()
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static void
|
||||
put_word (v)
|
||||
unsigned int v;
|
||||
static void put_word (unsigned int v)
|
||||
{
|
||||
put_byte (v);
|
||||
put_byte (v >> 8);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static long
|
||||
get_longword()
|
||||
static long get_longword(void)
|
||||
{
|
||||
long b0, b1, b2, b3;
|
||||
|
||||
@ -63,9 +56,7 @@ get_longword()
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static void
|
||||
put_longword(v)
|
||||
long v;
|
||||
static void put_longword(long v)
|
||||
{
|
||||
put_byte (v);
|
||||
put_byte (v >> 8);
|
||||
@ -74,10 +65,7 @@ put_longword(v)
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static void
|
||||
msdos_to_unix_filename(name, len)
|
||||
register char *name;
|
||||
register int len;
|
||||
static void msdos_to_unix_filename(char *name, int len)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@ -102,10 +90,7 @@ msdos_to_unix_filename(name, len)
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static void
|
||||
generic_to_unix_filename(name, len)
|
||||
register char *name;
|
||||
register int len;
|
||||
static void generic_to_unix_filename(char *name, int len)
|
||||
{
|
||||
register int i;
|
||||
boolean lower_case_used = FALSE;
|
||||
@ -146,9 +131,7 @@ generic_to_unix_filename(name, len)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static void
|
||||
macos_to_unix_filename(name, len)
|
||||
register char *name;
|
||||
register int len;
|
||||
macos_to_unix_filename(char *name, int len)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@ -162,9 +145,7 @@ macos_to_unix_filename(name, len)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static void
|
||||
unix_to_generic_filename(name, len)
|
||||
register char *name;
|
||||
register int len;
|
||||
unix_to_generic_filename(char *name, int len)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@ -302,9 +283,7 @@ msdos_to_unix_stamp_tm(a)
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static time_t
|
||||
generic_to_unix_stamp(t)
|
||||
long t;
|
||||
static time_t generic_to_unix_stamp(long t)
|
||||
#if defined(MKTIME) || defined(TIMELOCAL)
|
||||
{
|
||||
struct tm dostm;
|
||||
@ -320,8 +299,8 @@ generic_to_unix_stamp(t)
|
||||
dostm.tm_min = t >> 5 & 0x3f;
|
||||
dostm.tm_hour = t >> 11 & 0x1f;
|
||||
dostm.tm_mday = t >> 16 & 0x1f;
|
||||
dostm.tm_mon = (t >> 16 + 5 & 0x0f) - 1; /* 0..11 */
|
||||
dostm.tm_year = (t >> 16 + 9 & 0x7f) + 80;
|
||||
dostm.tm_mon = ((t >> 16) + 5 & 0x0f) - 1; /* 0..11 */
|
||||
dostm.tm_year = ((t >> 16) + 9 & 0x7f) + 80;
|
||||
#if 0
|
||||
dostm.tm_isdst = 0; /* correct? */
|
||||
#endif
|
||||
@ -377,9 +356,7 @@ generic_to_unix_stamp(t)
|
||||
#endif /* defined(MKTIME) || defined(TIMELOCAL) */
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static long
|
||||
unix_to_generic_stamp(t)
|
||||
time_t t;
|
||||
static long unix_to_generic_stamp(time_t t)
|
||||
{
|
||||
struct tm *tm = localtime(&t);
|
||||
|
||||
@ -394,10 +371,7 @@ unix_to_generic_stamp(t)
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* build header functions */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
boolean
|
||||
get_header(fp, hdr)
|
||||
struct zfile *fp;
|
||||
register LzHeader *hdr;
|
||||
boolean get_header(struct zfile *fp, LzHeader *hdr)
|
||||
{
|
||||
int header_size;
|
||||
int name_length;
|
||||
@ -554,7 +528,7 @@ get_header(fp, hdr)
|
||||
for (i = 0; i < header_size - 3; i++)
|
||||
dirname[i] = (char) get_byte ();
|
||||
dirname[header_size - 3] = '\0';
|
||||
convdelim(dirname, DELIM);
|
||||
convdelim((unsigned char*)dirname, DELIM);
|
||||
dir_length = header_size - 3;
|
||||
break;
|
||||
case 0x40:
|
||||
@ -663,11 +637,7 @@ get_header(fp, hdr)
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
void
|
||||
init_header(name, v_stat, hdr)
|
||||
char *name;
|
||||
struct stat *v_stat;
|
||||
LzHeader *hdr;
|
||||
void init_header(char *name, struct stat *v_stat, LzHeader *hdr)
|
||||
{
|
||||
int len;
|
||||
|
||||
@ -32,8 +32,7 @@ static int np;
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* Encording */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static void
|
||||
count_t_freq(/*void*/)
|
||||
static void count_t_freq(void)
|
||||
{
|
||||
short i, k, n, count;
|
||||
|
||||
@ -253,8 +252,7 @@ output_st1(c, p)
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
unsigned char *
|
||||
alloc_buf( /* void */ )
|
||||
unsigned char *alloc_buf(void)
|
||||
{
|
||||
bufsiz = 16 * 1024 *2; /* 65408U; */ /* t.okamoto */
|
||||
while ((buf = (unsigned char *) malloc(bufsiz)) == NULL) {
|
||||
@ -315,11 +313,7 @@ encode_end_st1( /* void */ )
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* decoding */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static void
|
||||
read_pt_len(nn, nbit, i_special)
|
||||
short nn;
|
||||
short nbit;
|
||||
short i_special;
|
||||
static void read_pt_len(short nn, short nbit, short i_special)
|
||||
{
|
||||
int i, c, n;
|
||||
|
||||
@ -352,13 +346,12 @@ read_pt_len(nn, nbit, i_special)
|
||||
}
|
||||
while (i < nn)
|
||||
pt_len[i++] = 0;
|
||||
make_table(nn, pt_len, 8, pt_table);
|
||||
lha_make_table(nn, pt_len, 8, pt_table);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static void
|
||||
read_c_len( /* void */ )
|
||||
static void read_c_len(void)
|
||||
{
|
||||
short i, c, n;
|
||||
|
||||
@ -399,13 +392,12 @@ read_c_len( /* void */ )
|
||||
}
|
||||
while (i < NC)
|
||||
c_len[i++] = 0;
|
||||
make_table(NC, c_len, 12, c_table);
|
||||
lha_make_table(NC, c_len, 12, c_table);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
unsigned short
|
||||
decode_c_st1( /*void*/ )
|
||||
unsigned short decode_c_st1(void)
|
||||
{
|
||||
unsigned short j, mask;
|
||||
|
||||
@ -435,8 +427,7 @@ decode_c_st1( /*void*/ )
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
unsigned short
|
||||
decode_p_st1( /* void */ )
|
||||
unsigned short decode_p_st1(void)
|
||||
{
|
||||
unsigned short j, mask;
|
||||
|
||||
@ -461,8 +452,7 @@ decode_p_st1( /* void */ )
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
void
|
||||
decode_start_st1( /* void */ )
|
||||
void decode_start_st1(void)
|
||||
{
|
||||
if (dicbit <= 13) {
|
||||
np = 14;
|
||||
@ -11,8 +11,7 @@
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static int flag, flagcnt, matchpos;
|
||||
/* ------------------------------------------------------------------------ */
|
||||
unsigned short
|
||||
decode_c_lzs( /*void*/ )
|
||||
unsigned short decode_c_lzs(void)
|
||||
{
|
||||
if (getbits(1)) {
|
||||
return getbits(8);
|
||||
@ -24,22 +23,19 @@ decode_c_lzs( /*void*/ )
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
unsigned short
|
||||
decode_p_lzs( /*void*/ )
|
||||
unsigned short decode_p_lzs(void)
|
||||
{
|
||||
return (loc - matchpos - MAGIC0) & 0x7ff;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
void
|
||||
decode_start_lzs( /*void*/ )
|
||||
void decode_start_lzs(void)
|
||||
{
|
||||
init_getbits();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
unsigned short
|
||||
decode_c_lz5( /*void*/ )
|
||||
unsigned short decode_c_lz5(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
@ -61,15 +57,13 @@ decode_c_lz5( /*void*/ )
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
unsigned short
|
||||
decode_p_lz5( /*void*/ )
|
||||
unsigned short decode_p_lz5(void)
|
||||
{
|
||||
return (loc - matchpos - MAGIC5) & 0xfff;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
void
|
||||
decode_start_lz5( /*void*/ )
|
||||
void decode_start_lz5(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -229,13 +229,13 @@ extern void build_standard_archive_name();
|
||||
|
||||
extern FILE *open_old_archive();
|
||||
extern void init_header();
|
||||
extern boolean get_header();
|
||||
extern boolean get_header(struct zfile *fp, LzHeader *hdr);
|
||||
extern boolean archive_is_msdos_sfx1();
|
||||
extern boolean skip_msdos_sfx1_code();
|
||||
extern void write_header();
|
||||
extern void write_archive_tail();
|
||||
extern void copy_old_one();
|
||||
extern unsigned char *convdelim();
|
||||
extern unsigned char *convdelim(unsigned char *path, unsigned char delim);
|
||||
extern long copyfile();
|
||||
|
||||
extern void cmd_list(), cmd_extract(), cmd_add(), cmd_delete();
|
||||
@ -246,7 +246,7 @@ extern char *extract_directory;
|
||||
|
||||
extern int encode_alloc();
|
||||
extern void encode();
|
||||
extern int decode();
|
||||
extern int decode(struct interfacing*);
|
||||
|
||||
/* from append.c */
|
||||
extern void start_indicator();
|
||||
@ -289,8 +289,8 @@ extern unsigned short decode_p_lz5();
|
||||
extern void decode_start_lzs();
|
||||
extern void decode_start_lz5();
|
||||
|
||||
extern void make_table( /* int nchar, uchar bitlen[], int tablebits,
|
||||
ushort table[] */ );
|
||||
extern void lha_make_table(short nchar, unsigned char bitlen[], short tablebits, unsigned short table[]);
|
||||
|
||||
|
||||
/* from maketree.c */
|
||||
/*
|
||||
@ -303,13 +303,13 @@ extern short make_tree( /* int nparm, ushort freqparm[], uchar lenparm[],
|
||||
|
||||
/* from crcio.c */
|
||||
extern void make_crctable();
|
||||
extern unsigned short calccrc( /* uchar *p, uint n */ );
|
||||
extern void fillbuf( /* uchar n */ );
|
||||
extern unsigned short getbits( /* uchar n */ );
|
||||
extern void putcode( /* uchar n, ushort x */ );
|
||||
extern void putbits( /* uchar n, ushort x */ );
|
||||
extern int fread_crc( /* uchar *p, int n, FILE *f */ );
|
||||
extern void fwrite_crc( /* uchar *p, int n, FILE *f */ );
|
||||
extern unsigned short calccrc(unsigned char *p, unsigned int n);
|
||||
extern void fillbuf(unsigned char n);
|
||||
extern unsigned short getbits(unsigned char n);
|
||||
extern void putcode(unsigned char n, unsigned short x);
|
||||
extern void putbits(unsigned char n, unsigned short x);
|
||||
extern int fread_crc(unsigned char *p, int n, struct zfile *f);
|
||||
extern void fwrite_crc(unsigned char *p, int n, struct zfile *f);
|
||||
extern void init_getbits();
|
||||
extern void init_putbits();
|
||||
extern void make_crctable();
|
||||
|
||||
@ -8,12 +8,7 @@
|
||||
/* ------------------------------------------------------------------------ */
|
||||
#include "lha.h"
|
||||
|
||||
void
|
||||
lha_make_table(nchar, bitlen, tablebits, table)
|
||||
short nchar;
|
||||
unsigned char bitlen[];
|
||||
short tablebits;
|
||||
unsigned short table[];
|
||||
void lha_make_table(short nchar, unsigned char bitlen[], short tablebits, unsigned short table[])
|
||||
{
|
||||
unsigned short count[17]; /* count of bitlen */
|
||||
unsigned short weight[17]; /* 0x10000ul >> bitlen */
|
||||
@ -129,9 +129,7 @@ init_variable() /* Added N.Watazaki */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static int
|
||||
sort_by_ascii(a, b)
|
||||
char **a, **b;
|
||||
static int sort_by_ascii(char **a, char **b)
|
||||
{
|
||||
register char *p, *q;
|
||||
register int c1, c2;
|
||||
@ -159,12 +157,9 @@ sort_by_ascii(a, b)
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
char *
|
||||
xrealloc(old, size)
|
||||
char *old;
|
||||
int size;
|
||||
char *xxrealloc(char *old, int size)
|
||||
{
|
||||
char *p = (char *) realloc(old, size);
|
||||
char *p = (char *) xrealloc(char, old, size);
|
||||
if (!p)
|
||||
fatal_error(L"Not enough memory");
|
||||
return p;
|
||||
@ -189,26 +184,20 @@ xrealloc(old, size)
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
void
|
||||
init_sp(sp)
|
||||
struct string_pool *sp;
|
||||
void init_sp(struct string_pool *sp)
|
||||
{
|
||||
sp->size = 1024 - 8; /* any ( >=0 ) */
|
||||
sp->used = 0;
|
||||
sp->n = 0;
|
||||
sp->buffer = (char *) xmalloc(sp->size * sizeof(char));
|
||||
sp->buffer = (char *) xmalloc(char, sp->size);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
void
|
||||
add_sp(sp, name, len)
|
||||
struct string_pool *sp;
|
||||
char *name; /* stored '\0' at tail */
|
||||
int len; /* include '\0' */
|
||||
void add_sp(struct string_pool *sp, char *name, int len)
|
||||
{
|
||||
while (sp->used + len > sp->size) {
|
||||
sp->size *= 2;
|
||||
sp->buffer = (char *) xrealloc(sp->buffer, sp->size * sizeof(char));
|
||||
sp->buffer = (char *) xxrealloc(sp->buffer, sp->size * sizeof(char));
|
||||
}
|
||||
bcopy(name, sp->buffer + sp->used, len);
|
||||
sp->used += len;
|
||||
@ -216,17 +205,13 @@ add_sp(sp, name, len)
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
void
|
||||
finish_sp(sp, v_count, v_vector)
|
||||
register struct string_pool *sp;
|
||||
int *v_count;
|
||||
char ***v_vector;
|
||||
void finish_sp(struct string_pool *sp, int *v_count, char ***v_vector)
|
||||
{
|
||||
int i;
|
||||
register char *p;
|
||||
char **v;
|
||||
|
||||
v = (char **) xmalloc((sp->n + 1) * sizeof(char *));
|
||||
v = (char **) xmalloc(char*, sp->n + 1);
|
||||
*v++ = sp->buffer;
|
||||
*v_vector = v;
|
||||
*v_count = sp->n;
|
||||
@ -239,9 +224,7 @@ finish_sp(sp, v_count, v_vector)
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
void
|
||||
free_sp(vector)
|
||||
char **vector;
|
||||
void free_sp(char **vector)
|
||||
{
|
||||
vector--;
|
||||
free(*vector); /* free string pool */
|
||||
@ -252,9 +235,7 @@ free_sp(vector)
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* READ DIRECTORY FILES */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static boolean
|
||||
include_path_p(path, name)
|
||||
char *path, *name;
|
||||
static boolean include_path_p(char *path, char *name)
|
||||
{
|
||||
char *n = name;
|
||||
while (*path)
|
||||
@ -21,8 +21,7 @@ int fixed[2][16] = {
|
||||
{2, 0x01, 0x01, 0x03, 0x06, 0x0D, 0x1F, 0x4E, 0} /* 8K buf */
|
||||
};
|
||||
/* ------------------------------------------------------------------------ */
|
||||
void
|
||||
decode_start_st0( /*void*/ )
|
||||
void decode_start_st0(void)
|
||||
{
|
||||
n_max = 286;
|
||||
maxmatch = MAXMATCH;
|
||||
@ -49,9 +48,7 @@ encode_p_st0(j)
|
||||
}
|
||||
#endif
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static void
|
||||
ready_made(method)
|
||||
int method;
|
||||
static void ready_made(int method)
|
||||
{
|
||||
int i, j;
|
||||
unsigned int code, weight;
|
||||
@ -87,8 +84,7 @@ encode_start_fix( /*void*/ )
|
||||
}
|
||||
#endif
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static void
|
||||
read_tree_c( /*void*/ )
|
||||
static void read_tree_c(void)
|
||||
{ /* read tree from file */
|
||||
int i, c;
|
||||
|
||||
@ -107,12 +103,11 @@ read_tree_c( /*void*/ )
|
||||
return;
|
||||
}
|
||||
}
|
||||
make_table(N1, c_len, 12, c_table);
|
||||
lha_make_table(N1, c_len, 12, c_table);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static void
|
||||
read_tree_p(/*void*/)
|
||||
static void read_tree_p(void)
|
||||
{ /* read tree from file */
|
||||
int i, c;
|
||||
|
||||
@ -135,8 +130,7 @@ read_tree_p(/*void*/)
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
void
|
||||
decode_start_fix(/*void*/)
|
||||
void decode_start_fix(void)
|
||||
{
|
||||
n_max = 314;
|
||||
maxmatch = 60;
|
||||
@ -144,12 +138,11 @@ decode_start_fix(/*void*/)
|
||||
np = 1 << (12 - 6);
|
||||
start_c_dyn();
|
||||
ready_made(0);
|
||||
make_table(np, pt_len, 8, pt_table);
|
||||
lha_make_table(np, pt_len, 8, pt_table);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
unsigned short
|
||||
decode_c_st0(/*void*/)
|
||||
unsigned short decode_c_st0(void)
|
||||
{
|
||||
int i, j;
|
||||
static unsigned short blocksize = 0;
|
||||
@ -163,7 +156,7 @@ decode_c_st0(/*void*/)
|
||||
else {
|
||||
ready_made(1);
|
||||
}
|
||||
make_table(NP, pt_len, 8, pt_table);
|
||||
lha_make_table(NP, pt_len, 8, pt_table);
|
||||
}
|
||||
blocksize--;
|
||||
j = c_table[lhabitbuf >> 4];
|
||||
@ -187,8 +180,7 @@ decode_c_st0(/*void*/)
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
unsigned short
|
||||
decode_p_st0(/*void*/)
|
||||
unsigned short decode_p_st0(void)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
@ -378,9 +378,7 @@ struct interfacing *lhinterface;
|
||||
|
||||
#endif
|
||||
|
||||
int
|
||||
decode(lhinterface)
|
||||
struct interfacing *lhinterface;
|
||||
int decode(struct interfacing *lhinterface)
|
||||
{
|
||||
unsigned int i, j, k, c;
|
||||
unsigned int dicsiz1, offset;
|
||||
@ -5,10 +5,9 @@
|
||||
|
||||
#include "sysconfig.h"
|
||||
#include "sysdeps.h"
|
||||
#include "zfile.h"
|
||||
#include "lha.h"
|
||||
#include "zarchive.h"
|
||||
|
||||
#include "lha.h"
|
||||
|
||||
static char *methods[] =
|
||||
{
|
||||
@ -21,10 +21,7 @@ extern unsigned short crc;
|
||||
/* convert path delimit
|
||||
erreturns *filename */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
unsigned char *
|
||||
convdelim(path, delim)
|
||||
unsigned char *path;
|
||||
unsigned char delim;
|
||||
unsigned char *convdelim(unsigned char *path, unsigned char delim)
|
||||
{
|
||||
unsigned char c;
|
||||
unsigned char *p;
|
||||
@ -205,9 +202,7 @@ mkdir(path, mode)
|
||||
*/
|
||||
|
||||
#ifndef USESTRCASECMP
|
||||
static int
|
||||
my_toupper(n)
|
||||
register int n;
|
||||
static int my_toupper(int n)
|
||||
{
|
||||
if (n >= 'a' && n <= 'z')
|
||||
return n & (~('a' - 'A'));
|
||||
@ -215,9 +210,7 @@ my_toupper(n)
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
int
|
||||
strucmp(s, t)
|
||||
register char *s, *t;
|
||||
int strucmp(char *s, char *t)
|
||||
{
|
||||
while (my_toupper(*s++) == my_toupper(*t++))
|
||||
if (!*s || !*t)
|
||||
@ -642,9 +642,9 @@ struct zfile *archive_access_lzx (struct znode *zn)
|
||||
startpos = znlast->offset;
|
||||
compsize = znlast->packedsize;
|
||||
zfile_fseek (zf, startpos, SEEK_SET);
|
||||
buf = xmalloc(compsize);
|
||||
buf = xmalloc (uae_u8, compsize);
|
||||
zfile_fread (buf, compsize, 1, zf);
|
||||
dbuf = xcalloc (unpsize, 1);
|
||||
dbuf = xcalloc (uae_u8, unpsize);
|
||||
|
||||
/* unpack complete block */
|
||||
memset(offset_len, 0, sizeof offset_len);
|
||||
@ -709,8 +709,8 @@ struct zvolume *archive_directory_lzx (struct zfile *in_file)
|
||||
unsigned int pack_size;
|
||||
unsigned int unpack_size;
|
||||
unsigned char archive_header[31];
|
||||
unsigned char header_filename[256];
|
||||
unsigned char header_comment[256];
|
||||
char header_filename[256];
|
||||
char header_comment[256];
|
||||
|
||||
if (zfile_fread(archive_header, 1, 10, in_file) != 10)
|
||||
return 0;
|
||||
@ -742,7 +742,7 @@ struct zvolume *archive_directory_lzx (struct zfile *in_file)
|
||||
if(actual == temp)
|
||||
{
|
||||
header_filename[temp] = 0;
|
||||
crc_calc(header_filename, temp);
|
||||
crc_calc((unsigned char*)header_filename, temp);
|
||||
temp = archive_header[14]; /* comment length */
|
||||
actual = zfile_fread(header_comment, 1, temp, in_file);
|
||||
if(!zfile_ferror(in_file))
|
||||
@ -750,7 +750,7 @@ struct zvolume *archive_directory_lzx (struct zfile *in_file)
|
||||
if(actual == temp)
|
||||
{
|
||||
header_comment[temp] = 0;
|
||||
crc_calc(header_comment, temp);
|
||||
crc_calc((unsigned char*)header_comment, temp);
|
||||
if(sum == crc)
|
||||
{
|
||||
unsigned int year, month, day;
|
||||
@ -1,481 +0,0 @@
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "sysconfig.h"
|
||||
#include "sysdeps.h"
|
||||
#include "zfile.h"
|
||||
#include "crc32.h"
|
||||
|
||||
/* based on http://libxad.cvs.sourceforge.net/libxad/libxad/portable/clients/ by Dirk Stoecker */
|
||||
|
||||
#define XADERR_ILLEGALDATA 1
|
||||
#define XADERR_DECRUNCH 2
|
||||
#define XADERR_NOMEMORY 3
|
||||
|
||||
struct rledata {
|
||||
uae_u32 rledata;
|
||||
};
|
||||
|
||||
struct fout {
|
||||
struct zfile *zf;
|
||||
int xio_BitNum;
|
||||
int xio_BitBuf;
|
||||
int err;
|
||||
};
|
||||
|
||||
|
||||
static void putrle (uae_u8 data, struct zfile *out, struct rledata *rled)
|
||||
{
|
||||
int num;
|
||||
uae_u32 a;
|
||||
|
||||
if (!rled) {
|
||||
zfile_putc (data, out);
|
||||
return;
|
||||
}
|
||||
a = rled->rledata;
|
||||
if (a & 0x100) /* was RLE mode */
|
||||
{
|
||||
if (!data || (data == 1 && (a & 0x80000000))) {
|
||||
a = 0x90; num = 1;
|
||||
} else {
|
||||
a &= 0xFF; num = data - 1;
|
||||
}
|
||||
} else if (data == 0x90) {
|
||||
num = 0; a |= 0x100;
|
||||
} else {
|
||||
num = 1; a = data;
|
||||
}
|
||||
rled->rledata = a;
|
||||
while (num--)
|
||||
zfile_putc (a, out);
|
||||
}
|
||||
|
||||
static uae_u32 xadIOGetBitsLow(struct fout *io, uae_u8 bits)
|
||||
{
|
||||
uae_u32 x;
|
||||
|
||||
io->err = 0;
|
||||
while(io->xio_BitNum < bits)
|
||||
{
|
||||
int v = zfile_getc (io->zf);
|
||||
if (v == -1) {
|
||||
io->err = 1;
|
||||
return 0;
|
||||
}
|
||||
io->xio_BitBuf |= v << io->xio_BitNum;
|
||||
io->xio_BitNum += 8;
|
||||
}
|
||||
x = io->xio_BitBuf & ((1<<bits)-1);
|
||||
io->xio_BitBuf >>= bits;
|
||||
io->xio_BitNum -= bits;
|
||||
return x;
|
||||
}
|
||||
|
||||
#define ARCSQSPEOF 256 /* special endfile token */
|
||||
#define ARCSQNUMVALS 257 /* 256 data values plus SPEOF */
|
||||
|
||||
static uae_s32 ARCunsqueeze(struct zfile *in, struct zfile *out, struct rledata *rled)
|
||||
{
|
||||
uae_s32 err = 0;
|
||||
uae_s32 i, numnodes;
|
||||
uae_s16 *node;
|
||||
struct fout io;
|
||||
|
||||
io.zf = in;
|
||||
io.xio_BitBuf = 0;
|
||||
io.xio_BitNum = 0;
|
||||
io.err = 0;
|
||||
|
||||
if((node = (uae_s16 *) xcalloc(2*2*ARCSQNUMVALS, 1)))
|
||||
{
|
||||
numnodes = xadIOGetBitsLow(&io, 16);
|
||||
|
||||
if(numnodes < 0 || numnodes >= ARCSQNUMVALS)
|
||||
err = XADERR_DECRUNCH;
|
||||
else
|
||||
{ /* initialize for possible empty tree (SPEOF only) */
|
||||
node[0] = node[1] = -(ARCSQSPEOF + 1);
|
||||
|
||||
numnodes *= 2; i = 0;
|
||||
while(i < numnodes && !io.err) /* get decoding tree from file */
|
||||
{
|
||||
node[i++] = xadIOGetBitsLow(&io, 16);
|
||||
node[i++] = xadIOGetBitsLow(&io, 16);
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
/* follow bit stream in tree to a leaf */
|
||||
i = 0;
|
||||
while(i >= 0 && !io.err)
|
||||
i = node[2*i + xadIOGetBitsLow(&io, 1)];
|
||||
|
||||
i = -(i + 1); /* decode fake node index to original data value */
|
||||
|
||||
if(i != ARCSQSPEOF)
|
||||
putrle (i, out, rled);
|
||||
} while(i != ARCSQSPEOF);
|
||||
}
|
||||
xfree(node);
|
||||
}
|
||||
else
|
||||
err = XADERR_NOMEMORY;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define UCOMPMAXCODE(n) (((uae_u32) 1 << (n)) - 1)
|
||||
#define UCOMPBITS 16
|
||||
#define UCOMPSTACKSIZE 8000
|
||||
#define UCOMPFIRST 257 /* first free entry */
|
||||
#define UCOMPCLEAR 256 /* table clear output code */
|
||||
#define UCOMPINIT_BITS 9 /* initial number of bits/code */
|
||||
#define UCOMPBIT_MASK 0x1f
|
||||
#define UCOMPBLOCK_MASK 0x80
|
||||
|
||||
struct UCompData {
|
||||
uae_s16 clear_flg;
|
||||
uae_u16 n_bits; /* number of bits/code */
|
||||
uae_u16 maxbits; /* user settable max # bits/code */
|
||||
uae_u32 maxcode; /* maximum code, given n_bits */
|
||||
uae_u32 maxmaxcode;
|
||||
uae_s32 free_ent;
|
||||
uae_s32 offset;
|
||||
uae_s32 size;
|
||||
uae_u16 *tab_prefixof;
|
||||
uae_u8 *tab_suffixof;
|
||||
uae_u8 stack[UCOMPSTACKSIZE];
|
||||
uae_u8 buf[UCOMPBITS];
|
||||
int insize;
|
||||
struct rledata *rled;
|
||||
};
|
||||
|
||||
|
||||
/* Read one code from input. If EOF, return -1. */
|
||||
static uae_s32 UCompgetcode(struct zfile *in, struct UCompData *cd)
|
||||
{
|
||||
uae_s32 code, r_off, bits;
|
||||
uae_u8 *bp = cd->buf;
|
||||
|
||||
if(cd->clear_flg > 0 || cd->offset >= cd->size || cd->free_ent > cd->maxcode)
|
||||
{
|
||||
/*
|
||||
* If the next entry will be too big for the current code
|
||||
* size, then we must increase the size. This implies reading
|
||||
* a new buffer full, too.
|
||||
*/
|
||||
if(cd->free_ent > cd->maxcode)
|
||||
{
|
||||
if(++cd->n_bits == cd->maxbits)
|
||||
cd->maxcode = cd->maxmaxcode; /* won't get any bigger now */
|
||||
else
|
||||
cd->maxcode = UCOMPMAXCODE(cd->n_bits);
|
||||
}
|
||||
if(cd->clear_flg > 0)
|
||||
{
|
||||
cd->maxcode = UCOMPMAXCODE(cd->n_bits = UCOMPINIT_BITS);
|
||||
cd->clear_flg = 0;
|
||||
}
|
||||
|
||||
/* This reads maximum n_bits characters into buf */
|
||||
cd->size = 0;
|
||||
while(cd->size < cd->n_bits) {
|
||||
int v;
|
||||
if (cd->insize == 0)
|
||||
break;
|
||||
v = zfile_getc (in);
|
||||
if (v == -1)
|
||||
break;
|
||||
cd->insize--;
|
||||
cd->buf[cd->size++] = v;
|
||||
}
|
||||
if(cd->size <= 0)
|
||||
return -1;
|
||||
|
||||
cd->offset = 0;
|
||||
/* Round size down to integral number of codes */
|
||||
cd->size = (cd->size << 3) - (cd->n_bits - 1);
|
||||
}
|
||||
|
||||
r_off = cd->offset;
|
||||
bits = cd->n_bits;
|
||||
|
||||
/* Get to the first byte. */
|
||||
bp += (r_off >> 3);
|
||||
r_off &= 7;
|
||||
|
||||
/* Get first part (low order bits) */
|
||||
code = (*bp++ >> r_off);
|
||||
bits -= (8 - r_off);
|
||||
r_off = 8 - r_off; /* now, offset into code word */
|
||||
|
||||
/* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
|
||||
if(bits >= 8)
|
||||
{
|
||||
code |= *bp++ << r_off;
|
||||
r_off += 8;
|
||||
bits -= 8;
|
||||
}
|
||||
|
||||
/* high order bits. */
|
||||
code |= (*bp & ((1<<bits)-1)) << r_off;
|
||||
cd->offset += cd->n_bits;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static uae_u32 xadIO_Compress(struct zfile *in, struct zfile *out, int insize, struct rledata *rled, uae_u8 bitinfo)
|
||||
{
|
||||
int err = 0;
|
||||
struct UCompData *cd;
|
||||
|
||||
if((bitinfo & UCOMPBIT_MASK) < UCOMPINIT_BITS)
|
||||
return XADERR_ILLEGALDATA;
|
||||
|
||||
if((cd = xcalloc(sizeof(struct UCompData), 1)))
|
||||
{
|
||||
int finchar, code, oldcode, incode, blockcomp;
|
||||
uae_u8 *stackp, *stack, *stackend;
|
||||
|
||||
stackp = stack = cd->stack;
|
||||
stackend = stack + UCOMPSTACKSIZE;
|
||||
cd->maxbits = bitinfo & UCOMPBIT_MASK;
|
||||
blockcomp = bitinfo & UCOMPBLOCK_MASK;
|
||||
cd->maxmaxcode = 1 << cd->maxbits;
|
||||
cd->maxcode = UCOMPMAXCODE(cd->n_bits = UCOMPINIT_BITS);
|
||||
cd->free_ent = blockcomp ? UCOMPFIRST : 256;
|
||||
cd->insize = insize;
|
||||
cd->rled = rled;
|
||||
|
||||
if((cd->tab_prefixof = xcalloc(sizeof(uae_u16) * cd->maxmaxcode, 1)))
|
||||
{
|
||||
if((cd->tab_suffixof = xcalloc(cd->maxmaxcode, 1)))
|
||||
{
|
||||
/* Initialize the first 256 entries in the table. */
|
||||
for(code = 255; code >= 0; code--)
|
||||
cd->tab_suffixof[code] = code;
|
||||
|
||||
if((finchar = oldcode = UCompgetcode(in, cd)) == -1)
|
||||
err = XADERR_DECRUNCH;
|
||||
else
|
||||
{
|
||||
putrle (finchar, out, cd->rled); /* first code must be 8 bits = uae_u8 */
|
||||
|
||||
while((code = UCompgetcode(in, cd)) > -1)
|
||||
{
|
||||
if((code == UCOMPCLEAR) && blockcomp)
|
||||
{
|
||||
for(code = 255; code >= 0; code--)
|
||||
cd->tab_prefixof[code] = 0;
|
||||
cd->clear_flg = 1;
|
||||
cd->free_ent = UCOMPFIRST - 1;
|
||||
if((code = UCompgetcode(in, cd)) == -1)
|
||||
break; /* O, untimely death! */
|
||||
}
|
||||
incode = code;
|
||||
|
||||
/* Special case for KwKwK string. */
|
||||
if(code >= cd->free_ent)
|
||||
{
|
||||
if(code > cd->free_ent)
|
||||
{
|
||||
err = XADERR_ILLEGALDATA;
|
||||
break;
|
||||
}
|
||||
*stackp++ = finchar;
|
||||
code = oldcode;
|
||||
}
|
||||
|
||||
/* Generate output characters in reverse order */
|
||||
while(stackp < stackend && code >= 256)
|
||||
{
|
||||
*stackp++ = cd->tab_suffixof[code];
|
||||
code = cd->tab_prefixof[code];
|
||||
}
|
||||
if(stackp >= stackend)
|
||||
{
|
||||
err = XADERR_ILLEGALDATA;
|
||||
break;
|
||||
}
|
||||
*(stackp++) = finchar = cd->tab_suffixof[code];
|
||||
|
||||
/* And put them out in forward order */
|
||||
do
|
||||
{
|
||||
putrle (*(--stackp), out, cd->rled);
|
||||
} while(stackp > stack);
|
||||
|
||||
/* Generate the new entry. */
|
||||
if((code = cd->free_ent) < cd->maxmaxcode)
|
||||
{
|
||||
cd->tab_prefixof[code] = (uae_u16) oldcode;
|
||||
cd->tab_suffixof[code] = finchar;
|
||||
cd->free_ent = code+1;
|
||||
}
|
||||
/* Remember previous code. */
|
||||
oldcode = incode;
|
||||
}
|
||||
}
|
||||
xfree (cd->tab_suffixof);
|
||||
}
|
||||
else
|
||||
err = XADERR_NOMEMORY;
|
||||
xfree(cd->tab_prefixof);
|
||||
}
|
||||
else
|
||||
err = XADERR_NOMEMORY;
|
||||
xfree(cd);
|
||||
}
|
||||
else
|
||||
err = XADERR_NOMEMORY;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void MakeCRC16(uae_u16 *buf, uae_u16 ID)
|
||||
{
|
||||
uae_u16 i, j, k;
|
||||
|
||||
for(i = 0; i < 256; ++i)
|
||||
{
|
||||
k = i;
|
||||
|
||||
for(j = 0; j < 8; ++j)
|
||||
{
|
||||
if(k & 1)
|
||||
k = (k >> 1) ^ ID;
|
||||
else
|
||||
k >>= 1;
|
||||
}
|
||||
buf[i] = k;
|
||||
}
|
||||
}
|
||||
|
||||
static uae_u16 wrpcrc16 (uae_u16 *tab, uae_u8 *buf, int len)
|
||||
{
|
||||
uae_u16 crc = 0;
|
||||
while (len-- > 0)
|
||||
crc = tab[(crc ^ *buf++) & 0xFF] ^ (crc >> 8);
|
||||
return crc;
|
||||
}
|
||||
|
||||
static int iswrp (uae_u8 *data)
|
||||
{
|
||||
if(data[0] == 'W' && data[1] == 'a' && data[2] == 'r' && data[3] == 'p'
|
||||
&& data[4] == ' ' && data[5] == 'v' && data[6] == '1' && data[7] == '.'
|
||||
&& data[8] == '1' && !data[9] && !data[18] && data[19] <= 3)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define COMPBUF 30000
|
||||
|
||||
struct zfile *unwarp(struct zfile *zf)
|
||||
{
|
||||
int err = 0;
|
||||
uae_u8 buf[26] = { 0 };
|
||||
int algo, side, track;
|
||||
int pos, dstpos, olddstpos;
|
||||
uae_u16 crc;
|
||||
uae_u32 size;
|
||||
struct zfile *nf = NULL, *tmpf = NULL;
|
||||
uae_u8 *zero, *data;
|
||||
int outsize = 11 * 512;
|
||||
int outsize2 = 11 * (512 + 16);
|
||||
struct rledata rled;
|
||||
uae_u16 wrpcrc16table[256];
|
||||
|
||||
MakeCRC16 (wrpcrc16table, 0xa001);
|
||||
|
||||
zero = xcalloc (outsize2, 1);
|
||||
olddstpos = 0;
|
||||
for (;;) {
|
||||
if (zfile_fread (buf, sizeof buf, 1, zf) == 0)
|
||||
break;
|
||||
if (!iswrp (buf))
|
||||
break;
|
||||
if (!nf) {
|
||||
nf = zfile_fopen_empty (zf, L"zipped.wrp", 1760 * 512);
|
||||
tmpf = zfile_fopen_empty (zf, L"tmp", outsize2);
|
||||
}
|
||||
track = (buf[10] << 8) | buf[11];
|
||||
algo = buf[19];
|
||||
side = -1;
|
||||
if (!memcmp (buf + 12, "BOT\0", 4))
|
||||
side = 1;
|
||||
if (!memcmp (buf + 12, "TOP\0", 4))
|
||||
side = 0;
|
||||
crc = (buf[20] << 8) | buf[21];
|
||||
pos = zfile_ftell (zf);
|
||||
dstpos = -1;
|
||||
if (side >= 0 && track >= 0 && track <= 79)
|
||||
dstpos = track * 22 * 512 + (side * 11 * 512);
|
||||
zfile_fseek (tmpf, 0, SEEK_SET);
|
||||
zfile_fwrite (zero, outsize2, 1, tmpf);
|
||||
zfile_fseek (tmpf, 0, SEEK_SET);
|
||||
size = (buf[22] << 24) | (buf[23] << 16) | (buf[24] << 8) | buf[25];
|
||||
err = 0;
|
||||
memset (&rled, 0, sizeof rled);
|
||||
|
||||
switch (algo)
|
||||
{
|
||||
case 1:
|
||||
if (zfile_getc (zf) != 12)
|
||||
err = XADERR_ILLEGALDATA;
|
||||
else
|
||||
err = xadIO_Compress (zf, tmpf, size - 1, &rled, 12 | UCOMPBLOCK_MASK);
|
||||
break;
|
||||
case 2:
|
||||
err = ARCunsqueeze (zf, tmpf, &rled);
|
||||
break;
|
||||
case 0:
|
||||
case 3:
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < size; i++) {
|
||||
uae_u8 v = zfile_getc (zf);
|
||||
putrle (v, tmpf, algo == 3 ? &rled : NULL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
write_log (L"WRP unknown compression method %d, track=%d,size=%d\n", algo, track, side);
|
||||
goto end;
|
||||
break;
|
||||
}
|
||||
if (err) {
|
||||
write_log (L"WRP corrupt data, track=%d,side=%d,err=%d\n", track, side, err);
|
||||
} else {
|
||||
uae_u16 crc2;
|
||||
int os = zfile_ftell (tmpf);
|
||||
data = zfile_getdata (tmpf, 0, os);
|
||||
crc2 = wrpcrc16 (wrpcrc16table, data, os);
|
||||
if (crc != crc2)
|
||||
write_log (L"WRP crc error %04x<>%04x, track=%d,side=%d\n", crc, crc2, track, side);
|
||||
xfree (data);
|
||||
}
|
||||
if (dstpos >= 0) {
|
||||
zfile_fseek (nf, dstpos, SEEK_SET);
|
||||
data = zfile_getdata (tmpf, 0, outsize);
|
||||
zfile_fwrite (data, outsize, 1, nf);
|
||||
}
|
||||
zfile_fseek (zf, pos + size, SEEK_SET);
|
||||
}
|
||||
end:
|
||||
xfree (zero);
|
||||
zfile_fclose (tmpf);
|
||||
if (nf) {
|
||||
zfile_fclose (zf);
|
||||
zf = nf;
|
||||
}
|
||||
return zf;
|
||||
}
|
||||
|
||||
481
archivers/wrp/warp.cpp
Normal file
481
archivers/wrp/warp.cpp
Normal file
@ -0,0 +1,481 @@
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "sysconfig.h"
|
||||
#include "sysdeps.h"
|
||||
#include "zfile.h"
|
||||
#include "crc32.h"
|
||||
|
||||
/* based on http://libxad.cvs.sourceforge.net/libxad/libxad/portable/clients/ by Dirk Stoecker */
|
||||
|
||||
#define XADERR_ILLEGALDATA 1
|
||||
#define XADERR_DECRUNCH 2
|
||||
#define XADERR_NOMEMORY 3
|
||||
|
||||
struct rledata {
|
||||
uae_u32 rledatav;
|
||||
};
|
||||
|
||||
struct fout {
|
||||
struct zfile *zf;
|
||||
int xio_BitNum;
|
||||
int xio_BitBuf;
|
||||
int err;
|
||||
};
|
||||
|
||||
|
||||
static void putrle (uae_u8 data, struct zfile *out, struct rledata *rled)
|
||||
{
|
||||
int num;
|
||||
uae_u32 a;
|
||||
|
||||
if (!rled) {
|
||||
zfile_putc (data, out);
|
||||
return;
|
||||
}
|
||||
a = rled->rledatav;
|
||||
if (a & 0x100) /* was RLE mode */
|
||||
{
|
||||
if (!data || (data == 1 && (a & 0x80000000))) {
|
||||
a = 0x90; num = 1;
|
||||
} else {
|
||||
a &= 0xFF; num = data - 1;
|
||||
}
|
||||
} else if (data == 0x90) {
|
||||
num = 0; a |= 0x100;
|
||||
} else {
|
||||
num = 1; a = data;
|
||||
}
|
||||
rled->rledatav = a;
|
||||
while (num--)
|
||||
zfile_putc (a, out);
|
||||
}
|
||||
|
||||
static uae_u32 xadIOGetBitsLow(struct fout *io, uae_u8 bits)
|
||||
{
|
||||
uae_u32 x;
|
||||
|
||||
io->err = 0;
|
||||
while(io->xio_BitNum < bits)
|
||||
{
|
||||
int v = zfile_getc (io->zf);
|
||||
if (v == -1) {
|
||||
io->err = 1;
|
||||
return 0;
|
||||
}
|
||||
io->xio_BitBuf |= v << io->xio_BitNum;
|
||||
io->xio_BitNum += 8;
|
||||
}
|
||||
x = io->xio_BitBuf & ((1<<bits)-1);
|
||||
io->xio_BitBuf >>= bits;
|
||||
io->xio_BitNum -= bits;
|
||||
return x;
|
||||
}
|
||||
|
||||
#define ARCSQSPEOF 256 /* special endfile token */
|
||||
#define ARCSQNUMVALS 257 /* 256 data values plus SPEOF */
|
||||
|
||||
static uae_s32 ARCunsqueeze(struct zfile *in, struct zfile *out, struct rledata *rled)
|
||||
{
|
||||
uae_s32 err = 0;
|
||||
uae_s32 i, numnodes;
|
||||
uae_s16 *node;
|
||||
struct fout io;
|
||||
|
||||
io.zf = in;
|
||||
io.xio_BitBuf = 0;
|
||||
io.xio_BitNum = 0;
|
||||
io.err = 0;
|
||||
|
||||
if((node = (uae_s16 *) xcalloc(uae_s16, 2*ARCSQNUMVALS)))
|
||||
{
|
||||
numnodes = xadIOGetBitsLow(&io, 16);
|
||||
|
||||
if(numnodes < 0 || numnodes >= ARCSQNUMVALS)
|
||||
err = XADERR_DECRUNCH;
|
||||
else
|
||||
{ /* initialize for possible empty tree (SPEOF only) */
|
||||
node[0] = node[1] = -(ARCSQSPEOF + 1);
|
||||
|
||||
numnodes *= 2; i = 0;
|
||||
while(i < numnodes && !io.err) /* get decoding tree from file */
|
||||
{
|
||||
node[i++] = xadIOGetBitsLow(&io, 16);
|
||||
node[i++] = xadIOGetBitsLow(&io, 16);
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
/* follow bit stream in tree to a leaf */
|
||||
i = 0;
|
||||
while(i >= 0 && !io.err)
|
||||
i = node[2*i + xadIOGetBitsLow(&io, 1)];
|
||||
|
||||
i = -(i + 1); /* decode fake node index to original data value */
|
||||
|
||||
if(i != ARCSQSPEOF)
|
||||
putrle (i, out, rled);
|
||||
} while(i != ARCSQSPEOF);
|
||||
}
|
||||
xfree(node);
|
||||
}
|
||||
else
|
||||
err = XADERR_NOMEMORY;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define UCOMPMAXCODE(n) (((uae_u32) 1 << (n)) - 1)
|
||||
#define UCOMPBITS 16
|
||||
#define UCOMPSTACKSIZE 8000
|
||||
#define UCOMPFIRST 257 /* first free entry */
|
||||
#define UCOMPCLEAR 256 /* table clear output code */
|
||||
#define UCOMPINIT_BITS 9 /* initial number of bits/code */
|
||||
#define UCOMPBIT_MASK 0x1f
|
||||
#define UCOMPBLOCK_MASK 0x80
|
||||
|
||||
struct UCompData {
|
||||
uae_s16 clear_flg;
|
||||
uae_u16 n_bits; /* number of bits/code */
|
||||
uae_u16 maxbits; /* user settable max # bits/code */
|
||||
uae_u32 maxcode; /* maximum code, given n_bits */
|
||||
uae_u32 maxmaxcode;
|
||||
uae_s32 free_ent;
|
||||
uae_s32 offset;
|
||||
uae_s32 size;
|
||||
uae_u16 *tab_prefixof;
|
||||
uae_u8 *tab_suffixof;
|
||||
uae_u8 stack[UCOMPSTACKSIZE];
|
||||
uae_u8 buf[UCOMPBITS];
|
||||
int insize;
|
||||
struct rledata *rled;
|
||||
};
|
||||
|
||||
|
||||
/* Read one code from input. If EOF, return -1. */
|
||||
static uae_s32 UCompgetcode(struct zfile *in, struct UCompData *cd)
|
||||
{
|
||||
uae_s32 code, r_off, bits;
|
||||
uae_u8 *bp = cd->buf;
|
||||
|
||||
if(cd->clear_flg > 0 || cd->offset >= cd->size || cd->free_ent > cd->maxcode)
|
||||
{
|
||||
/*
|
||||
* If the next entry will be too big for the current code
|
||||
* size, then we must increase the size. This implies reading
|
||||
* a new buffer full, too.
|
||||
*/
|
||||
if(cd->free_ent > cd->maxcode)
|
||||
{
|
||||
if(++cd->n_bits == cd->maxbits)
|
||||
cd->maxcode = cd->maxmaxcode; /* won't get any bigger now */
|
||||
else
|
||||
cd->maxcode = UCOMPMAXCODE(cd->n_bits);
|
||||
}
|
||||
if(cd->clear_flg > 0)
|
||||
{
|
||||
cd->maxcode = UCOMPMAXCODE(cd->n_bits = UCOMPINIT_BITS);
|
||||
cd->clear_flg = 0;
|
||||
}
|
||||
|
||||
/* This reads maximum n_bits characters into buf */
|
||||
cd->size = 0;
|
||||
while(cd->size < cd->n_bits) {
|
||||
int v;
|
||||
if (cd->insize == 0)
|
||||
break;
|
||||
v = zfile_getc (in);
|
||||
if (v == -1)
|
||||
break;
|
||||
cd->insize--;
|
||||
cd->buf[cd->size++] = v;
|
||||
}
|
||||
if(cd->size <= 0)
|
||||
return -1;
|
||||
|
||||
cd->offset = 0;
|
||||
/* Round size down to integral number of codes */
|
||||
cd->size = (cd->size << 3) - (cd->n_bits - 1);
|
||||
}
|
||||
|
||||
r_off = cd->offset;
|
||||
bits = cd->n_bits;
|
||||
|
||||
/* Get to the first byte. */
|
||||
bp += (r_off >> 3);
|
||||
r_off &= 7;
|
||||
|
||||
/* Get first part (low order bits) */
|
||||
code = (*bp++ >> r_off);
|
||||
bits -= (8 - r_off);
|
||||
r_off = 8 - r_off; /* now, offset into code word */
|
||||
|
||||
/* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
|
||||
if(bits >= 8)
|
||||
{
|
||||
code |= *bp++ << r_off;
|
||||
r_off += 8;
|
||||
bits -= 8;
|
||||
}
|
||||
|
||||
/* high order bits. */
|
||||
code |= (*bp & ((1<<bits)-1)) << r_off;
|
||||
cd->offset += cd->n_bits;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static uae_u32 xadIO_Compress(struct zfile *in, struct zfile *out, int insize, struct rledata *rled, uae_u8 bitinfo)
|
||||
{
|
||||
int err = 0;
|
||||
struct UCompData *cd;
|
||||
|
||||
if((bitinfo & UCOMPBIT_MASK) < UCOMPINIT_BITS)
|
||||
return XADERR_ILLEGALDATA;
|
||||
|
||||
if((cd = xcalloc(struct UCompData, 1)))
|
||||
{
|
||||
int finchar, code, oldcode, incode, blockcomp;
|
||||
uae_u8 *stackp, *stack, *stackend;
|
||||
|
||||
stackp = stack = cd->stack;
|
||||
stackend = stack + UCOMPSTACKSIZE;
|
||||
cd->maxbits = bitinfo & UCOMPBIT_MASK;
|
||||
blockcomp = bitinfo & UCOMPBLOCK_MASK;
|
||||
cd->maxmaxcode = 1 << cd->maxbits;
|
||||
cd->maxcode = UCOMPMAXCODE(cd->n_bits = UCOMPINIT_BITS);
|
||||
cd->free_ent = blockcomp ? UCOMPFIRST : 256;
|
||||
cd->insize = insize;
|
||||
cd->rled = rled;
|
||||
|
||||
if((cd->tab_prefixof = xcalloc(uae_u16, cd->maxmaxcode)))
|
||||
{
|
||||
if((cd->tab_suffixof = xcalloc(uae_u8, cd->maxmaxcode)))
|
||||
{
|
||||
/* Initialize the first 256 entries in the table. */
|
||||
for(code = 255; code >= 0; code--)
|
||||
cd->tab_suffixof[code] = code;
|
||||
|
||||
if((finchar = oldcode = UCompgetcode(in, cd)) == -1)
|
||||
err = XADERR_DECRUNCH;
|
||||
else
|
||||
{
|
||||
putrle (finchar, out, cd->rled); /* first code must be 8 bits = uae_u8 */
|
||||
|
||||
while((code = UCompgetcode(in, cd)) > -1)
|
||||
{
|
||||
if((code == UCOMPCLEAR) && blockcomp)
|
||||
{
|
||||
for(code = 255; code >= 0; code--)
|
||||
cd->tab_prefixof[code] = 0;
|
||||
cd->clear_flg = 1;
|
||||
cd->free_ent = UCOMPFIRST - 1;
|
||||
if((code = UCompgetcode(in, cd)) == -1)
|
||||
break; /* O, untimely death! */
|
||||
}
|
||||
incode = code;
|
||||
|
||||
/* Special case for KwKwK string. */
|
||||
if(code >= cd->free_ent)
|
||||
{
|
||||
if(code > cd->free_ent)
|
||||
{
|
||||
err = XADERR_ILLEGALDATA;
|
||||
break;
|
||||
}
|
||||
*stackp++ = finchar;
|
||||
code = oldcode;
|
||||
}
|
||||
|
||||
/* Generate output characters in reverse order */
|
||||
while(stackp < stackend && code >= 256)
|
||||
{
|
||||
*stackp++ = cd->tab_suffixof[code];
|
||||
code = cd->tab_prefixof[code];
|
||||
}
|
||||
if(stackp >= stackend)
|
||||
{
|
||||
err = XADERR_ILLEGALDATA;
|
||||
break;
|
||||
}
|
||||
*(stackp++) = finchar = cd->tab_suffixof[code];
|
||||
|
||||
/* And put them out in forward order */
|
||||
do
|
||||
{
|
||||
putrle (*(--stackp), out, cd->rled);
|
||||
} while(stackp > stack);
|
||||
|
||||
/* Generate the new entry. */
|
||||
if((code = cd->free_ent) < cd->maxmaxcode)
|
||||
{
|
||||
cd->tab_prefixof[code] = (uae_u16) oldcode;
|
||||
cd->tab_suffixof[code] = finchar;
|
||||
cd->free_ent = code+1;
|
||||
}
|
||||
/* Remember previous code. */
|
||||
oldcode = incode;
|
||||
}
|
||||
}
|
||||
xfree (cd->tab_suffixof);
|
||||
}
|
||||
else
|
||||
err = XADERR_NOMEMORY;
|
||||
xfree(cd->tab_prefixof);
|
||||
}
|
||||
else
|
||||
err = XADERR_NOMEMORY;
|
||||
xfree(cd);
|
||||
}
|
||||
else
|
||||
err = XADERR_NOMEMORY;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void MakeCRC16(uae_u16 *buf, uae_u16 ID)
|
||||
{
|
||||
uae_u16 i, j, k;
|
||||
|
||||
for(i = 0; i < 256; ++i)
|
||||
{
|
||||
k = i;
|
||||
|
||||
for(j = 0; j < 8; ++j)
|
||||
{
|
||||
if(k & 1)
|
||||
k = (k >> 1) ^ ID;
|
||||
else
|
||||
k >>= 1;
|
||||
}
|
||||
buf[i] = k;
|
||||
}
|
||||
}
|
||||
|
||||
static uae_u16 wrpcrc16 (uae_u16 *tab, uae_u8 *buf, int len)
|
||||
{
|
||||
uae_u16 crc = 0;
|
||||
while (len-- > 0)
|
||||
crc = tab[(crc ^ *buf++) & 0xFF] ^ (crc >> 8);
|
||||
return crc;
|
||||
}
|
||||
|
||||
static int iswrp (uae_u8 *data)
|
||||
{
|
||||
if(data[0] == 'W' && data[1] == 'a' && data[2] == 'r' && data[3] == 'p'
|
||||
&& data[4] == ' ' && data[5] == 'v' && data[6] == '1' && data[7] == '.'
|
||||
&& data[8] == '1' && !data[9] && !data[18] && data[19] <= 3)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define COMPBUF 30000
|
||||
|
||||
struct zfile *unwarp(struct zfile *zf)
|
||||
{
|
||||
int err = 0;
|
||||
uae_u8 buf[26] = { 0 };
|
||||
int algo, side, track;
|
||||
int pos, dstpos, olddstpos;
|
||||
uae_u16 crc;
|
||||
uae_u32 size;
|
||||
struct zfile *nf = NULL, *tmpf = NULL;
|
||||
uae_u8 *zero, *data;
|
||||
int outsize = 11 * 512;
|
||||
int outsize2 = 11 * (512 + 16);
|
||||
struct rledata rled;
|
||||
uae_u16 wrpcrc16table[256];
|
||||
|
||||
MakeCRC16 (wrpcrc16table, 0xa001);
|
||||
|
||||
zero = xcalloc (uae_u8, outsize2);
|
||||
olddstpos = 0;
|
||||
for (;;) {
|
||||
if (zfile_fread (buf, sizeof buf, 1, zf) == 0)
|
||||
break;
|
||||
if (!iswrp (buf))
|
||||
break;
|
||||
if (!nf) {
|
||||
nf = zfile_fopen_empty (zf, L"zipped.wrp", 1760 * 512);
|
||||
tmpf = zfile_fopen_empty (zf, L"tmp", outsize2);
|
||||
}
|
||||
track = (buf[10] << 8) | buf[11];
|
||||
algo = buf[19];
|
||||
side = -1;
|
||||
if (!memcmp (buf + 12, "BOT\0", 4))
|
||||
side = 1;
|
||||
if (!memcmp (buf + 12, "TOP\0", 4))
|
||||
side = 0;
|
||||
crc = (buf[20] << 8) | buf[21];
|
||||
pos = zfile_ftell (zf);
|
||||
dstpos = -1;
|
||||
if (side >= 0 && track >= 0 && track <= 79)
|
||||
dstpos = track * 22 * 512 + (side * 11 * 512);
|
||||
zfile_fseek (tmpf, 0, SEEK_SET);
|
||||
zfile_fwrite (zero, outsize2, 1, tmpf);
|
||||
zfile_fseek (tmpf, 0, SEEK_SET);
|
||||
size = (buf[22] << 24) | (buf[23] << 16) | (buf[24] << 8) | buf[25];
|
||||
err = 0;
|
||||
memset (&rled, 0, sizeof rled);
|
||||
|
||||
switch (algo)
|
||||
{
|
||||
case 1:
|
||||
if (zfile_getc (zf) != 12)
|
||||
err = XADERR_ILLEGALDATA;
|
||||
else
|
||||
err = xadIO_Compress (zf, tmpf, size - 1, &rled, 12 | UCOMPBLOCK_MASK);
|
||||
break;
|
||||
case 2:
|
||||
err = ARCunsqueeze (zf, tmpf, &rled);
|
||||
break;
|
||||
case 0:
|
||||
case 3:
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < size; i++) {
|
||||
uae_u8 v = zfile_getc (zf);
|
||||
putrle (v, tmpf, algo == 3 ? &rled : NULL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
write_log (L"WRP unknown compression method %d, track=%d,size=%d\n", algo, track, side);
|
||||
goto end;
|
||||
break;
|
||||
}
|
||||
if (err) {
|
||||
write_log (L"WRP corrupt data, track=%d,side=%d,err=%d\n", track, side, err);
|
||||
} else {
|
||||
uae_u16 crc2;
|
||||
int os = zfile_ftell (tmpf);
|
||||
data = zfile_getdata (tmpf, 0, os);
|
||||
crc2 = wrpcrc16 (wrpcrc16table, data, os);
|
||||
if (crc != crc2)
|
||||
write_log (L"WRP crc error %04x<>%04x, track=%d,side=%d\n", crc, crc2, track, side);
|
||||
xfree (data);
|
||||
}
|
||||
if (dstpos >= 0) {
|
||||
zfile_fseek (nf, dstpos, SEEK_SET);
|
||||
data = zfile_getdata (tmpf, 0, outsize);
|
||||
zfile_fwrite (data, outsize, 1, nf);
|
||||
}
|
||||
zfile_fseek (zf, pos + size, SEEK_SET);
|
||||
}
|
||||
end:
|
||||
xfree (zero);
|
||||
zfile_fclose (tmpf);
|
||||
if (nf) {
|
||||
zfile_fclose (zf);
|
||||
zf = nf;
|
||||
}
|
||||
return zf;
|
||||
}
|
||||
|
||||
@ -137,9 +137,7 @@ typedef struct
|
||||
*/
|
||||
|
||||
|
||||
local int unzlocal_getByte(fin,pi)
|
||||
struct zfile *fin;
|
||||
int *pi;
|
||||
local int unzlocal_getByte(struct zfile *fin,int *pi)
|
||||
{
|
||||
unsigned char c;
|
||||
int err = zfile_fread(&c, 1, 1, fin);
|
||||
@ -158,9 +156,7 @@ local int unzlocal_getByte(fin,pi)
|
||||
/* ===========================================================================
|
||||
Reads a long in LSB order from the given gz_stream. Sets
|
||||
*/
|
||||
local int unzlocal_getShort (fin,pX)
|
||||
struct zfile* fin;
|
||||
uLong *pX;
|
||||
local int unzlocal_getShort (struct zfile *fin,uLong *pX)
|
||||
{
|
||||
uLong x ;
|
||||
int i;
|
||||
@ -180,9 +176,7 @@ local int unzlocal_getShort (fin,pX)
|
||||
return err;
|
||||
}
|
||||
|
||||
local int unzlocal_getLong (fin,pX)
|
||||
struct zfile* fin;
|
||||
uLong *pX;
|
||||
local int unzlocal_getLong (struct zfile *fin, uLong *pX)
|
||||
{
|
||||
uLong x ;
|
||||
int i;
|
||||
@ -212,9 +206,7 @@ local int unzlocal_getLong (fin,pX)
|
||||
|
||||
|
||||
/* My own strcmpi / strcasecmp */
|
||||
local int strcmpcasenosensitive_internal (fileName1,fileName2)
|
||||
const char* fileName1;
|
||||
const char* fileName2;
|
||||
local int strcmpcasenosensitive_internal (const char *fileName1, const char *fileName2)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
@ -255,10 +247,7 @@ local int strcmpcasenosensitive_internal (fileName1,fileName2)
|
||||
(like 1 on Unix, 2 on Windows)
|
||||
|
||||
*/
|
||||
extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity)
|
||||
const char* fileName1;
|
||||
const char* fileName2;
|
||||
int iCaseSensitivity;
|
||||
extern int ZEXPORT unzStringFileNameCompare (const char*fileName1, const char*fileName2, int iCaseSensitivity)
|
||||
{
|
||||
if (iCaseSensitivity==0)
|
||||
iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
|
||||
@ -275,8 +264,7 @@ extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivit
|
||||
Locate the Central directory of a zipfile (at the end, just before
|
||||
the global comment)
|
||||
*/
|
||||
local uLong unzlocal_SearchCentralDir(fin)
|
||||
struct zfile *fin;
|
||||
local uLong unzlocal_SearchCentralDir(struct zfile *fin)
|
||||
{
|
||||
unsigned char* buf;
|
||||
uLong uSizeFile;
|
||||
@ -340,8 +328,7 @@ local uLong unzlocal_SearchCentralDir(fin)
|
||||
Else, the return value is a unzFile Handle, usable with other function
|
||||
of this unzip package.
|
||||
*/
|
||||
extern unzFile ZEXPORT unzOpen (fin)
|
||||
struct zfile *fin;
|
||||
extern unzFile ZEXPORT unzOpen (struct zfile *fin)
|
||||
{
|
||||
unz_s us;
|
||||
unz_s *s;
|
||||
@ -431,8 +418,7 @@ extern unzFile ZEXPORT unzOpen (fin)
|
||||
If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
|
||||
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
||||
return UNZ_OK if there is no problem. */
|
||||
extern int ZEXPORT unzClose (file)
|
||||
unzFile file;
|
||||
extern int ZEXPORT unzClose (unzFile file)
|
||||
{
|
||||
unz_s* s;
|
||||
if (file==NULL)
|
||||
@ -451,9 +437,7 @@ extern int ZEXPORT unzClose (file)
|
||||
Write info about the ZipFile in the *pglobal_info structure.
|
||||
No preparation of the structure is needed
|
||||
return UNZ_OK if there is no problem. */
|
||||
extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info)
|
||||
unzFile file;
|
||||
unz_global_info *pglobal_info;
|
||||
extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info *pglobal_info)
|
||||
{
|
||||
unz_s* s;
|
||||
if (file==NULL)
|
||||
@ -467,9 +451,7 @@ extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info)
|
||||
/*
|
||||
Translate date/time from Dos format to tm_unz (readable more easilty)
|
||||
*/
|
||||
local void unzlocal_DosDateToTmuDate (ulDosDate, ptm)
|
||||
uLong ulDosDate;
|
||||
tm_unz* ptm;
|
||||
local void unzlocal_DosDateToTmuDate (uLong ulDosDate, tm_unz *ptm)
|
||||
{
|
||||
uLong uDate;
|
||||
uDate = (uLong)(ulDosDate>>16);
|
||||
@ -496,21 +478,12 @@ local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file,
|
||||
char *szComment,
|
||||
uLong commentBufferSize));
|
||||
|
||||
local int unzlocal_GetCurrentFileInfoInternal (file,
|
||||
pfile_info,
|
||||
pfile_info_internal,
|
||||
szFileName, fileNameBufferSize,
|
||||
extraField, extraFieldBufferSize,
|
||||
szComment, commentBufferSize)
|
||||
unzFile file;
|
||||
unz_file_info *pfile_info;
|
||||
unz_file_info_internal *pfile_info_internal;
|
||||
char *szFileName;
|
||||
uLong fileNameBufferSize;
|
||||
void *extraField;
|
||||
uLong extraFieldBufferSize;
|
||||
char *szComment;
|
||||
uLong commentBufferSize;
|
||||
local int unzlocal_GetCurrentFileInfoInternal (unzFile file,
|
||||
unz_file_info *pfile_info,
|
||||
unz_file_info_internal *pfile_info_internal,
|
||||
char *szFileName, uLong fileNameBufferSize,
|
||||
void *extraField, uLong extraFieldBufferSize,
|
||||
char *szComment, uLong commentBufferSize)
|
||||
{
|
||||
unz_s* s;
|
||||
unz_file_info file_info;
|
||||
@ -661,19 +634,11 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
|
||||
No preparation of the structure is needed
|
||||
return UNZ_OK if there is no problem.
|
||||
*/
|
||||
extern int ZEXPORT unzGetCurrentFileInfo (file,
|
||||
pfile_info,
|
||||
szFileName, fileNameBufferSize,
|
||||
extraField, extraFieldBufferSize,
|
||||
szComment, commentBufferSize)
|
||||
unzFile file;
|
||||
unz_file_info *pfile_info;
|
||||
char *szFileName;
|
||||
uLong fileNameBufferSize;
|
||||
void *extraField;
|
||||
uLong extraFieldBufferSize;
|
||||
char *szComment;
|
||||
uLong commentBufferSize;
|
||||
extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
|
||||
unz_file_info *pfile_info,
|
||||
char *szFileName, uLong fileNameBufferSize,
|
||||
void *extraField, uLong extraFieldBufferSize,
|
||||
char *szComment, uLong commentBufferSize)
|
||||
{
|
||||
return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
|
||||
szFileName,fileNameBufferSize,
|
||||
@ -685,8 +650,7 @@ extern int ZEXPORT unzGetCurrentFileInfo (file,
|
||||
Set the current file of the zipfile to the first file.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
extern int ZEXPORT unzGoToFirstFile (file)
|
||||
unzFile file;
|
||||
extern int ZEXPORT unzGoToFirstFile (unzFile file)
|
||||
{
|
||||
int err=UNZ_OK;
|
||||
unz_s* s;
|
||||
@ -708,8 +672,7 @@ extern int ZEXPORT unzGoToFirstFile (file)
|
||||
return UNZ_OK if there is no problem
|
||||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
||||
*/
|
||||
extern int ZEXPORT unzGoToNextFile (file)
|
||||
unzFile file;
|
||||
extern int ZEXPORT unzGoToNextFile (unzFile file)
|
||||
{
|
||||
unz_s* s;
|
||||
int err;
|
||||
@ -741,10 +704,7 @@ extern int ZEXPORT unzGoToNextFile (file)
|
||||
UNZ_OK if the file is found. It becomes the current file.
|
||||
UNZ_END_OF_LIST_OF_FILE if the file is not found
|
||||
*/
|
||||
extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
|
||||
unzFile file;
|
||||
const char *szFileName;
|
||||
int iCaseSensitivity;
|
||||
extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)
|
||||
{
|
||||
unz_s* s;
|
||||
int err;
|
||||
@ -794,13 +754,9 @@ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
|
||||
store in *piSizeVar the size of extra info in local header
|
||||
(filename and size of extra field data)
|
||||
*/
|
||||
local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
|
||||
poffset_local_extrafield,
|
||||
psize_local_extrafield)
|
||||
unz_s* s;
|
||||
uInt* piSizeVar;
|
||||
uLong *poffset_local_extrafield;
|
||||
uInt *psize_local_extrafield;
|
||||
local int unzlocal_CheckCurrentFileCoherencyHeader (unz_s *s, uInt *piSizeVar,
|
||||
uLong *poffset_local_extrafield,
|
||||
uInt *psize_local_extrafield)
|
||||
{
|
||||
uLong uMagic,uData,uFlags;
|
||||
uLong size_filename;
|
||||
@ -884,8 +840,7 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
|
||||
Open for reading data the current file in the zipfile.
|
||||
If there is no error and the file is opened, the return value is UNZ_OK.
|
||||
*/
|
||||
extern int ZEXPORT unzOpenCurrentFile (file)
|
||||
unzFile file;
|
||||
extern int ZEXPORT unzOpenCurrentFile (unzFile file)
|
||||
{
|
||||
int err=UNZ_OK;
|
||||
int Store;
|
||||
@ -985,10 +940,7 @@ extern int ZEXPORT unzOpenCurrentFile (file)
|
||||
return <0 with error code if there is an error
|
||||
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
||||
*/
|
||||
extern int ZEXPORT unzReadCurrentFile (file, buf, len)
|
||||
unzFile file;
|
||||
voidp buf;
|
||||
unsigned len;
|
||||
extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned int len)
|
||||
{
|
||||
int err=UNZ_OK;
|
||||
uInt iRead = 0;
|
||||
@ -1112,8 +1064,7 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len)
|
||||
/*
|
||||
Give the current position in uncompressed data
|
||||
*/
|
||||
extern z_off_t ZEXPORT unztell (file)
|
||||
unzFile file;
|
||||
extern z_off_t ZEXPORT unztell (unzFile file)
|
||||
{
|
||||
unz_s* s;
|
||||
file_in_zip_read_info_s* pfile_in_zip_read_info;
|
||||
@ -1132,8 +1083,7 @@ extern z_off_t ZEXPORT unztell (file)
|
||||
/*
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
*/
|
||||
extern int ZEXPORT unzeof (file)
|
||||
unzFile file;
|
||||
extern int ZEXPORT unzeof (unzFile file)
|
||||
{
|
||||
unz_s* s;
|
||||
file_in_zip_read_info_s* pfile_in_zip_read_info;
|
||||
@ -1165,10 +1115,7 @@ extern int ZEXPORT unzeof (file)
|
||||
the return value is the number of bytes copied in buf, or (if <0)
|
||||
the error code
|
||||
*/
|
||||
extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
|
||||
unzFile file;
|
||||
voidp buf;
|
||||
unsigned len;
|
||||
extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned int len)
|
||||
{
|
||||
unz_s* s;
|
||||
file_in_zip_read_info_s* pfile_in_zip_read_info;
|
||||
@ -1212,8 +1159,7 @@ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
|
||||
Close the file in zip opened with unzipOpenCurrentFile
|
||||
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||
*/
|
||||
extern int ZEXPORT unzCloseCurrentFile (file)
|
||||
unzFile file;
|
||||
extern int ZEXPORT unzCloseCurrentFile (unzFile file)
|
||||
{
|
||||
int err=UNZ_OK;
|
||||
|
||||
@ -1254,10 +1200,7 @@ extern int ZEXPORT unzCloseCurrentFile (file)
|
||||
uSizeBuf is the size of the szComment buffer.
|
||||
return the number of byte copied or an error code <0
|
||||
*/
|
||||
extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
|
||||
unzFile file;
|
||||
char *szComment;
|
||||
uLong uSizeBuf;
|
||||
extern int ZEXPORT unzGetGlobalComment (unzFile file, char *szComment, uLong uSizeBuf)
|
||||
{
|
||||
int err=UNZ_OK;
|
||||
unz_s* s;
|
||||
@ -68,7 +68,7 @@ static int debugchannel (int ch)
|
||||
* entries so that CPU updates during minimum period can be played back. */
|
||||
#define SINC_QUEUE_LENGTH (SINC_QUEUE_MAX_AGE / 16 + 2)
|
||||
|
||||
#include "sinctable.c"
|
||||
#include "sinctable.cpp"
|
||||
|
||||
typedef struct {
|
||||
int age, output;
|
||||
@ -240,7 +240,7 @@ static void do_samplerip (struct audio_channel_data *adp)
|
||||
/* replace old identical but shorter sample */
|
||||
if (len > rs->len && !memcmp (rs->sample, smp, rs->len)) {
|
||||
xfree (rs->sample);
|
||||
rs->sample = xmalloc (len);
|
||||
rs->sample = xmalloc (uae_u8, len);
|
||||
memcpy (rs->sample, smp, len);
|
||||
write_log (L"SAMPLERIPPER: replaced sample %d (%d -> %d)\n", cnt, rs->len, len);
|
||||
rs->len = len;
|
||||
@ -256,14 +256,14 @@ static void do_samplerip (struct audio_channel_data *adp)
|
||||
}
|
||||
if (rs || cnt > 100)
|
||||
return;
|
||||
rs = xmalloc (sizeof(struct ripped_sample));
|
||||
rs = xmalloc (struct ripped_sample ,1);
|
||||
if (prev)
|
||||
prev->next = rs;
|
||||
else
|
||||
ripped_samples = rs;
|
||||
rs->len = len;
|
||||
rs->per = adp->per / CYCLE_UNIT;
|
||||
rs->sample = xmalloc (len);
|
||||
rs->sample = xmalloc (uae_u8, len);
|
||||
memcpy (rs->sample, smp, len);
|
||||
rs->next = NULL;
|
||||
rs->changed = 1;
|
||||
@ -1589,8 +1589,6 @@ void audio_evhandler (void)
|
||||
schedule_audio ();
|
||||
}
|
||||
|
||||
uae_u16 dmacon;
|
||||
|
||||
void audio_hsync (int hpos)
|
||||
{
|
||||
int nr, handle;
|
||||
@ -202,7 +202,7 @@ static uae_u32 REGPARAM2 getchipmemsize (TrapContext *context)
|
||||
|
||||
static uae_u32 REGPARAM2 uae_puts (TrapContext *context)
|
||||
{
|
||||
puts ((uae_u8*)get_real_address (m68k_areg (regs, 0)));
|
||||
puts ((char*)get_real_address (m68k_areg (regs, 0)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1517,7 +1517,7 @@ uae_u8 *save_blitter (int *len, uae_u8 *dstptr)
|
||||
if (dstptr)
|
||||
dstbak = dst = dstptr;
|
||||
else
|
||||
dstbak = dst = xmalloc (16);
|
||||
dstbak = dst = xmalloc (uae_u8, 16);
|
||||
save_u32 (((bltstate != BLT_done) ? 0 : 1) | forced | 4);
|
||||
*len = dst - dstbak;
|
||||
return dstbak;
|
||||
@ -294,7 +294,7 @@ void scsi_atapi_fixup_pre (uae_u8 *scsi_cmd, int *len, uae_u8 **datap, int *data
|
||||
scsi_cmd[9] = scsi_cmd[5];
|
||||
scsi_cmd[2] = scsi_cmd[3] = scsi_cmd[4] = scsi_cmd[5] = scsi_cmd[6] = 0;
|
||||
*len = 10;
|
||||
p = (uae_u8*)xmalloc (8 + datalen + 4);
|
||||
p = xmalloc (uae_u8, 8 + datalen + 4);
|
||||
if (datalen > 4)
|
||||
memcpy (p + 8, data + 4, datalen - 4);
|
||||
p[0] = 0;
|
||||
@ -313,7 +313,7 @@ void scsi_atapi_fixup_pre (uae_u8 *scsi_cmd, int *len, uae_u8 **datap, int *data
|
||||
scsi_cmd[3] = scsi_cmd[4] = scsi_cmd[5] = scsi_cmd[6] = 0;
|
||||
if (l > 8)
|
||||
datalen += 4;
|
||||
*datap = (uae_u8*)xmalloc (datalen);
|
||||
*datap = xmalloc (uae_u8, datalen);
|
||||
*len = 10;
|
||||
*parm = MODE_SENSE_10;
|
||||
}
|
||||
@ -445,7 +445,7 @@ uae_u8 *save_cd (int num, int *len)
|
||||
if (!currprefs.cdimagefile[0])
|
||||
return NULL;
|
||||
|
||||
dstbak = dst = xmalloc (4 + 256);
|
||||
dstbak = dst = xmalloc (uae_u8, 4 + 256);
|
||||
save_u32 (4);
|
||||
save_string (currprefs.cdimagefile);
|
||||
*len = dst - dstbak;
|
||||
@ -282,7 +282,7 @@ static uae_u8 *mp3decoder_get (struct zfile *zf, int maxsize)
|
||||
return NULL;
|
||||
}
|
||||
zfile_fseek (zf, 0, SEEK_SET);
|
||||
outbuf = xcalloc (maxsize, 1);
|
||||
outbuf = xcalloc (uae_u8, maxsize);
|
||||
for (;;) {
|
||||
int count = zfile_fread (mp3buf, 1, MP3_BLOCK_SIZE, zf);
|
||||
if (count != MP3_BLOCK_SIZE)
|
||||
@ -361,7 +361,7 @@ static void *cdda_play_func (void *v)
|
||||
Sleep (10);
|
||||
oldplay = -1;
|
||||
|
||||
p = xmalloc (2 * num_sectors * 4096);
|
||||
p = xmalloc (uae_u8, 2 * num_sectors * 4096);
|
||||
px[0] = p;
|
||||
px[1] = p + num_sectors * 4096;
|
||||
bufon[0] = bufon[1] = 0;
|
||||
@ -375,7 +375,7 @@ static void *cdda_play_func (void *v)
|
||||
for (i = 0; i < 2; i++) {
|
||||
memset (&whdr[i], 0, sizeof (WAVEHDR));
|
||||
whdr[i].dwBufferLength = 2352 * num_sectors;
|
||||
whdr[i].lpData = px[i];
|
||||
whdr[i].lpData = (LPSTR)px[i];
|
||||
mmr = waveOutPrepareHeader (cdda_wavehandle, &whdr[i], sizeof (WAVEHDR));
|
||||
if (mmr != MMSYSERR_NOERROR) {
|
||||
write_log (L"CDDA: waveOutPrepareHeader %d:%d\n", i, mmr);
|
||||
@ -26,6 +26,7 @@
|
||||
|
||||
#ifdef BSDSOCKET
|
||||
|
||||
struct socketbase *socketbases;
|
||||
static uae_u32 SockLibBase;
|
||||
|
||||
#define SOCKPOOLSIZE 128
|
||||
@ -82,7 +83,7 @@ uae_u32 addmem (uae_u32 * dst, const uae_char *src, int len)
|
||||
if (!src)
|
||||
return 0;
|
||||
|
||||
memcpyha_safe (*dst, src, len);
|
||||
memcpyha_safe (*dst, (uae_u8*)src, len);
|
||||
(*dst) += len;
|
||||
|
||||
return res;
|
||||
@ -216,7 +217,7 @@ SOCKET_TYPE getsock (SB, int sd)
|
||||
ot1 = get_long (sb1->ownertask + 10);
|
||||
if (!addr_valid (L"getsock4", ot1, 1))
|
||||
break;
|
||||
if (strcmp(get_real_address (ot1), get_real_address (ot)) == 0) {
|
||||
if (strcmp((char*)get_real_address (ot1), (char*)get_real_address (ot)) == 0) {
|
||||
// Task with same name already exists -> use same dtable
|
||||
if (sb1->dtable[sd - 1] != INVALID_SOCKET)
|
||||
return sb1->dtable[sd - 1];
|
||||
@ -372,7 +373,7 @@ static struct socketbase *alloc_socketbase (TrapContext *context)
|
||||
SB;
|
||||
int i;
|
||||
|
||||
if ((sb = (struct socketbase*)calloc (sizeof (struct socketbase), 1)) != NULL) {
|
||||
if ((sb = xcalloc (struct socketbase, 1)) != NULL) {
|
||||
sb->ownertask = gettask (context);
|
||||
|
||||
m68k_dreg (regs, 0) = -1;
|
||||
@ -691,7 +692,7 @@ static uae_u32 bsdsocklib_SetDTableSize (SB, int newSize)
|
||||
{
|
||||
int *newdtable;
|
||||
int *newftable;
|
||||
int *newmtable;
|
||||
unsigned int *newmtable;
|
||||
int i;
|
||||
|
||||
if (newSize < sb->dtablesize) {
|
||||
@ -699,9 +700,9 @@ static uae_u32 bsdsocklib_SetDTableSize (SB, int newSize)
|
||||
return 0;
|
||||
}
|
||||
|
||||
newdtable = (int *)calloc(newSize, sizeof(*sb->dtable));
|
||||
newftable = (int *)calloc(newSize, sizeof(*sb->ftable));
|
||||
newmtable = (int *)calloc(newSize, sizeof(*sb->mtable));
|
||||
newdtable = xcalloc (int, newSize);
|
||||
newftable = xcalloc (int, newSize);
|
||||
newmtable = xcalloc (unsigned int, newSize);
|
||||
|
||||
if (newdtable == NULL || newftable == NULL || newmtable == NULL) {
|
||||
sb->resultval = -1;
|
||||
@ -712,9 +713,9 @@ static uae_u32 bsdsocklib_SetDTableSize (SB, int newSize)
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(newdtable, sb->dtable, sb->dtablesize * sizeof(*sb->dtable));
|
||||
memcpy(newftable, sb->ftable, sb->dtablesize * sizeof(*sb->ftable));
|
||||
memcpy(newmtable, sb->mtable, sb->dtablesize * sizeof(*sb->mtable));
|
||||
memcpy (newdtable, sb->dtable, sb->dtablesize * sizeof(*sb->dtable));
|
||||
memcpy (newftable, sb->ftable, sb->dtablesize * sizeof(*sb->ftable));
|
||||
memcpy (newmtable, sb->mtable, sb->dtablesize * sizeof(*sb->mtable));
|
||||
for (i = sb->dtablesize + 1; i < newSize; i++)
|
||||
newdtable[i] = -1;
|
||||
|
||||
@ -1228,11 +1229,11 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context)
|
||||
break;
|
||||
case SBTC_ERRNO:
|
||||
BSDTRACE ((L"SBTC_ERRNO),%d", currval));
|
||||
tagcopy (currtag, currval, tagptr, &sb->sb_errno);
|
||||
tagcopy (currtag, currval, tagptr, (uae_u32*)&sb->sb_errno);
|
||||
break;
|
||||
case SBTC_HERRNO:
|
||||
BSDTRACE ((L"SBTC_HERRNO),%d", currval));
|
||||
tagcopy (currtag, currval, tagptr, &sb->sb_herrno);
|
||||
tagcopy (currtag, currval, tagptr, (uae_u32*)&sb->sb_herrno);
|
||||
break;
|
||||
case SBTC_DTABLESIZE:
|
||||
BSDTRACE ((L"SBTC_DTABLESIZE),0x%lx", currval));
|
||||
@ -1522,7 +1523,7 @@ void bsdlib_install (void)
|
||||
int i;
|
||||
|
||||
if (!sockdata) {
|
||||
sockdata = xcalloc (sizeof (struct sockd), 1);
|
||||
sockdata = xcalloc (struct sockd, 1);
|
||||
for (i = 0; i < SOCKPOOLSIZE; i++)
|
||||
sockdata->sockpoolids[i] = UNIQUE_ID;
|
||||
}
|
||||
@ -311,7 +311,7 @@ void catweasel_do_bput (uaecptr addr, uae_u32 b)
|
||||
//write_log (L"P %02X %02X %d\n", (uae_u8)addr, (uae_u8)b, did_read);
|
||||
}
|
||||
|
||||
#include "core.cw4.c"
|
||||
#include "core.cw4.cpp"
|
||||
|
||||
static int cw_config_done (void)
|
||||
{
|
||||
@ -522,7 +522,8 @@ static int detected;
|
||||
int catweasel_init(void)
|
||||
{
|
||||
TCHAR name[32], tmp[1000], *s;
|
||||
int i, len;
|
||||
int i;
|
||||
DWORD len;
|
||||
uae_u8 buffer[10000];
|
||||
uae_u32 model, base;
|
||||
int detect = 0;
|
||||
@ -589,7 +590,7 @@ int catweasel_init(void)
|
||||
write_log (L"CW: CW_GET_VERSION failed %d\n", GetLastError ());
|
||||
goto fail;
|
||||
}
|
||||
s = au (buffer);
|
||||
s = au ((char*)buffer);
|
||||
write_log (L"CW driver version string '%s'\n", s);
|
||||
xfree (s);
|
||||
if (!DeviceIoControl (handle, CW_GET_HWVERSION, 0, 0, buffer, sizeof (buffer), &len, 0)) {
|
||||
@ -146,7 +146,7 @@ static void REGPARAM2 fmv_wput (uaecptr addr, uae_u32 w)
|
||||
fmv_bput2 (addr + 1, w);
|
||||
}
|
||||
|
||||
static addrbank fmv_bank;
|
||||
extern addrbank fmv_bank;
|
||||
|
||||
static void REGPARAM2 fmv_bput (uaecptr addr, uae_u32 b)
|
||||
{
|
||||
@ -213,7 +213,7 @@ TCHAR *cfgfile_subst_path (const TCHAR *path, const TCHAR *subst, const TCHAR *f
|
||||
/* @@@ use strcasecmp for some targets. */
|
||||
if (_tcslen (path) > 0 && _tcsncmp (file, path, _tcslen (path)) == 0) {
|
||||
int l;
|
||||
TCHAR *p = xmalloc ((_tcslen (file) + _tcslen (subst) + 2) * sizeof (TCHAR));
|
||||
TCHAR *p = xmalloc (TCHAR, _tcslen (file) + _tcslen (subst) + 2);
|
||||
_tcscpy (p, subst);
|
||||
l = _tcslen (p);
|
||||
while (l > 0 && p[l - 1] == '/')
|
||||
@ -245,11 +245,11 @@ static size_t cfg_write (void *b, struct zfile *z)
|
||||
size_t v;
|
||||
if (unicode_config) {
|
||||
TCHAR lf = 10;
|
||||
v = zfile_fwrite (b, _tcslen (b), sizeof (TCHAR), z);
|
||||
v = zfile_fwrite (b, _tcslen ((TCHAR*)b), sizeof (TCHAR), z);
|
||||
zfile_fwrite (&lf, 1, 1, z);
|
||||
} else {
|
||||
char lf = 10;
|
||||
char *s = ua (b);
|
||||
char *s = ua ((TCHAR*)b);
|
||||
v = zfile_fwrite (s, strlen (s), 1, z);
|
||||
zfile_fwrite (&lf, 1, 1, z);
|
||||
xfree (s);
|
||||
@ -854,7 +854,7 @@ int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, i
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, int scale)
|
||||
int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, unsigned int *location, int scale)
|
||||
{
|
||||
int base = 10;
|
||||
TCHAR *endptr;
|
||||
@ -879,6 +879,17 @@ int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name,
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, int scale)
|
||||
{
|
||||
unsigned int v = 0;
|
||||
int r = cfgfile_intval (option, value, name, &v, scale);
|
||||
if (!r)
|
||||
return 0;
|
||||
*location = (int)v;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int cfgfile_strval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, const TCHAR *table[], int more)
|
||||
{
|
||||
@ -1405,7 +1416,7 @@ static void decode_rom_ident (TCHAR *romfile, int maxlen, TCHAR *ident)
|
||||
|
||||
if (!ident[0])
|
||||
return;
|
||||
romtxt = malloc (10000 * sizeof (TCHAR));
|
||||
romtxt = xmalloc (TCHAR, 10000);
|
||||
romtxt[0] = 0;
|
||||
for (round = 0; round < 2; round++) {
|
||||
ver = rev = subver = subrev = -1;
|
||||
@ -1543,7 +1554,7 @@ struct uaedev_config_info *add_filesys_config (struct uae_prefs *p, int index,
|
||||
|
||||
static void parse_addmem (struct uae_prefs *p, TCHAR *buf, int num)
|
||||
{
|
||||
uae_u32 size = 0, addr = 0;
|
||||
int size = 0, addr = 0;
|
||||
|
||||
if (!getintval2 (&buf, &addr, ','))
|
||||
return;
|
||||
@ -2131,7 +2142,7 @@ static void cfgfile_parse_separated_line (struct uae_prefs *p, TCHAR *line1b, TC
|
||||
if (sl->option && !strcasecmp (line1b, sl->option)) break;
|
||||
}
|
||||
if (!sl) {
|
||||
struct strlist *u = xcalloc (sizeof (struct strlist), 1);
|
||||
struct strlist *u = xcalloc (struct strlist, 1);
|
||||
u->option = my_strdup (line3b);
|
||||
u->value = my_strdup (line4b);
|
||||
u->next = p->all_lines;
|
||||
@ -2335,7 +2346,7 @@ int cfgfile_save (struct uae_prefs *p, const TCHAR *filename, int type)
|
||||
int cfgfile_get_description (const TCHAR *filename, TCHAR *description, TCHAR *hostlink, TCHAR *hardwarelink, int *type)
|
||||
{
|
||||
int result = 0;
|
||||
struct uae_prefs *p = xmalloc (sizeof (struct uae_prefs));
|
||||
struct uae_prefs *p = xmalloc (struct uae_prefs, 1);
|
||||
|
||||
p->description[0] = 0;
|
||||
p->config_host_path[0] = 0;
|
||||
@ -2586,7 +2597,7 @@ static void parse_cpu_specs (struct uae_prefs *p, const TCHAR *spec)
|
||||
/* Returns the number of args used up (0 or 1). */
|
||||
int parse_cmdline_option (struct uae_prefs *p, TCHAR c, const TCHAR *arg)
|
||||
{
|
||||
struct strlist *u = xcalloc (sizeof (struct strlist), 1);
|
||||
struct strlist *u = xcalloc (struct strlist, 1);
|
||||
const TCHAR arg_required[] = L"0123rKpImWSAJwNCZUFcblOdHRv";
|
||||
|
||||
if (_tcschr (arg_required, c) && ! arg) {
|
||||
@ -2594,7 +2605,7 @@ int parse_cmdline_option (struct uae_prefs *p, TCHAR c, const TCHAR *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
u->option = xmalloc (2 * sizeof (TCHAR));
|
||||
u->option = xmalloc (TCHAR, 2);
|
||||
u->option[0] = c;
|
||||
u->option[1] = 0;
|
||||
u->value = my_strdup (arg);
|
||||
@ -2727,7 +2738,7 @@ void cfgfile_addcfgparam (TCHAR *line)
|
||||
}
|
||||
if (!cfgfile_separate_line (line, line1b, line2b))
|
||||
return;
|
||||
u = xcalloc (sizeof (struct strlist), 1);
|
||||
u = xcalloc (struct strlist, 1);
|
||||
u->option = my_strdup (line1b);
|
||||
u->value = my_strdup (line2b);
|
||||
u->next = temp_lines;
|
||||
@ -2768,7 +2779,7 @@ static int cfgfile_handle_custom_event (TCHAR *custom, int mode)
|
||||
}
|
||||
|
||||
nextp = NULL;
|
||||
tmp = p = xcalloc (_tcslen (custom) + 2, 1);
|
||||
tmp = p = xcalloc (TCHAR, _tcslen (custom) + 2);
|
||||
_tcscpy (tmp, custom);
|
||||
while (p && *p) {
|
||||
if (*p == '\"') {
|
||||
@ -3022,13 +3033,13 @@ uae_u32 cfgfile_uaelib_modify (uae_u32 index, uae_u32 parms, uae_u32 size, uae_u
|
||||
while (get_byte (parms + size) != 0)
|
||||
size++;
|
||||
}
|
||||
parms_p = xmalloc (size + 1);
|
||||
parms_p = xmalloc (uae_char, size + 1);
|
||||
if (!parms_p) {
|
||||
ret = 10;
|
||||
goto end;
|
||||
}
|
||||
if (out) {
|
||||
out_p = xmalloc ((outsize + 1) * sizeof (TCHAR));
|
||||
out_p = xmalloc (TCHAR, outsize + 1);
|
||||
if (!out_p) {
|
||||
ret = 10;
|
||||
goto end;
|
||||
@ -3100,10 +3111,10 @@ uae_u32 cfgfile_uaelib (int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen)
|
||||
|
||||
uae_u8 *restore_configuration (uae_u8 *src)
|
||||
{
|
||||
TCHAR *s = au (src);
|
||||
TCHAR *s = au ((char*)src);
|
||||
//write_log (s);
|
||||
xfree (s);
|
||||
src += strlen (src) + 1;
|
||||
src += strlen ((char*)src) + 1;
|
||||
return src;
|
||||
}
|
||||
|
||||
@ -3113,7 +3124,7 @@ uae_u8 *save_configuration (int *len)
|
||||
uae_u8 *dstbak, *dst, *p;
|
||||
int index = -1;
|
||||
|
||||
dstbak = dst = malloc (tmpsize * sizeof (TCHAR));
|
||||
dstbak = dst = xmalloc (uae_u8, tmpsize);
|
||||
p = dst;
|
||||
for (;;) {
|
||||
TCHAR tmpout[256];
|
||||
@ -3126,10 +3137,10 @@ uae_u8 *save_configuration (int *len)
|
||||
if (!_tcsncmp (tmpout, L"input.", 6))
|
||||
continue;
|
||||
out = ua (tmpout);
|
||||
strcpy (p, out);
|
||||
strcpy ((char*)p, out);
|
||||
xfree (out);
|
||||
strcat (p, "\n");
|
||||
p += strlen (p);
|
||||
strcat ((char*)p, "\n");
|
||||
p += strlen ((char*)p);
|
||||
if (p - dstbak >= tmpsize - sizeof (tmpout))
|
||||
break;
|
||||
}
|
||||
@ -1232,7 +1232,7 @@ addrbank cia_bank = {
|
||||
};
|
||||
|
||||
|
||||
STATIC_INLINE isgayle (void)
|
||||
STATIC_INLINE int isgayle (void)
|
||||
{
|
||||
return (currprefs.cs_ide == IDE_A600A1200 || currprefs.cs_pcmcia);
|
||||
}
|
||||
@ -90,11 +90,11 @@ uaecptr consolehook_beginio (uaecptr request)
|
||||
|
||||
if (cmd == CMD_WRITE) {
|
||||
TCHAR *buf;
|
||||
const char *src = get_real_address (io_data);
|
||||
const char *src = (char*)get_real_address (io_data);
|
||||
int len = io_length;
|
||||
if (io_length == -1)
|
||||
len = strlen (src);
|
||||
buf = xmalloc ((len + 1) * sizeof (TCHAR));
|
||||
buf = xmalloc (TCHAR, len + 1);
|
||||
au_copy (buf, len, src);
|
||||
buf[len] = 0;
|
||||
f_out (L"%s", buf);
|
||||
@ -30,8 +30,9 @@ uae_u32 get_crc32_val (uae_u8 v, uae_u32 crc)
|
||||
crc = crc_table32[(crc ^ v) & 0xff] ^ (crc >> 8);
|
||||
return crc ^ 0xffffffff;
|
||||
}
|
||||
uae_u32 get_crc32 (uae_u8 *buf, int len)
|
||||
uae_u32 get_crc32 (void *vbuf, int len)
|
||||
{
|
||||
uae_u8 *buf = (uae_u8*)vbuf;
|
||||
uae_u32 crc;
|
||||
if (!crc_table32[1])
|
||||
make_crc_table();
|
||||
@ -40,8 +41,9 @@ uae_u32 get_crc32 (uae_u8 *buf, int len)
|
||||
crc = crc_table32[(crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
|
||||
return crc ^ 0xffffffff;
|
||||
}
|
||||
uae_u16 get_crc16 (uae_u8 *buf, int len)
|
||||
uae_u16 get_crc16 (void *vbuf, int len)
|
||||
{
|
||||
uae_u8 *buf = (uae_u8*)vbuf;
|
||||
uae_u16 crc;
|
||||
if (!crc_table32[1])
|
||||
make_crc_table();
|
||||
@ -327,16 +329,19 @@ static void sha1_finish( sha1_context *ctx, unsigned char output[20] )
|
||||
PUT_UINT32_BE( ctx->state[4], output, 16 );
|
||||
}
|
||||
|
||||
void get_sha1 (uae_u8 *input, int len, uae_u8 *out)
|
||||
void get_sha1 (void *vinput, int len, void *vout)
|
||||
{
|
||||
uae_u8 *input = (uae_u8*)vinput;
|
||||
uae_u8 *out = (uae_u8*)vout;
|
||||
sha1_context ctx;
|
||||
|
||||
sha1_starts( &ctx );
|
||||
sha1_update( &ctx, input, len );
|
||||
sha1_finish( &ctx, out );
|
||||
}
|
||||
const TCHAR *get_sha1_txt (uae_u8 *input, int len)
|
||||
const TCHAR *get_sha1_txt (void *vinput, int len)
|
||||
{
|
||||
uae_u8 *input = (uae_u8*)vinput;
|
||||
static TCHAR outtxt[SHA1_SIZE * 2 + 1];
|
||||
uae_u8 out[SHA1_SIZE];
|
||||
int i;
|
||||
@ -243,7 +243,6 @@ static unsigned int diwstrt, diwstop, diwhigh;
|
||||
static int diwhigh_written;
|
||||
static unsigned int ddfstrt, ddfstop, ddfstrt_old_hpos;
|
||||
static int ddf_change, badmode, diw_change;
|
||||
static int fmode;
|
||||
static int bplcon1_hpos;
|
||||
|
||||
/* The display and data fetch windows */
|
||||
@ -441,7 +440,7 @@ STATIC_INLINE void setclr (uae_u16 *p, uae_u16 val)
|
||||
*p &= ~val;
|
||||
}
|
||||
|
||||
STATIC_INLINE alloc_cycle (int hpos, int type)
|
||||
STATIC_INLINE void alloc_cycle (int hpos, int type)
|
||||
{
|
||||
#ifdef CPUEMU_12
|
||||
#if 0
|
||||
@ -455,7 +454,7 @@ STATIC_INLINE alloc_cycle (int hpos, int type)
|
||||
cycle_line[hpos] = type;
|
||||
#endif
|
||||
}
|
||||
STATIC_INLINE alloc_cycle_maybe (int hpos, int type)
|
||||
STATIC_INLINE void alloc_cycle_maybe (int hpos, int type)
|
||||
{
|
||||
if (cycle_line[hpos] == 0)
|
||||
alloc_cycle (hpos, type);
|
||||
@ -992,7 +991,7 @@ static void maybe_setup_fmodes (int hpos)
|
||||
}
|
||||
}
|
||||
|
||||
STATIC_INLINE maybe_check (int hpos)
|
||||
STATIC_INLINE void maybe_check (int hpos)
|
||||
{
|
||||
if (bpldmasetuphpos > 0 && hpos >= bpldmasetuphpos)
|
||||
maybe_setup_fmodes (hpos);
|
||||
@ -1599,8 +1598,10 @@ STATIC_INLINE int one_fetch_cycle_0 (int pos, int ddfstop_to_test, int dma, int
|
||||
finish_final_fetch (pos, fm);
|
||||
return 1;
|
||||
}
|
||||
if (plf_state >= plf_passed_stop)
|
||||
plf_state++;
|
||||
if (plf_state == plf_passed_stop)
|
||||
plf_state = plf_passed_stop2;
|
||||
else if (plf_state == plf_passed_stop2)
|
||||
plf_state = plf_end;
|
||||
}
|
||||
|
||||
maybe_check (pos);
|
||||
@ -2710,12 +2711,7 @@ void compute_vsynctime (void)
|
||||
else
|
||||
vsynctime = vsynctime_orig = syncbase / fake_vblank_hz;
|
||||
if (!picasso_on) {
|
||||
#ifdef OPENGL
|
||||
OGL_refresh ();
|
||||
#endif
|
||||
#ifdef D3D
|
||||
D3D_refresh ();
|
||||
#endif
|
||||
updatedisplayarea ();
|
||||
}
|
||||
if (currprefs.produce_sound > 1)
|
||||
update_sound (fake_vblank_hz, (bplcon0 & 4) ? -1 : lof, islinetoggle ());
|
||||
@ -3401,7 +3397,7 @@ int intlev (void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#define INT_PROCESSING_DELAY 1
|
||||
#define INT_PROCESSING_DELAY 3 * CYCLE_UNIT
|
||||
STATIC_INLINE int use_eventmode (uae_u16 v)
|
||||
{
|
||||
if (!currprefs.cpu_cycle_exact)
|
||||
@ -3450,7 +3446,7 @@ static void INTENA (uae_u16 v)
|
||||
}
|
||||
|
||||
if (use_eventmode (v))
|
||||
event2_newevent_xx (-1, INT_PROCESSING_DELAY * CYCLE_UNIT, intena, send_intena_do);
|
||||
event2_newevent_xx (-1, INT_PROCESSING_DELAY, intena, send_intena_do);
|
||||
else
|
||||
send_intena_do (intena);
|
||||
#if 0
|
||||
@ -3472,7 +3468,7 @@ void INTREQ_0 (uae_u16 v)
|
||||
return;
|
||||
}
|
||||
if (use_eventmode (v))
|
||||
event2_newevent_xx (-1, INT_PROCESSING_DELAY * CYCLE_UNIT, intreq, send_intreq_do);
|
||||
event2_newevent_xx (-1, INT_PROCESSING_DELAY, intreq, send_intreq_do);
|
||||
else
|
||||
send_intreq_do (intreq);
|
||||
}
|
||||
@ -5871,8 +5867,8 @@ void customreset (int hardreset)
|
||||
|
||||
void dumpcustom (void)
|
||||
{
|
||||
console_out_f (L"DMACON: %x INTENA: %x INTREQ: %x VPOS: %x HPOS: %x\n", DMACONR (current_hpos ()),
|
||||
(unsigned int)intena, (unsigned int)intreq, (unsigned int)vpos, (unsigned int)current_hpos());
|
||||
console_out_f (L"DMACON: %04x INTENA: %04x (%04x) INTREQ: %04x (%04x) VPOS: %x HPOS: %x\n", DMACONR (current_hpos ()),
|
||||
intena, intena_internal, intreq, intreq_internal, vpos, current_hpos ());
|
||||
console_out_f (L"COP1LC: %08lx, COP2LC: %08lx COPPTR: %08lx\n", (unsigned long)cop1lc, (unsigned long)cop2lc, cop_state.ip);
|
||||
console_out_f (L"DIWSTRT: %04x DIWSTOP: %04x DDFSTRT: %04x DDFSTOP: %04x\n",
|
||||
(unsigned int)diwstrt, (unsigned int)diwstop, (unsigned int)ddfstrt, (unsigned int)ddfstop);
|
||||
@ -6612,7 +6608,7 @@ uae_u8 *save_custom (int *len, uae_u8 *dstptr, int full)
|
||||
if (dstptr)
|
||||
dstbak = dst = dstptr;
|
||||
else
|
||||
dstbak = dst = malloc (8 + 256 * 2);
|
||||
dstbak = dst = xmalloc (uae_u8, 8 + 256 * 2);
|
||||
|
||||
SL (currprefs.chipset_mask);
|
||||
SW (0); /* 000 BLTDDAT */
|
||||
@ -6792,7 +6788,7 @@ uae_u8 *save_custom_agacolors (int *len, uae_u8 *dstptr)
|
||||
if (dstptr)
|
||||
dstbak = dst = dstptr;
|
||||
else
|
||||
dstbak = dst = xmalloc (256*4);
|
||||
dstbak = dst = xmalloc (uae_u8, 256 * 4);
|
||||
for (i = 0; i < 256; i++)
|
||||
#ifdef AGA
|
||||
SL (current_colors.color_regs_aga[i] | (color_regs_aga_genlock[i] ? 0x80000000 : 0));
|
||||
@ -6828,7 +6824,7 @@ uae_u8 *save_custom_sprite(int num, int *len, uae_u8 *dstptr)
|
||||
if (dstptr)
|
||||
dstbak = dst = dstptr;
|
||||
else
|
||||
dstbak = dst = xmalloc (30);
|
||||
dstbak = dst = xmalloc (uae_u8, 30);
|
||||
SL (spr[num].pt); /* 120-13E SPRxPT */
|
||||
SW (sprpos[num]); /* 1x0 SPRxPOS */
|
||||
SW (sprctl[num]); /* 1x2 SPRxPOS */
|
||||
@ -838,8 +838,8 @@ struct dma_rec *record_dma (uae_u16 reg, uae_u16 dat, uae_u32 addr, int hpos, in
|
||||
struct dma_rec *dr;
|
||||
|
||||
if (!dma_record[0]) {
|
||||
dma_record[0] = xmalloc (NR_DMA_REC_HPOS * NR_DMA_REC_VPOS * sizeof (struct dma_rec));
|
||||
dma_record[1] = xmalloc (NR_DMA_REC_HPOS * NR_DMA_REC_VPOS * sizeof (struct dma_rec));
|
||||
dma_record[0] = xmalloc (struct dma_rec, NR_DMA_REC_HPOS * NR_DMA_REC_VPOS);
|
||||
dma_record[1] = xmalloc (struct dma_rec, NR_DMA_REC_HPOS * NR_DMA_REC_VPOS);
|
||||
dma_record_toggle = 0;
|
||||
record_dma_reset ();
|
||||
}
|
||||
@ -954,8 +954,8 @@ void record_copper (uaecptr addr, int hpos, int vpos)
|
||||
{
|
||||
int t = nr_cop_records[curr_cop_set];
|
||||
if (!cop_record[0]) {
|
||||
cop_record[0] = xmalloc (NR_COPPER_RECORDS * sizeof (struct cop_rec));
|
||||
cop_record[1] = xmalloc (NR_COPPER_RECORDS * sizeof (struct cop_rec));
|
||||
cop_record[0] = xmalloc (struct cop_rec, NR_COPPER_RECORDS);
|
||||
cop_record[1] = xmalloc (struct cop_rec, NR_COPPER_RECORDS);
|
||||
}
|
||||
if (t < NR_COPPER_RECORDS) {
|
||||
cop_record[curr_cop_set][t].addr = addr;
|
||||
@ -1111,7 +1111,7 @@ static int totaltrainers;
|
||||
static void clearcheater(void)
|
||||
{
|
||||
if (!trainerdata)
|
||||
trainerdata = xmalloc(MAX_CHEAT_VIEW * sizeof (struct trainerstruct));
|
||||
trainerdata = xmalloc(struct trainerstruct, MAX_CHEAT_VIEW);
|
||||
memset(trainerdata, 0, sizeof (struct trainerstruct) * MAX_CHEAT_VIEW);
|
||||
totaltrainers = 0;
|
||||
}
|
||||
@ -1194,7 +1194,7 @@ static void deepcheatsearch (TCHAR **c)
|
||||
addr = end - 1;
|
||||
}
|
||||
memsize2 = (memsize + 7) / 8;
|
||||
memtmp = xmalloc (memsize + memsize2);
|
||||
memtmp = xmalloc (uae_u8, memsize + memsize2);
|
||||
if (!memtmp)
|
||||
return;
|
||||
memset (memtmp + memsize, 0xff, memsize2);
|
||||
@ -1320,7 +1320,7 @@ static void cheatsearch (TCHAR **c)
|
||||
console_out (L"Search reset\n");
|
||||
xfree (vlist);
|
||||
listsize = memsize;
|
||||
vlist = xcalloc (listsize >> 3, 1);
|
||||
vlist = xcalloc (uae_u8, listsize >> 3);
|
||||
return;
|
||||
}
|
||||
val = readint (c);
|
||||
@ -1342,7 +1342,7 @@ static void cheatsearch (TCHAR **c)
|
||||
|
||||
if (vlist == NULL) {
|
||||
listsize = memsize;
|
||||
vlist = xcalloc (listsize >> 3, 1);
|
||||
vlist = xcalloc (uae_u8, listsize >> 3);
|
||||
}
|
||||
|
||||
count = 0;
|
||||
@ -1417,8 +1417,8 @@ static void illg_init (void)
|
||||
uae_u8 c = 3;
|
||||
uaecptr addr, end;
|
||||
|
||||
illgdebug = xcalloc (0x01000000, 1);
|
||||
illghdebug = xcalloc (65536, 1);
|
||||
illgdebug = xcalloc (uae_u8, 0x01000000);
|
||||
illghdebug = xcalloc (uae_u8, 65536);
|
||||
if (!illgdebug || !illghdebug) {
|
||||
illg_free();
|
||||
return;
|
||||
@ -1552,7 +1552,7 @@ static void smc_detect_init (TCHAR **c)
|
||||
if (currprefs.z3fastmem_size)
|
||||
smc_size = currprefs.z3fastmem_start + currprefs.z3fastmem_size;
|
||||
smc_size += 4;
|
||||
smc_table = xmalloc (smc_size * sizeof (struct smc_item));
|
||||
smc_table = xmalloc (struct smc_item, smc_size);
|
||||
if (!smc_table)
|
||||
return;
|
||||
for (i = 0; i < smc_size; i++) {
|
||||
@ -1932,9 +1932,9 @@ static void initialize_memwatch (int mode)
|
||||
|
||||
deinitialize_memwatch ();
|
||||
as = currprefs.address_space_24 ? 256 : 65536;
|
||||
debug_mem_banks = xmalloc (sizeof (addrbank*) * as);
|
||||
debug_mem_area = xmalloc (sizeof (addrbank) * as);
|
||||
membank_stores = xcalloc (sizeof (struct membank_store), 32);
|
||||
debug_mem_banks = xmalloc (addrbank*, as);
|
||||
debug_mem_area = xmalloc (addrbank, as);
|
||||
membank_stores = xcalloc (struct membank_store, 32);
|
||||
oa = NULL;
|
||||
for (i = 0; i < as; i++) {
|
||||
a1 = debug_mem_banks[i] = debug_mem_area + i;
|
||||
@ -2016,7 +2016,7 @@ static void memwatch_dump (int num)
|
||||
TCHAR *buf;
|
||||
int multiplier = num < 0 ? MEMWATCH_TOTAL : 1;
|
||||
|
||||
buf = malloc (50 * multiplier * sizeof (TCHAR));
|
||||
buf = xmalloc (TCHAR, 50 * multiplier);
|
||||
if (!buf)
|
||||
return;
|
||||
memwatch_dump2 (buf, 50 * multiplier, num);
|
||||
@ -2259,7 +2259,7 @@ STATIC_INLINE uaecptr BPTR2APTR (uaecptr addr)
|
||||
static TCHAR *BSTR2CSTR (uae_u8 *bstr)
|
||||
{
|
||||
WCHAR *s;
|
||||
char *cstr = xmalloc (bstr[0] + 1);
|
||||
char *cstr = xmalloc (char, bstr[0] + 1);
|
||||
if (cstr) {
|
||||
memcpy (cstr, bstr + 1, bstr[0]);
|
||||
cstr[bstr[0]] = 0;
|
||||
@ -2275,7 +2275,7 @@ static void print_task_info (uaecptr node)
|
||||
int process = get_byte (node + 8) == 13 ? 1 : 0;
|
||||
|
||||
console_out_f (L"%08X: ", node);
|
||||
s = au (get_real_address (get_long (node + 10)));
|
||||
s = au ((char*)get_real_address (get_long (node + 10)));
|
||||
console_out_f (process ? L" PROCESS '%s'" : L" TASK '%s'\n", s);
|
||||
xfree (s);
|
||||
if (process) {
|
||||
@ -2339,7 +2339,7 @@ static void show_exec_lists (TCHAR t)
|
||||
return;
|
||||
node = get_long (list);
|
||||
while (get_long (node)) {
|
||||
TCHAR *name = au (get_real_address (get_long (node + 10)));
|
||||
TCHAR *name = au ((char*)get_real_address (get_long (node + 10)));
|
||||
console_out_f (L"%08x %s\n", node, name);
|
||||
xfree (name);
|
||||
node = get_long (node);
|
||||
@ -3339,7 +3339,7 @@ void debug (void)
|
||||
uaecptr execbase = get_long (4);
|
||||
uaecptr activetask = get_long (execbase + 276);
|
||||
int process = get_byte (activetask + 8) == 13 ? 1 : 0;
|
||||
uae_u8 *name = get_real_address (get_long (activetask + 10));
|
||||
char *name = (char*)get_real_address (get_long (activetask + 10));
|
||||
if (process) {
|
||||
uaecptr cli = BPTR2APTR(get_long (activetask + 172));
|
||||
uaecptr seglist = 0;
|
||||
@ -3347,13 +3347,13 @@ void debug (void)
|
||||
uae_char *command = NULL;
|
||||
if (cli) {
|
||||
if (processname)
|
||||
command = get_real_address (BPTR2APTR(get_long (cli + 16)));
|
||||
command = (char*)get_real_address (BPTR2APTR(get_long (cli + 16)));
|
||||
seglist = BPTR2APTR(get_long (cli + 60));
|
||||
} else {
|
||||
seglist = BPTR2APTR(get_long (activetask + 128));
|
||||
seglist = BPTR2APTR(get_long (seglist + 12));
|
||||
}
|
||||
if (activetask == processptr || (processname && (!stricmp(name, processname) || (command && command[0] && !strnicmp(command + 1, processname, command[0]) && processname[command[0]] == 0)))) {
|
||||
if (activetask == processptr || (processname && (!stricmp (name, processname) || (command && command[0] && !strnicmp (command + 1, processname, command[0]) && processname[command[0]] == 0)))) {
|
||||
while (seglist) {
|
||||
uae_u32 size = get_long (seglist - 4) - 4;
|
||||
if (pc >= (seglist + 4) && pc < (seglist + size)) {
|
||||
@ -3479,6 +3479,7 @@ struct mmunode {
|
||||
struct mmunode *next;
|
||||
};
|
||||
static struct mmunode **mmunl;
|
||||
extern regstruct mmu_backup_regs;
|
||||
|
||||
#define MMU_READ_U (1 << 0)
|
||||
#define MMU_WRITE_U (1 << 1)
|
||||
@ -3777,7 +3778,7 @@ int mmu_init(int mode, uaecptr parm, uaecptr parm2)
|
||||
}
|
||||
|
||||
mmu_slots = 1 << ((currprefs.address_space_24 ? 24 : 32) - MMU_PAGE_SHIFT);
|
||||
mmunl = xcalloc (sizeof (struct mmunode*) * mmu_slots, 1);
|
||||
mmunl = xcalloc (struct mmunode*, mmu_slots);
|
||||
size = 1;
|
||||
p2 = get_long (p);
|
||||
while (get_long (p2) != 0xffffffff) {
|
||||
@ -3785,7 +3786,7 @@ int mmu_init(int mode, uaecptr parm, uaecptr parm2)
|
||||
size++;
|
||||
}
|
||||
p = banks = get_long (p);
|
||||
snptr = mmubanks = xmalloc (sizeof (struct mmudata) * size);
|
||||
snptr = mmubanks = xmalloc (struct mmudata, size);
|
||||
for (;;) {
|
||||
int off;
|
||||
if (getmmubank(snptr, p))
|
||||
@ -3793,12 +3794,12 @@ int mmu_init(int mode, uaecptr parm, uaecptr parm2)
|
||||
p += 16;
|
||||
off = snptr->addr >> MMU_PAGE_SHIFT;
|
||||
if (mmunl[off] == NULL) {
|
||||
mn = mmunl[off] = xcalloc (sizeof (struct mmunode), 1);
|
||||
mn = mmunl[off] = xcalloc (struct mmunode, 1);
|
||||
} else {
|
||||
mn = mmunl[off];
|
||||
while (mn->next)
|
||||
mn = mn->next;
|
||||
mn = mn->next = xcalloc (sizeof (struct mmunode), 1);
|
||||
mn = mn->next = xcalloc (struct mmunode, 1);
|
||||
}
|
||||
mn->mmubank = snptr;
|
||||
snptr++;
|
||||
@ -134,7 +134,7 @@ typedef struct {
|
||||
#define DRIVE_ID_35HD 0xAAAAAAAA
|
||||
#define DRIVE_ID_525SD 0x55555555 /* 40 track 5.25 drive , kickstart does not recognize this */
|
||||
|
||||
typedef enum { ADF_NORMAL, ADF_EXT1, ADF_EXT2, ADF_FDI, ADF_IPF, ADF_CATWEASEL, ADF_PCDOS } drive_filetype;
|
||||
typedef enum { ADF_NONE = -1, ADF_NORMAL, ADF_EXT1, ADF_EXT2, ADF_FDI, ADF_IPF, ADF_CATWEASEL, ADF_PCDOS } drive_filetype;
|
||||
typedef struct {
|
||||
struct zfile *diskfile;
|
||||
struct zfile *writediskfile;
|
||||
@ -280,7 +280,7 @@ static void createbootblock (uae_u8 *sector, int bootable)
|
||||
memcpy (sector, bootblock, sizeof (bootblock));
|
||||
}
|
||||
|
||||
static void createrootblock (uae_u8 *sector, uae_u8 *disk_name)
|
||||
static void createrootblock (uae_u8 *sector, char *disk_name)
|
||||
{
|
||||
memset (sector, 0, FS_FLOPPY_BLOCKSIZE);
|
||||
sector[0+3] = 2;
|
||||
@ -288,7 +288,7 @@ static void createrootblock (uae_u8 *sector, uae_u8 *disk_name)
|
||||
sector[312] = sector[313] = sector[314] = sector[315] = (uae_u8)0xff;
|
||||
sector[316+2] = 881 >> 8; sector[316+3] = 881 & 255;
|
||||
sector[432] = strlen (disk_name);
|
||||
strcpy (sector + 433, disk_name);
|
||||
strcpy ((char*)sector + 433, disk_name);
|
||||
sector[508 + 3] = 1;
|
||||
disk_date (sector + 420);
|
||||
memcpy (sector + 472, sector + 420, 3 * 4);
|
||||
@ -325,7 +325,7 @@ static int createdirheaderblock (uae_u8 *sector, int parent, const char *filenam
|
||||
pl (sector, 4, block);
|
||||
disk_date (sector + 512 - 92);
|
||||
sector[512 - 80] = strlen (filename);
|
||||
strcpy (sector + 512 - 79, filename);
|
||||
strcpy ((char*)sector + 512 - 79, filename);
|
||||
pl (sector, 512 - 12, parent);
|
||||
pl (sector, 512 - 4, 2);
|
||||
return block;
|
||||
@ -355,7 +355,7 @@ static int createfileheaderblock (struct zfile *z,uae_u8 *sector, int parent, co
|
||||
pl (sector, FS_FLOPPY_BLOCKSIZE - 188, size);
|
||||
disk_date (sector + FS_FLOPPY_BLOCKSIZE - 92);
|
||||
sector[FS_FLOPPY_BLOCKSIZE - 80] = strlen (filename);
|
||||
strcpy (sector + FS_FLOPPY_BLOCKSIZE - 79, filename);
|
||||
strcpy ((char*)sector + FS_FLOPPY_BLOCKSIZE - 79, filename);
|
||||
pl (sector, FS_FLOPPY_BLOCKSIZE - 12, parent);
|
||||
pl (sector, FS_FLOPPY_BLOCKSIZE - 4, -3);
|
||||
extensioncounter = 0;
|
||||
@ -563,7 +563,7 @@ static void drive_image_free (drive *drv)
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
drv->filetype = -1;
|
||||
drv->filetype = ADF_NONE;
|
||||
zfile_fclose (drv->diskfile);
|
||||
drv->diskfile = 0;
|
||||
zfile_fclose (drv->writediskfile);
|
||||
@ -654,8 +654,10 @@ static void update_drive_gui (int num)
|
||||
|
||||
static void drive_fill_bigbuf (drive * drv,int);
|
||||
|
||||
struct zfile *DISK_validate_filename (const TCHAR *fname, int leave_open, int *wrprot, uae_u32 *crc32)
|
||||
int DISK_validate_filename (const TCHAR *fname, int leave_open, int *wrprot, uae_u32 *crc32, struct zfile **zf)
|
||||
{
|
||||
if (zf)
|
||||
*zf = NULL;
|
||||
if (crc32)
|
||||
*crc32 = 0;
|
||||
if (leave_open) {
|
||||
@ -670,7 +672,11 @@ struct zfile *DISK_validate_filename (const TCHAR *fname, int leave_open, int *w
|
||||
}
|
||||
if (f && crc32)
|
||||
*crc32 = zfile_crc32 (f);
|
||||
return f;
|
||||
if (!zf)
|
||||
zfile_fclose (f);
|
||||
else
|
||||
*zf = f;
|
||||
return f ? 1 : 0;
|
||||
} else {
|
||||
if (zfile_exists (fname)) {
|
||||
if (wrprot)
|
||||
@ -681,7 +687,7 @@ struct zfile *DISK_validate_filename (const TCHAR *fname, int leave_open, int *w
|
||||
*crc32 = zfile_crc32 (f);
|
||||
zfile_fclose (f);
|
||||
}
|
||||
return (void*)1;
|
||||
return 1;
|
||||
} else {
|
||||
if (wrprot)
|
||||
*wrprot = 1;
|
||||
@ -719,7 +725,7 @@ static int read_header_ext2 (struct zfile *diskfile, trackid *trackdata, int *nu
|
||||
|
||||
zfile_fseek (diskfile, 0, SEEK_SET);
|
||||
zfile_fread (buffer, 1, 8, diskfile);
|
||||
if (strncmp (buffer, "UAE-1ADF", 8))
|
||||
if (strncmp ((char*)buffer, "UAE-1ADF", 8))
|
||||
return 0;
|
||||
zfile_fread (buffer, 1, 4, diskfile);
|
||||
*num_tracks = buffer[2] * 256 + buffer[3];
|
||||
@ -728,7 +734,7 @@ static int read_header_ext2 (struct zfile *diskfile, trackid *trackdata, int *nu
|
||||
for (i = 0; i < (*num_tracks); i++) {
|
||||
tid = trackdata + i;
|
||||
zfile_fread (buffer, 2 + 2 + 4 + 4, 1, diskfile);
|
||||
tid->type = buffer[3];
|
||||
tid->type = (image_tracktype)buffer[3];
|
||||
tid->revolutions = buffer[2] + 1;
|
||||
tid->len = buffer[5] * 65536 + buffer[6] * 256 + buffer[7];
|
||||
tid->bitlen = buffer[9] * 65536 + buffer[10] * 256 + buffer[11];
|
||||
@ -771,7 +777,9 @@ TCHAR *DISK_get_saveimagepath (const TCHAR *name)
|
||||
|
||||
static struct zfile *getwritefile (const TCHAR *name, int *wrprot)
|
||||
{
|
||||
return DISK_validate_filename (DISK_get_saveimagepath (name), 1, wrprot, NULL);
|
||||
struct zfile *zf;
|
||||
DISK_validate_filename (DISK_get_saveimagepath (name), 1, wrprot, NULL, &zf);
|
||||
return zf;
|
||||
}
|
||||
|
||||
static int iswritefileempty (const TCHAR *name)
|
||||
@ -826,7 +834,7 @@ static int diskfile_iswriteprotect (const TCHAR *fname, int *needwritefile, driv
|
||||
|
||||
*needwritefile = 0;
|
||||
*drvtype = DRV_35_DD;
|
||||
zf1 = DISK_validate_filename (fname, 1, &wrprot1, NULL);
|
||||
DISK_validate_filename (fname, 1, &wrprot1, NULL, &zf1);
|
||||
if (!zf1)
|
||||
return 1;
|
||||
if (zfile_iscompressed (zf1)) {
|
||||
@ -867,11 +875,11 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const TCHAR
|
||||
trackid *tid;
|
||||
int num_tracks, size;
|
||||
int canauto;
|
||||
TCHAR *ext;
|
||||
const TCHAR *ext;
|
||||
|
||||
gui_disk_image_change (dnum, fname);
|
||||
drive_image_free (drv);
|
||||
drv->diskfile = DISK_validate_filename (fname, 1, &drv->wrprot, &drv->crc32);
|
||||
DISK_validate_filename (fname, 1, &drv->wrprot, &drv->crc32, &drv->diskfile);
|
||||
drv->ddhd = 1;
|
||||
drv->num_secs = 0;
|
||||
drv->hard_num_cyls = p->dfxtype[dnum] == DRV_525_SD ? 40 : 80;
|
||||
@ -1666,7 +1674,7 @@ static void drive_fill_bigbuf (drive * drv, int force)
|
||||
}
|
||||
|
||||
/* Update ADF_EXT2 track header */
|
||||
static void diskfile_update (struct zfile *diskfile, trackid *ti, int len, uae_u8 type)
|
||||
static void diskfile_update (struct zfile *diskfile, trackid *ti, int len, image_tracktype type)
|
||||
{
|
||||
uae_u8 buf[2 + 2 + 4 + 4], *zerobuf;
|
||||
|
||||
@ -1681,7 +1689,7 @@ static void diskfile_update (struct zfile *diskfile, trackid *ti, int len, uae_u
|
||||
do_put_mem_long ((uae_u32 *) (buf + 8), ti->bitlen);
|
||||
zfile_fwrite (buf, sizeof (buf), 1, diskfile);
|
||||
if (ti->len > (len + 7) / 8) {
|
||||
zerobuf = malloc (ti->len);
|
||||
zerobuf = xmalloc (uae_u8, ti->len);
|
||||
memset (zerobuf, 0, ti->len);
|
||||
zfile_fseek (diskfile, ti->offs, SEEK_SET);
|
||||
zfile_fwrite (zerobuf, 1, ti->len, diskfile);
|
||||
@ -2059,7 +2067,7 @@ void disk_creatediskfile (TCHAR *name, int type, drive_type adftype, TCHAR *disk
|
||||
}
|
||||
|
||||
f = zfile_fopen (name, L"wb", 0);
|
||||
chunk = xmalloc (32768);
|
||||
chunk = xmalloc (uae_u8, 32768);
|
||||
if (f && chunk) {
|
||||
int cylsize = sectors * 2 * 512;
|
||||
memset (chunk, 0, 32768);
|
||||
@ -2069,7 +2077,7 @@ void disk_creatediskfile (TCHAR *name, int type, drive_type adftype, TCHAR *disk
|
||||
if (adftype <= 1) {
|
||||
if (i == 0) {
|
||||
/* boot block */
|
||||
strcpy (chunk, "DOS");
|
||||
strcpy ((char*)chunk, "DOS");
|
||||
} else if (i == file_size / 2) {
|
||||
int block = file_size / 1024;
|
||||
/* root block */
|
||||
@ -2079,7 +2087,7 @@ void disk_creatediskfile (TCHAR *name, int type, drive_type adftype, TCHAR *disk
|
||||
chunk[316+2] = (block + 1) >> 8; chunk[316+3] = (block + 1) & 255;
|
||||
s = ua (disk_name);
|
||||
chunk[432] = strlen (s);
|
||||
strcpy (chunk + 433, s);
|
||||
strcpy ((char*)chunk + 433, s);
|
||||
xfree (s);
|
||||
chunk[508 + 3] = 1;
|
||||
disk_date (chunk + 420);
|
||||
@ -2172,7 +2180,7 @@ int disk_setwriteprotect (int num, const TCHAR *name, int protect)
|
||||
drive_type drvtype;
|
||||
|
||||
oldprotect = diskfile_iswriteprotect (name, &needwritefile, &drvtype);
|
||||
zf1 = DISK_validate_filename (name, 1, &wrprot1, NULL);
|
||||
DISK_validate_filename (name, 1, &wrprot1, NULL, &zf1);
|
||||
if (!zf1)
|
||||
return 0;
|
||||
if (zfile_iscompressed (zf1))
|
||||
@ -3496,7 +3504,7 @@ static uae_u32 getadfcrc (drive *drv)
|
||||
return 0;
|
||||
zfile_fseek (drv->diskfile, 0, SEEK_END);
|
||||
size = zfile_ftell (drv->diskfile);
|
||||
b = (uae_u8*)malloc (size);
|
||||
b = xmalloc (uae_u8, size);
|
||||
if (!b)
|
||||
return 0;
|
||||
zfile_fseek (drv->diskfile, 0, SEEK_SET);
|
||||
@ -3515,7 +3523,7 @@ uae_u8 *save_disk (int num, int *len, uae_u8 *dstptr)
|
||||
if (dstptr)
|
||||
dstbak = dst = dstptr;
|
||||
else
|
||||
dstbak = dst = xmalloc (2+1+1+1+1+4+4+256);
|
||||
dstbak = dst = xmalloc (uae_u8, 2+1+1+1+1+4+4+256);
|
||||
save_u32 (drv->drive_id); /* drive type ID */
|
||||
save_u8 ((drv->motoroff ? 0:1) | ((disabled & (1 << num)) ? 2 : 0) | (drv->idbit ? 4 : 0) | (drv->dskchange ? 8 : 0));
|
||||
save_u8 (drv->cyl); /* cylinder */
|
||||
@ -3555,7 +3563,7 @@ uae_u8 *save_floppy(int *len, uae_u8 *dstptr)
|
||||
if (dstptr)
|
||||
dstbak = dst = dstptr;
|
||||
else
|
||||
dstbak = dst = xmalloc (2 + 1 + 1 + 1 + 1 + 2);
|
||||
dstbak = dst = xmalloc (uae_u8, 2 + 1 + 1 + 1 + 1 + 2);
|
||||
save_u16 (word); /* current fifo (low word) */
|
||||
save_u8 (bitoffset); /* dma bit offset */
|
||||
save_u8 (dma_enable); /* disk sync found */
|
||||
@ -866,7 +866,7 @@ STATIC_INLINE uae_u8 render_sprites (int pos, int dualpf, uae_u8 apixel, int aga
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "linetoscr.c"
|
||||
#include "linetoscr.cpp"
|
||||
|
||||
#ifdef ECS_DENISE
|
||||
/* ECS SuperHires special cases */
|
||||
@ -1724,8 +1724,8 @@ static void init_aspect_maps (void)
|
||||
xfree (amiga2aspect_line_map);
|
||||
|
||||
/* At least for this array the +1 is necessary. */
|
||||
amiga2aspect_line_map = xmalloc (sizeof (int) * (MAXVPOS + 1) * 2 + 1);
|
||||
native2amiga_line_map = xmalloc (sizeof (int) * gfxvidinfo.height);
|
||||
amiga2aspect_line_map = xmalloc (int, (MAXVPOS + 1) * 2 + 1);
|
||||
native2amiga_line_map = xmalloc (int, gfxvidinfo.height);
|
||||
|
||||
maxl = (MAXVPOS + 1) * (linedbld ? 2 : 1);
|
||||
min_ypos_for_screen = minfirstline << (linedbl ? 1 : 0);
|
||||
@ -49,7 +49,7 @@ uae_s16 *decodewav (uae_u8 *s, int *lenp)
|
||||
if (!memcmp (s, "data", 4)) {
|
||||
s += 4;
|
||||
len = s[0] | (s[1] << 8) | (s[2] << 16) | (s[3] << 24);
|
||||
dst = xmalloc (len);
|
||||
dst = xmalloc (uae_s16, len / 2);
|
||||
memcpy (dst, s + 4, len);
|
||||
*lenp = len / 2;
|
||||
return dst;
|
||||
@ -78,7 +78,7 @@ static int loadsample (TCHAR *path, struct drvsample *ds)
|
||||
}
|
||||
zfile_fseek (f, 0, SEEK_END);
|
||||
size = zfile_ftell (f);
|
||||
buf = xmalloc (size);
|
||||
buf = xmalloc (uae_u8, size);
|
||||
zfile_fseek (f, 0, SEEK_SET);
|
||||
zfile_fread (buf, size, 1, f);
|
||||
zfile_fclose (f);
|
||||
@ -216,7 +216,7 @@ void driveclick_reset (void)
|
||||
clickbuffer = NULL;
|
||||
if (!wave_initialized)
|
||||
return;
|
||||
clickbuffer = xmalloc (paula_sndbufsize);
|
||||
clickbuffer = xmalloc (uae_s16, paula_sndbufsize / 2);
|
||||
sample_step = (freq << DS_SHIFT) / currprefs.sound_freq;
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ static int enforcer_decode_hunk_and_offset (TCHAR *buf, uae_u32 pc)
|
||||
uae_u8 *native_string = amiga2native (string, 100);
|
||||
|
||||
if (native_string) {
|
||||
if (!strcmp (native_string, "SegTracker"))
|
||||
if (!strcmp ((char*)native_string, "SegTracker"))
|
||||
break;
|
||||
}
|
||||
node = amiga_node_next (node);
|
||||
@ -162,7 +162,7 @@ static int enforcer_decode_hunk_and_offset (TCHAR *buf, uae_u32 pc)
|
||||
offset = pc - address - 4;
|
||||
name = get_long (node + 8); /* ln_Name */
|
||||
if (name) {
|
||||
native_name = au (amiga2native(name,100));
|
||||
native_name = au ((char*)amiga2native(name,100));
|
||||
if (!native_name)
|
||||
native_name = my_strdup (L"Unknown");
|
||||
} else {
|
||||
@ -213,7 +213,7 @@ static void enforcer_display_hit (const TCHAR *addressmode, uae_u32 pc, uaecptr
|
||||
goto end;
|
||||
|
||||
task_name = get_long (this_task + 10); /* ln_Name */
|
||||
native_task_name = au (amiga2native (task_name, 100));
|
||||
native_task_name = au ((char*)amiga2native (task_name, 100));
|
||||
/*if (strcmp(native_task_name,"c:MCP")!=0)
|
||||
{
|
||||
Exception (0x2d,0);
|
||||
@ -797,7 +797,7 @@ static void resetPrinterHard(void)
|
||||
resetPrinter();
|
||||
}
|
||||
|
||||
static printer_init(Bit16u dpi2, Bit16u width, Bit16u height, TCHAR* output2, int multipageOutput2, int numpins)
|
||||
static int printer_init(Bit16u dpi2, Bit16u width, Bit16u height, TCHAR* output2, int multipageOutput2, int numpins)
|
||||
{
|
||||
pins = numpins;
|
||||
if (ft == NULL || FT_Init_FreeType(&FTlib))
|
||||
@ -818,7 +818,7 @@ static printer_init(Bit16u dpi2, Bit16u width, Bit16u height, TCHAR* output2, in
|
||||
page_h = (Bitu)(defaultPageHeight*dpi);
|
||||
pagesize = page_w * page_h;
|
||||
page_pitch = page_w;
|
||||
page = xcalloc (pagesize, 1);
|
||||
page = xcalloc (uae_u8, pagesize);
|
||||
curFont = NULL;
|
||||
charRead = false;
|
||||
autoFeed = false;
|
||||
@ -856,10 +856,11 @@ static printer_init(Bit16u dpi2, Bit16u width, Bit16u height, TCHAR* output2, in
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
};
|
||||
|
||||
|
||||
static printer_close(void)
|
||||
static void printer_close(void)
|
||||
{
|
||||
if (page != NULL)
|
||||
{
|
||||
@ -1473,7 +1474,7 @@ static int processCommandChar(Bit8u ch)
|
||||
break;
|
||||
case 0x6b: // Select typeface (ESC k)
|
||||
if (params[0] <= 11 || params[0] == 30 || params[0] == 31)
|
||||
LQtypeFace = params[0];
|
||||
LQtypeFace = (Typeface)params[0];
|
||||
updateFont();
|
||||
break;
|
||||
case 0x6c: // Set left margin (ESC 1)
|
||||
@ -947,7 +947,7 @@ static void expamem_init_filesys (void)
|
||||
* Zorro III expansion memory
|
||||
*/
|
||||
|
||||
static void expamem_map_z3fastmem_2 (addrbank *bank, int *startp, uae_u32 size, uae_u32 allocated)
|
||||
static void expamem_map_z3fastmem_2 (addrbank *bank, uaecptr *startp, uae_u32 size, uae_u32 allocated)
|
||||
{
|
||||
int z3fs = ((expamem_hi | (expamem_lo >> 4)) << 16);
|
||||
int start = *startp;
|
||||
@ -105,7 +105,7 @@ static void *fdi_malloc (int size)
|
||||
return (int*)p + 1;
|
||||
}
|
||||
#else
|
||||
#define fdi_free free
|
||||
#define fdi_free xfree
|
||||
#define fdi_malloc xmalloc
|
||||
#endif
|
||||
|
||||
@ -195,10 +195,10 @@ static uae_u8 *expand_tree (uae_u8 *stream, NODE *node)
|
||||
temp = *stream++;
|
||||
temp2 = 0x80;
|
||||
}
|
||||
node->left = (NODE*)fdi_malloc (sizeof (NODE));
|
||||
node->left = fdi_malloc (NODE, 1);
|
||||
memset (node->left, 0, sizeof (NODE));
|
||||
stream_temp = expand_tree (stream, node->left);
|
||||
node->right = (NODE*)fdi_malloc (sizeof (NODE));
|
||||
node->right = fdi_malloc (NODE ,1);
|
||||
memset (node->right, 0, sizeof (NODE));
|
||||
return expand_tree (stream_temp, node->right);
|
||||
}
|
||||
@ -1358,7 +1358,7 @@ static uae_u8 *fdi_decompress (int pulses, uae_u8 *sizep, uae_u8 *src, int *dofr
|
||||
src += 4;
|
||||
}
|
||||
} else if (mode == 1) {
|
||||
dst = (uae_u8*)fdi_malloc (pulses *4);
|
||||
dst = fdi_malloc (uae_u8, pulses *4);
|
||||
*dofree = 1;
|
||||
fdi_decode (src, pulses, dst);
|
||||
} else {
|
||||
@ -1864,7 +1864,7 @@ static int decode_lowlevel_track (FDI *fdi, int track, struct fdi_cache *cache)
|
||||
idx_off3 = 4;
|
||||
}
|
||||
} else {
|
||||
idxp = (uae_u8*)fdi_malloc (pulses * 2);
|
||||
idxp = fdi_malloc (uae_u8, pulses * 2);
|
||||
idx_free = 1;
|
||||
for (i = 0; i < pulses; i++) {
|
||||
idxp[i * 2 + 0] = 2;
|
||||
@ -2015,7 +2015,7 @@ FDI *fdi2raw_header(struct zfile *f)
|
||||
FDI *fdi;
|
||||
|
||||
debuglog ("ALLOC: memory allocated %d\n", fdi_allocated);
|
||||
fdi = (FDI*)fdi_malloc(sizeof(FDI));
|
||||
fdi = fdi_malloc (FDI, 1);
|
||||
memset (fdi, 0, sizeof (FDI));
|
||||
fdi->file = f;
|
||||
oldseek = zfile_ftell (fdi->file);
|
||||
@ -2041,10 +2041,10 @@ FDI *fdi2raw_header(struct zfile *f)
|
||||
}
|
||||
}
|
||||
|
||||
fdi->mfmsync_buffer = (int*)fdi_malloc (MAX_MFM_SYNC_BUFFER * sizeof(int));
|
||||
fdi->track_src_buffer = (uae_u8*)fdi_malloc (MAX_SRC_BUFFER);
|
||||
fdi->track_dst_buffer = (uae_u8*)fdi_malloc (MAX_DST_BUFFER);
|
||||
fdi->track_dst_buffer_timing = (uae_u16*)fdi_malloc (MAX_TIMING_BUFFER);
|
||||
fdi->mfmsync_buffer = fdi_malloc (int, MAX_MFM_SYNC_BUFFER);
|
||||
fdi->track_src_buffer = fdi_malloc (uae_u8, MAX_SRC_BUFFER);
|
||||
fdi->track_dst_buffer = fdi_malloc (uae_u8, MAX_DST_BUFFER);
|
||||
fdi->track_dst_buffer_timing = fdi_malloc (uae_u16, MAX_TIMING_BUFFER / 2);
|
||||
|
||||
fdi->last_track = ((fdi->header[142] << 8) + fdi->header[143]) + 1;
|
||||
fdi->last_track *= fdi->header[144] + 1;
|
||||
@ -136,7 +136,7 @@ typedef struct {
|
||||
uae_thread_id tid;
|
||||
struct _unit *self;
|
||||
/* Reset handling */
|
||||
volatile uae_sem_t reset_sync_sem;
|
||||
uae_sem_t reset_sync_sem;
|
||||
volatile int reset_state;
|
||||
|
||||
/* RDB stuff */
|
||||
@ -365,7 +365,7 @@ TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, const
|
||||
continue;
|
||||
if (!_tcscmp (p + i, L":\\")) {
|
||||
xfree (p);
|
||||
p = xmalloc (10 * sizeof (TCHAR));
|
||||
p = xmalloc (TCHAR, 10);
|
||||
p[0] = rootdir[0];
|
||||
p[1] = 0;
|
||||
i = 0;
|
||||
@ -777,7 +777,7 @@ typedef struct key {
|
||||
struct key *next;
|
||||
a_inode *aino;
|
||||
uae_u32 uniq;
|
||||
void *fd;
|
||||
struct fs_filehandle *fd;
|
||||
uae_u64 file_pos;
|
||||
int dosmode;
|
||||
int createmode;
|
||||
@ -793,7 +793,7 @@ typedef struct notify {
|
||||
|
||||
typedef struct exallkey {
|
||||
uae_u32 id;
|
||||
void *dirhandle;
|
||||
struct fs_dirhandle *dirhandle;
|
||||
TCHAR *fn;
|
||||
uaecptr control;
|
||||
} ExAllKey;
|
||||
@ -963,60 +963,72 @@ static Unit*
|
||||
return u;
|
||||
}
|
||||
|
||||
static struct fs_dirhandle *fs_opendir (Unit *u, const TCHAR *nname)
|
||||
{
|
||||
struct fs_dirhandle *fsd = xmalloc (struct fs_dirhandle, 1);
|
||||
fsd->isarch = !!(u->volflags & MYVOLUMEINFO_ARCHIVE);
|
||||
if (fsd->isarch)
|
||||
fsd->zd = zfile_opendir_archive (nname);
|
||||
else
|
||||
fsd->od = my_opendir (nname);
|
||||
return fsd;
|
||||
}
|
||||
static void fs_closedir (struct fs_dirhandle *fsd)
|
||||
{
|
||||
if (!fsd)
|
||||
return;
|
||||
if (fsd->isarch)
|
||||
zfile_closedir_archive (fsd->zd);
|
||||
else
|
||||
my_closedir (fsd->od);
|
||||
xfree (fsd);
|
||||
}
|
||||
static struct fs_filehandle *fs_open (Unit *unit, const TCHAR *name, int flags)
|
||||
{
|
||||
struct fs_filehandle *fsf = xmalloc (struct fs_filehandle, 1);
|
||||
fsf->isarch = !!(unit->volflags & MYVOLUMEINFO_ARCHIVE);
|
||||
if (fsf->isarch)
|
||||
fsf->zf = zfile_open_archive (name, flags);
|
||||
else
|
||||
fsf->of = my_open (name, flags);
|
||||
return fsf;
|
||||
}
|
||||
static void fs_close (struct fs_filehandle *fd)
|
||||
{
|
||||
if (!fd)
|
||||
return;
|
||||
if (fd->isarch)
|
||||
zfile_close_archive (fd->zf);
|
||||
else
|
||||
my_close (fd->of);
|
||||
}
|
||||
static unsigned int fs_read (struct fs_filehandle *fsf, void *b, unsigned int size)
|
||||
{
|
||||
if (fsf->isarch)
|
||||
return zfile_read_archive (fsf->zf, b, size);
|
||||
else
|
||||
return my_read (fsf->of, b, size);
|
||||
}
|
||||
static unsigned int fs_write (struct fs_filehandle *fsf, void *b, unsigned int size)
|
||||
{
|
||||
if (fsf->isarch)
|
||||
return 0;
|
||||
return my_write (fsf->of, b, size);
|
||||
}
|
||||
|
||||
static void *fs_opendir (Unit *u, const TCHAR *nname)
|
||||
static uae_u64 fs_lseek64 (struct fs_filehandle *fsf, uae_s64 offset, int whence)
|
||||
{
|
||||
if (u->volflags & MYVOLUMEINFO_ARCHIVE)
|
||||
return zfile_opendir_archive (nname);
|
||||
if (fsf->isarch)
|
||||
return zfile_lseek_archive (fsf->zf, offset, whence);
|
||||
else
|
||||
return my_opendir (nname);
|
||||
return my_lseek (fsf->of, offset, whence);
|
||||
}
|
||||
static void fs_closedir (Unit *u, void *d)
|
||||
static uae_u32 fs_lseek (struct fs_filehandle *fsf, uae_s32 offset, int whence)
|
||||
{
|
||||
if (u->volflags & MYVOLUMEINFO_ARCHIVE)
|
||||
zfile_closedir_archive (d);
|
||||
if (fsf->isarch)
|
||||
return (uae_u32)zfile_lseek_archive (fsf->zf, (uae_s32)offset, whence);
|
||||
else
|
||||
my_closedir (d);
|
||||
}
|
||||
static void *fs_open (Unit *unit, const TCHAR *name, int flags)
|
||||
{
|
||||
int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
|
||||
if (isarch)
|
||||
return zfile_open_archive (name, flags);
|
||||
else
|
||||
return my_open (name, flags);
|
||||
}
|
||||
static void fs_close (Unit *unit, void *fd)
|
||||
{
|
||||
int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
|
||||
if (isarch)
|
||||
zfile_close_archive (fd);
|
||||
else
|
||||
my_close (fd);
|
||||
}
|
||||
static unsigned int fs_read (Unit *unit, void *d, void *b, unsigned int size)
|
||||
{
|
||||
int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
|
||||
if (isarch)
|
||||
return zfile_read_archive (d, b, size);
|
||||
else
|
||||
return my_read (d, b, size);
|
||||
}
|
||||
static uae_u64 fs_lseek64 (Unit *unit, void *d, uae_s64 offset, int whence)
|
||||
{
|
||||
int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
|
||||
if (isarch)
|
||||
return zfile_lseek_archive (d, offset, whence);
|
||||
else
|
||||
return my_lseek (d, offset, whence);
|
||||
}
|
||||
static uae_u32 fs_lseek (Unit *unit, void *d, uae_s32 offset, int whence)
|
||||
{
|
||||
int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
|
||||
if (isarch)
|
||||
return (uae_u32)zfile_lseek_archive (d, (uae_s32)offset, whence);
|
||||
else
|
||||
return (uae_u32)my_lseek (d, (uae_s32)offset, whence);
|
||||
return (uae_u32)my_lseek (fsf->of, (uae_s32)offset, whence);
|
||||
}
|
||||
static void set_volume_name (Unit *unit)
|
||||
{
|
||||
@ -1051,7 +1063,7 @@ static void clear_exkeys (Unit *unit)
|
||||
unit->examine_keys[i].uniq = 0;
|
||||
}
|
||||
for (i = 0; i < EXALLKEYS; i++) {
|
||||
fs_closedir (unit, unit->exalls[i].dirhandle);
|
||||
fs_closedir (unit->exalls[i].dirhandle);
|
||||
unit->exalls[i].dirhandle = NULL;
|
||||
xfree (unit->exalls[i].fn);
|
||||
unit->exalls[i].fn = NULL;
|
||||
@ -1479,7 +1491,7 @@ static void update_child_names (Unit *unit, a_inode *a, a_inode *parent)
|
||||
write_log (L"malformed file name");
|
||||
}
|
||||
name_start++;
|
||||
new_name = xmalloc ((_tcslen (name_start) + l0) * sizeof (TCHAR));
|
||||
new_name = xmalloc (TCHAR, _tcslen (name_start) + l0);
|
||||
_tcscpy (new_name, parent->nname);
|
||||
_tcscat (new_name, dirsep);
|
||||
_tcscat (new_name, name_start);
|
||||
@ -1594,7 +1606,7 @@ static a_inode *lookup_aino (Unit *unit, uae_u32 uniq)
|
||||
TCHAR *build_nname (const TCHAR *d, const TCHAR *n)
|
||||
{
|
||||
TCHAR dsep[2] = { FSDB_DIR_SEPARATOR, 0 };
|
||||
TCHAR *p = xmalloc ((_tcslen (d) + 1 + _tcslen (n) + 1) * sizeof (TCHAR));
|
||||
TCHAR *p = xmalloc (TCHAR, _tcslen (d) + 1 + _tcslen (n) + 1);
|
||||
_tcscpy (p, d);
|
||||
_tcscat (p, dsep);
|
||||
_tcscat (p, n);
|
||||
@ -1603,7 +1615,7 @@ TCHAR *build_nname (const TCHAR *d, const TCHAR *n)
|
||||
|
||||
TCHAR *build_aname (const TCHAR *d, const TCHAR *n)
|
||||
{
|
||||
TCHAR *p = xmalloc ((_tcslen (d) + 1 + _tcslen (n) + 1) * sizeof (TCHAR));
|
||||
TCHAR *p = xmalloc (TCHAR, _tcslen (d) + 1 + _tcslen (n) + 1);
|
||||
_tcscpy (p, d);
|
||||
_tcscat (p, L"/");
|
||||
_tcscat (p, n);
|
||||
@ -1775,7 +1787,7 @@ static a_inode *new_child_aino (Unit *unit, a_inode *base, TCHAR *rel)
|
||||
if (nn == 0)
|
||||
return 0;
|
||||
|
||||
aino = xcalloc (sizeof (a_inode), 1);
|
||||
aino = xcalloc (a_inode, 1);
|
||||
if (aino == 0)
|
||||
return 0;
|
||||
aino->aname = modified_rel ? modified_rel : my_strdup (rel);
|
||||
@ -1800,7 +1812,7 @@ static a_inode *new_child_aino (Unit *unit, a_inode *base, TCHAR *rel)
|
||||
|
||||
static a_inode *create_child_aino (Unit *unit, a_inode *base, TCHAR *rel, int isdir)
|
||||
{
|
||||
a_inode *aino = xcalloc (sizeof (a_inode), 1);
|
||||
a_inode *aino = xcalloc (a_inode, 1);
|
||||
if (aino == 0)
|
||||
return 0;
|
||||
|
||||
@ -1824,7 +1836,7 @@ static a_inode *create_child_aino (Unit *unit, a_inode *base, TCHAR *rel, int is
|
||||
return aino;
|
||||
}
|
||||
|
||||
static a_inode *lookup_child_aino (Unit *unit, a_inode *base, TCHAR *rel, uae_u32 *err)
|
||||
static a_inode *lookup_child_aino (Unit *unit, a_inode *base, TCHAR *rel, int *err)
|
||||
{
|
||||
a_inode *c = base->child;
|
||||
int l0 = _tcslen (rel);
|
||||
@ -1876,7 +1888,7 @@ static a_inode *lookup_child_aino_for_exnext (Unit *unit, a_inode *base, TCHAR *
|
||||
if (!isarch)
|
||||
c = fsdb_lookup_aino_nname (base, rel);
|
||||
if (c == 0) {
|
||||
c = xcalloc (sizeof (a_inode), 1);
|
||||
c = xcalloc (a_inode, 1);
|
||||
if (c == 0) {
|
||||
*err = ERROR_NO_FREE_STORE;
|
||||
return 0;
|
||||
@ -1902,7 +1914,7 @@ static a_inode *lookup_child_aino_for_exnext (Unit *unit, a_inode *base, TCHAR *
|
||||
return c;
|
||||
}
|
||||
|
||||
static a_inode *get_aino (Unit *unit, a_inode *base, const TCHAR *rel, uae_u32 *err)
|
||||
static a_inode *get_aino (Unit *unit, a_inode *base, const TCHAR *rel, int *err)
|
||||
{
|
||||
TCHAR *tmp;
|
||||
TCHAR *p;
|
||||
@ -1968,7 +1980,7 @@ static uae_u32 notifyhash (TCHAR *s)
|
||||
|
||||
static Notify *new_notify (Unit *unit, TCHAR *name)
|
||||
{
|
||||
Notify *n = xmalloc (sizeof (Notify));
|
||||
Notify *n = xmalloc (Notify, 1);
|
||||
uae_u32 hash = notifyhash (name);
|
||||
n->next = unit->notifyhash[hash];
|
||||
unit->notifyhash[hash] = n;
|
||||
@ -2018,7 +2030,7 @@ static Unit *startup_create_unit (UnitInfo *uinfo, int num)
|
||||
int i;
|
||||
Unit *unit, *u;
|
||||
|
||||
unit = xcalloc (sizeof (Unit), 1);
|
||||
unit = xcalloc (Unit, 1);
|
||||
/* keep list in insertion order */
|
||||
u = units;
|
||||
if (u) {
|
||||
@ -2089,8 +2101,8 @@ static void filesys_start_thread (UnitInfo *ui, int nr)
|
||||
}
|
||||
#ifdef UAE_FILESYS_THREADS
|
||||
if (is_hardfile (nr) == FILESYS_VIRTUAL) {
|
||||
ui->unit_pipe = xmalloc (sizeof (smp_comm_pipe));
|
||||
ui->back_pipe = xmalloc (sizeof (smp_comm_pipe));
|
||||
ui->unit_pipe = xmalloc (smp_comm_pipe, 1);
|
||||
ui->back_pipe = xmalloc (smp_comm_pipe, 1);
|
||||
init_comm_pipe (ui->unit_pipe, 100, 3);
|
||||
init_comm_pipe (ui->back_pipe, 100, 1);
|
||||
uae_start_thread (L"filesys", filesys_thread, (void *)ui, &ui->tid);
|
||||
@ -2259,7 +2271,7 @@ static void free_key (Unit *unit, Key *k)
|
||||
}
|
||||
|
||||
if (k->fd != NULL)
|
||||
fs_close (unit, k->fd);
|
||||
fs_close (k->fd);
|
||||
|
||||
xfree(k);
|
||||
}
|
||||
@ -2281,7 +2293,7 @@ static Key *lookup_key (Unit *unit, uae_u32 uniq)
|
||||
|
||||
static Key *new_key (Unit *unit)
|
||||
{
|
||||
Key *k = xcalloc (sizeof (Key), 1);
|
||||
Key *k = xcalloc (Key, 1);
|
||||
k->uniq = ++key_uniq;
|
||||
k->fd = NULL;
|
||||
k->file_pos = 0;
|
||||
@ -2313,7 +2325,7 @@ static void
|
||||
TRACE((L" }\n"));
|
||||
}
|
||||
|
||||
static a_inode *find_aino (Unit *unit, uaecptr lock, const TCHAR *name, uae_u32 *err)
|
||||
static a_inode *find_aino (Unit *unit, uaecptr lock, const TCHAR *name, int *err)
|
||||
{
|
||||
a_inode *a;
|
||||
|
||||
@ -2391,7 +2403,7 @@ static void notify_check (Unit *unit, a_inode *a)
|
||||
for (n = unit->notifyhash[hash]; n; n = n->next) {
|
||||
uaecptr nr = n->notifyrequest;
|
||||
if (same_aname(n->partname, a->aname)) {
|
||||
uae_u32 err;
|
||||
int err;
|
||||
a_inode *a2 = find_aino (unit, 0, n->fullname, &err);
|
||||
if (err == 0 && a == a2)
|
||||
notify_send (unit, n);
|
||||
@ -2402,7 +2414,7 @@ static void notify_check (Unit *unit, a_inode *a)
|
||||
for (n = unit->notifyhash[hash]; n; n = n->next) {
|
||||
uaecptr nr = n->notifyrequest;
|
||||
if (same_aname(n->partname, a->parent->aname)) {
|
||||
uae_u32 err;
|
||||
int err;
|
||||
a_inode *a2 = find_aino (unit, 0, n->fullname, &err);
|
||||
if (err == 0 && a->parent == a2)
|
||||
notify_send (unit, n);
|
||||
@ -2457,7 +2469,7 @@ static void
|
||||
n->notifyrequest = nr;
|
||||
n->fullname = name;
|
||||
if (flags & NRF_NOTIFY_INITIAL) {
|
||||
uae_u32 err;
|
||||
int err;
|
||||
a_inode *a = find_aino (unit, 0, n->fullname, &err);
|
||||
if (err == 0)
|
||||
notify_send (unit, n);
|
||||
@ -2522,7 +2534,7 @@ static void
|
||||
uaecptr name = GET_PCK_ARG2 (packet) << 2;
|
||||
long mode = GET_PCK_ARG3 (packet);
|
||||
a_inode *a;
|
||||
uae_u32 err;
|
||||
int err;
|
||||
|
||||
if (mode != SHARED_LOCK && mode != EXCLUSIVE_LOCK) {
|
||||
TRACE((L"Bad mode %d (should be %d or %d).\n", mode, SHARED_LOCK, EXCLUSIVE_LOCK));
|
||||
@ -2883,7 +2895,8 @@ static int exalldo (uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaec
|
||||
int size, size2;
|
||||
int entrytype;
|
||||
TCHAR *xs = NULL, *commentx = NULL;
|
||||
uae_u32 flags = 15, days, mins, ticks;
|
||||
uae_u32 flags = 15;
|
||||
long days, mins, ticks;
|
||||
struct _stat64 statbuf;
|
||||
int fsdb_can = fsdb_cando (unit);
|
||||
uae_u16 uid = 0, gid = 0;
|
||||
@ -2998,8 +3011,7 @@ static int action_examine_all_do (Unit *unit, uaecptr lock, ExAllKey *eak, uaecp
|
||||
a_inode *aino, *base;
|
||||
int ok;
|
||||
uae_u32 err;
|
||||
int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
|
||||
void *d;
|
||||
struct fs_dirhandle *d;
|
||||
TCHAR fn[MAX_DPATH];
|
||||
|
||||
if (lock != 0)
|
||||
@ -3010,11 +3022,11 @@ static int action_examine_all_do (Unit *unit, uaecptr lock, ExAllKey *eak, uaecp
|
||||
d = eak->dirhandle;
|
||||
if (!eak->fn) {
|
||||
do {
|
||||
if (isarch)
|
||||
ok = zfile_readdir_archive (d, fn);
|
||||
if (d->isarch)
|
||||
ok = zfile_readdir_archive (d->zd, fn);
|
||||
else
|
||||
ok = my_readdir (d, fn);
|
||||
} while (ok && !isarch && fsdb_name_invalid (fn));
|
||||
ok = my_readdir (d->od, fn);
|
||||
} while (ok && !d->isarch && fsdb_name_invalid (fn));
|
||||
if (!ok)
|
||||
return 0;
|
||||
} else {
|
||||
@ -3054,7 +3066,7 @@ static int action_examine_all_end (Unit *unit, dpacket packet)
|
||||
doserr = ERROR_OBJECT_WRONG_TYPE;
|
||||
} else {
|
||||
eak->id = 0;
|
||||
fs_closedir (unit, eak->dirhandle);
|
||||
fs_closedir (eak->dirhandle);
|
||||
xfree (eak->fn);
|
||||
eak->fn = NULL;
|
||||
eak->dirhandle = NULL;
|
||||
@ -3077,9 +3089,8 @@ static int action_examine_all (Unit *unit, dpacket packet)
|
||||
uaecptr control = GET_PCK_ARG5 (packet);
|
||||
|
||||
ExAllKey *eak = NULL;
|
||||
int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
|
||||
a_inode *base;
|
||||
void *d;
|
||||
struct fs_dirhandle *d;
|
||||
int ok, i;
|
||||
uaecptr exp;
|
||||
uae_u32 id, doserr = ERROR_NO_MORE_ENTRIES;
|
||||
@ -3175,7 +3186,7 @@ fail:
|
||||
PUT_PCK_RES2 (packet, doserr);
|
||||
if (eak) {
|
||||
eak->id = 0;
|
||||
fs_closedir (unit, eak->dirhandle);
|
||||
fs_closedir (eak->dirhandle);
|
||||
eak->dirhandle = NULL;
|
||||
xfree (eak->fn);
|
||||
eak->fn = NULL;
|
||||
@ -3239,9 +3250,8 @@ finished - they may never finish! */
|
||||
|
||||
static void populate_directory (Unit *unit, a_inode *base)
|
||||
{
|
||||
void *d;
|
||||
struct fs_dirhandle *d;
|
||||
a_inode *aino;
|
||||
int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
|
||||
|
||||
d = fs_opendir (unit, base->nname);
|
||||
if (!d)
|
||||
@ -3260,18 +3270,18 @@ static void populate_directory (Unit *unit, a_inode *base)
|
||||
/* Find next file that belongs to the Amiga fs (skipping things
|
||||
like "..", "." etc. */
|
||||
do {
|
||||
if (isarch)
|
||||
ok = zfile_readdir_archive(d, fn);
|
||||
if (d->isarch)
|
||||
ok = zfile_readdir_archive(d->zd, fn);
|
||||
else
|
||||
ok = my_readdir (d, fn);
|
||||
} while (ok && !isarch && fsdb_name_invalid (fn));
|
||||
ok = my_readdir (d->od, fn);
|
||||
} while (ok && !d->isarch && fsdb_name_invalid (fn));
|
||||
if (!ok)
|
||||
break;
|
||||
/* This calls init_child_aino, which will notice that the parent is
|
||||
being ExNext()ed, and it will increment the locked counts. */
|
||||
aino = lookup_child_aino_for_exnext (unit, base, fn, &err);
|
||||
}
|
||||
fs_closedir (unit, d);
|
||||
fs_closedir (d);
|
||||
}
|
||||
|
||||
static void do_examine (Unit *unit, dpacket packet, ExamineKey *ek, uaecptr info)
|
||||
@ -3360,8 +3370,8 @@ static void do_find (Unit *unit, dpacket packet, int mode, int create, int fallb
|
||||
uaecptr name = GET_PCK_ARG3 (packet) << 2;
|
||||
a_inode *aino;
|
||||
Key *k;
|
||||
void *fd;
|
||||
uae_u32 err;
|
||||
struct fs_filehandle *fd;
|
||||
int err;
|
||||
mode_t openmode;
|
||||
int aino_created = 0;
|
||||
int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
|
||||
@ -3486,7 +3496,7 @@ static void
|
||||
uaecptr lock = GET_PCK_ARG2 (packet) << 2;
|
||||
a_inode *aino;
|
||||
Key *k;
|
||||
void *fd;
|
||||
struct fs_filehandle *fd;
|
||||
mode_t openmode;
|
||||
int mode;
|
||||
int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
|
||||
@ -3638,7 +3648,7 @@ static void
|
||||
if (valid_address (addr, size)) {
|
||||
uae_u8 *realpt;
|
||||
realpt = get_real_address (addr);
|
||||
actual = fs_read (unit, k->fd, realpt, size);
|
||||
actual = fs_read (k->fd, realpt, size);
|
||||
|
||||
if (actual == 0) {
|
||||
PUT_PCK_RES1 (packet, 0);
|
||||
@ -3657,19 +3667,19 @@ static void
|
||||
write_log (L"unixfs warning: Bad pointer passed for read: %08x, size %d\n", addr, size);
|
||||
/* ugh this is inefficient but easy */
|
||||
|
||||
old = fs_lseek (unit, k->fd, 0, SEEK_CUR);
|
||||
filesize = fs_lseek (unit, k->fd, 0, SEEK_END);
|
||||
fs_lseek (unit, k->fd, old, SEEK_SET);
|
||||
old = fs_lseek (k->fd, 0, SEEK_CUR);
|
||||
filesize = fs_lseek (k->fd, 0, SEEK_END);
|
||||
fs_lseek (k->fd, old, SEEK_SET);
|
||||
if (size > filesize)
|
||||
size = filesize;
|
||||
|
||||
buf = xmalloc (size);
|
||||
buf = xmalloc (uae_u8, size);
|
||||
if (!buf) {
|
||||
PUT_PCK_RES1 (packet, -1);
|
||||
PUT_PCK_RES2 (packet, ERROR_NO_FREE_STORE);
|
||||
return;
|
||||
}
|
||||
actual = fs_read (unit, k->fd, buf, size);
|
||||
actual = fs_read (k->fd, buf, size);
|
||||
|
||||
if (actual < 0) {
|
||||
PUT_PCK_RES1 (packet, 0);
|
||||
@ -3693,7 +3703,7 @@ static void
|
||||
uaecptr addr = GET_PCK_ARG2 (packet);
|
||||
long size = GET_PCK_ARG3 (packet);
|
||||
long actual;
|
||||
TCHAR *buf;
|
||||
uae_u8 *buf;
|
||||
int i;
|
||||
|
||||
if (k == 0) {
|
||||
@ -3713,13 +3723,13 @@ static void
|
||||
|
||||
if (valid_address (addr, size)) {
|
||||
uae_u8 *realpt = get_real_address (addr);
|
||||
actual = my_write (k->fd, realpt, size);
|
||||
actual = fs_write (k->fd, realpt, size);
|
||||
|
||||
} else {
|
||||
|
||||
write_log (L"unixfs warning: Bad pointer passed for write: %08x, size %d\n", addr, size);
|
||||
/* ugh this is inefficient but easy */
|
||||
buf = (TCHAR *)malloc(size);
|
||||
buf = xmalloc (uae_u8, size);
|
||||
if (!buf) {
|
||||
PUT_PCK_RES1 (packet, -1);
|
||||
PUT_PCK_RES2 (packet, ERROR_NO_FREE_STORE);
|
||||
@ -3729,7 +3739,7 @@ static void
|
||||
for (i = 0; i < size; i++)
|
||||
buf[i] = get_byte (addr + i);
|
||||
|
||||
actual = my_write (k->fd, buf, size);
|
||||
actual = fs_write (k->fd, buf, size);
|
||||
xfree (buf);
|
||||
}
|
||||
|
||||
@ -3767,11 +3777,11 @@ static void
|
||||
TRACE((L"ACTION_SEEK(%s,%d,%d)\n", k->aino->nname, pos, mode));
|
||||
gui_flicker_led (LED_HD, unit->unit, 1);
|
||||
|
||||
old = fs_lseek (unit, k->fd, 0, SEEK_CUR);
|
||||
old = fs_lseek (k->fd, 0, SEEK_CUR);
|
||||
{
|
||||
uae_s64 temppos;
|
||||
uae_s64 filesize = fs_lseek64 (unit, k->fd, 0, SEEK_END);
|
||||
fs_lseek (unit, k->fd, old, SEEK_SET);
|
||||
uae_s64 filesize = fs_lseek64 (k->fd, 0, SEEK_END);
|
||||
fs_lseek (k->fd, old, SEEK_SET);
|
||||
|
||||
if (whence == SEEK_CUR)
|
||||
temppos = old + pos;
|
||||
@ -3786,12 +3796,12 @@ static void
|
||||
return;
|
||||
}
|
||||
}
|
||||
res = fs_lseek64 (unit, k->fd, pos, whence);
|
||||
res = fs_lseek64 (k->fd, pos, whence);
|
||||
|
||||
if (-1 == res || old > MAXFILESIZE32) {
|
||||
PUT_PCK_RES1 (packet, -1);
|
||||
PUT_PCK_RES2 (packet, ERROR_SEEK_ERROR);
|
||||
fs_lseek64 (unit, k->fd, old, SEEK_SET);
|
||||
fs_lseek64 (k->fd, old, SEEK_SET);
|
||||
res = old;
|
||||
} else {
|
||||
PUT_PCK_RES1 (packet, old);
|
||||
@ -3806,7 +3816,7 @@ static void
|
||||
uaecptr name = GET_PCK_ARG3 (packet) << 2;
|
||||
uae_u32 mask = GET_PCK_ARG4 (packet);
|
||||
a_inode *a;
|
||||
uae_u32 err;
|
||||
int err;
|
||||
|
||||
TRACE((L"ACTION_SET_PROTECT(0x%lx,\"%s\",0x%lx)\n", lock, bstr (unit, name), mask));
|
||||
|
||||
@ -3844,7 +3854,7 @@ static void action_set_comment (Unit * unit, dpacket packet)
|
||||
uaecptr comment = GET_PCK_ARG4 (packet) << 2;
|
||||
TCHAR *commented = NULL;
|
||||
a_inode *a;
|
||||
uae_u32 err;
|
||||
int err;
|
||||
|
||||
if (unit->ui.readonly) {
|
||||
PUT_PCK_RES1 (packet, DOS_FALSE);
|
||||
@ -3861,7 +3871,7 @@ static void action_set_comment (Unit * unit, dpacket packet)
|
||||
}
|
||||
if (_tcslen (commented) > 0) {
|
||||
TCHAR *p = commented;
|
||||
commented = xmalloc (81 * sizeof (TCHAR));
|
||||
commented = xmalloc (TCHAR, 81);
|
||||
_tcsncpy (commented, p, 80);
|
||||
commented[80] = 0;
|
||||
} else {
|
||||
@ -3925,7 +3935,7 @@ static void
|
||||
long mode = GET_PCK_ARG3 (packet);
|
||||
unsigned long uniq;
|
||||
a_inode *a = NULL, *olda = NULL;
|
||||
uae_u32 err = 0;
|
||||
int err = 0;
|
||||
TRACE((L"ACTION_CHANGE_MODE(0x%lx,%d,%d)\n", object, type, mode));
|
||||
|
||||
if (! object || (type != CHANGE_FH && type != CHANGE_LOCK)) {
|
||||
@ -4032,7 +4042,7 @@ static void
|
||||
uaecptr lock = GET_PCK_ARG1 (packet) << 2;
|
||||
uaecptr name = GET_PCK_ARG2 (packet) << 2;
|
||||
a_inode *aino;
|
||||
uae_u32 err;
|
||||
int err;
|
||||
|
||||
TRACE((L"ACTION_CREATE_DIR(0x%lx,\"%s\")\n", lock, bstr (unit, name)));
|
||||
|
||||
@ -4137,11 +4147,11 @@ static void
|
||||
}
|
||||
|
||||
/* Write one then truncate: that should give the right size in all cases. */
|
||||
offset = fs_lseek (unit, k->fd, offset, whence);
|
||||
my_write (k->fd, /* whatever */(uae_u8*)&k1, 1);
|
||||
offset = fs_lseek (k->fd, offset, whence);
|
||||
fs_write (k->fd, /* whatever */(uae_u8*)&k1, 1);
|
||||
if (k->file_pos > offset)
|
||||
k->file_pos = offset;
|
||||
fs_lseek (unit, k->fd, (off_t)k->file_pos, SEEK_SET);
|
||||
fs_lseek (k->fd, (off_t)k->file_pos, SEEK_SET);
|
||||
|
||||
/* Brian: no bug here; the file _must_ be one byte too large after writing
|
||||
The write is supposed to guarantee that the file can't be smaller than
|
||||
@ -4166,7 +4176,7 @@ static int relock_do(Unit *unit, a_inode *a1)
|
||||
knext = k1->next;
|
||||
if (k1->aino == a1 && k1->fd) {
|
||||
wehavekeys++;
|
||||
fs_close (unit, k1->fd);
|
||||
fs_close (k1->fd);
|
||||
write_log (L"handle %p freed\n", k1->fd);
|
||||
}
|
||||
}
|
||||
@ -4200,7 +4210,7 @@ static void relock_re (Unit *unit, a_inode *a1, a_inode *a2, int failed)
|
||||
write_log (L"relocking failed '%s' -> '%s'\n", a1->nname, a2->nname);
|
||||
free_key (unit, k1);
|
||||
} else {
|
||||
fs_lseek64 (unit, k1->fd, k1->file_pos, SEEK_SET);
|
||||
fs_lseek64 (k1->fd, k1->file_pos, SEEK_SET);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4212,7 +4222,7 @@ static void
|
||||
uaecptr lock = GET_PCK_ARG1 (packet) << 2;
|
||||
uaecptr name = GET_PCK_ARG2 (packet) << 2;
|
||||
a_inode *a;
|
||||
uae_u32 err;
|
||||
int err;
|
||||
|
||||
TRACE((L"ACTION_DELETE_OBJECT(0x%lx,\"%s\")\n", lock, bstr (unit, name)));
|
||||
|
||||
@ -4274,7 +4284,7 @@ static void
|
||||
uaecptr date = GET_PCK_ARG4 (packet);
|
||||
a_inode *a;
|
||||
struct utimbuf ut;
|
||||
uae_u32 err;
|
||||
int err;
|
||||
|
||||
TRACE((L"ACTION_SET_DATE(0x%lx,\"%s\")\n", lock, bstr (unit, name)));
|
||||
|
||||
@ -4307,7 +4317,7 @@ static void
|
||||
uaecptr lock2 = GET_PCK_ARG3 (packet) << 2;
|
||||
uaecptr name2 = GET_PCK_ARG4 (packet) << 2;
|
||||
a_inode *a1, *a2;
|
||||
uae_u32 err1, err2;
|
||||
int err1, err2;
|
||||
Key *k1, *knext;
|
||||
int wehavekeys = 0;
|
||||
|
||||
@ -4514,11 +4524,11 @@ static void action_change_file_position64 (Unit *unit, dpacket packet)
|
||||
TRACE((L"ACTION_CHANGE_FILE_POSITION64(%s,%I64d,%d)\n", k->aino->nname, pos, mode));
|
||||
gui_flicker_led (LED_HD, unit->unit, 1);
|
||||
|
||||
old = fs_lseek64 (unit, k->fd, 0, SEEK_CUR);
|
||||
old = fs_lseek64 (k->fd, 0, SEEK_CUR);
|
||||
{
|
||||
uae_s64 temppos;
|
||||
uae_s64 filesize = fs_lseek64 (unit, k->fd, 0, SEEK_END);
|
||||
fs_lseek64 (unit, k->fd, old, SEEK_SET);
|
||||
uae_s64 filesize = fs_lseek64 (k->fd, 0, SEEK_END);
|
||||
fs_lseek64 (k->fd, old, SEEK_SET);
|
||||
|
||||
if (whence == SEEK_CUR)
|
||||
temppos = old + pos;
|
||||
@ -4533,7 +4543,7 @@ static void action_change_file_position64 (Unit *unit, dpacket packet)
|
||||
return;
|
||||
}
|
||||
}
|
||||
res = fs_lseek64 (unit, k->fd, pos, whence);
|
||||
res = fs_lseek64 (k->fd, pos, whence);
|
||||
|
||||
if (-1 == res) {
|
||||
PUT_PCK64_RES1 (packet, DOS_FALSE);
|
||||
@ -4597,11 +4607,11 @@ static void action_change_file_size64 (Unit *unit, dpacket packet)
|
||||
}
|
||||
|
||||
/* Write one then truncate: that should give the right size in all cases. */
|
||||
offset = fs_lseek (unit, k->fd, offset, whence);
|
||||
my_write (k->fd, /* whatever */(uae_u8*)&k1, 1);
|
||||
offset = fs_lseek (k->fd, offset, whence);
|
||||
fs_write (k->fd, /* whatever */(uae_u8*)&k1, 1);
|
||||
if (k->file_pos > offset)
|
||||
k->file_pos = offset;
|
||||
fs_lseek (unit, k->fd, k->file_pos, SEEK_SET);
|
||||
fs_lseek (k->fd, k->file_pos, SEEK_SET);
|
||||
|
||||
if (my_truncate (k->aino->nname, offset) == -1) {
|
||||
PUT_PCK64_RES1 (packet, DOS_FALSE);
|
||||
@ -4627,11 +4637,11 @@ static void action_get_file_size64 (Unit *unit, dpacket packet)
|
||||
return;
|
||||
}
|
||||
TRACE((L"ACTION_GET_FILE_SIZE64(%s)\n", k->aino->nname));
|
||||
old = fs_lseek64 (unit, k->fd, 0, SEEK_CUR);
|
||||
old = fs_lseek64 (k->fd, 0, SEEK_CUR);
|
||||
if (old >= 0) {
|
||||
filesize = fs_lseek64 (unit, k->fd, 0, SEEK_END);
|
||||
filesize = fs_lseek64 (k->fd, 0, SEEK_END);
|
||||
if (filesize >= 0) {
|
||||
fs_lseek64 (unit, k->fd, old, SEEK_SET);
|
||||
fs_lseek64 (k->fd, old, SEEK_SET);
|
||||
PUT_PCK64_RES1 (packet, filesize);
|
||||
PUT_PCK64_RES2 (packet, 0);
|
||||
return;
|
||||
@ -5008,7 +5018,7 @@ void filesys_free_handles (void)
|
||||
for (k1 = u->keys; k1; k1 = knext) {
|
||||
knext = k1->next;
|
||||
if (k1->fd)
|
||||
fs_close (u, k1->fd);
|
||||
fs_close (k1->fd);
|
||||
xfree (k1);
|
||||
}
|
||||
u->keys = NULL;
|
||||
@ -5323,9 +5333,9 @@ static TCHAR *device_dupfix (uaecptr expbase, TCHAR *devname)
|
||||
return my_strdup (newname);
|
||||
}
|
||||
|
||||
static void dump_partinfo (uae_char *name, int num, uaecptr pp, int partblock)
|
||||
static void dump_partinfo (uae_u8 *name, int num, uaecptr pp, int partblock)
|
||||
{
|
||||
TCHAR *s = au (name);
|
||||
TCHAR *s = au ((char*)name);
|
||||
uae_u32 dostype = get_long (pp + 80);
|
||||
uae_u64 size;
|
||||
|
||||
@ -5421,7 +5431,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke
|
||||
rdblock, fileblock, hfd->cylinders, hfd->sectors, hfd->heads);
|
||||
}
|
||||
|
||||
buf = xmalloc (readblocksize);
|
||||
buf = xmalloc (uae_u8, readblocksize);
|
||||
for (i = 0; i <= partnum; i++) {
|
||||
if (i == 0)
|
||||
partblock = rl (bufrdb + 28);
|
||||
@ -5451,7 +5461,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke
|
||||
m68k_dreg (regs, 7) = m68k_dreg (regs, 7) & ~1;
|
||||
|
||||
buf[37 + buf[36]] = 0; /* zero terminate BSTR */
|
||||
s = au (buf + 37);
|
||||
s = au ((char*)buf + 37);
|
||||
uip->rdb_devname_amiga[partnum] = ds (device_dupfix (get_long (parmpacket + PP_EXPLIB), s));
|
||||
xfree (s);
|
||||
put_long (parmpacket, uip->rdb_devname_amiga[partnum]); /* name */
|
||||
@ -5533,7 +5543,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke
|
||||
put_byte (parmpacket + PP_FSHDSTART + i, buf[32 + i]);
|
||||
put_long (parmpacket + PP_FSHDSTART, dostype);
|
||||
/* we found required FSHD block */
|
||||
fsmem = xmalloc (262144);
|
||||
fsmem = xmalloc (uae_u8, 262144);
|
||||
lsegblock = rl (buf + 72);
|
||||
i = 0;
|
||||
for (;;) {
|
||||
@ -5636,7 +5646,7 @@ static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket)
|
||||
size = zfile_ftell (zf);
|
||||
if (size > 0) {
|
||||
zfile_fseek (zf, 0, SEEK_SET);
|
||||
uip->rdb_filesysstore = xmalloc (size);
|
||||
uip->rdb_filesysstore = xmalloc (uae_u8, size);
|
||||
zfile_fread (uip->rdb_filesysstore, size, 1, zf);
|
||||
}
|
||||
zfile_fclose (zf);
|
||||
@ -5825,7 +5835,7 @@ void filesys_install_code (void)
|
||||
bootrom_header = 3 * 4;
|
||||
align(4);
|
||||
a = here ();
|
||||
#include "filesys_bootrom.c"
|
||||
#include "filesys_bootrom.cpp"
|
||||
|
||||
bootrom_items = dlg (a + 8);
|
||||
/* The last offset comes from the code itself, look for it near the top. */
|
||||
@ -5834,7 +5844,7 @@ void filesys_install_code (void)
|
||||
filesys_initcode = a + dlg (b) + bootrom_header - 4;
|
||||
}
|
||||
|
||||
#include "od-win32/win32_filesys.c"
|
||||
#include "od-win32/win32_filesys.cpp"
|
||||
|
||||
static uae_u8 *restore_filesys_hardfile (UnitInfo *ui, uae_u8 *src)
|
||||
{
|
||||
@ -5904,7 +5914,7 @@ static a_inode *restore_filesys_get_base (Unit *u, TCHAR *npath)
|
||||
/* iterate from root to last to previous path part,
|
||||
* create ainos if not already created.
|
||||
*/
|
||||
path = xcalloc((_tcslen (npath) + 2) * sizeof (TCHAR), 1);
|
||||
path = xcalloc(TCHAR, _tcslen (npath) + 2);
|
||||
cnt = 1;
|
||||
for (;;) {
|
||||
_tcscpy (path, npath);
|
||||
@ -5971,7 +5981,7 @@ static TCHAR *makenativepath (UnitInfo *ui, TCHAR *apath)
|
||||
int i;
|
||||
TCHAR *pn;
|
||||
/* create native path. FIXME: handle 'illegal' characters */
|
||||
pn = xcalloc ((_tcslen (apath) + 1 + _tcslen (ui->rootdir) + 1) * sizeof (TCHAR), 1);
|
||||
pn = xcalloc (TCHAR, _tcslen (apath) + 1 + _tcslen (ui->rootdir) + 1);
|
||||
_stprintf (pn, L"%s/%s", ui->rootdir, apath);
|
||||
if (FSDB_DIR_SEPARATOR != '/') {
|
||||
for (i = 0; i < _tcslen (pn); i++) {
|
||||
@ -5990,7 +6000,7 @@ static uae_u8 *restore_aino (UnitInfo *ui, Unit *u, uae_u8 *src)
|
||||
a_inode *base, *a;
|
||||
|
||||
missing = 0;
|
||||
a = xcalloc (sizeof (a_inode), 1);
|
||||
a = xcalloc (a_inode, 1);
|
||||
a->uniq = restore_u64 ();
|
||||
a->locked_children = restore_u32 ();
|
||||
a->exnext_count = restore_u32 ();
|
||||
@ -6061,13 +6071,13 @@ static uae_u8 *restore_key (UnitInfo *ui, Unit *u, uae_u8 *src)
|
||||
int savedsize, uniq;
|
||||
TCHAR *p, *pn;
|
||||
mode_t openmode;
|
||||
DWORD err;
|
||||
int err;
|
||||
int missing;
|
||||
a_inode *a;
|
||||
Key *k;
|
||||
|
||||
missing = 0;
|
||||
k = xcalloc (sizeof (Key), 1);
|
||||
k = xcalloc (Key, 1);
|
||||
k->uniq = restore_u64 ();
|
||||
k->file_pos = restore_u32 ();
|
||||
k->createmode = restore_u32 ();
|
||||
@ -6095,11 +6105,11 @@ static uae_u8 *restore_key (UnitInfo *ui, Unit *u, uae_u8 *src)
|
||||
write_log (L"*** FS: Open file '%s' is missing, creating dummy file!\n", p);
|
||||
k->fd = fs_open (u, pn, openmode | O_CREAT |O_BINARY);
|
||||
if (k->fd) {
|
||||
uae_u8 *buf = xcalloc (10000, 1);
|
||||
uae_u8 *buf = xcalloc (uae_u8, 10000);
|
||||
int sp = savedsize;
|
||||
while (sp) {
|
||||
int s = sp >= 10000 ? 10000 : sp;
|
||||
my_write(k->fd, buf, s);
|
||||
fs_write (k->fd, buf, s);
|
||||
sp -= s;
|
||||
}
|
||||
xfree(buf);
|
||||
@ -6115,14 +6125,14 @@ static uae_u8 *restore_key (UnitInfo *ui, Unit *u, uae_u8 *src)
|
||||
missing = 1;
|
||||
} else {
|
||||
uae_s64 s;
|
||||
s = fs_lseek64 (u, k->fd, 0, SEEK_END);
|
||||
s = fs_lseek64 (k->fd, 0, SEEK_END);
|
||||
if (s != savedsize)
|
||||
write_log (L"FS: restored file '%s' size changed! orig=%d, now=%d!!\n", p, savedsize, s);
|
||||
if (k->file_pos > s) {
|
||||
write_log (L"FS: restored filepos larger than size of file '%s'!! %d > %d\n", p, k->file_pos, s);
|
||||
k->file_pos = s;
|
||||
}
|
||||
fs_lseek64 (u,k->fd, k->file_pos, SEEK_SET);
|
||||
fs_lseek64 (k->fd, k->file_pos, SEEK_SET);
|
||||
}
|
||||
}
|
||||
xfree (p);
|
||||
@ -6137,13 +6147,13 @@ static uae_u8 *restore_key (UnitInfo *ui, Unit *u, uae_u8 *src)
|
||||
|
||||
static uae_u8 *restore_notify (UnitInfo *ui, Unit *u, uae_u8 *src)
|
||||
{
|
||||
Notify *n = xcalloc (sizeof (Notify), 1);
|
||||
Notify *n = xcalloc (Notify, 1);
|
||||
uae_u32 hash;
|
||||
TCHAR *s;
|
||||
|
||||
n->notifyrequest = restore_u32 ();
|
||||
s = restore_string ();
|
||||
n->fullname = xmalloc ((_tcslen (ui->volname) + 2 + _tcslen (s) + 1) * sizeof (TCHAR));
|
||||
n->fullname = xmalloc (TCHAR, _tcslen (ui->volname) + 2 + _tcslen (s) + 1);
|
||||
_stprintf (n->fullname, L"%s:%s", ui->volname, s);
|
||||
xfree(s);
|
||||
s = _tcsrchr (n->fullname, '/');
|
||||
@ -6212,7 +6222,7 @@ static TCHAR *getfullaname(a_inode *a)
|
||||
TCHAR *p;
|
||||
int first = 1;
|
||||
|
||||
p = xcalloc (2000 * sizeof (TCHAR), 1);
|
||||
p = xcalloc (TCHAR, 2000);
|
||||
while (a) {
|
||||
int len = _tcslen (a->aname);
|
||||
memmove (p + len + 1, p, (_tcslen (p) + 1) * sizeof (TCHAR));
|
||||
@ -6275,10 +6285,10 @@ static uae_u8 *save_key (uae_u8 *dst, Key *k)
|
||||
save_u32 ((uae_u32)k->file_pos);
|
||||
save_u32 (k->createmode);
|
||||
save_u32 (k->dosmode);
|
||||
size = my_lseek (k->fd, 0, SEEK_END);
|
||||
size = fs_lseek (k->fd, 0, SEEK_END);
|
||||
save_u32 ((uae_u32)size);
|
||||
save_u64 (k->aino->uniq);
|
||||
my_lseek (k->fd, k->file_pos, SEEK_SET);
|
||||
fs_lseek (k->fd, k->file_pos, SEEK_SET);
|
||||
save_string (fn);
|
||||
save_u64 (k->file_pos);
|
||||
save_u64 (size);
|
||||
@ -6376,7 +6386,7 @@ uae_u8 *save_filesys_common (int *len)
|
||||
uae_u8 *dstbak, *dst;
|
||||
if (nr_units () == 0)
|
||||
return NULL;
|
||||
dstbak = dst = xmalloc (1000);
|
||||
dstbak = dst = xmalloc (uae_u8, 1000);
|
||||
save_u32 (2);
|
||||
save_u64 (a_uniq);
|
||||
save_u64 (key_uniq);
|
||||
@ -6408,7 +6418,7 @@ uae_u8 *save_filesys (int num, int *len)
|
||||
if (type == FILESYS_VIRTUAL && (ui->self == NULL || ui->volname == NULL))
|
||||
return NULL;
|
||||
write_log (L"FS_FILESYS: '%s' '%s'\n", ui->devname, ui->volname);
|
||||
dstbak = dst = xmalloc (100000);
|
||||
dstbak = dst = xmalloc (uae_u8, 100000);
|
||||
save_u32 (2); /* version */
|
||||
save_u32 (ui->devno);
|
||||
save_u16 (type);
|
||||
@ -325,6 +325,8 @@ STATIC_INLINE tointtype toint (fptype src, fptype minval, fptype maxval)
|
||||
#endif
|
||||
}
|
||||
|
||||
extern int isinf (double x);
|
||||
|
||||
uae_u32 get_fpsr (void)
|
||||
{
|
||||
uae_u32 answer = regs.fpsr & 0x00ffffff;
|
||||
@ -1744,7 +1746,7 @@ uae_u8 *save_fpu (int *len, uae_u8 *dstptr)
|
||||
if (dstptr)
|
||||
dstbak = dst = dstptr;
|
||||
else
|
||||
dstbak = dst = malloc (4+4+8*10+4+4+4+4+4);
|
||||
dstbak = dst = xmalloc (uae_u8, 4+4+8*10+4+4+4+4+4);
|
||||
save_u32 (currprefs.fpu_model);
|
||||
save_u32 (0x80000000);
|
||||
for (i = 0; i < 8; i++) {
|
||||
@ -146,18 +146,18 @@ void fsdb_clean_dir (a_inode *dir)
|
||||
static a_inode *aino_from_buf (a_inode *base, uae_u8 *buf, long off)
|
||||
{
|
||||
uae_u32 mode;
|
||||
a_inode *aino = (a_inode *) xcalloc (sizeof (a_inode), 1);
|
||||
a_inode *aino = xcalloc (a_inode, 1);
|
||||
TCHAR *s;
|
||||
|
||||
mode = do_get_mem_long ((uae_u32 *)(buf + 1));
|
||||
buf += 5;
|
||||
aino->aname = au (buf);
|
||||
aino->aname = au ((char*)buf);
|
||||
buf += 257;
|
||||
s = au (buf);
|
||||
s = au ((char*)buf);
|
||||
aino->nname = build_nname (base->nname, s);
|
||||
xfree (s);
|
||||
buf += 257;
|
||||
aino->comment = *buf != '\0' ? au (buf) : 0;
|
||||
aino->comment = *buf != '\0' ? au ((char*)buf) : 0;
|
||||
fsdb_fill_file_attrs (base, aino);
|
||||
aino->amigaos_mode = mode;
|
||||
aino->has_dbentry = 1;
|
||||
@ -181,7 +181,7 @@ a_inode *fsdb_lookup_aino_aname (a_inode *base, const TCHAR *aname)
|
||||
TCHAR *s;
|
||||
if (fread (buf, 1, sizeof buf, f) < sizeof buf)
|
||||
break;
|
||||
s = au (buf + 5);
|
||||
s = au ((char*)buf + 5);
|
||||
if (buf[0] != 0 && same_aname (s, aname)) {
|
||||
long pos = ftell (f) - sizeof buf;
|
||||
fclose (f);
|
||||
@ -210,7 +210,7 @@ a_inode *fsdb_lookup_aino_nname (a_inode *base, const TCHAR *nname)
|
||||
uae_u8 buf[1 + 4 + 257 + 257 + 81];
|
||||
if (fread (buf, 1, sizeof buf, f) < sizeof buf)
|
||||
break;
|
||||
if (buf[0] != 0 && strcmp (buf + 5 + 257, s) == 0) {
|
||||
if (buf[0] != 0 && strcmp ((char*)buf + 5 + 257, s) == 0) {
|
||||
long pos = ftell (f) - sizeof buf;
|
||||
fclose (f);
|
||||
xfree (s);
|
||||
@ -239,7 +239,7 @@ int fsdb_used_as_nname (a_inode *base, const TCHAR *nname)
|
||||
break;
|
||||
if (buf[0] == 0)
|
||||
continue;
|
||||
s = au (buf + 5 + 257);
|
||||
s = au ((char*)buf + 5 + 257);
|
||||
if (_tcscmp (s, nname) == 0) {
|
||||
xfree (s);
|
||||
fclose (f);
|
||||
@ -271,11 +271,11 @@ static void write_aino (FILE *f, a_inode *aino)
|
||||
|
||||
buf[0] = aino->needs_dbentry;
|
||||
do_put_mem_long ((uae_u32 *)(buf + 1), aino->amigaos_mode);
|
||||
ua_copy (buf + 5, 256, aino->aname);
|
||||
ua_copy ((char*)buf + 5, 256, aino->aname);
|
||||
buf[5 + 256] = '\0';
|
||||
ua_copy (buf + 5 + 257, 256, nname_begin (aino->nname));
|
||||
ua_copy ((char*)buf + 5 + 257, 256, nname_begin (aino->nname));
|
||||
buf[5 + 257 + 256] = '\0';
|
||||
ua_copy (buf + 5 + 2 * 257, 80, aino->comment ? aino->comment : L"");
|
||||
ua_copy ((char*)buf + 5 + 2 * 257, 80, aino->comment ? aino->comment : L"");
|
||||
buf[5 + 2 * 257 + 80] = '\0';
|
||||
aino->db_offset = ftell (f);
|
||||
fwrite (buf, 1, sizeof buf, f);
|
||||
@ -359,7 +359,7 @@ void fsdb_dir_writeback (a_inode *dir)
|
||||
|
||||
i = 0;
|
||||
while (!aino->has_dbentry && i < size) {
|
||||
TCHAR *s = au (tmpbuf + i + 5);
|
||||
TCHAR *s = au ((char*)tmpbuf + i + 5);
|
||||
if (!_tcscmp (s, aino->aname)) {
|
||||
aino->has_dbentry = 1;
|
||||
aino->db_offset = i;
|
||||
@ -16,6 +16,7 @@ along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "sysconfig.h"
|
||||
#include "sysdeps.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
@ -46,7 +47,6 @@ static long adjust_blocks (long blocks, int fromsize, int tosize)
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "sysdeps.h"
|
||||
#include "od-win32/posixemu.h"
|
||||
#include <windows.h>
|
||||
int get_fs_usage (const TCHAR *path, const TCHAR *disk, struct fs_usage *fsp)
|
||||
@ -1486,17 +1486,17 @@ static void initsramattr (int size, int readonly)
|
||||
*p++= 4; /* PCMCIA 2.1 */
|
||||
*p++= 1;
|
||||
if (real) {
|
||||
ua_copy (p, -1, hfd->product_id);
|
||||
p += strlen (p) + 1;
|
||||
ua_copy(p, -1, hfd->product_rev);
|
||||
ua_copy ((char*)p, -1, hfd->product_id);
|
||||
p += strlen ((char*)p) + 1;
|
||||
ua_copy ((char*)p, -1, hfd->product_rev);
|
||||
} else {
|
||||
strcpy (p, "UAE");
|
||||
p += strlen (p) + 1;
|
||||
strcpy (p, "68000");
|
||||
strcpy ((char*)p, "UAE");
|
||||
p += strlen ((char*)p) + 1;
|
||||
strcpy ((char*)p, "68000");
|
||||
}
|
||||
p += strlen (p) + 1;
|
||||
sprintf (p, "Generic Emulated %dKB PCMCIA SRAM Card", size >> 10);
|
||||
p += strlen (p) + 1;
|
||||
p += strlen ((char*)p) + 1;
|
||||
sprintf ((char*)p, "Generic Emulated %dKB PCMCIA SRAM Card", size >> 10);
|
||||
p += strlen ((char*)p) + 1;
|
||||
*p++= 0;
|
||||
*p++= 0xff;
|
||||
*rp = p - rp;
|
||||
@ -1583,7 +1583,7 @@ static int initpcmcia (const TCHAR *path, int readonly, int reset)
|
||||
return 0;
|
||||
freepcmcia (reset);
|
||||
if (!pcmcia_sram)
|
||||
pcmcia_sram = xcalloc (sizeof (struct hd_hardfiledata), 1);
|
||||
pcmcia_sram = xcalloc (struct hd_hardfiledata, 1);
|
||||
if (!pcmcia_sram->hfd.handle_valid)
|
||||
reset = 1;
|
||||
if (reset) {
|
||||
@ -1597,14 +1597,14 @@ static int initpcmcia (const TCHAR *path, int readonly, int reset)
|
||||
pcmcia_common_size = 0;
|
||||
pcmcia_readonly = readonly;
|
||||
pcmcia_attrs_size = 256;
|
||||
pcmcia_attrs = xcalloc (pcmcia_attrs_size, 1);
|
||||
pcmcia_attrs = xcalloc (uae_u8, pcmcia_attrs_size);
|
||||
if (!pcmcia_sram->hfd.drive_empty) {
|
||||
pcmcia_common_size = pcmcia_sram->hfd.virtsize;
|
||||
if (pcmcia_sram->hfd.virtsize > 4 * 1024 * 1024) {
|
||||
write_log (L"PCMCIA SRAM: too large device, %d bytes\n", pcmcia_sram->hfd.virtsize);
|
||||
pcmcia_common_size = 4 * 1024 * 1024;
|
||||
}
|
||||
pcmcia_common = xcalloc (pcmcia_common_size, 1);
|
||||
pcmcia_common = xcalloc (uae_u8, pcmcia_common_size);
|
||||
write_log (L"PCMCIA SRAM: '%s' open, size=%d\n", path, pcmcia_common_size);
|
||||
hdf_read (&pcmcia_sram->hfd, pcmcia_common, 0, pcmcia_common_size);
|
||||
pcmcia_card = 1;
|
||||
@ -1838,7 +1838,7 @@ static void alloc_ide_mem (struct ide_hdf **ide, int max)
|
||||
|
||||
for (i = 0; i < max; i++) {
|
||||
if (!ide[i])
|
||||
ide[i] = xcalloc (sizeof (struct ide_hdf), 1);
|
||||
ide[i] = xcalloc (struct ide_hdf, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1960,7 +1960,7 @@ uae_u8 *save_gayle (int *len)
|
||||
|
||||
if (currprefs.cs_ide <= 0)
|
||||
return NULL;
|
||||
dstbak = dst = malloc (1000);
|
||||
dstbak = dst = xmalloc (uae_u8, 1000);
|
||||
save_u8 (currprefs.cs_ide);
|
||||
save_u8 (gayle_int);
|
||||
save_u8 (gayle_irq);
|
||||
@ -1983,7 +1983,7 @@ uae_u8 *save_ide (int num, int *len)
|
||||
ide = idedrive[num];
|
||||
if (ide->hdhfd.size == 0)
|
||||
return NULL;
|
||||
dstbak = dst = malloc (1000);
|
||||
dstbak = dst = xmalloc (uae_u8, 1000);
|
||||
save_u32 (num);
|
||||
save_u64 (ide->hdhfd.size);
|
||||
save_string (ide->hdhfd.path);
|
||||
@ -353,6 +353,8 @@ static void irc2ir (void)
|
||||
if (!using_prefetch)
|
||||
return;
|
||||
printf ("\tregs.ir = regs.irc;\n");
|
||||
if (using_ce)
|
||||
printf ("\tipl_fetch ();\n");
|
||||
}
|
||||
|
||||
static int did_prefetch;
|
||||
@ -3756,10 +3758,10 @@ int main (int argc, char **argv)
|
||||
read_table68k ();
|
||||
do_merges ();
|
||||
|
||||
opcode_map = (int *) xmalloc (sizeof (int) * nr_cpuop_funcs);
|
||||
opcode_last_postfix = (int *) xmalloc (sizeof (int) * nr_cpuop_funcs);
|
||||
opcode_next_clev = (int *) xmalloc (sizeof (int) * nr_cpuop_funcs);
|
||||
counts = (unsigned long *) xmalloc (65536 * sizeof (unsigned long));
|
||||
opcode_map = xmalloc (int, nr_cpuop_funcs);
|
||||
opcode_last_postfix = xmalloc (int, nr_cpuop_funcs);
|
||||
opcode_next_clev = xmalloc (int, nr_cpuop_funcs);
|
||||
counts = xmalloc (unsigned long, 65536);
|
||||
read_counts ();
|
||||
|
||||
/* It would be a lot nicer to put all in one file (we'd also get rid of
|
||||
@ -3768,7 +3770,7 @@ int main (int argc, char **argv)
|
||||
|
||||
headerfile = fopen ("cputbl.h", "wb");
|
||||
|
||||
stblfile = fopen ("cpustbl.c", "wb");
|
||||
stblfile = fopen ("cpustbl.cpp", "wb");
|
||||
generate_includes (stblfile);
|
||||
|
||||
using_prefetch = 0;
|
||||
@ -3786,7 +3788,7 @@ int main (int argc, char **argv)
|
||||
if (generate_stbl)
|
||||
fprintf (stblfile, "#ifdef CPUEMU_%d\n", postfix);
|
||||
postfix2 = postfix;
|
||||
sprintf (fname, "cpuemu_%d.c", postfix);
|
||||
sprintf (fname, "cpuemu_%d.cpp", postfix);
|
||||
freopen (fname, "wb", stdout);
|
||||
generate_includes (stdout);
|
||||
}
|
||||
@ -13,12 +13,11 @@
|
||||
/* Output for big-endian target if true, little-endian is false. */
|
||||
int do_bigendian;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DEPTH_8BPP,
|
||||
DEPTH_16BPP,
|
||||
DEPTH_32BPP,
|
||||
} DEPTH_T;
|
||||
typedef int DEPTH_T;
|
||||
|
||||
#define DEPTH_8BPP 0
|
||||
#define DEPTH_16BPP 1
|
||||
#define DEPTH_32BPP 2
|
||||
#define DEPTH_MAX DEPTH_32BPP
|
||||
|
||||
static const char *get_depth_str (DEPTH_T bpp)
|
||||
@ -41,17 +40,15 @@ static const char *get_depth_type_str (DEPTH_T bpp)
|
||||
return "uae_u32";
|
||||
}
|
||||
|
||||
typedef int HMODE_T;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HMODE_NORMAL,
|
||||
HMODE_DOUBLE,
|
||||
HMODE_DOUBLE2X,
|
||||
HMODE_HALVE1,
|
||||
HMODE_HALVE1F,
|
||||
HMODE_HALVE2,
|
||||
HMODE_HALVE2F
|
||||
} HMODE_T;
|
||||
#define HMODE_NORMAL 0
|
||||
#define HMODE_DOUBLE 1
|
||||
#define HMODE_DOUBLE2X 2
|
||||
#define HMODE_HALVE1 3
|
||||
#define HMODE_HALVE1F 4
|
||||
#define HMODE_HALVE2 5
|
||||
#define HMODE_HALVE2F 6
|
||||
#define HMODE_MAX HMODE_HALVE2F
|
||||
|
||||
static const char *get_hmode_str (HMODE_T hmode)
|
||||
@ -215,7 +215,7 @@ static void create_virtual_rdb (struct hardfiledata *hfd, uae_u32 dostype, int b
|
||||
int cyls = 262144 / (cyl * 512);
|
||||
int size = cyl * cyls * 512;
|
||||
|
||||
rdb = (uae_u8*)xcalloc (size, 1);
|
||||
rdb = xcalloc (uae_u8, size);
|
||||
hfd->virtual_rdb = rdb;
|
||||
hfd->virtual_size = size;
|
||||
part = rdb + 512;
|
||||
@ -259,9 +259,9 @@ static void create_virtual_rdb (struct hardfiledata *hfd, uae_u32 dostype, int b
|
||||
pl(rdb, 37, 0); // autopark
|
||||
pl(rdb, 38, 2); // highrdskblock
|
||||
pl(rdb, 39, -1); // res
|
||||
ua_copy (rdb + 40 * 4, -1, hfd->vendor_id);
|
||||
ua_copy (rdb + 42 * 4, -1, hfd->product_id);
|
||||
ua_copy (rdb + 46 * 4, -1, L"UAE");
|
||||
ua_copy ((char*)rdb + 40 * 4, -1, hfd->vendor_id);
|
||||
ua_copy ((char*)rdb + 42 * 4, -1, hfd->product_id);
|
||||
ua_copy ((char*)rdb + 46 * 4, -1, L"UAE");
|
||||
rdb_crc (rdb);
|
||||
|
||||
pl(part, 0, 0x50415254);
|
||||
@ -274,7 +274,7 @@ static void create_virtual_rdb (struct hardfiledata *hfd, uae_u32 dostype, int b
|
||||
pl(part, 7, -1);
|
||||
pl(part, 8, 0); // devflags
|
||||
part[9 * 4] = _tcslen (hfd->device_name);
|
||||
ua_copy (part + 9 * 4 + 1, -1, hfd->device_name);
|
||||
ua_copy ((char*)part + 9 * 4 + 1, -1, hfd->device_name);
|
||||
|
||||
denv = part + 128;
|
||||
pl(denv, 0, 80);
|
||||
@ -405,10 +405,10 @@ static int hdf_open2 (struct hardfiledata *hfd, const TCHAR *pname)
|
||||
hfd->vhd_bamoffset = gl (tmp + 8 + 8 + 4);
|
||||
hfd->vhd_bamsize = (((hfd->virtsize + hfd->vhd_blocksize - 1) / hfd->vhd_blocksize) * 4 + 511) & ~511;
|
||||
size = hfd->vhd_bamoffset + hfd->vhd_bamsize;
|
||||
hfd->vhd_header = xmalloc (size);
|
||||
hfd->vhd_header = xmalloc (uae_u8, size);
|
||||
if (hdf_read_target (hfd, hfd->vhd_header, 0, size) != size)
|
||||
goto end;
|
||||
hfd->vhd_sectormap = xmalloc (512);
|
||||
hfd->vhd_sectormap = xmalloc (uae_u8, 512);
|
||||
hfd->vhd_sectormapblock = -1;
|
||||
hfd->vhd_bitmapsize = ((hfd->vhd_blocksize / (8 * 512)) + 511) & ~511;
|
||||
}
|
||||
@ -460,11 +460,12 @@ int hdf_dup (struct hardfiledata *dhfd, const struct hardfiledata *shfd)
|
||||
|
||||
extern int get_guid_target (uae_u8 *out);
|
||||
|
||||
static uae_u64 vhd_read (struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offset, uae_u64 len)
|
||||
static uae_u64 vhd_read (struct hardfiledata *hfd, void *v, uae_u64 offset, uae_u64 len)
|
||||
{
|
||||
uae_u32 bamoffset;
|
||||
uae_u32 sectoroffset;
|
||||
uae_u64 read;
|
||||
uae_u8 *dataptr = (uae_u8*)v;
|
||||
|
||||
//write_log (L"%08x %08x\n", (uae_u32)offset, (uae_u32)len);
|
||||
read = 0;
|
||||
@ -524,7 +525,7 @@ static int vhd_write_enlarge (struct hardfiledata *hfd, uae_u32 bamoffset)
|
||||
int v;
|
||||
|
||||
len = hfd->vhd_blocksize + hfd->vhd_bitmapsize + 512;
|
||||
buf = xcalloc (len, 1);
|
||||
buf = xcalloc (uae_u8, len);
|
||||
if (!hdf_resize_target (hfd, hfd->physsize + len - 512)) {
|
||||
write_log (L"vhd_enlarge: failure\n");
|
||||
return 0;
|
||||
@ -553,11 +554,12 @@ static int vhd_write_enlarge (struct hardfiledata *hfd, uae_u32 bamoffset)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uae_u64 vhd_write (struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offset, uae_u64 len)
|
||||
static uae_u64 vhd_write (struct hardfiledata *hfd, void *v, uae_u64 offset, uae_u64 len)
|
||||
{
|
||||
uae_u32 bamoffset;
|
||||
uae_u32 sectoroffset;
|
||||
uae_u64 written;
|
||||
uae_u8 *dataptr = (uae_u8*)v;
|
||||
|
||||
//write_log (L"%08x %08x\n", (uae_u32)offset, (uae_u32)len);
|
||||
written = 0;
|
||||
@ -636,14 +638,14 @@ int vhd_create (const TCHAR *name, uae_u64 size, uae_u32 dostype)
|
||||
zf = zfile_fopen (name, L"wb", 0);
|
||||
if (!zf)
|
||||
goto end;
|
||||
b = xcalloc (512 + 1024 + batsize + 512, 1);
|
||||
b = xcalloc (uae_u8, 512 + 1024 + batsize + 512);
|
||||
if (zfile_fwrite (b, 512 + 1024 + batsize + 512, 1, zf) != 1)
|
||||
goto end;
|
||||
|
||||
memset (&hfd, 0, sizeof hfd);
|
||||
hfd.virtsize = hfd.physsize = size;
|
||||
hfd.blocksize = 512;
|
||||
strcpy (b, "conectix"); // cookie
|
||||
strcpy ((char*)b, "conectix"); // cookie
|
||||
b[0x0b] = 2; // features
|
||||
b[0x0d] = 1; // version
|
||||
b[0x10 + 6] = 2; // data offset
|
||||
@ -653,9 +655,9 @@ int vhd_create (const TCHAR *name, uae_u64 size, uae_u32 dostype)
|
||||
b[0x19] = tm >> 16;
|
||||
b[0x1a] = tm >> 8;
|
||||
b[0x1b] = tm >> 0;
|
||||
strcpy (b + 0x1c, "vpc "); // creator application
|
||||
strcpy ((char*)b + 0x1c, "vpc "); // creator application
|
||||
b[0x21] = 5; // creator version
|
||||
strcpy (b + 0x24, "Wi2k"); // creator host os
|
||||
strcpy ((char*)b + 0x24, "Wi2k"); // creator host os
|
||||
// original and current size
|
||||
b[0x28] = b[0x30] = size >> 56;
|
||||
b[0x29] = b[0x31] = size >> 48;
|
||||
@ -692,7 +694,7 @@ int vhd_create (const TCHAR *name, uae_u64 size, uae_u32 dostype)
|
||||
// dynamic disk header
|
||||
memset (b, 0, 1024);
|
||||
// cookie
|
||||
strcpy (b, "cxsparse");
|
||||
strcpy ((char*)b, "cxsparse");
|
||||
// data offset
|
||||
for (i = 0; i < 8; i++)
|
||||
b[0x08 + i] = 0xff;
|
||||
@ -757,9 +759,10 @@ static int hdf_read2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, in
|
||||
return hdf_read_target (hfd, buffer, offset, len);
|
||||
}
|
||||
|
||||
static void adide_decode (uae_u8 *buffer, int len)
|
||||
static void adide_decode (void *v, int len)
|
||||
{
|
||||
int i;
|
||||
uae_u8 *buffer = (uae_u8*)v;
|
||||
for (i = 0; i < len; i += 2) {
|
||||
uae_u8 *b = buffer + i;
|
||||
uae_u16 w = (b[0] << 8) | (b[1] << 0);
|
||||
@ -809,9 +812,10 @@ static void adide_decode (uae_u8 *buffer, int len)
|
||||
b[1] = o >> 0;
|
||||
}
|
||||
}
|
||||
static void adide_encode (uae_u8 *buffer, int len)
|
||||
static void adide_encode (void *v, int len)
|
||||
{
|
||||
int i;
|
||||
uae_u8 *buffer = (uae_u8*)v;
|
||||
for (i = 0; i < len; i += 2) {
|
||||
uae_u8 *b = buffer + i;
|
||||
uae_u16 w = (b[0] << 8) | (b[1] << 0);
|
||||
@ -862,9 +866,11 @@ static void adide_encode (uae_u8 *buffer, int len)
|
||||
}
|
||||
}
|
||||
|
||||
static void hdf_byteswap (uae_u8 *b, int len)
|
||||
static void hdf_byteswap (void *v, int len)
|
||||
{
|
||||
int i;
|
||||
uae_u8 *b = (uae_u8*)v;
|
||||
|
||||
for (i = 0; i < len; i += 2) {
|
||||
uae_u8 tmp = b[i];
|
||||
b[i] = b[i + 1];
|
||||
@ -1285,7 +1291,7 @@ static int handle_scsi (uaecptr request, struct hardfiledata *hfd)
|
||||
{
|
||||
uae_u32 acmd = get_long (request + 40);
|
||||
uaecptr scsi_data = get_long (acmd + 0);
|
||||
uae_u32 scsi_len = get_long (acmd + 4);
|
||||
int scsi_len = get_long (acmd + 4);
|
||||
uaecptr scsi_cmd = get_long (acmd + 12);
|
||||
uae_u16 scsi_cmd_len = get_word (acmd + 16);
|
||||
uae_u8 scsi_flags = get_byte (acmd + 20);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user