-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQFilesPriv.h
233 lines (199 loc) · 6.72 KB
/
QFilesPriv.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/*
* (c) UQLX - see COPYRIGHT
*/
#ifndef QFPH
#define QFPH
#define rOpenFiles 133
#define SOFT_ERROR -9845
#define DEMO_ERROR -9846
/* it would be so easy to use this struct ..*/
#if 0
#pragma options align=mac68k
struct mdvFile {
w16 fNumber;
w32 pos;
w32 eof;
w32 slave;
char boh[6];
unsigned char name[38];
struct mdvFile *next;
short vol;
long dir;
short ref;
short key;
short drive;
Cond isDirectory; /* dirs can't be written !! */
Cond open;
Cond qlDisk;
long id; /* to detect overwritten file block */
};
#else
struct mdvFile{ char dummy[130];};
#endif
/* unfortunately it gets packed differently on many systems so we need
assembler style offstes instead */
#define PACKED __attribute__ ((packed))
typedef struct {
int dir PACKED; /* file number of (parent) direcory */
int file PACKED;
int entrynum PACKED; /* number of entry in directory */
}FileNum;
struct fileHeader *GetFileHeader(FileNum fileNum);
/* Commented out, cos redefined below without all the screwy brackets and maths
#define _fNumber 0
#define _pos 2
#define _eof 6
#define _slave 10
#define _name 20
#define _next (20+38)
#define _vol (_next+4)
#define _dir (_vol+2)
#define _ref (_dir+4)
#define _qkey (_ref+4)
#define _drive (_key+2)
#define _isdir (_drive+2)
#define _open (_isdir+2)
#define _qlDisk (_open+2)
#define _id (_qlDisk+2)
#define _filesys (_id+4)
#define _hfileref (_filesys+4)
//#define _nfn (_hfileref+4)
#define _hf_fcb (_hfileref+4)
#define mdvFile_len (_hf_fcb+8)
*/
// Defined these offsets directly, and ipc.h defines _key so changed it to _qkey
#define _fNumber 0
#define _pos 2
#define _eof 6
#define _slave 10
#define _name 20
#define _next 58
#define _vol 62
#define _dir 64
#define _ref 68
#define _qkey 72
#define _drive 74
#define _isdir 76
#define _open 78
#define _qlDisk 80
#define _id 82
#define _filesys 86
#define _hfileref 90
//#define _nfn (_hfileref+4)
#define _hf_fcb 94
#define mdvFile_len 102
/* Macros needed to avoid alignment errors on certain architectures */
#if 0
#define SET_FNUM(_mdvf_,_num_) (WW((Ptr)((Ptr)(_mdvf_)+_fNumber),(_num_)))
#define GET_FNUMBER(_mdvf_) (RW((Ptr)((Ptr)(_mdvf_)+_fNumber)))
#else
#if 0
#define SET_FNUM(_mdvf_,_num_) (*(FileNum*)((Ptr)(_mdvf_)+_nfn)=(_num_))
#define GET_FNUMBER(_mdvf_) (*(FileNum*)((Ptr)(_mdvf_)+_nfn))
#endif
#endif
#define SET_POS(_mdvf_,_pos_) (WL((Ptr)((Ptr)(_mdvf_)+_pos),(_pos_)))
#define GET_POS(_mdvf_) (RL((Ptr)((Ptr)(_mdvf_)+_pos)))
#define SET_EOF(_mdvf_,_pos_) (WL((Ptr)((Ptr)(_mdvf_)+_eof),(_pos_)))
#define GET_EOF(_mdvf_) (RL((Ptr)((Ptr)(_mdvf_)+_eof)))
#define SET_REF(_mdvf_,_ref_) (WL((Ptr)((Ptr)(_mdvf_)+_ref),(_ref_)))
#define GET_REF(_mdvf_) (RL((Ptr)((Ptr)(_mdvf_)+_ref)))
#define SET_NEXT(_mdvf_,_nxt_) (WL((Ptr)((Ptr)(_mdvf_)+_next),(w32)(_nxt_)))
#define GET_NEXT(_mdvf_) ((struct mdvFile *)RL((Ptr)((Ptr)(_mdvf_)+_next)))
#define SET_ID(_mdvf_,_id_) (WL((Ptr)((Ptr)(_mdvf_)+_id),(_id_)))
#define GET_ID(_mdvf_) (RL((Ptr)((Ptr)(_mdvf_)+_id)))
#define GET_OPEN(_mdvf_) (RW((Ptr)((Ptr)(_mdvf_)+_open)))
#define SET_OPEN(_mdvf_,_val_) (WW((Ptr)((Ptr)(_mdvf_)+_open),(_val_)))
#define GET_DRIVE(_mdvf_) (RW((Ptr)((Ptr)(_mdvf_)+_drive)))
#define GET_ISDIR(_mdvf_) (RW((Ptr)((Ptr)(_mdvf_)+_isdir)))
#define GET_ISDISK(_mdvf_) (RW((Ptr)((Ptr)(_mdvf_)+_qlDisk)))
#define NAME_REF(_mdvf_) ((char *)(Ptr)(_mdvf_)+_name)
#define GET_KEY(_mdvf_) ((w16)RW((Ptr)((Ptr)(_mdvf_)+_qkey)))
#define SET_DRIVE(_mdvf_,_drv_) (WW((Ptr)((Ptr)(_mdvf_)+_drive),(_drv_)))
#define SET_ISDIR(_mdvf_,_val_) (WW((Ptr)((Ptr)(_mdvf_)+_isdir),(_val_)))
#define SET_ISDISK(_mdvf_,_val_) (WW((Ptr)((Ptr)(_mdvf_)+_qlDisk),(_val_)))
#define SET_KEY(_mdvf_,_val_) (WW((Ptr)((Ptr)(_mdvf_)+_qkey),(_val_)))
#define GET_FILESYS(_mdvf_) ((w32)(RL((Ptr)((Ptr)(_mdvf_)+_filesys))))
#define SET_FILESYS(_mdvf_,_val_) (WL((Ptr)((Ptr)(_mdvf_)+_filesys),(_val_)))
#define GET_HFILE(_mdvf_) ((RL((Ptr)((Ptr)(_mdvf_)+_hfileref))))
#define SET_HFILE(_mdvf_,_val_) (WL((Ptr)((Ptr)(_mdvf_)+_hfileref),(_val_)))
#define GET_FCB(_mdvf_) ((struct HF_FCB *)(GET_POINTER((Ptr)(_mdvf_) + _hf_fcb)))
/*(RL((Ptr)((Ptr)(_mdvf_)+_hf_fcb))))*/
#define SET_FCB(_mdvf_,_val_) SET_POINTER((Ptr)(_mdvf_)+_hf_fcb,(_val_))
/*(WL((Ptr)((Ptr)(_mdvf_)+_hf_fcb),(_val_)))*/
#define SET_FNUM(_mxdvf_,_num_) (GET_FCB(_mxdvf_)->fileNum=_num_)
#define GET_FNUMBER(_mxdvf_) (GET_FCB(_mxdvf_)->fileNum)
/* the addr of this struct is accessed by GET_FCB(f) */
/* most of the attribs now stored in mdvFile should go into it */
struct HF_FCB
{
struct HF_FCB *next;
int mode;
FileNum fileNum; /* DiskOp only */
/* %--------------% */
char uxname[256]; /* must be last and unpadded in this struct for QVFS */
};
#if 0
struct fileHeader{
w32 len;
w8 access;
w8 type;
w32 info1;
w32 info2;
unsigned char name[38];
w32 date_update;
w32 date_ref;
w32 date_backup;
};
#else
struct fileHeader { char xx[64];};
#endif
#define _flen 0
#define _facc 4
#define _ftyp 5
#define _finf1 6
#define _finf2 10
#define _fname 14
#define _fdupdt (0x34)
/*#define _fdref (_0x3c)*/
#define _fdtbak (0x3c)
#define _fdvers 0x38
#define SET_FLEN(_fh_,_len_) (WL((Ptr)_fh_,_len_))
#define GET_FLEN(_fh_) (RL((Ptr)_fh_))
#define SET_FACC(_fh_,_len_) (WB((Ptr)_fh_+_facc,_len_))
#define GET_FACC(_fh_) (RB((Ptr)_fh_+_facc))
#define SET_FTYP(_fh_,_len_) (WB((Ptr)_fh_+_ftyp,_len_))
#define GET_FTYP(_fh_) (RB((Ptr)_fh_+_ftyp))
#define R_FNM(_fh_) ((unsigned char *)((unsigned char *)(_fh_)+_fname))
#define SET_FDUPDT(_fh_,_tme_) (WL((Ptr)_fh_+_fdupdt,_tme_))
#define SET_FDTBAC(_fh_,_tme_) (WL((Ptr)_fh_+_fdtbak,_tme_))
#define SET_FVER(_fh_,_tme_) (WW((Ptr)_fh_+_fdvers,_tme_))
#define GET_FVER(_fh_) (RW((Ptr)_fh_+_fdvers))
#define GET_FDUPDT(_fh_) (RL((Ptr)_fh_+_fdupdt))
#define GET_FDTBAC(_fh_) (RL((Ptr)_fh_+_fdtbak))
typedef char Str255[256];
extern unsigned char mdvHeaders[];
extern short mdvOn;
void CloseAllMdvFiles(short,int);
void StopMotor(void);
Cond FileAlreadyOpen(short,int,FileNum,w16 *);
void FilenameFromQL(unsigned char *);
void GetWDparms(short,short *,long *);
OSErr GetDirName(Str255,short,long);
OSErr QDiskDelete(struct mdvFile*);
OSErr QDiskOpen(struct mdvFile*,int ,Cond, Cond);
void QDiskClose(struct mdvFile*);
w32 QDiskLen(struct mdvFile*);
OSErr QDiskIO(struct mdvFile*,short);
void QDiskFormat(uw8*,long*,long*);
void AdjustSetDirMenu(void);
void InitFileDrivers(void);
w32 PhysicalDefBlock(void);
void QHDeleteHeader(char *,int , char *, struct mdvFile *, int);
int HDelete(int , int , unsigned char *, struct mdvFile *, int);
int HOpenDF(int , long ,unsigned char *, long, struct mdvFile *, int, int);
int QHOpenDir(struct mdvFile *, int);
int HCreate(struct mdvFile *, unsigned char *, unsigned char *, unsigned char *, int);
int HDfLen(struct mdvFile *, int);
int QHostIO(struct mdvFile *, int, int );
#endif