1
|
/*! \file scol_plugin_win.h
|
2
|
* \brief Scol plugin definition API (MS Windows)
|
3
|
* \author Sylvain HUET
|
4
|
*/
|
5
|
|
6
|
/*
|
7
|
// Modifications History
|
8
|
//
|
9
|
//$ LB (13/06/2002) : added the OBJgetNewHandler function to the cbmachine
|
10
|
// $ IRI (19/12/2010) : version windows
|
11
|
// $ IRI (31/01/2011) : add MMneedMemory
|
12
|
*/
|
13
|
|
14
|
#ifdef __cplusplus
|
15
|
extern "C" {
|
16
|
#endif
|
17
|
|
18
|
#ifndef SCOLPLUGIN_H
|
19
|
#define SCOLPLUGIN_H
|
20
|
|
21
|
#include <windows.h>
|
22
|
|
23
|
#include <stdio.h>
|
24
|
#include <stdlib.h>
|
25
|
|
26
|
|
27
|
/* DEFINITIONS DE TYPES ET DE CONSTANTES
|
28
|
---------------------------------------*/
|
29
|
#define SizeWord 4
|
30
|
#define SizeHeader 3
|
31
|
|
32
|
#define NIL -1
|
33
|
|
34
|
/* Scol virtual machine */
|
35
|
struct Mmachine
|
36
|
{
|
37
|
int *tape; /* tape pointer */
|
38
|
int sizetape; /* size of the tape */
|
39
|
int pp; /* stack pointer */
|
40
|
int maxpp; /* max value of pp */
|
41
|
int topheap; /* top of stack */
|
42
|
int sigGC; /* GC activation distance */
|
43
|
int h; /* current header position */
|
44
|
int err;
|
45
|
int *top; /* top of tape */
|
46
|
/*$BLG - v5.22: Add*/
|
47
|
int lckdGC; /* Locked GC flag*/
|
48
|
};
|
49
|
|
50
|
typedef struct Mmachine *mmachine;
|
51
|
|
52
|
/* masq for MMmalloc : object table or other buffer */
|
53
|
#define TYPETAB 1
|
54
|
#define TYPEBUF 0
|
55
|
|
56
|
/* errors definition */
|
57
|
#define MERREND 1
|
58
|
#define MERROK 0
|
59
|
#define MERRMEM -1
|
60
|
#define MERRTYP -2
|
61
|
#define MERRRET -3
|
62
|
#define MERRNUL -4
|
63
|
#define MERRNF -5
|
64
|
#define MERRLINK -6
|
65
|
#define MERRFULL -7
|
66
|
#define MERRUNKNOWN -8
|
67
|
#define MERRTOOLARGE -9
|
68
|
#define MERREP -10
|
69
|
#define MERRFILE -11
|
70
|
#define MERRCLOSE -12
|
71
|
/*$BLG - v5.22: Add*/
|
72
|
#define MERRCHNLDWN -13
|
73
|
|
74
|
/* offsets object definition */
|
75
|
#define OFFSCCUR 0
|
76
|
|
77
|
#define OFFOBJMAG 0
|
78
|
#define OFFOBJCHN 1
|
79
|
#define OFFOBJTYP 2
|
80
|
#define OFFOBJHAND 3
|
81
|
#define OFFOBJTPERE 4
|
82
|
#define OFFOBJHPERE 5
|
83
|
#define OFFOBJREF0 6
|
84
|
#define OFFOBJUSER0 7
|
85
|
|
86
|
/* console messages mask definition */
|
87
|
#define MSKFOO 1
|
88
|
#define MSKRUNTIME 2
|
89
|
#define MSKWARNING 4
|
90
|
#define MSKTRACE 8
|
91
|
#define MSKDEBUG 16
|
92
|
|
93
|
|
94
|
/* predefined Scol types */
|
95
|
#define TYPVAR -1
|
96
|
#define TYPCONS -2
|
97
|
#define TYPTYPE -3
|
98
|
#define TYPFIELD -4
|
99
|
#define TYPSTRUC -5
|
100
|
#define TYPCONS0 -6
|
101
|
#define TYPCOM -7
|
102
|
#define TYPCOMV -8
|
103
|
|
104
|
|
105
|
/* Files management in Scol
|
106
|
------------------------------*/
|
107
|
|
108
|
#define SIZESIGN 1024
|
109
|
|
110
|
struct Packdir
|
111
|
{
|
112
|
char path[SIZESIGN]; /* end by '/'*/
|
113
|
int quota; /* -1: read only, 0: unlimited*/
|
114
|
struct Packdir *next;
|
115
|
};
|
116
|
typedef struct Packdir *packdir;
|
117
|
|
118
|
#define TYPESNONE 0
|
119
|
#define TYPESLOGIC 1
|
120
|
|
121
|
|
122
|
/*
|
123
|
* Exported Kernel functions to plugin
|
124
|
----------------------------------------------*/
|
125
|
|
126
|
struct CBmachine
|
127
|
{
|
128
|
int (*MMpush)(mmachine m, int val);
|
129
|
int (*MMpushNoGC)(mmachine m, int val);
|
130
|
int (*MMpull)(mmachine m);
|
131
|
int (*MMgetPP)(mmachine m);
|
132
|
void (*MMsetPP)(mmachine m,int i);
|
133
|
int (*MMget)(mmachine m,int i);
|
134
|
void (*MMset)(mmachine m,int i,int v);
|
135
|
int (*MMgetglobal)(mmachine m,int i);
|
136
|
void (*MMsetglobal)(mmachine m,int i,int v);
|
137
|
int (*MMgetbase)(mmachine m,int b,int i);
|
138
|
void (*MMsetbase)(mmachine m,int b,int i,int v);
|
139
|
int (*MMfetch)(mmachine m,int s,int i);
|
140
|
void (*MMstore)(mmachine m,int s,int i,int v);
|
141
|
int* (*MMstart)(mmachine m,int s);
|
142
|
int (*MMsize)(mmachine m,int s);
|
143
|
int (*MMtype)(mmachine m,int s);
|
144
|
char* (*MMstartstr)(mmachine m,int s);
|
145
|
int (*MMsizestr)(mmachine m,int s);
|
146
|
void (*MMsetsizestr)(mmachine m,int s,int size);
|
147
|
int (*MMmalloc)(mmachine m, int size, int type);
|
148
|
int (*MMmallocCLR)(mmachine m, int size, int type);
|
149
|
int (*Mpushstrbloc)(mmachine m,char *buf);
|
150
|
int (*MBdeftab)(mmachine m);
|
151
|
int (*MBstrcat)(mmachine m);
|
152
|
int (*PKhardpak)(mmachine m, char *name,
|
153
|
int n, char **namefun, int (**fun)(mmachine z),
|
154
|
int *nargfun, char **typfun);
|
155
|
int (*PKloader)(mmachine m,char *name,char *simplename);
|
156
|
int (*SPfindfile)(packdir p,char *sign,int *size,char *path);
|
157
|
int (*SPaddfile)(packdir p,char *sign,int size,char *path);
|
158
|
int (*SCgetsrvsocket)(mmachine m, int server);
|
159
|
int (*SCgetsocket)(mmachine m, int channel);
|
160
|
int (*Mcutting)(char *comm, char **argv);
|
161
|
void (*MMechostr)(int i,char *buf,...);
|
162
|
size_t (*fread)(void* buf,size_t i,size_t j,FILE *f);
|
163
|
packdir Firstpack;
|
164
|
int (*OBJcreate)(mmachine m,int typ,int handsys,int typpere,int handsyspere);
|
165
|
int (*OBJaddreflex)(mmachine m,int typ, int num);
|
166
|
int (*OBJbeginreflex)(mmachine m,int typ,int handsys,int num);
|
167
|
int (*OBJdel)(mmachine m,int p,int flag);
|
168
|
int (*OBJdestroy)(mmachine m, int typ,int handsys,int objm,int flag);
|
169
|
int (*OBJdelTH)(mmachine m,int typ,int handsys);
|
170
|
int (*OBJcallreflex)(mmachine m,int nbarg);
|
171
|
int (*OBJregister)(int nbrefl,int recrefl,int (*destroy)(mmachine m,int handsys,int objm),char *name);
|
172
|
int (*OBJtypebyname)(char *name);
|
173
|
int (*OBJdefEvent)(int event,int (*cbevent)(mmachine m,int hwnd, unsigned msg,
|
174
|
int wParam,int lParam,int *ret));
|
175
|
int (*OBJgetUserEvent)();
|
176
|
void* (*SCgetExtra)(char *funcname);
|
177
|
char* (*stdloadJpg)(char *name,int *w,int *h);
|
178
|
int (*OBJdelTM)(mmachine m,int typ,int q);
|
179
|
int (*OBJfindTH)(mmachine m,int typ,int handsys);
|
180
|
int (*OBJfindTM)(mmachine m,int typ,int objm);
|
181
|
int (*Mpushstrblocn)(mmachine m,char *buf, int n);
|
182
|
int (*Minterpreter)(mmachine m);
|
183
|
int (*Msearchinsyspak)(mmachine m, char *name);
|
184
|
int (*MBstrcatn)(mmachine m);
|
185
|
int (*Buffer2texture)(mmachine m, char *buffer, int width, int height);
|
186
|
void (*MMputs)(int i, const char* text);
|
187
|
|
188
|
/*$ LB (13/06/2002)*/
|
189
|
int (*OBJgetNewHandler)();
|
190
|
|
191
|
int (*MMneedMemory)(mmachine m,int size,int realsize); /* $Iri */
|
192
|
|
193
|
|
194
|
};
|
195
|
typedef struct CBmachine *cbmachine;
|
196
|
|
197
|
extern cbmachine ww;
|
198
|
|
199
|
#define SCOLinitplugin(X) ww=X
|
200
|
|
201
|
#define MMpush (ww->MMpush)
|
202
|
#define MMpushNoGC (ww->MMpushNoGC)
|
203
|
#define MMpull (ww->MMpull)
|
204
|
#define MMgetPP (ww->MMgetPP)
|
205
|
#define MMsetPP (ww->MMsetPP)
|
206
|
#define MMget (ww->MMget)
|
207
|
#define MMset (ww->MMset)
|
208
|
#define MMgetglobal (ww->MMgetglobal)
|
209
|
#define MMsetglobal (ww->MMsetglobal)
|
210
|
#define MMgetbase (ww->MMgetbase)
|
211
|
#define MMsetbase (ww->MMsetbase)
|
212
|
#define MMfetch (ww->MMfetch)
|
213
|
#define MMstore (ww->MMstore)
|
214
|
#define MMstart (ww->MMstart)
|
215
|
#define MMsize (ww->MMsize)
|
216
|
#define MMtype (ww->MMtype)
|
217
|
#define MMstartstr (ww->MMstartstr)
|
218
|
#define MMsizestr (ww->MMsizestr)
|
219
|
#define MMsetsizestr (ww->MMsetsizestr)
|
220
|
#define MMmalloc (ww->MMmalloc)
|
221
|
#define MMmallocCLR (ww->MMmallocCLR)
|
222
|
#define Mpushstrbloc (ww->Mpushstrbloc)
|
223
|
#define MBdeftab (ww->MBdeftab)
|
224
|
#define MBstrcat (ww->MBstrcat)
|
225
|
#define PKhardpak (ww->PKhardpak)
|
226
|
#define PKloader (ww->PKloader)
|
227
|
#define SPfindfile (ww->SPfindfile)
|
228
|
#define SPaddfile (ww->SPaddfile)
|
229
|
#define SCgetsrvsocket (ww->SCgetsrvsocket)
|
230
|
#define SCgetsocket (ww->SCgetsocket)
|
231
|
#define Mcutting (ww->Mcutting)
|
232
|
#define MMechostr (ww->MMechostr)
|
233
|
/*#define fread (ww->fread)*/
|
234
|
#define Firstpack (ww->Firstpack)
|
235
|
#define OBJcreate (ww->OBJcreate)
|
236
|
#define OBJaddreflex (ww->OBJaddreflex)
|
237
|
#define OBJbeginreflex (ww->OBJbeginreflex)
|
238
|
#define OBJdel (ww->OBJdel)
|
239
|
#define OBJdestroy (ww->OBJdestroy)
|
240
|
#define OBJdelTH (ww->OBJdelTH)
|
241
|
#define OBJcallreflex (ww->OBJcallreflex)
|
242
|
#define OBJregister (ww->OBJregister)
|
243
|
#define OBJtypebyname (ww->OBJtypebyname)
|
244
|
#define OBJdefEvent (ww->OBJdefEvent)
|
245
|
#define OBJgetUserEvent (ww->OBJgetUserEvent)
|
246
|
#define SCgetExtra (ww->SCgetExtra)
|
247
|
#define stdloadJpg (ww->stdloadJpg)
|
248
|
#define OBJdelTM (ww->OBJdelTM)
|
249
|
#define OBJfindTH (ww->OBJfindTH)
|
250
|
#define OBJfindTM (ww->OBJfindTM)
|
251
|
#define Mpushstrblocn (ww->Mpushstrblocn)
|
252
|
#define Minterpreter (ww->Minterpreter)
|
253
|
#define Msearchinsyspak (ww->Msearchinsyspak)
|
254
|
#define MBstrcatn (ww->MBstrcatn)
|
255
|
#define Buf2Tex (ww->Buffer2texture)
|
256
|
#define MMputs (ww->MMputs)
|
257
|
|
258
|
/*$ LB (13/06/2002)*/
|
259
|
#define OBJgetNewHandler (ww->OBJgetNewHandler)
|
260
|
|
261
|
#define MMneedMemory (ww->MMneedMemory) /* $Iri */
|
262
|
|
263
|
|
264
|
#endif
|
265
|
|