-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFTPMount.h
281 lines (223 loc) · 6.29 KB
/
FTPMount.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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/* All includes for FTPMount in one file - R.Riedel 2003-03-08
* AmigaOS4 port (c) 2005-2006 Alexandre BALABAN (alexandre (at) free (dot) fr)
*/
/* activate this to build debug-versions! */
/*
#define DEBUGSTATUS 1
*/
#define __USE_INLINE__ /* 2005-05-14 ABA : OS4 */
#define __USE_BASETYPE__ /* 2005-05-14 ABA : OS4 */
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdint.h>
#include <proto/exec.h>
#include <dos/dostags.h>
#include <intuition/sghooks.h>
#include <devices/timer.h>
#include <clib/alib_protos.h>
/*
#ifndef __MORPHOS__
#include <clib/alib_stdio_protos.h>
#endif
*/
#include <clib/debug_protos.h>
#include <proto/commodities.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/gadtools.h>
#include <proto/graphics.h>
#include <proto/icon.h>
#include <proto/intuition.h>
#include <proto/locale.h>
#include <proto/wb.h>
#ifndef __SASC
#define INLINES_AS_MACROS 1 /* SAS doesn't seem to do inlines properly */
#endif
#ifndef __MORPHOS__
#include <proto/bsdsocket.h> /* 2003-03-02 rri */
#else
#include <proto/socket.h>
#endif
#include <sys/errno.h>
#include <sys/ioccom.h> /* 2003-03-02 rri */
#include <netdb.h>
#define FIONBIO _IOW('f', 126, long) /* set/clear non-blocking i/o */ /* 2003-03-02 rri */
#define stci_d(out, ival) sprintf((out),"%d", (ival))
#ifdef __amigaos4__
#undef CreateExtIO
#define CreateExtIO( mp, size ) AllocSysObjectTags( ASOT_IOREQUEST, \
ASOIOR_Size, (size), \
ASOIOR_ReplyPort, (mp), \
ASO_NoTrack, 0, \
TAG_DONE)
#undef DeleteExtIO
#define DeleteExtIO( io ) FreeSysObject(ASOT_IOREQUEST, (io));
int atoi(const char *string);
#endif
#ifdef __MORPHOS__
#define sprintf(buf, fmt, tags...) NewRawDoFmt(fmt, 0, buf, tags)
int atoi(const char *string);
static inline int atol(const char *string)
{
return atoi(string);
}
static inline void *malloc(int size)
{
return AllocVecTaskPooled(size);
}
static inline void free(void *p)
{
FreeVecTaskPooled(p);
}
#endif
/* twdebug.h */
#ifdef DEBUGSTATUS
/* void kprintf(UBYTE *fmt,...); */
#define DS(x) x;
#else
#define DS(x)
#endif
#if !defined(__amigaos4__) /* 2005-05-14 ABA : OS4 already defines what's needed */
# if !defined(__MORPHOS__)
#ifdef __SASC
# define SAVEDS __saveds
# define ASM __asm
# define REG(x,y) register __##x y
#elif defined(__GNUC__)
# define SAVEDS __saveds
# define ASM
# define REG(x,y) y __asm(#x)
#elif defined(_DCC)
# define SAVEDS __geta4
# define ASM
# define REG(x,y) __##x y
#elif defined(__STORM__)
# define SAVEDS __saveds
# define ASM
# define REG(x,y) register __##x y
#elif defined(__VBCC__)
# define SAVEDS __saveds
# define ASM
# define REG(x,y) __reg(#x) y
#endif
#endif
#endif
/* evtypes.h */
typedef void (*ptf)();
#ifdef TRUE
#undef TRUE
#endif
#ifdef FALSE
#undef FALSE
#endif
#ifdef NULL
#undef NULL
#endif
static void* const nil = 0;
static void* const NULL = 0;
typedef enum
{ false = (1 == 0), true = (1 == 1)
} boolean;
/* NB: this only works for y a power of 2 */
#define ROUND_UP(x, y) ((x + y - 1) & (~(y - 1)))
#include "verify.h"
#define V_DosList 17519
#define V_StandardPacket 21364
#define V_bstr 25203
#define V_cstr 25458
#define V_lock 27759
typedef struct my_lock
{
struct FileLock fl;
magic_verify;
struct my_lock* next;
struct MsgPort* port;
unsigned long rfsl, lastkey;
unsigned char fname[1];
} lock;
#define V_file_info 26217
#define FIRST_BLOCK_SIZE 512
#define MAX_READ_SIZE 2048
typedef struct my_file_info
{
magic_verify;
struct my_file_info* next;
unsigned long rfarg; /* real file arg */
unsigned long rpos, vpos, end; /* real file position, virtual file position, file end */
struct MsgPort* port;
struct tcpm* tm;
unsigned short type;
boolean seek_end, eof, closed;
unsigned char first_block[FIRST_BLOCK_SIZE];
unsigned char fname[1];
} file_info;
/* special internal packets */
#define action_IDLE 2050
#define action_IDLE_DEATH 2051
#define action_SUSPEND 2052
#define VERSION "1"
#define REVISION "5"
#ifdef DECLARE_GLOBALS_HERE
#define global
#else
#define global extern
#endif
global struct ExecBase *SysBase;
global struct DosLibrary *DOSBase;
global struct IntuitionBase* IntuitionBase;
global struct GfxBase* GfxBase;
global struct Library* GadToolsBase;
global struct Library* IconBase;
global struct Library *CxBase;
#if defined(__MORPHOS__) || defined(__amigaos4__)
global struct Library *LocaleBase; /* 12-04-04 itix */
#else
global struct LocaleBase* LocaleBase; /* 03-03-01 rri */
#endif
#ifdef __amigaos4__
global struct ExecIFace *IExec;
global struct DOSIFace *IDOS;
global struct IntuitionIFace *IIntuition;
global struct GraphicsIFace *IGraphics;
global struct GadToolsIFace *IGadTools;
global struct IconIFace *IIcon;
global struct LocaleIFace *ILocale;
#define IntuitionParamDef struct IntuitionIFace * IIntuition
#define IntuitionParam IIntuition
#define GraphicsParamDef struct GraphicsIFace * IGraphics
#define GraphicsParam IGraphics
#define GadToolsParamDef struct GadToolsIFace * IGadTools
#define GadToolsParam IGadTools
#else
#define IntuitionParamDef struct IntuitionBase *IntuitionBase
#define IntuitionParam IntuitionBase
#define GraphicsParamDef struct GfxBase *GfxBase
#define GraphicsParam GfxBase
#define GadToolsParamDef struct Library *GadToolsBase
#define GadToolsParam GadToolsBase
#endif
global struct MsgPort *ftp_port, *tcp, *startup_sync, *broker_port;
global struct DosList *ftp_device, *ftp_volume;
global BPTR ftpdir_lock, ftphosts_lock;
global struct tcpm* prime; /* the numero uno tcp message */
global unsigned char unique_buffer[25];
global unsigned short ftp_port_number;
global struct site_s* sites;
global unsigned char* anon_login;
global struct Message* local_msg;
global struct MsgPort* local_port;
global struct gim *cancel_gim, *abort_gim, *disconnect_gim, *login_gim;
global struct status_message* status_mess;
global struct MsgPort *status_control, *status_port;
global unsigned long darkpen, lightpen, textpen, fillpen;
global struct my_lock* orphaned_locks;
global unsigned short year;
global struct Locale* my_locale;
global struct Catalog* cat;
global unsigned char* volume_name;
#ifdef DECLARE_GLOBALS_HERE
unsigned char* ver = (unsigned char*)"$VER: FTPMount " VERSION "." REVISION " (2015-08-09)";
#endif