New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / workbench / libs / dummylib.c
blobe97c98a21e86c39e73abef91253e310466dc81da
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang:
7 */
8 #include <exec/types.h>
9 #include <exec/resident.h>
10 #include <proto/exec.h>
11 #include <aros/libcall.h>
12 #ifdef __GNUC__
13 # include "dummylib_gcc.h"
14 #endif
15 #include "initstruct.h"
16 #include <stddef.h>
18 struct inittable;
19 extern const char name[];
20 extern const char version[];
21 extern const APTR inittabl[4];
22 extern void *const functable[];
23 extern const struct inittable datatable;
24 extern struct dummybase *AROS_SLIB_ENTRY(init,dummy)();
25 extern struct dummybase *AROS_SLIB_ENTRY(open,dummy)();
26 extern BPTR AROS_SLIB_ENTRY(close,dummy)();
27 extern BPTR AROS_SLIB_ENTRY(expunge,dummy)();
28 extern int AROS_SLIB_ENTRY(null,dummy)();
29 extern ULONG AROS_SLIB_ENTRY(add,dummy)();
30 extern ULONG AROS_SLIB_ENTRY(asl,dummy)();
31 extern const char end;
33 int entry(void)
35 /* If the library was executed by accident return error code. */
36 return -1;
39 const struct Resident resident=
41 RTC_MATCHWORD,
42 (struct Resident *)&resident,
43 (APTR)&end,
44 RTF_AUTOINIT,
46 NT_LIBRARY,
48 (char *)name,
49 (char *)&version[6],
50 (ULONG *)inittabl
53 const char name[]="dummy.library";
55 const char version[]="$VER: dummylib 41.1 (28.3.96)\n\015";
57 const APTR inittabl[4]=
59 (APTR)sizeof(struct dummybase),
60 (APTR)functable,
61 (APTR)&datatable,
62 &AROS_SLIB_ENTRY(init,dummy)
65 void *const functable[]=
67 &AROS_SLIB_ENTRY(open,dummy),
68 &AROS_SLIB_ENTRY(close,dummy),
69 &AROS_SLIB_ENTRY(expunge,dummy),
70 &AROS_SLIB_ENTRY(null,dummy),
71 &AROS_SLIB_ENTRY(add,dummy),
72 &AROS_SLIB_ENTRY(asl,dummy),
73 (void *)-1
76 struct inittable
78 S_CPYO(1,1,B);
79 S_CPYO(2,1,L);
80 S_CPYO(3,1,B);
81 S_CPYO(4,1,W);
82 S_CPYO(5,1,W);
83 S_CPYO(6,1,L);
84 S_END (end);
87 #define O(n) offsetof(struct dummybase,n)
89 const struct inittable datatable=
91 { { I_CPYO(1,B,O(library.lib_Node.ln_Type)), { NT_LIBRARY } } },
92 { { I_CPYO(1,L,O(library.lib_Node.ln_Name)), { (IPTR)name } } },
93 { { I_CPYO(1,B,O(library.lib_Flags )), { LIBF_SUMUSED|LIBF_CHANGED } } },
94 { { I_CPYO(1,W,O(library.lib_Version )), { 1 } } },
95 { { I_CPYO(1,W,O(library.lib_Revision )), { 0 } } },
96 { { I_CPYO(1,L,O(library.lib_IdString )), { (IPTR)&version[6] } } },
97 I_END ()
100 #undef O
102 AROS_LH2(struct dummybase *, init,
103 AROS_LHA(struct dummybase *, dummybase, D0),
104 AROS_LHA(BPTR, segList, A0),
105 struct ExecBase *, SysBase, 0, dummy)
107 AROS_LIBFUNC_INIT
108 /* This function is single-threaded by exec by calling Forbid. */
110 /* Store arguments */
111 dummybase->sysbase=SysBase;
112 dummybase->seglist=segList;
114 /* You would return NULL here if the init failed. */
115 return dummybase;
116 AROS_LIBFUNC_EXIT
119 /* Use This from now on */
120 #ifdef SysBase
121 #undef SysBase
122 #endif
123 #define SysBase dummybase->sysbase
125 AROS_LH1(struct dummybase *, open,
126 AROS_LHA(ULONG, version, D0),
127 struct dummybase *, dummybase, 1, dummy)
129 AROS_LIBFUNC_INIT
131 This function is single-threaded by exec by calling Forbid.
132 If you break the Forbid() another task may enter this function
133 at the same time. Take care.
136 /* Keep compiler happy */
137 version=0;
139 /* I have one more opener. */
140 dummybase->library.lib_OpenCnt++;
141 dummybase->library.lib_Flags&=~LIBF_DELEXP;
143 /* You would return NULL if the open failed. */
144 return dummybase;
145 AROS_LIBFUNC_EXIT
148 AROS_LH0(BPTR, close, struct dummybase *, dummybase, 2, dummy)
150 AROS_LIBFUNC_INIT
152 This function is single-threaded by exec by calling Forbid.
153 If you break the Forbid() another task may enter this function
154 at the same time. Take care.
157 /* I have one fewer opener. */
158 if(!--dummybase->library.lib_OpenCnt)
160 /* Delayed expunge pending? */
161 if(dummybase->library.lib_Flags&LIBF_DELEXP)
162 /* Then expunge the library */
163 return expunge();
165 return 0;
166 AROS_LIBFUNC_EXIT
169 AROS_LH0(BPTR, expunge, struct dummybase *, dummybase, 3, dummy)
171 AROS_LIBFUNC_INIT
173 BPTR ret;
175 This function is single-threaded by exec by calling Forbid.
176 Never break the Forbid() or strange things might happen.
179 /* Test for openers. */
180 if(dummybase->library.lib_OpenCnt)
182 /* Set the delayed expunge flag and return. */
183 dummybase->library.lib_Flags|=LIBF_DELEXP;
184 return 0;
187 /* Get rid of the library. Remove it from the list. */
188 Remove(&dummybase->library.lib_Node);
190 /* Get returncode here - FreeMem() will destroy the field. */
191 ret=dummybase->seglist;
193 /* Free the memory. */
194 FreeMem((char *)dummybase-dummybase->library.lib_NegSize,
195 dummybase->library.lib_NegSize+dummybase->library.lib_PosSize);
197 return ret;
198 AROS_LIBFUNC_EXIT
200 AROS_LH0I(int, null, struct dummybase *, dummybase, 4, dummy)
202 AROS_LIBFUNC_INIT
203 return 0;
204 AROS_LIBFUNC_EXIT
207 AROS_LH2I(ULONG, add,
208 AROS_LHA(ULONG,a,D0),
209 AROS_LHA(ULONG,b,D1),
210 struct dummybase *,dummybase,5,dummy)
212 AROS_LIBFUNC_INIT
213 return a+b;
214 AROS_LIBFUNC_EXIT
217 AROS_LH2I(ULONG, asl,
218 AROS_LHA(ULONG,a,D0),
219 AROS_LHA(ULONG,b,D1),
220 struct dummybase *,dummybase,6,dummy)
222 AROS_LIBFUNC_INIT
223 return a<<b;
224 AROS_LIBFUNC_EXIT
227 const char end=0;