From: Toni Wilen Date: Sat, 13 Feb 2010 12:57:53 +0000 (+0200) Subject: imported winuaesrc2020b11b.zip X-Git-Tag: 2100~27 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=dc4fd26a84e27941cea94cec81f99724a45c3630;p=francis%2Fwinuae.git imported winuaesrc2020b11b.zip --- diff --git a/archivers/dms/cdata.h b/archivers/dms/cdata.h index b5e77e09..4de9b9f9 100644 --- a/archivers/dms/cdata.h +++ b/archivers/dms/cdata.h @@ -75,6 +75,6 @@ #define DIR_SEPARATORS ":\\/" -extern UCHAR *text; - +extern UCHAR *dms_text; +extern USHORT dms_lastlen, dms_np; diff --git a/archivers/dms/crc_csum.cpp b/archivers/dms/crc_csum.cpp index 70337c62..8147c5b5 100644 --- a/archivers/dms/crc_csum.cpp +++ b/archivers/dms/crc_csum.cpp @@ -14,7 +14,7 @@ -USHORT Calc_CheckSum(UCHAR *mem, ULONG size){ +USHORT dms_Calc_CheckSum(UCHAR *mem, ULONG size){ USHORT u=0; while(size--) u += *mem++; @@ -23,7 +23,7 @@ USHORT Calc_CheckSum(UCHAR *mem, ULONG size){ -USHORT CreateCRC(UCHAR* mem, ULONG size ){ +USHORT dms_CreateCRC(UCHAR* mem, ULONG size ){ static USHORT CRCTab[256]={ 0x0000,0xC0C1,0xC181,0x0140,0xC301,0x03C0,0x0280,0xC241, 0xC601,0x06C0,0x0780,0xC741,0x0500,0xC5C1,0xC481,0x0440, diff --git a/archivers/dms/crc_csum.h b/archivers/dms/crc_csum.h index 0fa92f50..4809fa5b 100644 --- a/archivers/dms/crc_csum.h +++ b/archivers/dms/crc_csum.h @@ -1,4 +1,4 @@ -USHORT Calc_CheckSum(UCHAR *, ULONG); -USHORT CreateCRC(UCHAR *, ULONG); +USHORT dms_Calc_CheckSum(UCHAR *, ULONG); +USHORT dms_CreateCRC(UCHAR *, ULONG); diff --git a/archivers/dms/getbits.cpp b/archivers/dms/getbits.cpp index bfaa835c..e972c7b3 100644 --- a/archivers/dms/getbits.cpp +++ b/archivers/dms/getbits.cpp @@ -10,7 +10,7 @@ #include "getbits.h" -ULONG mask_bits[]={ +ULONG dms_mask_bits[]={ 0x000000L,0x000001L,0x000003L,0x000007L,0x00000fL,0x00001fL, 0x00003fL,0x00007fL,0x0000ffL,0x0001ffL,0x0003ffL,0x0007ffL, 0x000fffL,0x001fffL,0x003fffL,0x007fffL,0x00ffffL,0x01ffffL, @@ -19,15 +19,15 @@ ULONG mask_bits[]={ }; -UCHAR *indata, bitcount; -ULONG bitbuf; +UCHAR *dms_indata, dms_bitcount; +ULONG dms_bitbuf; void initbitbuf(UCHAR *in){ - bitbuf = 0; - bitcount = 0; - indata = in; + dms_bitbuf = 0; + dms_bitcount = 0; + dms_indata = in; DROPBITS(0); } diff --git a/archivers/dms/getbits.h b/archivers/dms/getbits.h index f0c5adde..d6224ec1 100644 --- a/archivers/dms/getbits.h +++ b/archivers/dms/getbits.h @@ -1,9 +1,9 @@ -extern ULONG mask_bits[], bitbuf; -extern UCHAR *indata, bitcount; +extern ULONG dms_mask_bits[], dms_bitbuf; +extern UCHAR *dms_indata, dms_bitcount; -#define GETBITS(n) ((USHORT)(bitbuf >> (bitcount-(n)))) -#define DROPBITS(n) {bitbuf &= mask_bits[bitcount-=(n)]; while (bitcount<16) {bitbuf = (bitbuf << 8) | *indata++; bitcount += 8;}} +#define GETBITS(n) ((USHORT)(dms_bitbuf >> (dms_bitcount-(n)))) +#define DROPBITS(n) {dms_bitbuf &= dms_mask_bits[dms_bitcount-=(n)]; while (dms_bitcount<16) {dms_bitbuf = (dms_bitbuf << 8) | *dms_indata++; dms_bitcount += 8;}} void initbitbuf(UCHAR *); diff --git a/archivers/dms/maketbl.cpp b/archivers/dms/maketbl.cpp index c735988c..2e85370f 100644 --- a/archivers/dms/maketbl.cpp +++ b/archivers/dms/maketbl.cpp @@ -23,7 +23,7 @@ static USHORT mktbl(void); -USHORT make_table(USHORT nchar, UCHAR bitlen[],USHORT tablebits, USHORT table[]){ +USHORT dms_make_table(USHORT nchar, UCHAR bitlen[],USHORT tablebits, USHORT table[]){ n = avail = nchar; blen = bitlen; tbl = table; @@ -77,8 +77,8 @@ static USHORT mktbl(void){ TabErr = 3; return 0; } - left[i] = mktbl(); - right[i] = mktbl(); + dms_left[i] = mktbl(); + dms_right[i] = mktbl(); if (codeword >= tblsiz) { TabErr = 4; return 0; diff --git a/archivers/dms/maketbl.h b/archivers/dms/maketbl.h index 42abc3e7..ad3fac6f 100644 --- a/archivers/dms/maketbl.h +++ b/archivers/dms/maketbl.h @@ -1,5 +1,5 @@ -extern USHORT left[], right[]; +extern USHORT dms_left[], dms_right[]; -USHORT make_table(USHORT nchar, UCHAR bitlen[], USHORT tablebits, USHORT table[]); +USHORT dms_make_table(USHORT nchar, UCHAR bitlen[], USHORT tablebits, USHORT table[]); diff --git a/archivers/dms/pfile.cpp b/archivers/dms/pfile.cpp index f84b8e9e..5112a98b 100644 --- a/archivers/dms/pfile.cpp +++ b/archivers/dms/pfile.cpp @@ -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; -static UCHAR *text; +UCHAR *dms_text; static void log_error(int track) { @@ -91,8 +91,8 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o free(b1); return ERR_NOMEMORY; } - text = xcalloc(UCHAR,TEMP_BUFFER_LEN); - if (!text) { + dms_text = xcalloc(UCHAR,TEMP_BUFFER_LEN); + if (!dms_text) { free(b1); free(b2); return ERR_NOMEMORY; @@ -103,7 +103,7 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o if (zfile_fread(b1,1,HEADLEN,fi) != HEADLEN) { free(b1); free(b2); - free(text); + free(dms_text); return ERR_SREAD; } @@ -111,17 +111,17 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o /* Check the first 4 bytes of file to see if it is "DMS!" */ free(b1); free(b2); - free(text); + free(dms_text); return ERR_NOTDMS; } hcrc = (USHORT)((b1[HEADLEN-2]<<8) | b1[HEADLEN-1]); /* Header CRC */ - if (hcrc != CreateCRC(b1+4,(ULONG)(HEADLEN-6))) { + if (hcrc != dms_CreateCRC(b1+4,(ULONG)(HEADLEN-6))) { free(b1); free(b2); - free(text); + free(dms_text); return ERR_HCRC; } @@ -133,7 +133,7 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o if (part && from < 30) { free(b1); free(b2); - free(text); + free(dms_text); return DMS_FILE_END; } @@ -221,7 +221,7 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o /* It's not a DMS compressed disk image, but a FMS archive */ free(b1); free(b2); - free(text); + free(dms_text); return ERR_FMS; } @@ -290,7 +290,7 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o free(b1); free(b2); - free(text); + free(dms_text); return ret; } @@ -316,7 +316,7 @@ static USHORT Process_Track(struct zfile *fi, struct zfile *fo, UCHAR *b1, UCHAR /* Track Header CRC */ hcrc = (USHORT)((b1[THLEN-2] << 8) | b1[THLEN-1]); - if (CreateCRC(b1,(ULONG)(THLEN-2)) != hcrc) return ERR_THCRC; + if (dms_CreateCRC(b1,(ULONG)(THLEN-2)) != hcrc) return ERR_THCRC; number = (USHORT)((b1[2] << 8) | b1[3]); /* Number of track */ pklen1 = (USHORT)((b1[6] << 8) | b1[7]); /* Length of packed track data as in archive */ @@ -347,7 +347,7 @@ static USHORT Process_Track(struct zfile *fi, struct zfile *fo, UCHAR *b1, UCHAR if (zfile_fread(b1,1,(size_t)pklen1,fi) != pklen1) return ERR_SREAD; - if (CreateCRC(b1,(ULONG)pklen1) != dcrc) { + if (dms_CreateCRC(b1,(ULONG)pklen1) != dcrc) { log_error (number); crcerr = 1; } @@ -480,7 +480,7 @@ static USHORT Unpack_Track(UCHAR *b1, UCHAR *b2, USHORT pklen2, USHORT unpklen, dms_decrypt(b1, pklen1, b1); r = Unpack_Track_2(b1, b2, pklen2, unpklen, cmode, flags); if (r == NO_PROBLEM) { - if (usum1 == Calc_CheckSum(b2,(ULONG)unpklen)) + if (usum1 == dms_Calc_CheckSum(b2,(ULONG)unpklen)) return NO_PROBLEM; } log_error(number); @@ -497,7 +497,7 @@ static USHORT Unpack_Track(UCHAR *b1, UCHAR *b2, USHORT pklen2, USHORT unpklen, for (;;) { r = Unpack_Track_2(b1, b2, pklen2, unpklen, cmode, flags); if (r == NO_PROBLEM) { - if (usum1 == Calc_CheckSum(b2,(ULONG)unpklen)) { + if (usum1 == dms_Calc_CheckSum(b2,(ULONG)unpklen)) { passfound = maybeencrypted; if (passfound) write_log (L"DMS: decryption key = 0x%04X\n", prevpass); diff --git a/archivers/dms/u_deep.cpp b/archivers/dms/u_deep.cpp index 45d040ae..1595d778 100644 --- a/archivers/dms/u_deep.cpp +++ b/archivers/dms/u_deep.cpp @@ -23,8 +23,8 @@ INLINE void update(USHORT c); static void reconst(void); -USHORT deep_text_loc; -int init_deep_tabs=1; +USHORT dms_deep_text_loc; +int dms_init_deep_tabs=1; @@ -66,7 +66,7 @@ void Init_DEEP_Tabs(void){ freq[T] = 0xffff; prnt[R] = 0; - init_deep_tabs = 0; + dms_init_deep_tabs = 0; } @@ -77,21 +77,21 @@ USHORT Unpack_DEEP(UCHAR *in, UCHAR *out, USHORT origsize){ initbitbuf(in); - if (init_deep_tabs) Init_DEEP_Tabs(); + if (dms_init_deep_tabs) Init_DEEP_Tabs(); outend = out+origsize; while (out < outend) { c = DecodeChar(); if (c < 256) { - *out++ = text[deep_text_loc++ & DBITMASK] = (UCHAR)c; + *out++ = dms_text[dms_deep_text_loc++ & DBITMASK] = (UCHAR)c; } else { j = (USHORT) (c - 255 + THRESHOLD); - i = (USHORT) (deep_text_loc - DecodePosition() - 1); - while (j--) *out++ = text[deep_text_loc++ & DBITMASK] = text[i++ & DBITMASK]; + i = (USHORT) (dms_deep_text_loc - DecodePosition() - 1); + while (j--) *out++ = dms_text[dms_deep_text_loc++ & DBITMASK] = dms_text[i++ & DBITMASK]; } } - deep_text_loc = (USHORT)((deep_text_loc+60) & DBITMASK); + dms_deep_text_loc = (USHORT)((dms_deep_text_loc+60) & DBITMASK); return 0; } diff --git a/archivers/dms/u_deep.h b/archivers/dms/u_deep.h index d87be1d9..ae542ee9 100644 --- a/archivers/dms/u_deep.h +++ b/archivers/dms/u_deep.h @@ -2,6 +2,6 @@ USHORT Unpack_DEEP(UCHAR *, UCHAR *, USHORT); -extern int init_deep_tabs; -extern USHORT deep_text_loc; +extern int dms_init_deep_tabs; +extern USHORT dms_deep_text_loc; diff --git a/archivers/dms/u_heavy.cpp b/archivers/dms/u_heavy.cpp index 42d2eb81..6ce06c49 100644 --- a/archivers/dms/u_heavy.cpp +++ b/archivers/dms/u_heavy.cpp @@ -21,11 +21,11 @@ #define N1 510 #define OFFSET 253 -static USHORT left[2 * NC - 1], right[2 * NC - 1 + 9]; +USHORT dms_left[2 * NC - 1], dms_right[2 * NC - 1 + 9]; static UCHAR c_len[NC], pt_len[NPT]; static USHORT c_table[4096], pt_table[256]; -USHORT lastlen, np; -USHORT heavy_text_loc; +USHORT dms_lastlen, dms_np; +USHORT dms_heavy_text_loc; static USHORT read_tree_c(void); @@ -42,10 +42,10 @@ USHORT Unpack_HEAVY(UCHAR *in, UCHAR *out, UCHAR flags, USHORT origsize){ /* Heavy 1 uses a 4Kb dictionary, Heavy 2 uses 8Kb */ if (flags & 8) { - np = 15; + dms_np = 15; bitmask = 0x1fff; } else { - np = 14; + dms_np = 14; bitmask = 0x0fff; } @@ -61,11 +61,11 @@ USHORT Unpack_HEAVY(UCHAR *in, UCHAR *out, UCHAR flags, USHORT origsize){ while (out>= 1; } while (j >= N1); DROPBITS(c_len[j] - 12); @@ -100,29 +100,29 @@ INLINE USHORT decode_p(void){ USHORT i, j, m; j = pt_table[GETBITS(8)]; - if (j < np) { + if (j < dms_np) { DROPBITS(pt_len[j]); } else { DROPBITS(8); i = GETBITS(16); m = 0x8000; do { - if (i & m) j = right[j]; - else j = left [j]; + if (i & m) j = dms_right[j]; + else j = dms_left [j]; m >>= 1; - } while (j >= np); + } while (j >= dms_np); DROPBITS(pt_len[j] - 8); } - if (j != np-1) { + if (j != dms_np-1) { if (j > 0) { j = (USHORT)(GETBITS(i=(USHORT)(j-1)) | (1U << (j-1))); DROPBITS(i); } - lastlen=j; + dms_lastlen=j; } - return lastlen; + return dms_lastlen; } @@ -139,7 +139,7 @@ static USHORT read_tree_c(void){ DROPBITS(5); } for (i=n; i<510; i++) c_len[i] = 0; - if (make_table(510,c_len,12,c_table)) return 1; + if (dms_make_table(510,c_len,12,c_table)) return 1; } else { n = GETBITS(9); DROPBITS(9); @@ -161,12 +161,12 @@ static USHORT read_tree_p(void){ pt_len[i] = (UCHAR)GETBITS(4); DROPBITS(4); } - for (i=n; i