System Types

Instructions manual





OKit: Object Tree, RPL Virtual Machine and compiler shared library

Copyright (C) 2000 Yann LANDRIN-SCHWEITZER


This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA


Author: Yann LANDRIN-SCHWEITZER
Contact: varkhan@free.fr
Homepage: http://varkhan.free.fr/





USES ErrLog.h





OKit_Stack definition






Function OKit_StackAlloc

OKit_Stack OKit_StackAlloc(unsigned long chksz) ;
Allocates a new, empty OKit_Stack.


Args
_chksz:buffer size increment


Returns
_NULL:if no memory was available
else the newly allocated OKit_Stack.


Errors
_ENOMEM:if no memory was available



Function OKit_StackFree

void OKit_StackFree(OKit_Stack stk) ;
Frees a OKit_Stack, dereferences and frees its contents.


Args
_stk:OKit_Stack to free



Function OKit_StackDepth

unsigned long OKit_StackDepth(OKit_Stack stk) ;
Returns the depth (number of elements) of a OKit_Stack.


Args
_stk:OKit_Stack we want to get information about


Returns
_-1:if a NULL OKit_Stack was passed as argument
else the OKit_Stack's depth.


Errors
_EINVAL:if a NULL OKit_Stack was passed as argument



Function OKit_StackPush

unsigned long OKit_StackPush(OKit_Stack stk, OKit_Object obj) ;
Pushes and references an OKit_Object onto a OKit_Stack.


Args
_stk:OKit_Stack
_obj:OKit_Object to push


Returns
_-1:if some error occurred
else the new depth of the OKit_Stack.


Errors
_EINVAL:if a NULL OKit_Stack or OKit_Object was passed as argument
_EACCES:if the OKit_Stack was freezed and consequently cannot receive OKit_Objects
_ENOMEM:if no memory was available



Function OKit_StackPop

OKit_Object OKit_StackPop(OKit_Stack stk) ;
Pops and dereferences an OKit_Object from a OKit_Stack.


Args
_stk:non-empty OKit_Stack


Returns
_NULL:if the OKit_Stack was NULL, empty or freezed
else the object popped from the stack.


Errors
_EINVAL:if a NULL OKit_Stack was passed as argument
_EACCES:if the OKit_Stack was freezed and consequently cannot yield OKit_Objects
_ENOMEM:if a memory disallocation failed (non-fatal error)



Function OKit_StackGet

OKit_Object OKit_StackGet(OKit_Stack stk, unsigned long num) ;
Gets an OKit_Object at a specified level of a OKit_Stack.


Args
_stk:non-empty OKit_Stack
_num:level at which to look for an object


Returns
_NULL:if the OKit_Stack was NULL, or the level invalid
else the object at level 'num' of the OKit_Stack (first level is 1).


Errors
_EINVAL:if a NULL or empty OKit_Stack was passed as argument, or the level was invalid



Function OKit_StackPut

OKit_Object OKit_StackPut(OKit_Stack stk, OKit_Object obj, unsigned long num) ;
Puts an OKit_Object at a specified level of a OKit_Stack.


Args
_stk:OKit_Stack
_obj:OKit_Object to put
_num:level at which to put an object


Returns
_NULL:if the OKit_Stack was NULL, or the level invalid
else the old object at the specified level of the OKit_Stack (first level is 1).


Errors
_EINVAL:if a NULL OKit_Stack or OKit_Object was passed as argument, or the level was invalid



Function OKit_StackChkType

unsigned long OKit_StackChkType(OKit_Stack stk, unsigned long argc, OKit_Type * argt) ;
Checks the types of OKit_Objects on a OKit_Stack.


Args
_stk:OKit_Stack
_argc:number of OKit_Objects to check
_argt:types of OKit_Objects to check (or-ed types of admissible objects, level by level)


Returns
_-1:if the OKit_Stack was NULL or there was not enough OKit_Objects on OKit_Stack
else an error flag (0 if all arguments were OK, every bit standing as an individual
error flag for each level).


Errors
_EINVAL:if a NULL OKit_Stack was passed as argument



Function OKit_StackOut

unsigned long OKit_StackOut(OKit_Stack stk, char * out, unsigned long max, char * head, char * rowfmt, char * tail, unsigned long rows) ;
Prints the contents of a OKit_Stack, following the given formats.


Args
_stk:OKit_Stack
_out:output character string
_max:maximum number of characters to print (final nil char EXCEPTED)
_head:head string
_rowfmt:row printing format
_tail:tail string
_rows:number of rows (height in chars)


Returns
_-1:if the OKit_Stack was NULL
else the number of characters printed.
or the total number of characters that should be printed, if 'out' was NULL.


Errors
_EINVAL:if a NULL OKit_Stack was passed as argument


Note
The row format string is printed for each stack row between 0 and rows-1.
Escape sequences take the form %fdd..dd?, where the 'f' char is an optionnal
fill character (by dfault ' '), 'd' chars are digits and '?' denotes either
the 'n' or 's' characters. They are replaced by the stack row number, for the 'n'
format, and the corresponding object, for the 's' format, each written on
the number of chars denoted by the digits.



Function OKit_StackStat

unsigned long OKit_StackStat(OKit_Stack stk) ;
Prints OKit_Stack statistics on 'stdout'.


Args
_stk:OKit_Stack


Returns
_-1:if the OKit_Stack was NULL
else 0.


Errors
any error generated by the 'printf' libc call.




Variables domain definition






Function OKit_NameSpaceAlloc

OKit_NameSpace OKit_NameSpaceAlloc(unsigned long chksz) ;
Allocates an empty OKit_NameSpace.


Args
_chksz:buffer size increment


Returns
_NULL:if no memory was available
else the newly allocated OKit_NameSpace.


Errors
_ENOMEM:if no memory was available



Function OKit_NameSpaceFree

void OKit_NameSpaceFree(OKit_NameSpace nms) ;
Frees a OKit_NameSpace, dereferences and frees its contents.


Args
_nms:OKit_NameSpace to free



Function OKit_NameSpaceGet

OKit_Object OKit_NameSpaceGet(OKit_NameSpace nms, char * name) ;
Gets an elements by its key in a OKit_NameSpace.


Args
_nms:OKit_NameSpace
_name:key, or "OKit_Object name"


Returns
_NULL:if a NULL OKit_NameSpace or name was passed as argument, or no OKit_Object was known by this key
else the OKit_Object under name 'name'.


Errors
_EINVAL:if a NULL OKit_NameSpace or name was passed as argument
_ENOMEM:if no memory was available



Function OKit_NameSpaceSet

OKit_Object OKit_NameSpaceSet(OKit_NameSpace nms, char * name, OKit_Object obj) ;
Sets and references an OKit_Object under a key in a OKit_NameSpace.


Args
_nms:OKit_NameSpace
_name:key, or "OKit_Object name"
_obj:OKit_Object to set under its "name"


Returns
_NULL:if some error occurred
else the old OKit_Object under this key, if it existed (and it is then dereferenced)
or the OKit_Object passed as argument.


Errors
_EINVAL:if a NULL OKit_NameSpace, name or OKit_Object was passed as argument
_EACCES:if the OKit_NameSpace was freezed and consequently cannot receive OKit_Objects
_ENOMEM:if no memory was available



Function OKit_NameSpaceDel

OKit_Object OKit_NameSpaceDel(OKit_NameSpace nms, char * name) ;
Deletes a key and dereferences its contents in a OKit_NameSpace.


Args
_nms:OKit_NameSpace
_name:key, or "OKit_Object name"


Returns
_NULL:if a NULL OKit_NameSpace or name was passed as argument,
or the key was not found
else the OKit_Object under name 'name'.


Errors
_EINVAL:if a NULL OKit_NameSpace or name was passed as argument
_EACCES:if the OKit_NameSpace was freezed and consequently cannot yield OKit_Objects
_ENOMEM:if a disallocation failed (non-fatal error)



Function OKit_NameSpaceOKit_List

OKit_List OKit_NameSpaceOKit_List(OKit_NameSpace nms) ;
OKit_Lists all the names in a OKit_NameSpace.


Args
_nms:OKit_NameSpace


Returns
_NULL:if a NULL OKit_NameSpace was passed as argument, or the OKit_List allocation failed
else the OKit_List of all names in nms.


Errors
_EINVAL:if a NULL OKit_NameSpace or name was passed as argument
_ENOMEM:if no memory was available



Function OKit_NameSpaceOut

unsigned long OKit_NameSpaceOut(OKit_NameSpace nms, char * out, unsigned long max, char * head, char * rowfmt, char * tail) ;
Prints a OKit_NameSpace keys and contents, acording to formats.


Args
_nms:OKit_NameSpace
_out:output character string
_max:maximum number of characters to print (final nil char EXCEPTED)
_head:head string
_rowfmt:row printing format
_tail:tail string
_rows:number of rows (height in chars)


Returns
_-1:if the OKit_Stack was NULL
else the number of characters printed.
or the total number of characters that should be printed, if 'out' was NULL.


Errors
_EINVAL:if a NULL OKit_NameSpace was passed as argument


Note
The row format string is printed for each name entry in the OKit_NameSpace.
Escape sequences take the form %fdd..dd?, where the 'f' char is an optionnal
fill character (by dfault ' '), 'd' chars are digits and '?' denotes either
the 'n' or 's' characters. They are replaced by the entry name, for the 'n'
format, and the corresponding object, for the 's' format, each written on
the number of chars denoted by the digits.



Function OKit_NameSpaceStat

unsigned long OKit_NameSpaceStat(OKit_NameSpace nms) ;
Prints OKit_NameSpace statistics on 'stdout'.


Args
_nms:OKit_NameSpace


Returns
_-1:if the OKit_NameSpace was NULL
else 0.


Errors
any error generated by the 'printf' libc call.