-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcbmarcs.h
126 lines (112 loc) · 3.38 KB
/
cbmarcs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
* cbmarcs.h
*
* Commodore archive formats directory display routines
*
* fvcbm is copyright 1993-2024 Dan Fandrich, et. al.
* fvcbm is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2, as
* published by the Free Software Foundation.
*
* fvcbm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with fvcbm; if not, see <https://www.gnu.org/licenses/>.
*/
/*
* System type defined upon the following
* __TURBOC__ : All Borland C/C++ versions
* __ZTC__ : Zortech
* __SC__ : Symantec
* __WATCOM__ : Watcom
* MSDOS : Set by various DOS compilers... ( Watcom 386, Microsoft )
*/
#if defined(__TURBOC__) || defined(__ZTC__) || defined(MSDOS) || \
defined(__SC__) || defined(__WATCOMC__)
#ifndef __MSDOS__
#define __MSDOS__
#endif
#endif
#include <stdio.h>
#if (!defined(SUNOS) && !defined(sun) && !defined(_WIN32))
#if defined(__MACH__) || defined(__DJGPP__) || defined(__FreeBSD__)
#include <machine/endian.h>
#elif defined(__GNUC__)
#include <endian.h>
#endif
#endif
#if (defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN) \
|| (defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN) \
|| defined(IS_BIG_ENDIAN)
/* big-endian conversion macros */
#define CF_LE_W(n) ((((n) & 0xff) << 8) | (((n) & 0xff00) >> 8))
#define CF_LE_L(n) ((((n) & 0xff) << 24) | (((n) & 0xff00) << 8) | \
(((n) & 0xff0000L) >> 8) | (((n) & 0xff000000L) >> 24))
#else
/* little-endian conversion macros */
#define CF_LE_W(n) (n)
#define CF_LE_L(n) (n)
#endif
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
/* C99 introduced these specific-length types */
#include <stdint.h>
typedef uint8_t BYTE; /* 8 bits */
typedef uint16_t WORD; /* 16 bits */
typedef int32_t LONG; /* 32 bits */
#else
/* These may be wrong, especially on 64-bit architectures */
typedef unsigned char BYTE; /* 8 bits */
typedef unsigned short WORD; /* 16 bits */
typedef long LONG; /* 32 bits */
#endif
/* Codes for each identifiable archive type */
/* Remember to change ArchiveFormats[], DirFunctions[] and TestFunctions[]
if you change these enums */
enum ArchiveTypes {
C64_ARC,
C64_10,
C64_13,
C64_15,
C128_15,
LHA_SFX,
LHA,
Lynx,
LynxNew,
T64,
D64,
C1581,
X64,
P00,
S00,
U00,
R00,
D00,
X00,
N64,
LBR,
TAP,
UnknownArchive
};
extern const char * const ArchiveFormats[];
extern int WideFormat;
struct ArcTotals {
int ArchiveEntries;
int TotalBlocks;
int TotalBlocksNow;
long TotalLength;
int DearcerBlocks;
int Version; /* Not a total, but still interesting info */
/* Version > 0 is an integer
Version < 0 is a fixed point integer to 1 decimal
Version = 0 is unknown or n/a */
};
enum ArchiveTypes DetermineArchiveType(FILE *InFile, const char *FileName);
typedef void (*DisplayStartFunc)(enum ArchiveTypes ArchiveType, const char *Name);
typedef int (*DisplayEntryFunc)(const char *Name, const char *Type,
unsigned long Length, unsigned Blocks, const char *Storage,
int Compression, unsigned BlocksNow, long Checksum);
int DirArchive(FILE *InFile, enum ArchiveTypes SDAType,
struct ArcTotals *Totals, DisplayStartFunc, DisplayEntryFunc);