Initial revision
[ssr] / StraySrc / Libraries / DLLLib / h / dll
1 /*
2 * dll.h
3 *
4 * Definitions for DLLLib
5 *
6 * © 1994 Straylight
7 */
8
9 #ifndef __dll_h
10 #define __dll_h
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 /*----- External dependencies ---------------------------------------------*/
17
18 #ifndef __os_h
19 #include "os.h"
20 #endif
21
22 #ifndef __kernel_h
23 #include "kernel.h"
24 #endif
25
26 #ifndef __wimp_h
27 #include "wimp.h"
28 #endif
29
30 /*----- Type definitions for DLLs -----------------------------------------*/
31
32 typedef void *dll; /* What a DLL handle looks like */
33
34 typedef struct /* An external DLL table */
35 {
36 char *name; /* Name of DLL to load */
37 int version; /* Minimum acceptable version */
38 char *entryNames; /* Pointer to entry name table */
39 void *branchTable; /* Pointer to branch table to fill */
40 }
41 dll_table;
42
43 typedef struct /* A DLL information structure */
44 {
45 dll d; /* The handle of the DLL */
46 char *name; /* The DLL's textual name */
47 int version; /* The DLL's version number */
48 char *author; /* The name of the DLL's author */
49 unsigned instSize; /* Size of the DLL's instance vars */
50 }
51 dll_infostr;
52
53 /*----- Interface to DLLManager SWIs --------------------------------------*
54 *
55 * The sharper eyed amongst you may have noticed that DLL_Prologue doesn't
56 * have an entry point here. This is for several reasons:
57 *
58 * 1. It's not a very safe call to make if you don't know what you're doing.
59 * Then again, nor are any of the others.
60 *
61 * 2. It's not all that useful unless you're writing in assembler, in which
62 * case you can call the SWI directly.
63 *
64 * 3. Hopefully, the cdll program can generate all the code you'll ever need
65 * which calls DLL_Prologue, and you'll never need to mess about with it.
66 *
67 * Several of the calls listed here suffer badly from lack of usefulness.
68 * The only ones that you're really likely to want to use are dll_nameApp,
69 * dll_info and dll_findEntry.
70 */
71
72 os_error *dll_find(const char */*name*/, int /*version*/, dll */*d*/);
73 os_error *dll_findFromTable(const dll_table */*table*/, int /*entries*/);
74 os_error *dll_load(void */*buffer*/, const char */*name*/);
75 os_error *dll_lose(dll /*d*/);
76 os_error *dll_appDying(void);
77 os_error *dll_giveCLibData(void */*data*/);
78 os_error *dll_findCLibData(void **/*p*/);
79 os_error *dll_instanceVars(void */*buffer*/, int */*size*/, int */*magic*/);
80 os_error *dll_setInstanceVars(dll /*d*/, void */*workspace*/);
81 os_error *dll_appData(void);
82 os_error *dll_readStackPtr(int */*sp*/);
83 os_error *dll_setStackPtr(int /*sp*/);
84 os_error *dll_nameApp(const char */*name*/);
85 os_error *dll_info(dll /*d*/, dll_infostr */*i*/);
86 os_error *dll_findEntry(dll /*d*/, const char */*name*/,
87 void (**/*entry*/)());
88 os_error *dll_saveHandle(int */*handle*/);
89 os_error *dll_restoreHandle(int */*handle*/);
90 os_error *dll_findInstanceVars(dll /*d*/, void **/*addr*/);
91 os_error *dll_registerAppEntryTable(void (**/*btable*/)(), char */*names*/);
92 os_error *dll_findAppEntry(char */*name*/, void (**/*func*/)());
93 os_error *dll_setExtensionTable(void (**/*btable*/)(), char */*names*/);
94
95 /*----- Doing nothing at all, but without warnings! -----------------------*/
96
97 #define _dll_nothing ((void)(0))
98
99 /*----- Registration with DLLManager --------------------------------------*/
100
101 #ifndef _dll_NODLL
102
103 void _dll_appspace(void);
104 void _dll_clibdata(void);
105 #define _dll_setname(name) (void)dll_nameApp(name)
106
107 #else
108
109 #define _dll_appspace(x) _dll_nothing
110 #define _dll_clibdata(x) _dll_nothing
111 #define _dll_setname(name) _dll_nothing
112
113 #endif
114
115 /*----- Handling *commands ------------------------------------------------*/
116
117 #ifndef _dll_NODLL
118
119 int _dll_system(const char */*command*/);
120 int _dll_ksystem(const char */*command*/, int /*chain*/);
121 os_error *_dll_oscli(const char */*command*/);
122 os_error *_dll_starttask(const char */*command*/);
123
124 #else
125
126 #define _dll_system(x) system(x)
127 #define _dll_ksystem(x) _kernel_system(x)
128 #define _dll_oscli(x) os_cli(x)
129 #define _dll_starttask(x) wimp_starttask(x)
130
131 #endif
132
133 /*----- Handling of extension DLLs ----------------------------------------*/
134
135 dll _dll_loadExtension(const char */*name*/);
136 void _dll_freeExtension(dll /*d*/);
137
138 /*----- setjmp and longjmp support ----------------------------------------*/
139
140 #ifndef _dll_NODLL
141
142 int _dll_setjmp(void);
143 void _dll_longjmped(int /*sp*/);
144
145 #else
146
147 #define _dll_setjmp(x) (0)
148 #define _dll_longjmped(x) ((x)=(x))
149
150 #endif
151
152 /*----- Other miscellaneous calls -----------------------------------------*/
153
154 #ifndef _dll_NODLL
155
156 void _dll_giveMemory(void);
157
158 #else
159
160 #define _dll_giveMemory(x) _dll_nothing
161
162 #endif
163
164 /*----- External names for extentry functions -----------------------------*/
165
166 #ifdef _DLL
167
168 #define _dllEntry(name) _dllEntry_ ## name
169
170 #else
171
172 #define _dllEntry(name) name
173
174 #endif
175
176 #ifndef _dll_NODLL
177
178 #define _extEntry(name) _extEntry_ ## name
179 #define _dll_static
180
181 #else
182
183 #define _extEntry(name) name
184 #define _dll_static static
185
186 #endif
187
188 #ifdef __cplusplus
189 }
190 #endif
191
192 #endif