2 * Generic Call Interface for Rexx
3 * Copyright © 2003-2004, Florian Große-Coosmann
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 * ----------------------------------------------------------------------------
21 * This file contains types, constants and prototypes which are global to the
22 * GCI system and may be used to invoke the GCI.
25 #ifndef incl_LINK_FUNCS_ONLY
29 * GCI_result is either GCI_OK for success or a more or less understandable
34 GCI_NoMemory
, /* out of memory while processing */
35 GCI_WrongInput
, /* unexpected input, either unknown type (e.g. FIXED)
36 or illegal data (e.g. 0xFF as an integer). */
37 GCI_NumberRange
, /* Number doesn't fit in the allowed range.. */
38 GCI_StringRange
, /* String too big for the defined buffer. */
39 GCI_UnsupportedType
, /* Illegal combination of type/size, e.g. INTEGER3 */
40 GCI_UnsupportedNumber
, /* nan, inf, etc */
41 GCI_BufferTooSmall
, /* Internal error: insufficent buffer size. The */
42 /* structure is too complex. */
43 GCI_MissingName
, /* A name in the structure is missing. */
44 GCI_MissingValue
, /* A value in the structure is missing. */
45 GCI_IllegalName
, /* The name or part of a name is illegal for the */
47 GCI_RexxError
, /* Problems communicating with the interpreter. */
48 /* NEVER FORGET TO EXTEND gci_helper.c:GCI_describe*/
49 GCI_NoBaseType
, /* The type won't fit the requirements for basic */
51 GCI_InternalError
, /* Internal, unknown problems */
52 GCI_FunctionAlreadyKnown
, /* New name already registered to Rexx */
53 GCI_LibraryNotFound
, /* The given external library can't be loaded */
54 GCI_NoLibraryFunction
, /* The given external function can't be found in */
56 GCI_FunctionNotFound
, /* The name was not registered in the Rexx core */
57 GCI_SyntaxError
, /* The number of arguments is wrong */
58 GCI_CoreConfused
, /* The core of GCI can't determine how to invoke */
59 /* generic functions */
60 GCI_ArgStackOverflow
, /* GCI's internal stack for arguments got an */
62 GCI_NestingOverflow
, /* GCI counted too many nested LIKE containers */
63 GCI_LastResult
/* currently not used. */
67 * GCI understands some basic types of which it builds more complex type
68 * structures. The basic types are listed here, although we need some extra
69 * types while parsing the name; these have negative values.
86 * GCI enumerates all basic types while parsing the type tree. Each leaf or
87 * branch has an info node for the type.
91 unsigned indirect
; /* flag "indirect" */
92 unsigned size
; /* bytes or # of elements (array, container) */
93 unsigned generated
; /* generated indirection for arrays */
97 * GCI knows several basic call types.
98 * cdecl: arguments pushed in order right to left, stack cleanup by caller
99 * stdcall: arguments pushed in order right to left, stack cleanup by callee
100 * pascal: arguments pushed in order left to right, stack cleanup by callee
110 * GCI has a structure for the call type.
114 unsigned as_function
; /* flag "as function" */
115 unsigned with_parameters
; /* flag "as parameters" */
119 * GCI_nodeinfo provides all informations needed for one branch or leaf in the
120 * type information tree.
124 int parent
; /* index of the parent's node or -1 */
125 int child
; /* index of the first child or -1 */
126 int sibling
; /* next if same depth with same parent */
127 unsigned direct_size
; /* size in bytes of this and all children */
128 unsigned indirect_size
; /* as direct_size, but for INDIRECT children */
129 unsigned direct_pos
; /* pos in buffer of this node */
130 unsigned indirect_pos
; /* as direct_pos, but for INDIRECT children */
134 * GCI_treeinfo provides all informations needed for all arguments and the
135 * return value for one call.
138 GCI_callinfo callinfo
;
140 int used
; /* used elements of nodes */
141 int max
; /* current maximum of elements of nodes */
142 int args
[GCI_REXX_ARGS
]; /* ??? arguments' starting index or -1 */
143 int retval
; /* return value's starting index or -1 */
144 unsigned size
; /* size in bytes of all args */
148 * STEMDEPTH is the amount of space which will be allocated additionally to
149 * a stem's string length for iterative access. We shall support roughly
150 * a depth of 100 elements, most of a short depth. Don't forgetting the
151 * separating dot we have about 250 chars.
153 #define STEMDEPTH 250
155 #define elements(array) ( sizeof( array ) / sizeof( (array)[0] ) )
160 GCI_result
GCI_string2bin( void *hidden
,
166 GCI_result
GCI_bin2string( void *hidden
,
172 GCI_result
GCI_validate( int size
,
179 int GCI_strlen( const GCI_str
*str
);
180 int GCI_strmax( const GCI_str
*str
);
181 char * GCI_content( GCI_str
*str
);
182 const char * GCI_ccontent( const GCI_str
*str
);
183 int GCI_streq( const GCI_str
*s1
,
185 GCI_result
GCI_strcat( GCI_str
*first
,
186 const GCI_str
*second
);
187 GCI_result
GCI_strcats( GCI_str
*first
,
188 const char *second
);
189 void GCI_strsetlen( GCI_str
*str
,
191 GCI_result
GCI_strcpy( GCI_str
*first
,
192 const GCI_str
*second
);
193 GCI_str
*GCI_strfromascii( GCI_str
*str
,
196 const GCI_str
*GCI_migratefromascii( GCI_str
*str
,
198 GCI_result
GCI_stralloc( void *hidden
,
201 void GCI_strfree( void *hidden
,
203 GCI_result
GCI_strdup( void *hidden
,
205 const GCI_str
*second
);
206 char *GCI_strtoascii( void *hidden
,
207 const GCI_str
*str
);
208 void GCI_uppercase( void *hidden
,
210 void GCI_describe( GCI_str
*description
,
212 void GCI_strswap( GCI_str
*first
,
218 GCI_result
GCI_parsenodes( void *hidden
,
222 unsigned return_valid
,
223 const char *prefixChar
);
228 GCI_result
GCI_readRexx( void *hidden
,
234 GCI_result
GCI_readNewRexx( void *hidden
,
240 GCI_result
GCI_writeRexx( void *hidden
,
242 const GCI_str
*value
,
243 int symbolicAccess
);
244 GCI_result
GCI_RegisterDefinedFunction( void *hidden
,
245 const GCI_str
*internal
,
246 const GCI_str
*library
,
247 const GCI_str
*external
,
248 const GCI_treeinfo
*ti
);
249 void GCI_remove_structure( void *hidden
,
250 GCI_treeinfo
*gci_info
);
255 GCI_result
GCI_ParseTree( void *hidden
,
257 GCI_treeinfo
*gci_info
,
258 GCI_str
*error_disposition
,
259 const char *prefixChar
);
260 GCI_result
GCI_RxFuncDefine( void *hidden
,
261 const GCI_str
*internal
,
262 const GCI_str
*library
,
263 const GCI_str
*external
,
265 GCI_str
*error_disposition
,
266 const char *prefixChar
);
271 GCI_result
GCI_parsetree( void *hidden
,
273 GCI_result (*callback
)(int depth
,
276 const GCI_parseinfo
*info
),
278 const char *prefixChar
);
283 GCI_result
GCI_execute( void *hidden
,
285 const GCI_treeinfo
*ti
,
288 GCI_str
*error_disposition
,
290 const char *prefixChar
);
295 GCI_result
GCI_call( void *hidden
,
297 const GCI_treeinfo
*ti
,
300 #endif /* incl_LINK_FUNCS_ONLY */
303 * gci_oslink.c (not used for a GCI which is embedded in a true interpreter)
305 void *GCI_getLibrary( const char *libname
, int libnamelen
, char *buf
);
306 void GCI_freeLibrary( void *handle
);
307 void ( *GCI_getEntryPoint( void *handle
, const char *function
) )();