Metatarget for copying of testfile fixed.
[AROS.git] / workbench / libs / muimaster / zunemaster_lib.c
blobe9dfd0b1ee20412996f1501e0ad0676fe1a9c870
1 /*
2 Copyright © 2002, The AROS Development Team.
3 All rights reserved.
5 $Id$
7 Library code for AmigaOS, based on Dirk Stöckers Libary
8 Example
9 */
11 #define BASE_GLOBAL
13 #include <proto/exec.h>
14 #include <exec/resident.h>
15 #include <exec/initializers.h>
16 #include <intuition/intuitionbase.h>
17 #include <exec/execbase.h>
19 struct ExecBase *SysBase;
21 LONG ReturnError2(void)
23 return -1;
26 #include "muimaster_intern.h"
28 #define VERSION 1
29 #define REVISION 0
30 #define DATETXT "27.06.2003"
31 #define VERSTXT "1.0"
33 #define LIBNAME "zunemaster.library"
34 #define IDSTRING "zunemaster.library " VERSTXT " (" DATETXT ")\r\n"
36 #define MYDEBUG 1
37 #include "debug.h"
39 typedef BPTR SEGLISTPTR;
40 #define LC_LIBHEADERTYPEPTR struct Library *
42 /************************************************************************/
44 /* First executable routine of this library; must return an error
45 to the unsuspecting caller */
46 LONG ReturnError(void)
48 return -1;
51 /************************************************************************/
53 /* MUI private functions */
55 __asm void MUI_Priv1(register __a6 struct Library *MUIMasterBase)
57 D(bug("MUI_Priv1() called"));
60 __asm void MUI_Priv2(register __a6 struct Library *MUIMasterBase)
62 D(bug("MUI_Priv2() called"));
65 __asm void MUI_Priv3(register __a6 struct Library *MUIMasterBase)
67 D(bug("MUI_Priv3() called"));
70 __asm void MUI_Priv4(register __a6 struct Library *MUIMasterBase)
72 D(bug("MUI_Priv4() called"));
75 /************************************************************************/
77 /* Some functions which are somewhere else */
79 ULONG SAVEDS STDARGS LC_BUILDNAME(L_InitLib) (LC_LIBHEADERTYPEPTR MUIMasterBase);
80 ULONG SAVEDS STDARGS LC_BUILDNAME(L_OpenLib) (LC_LIBHEADERTYPEPTR MUIMasterBase);
81 void SAVEDS STDARGS LC_BUILDNAME(L_CloseLib) (LC_LIBHEADERTYPEPTR MUIMasterBase);
82 void SAVEDS STDARGS LC_BUILDNAME(L_ExpungeLib) (LC_LIBHEADERTYPEPTR MUIMasterBase);
84 /************************************************************************/
86 struct LibInitData {
87 UBYTE i_Type; UBYTE o_Type; UBYTE d_Type; UBYTE p_Type;
88 UBYTE i_Name; UBYTE o_Name; STRPTR d_Name;
89 UBYTE i_Flags; UBYTE o_Flags; UBYTE d_Flags; UBYTE p_Flags;
90 UBYTE i_Version; UBYTE o_Version; UWORD d_Version;
91 UBYTE i_Revision; UBYTE o_Revision; UWORD d_Revision;
92 UBYTE i_IdString; UBYTE o_IdString; STRPTR d_IdString;
93 ULONG endmark;
96 /************************************************************************/
97 extern const ULONG LibInitTable[4]; /* the prototype */
99 /* The library loader looks for this marker in the memory
100 the library code and data will occupy. It is responsible
101 setting up the Library base data structure. */
102 const struct Resident RomTag = {
103 RTC_MATCHWORD, /* Marker value. */
104 (struct Resident *)&RomTag, /* This points back to itself. */
105 (struct Resident *)LibInitTable, /* This points somewhere behind this marker. */
106 RTF_AUTOINIT, /* The Library should be set up according to the given table. */
107 VERSION, /* The version of this Library. */
108 NT_LIBRARY, /* This defines this module as a Library. */
109 0, /* Initialization priority of this Library; unused. */
110 LIBNAME, /* Points to the name of the Library. */
111 IDSTRING, /* The identification string of this Library. */
112 (APTR)&LibInitTable /* This table is for initializing the Library. */
115 /************************************************************************/
117 /* The mandatory reserved library function */
118 ULONG LibReserved(void)
120 return 0;
123 /* Open the library, as called via OpenLibrary() */
124 ASM struct Library *LibOpen(REG(a6, struct MUIMasterBase_intern * MUIMasterBase))
126 /* Prevent delayed expunge and increment opencnt */
127 MUIMasterBase->library.lib_Flags &= ~LIBF_DELEXP;
128 MUIMasterBase->library.lib_OpenCnt++;
130 return &MUIMasterBase->library;
133 /* Expunge the library, remove it from memory */
134 ASM SEGLISTPTR LibExpunge(REG(a6, struct MUIMasterBase_intern *mb))
136 if (!mb->library.lib_OpenCnt)
138 SEGLISTPTR seglist;
140 seglist = mb->seglist;
142 L_ExpungeLib(&mb->library);
144 /* Remove the library from the public list */
145 Remove((struct Node *)mb);
147 /* Free the vector table and the library data */
148 FreeMem((STRPTR) mb - mb->library.lib_NegSize,
149 mb->library.lib_NegSize +
150 mb->library.lib_PosSize);
152 return seglist;
154 else
155 mb->library.lib_Flags |= LIBF_DELEXP;
157 /* Return the segment pointer, if any */
158 return 0;
161 /* Close the library, as called by CloseLibrary() */
162 ASM SEGLISTPTR LibClose(REG(a6, struct MUIMasterBase_intern *mb))
164 if(!(--mb->library.lib_OpenCnt))
166 if (mb->library.lib_Flags & LIBF_DELEXP)
167 return LibExpunge(mb);
169 return 0;
172 #undef SysBase
173 extern struct ExecBase *SysBase;
175 /* Initialize library */
176 ASM struct Library *LibInit(REG(a0, SEGLISTPTR seglist), REG(d0, struct MUIMasterBase_intern *mb), REG(a6, struct ExecBase *sysbase))
178 #ifdef _M68060
179 if(!(sysbase->AttnFlags & AFF_68060))
180 return 0;
181 #elif defined (_M68040)
182 if(!(sysbase->AttnFlags & AFF_68040))
183 return 0;
184 #elif defined (_M68030)
185 if(!(sysbase->AttnFlags & AFF_68030))
186 return 0;
187 #elif defined (_M68020)
188 if(!(sysbase->AttnFlags & AFF_68020))
189 return 0;
190 #endif
192 /* Remember stuff */
193 mb->seglist = seglist;
195 /* Fill some globals */
196 // MUIMasterBase = (struct Library *)mb;
197 mb->sysbase = sysbase;
198 SysBase = sysbase;
200 D(bug("Librarybase at 0x%lx\n",mb));
202 if (L_InitLib(&mb->library))
203 return &mb->library;
205 /* Free the vector table and the library data */
206 FreeMem((STRPTR)mb - mb->library.lib_NegSize,
207 mb->library.lib_NegSize +
208 mb->library.lib_PosSize);
209 return 0;
212 /************************************************************************/
213 /* This is the table of functions that make up the library. The first
214 four are mandatory, everything following it are user callable
215 routines. The table is terminated by the value -1. */
217 static const APTR LibVectors[] = {
218 (APTR) LibOpen,
219 (APTR) LibClose,
220 (APTR) LibExpunge,
221 (APTR) LibReserved,
222 (APTR) MUI_NewObjectA,
223 (APTR) MUI_DisposeObject,
224 (APTR) MUI_RequestA,
225 (APTR) MUI_AllocAslRequest,
226 (APTR) MUI_AslRequest,
227 (APTR) MUI_FreeAslRequest,
228 (APTR) MUI_Error,
229 (APTR) MUI_SetError,
230 (APTR) MUI_GetClass,
231 (APTR) MUI_FreeClass,
232 (APTR) MUI_RequestIDCMP,
233 (APTR) MUI_RejectIDCMP,
234 (APTR) MUI_Redraw,
235 (APTR) MUI_CreateCustomClass,
236 (APTR) MUI_DeleteCustomClass,
237 (APTR) MUI_MakeObjectA,
238 (APTR) MUI_Layout,
239 (APTR) MUI_Priv1,
240 (APTR) MUI_Priv2,
241 (APTR) MUI_Priv3,
242 (APTR) MUI_Priv4,
243 (APTR) MUI_ObtainPen,
244 (APTR) MUI_ReleasePen,
245 (APTR) MUI_AddClipping,
246 (APTR) MUI_RemoveClipping,
247 (APTR) MUI_AddClipRegion,
248 (APTR) MUI_RemoveClipRegion,
249 (APTR) MUI_BeginRefresh,
250 (APTR) MUI_EndRefresh,
251 (APTR) -1
254 static const struct LibInitData LibInitData = {
255 #ifdef __VBCC__ /* VBCC does not like OFFSET macro */
256 0xA0, 8, NT_LIBRARY, 0,
257 0x80, 10, LIBNAME,
258 0xA0, 14, LIBF_SUMUSED|LIBF_CHANGED, 0,
259 0x90, 20, VERSION,
260 0x90, 22, REVISION,
261 0x80, 24, IDSTRING,
262 #else
263 0xA0, (UBYTE) OFFSET(Node, ln_Type), NT_LIBRARY, 0,
264 0x80, (UBYTE) OFFSET(Node, ln_Name), LIBNAME,
265 0xA0, (UBYTE) OFFSET(Library, lib_Flags), LIBF_SUMUSED|LIBF_CHANGED, 0,
266 0x90, (UBYTE) OFFSET(Library, lib_Version), VERSION,
267 0x90, (UBYTE) OFFSET(Library, lib_Revision), REVISION,
268 0x80, (UBYTE) OFFSET(Library, lib_IdString), IDSTRING,
269 #endif
273 /* The following data structures and data are responsible for
274 setting up the Library base data structure and the library
275 function vector.
277 const ULONG LibInitTable[4] = {
278 (ULONG)sizeof(struct MUIMasterBase_intern), /* Size of the base data structure */
279 (ULONG)LibVectors, /* Points to the function vector */
280 (ULONG)&LibInitData, /* Library base data structure setup table */
281 (ULONG)LibInit /* The address of the routine to do the setup */
284 void _CXFERR(void)
286 D(bug("CFXERR\n"));