Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / reqtools / reqtoolsami_init.c
blob2a3d58855ae9882f67f5a85034a72c91fd15c407
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: AmigaOS specific ReqTools initialization code.
6 Lang: English.
7 */
9 /****************************************************************************************/
11 #include <exec/libraries.h>
12 #include <exec/resident.h>
13 #include <exec/execbase.h>
14 #include <exec/tasks.h>
15 #include <exec/memory.h>
16 #include <libraries/reqtools.h>
17 #include <intuition/classes.h>
18 #include <proto/exec.h>
20 #include "reqtools_intern.h"
21 #include "general.h"
22 #include "rtfuncs.h"
24 #define VERSION 39
25 #define REVISION 4
27 #define NAME_STRING "reqtools.library"
28 #define VERSION_STRING "$VER: reqtools 39.4 (17.01.2002)\r\n"
30 /****************************************************************************************/
32 extern const char name[];
33 extern const char version[];
34 extern const APTR inittable[4];
35 extern void *const functable[];
36 extern struct ReqToolsBase *libinit();
37 extern const char libend;
39 /****************************************************************************************/
41 int entry(void)
43 return -1;
46 /****************************************************************************************/
48 const struct Resident ROMTag =
50 RTC_MATCHWORD,
51 (struct Resident *)&ROMTag,
52 (APTR)&libend,
53 RTF_AUTOINIT,
54 VERSION,
55 NT_LIBRARY,
57 (char *)name,
58 (char *)&version[6],
59 (ULONG *)inittable
62 /****************************************************************************************/
64 const char name[] = NAME_STRING;
65 const char version[] = VERSION_STRING;
67 const APTR inittable[4] =
69 (APTR)sizeof(struct ReqToolsBase),
70 (APTR)functable,
71 NULL,
72 (APTR)&libinit
75 /****************************************************************************************/
77 #define __RT_DEFINEVARS
78 #include "globalvars.h"
79 #undef __RT_DEFINEVARS
81 /****************************************************************************************/
83 struct ReqToolsBase * SAVEDS ASM libinit(REGPARAM(d0, struct ReqToolsBase *, RTBase),
84 REGPARAM(a0, BPTR, segList))
86 ReqToolsBase = RTBase;
87 SysBase = *(struct ExecBase **)4L;
89 ReqToolsBase->LibNode.lib_Node.ln_Type = NT_LIBRARY;
90 ReqToolsBase->LibNode.lib_Node.ln_Name = (char *)name;
91 ReqToolsBase->LibNode.lib_Flags = LIBF_SUMUSED|LIBF_CHANGED;
92 ReqToolsBase->LibNode.lib_Version = VERSION;
93 ReqToolsBase->LibNode.lib_Revision = REVISION;
94 ReqToolsBase->LibNode.lib_IdString = (char *)&version[6];
96 return RTFuncs_Init(RTBase, segList);
99 /****************************************************************************************/
101 extern ULONG ASM SAVEDS GetString (REGPARAM(a1, UBYTE *, stringbuff),
102 REGPARAM(d0, LONG, maxlen),
103 REGPARAM(a2, char *, title),
104 REGPARAM(d1, ULONG, checksum),
105 REGPARAM(d2, ULONG *, value),
106 REGPARAM(d3, LONG, mode),
107 REGPARAM(d4, struct rtReqInfo *, reqinfo),
108 REGPARAM(a0, struct TagItem *, taglist));
111 /****************************************************************************************/
113 #ifdef USE_STACKSWAP
115 /****************************************************************************************/
117 #ifdef __AROS__
118 #error No StackSwap support for AROS yet
119 #endif
121 #ifndef __GNUC__
122 #error Only StackSwap support for GCC compiler for now
123 #endif
125 /****************************************************************************************/
127 struct MyStackSwapStruct
129 struct StackSwapStruct sss;
130 UBYTE *stringbuff;
131 LONG maxlen;
132 char *title;
133 ULONG checksum;
134 ULONG *value;
135 LONG mode;
136 struct rtReqInfo *reqinfo;
137 struct TagItem *taglist;
140 #ifndef MIN_STACK
141 #define MIN_STACK 4096
142 #endif
144 /****************************************************************************************/
146 static ULONG CheckStack_GetString(UBYTE *stringbuff,
147 LONG maxlen,
148 char *title,
149 ULONG checksum,
150 ULONG *value,
151 LONG mode,
152 struct rtReqInfo *reqinfo,
153 struct TagItem *taglist)
155 /* I could not manage to get correct code to be generated when
156 using asm("a7") or asm("sp") to access sp!? :-( */
158 #define sp ((IPTR)(&sss))
160 struct MyStackSwapStruct sss;
161 register struct MyStackSwapStruct *sssptr = &sss;
162 struct Task *me = FindTask(NULL);
163 register ULONG retval = 0;
165 if ((sp <= (IPTR)me->tc_SPLower) ||
166 (sp >= (IPTR)me->tc_SPUpper) ||
167 (sp - MIN_STACK < (IPTR)me->tc_SPLower))
169 sssptr->sss.stk_Lower = AllocVec(MIN_STACK, MEMF_PUBLIC);
170 if (sssptr->sss.stk_Lower)
172 sssptr->sss.stk_Upper = ((IPTR)sssptr->sss.stk_Lower) + MIN_STACK;
173 sssptr->sss.stk_Pointer = (APTR) sssptr->sss.stk_Upper;
175 sssptr->stringbuff = stringbuff;
176 sssptr->maxlen = maxlen;
177 sssptr->title = title;
178 sssptr->checksum = checksum;
179 sssptr->value = value;
180 sssptr->mode = mode;
181 sssptr->reqinfo = reqinfo;
182 sssptr->taglist = taglist;
184 StackSwap(&sssptr->sss);
186 retval = GetString(sssptr->stringbuff,
187 sssptr->maxlen,
188 sssptr->title,
189 sssptr->checksum,
190 sssptr->value,
191 sssptr->mode,
192 sssptr->reqinfo,
193 sssptr->taglist);
195 StackSwap(&sssptr->sss);
197 FreeVec(sssptr->sss.stk_Lower);
200 else
202 retval = GetString(stringbuff, maxlen, title, checksum, value, mode, reqinfo, taglist);
205 return retval;
208 /****************************************************************************************/
210 #define GETSTRING CheckStack_GetString
212 #else
214 #define GETSTRING GetString
216 /****************************************************************************************/
218 #endif /* USE_STACKSWAP */
220 /****************************************************************************************/
222 ULONG SAVEDS ASM librtEZRequestA(REGPARAM(a1, char *, bodyfmt),
223 REGPARAM(a2, char *, gadfmt),
224 REGPARAM(a3, struct rtReqInfo *, reqinfo),
225 REGPARAM(a4, APTR, argarray),
226 REGPARAM(a0, struct TagItem *, taglist))
228 return GETSTRING(bodyfmt,
229 (LONG)argarray,
230 gadfmt,
232 NULL,
233 IS_EZREQUEST,
234 reqinfo,
235 taglist);
238 /****************************************************************************************/
240 ULONG SAVEDS ASM librtGetStringA(REGPARAM(a1, UBYTE *, buffer),
241 REGPARAM(d0, ULONG, maxchars),
242 REGPARAM(a2, char *, title),
243 REGPARAM(a3, struct rtReqInfo *, reqinfo),
244 REGPARAM(a0, struct TagItem *, taglist))
246 return GETSTRING(buffer,
247 maxchars,
248 title,
250 NULL,
251 ENTER_STRING,
252 reqinfo,
253 taglist);
256 /****************************************************************************************/
258 ULONG SAVEDS ASM librtGetLongA(REGPARAM(a1, ULONG *, longptr),
259 REGPARAM(a2, char *, title),
260 REGPARAM(a3, struct rtReqInfo *, reqinfo),
261 REGPARAM(a0, struct TagItem *, taglist))
263 return GETSTRING(NULL,
265 title,
267 longptr,
268 ENTER_NUMBER,
269 reqinfo,
270 taglist);
273 /****************************************************************************************/
275 /* NOTE: Used by powerpacker.library/ppGetPassword() */
277 BOOL SAVEDS ASM librtInternalGetPasswordA(REGPARAM(a1, UBYTE *, buffer),
278 REGPARAM(d1, ULONG, checksum),
279 REGPARAM(d2, PWCALLBACKFUNPTR, pwcallback),
280 REGPARAM(a3, struct rtReqInfo *, reqinfo),
281 REGPARAM(a0, struct TagItem *, taglist))
283 buffer[0] = '\0';
285 return GETSTRING(buffer,
287 "Password",
288 checksum & 0xffff,
289 (ULONG *) pwcallback,
290 CHECK_PASSWORD,
291 reqinfo,
292 taglist);
295 /****************************************************************************************/
297 /* NOTE: Used by powerpacker.library/ppEnterPassword */
299 BOOL SAVEDS ASM librtInternalEnterPasswordA(REGPARAM(a1, UBYTE *, buffer),
300 REGPARAM(d2, PWCALLBACKFUNPTR, pwcallback),
301 REGPARAM(a3, struct rtReqInfo *, reqinfo),
302 REGPARAM(a0, struct TagItem *, taglist))
304 return GETSTRING(buffer,
306 "Password",
308 (ULONG *) pwcallback,
309 ENTER_PASSWORD,
310 reqinfo,
311 taglist);
314 /****************************************************************************************/
316 extern void libopen(void);
317 extern void libclose(void);
318 extern void libexpunge(void);
319 extern void libnull(void);
321 extern void AllocRequestA(void);
322 extern void FreeRequest(void);
323 extern void FreeReqBuffer(void);
324 extern void ChangeReqAttrA(void);
325 extern void FileRequestA(void);
326 extern void FreeFileList(void);
327 extern void PaletteRequestA(void);
328 extern void GetVScreenSize(void);
330 /****************************************************************************************/
332 void *const functable[]=
334 RTFuncs_Open,
335 RTFuncs_Close,
336 RTFuncs_Expunge,
337 RTFuncs_Null,
338 AllocRequestA,
339 FreeRequest,
340 FreeReqBuffer,
341 ChangeReqAttrA,
342 FileRequestA,
343 FreeFileList,
344 librtEZRequestA,
345 librtGetStringA,
346 librtGetLongA,
347 librtInternalGetPasswordA,
348 librtInternalEnterPasswordA,
349 FileRequestA,
350 PaletteRequestA,
351 RTFuncs_rtReqHandlerA,
352 RTFuncs_rtSetWaitPointer,
353 GetVScreenSize,
354 RTFuncs_rtSetReqPosition,
355 RTFuncs_rtSpread,
356 RTFuncs_ScreenToFrontSafely,
357 FileRequestA,
358 RTFuncs_CloseWindowSafely,
359 RTFuncs_rtLockWindow,
360 RTFuncs_rtUnlockWindow,
361 RTFuncs_LockPrefs,
362 RTFuncs_UnlockPrefs,
363 (void *)-1L
366 /****************************************************************************************/
368 const char libend = 0;
370 /****************************************************************************************/