2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: AmigaOS specific ReqTools initialization code.
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"
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 /****************************************************************************************/
46 /****************************************************************************************/
48 const struct Resident ROMTag
=
51 (struct Resident
*)&ROMTag
,
62 /****************************************************************************************/
64 const char name
[] = NAME_STRING
;
65 const char version
[] = VERSION_STRING
;
67 const APTR inittable
[4] =
69 (APTR
)sizeof(struct ReqToolsBase
),
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 /****************************************************************************************/
115 /****************************************************************************************/
118 #error No StackSwap support for AROS yet
122 #error Only StackSwap support for GCC compiler for now
125 /****************************************************************************************/
127 struct MyStackSwapStruct
129 struct StackSwapStruct sss
;
136 struct rtReqInfo
*reqinfo
;
137 struct TagItem
*taglist
;
141 #define MIN_STACK 4096
144 /****************************************************************************************/
146 static ULONG
CheckStack_GetString(UBYTE
*stringbuff
,
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
;
181 sssptr
->reqinfo
= reqinfo
;
182 sssptr
->taglist
= taglist
;
184 StackSwap(&sssptr
->sss
);
186 retval
= GetString(sssptr
->stringbuff
,
195 StackSwap(&sssptr
->sss
);
197 FreeVec(sssptr
->sss
.stk_Lower
);
202 retval
= GetString(stringbuff
, maxlen
, title
, checksum
, value
, mode
, reqinfo
, taglist
);
208 /****************************************************************************************/
210 #define GETSTRING CheckStack_GetString
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
,
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
,
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
,
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
))
285 return GETSTRING(buffer
,
289 (ULONG
*) pwcallback
,
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
,
308 (ULONG
*) pwcallback
,
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
[]=
347 librtInternalGetPasswordA
,
348 librtInternalEnterPasswordA
,
351 RTFuncs_rtReqHandlerA
,
352 RTFuncs_rtSetWaitPointer
,
354 RTFuncs_rtSetReqPosition
,
356 RTFuncs_ScreenToFrontSafely
,
358 RTFuncs_CloseWindowSafely
,
359 RTFuncs_rtLockWindow
,
360 RTFuncs_rtUnlockWindow
,
366 /****************************************************************************************/
368 const char libend
= 0;
370 /****************************************************************************************/