G:/ScriptBasic/source/basext.c

Go to the documentation of this file.
00001 /*
00002 FILE:   basext.c
00003 HEADER: basext.h
00004 
00005 --GNU LGPL
00006 This library is free software; you can redistribute it and/or
00007 modify it under the terms of the GNU Lesser General Public
00008 License as published by the Free Software Foundation; either
00009 version 2.1 of the License, or (at your option) any later version.
00010 
00011 This library is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 Lesser General Public License for more details.
00015 
00016 You should have received a copy of the GNU Lesser General Public
00017 License along with this library; if not, write to the Free Software
00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 This is a C file that contains mainly header information. Use headerer.pl to
00021 create basext.h
00022 
00023 We do not created basext.h using an editor because all .h files may be deleted
00024 in this project during cleanup and we may loose this file accidentally.
00025 
00026 TO_HEADER:
00027 #include "report.h"
00028 #include "sym.h"
00029 #include "lexer.h"
00030 #include "expression.h"
00031 #include "syntax.h"
00032 #include "reader.h"
00033 #include "myalloc.h"
00034 #include "builder.h"
00035 #include "memory.h"
00036 #include "execute.h"
00037 #include "command.h"
00038 #include "conftree.h"
00039 #include "filesys.h"
00040 #include "errcodes.h"
00041 #include "tools/global.h"
00042 #include "tools/md5.h"
00043 #include "match.h"
00044 #include "thread.h"
00045 #include "scriba.h"
00046 #include "logger.h"
00047 #include "hndlptr.h"
00048 #include "ipreproc.h"
00049 
00050 
00051 // C++ support was suggested by
00052 // Gavin Jenkins [gavinjenkins@inform-comms.co.uk]
00053 // use -DSTATIC_LINK=1 in case you want to link the module to ScriptBasic
00054 // statically. Though this is experimental.
00055 #if (defined(_WIN32) || defined(__MACOS__))
00056 # if STATIC_LINK
00057 #  ifdef __cplusplus
00058 #   define DLL_EXPORT extern "C" static
00059 #  else
00060 #   define DLL_EXPORT static
00061 #  endif
00062 # else
00063 #  ifdef __cplusplus
00064 #   define DLL_EXPORT extern "C" __declspec(dllexport) 
00065 #  else
00066 #   define DLL_EXPORT __declspec(dllexport) 
00067 #  endif
00068 # endif
00069 #else
00070 # if STATIC_LINK
00071 #  ifdef __cplusplus
00072 #   define DLL_EXPORT extern "C" static
00073 #  else
00074 #   define DLL_EXPORT static
00075 #  endif
00076 # else
00077 #  ifdef __cplusplus
00078 #   define DLL_EXPORT extern "C" 
00079 #  else
00080 #   define DLL_EXPORT
00081 #  endif
00082 # endif
00083 #endif
00084 
00085 typedef struct _SLFST {
00086   char *name;
00087   void *function;
00088   } SLFST, *PSLFST;
00089 
00090 typedef struct _MODLIST {
00091   char *name;
00092   PSLFST *table;
00093   } MODLIST, *PMODLIST;
00094 
00095 =POD
00096 =H Basic Extension Support functions, structures and macros
00097 =CUT
00098 
00099 typedef struct _SupportTable {
00100 
00101   pExecuteObject pEo; // The execution context
00102 
00103 =POD
00104 =section besALLOC
00105 =H besALLOC(X)
00106 
00107 Use this macro to allocate memory in an extension like you would use
00108 T<malloc> in a normal, old fashioned C program. The argument is the size of the memory in
00109 byte count to be allocated. The result is the pointer to the allocated memory or T<NULL> if there
00110 is not enough memory available.
00111 
00112 The allocated memory is assigned to the memory segment of the execution thread and thus this memory
00113 is released automatically when the module is unloaded from the interpreter. In other words if
00114 a module uses T<besALLOC> to allocate memory there is no need to call R<besFREE(X)>.
00115 
00116 Modules written for multi-thread variations of ScriptBasic should also be aware of the fact that
00117 the memory allocated by this macro is released whent he calling interpreter thread finishes.
00118 
00119 This macro calls the function R<alloc_Alloc()>
00120 =CUT
00121   void * (*Alloc)(size_t n, void *p);
00122 #define besALLOC(X) (pSt->Alloc((X),pSt->pEo->pMemorySegment))
00123 
00124 =POD
00125 =section besPROCALLOC
00126 =H besPROCALLOC(X)
00127 
00128 Use this macro in multi-thread supporting modules to allocate memory that is
00129 not freed when the actual interpreter finishes but stays in memory so long
00130 as long the process is alive.
00131 
00132 =CUT
00133 #define besPROCALLOC(X) (pSt->pEo->pSTI->Alloc((X),besPROCMEMORYSEGMENT))
00134 
00135 =POD
00136 =section besFREE
00137 =H besFREE(X)
00138 
00139 Use this macro to release memory that was allocated by R<besALLOC(X)>.
00140 
00141 Altough all memory allocated by R<besALLOC()> is automatically released when the
00142 interpreter thread calling R<besALLOC()> finishes it is advised to release all
00143 memory chunks, especially large onces when they are not needed anymore.
00144 
00145 This macro also T<NULL>ifies the argument.
00146 
00147 This macro calls the function R<alloc_Free()>
00148 =CUT
00149   void   (*Free)(void *pMem, void *p);
00150 #define besFREE(X) (pSt->Free((X),pSt->pEo->pMemorySegment),(X)=NULL)
00151 
00152 =POD
00153 =section besPROCFREE
00154 =H besPROCFREE(X)
00155 
00156 This is the counterpart of R<besPROCALLOC> releasing memory allocated
00157 for process life time.
00158 =CUT
00159 #define besPROCFREE(X) (pSt->pEo->pSTI->Free((X),besPROCMEMORYSEGMENT),(X)=NULL)
00160 
00161 =POD
00162 =section besPROCMEMORYSEGMENT
00163 =H besPROCMEMORYSEGMENT
00164 
00165 Use this macro in case you need to pass the process level memory
00166 segment to a function.
00167 =CUT
00168 #define besPROCMEMORYSEGMENT (pSt->pEo->pSTI->pEo->pMemorySegment)
00169 
00170   // create new mortal variables. The memory object should be pSt->pEo->pMo, the mortal list pSt->pEo->pGlobalMortalList
00171   // use the macros
00172   pFixSizeMemoryObject (*NewMortalString)(pMemoryObject pMo, unsigned long StringSize, pMortalList pMortal);
00173   pFixSizeMemoryObject (*NewMortalLong)(pMemoryObject pMo, pMortalList pMortal);
00174   pFixSizeMemoryObject (*NewMortalRef)(pMemoryObject pMo, pMortalList pMortal);
00175   pFixSizeMemoryObject (*NewMortalDouble)(pMemoryObject pMo, pMortalList pMortal);
00176   pFixSizeMemoryObject (*NewMortalArray)(pMemoryObject pMo, pMortalList pMortal, long IndexLow, long IndexHigh);
00177 
00178 =POD
00179 =section besNEWMORTALSTRING
00180 =H besNEWMORTALSTRING(X)
00181 
00182 Create a new mortal string and return a pointer to it. The argument should be the
00183 number of characters in the string.
00184 This macro calls the function R<memory_NewMortalString()>.
00185 
00186 See also 
00187 =itemize
00188 =item R<besNEWMORTALSTRING>
00189 =item R<besNEWMORTALLONG>
00190 =item R<besNEWMORTALREF>
00191 =item R<besNEWMORTALDOUBLE>
00192 =item R<besNEWMORTALARRAY>
00193 =noitemize
00194 =CUT
00195 #define besNEWMORTALSTRING(X)  (pSt->NewMortalString(pSt->pEo->pMo,(X),pSt->pEo->pGlobalMortalList))
00196 
00197 =POD
00198 =section besNEWMORTALLONG
00199 =H besNEWMORTALLONG
00200 
00201 Create a new mortal T<long> and return the pointer to it.
00202 This macro calls the function R<memory_NewMortalLong()>.
00203 
00204 See also 
00205 =itemize
00206 =item R<besNEWMORTALSTRING>
00207 =item R<besNEWMORTALLONG>
00208 =item R<besNEWMORTALREF>
00209 =item R<besNEWMORTALDOUBLE>
00210 =item R<besNEWMORTALARRAY>
00211 =noitemize
00212 =CUT
00213 #define besNEWMORTALLONG       (pSt->NewMortalLong(pSt->pEo->pMo,pSt->pEo->pGlobalMortalList))
00214 
00215 =POD
00216 =section besNEWMORTALREF
00217 =H besNEWMORTALREF
00218 
00219 Create a new mortal reference and return the pointer to it.
00220 This macro calls the function R<memory_NewMortalRef()>.
00221 
00222 See also 
00223 =itemize
00224 =item R<besNEWMORTALSTRING>
00225 =item R<besNEWMORTALLONG>
00226 =item R<besNEWMORTALREF>
00227 =item R<besNEWMORTALDOUBLE>
00228 =item R<besNEWMORTALARRAY>
00229 =noitemize
00230 =CUT
00231 #define besNEWMORTALREF        (pSt->NewMortalRef(pSt->pEo->pMo,pSt->pEo->pGlobalMortalList))
00232 
00233 =POD
00234 =section besNEWMORTALDOUBLE
00235 =H besNEWMORTALDOUBLE
00236 
00237 Create a new mortal T<double> and return the pointer to it.
00238 This macro calls the function R<memory_NewMortalDouble()>.
00239 
00240 See also 
00241 =itemize
00242 =item R<besNEWMORTALSTRING>
00243 =item R<besNEWMORTALLONG>
00244 =item R<besNEWMORTALREF>
00245 =item R<besNEWMORTALDOUBLE>
00246 =item R<besNEWMORTALARRAY>
00247 =noitemize
00248 =CUT
00249 #define besNEWMORTALDOUBLE     (pSt->NewMortalDouble(pSt->pEo->pMo,pSt->pEo->pGlobalMortalList))
00250 
00251 =POD
00252 =section besNEWMORTALARRAY
00253 =H besNEWMORTALARRAY(X,Y)
00254 
00255 Create a new mortal array and return the pointer to it. The arguments define the array
00256 low index and the array high index. This macro calls the function R<memory_NewMortalArray()>.
00257 
00258 See also 
00259 =itemize
00260 =item R<besNEWMORTALSTRING>
00261 =item R<besNEWMORTALLONG>
00262 =item R<besNEWMORTALREF>
00263 =item R<besNEWMORTALDOUBLE>
00264 =item R<besNEWMORTALARRAY>
00265 =noitemize
00266 =CUT
00267 #define besNEWMORTALARRAY(X,Y) (pSt->NewMortalArray(pSt->pEo->pMo,pSt->pEo->pGlobalMortalList,(X),(Y)))
00268 
00269   pFixSizeMemoryObject (*NewString)(pMemoryObject pMo, unsigned long StringSize);
00270   pFixSizeMemoryObject (*NewLong)(pMemoryObject pMo);
00271   pFixSizeMemoryObject (*NewRef)(pMemoryObject pMo);
00272   pFixSizeMemoryObject (*NewDouble)(pMemoryObject pMo);
00273   pFixSizeMemoryObject (*NewArray)(pMemoryObject pMo, long LowIndex, long HighIndex);
00274 
00275 =POD
00276 =section besNEWSTRING
00277 =H besNEWSTRING(X)
00278 
00279 Create a new string and return the pointer to it. The argument defines the number
00280 of bytes in the string. This macro calls the function R<memory_NewString()>.
00281 
00282 See also 
00283 =itemize
00284 =item R<besNEWSTRING>
00285 =item R<besNEWLONG>
00286 =item R<besNEWREF>
00287 =item R<besNEWDOUBLE>
00288 =item R<besNEWARRAY>
00289 =noitemize
00290 =CUT
00291 #define besNEWSTRING(X)  (pSt->NewString(pSt->pEo->pMo,(X)))
00292 
00293 =POD
00294 =section besNEWLONG
00295 =H besNEWLONG
00296 
00297 Create a new T<long> and return the pointer to it. This macro calls the function
00298 R<memory_NewLong()>.
00299 
00300 See also 
00301 =itemize
00302 =item R<besNEWSTRING>
00303 =item R<besNEWLONG>
00304 =item R<besNEWREF>
00305 =item R<besNEWDOUBLE>
00306 =item R<besNEWARRAY>
00307 =noitemize
00308 =CUT
00309 #define besNEWLONG       (pSt->NewLong(pSt->pEo->pMo))
00310 
00311 =POD
00312 =section besNEWREF
00313 =H besNEWREF
00314 
00315 Create a new reference variable and return the pointer to it. This macro calls the function
00316 R<memory_NewRef()>.
00317 
00318 See also 
00319 =itemize
00320 =item R<besNEWSTRING>
00321 =item R<besNEWLONG>
00322 =item R<besNEWREF>
00323 =item R<besNEWDOUBLE>
00324 =item R<besNEWARRAY>
00325 =noitemize
00326 =CUT
00327 #define besNEWREF        (pSt->NewRef(pSt->pEo->pMo))
00328 
00329 =POD
00330 =section besNEWDOUBLE
00331 =H besNEWDOUBLE
00332 
00333 Create a new T<double> and return the pointer to it. This macro calls the function
00334 R<memory_NewDouble()>.
00335 
00336 See also 
00337 =itemize
00338 =item R<besNEWSTRING>
00339 =item R<besNEWLONG>
00340 =item R<besNEWREF>
00341 =item R<besNEWDOUBLE>
00342 =item R<besNEWARRAY>
00343 =noitemize
00344 =CUT
00345 #define besNEWDOUBLE     (pSt->NewDouble(pSt->pEo->pMo))
00346 
00347 =POD
00348 =section besNEWARRAY
00349 =H besNEWARRAY(X,Y)
00350 
00351 Create a new array and return the pointer to it. The arguments define the array
00352 low index and the array high index. This macro calls the function R<memory_NewArray()>.
00353 
00354 See also 
00355 =itemize
00356 =item R<besNEWSTRING>
00357 =item R<besNEWLONG>
00358 =item R<besNEWREF>
00359 =item R<besNEWDOUBLE>
00360 =item R<besNEWARRAY>
00361 =noitemize
00362 =CUT
00363 #define besNEWARRAY(X,Y) (pSt->NewArray(pSt->pEo->pMo,(X),(Y)))
00364 
00365 =POD
00366 =section besRELEASE
00367 =H besRELEASE(X)
00368 
00369 Use this macro to release a non-mortal variable. This macro calls the function
00370 R<memory_ReleaseVariable()> with the appropriate memory segment arguments.
00371 
00372 See also 
00373 =itemize
00374 =item R<besNEWSTRING>
00375 =item R<besNEWLONG>
00376 =item R<besNEWREF>
00377 =item R<besNEWDOUBLE>
00378 =item R<besNEWARRAY>
00379 =noitemize
00380 =CUT
00381   int (*ReleaseVariable)(pMemoryObject, pFixSizeMemoryObject);
00382 #define besRELEASE(X)    (pSt->ReleaseVariable(pSt->pEo->pMo,(X)))
00383 
00384 =POD
00385 =section besSETREF
00386 =H besSETREF(VAR,VAL)
00387 
00388 Use this macro in external modules to set the value of a variable to a reference to another variable.
00389 The argument T<VAR> is the variable and the argument T<VAL> is the variable to be referenced.
00390 =CUT
00391   int (*SetRef)(pMemoryObject,pFixSizeMemoryObject *,pFixSizeMemoryObject *);
00392 #define besSETREF(X,Y) (pSt->SetRef(St->pEo->pMo,(X),(Y))
00393 
00394 =POD
00395 =section besCONFIG
00396 =H besCONFIG(X)
00397 
00398 Get a configuration value that is supposed to be a string. This macro uses the
00399 configuration of the callign interpreter thread and it calls the function
00400 R<cft_GetString>.
00401 =CUT
00402   char * (*ConfigData)(ptConfigTree p, char *s);
00403 #define besCONFIG(X) (pSt->ConfigData(pSt->pEo->pConfig,(X)))
00404 
00405 =POD
00406 =section besCONFIGFINDNODE
00407 =H besCONFIGFINDNODE(X,Y,Z)
00408 This macro calls the function R<cft_FindNode>. Use this macro for sophisticated
00409 configuration handling that needs configuration key enumeration.
00410 =CUT
00411   CFT_NODE (*FindNode)(ptConfigTree, CFT_NODE, char *);
00412 #define besCONFIGFINDNODE(X,Y,Z) (pSt->FindNode((X),(Y),(Z)))
00413 
00414 =POD
00415 =section besCONFIGEX
00416 =H besCONFIGEX(CT,CS,NS,CSS,LS,DS,IS)
00417 
00418 This macro calls the function R<cft_GetEx>. Use this macro to retrieve
00419 configuration information that is not a string or the type is not known.
00420 =CUT
00421   int (*GetEx)(ptConfigTree, char *, CFT_NODE *, char **, long *, double *, int *);
00422 #define besCONFIGEX(CT,CS,NS,CSS,LS,DS,IS) (pSt->GetEx((CT),(CS),(NS),(CSS),(LS),(DS),(IS)))
00423 
00424 =POD
00425 =section besCONFIGENUMFIRST
00426 =H besCONFIGENUMFIRST(X,Y)
00427 
00428 This macro calls the function R<cft_EnumFirst>.
00429 =CUT
00430   CFT_NODE (*EnumFirst)(ptConfigTree, CFT_NODE);
00431 #define besCONFIGENUMFIRST(X,Y) (pSt->EnumFirst((X),(Y)))
00432 
00433 =POD
00434 =section besCONFIGENUMNEXT
00435 =H besCONFIGENUMNEXT(X,Y)
00436 
00437 This macro calls the function R<cft_EnumNext>.
00438 =CUT
00439   CFT_NODE (*EnumNext)(ptConfigTree, CFT_NODE);
00440 #define besCONFIGENUMNEXT(X,Y) (pSt->EnumNext((X),(Y)))
00441 
00442 =POD
00443 =section besCONFIGGETKEY
00444 =H besCONFIGGETKEY(X,Y)
00445 
00446 This macro calls the function R<cft_GetKey>.
00447 =CUT
00448   char * (*GetKey)(ptConfigTree, CFT_NODE );
00449 #define besCONFIGGETKEY(X,Y) (pSt->GetKey((X),(Y)))
00450 
00451   SymbolTable (*NewSymbolTable)(void* (*memory_allocating_function)(size_t,void *),
00452                                 void *pMemorySegment);
00453   void (*FreeSymbolTable)(SymbolTable table,
00454                           void (*memory_releasing_function)(void *,void *),
00455                           void *pMemorySegment);
00456   void (*TraverseSymbolTable)(SymbolTable table,
00457                               void (*call_back_function)(char *SymbolName, void *SymbolValue, void *f),
00458                               void *f);
00459   void **(*LookupSymbol)(char *s,
00460                          SymbolTable hashtable,
00461                          int insert,
00462                          void* (*memory_allocating_function)(size_t, void *),
00463                          void (*memory_releasing_function)(void *, void *),
00464                          void *pMemorySegment);
00465 
00466   int (*DeleteSymbol)(char *s,
00467                       SymbolTable hashtable,
00468                       void (*memory_releasing_function)(void *, void *),
00469                       void *pMemorySegment);
00470 
00471 =POD
00472 =section besNEWSYMBOLTABLE
00473 =H besNEWSYMBOLTABLE
00474 
00475 This macro allocates a new symbol table and returns the handle pointer to it. This
00476 macro calls the function R<sym_NewSymbolTable>. The allocation function and the memory
00477 segment used to allocate the symbol table is the default one that is used by the interpreter.
00478 =CUT
00479 #define besNEWSYMBOLTABLE() \
00480   (pSt->NewSymbolTable(pSt->Alloc,pSt->pEo->pMemorySegment))
00481 
00482 =POD
00483 =section besFREESYMBOLTABLE
00484 =H besFREESYMBOLTABLE(X)
00485 
00486 This macro releases a symbol table calling the function R<sym_FreeSymbolTable>.
00487 The allocation function and the memory segment used to allocate the symbol table
00488 is the default one that is used by the interpreter.
00489 =CUT
00490 #define besFREESYMBOLTABLE(X) \
00491   (pSt->FreeSymbolTable((X),pSt->Free,pSt->pEo->pMemorySegment))
00492 
00493 =POD
00494 =section besTRAVERSESYMBOLTABLE
00495 =H besTRAVERSESYMBOLTABLE(X,Y,Z)
00496 
00497 This macro calls the function R<sym_TraverseSymbolTable>.
00498 =CUT
00499 #define besTRAVERSESYMBOLTABLE(X,Y,Z) \
00500   (pSt->TraverseSymbolTable((X),(Y),(Z)))
00501 
00502 =POD
00503 =section besLOOKUPSYMBOL
00504 =H besLOOKUPSYMBOL(X,Y,Z)
00505 
00506 This macro calls the function R<sym_LookupSymbol>.
00507 =CUT
00508 #define besLOOKUPSYMBOL(X,Y,Z) \
00509   (pSt->LookupSymbol((X),(Y),(Z),pSt->Alloc,\
00510                                  pSt->Free,\
00511                                  pSt->pEo->pMemorySegment))
00512 
00513 =POD
00514 =section besDeleteSymbol
00515 =H besDeleteSymbol(X,Y,Z)
00516 
00517 This macro calls the function R<sym_DeleteSymbol>.
00518 =CUT
00519 #define besDeleteSymbol(X,Y) \
00520   (pSt->DeleteSymbol((X),(Y),pSt->Free,pSt->pEo->pMemorySegment))
00521 
00522   void *(*LoadLibrary)(char *s); // load a dynamic load library
00523   void (*FreeLibrary)(void *);     // free the loaded library
00524   void *(*GetFunctionByName)(void *pLibrary,char *pszFunctionName);
00525 
00526 =POD
00527 =section besLOADLIBRARY
00528 =H besLOADLIBRARY(X)
00529 
00530 This macro calls the function R<dynlolib_LoadLibrary()>.
00531 =CUT
00532 #define besLOADLIBRARY(X) (pSt->LoadLibrary( (X) ))
00533 
00534 =POD
00535 =section besFREELIBRARY
00536 =H besFREELIBRARY(X)
00537 
00538 This macro calls the function R<dynlolib_FreeLibrary()>.
00539 =CUT
00540 #define besFREELIBRARY(X) (pSt->FreeLibrary( (X) ))
00541 
00542 =POD
00543 =section besGETFUNCTIONBYNAME
00544 =H besGETFUNCTIONBYNAME(X)
00545 
00546 This macro calls the function R<dynlolib_GetFunctionByName()>.
00547 =CUT
00548 #define besGETFUNCTIONBYNAME(LIB,FUN) (pSt->GetFunctionByName((LIB),(FUN)))
00549 
00550   FILE *(*fopen)(char *pszFileName,char *pszOpenMode);
00551   void (*fclose)(FILE *fp);
00552   long (*size)(char *pszFileName);
00553   long (*time_accessed)(char *pszFileName);
00554   long (*time_modified)(char *pszFileName);
00555   long (*time_created)(char *pszFileName);
00556   int (*isdir)(char *pszFileName);
00557   int (*isreg)(char *pszFileName);
00558   int (*exists)(char *pszFileName);
00559   int (*truncate)(FILE *,long lNewFileSize);
00560   int (*fgetc)(FILE *);
00561   int (*fread)(char *, int, int, FILE *);
00562   int (*fwrite)(char *, int, int, FILE *);
00563   void (*setmode)(FILE *, int);
00564   void (*binmode)(FILE *);
00565   void (*textmode)(FILE *);
00566   int (*ferror)(FILE *);
00567   int (*fputc)(int c, FILE*fp);
00568   int (*flock)(FILE *fp,int iLockType);
00569   int (*lock)(FILE *fp,int iLockType,long lStart,long lLength);
00570   int (*feof)(FILE *fp);
00571   int (*mkdir)(char *pszDirectoryName);
00572   int (*rmdir)(char *pszDirectoryName);
00573   int (*remove)(char *pszFileName);
00574   int (*deltree)(char *pszDirectoryName);
00575   int (*MakeDirectory)(char *pszDirectoryName);
00576   DIR *(*opendir)(char *pszDirectoryName,tDIR *pDirectory);
00577   struct dirent *(*readdir)(DIR *pDirectory);
00578   void (*closedir)(DIR *pDirectory);
00579 
00580 =POD
00581 =section besFOPEN
00582 =H besFOPEN
00583 
00584 This macro calls the function R<file_fopen>.
00585 =CUT
00586 #define besFOPEN(FN,OM)       (pSt->fopen( (FN),(OM) ))
00587 
00588 =POD
00589 =section besFCLOSE
00590 =H besFCLOSE
00591 
00592 This macro calls the function R<file_fclose>.
00593 =CUT
00594 #define besFCLOSE(FP)         (pSt->fclose( (FP) ))
00595 
00596 =POD
00597 =section besSIZE
00598 =H besSIZE
00599 
00600 This macro calls the function R<file_size>.
00601 =CUT
00602 #define besSIZE(FN)           (pSt->size( (FN) ))
00603 
00604 =POD
00605 =section besTIME_ACCESSED
00606 =H besTIME_ACCESSED
00607 
00608 This macro calls the function R<file_time_accessed>.
00609 =CUT
00610 #define besTIME_ACCESSED(FN)  (pSt->time_accessed( (FN) ))
00611 
00612 =POD
00613 =section besTIME_MODIFIED
00614 =H besTIME_MODIFIED
00615 
00616 This macro calls the function R<file_time_modified>.
00617 =CUT
00618 #define besTIME_MODIFIED(FN)  (pSt->time_modified( (FN) ))
00619 
00620 =POD
00621 =section besTIME_CREATED
00622 =H besTIME_CREATED
00623 
00624 This macro calls the function R<file_time_created>.
00625 =CUT
00626 #define besTIME_CREATED(FN)   (pSt->time_created( (FN) ))
00627 
00628 =POD
00629 =section besISDIR
00630 =H besISDIR
00631 
00632 This macro calls the function R<file_isdir>.
00633 =CUT
00634 #define besISDIR(FN)          (pSt->isdir( (FN) ))
00635 
00636 =POD
00637 =section besISREG
00638 =H besISREG
00639 
00640 This macro calls the function R<file_isreg>.
00641 =CUT
00642 #define besISREG(FN)          (pSt->isreg( (FN) ))
00643 
00644 =POD
00645 =section besEXISTS
00646 =H besEXISTS
00647 
00648 This macro calls the function R<file_fileexists>.
00649 =CUT
00650 #define besEXISTS(FN)         (pSt->exists( (FN) ))
00651 
00652 =POD
00653 =section besTRUNCATE
00654 =H besTRUNCATE
00655 
00656 This macro calls the function R<file_truncate>.
00657 =CUT
00658 #define besTRUNCATE(FN,NS)    (pSt->truncate( (FN),(NS) ))
00659 
00660 =POD
00661 =section besFGETC
00662 =H besFGETC
00663 
00664 This macro calls the function R<file_fgetc>.
00665 =CUT
00666 #define besFGETC(FP)          (pSt->fgetc( (FP) ))
00667 
00668 =POD
00669 =section besFREAD
00670 =H besFREAD
00671 
00672 This macro calls the function R<file_fread>.
00673 =CUT
00674 #define besFREAD(S,X,Y,FP)    (pSt->fread( (S),(X),(Y),(FP) ))
00675 
00676 =POD
00677 =section besFWRITE
00678 =H besFWRITE
00679 
00680 This macro calls the function R<file_fwrite>.
00681 =CUT
00682 #define besFWRITE(S,X,Y,FP)   (pSt->fwrite( (S),(X),(Y),(FP) ))
00683 
00684 =POD
00685 =section besSETMODE
00686 =H besSETMODE
00687 
00688 This macro calls the function R<file_setmode>.
00689 =CUT
00690 #define besSETMODE(FP,M)      (pSt->setmode( (FP),(M) ))
00691 
00692 =POD
00693 =section besBINMODE
00694 =H besBINMODE
00695 
00696 This macro calls the function R<file_binmode>.
00697 =CUT
00698 #define besBINMODE(FP)        (pSt->binmode( (FP) ))
00699 
00700 =POD
00701 =section besTEXTMODE
00702 =H besTEXTMODE
00703 
00704 This macro calls the function R<file_textmode>.
00705 =CUT
00706 #define besTEXTMODE(FP)       (pSt->textmode( (FP) ))
00707 
00708 =POD
00709 =section besFERROR
00710 =H besFERROR
00711 
00712 This macro calls the function R<file_ferror>.
00713 =CUT
00714 #define besFERROR(FP)         (pSt->ferror( (FP) ))
00715 
00716 =POD
00717 =section besFPUTC
00718 =H besFPUTC
00719 
00720 This macro calls the function R<file_fputc>.
00721 =CUT
00722 #define besFPUTC(C,FP)        (pSt->fputc( (C),(FP) ))
00723 
00724 =POD
00725 =section besFLOCK
00726 =H besFLOCK
00727 
00728 This macro calls the function R<file_flock>.
00729 =CUT
00730 #define besFLOCK(FP)          (pSt->flock( (FP) ))
00731 
00732 =POD
00733 =section besLOCK
00734 =H besLOCK
00735 
00736 This macro calls the function R<file_lock>.
00737 =CUT
00738 #define besLOCK(FP,LT,LS,LE)  (pSt->lock( (FP),(LT),(LS),(LE) ))
00739 
00740 =POD
00741 =section besFEOF
00742 =H besFEOF
00743 
00744 This macro calls the function R<file_feof>.
00745 =CUT
00746 #define besFEOF(FP)           (pSt->feof( (FP) ))
00747 
00748 =POD
00749 =section besMKDIR
00750 =H besMKDIR
00751 
00752 This macro calls the function R<file_mkdir>.
00753 =CUT
00754 #define besMKDIR(DN)          (pSt->mkdir( (DN) ))
00755 
00756 =POD
00757 =section besRMDIR
00758 =H besRMDIR
00759 
00760 This macro calls the function R<file_rmdir>.
00761 =CUT
00762 #define besRMDIR(DN)          (pSt->rmdir( (DN) ))
00763 
00764 =POD
00765 =section besREMOVE
00766 =H besREMOVE
00767 
00768 This macro calls the function R<file_remove>.
00769 =CUT
00770 #define besREMOVE(FN)         (pSt->remove( (FN) ))
00771 
00772 =POD
00773 =section besDELTREE
00774 =H besDELTREE
00775 
00776 This macro calls the function R<file_deltree>.
00777 =CUT
00778 #define besDELTREE(DN)        (pSt->deltree( (DN) ))
00779 
00780 =POD
00781 =section besMAKEDIRECTORY
00782 =H besMAKEDIRECTORY
00783 
00784 This macro calls the function R<file_MakeDirectory>.
00785 =CUT
00786 #define besMAKEDIRECTORY(DN)  (pSt->MakeDirectory( (DN) ))
00787 
00788 =POD
00789 =section besOPENDIR
00790 =H besOPENDIR
00791 
00792 This macro calls the function R<file_opendir>.
00793 =CUT
00794 #define besOPENDIR(DN,DP)     (pSt->opendir( (DN),(DP) ))
00795 
00796 =POD
00797 =section besREADDIR
00798 =H besREADDIR
00799 
00800 This macro calls the function R<file_readdir>.
00801 =CUT
00802 #define besREADDIR(DP)        (pSt->readdir( (DP) ))
00803 
00804 =POD
00805 =section besCLOSEDIR
00806 =H besCLOSEDIR
00807 
00808 This macro calls the function R<file_closedir>.
00809 =CUT
00810 #define besCLOSEDIR(DP)       (pSt->closedir( (DP) ))
00811 
00812   long (*GetOption)(pExecuteObject,char*);
00813   int (*SetOption)(pExecuteObject,char *,long);
00814   int (*ResetOption)(pExecuteObject,char *);
00815 
00816 =POD
00817 =section besOPTION
00818 =H besOPTION(X)
00819 Get the T<long> value of the option T<X>. This macro calls the function
00820 R<options_Get>. The macro uses the default execution context.
00821 =CUT
00822 #define besOPTION(x)          (pSt->GetOption(pSt->pEo,(x)))
00823 
00824 =POD
00825 =section besSETOPTION
00826 =H besSETOPTION(x,y)
00827 Set the T<y> T<long> value of the option T<x>. This macro calls the function
00828 R<options_Set>. The macro uses the default execution context.
00829 =CUT
00830 #define besSETOPTION(x,y)     (pSt->SetOption(pSt->pEo,(x),(y)))
00831 
00832 =POD
00833 =section besRESETOPTION
00834 =H besRESETOPTION(X)
00835 Reset the option T<X>. This macro calls the function R<options_Reset>.
00836 The macro uses the default execution context.
00837 =CUT
00838 #define besRESETOPTION(x)     (pSt->ResetOption(pSt->pEo,(x)))
00839 
00840   pFixSizeMemoryObject (*Convert2String)(pExecuteObject, pFixSizeMemoryObject, pMortalList);
00841   pFixSizeMemoryObject (*Convert2Long)(pExecuteObject, pFixSizeMemoryObject, pMortalList);
00842   pFixSizeMemoryObject (*Convert2Double)(pExecuteObject, pFixSizeMemoryObject, pMortalList);
00843   int                  (*IsStringInteger)(pFixSizeMemoryObject);
00844 
00845   double               (*GetDoubleValue)(pExecuteObject, pFixSizeMemoryObject);
00846   long                 (*GetLongValue)  (pExecuteObject, pFixSizeMemoryObject);
00847 
00848 =POD
00849 =section besCONVERT2STRING
00850 =H besCONVERT2STRING(x)
00851 
00852 Use this macro to convert a mortal T<VARIABLE> to string. The macro calls the
00853 function R<execute_Convert2String> and uses the global mortal list.
00854 =CUT
00855 #define besCONVERT2STRING(x)  (pSt->Convert2String(pSt->pEo,(x),pSt->pEo->pGlobalMortalList))
00856 
00857 =POD
00858 =section besCONVERT2LONG
00859 =H besCONVERT2LONG(x)
00860 Use this macro to convert a mortal T<VARIABLE> to T<long>. The macro calls the
00861 function R<execute_Convert2Long> and uses the global mortal list.
00862 =CUT
00863 #define besCONVERT2LONG(x)    (pSt->Convert2Long(pSt->pEo,(x),pSt->pEo->pGlobalMortalList))
00864 
00865 =POD
00866 =section besGETLONGVALUE
00867 =H besGETLONGVALUE(x)
00868 Use this macro to get the long value of a variable. This macro is not the same as T<LONGVALUE>.
00869 The macro T<LONGVALUE> simply accesses the long value of a variable and thus can also be used
00870 as a left value assigning value to. On the other hand T<besGETLONGVALUE> is a function call that
00871 returns a long value when the argumentum variable is T<NULL>, T<double>, string or some other value.
00872 In such situation using T<LONGVALUE> would be erroneous.
00873 
00874 The macro T<LONGVALUE> should be used to access the long value of a variable that is known to
00875 hold a long value or when the long value of a variable is to be set.
00876 
00877 The macro T<besGETLONGVALUE> has to be used in a situation when we want to use a variable
00878 for its value being long. It is faster and consumes less memory than converting the variable to
00879 long allocating a new mortal just to access the long value of the new mortal using T<LONGVALUE>.
00880 
00881 The same statements hold for T<DOUBLEVALUE> and R<besGETDOUBLEVALUE>.
00882 =CUT
00883 #define besGETLONGVALUE(x)    (pSt->GetLongValue(pSt->pEo,(x)))
00884 
00885 =POD
00886 =section besCONVERT2DOUBLE
00887 =H besCONVERT2DOUBLE(x)
00888 Use this macro to convert a mortal T<VARIABLE> to T<double>. The macro calls the
00889 function R<execute_Convert2Double> and uses the global mortal list.
00890 
00891 =CUT
00892 #define besCONVERT2DOUBLE(x)  (pSt->Convert2Double(pSt->pEo,(x),pSt->pEo->pGlobalMortalList))
00893 
00894 =POD
00895 =section besGETDOUBLEVALUE
00896 =H besGETDOUBLEVALUE(x)
00897 Use this macro to get the double value of a variable.
00898 
00899 For comparision of T<DOUBLEVALUE> and this macro see the explanation in R<besGETLONGVALUE>.
00900 
00901 =CUT
00902 #define besGETDOUBLEVALUE(x)    (pSt->GetDoubleValue(pSt->pEo,(x)))
00903 
00904 =POD
00905 =section besISSTRINGINTEGER
00906 =H besISSTRINGINTEGER(x)
00907 
00908 Use this macro to decide if a string contains caharacters copnvertible to an
00909 integer value. This macro calls the function R<execute_IsStringInteger>.
00910 =CUT
00911 #define besISSTRINGINTEGER(x) (pSt->IsStringInteger(x))
00912 
00913 =POD
00914 =section besCONVERT2ZCHAR
00915 =H besCONVERT2ZCHAR(x)
00916 
00917 Use this macro to convert a T<VARIABLE> that is already STRING type to zero character
00918 terminated string. This is needed many times when a BASIC string has to be passed to
00919 operating system functions.
00920 
00921 The macro argument T<x> is converted to zero character terminated string and the
00922 result will be pointed by T<y>. T<y> has to be a T<(char *)> C variable.
00923 
00924 If there is not enough memory the macro returns from the function with the error code
00925 T<COMMAND_ERROR_MEMORY_LOW> thus there is no need to check the value of the variable T<y>
00926 if it is T<NULL>.
00927 
00928 The memory allocated to store the ZCHAR string should be released by the macro R<besFREE>.
00929 
00930 Note that the macro does not check wheter the string already contains a zero character or not.
00931 It simply allocates a buffer that has length n+1 bytes to store the n bytes of the original
00932 BASIC string and an extra zero character.
00933 =CUT
00934 #define besCONVERT2ZCHAR(x,y)   (y) = besALLOC(STRLEN( (x) )+1);\
00935                                 if( (y) == NULL )return COMMAND_ERROR_MEMORY_LOW;\
00936                                 memcpy((y),STRINGVALUE( (x) ),STRLEN( (x) ));\
00937                                 (y)[STRLEN( (x) )] = (char)0;
00938 
00939   int (*InitModuleInterface)(pExecuteObject, int);
00940   int (*LoadModule)(pExecuteObject, char *, pModule **);
00941   int (*GetModuleFunctionByName)(pExecuteObject, char *, char *, void **, pModule **);
00942   int (*UnloadAllModules)(pExecuteObject);
00943   int (*UnloadModule)(pExecuteObject, char *);
00944 
00945 =POD
00946 =section besREINITINTERFACE
00947 =H besREINITINTERFACE
00948 
00949 This macro calls the function R<modu_Init> to reset the module interface to
00950 point to the original functions.
00951 
00952 External modules are allowed to alter the support function table implementing their
00953 own functions and thus altering the behavior of other extensions. These extensions
00954 usually set some of the entries of the support function table to point to functions
00955 implemented in the external module. However these functions are available only so long
00956 as long the extension is in memory. When the extension is exiting the pointers should
00957 be restored. Otherwise it may happen that the extension is already unloaded and the function
00958 is used by another module exiting later.
00959 
00960 Because there is no guaranteed order of extension module unload the modules should call
00961 this function to restore the support function table and should not rely on altered
00962 function calls during module exit code is executed.
00963 
00964 =CUT
00965 #define besREINITINTERFACE (pSt->InitModuleInterface(pSt->pEo,1)
00966 
00967 =POD
00968 =section besLOADMODULE
00969 =H besLOADMODULE(x,y)
00970 
00971 This macro calls the function R<modu_LoadModule>. The execution
00972 environment (T<ExecuteObject>) used by the macro while calling the
00973 function is the default execution environment.
00974 =CUT
00975 #define besLOADMODULE(x,y) (pSt->LoadModule(pSt->pEo,(x),(y))
00976 
00977 =POD
00978 =section besGETMODULEFUNCTIONBYNAME
00979 =H besGETMODULEFUNCTIONBYNAME
00980 
00981 This macro calls the function R<modu_GetFunctionByName>. The execution
00982 environment (T<ExecuteObject>) used by the macro while calling the
00983 function is the default execution environment.
00984 =CUT
00985 #define besGETMODULEFUNCTIONBYNAME(x,y,z,w) (pSt->GetModuleFunctionByName(pSt->pEo,(x),(y),(z),(w))
00986 
00987 =POD
00988 =section besUNLOADALLMODULES
00989 =H besUNLOADALLMODULES
00990 
00991 This macro calls the function R<modu_UnloadAllModules>. This will unload all modules that are
00992 not active. Because this macro is called by an extension that is a module itself the calling module
00993 will not be unloaded.
00994 
00995 A module is active if there is a function called in the module and the module did not return from the
00996 function call yet. Typically there can be only one active module at a time unless some
00997 modules call each other in tricky ways through the ScriptBasic module calling functions. Therefore
00998 calling this macro practically unloads all modules but the very one using this macro.
00999 
01000 See also R<besUNLOADMODULE>.
01001 =CUT
01002 #define besUNLOADALLMODULES (pSt->UnloadAllModules(pSt->pEo))
01003 
01004 =POD
01005 =section besUNLOADMODULE
01006 =H besUNLOADMODULE(x)
01007 
01008 This macro calls the function R<modu_UnloadModule> to unload the named
01009 module. Note that the module name T<x> should be the same
01010 string that was used to load the module and it can not be the actual module or
01011 any other module that is active.
01012 
01013 See also R<besUNLOADALLMODULES>.
01014 =CUT
01015 #define besUNLOADMODULE(x) (pSt->UnloadModule(pSt->pEo,(x))
01016 
01017   void (*sleep)(long);
01018   int  (*curdir)(char *, unsigned long);
01019   int  (*chdir)(char *);
01020   int  (*chown)(char *, char *);
01021   int  (*SetCreateTime)(char *, long);
01022   int  (*SetModifyTime)(char *, long);
01023   int  (*SetAccessTime)(char *, long);
01024 
01025 =POD
01026 =section besSLEEP
01027 =H besSLEEP(x)
01028 
01029 This macro calls R<file_sleep> to sleep T<x> number of seconds.
01030 =CUT
01031 #define besSLEEP(x)           (pSt->sleep(x))
01032 
01033 =POD
01034 =section besCURDIR
01035 =H besCURDIR(x,y)
01036 
01037 This function calls R<file_curdir> to get the current working directory.
01038 =CUT
01039 #define besCURDIR(x,y)        (pSt->curdir((x),(y)))
01040 
01041 =POD
01042 =section besCHDIR
01043 =H besCHDIR(x)
01044 
01045 This function calls R<file_chdir> to set the current working directory.
01046 Be careful changing the working directory because it may prevent the extension
01047 module being used in multi-thread variation of ScriptBasic.
01048 =CUT
01049 #define besCHDIR(x)           (pSt->chdir(x))
01050 
01051 =POD
01052 =section besCHOWN
01053 =H besCHOWN(x,y)
01054 
01055 This macro calls the function R<file_chown>.
01056 =CUT
01057 #define besCHOWN(x,y)         (pSt->chown((x),(y)))
01058 
01059 =POD
01060 =section besSETCREATETIME
01061 =H besSETCREATETIME(x,y)
01062 
01063 This macro calls the function R<file_SetCreateTime>.
01064 =CUT
01065 #define besSETCREATETIME(x,y) (pSt->SetCreateTime((x),(y)))
01066 
01067 =POD
01068 =section besSETMODIFYTIME
01069 =H besSETMODIFYTIME(x,y)
01070 
01071 This macro calls the function R<file_SetModifyTime>.
01072 =CUT
01073 #define besSETMODIFYTIME(x,y) (pSt->SetModifyTime((x),(y)))
01074 
01075 =POD
01076 =section besSETACCESSTIME
01077 =H besSETACCESSTIME(x,y)
01078 
01079 This macro calls the function R<file_SetAccessTime>.
01080 =CUT
01081 #define besSETACCESSTIME(x,y) (pSt->SetAccessTime((x),(y)))
01082 
01083   int (*GetHostName)(char *, long);
01084   int (*GetHost)(char *, struct hostent *);
01085   int (*TcpConnect)(SOCKET *, char *);
01086   int (*TcpSend)(SOCKET, char *, long, int);
01087   int (*TcpRecv)(SOCKET, char *, long, int);
01088   int (*TcpClose)(SOCKET);
01089 
01090 =POD
01091 =section besGETHOSTNAME
01092 =H besGETHOSTNAME(x,y)
01093 
01094 This macro calls the function R<file_GetHostName>.
01095 =CUT
01096 #define besGETHOSTNAME(X,Y) (pSt->GetHostName((X),(Y)))
01097 
01098 =POD
01099 =section besGETHOST
01100 =H besGETHOST(x,y)
01101 
01102 This macro calls the function R<file_GetHost>.
01103 =CUT
01104 #define besGETHOST(X,Y) (pSt->GetHost((X),((Y)))
01105 
01106 =POD
01107 =section besTCPCONNECT
01108 =H besTCPCONNECT(x,y)
01109 
01110 This macro calls the function R<file_TcpConnect>.
01111 =CUT
01112 #define besTCPCONNECT(X,Y) (pSt->TcpConnect((X),(Y)))
01113 
01114 =POD
01115 =section besTCPSEND
01116 =H besTCPSEND(x,y,z)
01117 
01118 This macro calls the function R<file_TcpSend>.
01119 =CUT
01120 #define besTCPSEND(X,Y,Z) (pSt->TcpSend((X),(Y),(Z)))
01121 
01122 =POD
01123 =section besTCPRECV
01124 =H besTCPRECV(x,y,z)
01125 
01126 This macro calls the function R<file_TcpRecv>.
01127 =CUT
01128 #define besTCPRECV(X,Y,Z) (pSt->TcpRecv((X),(Y),(Z)))
01129 
01130 =POD
01131 =section besTCPCLOSE
01132 =H besTCPCLOSE(y)
01133 
01134 This macro calls the function R<file_TcpClose>.
01135 =CUT
01136 #define besTCPCLOSE(Y) (pSt->TcpClose((X))
01137 
01138 =POD
01139 =section besKILLPROC
01140 =H besKILLPROC(x)
01141 
01142 This macro calls the function R<file_KillProc>.
01143 =CUT
01144   int (*KillProc)(long);
01145 #define besKILLPROC(X) (pSt->KillProc((X))
01146 
01147 =POD
01148 =section besGETOWNER
01149 =H besGETOWNER(x,y,z)
01150 
01151 This macro calls the function R<file_GetOwner>.
01152 =CUT
01153   int (*GetOwner)(char *, char *, long);
01154 #define besGETOWNER(X,Y,Z) (pSt->GetOwner((X),(Y),(Z));
01155 
01156 
01157 =POD
01158 =section besCRYPT
01159 =H besCRYPT(x,y,z)
01160 
01161 This macro calls the function R<file_fcrypt>.
01162 =CUT
01163   char *(*Crypt)(char *, char *, char *);
01164 #define besCRYPT(X,Y,Z) (pSt->Crypt((X),(Y),(Z)))
01165 
01166 =POD
01167 =section besMD5INIT
01168 =H besMD5INIT(C)
01169 
01170 This macro calls the function T<MD5Init>.
01171 =CUT
01172   void (*MD5Init)(MD5_CTX *context);
01173 #define besMD5INIT(C) (pSt->MD5Init((C)))
01174 
01175 =POD
01176 =section besMD5UPDATE
01177 =H besMD5UPDATE(C,I,L)
01178 
01179 This macro calls the function T<MD5Update>.
01180 =CUT
01181   void (*MD5Update)(MD5_CTX *context, unsigned char *input, unsigned int inputLen);
01182 #define besMD5UPDATE(C,I,L) (pSt->MD5Update((C),(I),(L)))
01183 
01184 =POD
01185 =section besMD5FINAL
01186 =H besMD5FINAL(D,C)
01187 
01188 This macro calls the function T<MD5Final>.
01189 =CUT
01190   void (*MD5Final)(unsigned char digest[16], MD5_CTX *context);
01191 #define besMD5FINAL(D,C) (pSt->MD5Final((D),(C)))
01192 
01193 =POD
01194 =section besCREATEPROCESS
01195 =H besCREATEPROCESS(X)
01196 
01197 This macro calls the function R<file_CreateProcess>.
01198 =CUT
01199   long (*CreateProcess)(char *);
01200 #define besCREATEPROCESS(X) (pSt->CreateProcess(X))
01201 
01202 =POD
01203 =section besCOPYCOMMANDTABLE
01204 =H besCOPYCOMMANDTABLE(X)
01205 
01206 This macro calls the function R<execute_CopyCommandTable>.
01207 =CUT
01208   int (*CopyCommandTable)(pExecuteObject);
01209 #define besCOPYCOMMANDTABLE (pSt->CopyCommandTable(pSt->pEo))
01210 
01211 =POD
01212 =section besGETCOMMANDBYNAME
01213 =H besGETCOMMANDBYNAME(X,Y)
01214 
01215 This macro calls the function R<execute_GetCommandByName>.
01216 =CUT
01217   long (*GetCommandByName)(pExecuteObject, char *, long);
01218 #define besGETCOMMANDBYNAME(X,Y) (pSt->GetCommandByName(pSt->pEo,(X),(Y)))
01219 
01220   pFixSizeMemoryObject (*DupMortalize)(pMemoryObject,pFixSizeMemoryObject,pMortalList,int *);
01221   pFixSizeMemoryObject (*Evaluate)(pExecuteObject,unsigned long,pMortalList,int *,int);
01222   pFixSizeMemoryObject *(*LeftValue)(pExecuteObject,unsigned long,pMortalList,int *,int);
01223   void (*Immortalize)(pFixSizeMemoryObject,pMortalList);
01224   void (*ReleaseMortals)(pMemoryObject,pMortalList pMortal);
01225 
01226 =POD
01227 =section besEVALUATEEXPRESSION
01228 =H besEVALUATEEXPRESSION(X)
01229 
01230 This macro evaluates an expression and returns the result T<VARIABLE>.
01231 This should usually be used only in extension R<besCOMMAND> commands
01232 and not in R<besFUNCTION>. The result is duplicated and mortalized
01233 and therefore the command is free to modify the
01234 T<VARIABLE>. 
01235 
01236 =CUT
01237 #define besEVALUATEEXPRESSION(x) (pSt->DupMortalize(pEo->pMo,\
01238                                             pSt->Evaluate(pEo,x,_pThisCommandMortals,&iErrorCode,0),\
01239                                             _pThisCommandMortals,\
01240                                             &iErrorCode))
01241 
01242 =POD
01243 =section _besEVALUATEEXPRESSION
01244 =H _besEVALUATEEXPRESSION(X)
01245 
01246 This macro evaluates an expression and returns the result T<VARIABLE>.
01247 This should usually be used only in extension R<besCOMMAND> commands
01248 and not in R<besFUNCTION>. The result is B<NOT> duplicated and B<NOT>
01249 mortalized and therefore the command modifying the T<VARIABLE> may happen
01250 to modify a BASIC variable.
01251 
01252 This should not be done! There are other ways to modify the value of a
01253 variable.
01254 =CUT
01255 #define _besEVALUATEEXPRESSION(x) (pSt->Evaluate(pEo,x,_pThisCommandMortals,&iErrorCode,0))
01256 
01257 =POD
01258 =section _besEVALUATEEXPRESSION_A
01259 =H _besEVALUATEEXPRESSION_A(X)
01260 
01261 This macro evaluates an expression and returns the result T<VARIABLE>.
01262 This macro is the same as R<_besEVALUATEEXPRESSION> except that this
01263 macro may result a whole array.
01264 =CUT
01265 #define _besEVALUATEEXPRESSION_A(x) (pSt->Evaluate(pEo,x,_pThisCommandMortals,&iErrorCode,1))
01266 
01267 =POD
01268 =section besEVALUATELEFTVALUE
01269 =H besEVALUATELEFTVALUE(X)
01270 
01271 This macro evaluates a left value. This left-value is a pointer to a T<VARIABLE>.
01272 If this is not T<NULL> it has to be released first using the macro R<besRELEASE>
01273 and a new immortal value may be assigned to it afterwards.
01274 =CUT
01275 #define besEVALUATELEFTVALUE(x) (pSt->LeftValue(pEo,x,_pThisCommandMortals,&iErrorCode,0))
01276 
01277 =POD
01278 =section besEVALUATELEFTVALUE_A
01279 =H besEVALUATELEFTVALUE_A(X)
01280 
01281 This macro evaluates a left value. This macro is the same as R<besEVALUATELEFTVALUE>
01282 except that this macro may result a whole array.
01283 =CUT
01284 #define besEVALUATELEFTVALUE_A(x) (pSt->LeftValue(pEo,x,_pThisCommandMortals,&iErrorCode,1))
01285 
01286 =POD
01287 =section besIMMORTALIZE
01288 =H besIMMORTALIZE(x)
01289 
01290 This macro calls the function R<memory_Immortalize()>. Use this macro
01291 to immortalize a mortal variable before assigning it to a BASIC variable.
01292 
01293 =CUT
01294 #define besIMMORTALIZE(x) (pSt->Immortalize(x,_pThisCommandMortals))
01295 
01296 =POD
01297 =section besDEREFERENCE
01298 =H besDEREFERENCE(X)
01299 
01300 This macro calls R<execute_DereferenceS>. 
01301 
01302 =CUT
01303   int (*Dereference)(unsigned long, pFixSizeMemoryObject *);
01304 // dereference an argument passed by reference
01305 #define besDEREFERENCE(X) if( pSt->Dereference(pSt->pEo->pMo->maxderef,&(X)) )\
01306                             return COMMAND_ERROR_CIRCULAR;
01307 
01308 =POD
01309 =section besMatchIndex
01310 =H besMatchIndex(X)
01311 
01312 This macro calls R<match_index>.
01313 =CUT
01314   unsigned long (*match_index)(char ch);
01315 #define besMatchIndex(X) (pSt->match_index(X))
01316 
01317 =POD
01318 =section besMatchIniSets
01319 =H besMatchIniSets(X)
01320 
01321 This macro calls R<match_InitSets>.
01322 =CUT
01323   void (*match_InitSets)(pMatchSets pMS);
01324 #define besMatchIniSets(X) (pSt->matchInitSets(X))
01325 
01326 =POD
01327 =section besMatchModifySet
01328 =H besMatchModifySet(X,Y,Z,W,Q)
01329 
01330 This macro calls R<match_ModifySet>.
01331 =CUT
01332   void (*match_ModifySet)(pMatchSets pMS,
01333                           char JokerCharacter,
01334                           int nChars,
01335                           unsigned char *pch,
01336                           int fAction);
01337 #define besMatchModifySet(X,Y,Z,W,Q) (pSt->match_ModifySet((X),(Y),(Z),(W),(Q)))
01338 
01339 =POD
01340 =section besMatchMatch
01341 =H besMatchMatch(P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12)
01342 
01343 This macro calls R<match_match>.
01344 =CUT
01345   int (*match_match)(char *pszPattern,
01346                      unsigned long cbPattern,
01347                      char *pszString,
01348                      unsigned long cbString,
01349                      char **ParameterArray,
01350                      unsigned long *pcbParameterArray,
01351                      char *pszBuffer,
01352                      int cArraySize,
01353                      int cbBufferSize,
01354                      int fCase,
01355                      pMatchSets pThisMatchSets,
01356                      int *iResult);
01357 #define besMatchMatch(P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12)\
01358 (pSt->match_match((P1),(P2),(P3),(P4),(P5),(P6),(P7),(P8),(P9),(P10),(P11),(P12)))
01359 
01360 =POD
01361 =section besMatchCount
01362 =H besMatchCount(X,Y)
01363 
01364 This macro calls R<match_count>.
01365 =CUT
01366   int (*match_count)(char *pszPattern,unsigned long cbPattern);
01367 #define besMatchCount(X,Y) (pSt->match_count((X),(Y)))
01368 
01369 =POD
01370 =section besMatchParameter
01371 =H besMatchParameter(P1,P2,P3,P4,P5,P6,P7)
01372 
01373 This macro calls R<match_parameter>.
01374 =CUT
01375   int (*match_parameter)(char *pszFormat,
01376                          unsigned long cbFormat,
01377                          char **ParameterArray,
01378                          unsigned long *pcbParameterArray,
01379                          char *pszBuffer,
01380                          int cArraySize,
01381                          unsigned long *pcbBufferSize);
01382 #define besMatchParameter(P1,P2,P3,P4,P5,P6,P7)\
01383 (pSt->match_parameter((P1),(P2),(P3),(P4),(P5),(P6),(P7)))
01384 
01385 =POD
01386 =section besMatchSize
01387 =H besMatchSize(P1,P2,P3,P4,P5)
01388 
01389 This macro calls R<match_size()>.
01390 =CUT
01391   int (*match_size)(char *pszFormat,
01392                     unsigned long cbFormat,
01393                     unsigned long *pcbParameterArray,
01394                     int cArraySize,
01395                     int *cbBufferSize);
01396 #define besMatchSize(P1,P2,P3,P4,P5)\
01397 (pSt->match_size((P1),(P2),(P3),(P4),(P5)))
01398 
01399 //
01400 //  Multi-thread functions and locking support
01401 //
01402 
01403 =POD
01404 =section besCreateThread
01405 =H besCreateThread(X,Y,Z)
01406 
01407 This macro calls R<thread_CreateThread>.
01408 =CUT
01409   int (*thread_CreateThread)(PTHREADHANDLE pThread,
01410                       void *pStartFunction,
01411                       void *pThreadParameter);
01412 #define besCreateThread(X,Y,Z) (pSt->thread_CreateThread((X),(Y),(Z)))
01413 
01414 =POD
01415 =section besExitThread
01416 =H besExitThread
01417 
01418 This macro calls R<thread_ExitThread>.
01419 =CUT
01420   void (*thread_ExitThread)();
01421 #define besExitThread() (pSt->thread_ExitThread())
01422 
01423 =POD
01424 =section besInitMutex
01425 =H besInitMutex(X)
01426 
01427 This macro calls R<thread_InitMutex>.
01428 =CUT
01429   void (*thread_InitMutex)(PMUTEX pMutex);
01430 #define besInitMutex(X) (pSt->thread_InitMutex(X))
01431 
01432 =POD
01433 =section besFinishMutex
01434 =H besFinishMutex(X)
01435 
01436 This macro calls R<thread_FinishMutex>.
01437 =CUT
01438   void (*thread_FinishMutex)(PMUTEX pMutex);
01439 #define besFinishMutex(X) (pSt->thread_FinishMutex(X))
01440 
01441 =POD
01442 =section besLockMutex
01443 =H besLockMutex(X)
01444 
01445 This macro calls R<thread_LockMutex>.
01446 =CUT
01447   void (*thread_LockMutex)(PMUTEX pMutex);
01448 #define besLockMutex(X) (pSt->thread_LockMutex(X))
01449 
01450 =POD
01451 =section besUnlockMutex
01452 =H besUnlockMutex(X)
01453 
01454 This macro calls R<thread_UnlockMutex>.
01455 =CUT
01456   void (*thread_UnlockMutex)(PMUTEX pMutex);
01457 #define besUnlockMutex(X) (pSt->thread_UnlockMutex(X))
01458 
01459 =POD
01460 =section besInitSharedLock
01461 =H besInitSharedLock(X)
01462 
01463 This macro calls R<thread_InitLock>.
01464 =CUT
01465   void (*shared_InitLock)(PSHAREDLOCK p);
01466 #define besInitSharedLock(X) (pSt->shared_InitLock(X))
01467 
01468 =POD
01469 =section besFinishSharedLock
01470 =H besFinishSharedLock(X)
01471 
01472 This macro calls R<thread_FinishLock>.
01473 =CUT
01474   void (*shared_FinishLock)(PSHAREDLOCK p);
01475 #define besFinishSharedLock(X) (pSt->shared_FinishLock(X))
01476 
01477 =POD
01478 =section besLockSharedRead
01479 =H besLockSharedRead(X)
01480 
01481 This macro calls R<thread_LockRead>.
01482 =CUT
01483   void (*shared_LockRead)(PSHAREDLOCK p);
01484 #define besLockSharedRead(X) (pSt->shared_LockRead(X))
01485 
01486 =POD
01487 =section besLockSharedWrite
01488 =H besLockSharedWrite(X)
01489 
01490 This macro calls R<thread_LockWrite>.
01491 =CUT
01492   void (*shared_LockWrite)(PSHAREDLOCK p);
01493 #define besLockSharedWrite(X) (pSt->shared_LockWrite(X))
01494 
01495 =POD
01496 =section besUnlockSharedRead
01497 =H besUnlockSharedRead(X)
01498 
01499 This macro calls R<thread_UnlockRead>.
01500 =CUT
01501   void (*shared_UnlockRead)(PSHAREDLOCK p);
01502 #define besUnlockSharedRead(X) (pSt->shared_UnlockRead(X))
01503 
01504 =POD
01505 =section besUnlockSharedWrite
01506 =H besUnlockSharedWrite(X)
01507 
01508 This macro calls R<thread_UnlockWrite>.
01509 =CUT
01510   void (*shared_UnlockWrite)(PSHAREDLOCK p);
01511 #define besUnlockSharedWrite(X) (pSt->shared_UnlockWrite(X))
01512 
01513 
01514 //
01515 //  Using these callback functions a module can even start another BASIC
01516 // program and execute synchronous or asynchronous mode
01517 //
01518 
01519 =POD
01520 =section besScribaNew
01521 =H besScribaNew(F0,F1)
01522 
01523 This macro calls R<scriba_new>
01524 =CUT
01525   pSbProgram (*scriba_new)(void * (*maf)(size_t), void (*mrf)(void *));
01526 #define besScribaNew(F0,F1) (pSt->scriba_New((F0),(F1)))
01527 
01528 =POD
01529 =section besScribaDestroy
01530 =H besScribaDestroy(F0)
01531 
01532 This macro calls R<scriba_destroy>
01533 =CUT
01534   void (*scriba_destroy)(pSbProgram pProgram);
01535 #define besScribaDestroy(F0) (pSt->scriba_Destroy((F0)))
01536 
01537 =POD
01538 =section besScribaNewSbData
01539 =H besScribaNewSbData(F0)
01540 
01541 This macro calls R<scriba_NewSbData>
01542 =CUT
01543   pSbData (*scriba_NewSbData)(pSbProgram pProgram);
01544 #define besScribaNewSbData(F0) (pSt->scriba_NewSbData((F0)))
01545 
01546 =POD
01547 =section besScribaNewSbLong
01548 =H besScribaNewSbLong(F0,F1)
01549 
01550 This macro calls R<scriba_NewSbLong>
01551 =CUT
01552   pSbData (*scriba_NewSbLong)(pSbProgram pProgram, long lInitValue);
01553 #define besScribaNewSbLong(F0,F1) (pSt->scriba_NewSbLong((F0),(F1)))
01554 
01555 =POD
01556 =section besScribaNewSbDouble
01557 =H besScribaNewSbDouble(F0,F1)
01558 
01559 This macro calls R<scriba_NewSbDouble>
01560 =CUT
01561   pSbData (*scriba_NewSbDouble)(pSbProgram pProgram, double dInitValue);
01562 #define besScribaNewSbDouble(F0,F1) (pSt->scriba_NewSbDouble((F0),(F1)))
01563 
01564 =POD
01565 =section besScribaNewSbUndef
01566 =H besScribaNewSbUndef(F0)
01567 
01568 This macro calls R<scriba_NewSbUndef>
01569 =CUT
01570   pSbData (*scriba_NewSbUndef)(pSbProgram pProgram);
01571 #define besScribaNewSbUndef(F0) (pSt->scriba_NewSbUndef((F0)))
01572 
01573 =POD
01574 =section besScribaNewSbString
01575 =H besScribaNewSbString(F0,F1)
01576 
01577 This macro calls R<scriba_NewSbString>
01578 =CUT
01579   pSbData (*scriba_NewSbString)(pSbProgram pProgram, char *pszInitValue);
01580 #define besScribaNewSbString(F0,F1) (pSt->scriba_NewSbString((F0),(F1)))
01581 
01582 =POD
01583 =section besScribaNewSbBytes
01584 =H besScribaNewSbBytes(F0,F1,F2)
01585 
01586 This macro calls R<scriba_NewSbBytes>
01587 =CUT
01588   pSbData (*scriba_NewSbBytes)(pSbProgram pProgram, unsigned long len, unsigned char *pszInitValue);
01589 #define besScribaNewSbBytes(F0,F1,F2) (pSt->scriba_NewSbBytes((F0),(F1),(F2)))
01590 
01591 =POD
01592 =section besScribaDestroySbData
01593 =H besScribaDestroySbData(F0,F1)
01594 
01595 This macro calls R<scriba_DestroySbData>
01596 =CUT
01597   void (*scriba_DestroySbData)(pSbProgram pProgram, pSbData p);
01598 #define besScribaDestroySbData(F0,F1) (pSt->scriba_DestroySbData((F0),(F1)))
01599 
01600 =POD
01601 =section besScribaPurgeReaderMemory
01602 =H besScribaPurgeReaderMemory(F0)
01603 
01604 This macro calls R<scriba_PurgeReaderMemory>
01605 =CUT
01606   void (*scriba_PurgeReaderMemory)(pSbProgram pProgram);
01607 #define besScribaPurgeReaderMemory(F0) (pSt->scriba_PurgeReaderMemory((F0)))
01608 
01609 =POD
01610 =section besScribaPurgeLexerMemory
01611 =H besScribaPurgeLexerMemory(F0)
01612 
01613 This macro calls R<scriba_PurgeLexerMemory>
01614 =CUT
01615   void (*scriba_PurgeLexerMemory)(pSbProgram pProgram);
01616 #define besScribaPurgeLexerMemory(F0) (pSt->scriba_PurgeLexerMemory((F0)))
01617 
01618 =POD
01619 =section besScribaPurgeSyntaxerMemory
01620 =H besScribaPurgeSyntaxerMemory(F0)
01621 
01622 This macro calls R<scriba_PurgeSyntaxerMemory>
01623 =CUT
01624   void (*scriba_PurgeSyntaxerMemory)(pSbProgram pProgram);
01625 #define besScribaPurgeSyntaxerMemory(F0) (pSt->scriba_PurgeSyntaxerMemory((F0)))
01626 
01627 =POD
01628 =section besScribaPurgeBuilderMemory
01629 =H besScribaPurgeBuilderMemory(F0)
01630 
01631 This macro calls R<scriba_PurgeBuilderMemory>
01632 =CUT
01633   void (*scriba_PurgeBuilderMemory)(pSbProgram pProgram);
01634 #define besScribaPurgeBuilderMemory(F0) (pSt->scriba_PurgeBuilderMemory((F0)))
01635 
01636 =POD
01637 =section besScribaPurgeExecuteMemory
01638 =H besScribaPurgeExecuteMemory(F0)
01639 
01640 This macro calls R<scriba_PurgeExecuteMemory>
01641 =CUT
01642   void (*scriba_PurgeExecuteMemory)(pSbProgram pProgram);
01643 #define besScribaPurgeExecuteMemory(F0) (pSt->scriba_PurgeExecuteMemory((F0)))
01644 
01645 =POD
01646 =section besScribaSetFileName
01647 =H besScribaSetFileName(F0,F1)
01648 
01649 This macro calls R<scriba_SetFileName>
01650 =CUT
01651   int (*scriba_SetFileName)(pSbProgram pProgram, char *pszFileName);
01652 #define besScribaSetFileName(F0,F1) (pSt->scriba_SetFileName((F0),(F1)))
01653 
01654 =POD
01655 =section besScribaLoadConfiguration
01656 =H besScribaLoadConfiguration(F0,F1)
01657 
01658 This macro calls R<scriba_LoadConfiguration>
01659 =CUT
01660   int (*scriba_LoadConfiguration)(pSbProgram pProgram, char *pszForcedConfigurationFileName);
01661 #define besScribaLoadConfiguration(F0,F1) (pSt->scriba_LoadConfiguration((F0),(F1)))
01662 
01663 =POD
01664 =section besScribaInheritConfiguration
01665 =H besScribaInheritConfiguration(F0,F1)
01666 
01667 This macro calls R<scriba_InheritConfiguration>
01668 =CUT
01669   int (*scriba_InheritConfiguration)(pSbProgram pProgram, pSbProgram pFrom);
01670 #define besScribaInheritConfiguration(F0,F1) (pSt->scriba_InheritConfiguration((F0),(F1)))
01671 
01672 =POD
01673 =section besScribaSetCgiFlag
01674 =H besScribaSetCgiFlag(F0)
01675 
01676 This macro calls R<scriba_SetCgiFlag>
01677 =CUT
01678   void (*scriba_SetCgiFlag)(pSbProgram pProgram);
01679 #define besScribaSetCgiFlag(F0) (pSt->scriba_SetCgiFlag((F0)))
01680 
01681 =POD
01682 =section besScribaSetReportFunction
01683 =H besScribaSetReportFunction(F0,F1)
01684 
01685 This macro calls R<scriba_SetReportFunction>
01686 =CUT
01687   void (*scriba_SetReportFunction)(pSbProgram pProgram, void *fpReportFunction);
01688 #define besScribaSetReportFunction(F0,F1) (pSt->scriba_SetReportFunction((F0),(F1)))
01689 
01690 =POD
01691 =section besScribaSetReportPointer
01692 =H besScribaSetReportPointer(F0,F1)
01693 
01694 This macro calls R<scriba_SetReportPointer>
01695 =CUT
01696   void (*scriba_SetReportPointer)(pSbProgram pProgram, void *pReportPointer);
01697 #define besScribaSetReportPointer(F0,F1) (pSt->scriba_SetReportPointer((F0),(F1)))
01698 
01699 =POD
01700 =section besScribaSetStdin
01701 =H besScribaSetStdin(F0,F1)
01702 
01703 This macro calls R<scriba_SetStdin>
01704 =CUT
01705   void (*scriba_SetStdin)(pSbProgram pProgram, void *fpStdinFunction);
01706 #define besScribaSetStdin(F0,F1) (pSt->scriba_SetStdin((F0),(F1)))
01707 
01708 =POD
01709 =section besScribaSetStdout
01710 =H besScribaSetStdout(F0,F1)
01711 
01712 This macro calls R<scriba_SetStdout>
01713 =CUT
01714   void (*scriba_SetStdout)(pSbProgram pProgram, void *fpStdoutFunction);
01715 #define besScribaSetStdout(F0,F1) (pSt->scriba_SetStdout((F0),(F1)))
01716 
01717 =POD
01718 =section besScribaSetEmbedPointer
01719 =H besScribaSetEmbedPointer(F0,F1)
01720 
01721 This macro calls R<scriba_SetEmbedPointer>
01722 =CUT
01723   void (*scriba_SetEmbedPointer)(pSbProgram pProgram, void *pEmbedder);
01724 #define besScribaSetEmbedPointer(F0,F1) (pSt->scriba_SetEmbedPointer((F0),(F1)))
01725 
01726 =POD
01727 =section besScribaSetEnvironment
01728 =H besScribaSetEnvironment(F0,F1)
01729 
01730 This macro calls R<scriba_SetEnvironment>
01731 =CUT
01732   void (*scriba_SetEnvironment)(pSbProgram pProgram, void *fpEnvirFunction);
01733 #define besScribaSetEnvironment(F0,F1) (pSt->scriba_SetEnvironment((F0),(F1)))
01734 
01735 =POD
01736 =section besScribaLoadBinaryProgram
01737 =H besScribaLoadBinaryProgram(F0)
01738 
01739 This macro calls R<scriba_LoadBinaryProgram>
01740 =CUT
01741   int (*scriba_LoadBinaryProgram)(pSbProgram pProgram);
01742 #define besScribaLoadBinaryProgram(F0) (pSt->scriba_LoadBinaryProgram((F0)))
01743 
01744 =POD
01745 =section besScribaInheritBinaryProgram
01746 =H besScribaInheritBinaryProgram(F0,F1)
01747 
01748 This macro calls R<scriba_InheritBinaryProgram>
01749 =CUT
01750   int (*scriba_InheritBinaryProgram)(pSbProgram pProgram, pSbProgram pFrom);
01751 #define besScribaInheritBinaryProgram(F0,F1) (pSt->scriba_InheritBinaryProgram((F0),(F1)))
01752 
01753 =POD
01754 =section besScribaReadSource
01755 =H besScribaReadSource(F0)
01756 
01757 This macro calls R<scriba_ReadSource>
01758 =CUT
01759   int (*scriba_ReadSource)(pSbProgram pProgram);
01760 #define besScribaReadSource(F0) (pSt->scriba_ReadSource((F0)))
01761 
01762 =POD
01763 =section besScribaDoLexicalAnalysis
01764 =H besScribaDoLexicalAnalysis(F0)
01765 
01766 This macro calls R<scriba_DoLexicalAnalysis>
01767 =CUT
01768   int (*scriba_DoLexicalAnalysis)(pSbProgram pProgram);
01769 #define besScribaDoLexicalAnalysis(F0) (pSt->scriba_DoLexicalAnalysis((F0)))
01770 
01771 =POD
01772 =section besScribaDoSyntaxAnalysis
01773 =H besScribaDoSyntaxAnalysis(F0)
01774 
01775 This macro calls R<scriba_DoSyntaxAnalysis>
01776 =CUT
01777   int (*scriba_DoSyntaxAnalysis)(pSbProgram pProgram);
01778 #define besScribaDoSyntaxAnalysis(F0) (pSt->scriba_DoSyntaxAnalysis((F0)))
01779 
01780 =POD
01781 =section besScribaBuildCode
01782 =H besScribaBuildCode(F0)
01783 
01784 This macro calls R<scriba_BuildCode>
01785 =CUT
01786   int (*scriba_BuildCode)(pSbProgram pProgram);
01787 #define besScribaBuildCode(F0) (pSt->scriba_BuildCode((F0)))
01788 
01789 =POD
01790 =section besScribaIsFileBinaryFormat
01791 =H besScribaIsFileBinaryFormat(F0)
01792 
01793 This macro calls R<scriba_IsFileBinaryFormat>
01794 =CUT
01795   int (*scriba_IsFileBinaryFormat)(pSbProgram pProgram);
01796 #define besScribaIsFileBinaryFormat(F0) (pSt->scriba_IsFileBinaryFormat((F0)))
01797 
01798 =POD
01799 =section besScribaGetCacheFileName
01800 =H besScribaGetCacheFileName(F0)
01801 
01802 This macro calls R<scriba_GetCacheFileName>
01803 =CUT
01804   int (*scriba_GetCacheFileName)(pSbProgram pProgram);
01805 #define besScribaGetCacheFileName(F0) (pSt->scriba_GetCacheFileName((F0)))
01806 
01807 =POD
01808 =section besScribaUseCacheFile
01809 =H besScribaUseCacheFile(F0)
01810 
01811 This macro calls R<scriba_UseCacheFile>
01812 =CUT
01813   int (*scriba_UseCacheFile)(pSbProgram pProgram);
01814 #define besScribaUseCacheFile(F0) (pSt->scriba_UseCacheFile((F0)))
01815 
01816 =POD
01817 =section besScribaSaveCacheFile
01818 =H besScribaSaveCacheFile(F0)
01819 
01820 This macro calls R<scriba_SaveCacheFile>
01821 =CUT
01822   int (*scriba_SaveCacheFile)(pSbProgram pProgram);
01823 #define besScribaSaveCacheFile(F0) (pSt->scriba_SaveCacheFile((F0)))
01824 
01825 =POD
01826 =section besScribaRunExternalPreprocessor
01827 =H besScribaRunExternalPreprocessor(F0,F1)
01828 
01829 This macro calls R<scriba_RunExternalPreprocessor>
01830 =CUT
01831   int (*scriba_RunExternalPreprocessor)(pSbProgram pProgram, char **ppszArgPreprocessor);
01832 #define besScribaRunExternalPreprocessor(F0,F1) (pSt->scriba_RunExternalPreprocessor((F0),(F1)))
01833 
01834 =POD
01835 =section besScribaSaveCode
01836 =H besScribaSaveCode(F0,F1)
01837 
01838 This macro calls R<scriba_SaveCode>
01839 =CUT
01840   int (*scriba_SaveCode)(pSbProgram pProgram, char *pszCodeFileName);
01841 #define besScribaSaveCode(F0,F1) (pSt->scriba_SaveCode((F0),(F1)))
01842 
01843 =POD
01844 =section besScribaSaveCCode
01845 =H besScribaSaveCCode(F0,F1)
01846 
01847 This macro calls R<scriba_SaveCCode>
01848 =CUT
01849   void (*scriba_SaveCCode)(pSbProgram pProgram, char *pszCodeFileName);
01850 #define besScribaSaveCCode(F0,F1) (pSt->scriba_SaveCCode((F0),(F1)))
01851 
01852 =POD
01853 =section besScribaLoadSourceProgram
01854 =H besScribaLoadSourceProgram(F0)
01855 
01856 This macro calls R<scriba_LoadSourceProgram>
01857 =CUT
01858   int (*scriba_LoadSourceProgram)(pSbProgram pProgram);
01859 #define besScribaLoadSourceProgram(F0) (pSt->scriba_LoadSourceProgram((F0)))
01860 
01861 =POD
01862 =section besScribaRun
01863 =H besScribaRun(F0,F1)
01864 
01865 This macro calls R<scriba_Run>
01866 =CUT
01867   int (*scriba_Run)(pSbProgram pProgram, char *pszCommandLineArgument);
01868 #define besScribaRun(F0,F1) (pSt->scriba_Run((F0),(F1)))
01869 
01870 =POD
01871 =section besScribaNoRun
01872 =H besScribaNoRun(F0)
01873 
01874 This macro calls R<scriba_NoRun>
01875 =CUT
01876   int (*scriba_NoRun)(pSbProgram pProgram);
01877 #define besScribaNoRun(F0) (pSt->scriba_NoRun((F0)))
01878 
01879 =POD
01880 =section besScribaResetVariables
01881 =H besScribaResetVariables(F0)
01882 
01883 This macro calls R<scriba_ResetVariables>
01884 =CUT
01885   void (*scriba_ResetVariables)(pSbProgram pProgram);
01886 #define besScribaResetVariables(F0) (pSt->scriba_ResetVariables((F0)))
01887 
01888 =POD
01889 =section besScribaCall
01890 =H besScribaCall(F0,F1)
01891 
01892 This macro calls R<scriba_Call>
01893 =CUT
01894   int (*scriba_Call)(pSbProgram pProgram, unsigned long lEntryNode);
01895 #define besScribaCall(F0,F1) (pSt->scriba_Call((F0),(F1)))
01896 
01897 =POD
01898 =section besScribaCallArg
01899 =H besScribaCallArg(F0,F1,F2,F3)
01900 
01901 This macro calls R<scriba_CallArg>
01902 =CUT
01903   int (*scriba_CallArg)(pSbProgram pProgram, unsigned long lEntryNode, char *pszFormat, ...);
01904 #define besScribaCallArg(F0,F1,F2,F3) (pSt->scriba_CallArg((F0),(F1),(F2),(F3)))
01905 
01906 =POD
01907 =section besScribaDestroySbArgs
01908 =H besScribaDestroySbArgs(F0,F1,F2)
01909 
01910 This macro calls R<scriba_DestroySbArgs>
01911 =CUT
01912   void (*scriba_DestroySbArgs)(pSbProgram pProgram, pSbData Args, unsigned long cArgs);
01913 #define besScribaDestroySbArgs(F0,F1,F2) (pSt->scriba_DestroySbArgs((F0),(F1),(F2)))
01914 
01915 =POD
01916 =section besScribaNewSbArgs
01917 =H besScribaNewSbArgs(F0,F1,F2)
01918 
01919 This macro calls R<scriba_NewSbArgs>
01920 =CUT
01921   pSbData (*scriba_NewSbArgs)(pSbProgram pProgram, char *pszFormat, ...);
01922 #define besScribaNewSbArgs(F0,F1,F2) (pSt->scriba_NewSbArgs((F0),(F1),(F2)))
01923 
01924 =POD
01925 =section besScribaCallArgEx
01926 =H besScribaCallArgEx(F0,F1,F2,F3,F4)
01927 
01928 This macro calls R<scriba_CallArgEx>
01929 =CUT
01930   int (*scriba_CallArgEx)(pSbProgram pProgram, unsigned long lEntryNode, pSbData ReturnValue, unsigned long cArgs, pSbData Args);
01931 #define besScribaCallArgEx(F0,F1,F2,F3,F4) (pSt->scriba_CallArgEx((F0),(F1),(F2),(F3),(F4)))
01932 
01933 =POD
01934 =section besScribaLookupFunctionByName
01935 =H besScribaLookupFunctionByName(F0,F1)
01936 
01937 This macro calls R<scriba_LookupFunctionByName>
01938 =CUT
01939   long (*scriba_LookupFunctionByName)(pSbProgram pProgram, char *pszFunctionName);
01940 #define besScribaLookupFunctionByName(F0,F1) (pSt->scriba_LookupFunctionByName((F0),(F1)))
01941 
01942 =POD
01943 =section besScribaLookupVariableByName
01944 =H besScribaLookupVariableByName(F0,F1)
01945 
01946 This macro calls R<scriba_LookupVariableByName>
01947 =CUT
01948   long (*scriba_LookupVariableByName)(pSbProgram pProgram, char *pszVariableName);
01949 #define besScribaLookupVariableByName(F0,F1) (pSt->scriba_LookupVariableByName((F0),(F1)))
01950 
01951 =POD
01952 =section besScribaGetVariableType
01953 =H besScribaGetVariableType(F0,F1)
01954 
01955 This macro calls R<scriba_GetVariableType>
01956 =CUT
01957   long (*scriba_GetVariableType)(pSbProgram pProgram, long lSerial);
01958 #define besScribaGetVariableType(F0,F1) (pSt->scriba_GetVariableType((F0),(F1)))
01959 
01960 =POD
01961 =section besScribaGetVariable
01962 =H besScribaGetVariable(F0,F1,F2)
01963 
01964 This macro calls R<scriba_GetVariable>
01965 =CUT
01966   int (*scriba_GetVariable)(pSbProgram pProgram, long lSerial, pSbData *pVariable);
01967 #define besScribaGetVariable(F0,F1,F2) (pSt->scriba_GetVariable((F0),(F1),(F2)))
01968 
01969 =POD
01970 =section besScribaSetVariable
01971 =H besScribaSetVariable(F0,F1,F2,F3,F4,F5,F6)
01972 
01973 This macro calls R<scriba_SetVariable>
01974 =CUT
01975   int (*scriba_SetVariable)(pSbProgram pProgram, long lSerial, int type, long lSetValue, double dSetValue, char *pszSetValue, unsigned long size);
01976 #define besScribaSetVariable(F0,F1,F2,F3,F4,F5,F6) (pSt->scriba_SetVariable((F0),(F1),(F2),(F3),(F4),(F5),(F6)))
01977 
01978 =POD
01979 =section besLogState
01980 =H besLogState(X)
01981 
01982 This macro calls R<log_state>
01983 =CUT
01984   int (*log_state)(ptLogger pLOG);
01985 #define besLogState(X) (pSt->log_state(X))
01986 
01987 
01988 =POD
01989 =section besLogInit
01990 =H besLogInit(F0,F1,F2,F3,F4,F5)
01991 
01992 This macro calls R<log_init>
01993 =CUT
01994   int (*log_init)(ptLogger pLOG,
01995                   void *(*memory_allocating_function)(size_t, void *),
01996                   void (*memory_releasing_function)(void *, void *),
01997                   void *pMemorySegment,
01998                   char *pszLogFileName,
01999                   int iLogType);
02000 #define besLogInit(F0,F1,F2,F3,F4,F5) (pSt->log_init((F0),(F1),(F2),(F3),(F4),(F5)))
02001 
02002 =POD
02003 =section besLogPrintf
02004 =H besLogPrintf(pLOG,FORMAT, ...)
02005 
02006 This macro calls R<log_printf>
02007 =CUT
02008   int (*log_printf)(ptLogger pLOG,
02009                     char *pszFormat,
02010                     ...);
02011 #define besLogPrintf pSt->log_printf
02012 
02013 =POD
02014 =section besLogShutdown
02015 =H besLogShutdown(pLOG)
02016 
02017 This macro calls R<log_shutdown>
02018 =CUT
02019   int (*log_shutdown)(ptLogger pLOG);
02020 #define besLogShutdown(X) (pSt->log_shutdown(X))
02021 
02022 =POD
02023 =section besHandleGetHandle
02024 =H besHandleGetHandle(X,Y)
02025 
02026 This macro calls R<handle_GetHandle>. The memory segment used by the
02027 macro is the default.
02028 
02029 Example:
02030 
02031 =verbatim
02032   void *H;
02033   int i;
02034     ....
02035   i = besHandleGetPointer(H,pointer);
02036 =noverbatim
02037 
02038 =CUT
02039   unsigned long (*handle_GetHandle)(void **pHandle,
02040                                     void *pMEM,
02041                                     void *pointer);
02042 #define besHandleGetHandle(X,Y) (pSt->handle_GetHandle(&(X),pSt->pEo->pMemorySegment,(Y)))
02043 
02044 =POD
02045 =section besHandleGetPointer
02046 =H besHandleGetPointer(X,Y)
02047 
02048 This macro calls R<handle_GetPointer>. The memory segment used by the
02049 macro is the default.
02050 
02051 Example:
02052 
02053 =verbatim
02054   void *H,*pointer;
02055     ....
02056   pointer = besHandleGetPointer(H,handle);
02057 =noverbatim
02058 
02059 =CUT
02060   void *(*handle_GetPointer)(void **pHandle,
02061                              unsigned long handle);
02062 #define besHandleGetPointer(X,Y) (pSt->handle_GetPointer( &(X),(Y)))
02063 
02064 =POD
02065 =section besHandleFreeHandle
02066 =H besHandleFreeHandle(X,Y)
02067 
02068 This macro calls R<handle_FreeHandle>
02069 =CUT
02070   void (*handle_FreeHandle)(void **pHandle,
02071                             unsigned long handle);
02072 #define besHandleFreeHandle(X,Y) (pSt->handle_FreeHandle( &(X), (Y)))
02073 
02074 =POD
02075 =section besHandleDestroyHandleArray
02076 =H besHandleDestroyHandleArray(X)
02077 
02078 This macro calls R<handle_DestroyHandleArray>
02079 =CUT
02080   void (*handle_DestroyHandleArray)(void **pHandle,
02081                                     void *pMEM);
02082 #define besHandleDestroyHandleArray(X) (pSt->handle_DestroyHandleArray( &(X),pSt->pEo->pMemorySegment))
02083 
02084   int (*basext_GetArgsF)(pSupportTable pSt,
02085                       pFixSizeMemoryObject pParameters,
02086                       char *pszFormat,
02087                       ...
02088                       );
02089 
02090 #define besGETARGS pSt->basext_GetArgsF(pSt,pParameters,
02091 #define besGETARGE );
02092 
02093 =POD
02094 =section besARGUMENTS
02095 
02096 Use this macro to declare and process the arguments of a besFUNCTION. The
02097 macro should be placed right after the variable declaration and before
02098 any other code, because it declares the variable T<iError>.
02099 
02100 The macro calls the function R<basext_GetArgsF> and returns with error in case
02101 some error has happened during the parsing of the arguments.
02102 
02103 Example:
02104 
02105 =verbatim
02106 besARGUMENTS("llzz")
02107 &my_first_long , &my_second_long, &my_string1 , &my_string2
02108 besARGEND
02109 =noverbatim
02110 =CUT
02111 #define besARGUMENTS(X) int iError; iError = pSt->basext_GetArgsF(pSt,pParameters,(X),
02112 #define besARGEND ); if( iError )return iError;
02113 
02114   void *(*InitSegment)(void * (*maf)(size_t),
02115                             void   (*mrf)(void *));
02116   long (*SegmentLimit)(void *p,unsigned long NewMaxSize);
02117   void (*FreeSegment)(void *p);
02118   void (*FinishSegment)(void *p);
02119 
02120 =POD
02121 =section besINIT_SEGMENT
02122 =H besINIT_SEGMENT(MAF,MRF)
02123 This macro calls the function R<alloc_InitSegment>
02124 =CUT
02125 #define besINIT_SEGMENT(MAF,MRF) (pSt->InitSegment(MAF,MRF))
02126 
02127 =POD
02128 =section besSEGMENT_LIMIT
02129 =H besSEGMENT_LIMIT(PMS,L)
02130 This macro calls the function R<alloc_SegmentLimit>
02131 =CUT
02132 #define besSEGMENT_LIMIT(PMS,L) (pSt->SegmentLimit(PMS,L))
02133 
02134 =POD
02135 =section besFREE_SEGMENT
02136 =H besFREE_SEGMENT(PMS)
02137 This macro calls the function R<alloc_FreeSegment>
02138 =CUT
02139 #define besFREE_SEGMENT(PMS) (pSt->FreeSegment(PMS))
02140 
02141 =POD
02142 =section besFINISH_SEGMENT
02143 =H besFINISH_SEGMENT(PMS)
02144 This macro calls the function R<alloc_FinishSegment>
02145 =CUT
02146 #define besFINISH_SEGMENT(PMS) (pSt->FinishSegment(PMS))
02147 
02148   } SupportTable
02149 #ifndef PSUPPORTTABLE
02150   , *pSupportTable
02151 #endif
02152   ;
02153 
02154 // The support table contains the function pointers and other support information
02155 // that the modules may need. This support table is common for all modules.
02156 // The pointer ModuleInternal points to a NULL initialized pointer. This pointer
02157 // is unique for each module and is guaranteed to be available and guaranteed
02158 // be unchanged. The module may use this pointer to store internal non-volatile
02159 // data.
02160 
02161 =POD
02162 =section besFUNCTION
02163 =H besFUNCTION(X)
02164 
02165 Use this macro to start an extension module interface function. The macro argument T<X>
02166 is the name of the function as it is used in the BASIC statement
02167 
02168 =verbatim
02169 declare sub ::Function alias "X" lib "module"
02170 =noverbatim
02171 
02172 This macro handles all system dependant function decoration declarations and
02173 declares the argument variables. Altough it is possible to name the argument
02174 variables in a different way it is strongly recommended that the programmer
02175 writing external module uses this macro and thus uses the argument names, because
02176 the T<besXXX> macros rely on these variable names.
02177 =CUT
02178 #define besFUNCTION(X) DLL_EXPORT int X(pSupportTable pSt, \
02179                           void **ppModuleInternal, \
02180                           pFixSizeMemoryObject pParameters, \
02181                           pFixSizeMemoryObject *pReturnValue){\
02182                           pExecuteObject pEo=NULL;
02183 
02184 =POD
02185 =section besASSERT_FUNCTION
02186 =H besASSERT_FUNCTION
02187 
02188 Use this macro to check inside a besFUNCTION that the function was called
02189 as a sub and not command. If the include file declares the function as
02190 
02191 =verbatim
02192 declare command XXX alias "xxx" lib "library"
02193 =noverbatim
02194 
02195 instead of
02196 
02197 =verbatim
02198 declare sub XXX alias "xxx" lib "library"
02199 =noverbatim
02200 
02201 then you can not execute the rest of the code safely. This macro returns
02202 with the error code T<COMMAND_ERROR_BAD_CALL> if the function was
02203 declared the wrong way.
02204 =CUT
02205 #define besASSERT_FUNCTION if( pSt == NULL || pSt->pEo == NULL || pSt->pEo->pST != pSt ){\
02206                               pEo = (pExecuteObject)pSt;\
02207                               pEo->ErrorCode = COMMAND_ERROR_BAD_CALL;\
02208                               return 0;\
02209                               }
02210 
02211 =POD
02212 =section besCOMMAND
02213 =H besCOMMAND(X)
02214 
02215 Use this macro to start an extension module interface command. The macro argument T<X>
02216 is the name of the command as it is used in the BASIC statement
02217 
02218 =verbatim
02219 declare command ::Function alias "X" lib "module"
02220 =noverbatim
02221 
02222 This macro handles all system dependant function decoration declarations and
02223 declares the argument variables. Altough it is possible to name the argument
02224 variables in a different way it is strongly recommended that the programmer
02225 writing external module uses this macro and thus uses the argument names, because
02226 the T<besXXX> macros rely on these variable names.
02227 
02228 In addition to the arguments this macro also declares some mandatory local variables
02229 thatshould be used in most of the module implemented commands and are used by some
02230 macros.
02231 
02232 Note that interface functions get their arguments already evaluated while interface
02233 commands may decide if an argument is evaluated or not, or even evaluated multiple
02234 times.
02235 =CUT
02236 #define besCOMMAND(x) DLL_EXPORT int x(pExecuteObject pEo,void **ppModuleInternal){\
02237                         MortalList _ThisCommandMortals=NULL;\
02238                         pMortalList _pThisCommandMortals = &_ThisCommandMortals;\
02239                         unsigned long _ActualNode= pEo && pEo->pST && pEo->pST->pEo == pEo ? PROGRAMCOUNTER : 0;\
02240                         int iErrorCode;\
02241                         pSupportTable pSt= pEo ? pEo->pST : NULL;
02242 
02243 =POD
02244 =section besASSERT_COMMAND
02245 =H besASSERT_COMMAND
02246 
02247 Use this macro to check inside a besCOMMAND that the command was called
02248 as a command. If the include file declares the function as
02249 
02250 =verbatim
02251 declare sub XXX alias "xxx" lib "library"
02252 =noverbatim
02253 
02254 instead of
02255 
02256 =verbatim
02257 declare command XXX alias "xxx" lib "library"
02258 =noverbatim
02259 
02260 then you can not execute the rest of the code safely. This macro returns
02261 with the error code T<COMMAND_ERROR_BAD_CALL> if the function was
02262 declared the wrong way.
02263 
02264 =CUT
02265 #define besASSERT_COMMAND if( pEo == NULL || pEo->pST == NULL || pEo->pST->pEo != pEo )return COMMAND_ERROR_BAD_CALL;
02266 
02267 
02268 =POD
02269 =section besEND_COMMAND
02270 =H besEND_COMMAND
02271 
02272 Use this macro to finish an extension module command.
02273 
02274 Note that this macro uses the macro T<FINISH> that is empty by default. However a command
02275 may decide to perform some action after the mortals are released. To do so the macro
02276 T<FINISH> can be redefined.
02277 =CUT
02278 #define besEND_COMMAND goto _FunctionFinishLabel;\ // this is to avoid warnings on unrefereced labels
02279             _FunctionFinishLabel: \
02280             pSt->ReleaseMortals(pEo->pMo,&_ThisCommandMortals);\
02281             iErrorCode = 0;\ // this is to avoid warnings on unreferenced variable
02282             FINISH;\
02283             return 0;\
02284             }
02285 
02286 =POD
02287 =section besARGNR
02288 =H besARGNR
02289 
02290 This macro returns the number of arguments passed to the extension module interface function.
02291 =CUT
02292 #define besARGNR       (pParameters ? pParameters->ArrayHighLimit : 0)
02293 
02294 =POD
02295 =section besARGUMENT
02296 =H besARGUMENT(X)
02297 To access the function arguments the module can use the macro. The argument is the
02298 ordinal number of the argument starting from 1. You can overindex the arguments. In
02299 that case the macro value is T<NULL>.
02300 
02301 Note that this macro can only be used in interface functions and not in interface commands.
02302 =CUT
02303 #define besARGUMENT(X) ((X) <= besARGNR ? pParameters->Value.aValue[(X)-1]: NULL)
02304 
02305 =POD
02306 =section besPARAMETERLIST
02307 =H besPARAMETERLIST
02308 
02309 Get the ordinal number of the node, where the parameter list starts for the
02310 extenal module interface command. This macro should not be used in interface
02311 functions only in interface commands.
02312 =CUT
02313 #define besPARAMETERLIST (pEo->OperatorNode)
02314 
02315 =POD
02316 =section besLEFTVALUE
02317 =H besLEFTVALUE(X,Y)
02318 
02319 Use this macro to evaluate an argument as left value in an interface command.
02320 This macro should not be used in interface functions.
02321 =CUT
02322 #define besLEFTVALUE(X,Y) do{if( TYPE((X)) == VTYPE_REF ){\
02323                                __refcount_ = pSt->pEo->pMo->maxderef;\
02324                                Y=(X)->Value.aValue;\
02325                                while( *(Y) && TYPE(*(Y))== VTYPE_REF ){\
02326                                  (Y=(*(Y))->Value.aValue);\
02327                                  if( ! __refcount_ -- ){\
02328                                    return COMMAND_ERROR_CIRCULAR;\
02329                                    }\
02330                                  }\
02331                                }else Y=NULL;}while(0)
02332 
02333 // define the name of the function which is called to negotiate the version
02334 #define MODULE_VERSIONER   "versmodu"
02335 // define the name of the function which is called to initialize the module
02336 #define MODULE_INITIALIZER "bootmodu"
02337 // define the function name which is called when the module is not used by the
02338 // interpreter anymore
02339 #define MODULE_FINALIZER   "finimodu"
02340 // define the function name which is called when the module is shut-down
02341 #define MODULE_SHUTDOWN    "shutmodu"
02342 // define the autoloader function which is called when a function is not
02343 // found in the DLL or so file
02344 #define MODULE_AUTOLOADER  "automodu"
02345 // define the function name which is called in multi thread implementation
02346 // to decide whether to call dynlolib_FreeLibrary or not
02347 // thus helping to keep a module inside a process even if there is no any
02348 // current threads using it
02349 #define MODULE_KEEPER      "keepmodu"
02350 // define the error message function that results an error message whenever an
02351 // error code is returned by the module
02352 #define MODULE_ERRMSG      "emsgmodu"
02353 
02354 =POD
02355 =section besVERSION_NEGOTIATE
02356 =H besVERSION_NEGOTIATE
02357 
02358 Use this macro to start the module interface version negotiation function. The simplest
02359 example is:
02360 
02361 =verbatim
02362 besVERSION_NEGOTIATE
02363   return (int)INTERFACE_VERSION;
02364 besEND
02365 =noverbatim
02366 =CUT
02367 #define besVERSION_NEGOTIATE int DLL_EXPORT versmodu(int Version, char *pszVariation, void **ppModuleInternal){
02368 
02369 =POD
02370 =section besSUB_START
02371 =H besSUB_START
02372 
02373 Use this macro to start the module initialization function.
02374 
02375 =verbatim
02376 besSUB_START
02377   ....
02378 besEND
02379 =noverbatim
02380 =CUT
02381 #define besSUB_START  besFUNCTION(bootmodu)
02382 
02383 =POD
02384 =section besSUB_FINISH
02385 =H besSUB_FINISH
02386 
02387 Use this macro to start the module finalization function.
02388 
02389 =verbatim
02390 besSUB_FINISH
02391   ....
02392 besEND
02393 =noverbatim
02394 =CUT
02395 #define besSUB_FINISH besFUNCTION(finimodu)
02396 
02397 =POD
02398 =section besSUB_ERRMSG
02399 =H besSUB_ERRMSG
02400 Use this macro to start the error message function of an external module.
02401 
02402 =verbatim
02403 besSUB_ERRMSG
02404   ....
02405 besEND
02406 =noverbatim
02407 =CUT
02408 #define besSUB_ERRMSG char DLL_EXPORT * emsgmodu(pSupportTable pSt, \
02409                                                  void **ppModuleInternal, \
02410                                                  int iError){
02411 =POD
02412 =section besSUB_PROCESS_START
02413 =H besSUB_PROCESS_START
02414 
02415 Use this macro to start the function that will be invoked when the module is loaded by the
02416 operating system. This is T<_init> under UNIX and T<DllMain> under Windows NT. Using this
02417 macro the programmer can hide the OS dependant code.
02418 =CUT
02419 #if STATIC_LINK
02420 #define besSUB_PROCESS_START static int _init(){
02421 #else
02422 #define besSUB_PROCESS_START int _init(){
02423 #endif
02424 
02425 =POD
02426 =section besSUB_PROCESS_FINISH
02427 =H besSUB_PROCESS_FINISH
02428 
02429 Use this macro to start the function that will be invoked when the module is unloaded by the
02430 operating system. This is T<_fini> under UNIX and T<DllMain> under Windows NT. Using this
02431 macro the programmer can hide the OS dependant code.
02432 =CUT
02433 #if STATIC_LINK
02434 #define besSUB_PROCESS_FINISH static int _fini(){
02435 #else
02436 #define besSUB_PROCESS_FINISH int _fini(){
02437 #endif
02438 
02439 =POD
02440 =section besSUB_KEEP
02441 =H besSUB_KEEP
02442 
02443 Use this macro to start the module kepper function. This function should return 1 when the
02444 module wants to remain in memory and 0 when the module can be unloaded.
02445 =CUT
02446 #define besSUB_KEEP int DLL_EXPORT keepmodu(){
02447 
02448 =POD
02449 =section besSUB_SHUTDOWN
02450 =H besSUB_SHUTDOWN
02451 
02452 Use this macro to start a module shutdown function.
02453 
02454 This shutdown function is called before a module is unloaded from the process 
02455 space. The function is similar to R<besSUB_FINISH>. That function is called when
02456 the interpreter finishes. When there are many interpreter threads in a single process
02457 that uses the module the function R<besSUB_FINISH> is called each time an
02458 interpreter finishes. The function R<besSUB_SHUTDOWN> is called only once, before the
02459 interpreter unloads the extesion from memory.
02460 
02461 The difference between T<besSUB_SHUTDOWN> and R<besSUB_PROCESS_FINISH> is that T<besSUB_SHUTDOWN>
02462 is called by the interpreter, R<besSUB_PROCESS_FINISH> is called by the operating system.
02463 T<besSUB_SHUTDOWN> can access the support functions because it gets the T<pSt> argument,
02464 R<besSUB_PROCESS_FINISH> can not access these functions.
02465 
02466 When a single thread interpreter finishes it first calls the function R<besSUB_FINISH> to unload
02467 the module and after that it calls T<besSUB_SHUTDOWN>.
02468 
02469 This is not an error if a module does not implement these functions.
02470 
02471 The function should return T<COMMAND_ERROR_SUCCESS> if the module has no remaining activity and
02472 is ready to be unloaded.
02473 
02474 The function should return T<COMMAND_ERROR_STAYS_IN_MEMORY> if there are unstopped threads
02475 that use the module code. In this case unloading the module would cause segmentation
02476 fault that would interfere with the still running shutdown procedures. In that case the module
02477 is not unloaded by the program, but only when the process finishes by the operating system.
02478 =CUT
02479 #define besSUB_SHUTDOWN besFUNCTION(shutmodu)
02480 
02481 =POD
02482 =section besSUB_AUTO
02483 =H besSUB_AUTO
02484 
02485 Use this macro to start the external module autoloader function.
02486 
02487 =CUT
02488 #define besSUB_AUTO int DLL_EXPORT automodu(pSupportTable pSt, \
02489                                                      void **ppModuleInternal, \
02490                                                      char *pszFunction, \
02491                                                      void **ppFunction){
02492 =POD
02493 =section besEND
02494 =H besEND
02495 
02496 Use this macro to close an extension module interface function.
02497 =CUT
02498 #define besEND return 0;}
02499 
02500 =POD
02501 =section besRETURNVALUE
02502 =H besRETURNVALUE
02503 Use this macro to access the extension function or command return value pointer. Assign allocated
02504 mortal variable to this pointer.
02505 =CUT
02506 #define besRETURNVALUE (*pReturnValue)
02507 
02508 =POD
02509 =section besMODULEPOINTER
02510 =H besMODULEPOINTER
02511 Use this macro to access the extension module pointer.
02512 =CUT
02513 #define besMODULEPOINTER (*ppModuleInternal)
02514 
02515 =POD
02516 =section besALLOC_RETURN_STRING
02517 =H besALLOC_RETURN_STRING(X)
02518 
02519 Use this macro to allocate a string as a return value. If there is not enough space to store the
02520 result the macro returns from the function with the error code T<COMMAND_ERROR_MEMORY_LOW>.
02521 
02522 The argument should be the number of bytes of the return value. After using this macro the
02523 macro T<STRINGVALUE(besRETURNVALUE)> can be used to access the byte-buffer of the return
02524 value. Usually the program uses T<memcpy> to copy the bytes there.
02525 =CUT
02526 #define besALLOC_RETURN_STRING(x) do{besRETURNVALUE  = besNEWMORTALSTRING(x);\
02527                                      if( besRETURNVALUE  == NULL )return COMMAND_ERROR_MEMORY_LOW;\
02528                                     }while(0);
02529 
02530 =POD
02531 =section besALLOC_RETURN_POINTER
02532 =H besALLOC_RETURN_POINTER
02533 
02534 Use this macro to allocate a string as a return value to return a pointer. If there is not enough space to store the
02535 result the macro returns from the function with the error code T<COMMAND_ERROR_MEMORY_LOW>.
02536 
02537 After using this macro the macro T<STRINGVALUE(besRETURNVALUE)> can be used to access the byte-buffer of the return
02538 value. Usually the program uses T<memcpy> to copy the bytes there.
02539 =CUT
02540 #define besALLOC_RETURN_POINTER do{besRETURNVALUE  = besNEWMORTALSTRING(sizeof( void *));\
02541                                      if( besRETURNVALUE  == NULL )return COMMAND_ERROR_MEMORY_LOW;\
02542                                     }while(0);
02543 
02544 =POD
02545 =section besALLOC_RETURN_LONG
02546 =H besALLOC_RETURN_LONG
02547 
02548 Use this macro to allocate a T<long> as a return value. If there is not enough space to store the
02549 result the macro returns from the function with the error code T<COMMAND_ERROR_MEMORY_LOW>.
02550 
02551 After using this macro the
02552 macro T<LONGVALUE(besRETURNVALUE)> can be used to access the long value of the return
02553 value.
02554 =CUT
02555 #define besALLOC_RETURN_LONG do{besRETURNVALUE = besNEWMORTALLONG;\
02556                                      if( besRETURNVALUE  == NULL )return COMMAND_ERROR_MEMORY_LOW;\
02557                                     }while(0);
02558 
02559 =POD
02560 =section besALLOC_RETURN_DOUBLE
02561 =H besALLOC_RETURN_DOUBLE
02562 
02563 Use this macro to allocate a T<double> as a return value. If there is not enough space to store the
02564 result the macro returns from the function with the error code T<COMMAND_ERROR_MEMORY_LOW>.
02565 
02566 After using this macro the
02567 macro T<DOUBLEVALUE(besRETURNVALUE)> can be used to access the double value of the return
02568 value.
02569 =CUT
02570 #define besALLOC_RETURN_DOUBLE do{besRETURNVALUE = besNEWMORTALDOUBLE;\
02571                                   if( besRETURNVALUE  == NULL )return COMMAND_ERROR_MEMORY_LOW;\
02572                                   }while(0);
02573 
02574 
02575 =POD
02576 =section besRETURN_STRING
02577 =H besRETURN_STRING(X)
02578 
02579 Use this program to return a string value. The argument of the macro should be a zero terminated
02580 string. 
02581 
02582 The macro allocates the return string, copies the content of the string to the allocated space and
02583 returns from the function using the macro with no error (COMMAND_ERROR_SUCCESS).
02584 
02585 If the return value can not be allocated the macro returns with COMMAND_ERROR_MEMORY_LOW.
02586 
02587 If the argument is T<NULL> the macro will return the BASIC value T<undef>.
02588 
02589 The macro evaluates its argument twice.
02590 =CUT
02591 #define besRETURN_STRING(x) do{if( NULL == (x) ){besRETURNVALUE = NULL; return COMMAND_ERROR_SUCCESS; }\
02592                                besRETURNVALUE  = besNEWMORTALSTRING(strlen(x));\
02593                                if( besRETURNVALUE  == NULL )return COMMAND_ERROR_MEMORY_LOW;\
02594                                memcpy(STRINGVALUE(besRETURNVALUE),(x),STRLEN(besRETURNVALUE));\
02595                                return COMMAND_ERROR_SUCCESS;\
02596                               }while(0);
02597 
02598 =POD
02599 =section besSET_RETURN_STRING
02600 =H besSET_RETURN_STRING(X)
02601 
02602 Use this program to return a string value. The argument of the macro should be a zero terminated
02603 string. 
02604 
02605 The macro allocates the return string, copies the content of the string to the allocated space.
02606 This macro does NOT return from the function that uses it. It allows the function to execute
02607 some extra code before returning from the function, for example to release the string
02608 variable passed as argument to this macro.
02609 
02610 If the return value can not be allocated the macro returns with COMMAND_ERROR_MEMORY_LOW.
02611 
02612 If the argument is T<NULL> the macro will set the return value to be T<NULL> (BASIC value T<undef>).
02613 
02614 The macro evaluates its argument twice.
02615 =CUT
02616 #define besSET_RETURN_STRING(x) do{if( NULL == (x) ){besRETURNVALUE = NULL;}else{\
02617                                      besRETURNVALUE  = besNEWMORTALSTRING((unsigned long)strlen(x));\
02618                                      if( besRETURNVALUE  == NULL )return COMMAND_ERROR_MEMORY_LOW;\
02619                                      memcpy(STRINGVALUE(besRETURNVALUE),(x),STRLEN(besRETURNVALUE));\
02620                                      }\
02621                                    }while(0);
02622 
02623 
02624 =POD
02625 =section besRETURN_MEM
02626 =H besRETURN_MEM(X,Y)
02627 
02628 Use this program to return a binary string value. The arguments of the macro should be a pointer
02629 to the binary string and the T<long> length of the binary string. 
02630 
02631 The macro allocates the return string, copies the content of the string to the allocated space and
02632 returns from the function using the macro with no error (COMMAND_ERROR_SUCCESS).
02633 
02634 If the return value can not be allocated the macro returns with COMMAND_ERROR_MEMORY_LOW.
02635 
02636 The macro evaluates its argument twice.
02637 =CUT
02638 #define besRETURN_MEM(x,y)    do{besRETURNVALUE  = besNEWMORTALSTRING(y);\
02639                                  if( besRETURNVALUE  == NULL )return COMMAND_ERROR_MEMORY_LOW;\
02640                                  memcpy(STRINGVALUE(besRETURNVALUE),(x),STRLEN(besRETURNVALUE));\
02641                                  return COMMAND_ERROR_SUCCESS;\
02642                                 }while(0);
02643 
02644 =POD
02645 =section besRETURN_POINTER
02646 =H besRETURN_POINTER(X)
02647 
02648 Use this macro to return a pointer. The argument of the macro should be the pointer to return. The
02649 BASIC program will see this value as a string of four (32 bit machines) or eight (64bit machines)
02650 characters. The BASIC program should not alter the value but pass it back to the module wherever
02651 the program needs. In other words the program should treat the value as an abstract handle
02652 and not try to manipulate it.
02653 
02654 The macro allocates the return string, copies the pointer into the string and returns from the function
02655 using the macro with no error (COMMAND_ERROR_SUCCESS).
02656 
02657 If the return value can not be allocated the macro returns with COMMAND_ERROR_MEMORY_LOW.
02658 
02659 If the pointer is T<NULL> the function will return the BASIC value T<undef>. This way you can not pass a
02660 T<NULL> pointer back to the BASIC program stored as four (or eight) zero characters in a string. On the other
02661 hand this is usually not what you really want and the BASIC program can check T<undef>indeness of the value.
02662 When T<undef> is passed back to the module the argument handling functions convert it back to T<NULL>.
02663 =CUT
02664 #define besRETURN_POINTER(x) do{if( NULL == (x) ){ besRETURNVALUE = NULL; return COMMAND_ERROR_SUCCESS; }\
02665                                 besRETURNVALUE  = besNEWMORTALSTRING(sizeof( void *));\
02666                                 if( besRETURNVALUE  == NULL )return COMMAND_ERROR_MEMORY_LOW;\
02667                                 memcpy(STRINGVALUE(besRETURNVALUE),&(x),sizeof( void *) );\
02668                                 return COMMAND_ERROR_SUCCESS;\
02669                                 }while(0);
02670 
02671 =POD
02672 =section besRETURN_LONG
02673 =H besRETURN_LONG(X)
02674 
02675 Use this macro to return a long value. The argument should be a T<long> value to return.
02676 
02677 The macro allocates the BASIC variable to return the value, sets the value to it to the actual
02678 value of the macro argument and returns from the funcion using the macro with no error (COMMAND_ERROR_SUCCESS).
02679 
02680 If the return value can not be allocated the macro returns with COMMAND_ERROR_MEMORY_LOW.
02681 =CUT
02682 #define besRETURN_LONG(X) do{besRETURNVALUE = besNEWMORTALLONG;\
02683                              if( besRETURNVALUE  == NULL )return COMMAND_ERROR_MEMORY_LOW;\
02684                              LONGVALUE(besRETURNVALUE) = (X);\
02685                              return COMMAND_ERROR_SUCCESS;\
02686                              }while(0);
02687 
02688 =POD
02689 =section besRETURN_DOUBLE
02690 =H besRETURN_DOUBLE
02691 
02692 
02693 Use this macro to return a double value. The argument should be a T<double> value to return.
02694 
02695 The macro allocates the BASIC variable to return the value, sets the value to it to the actual
02696 value of the macro argument and returns from the funcion using the macro with no error (COMMAND_ERROR_SUCCESS).
02697 
02698 If the return value can not be allocated the macro returns with COMMAND_ERROR_MEMORY_LOW.
02699 =CUT
02700 #define besRETURN_DOUBLE(X) do{besRETURNVALUE = besNEWMORTALDOUBLE;\
02701                                if( besRETURNVALUE  == NULL )return COMMAND_ERROR_MEMORY_LOW;\
02702                                DOUBLEVALUE(besRETURNVALUE) = (X);\
02703                                return COMMAND_ERROR_SUCCESS;\
02704                                }while(0);
02705 
02706 =POD
02707 =section besSETCOMMAND
02708 =H besSETCOMMAND(X,Y)
02709 Use this macro to alter the command table. T<X> is the command code and T<Y> is the
02710 new function implementing the command.
02711 =CUT
02712 #define besSETCOMMAND(X,Y) (pSt->pEo->pCommandFunction[(X)-START_CMD] = Y)
02713 
02714 =POD
02715 =section besGETCOMMAND
02716 =H besGETCOMMAND(X)
02717 Use this macro to get the command function currently assigned to the command T<X>.
02718 =CUT
02719 #define besGETCOMMAND(X)   (pSt->pEo->pCommandFunction[(X)-START_CMD])
02720 
02721 =POD
02722 =section INTERFACE_VERSION
02723 =H INTERFACE_VERSION
02724 The current external module interface version. This is an integer number.
02725 =CUT
02726 #define INTERFACE_VERSION 11
02727 
02728 =POD
02729 =section besHOOK_FILE_ACCESS
02730 =H besHOOK_FILE_ACCESS
02731 This macro calls the function R<hook_file_access>
02732 =CUT
02733 #define besHOOK_FILE_ACCESS(X) (pSt->pEo->pHookers->HOOK_file_access(pSt->pEo,(X)))
02734 =POD
02735 =section besHOOK_FOPEN
02736 =H besHOOK_FOPEN
02737 This macro calls the function R<hook_fopen>
02738 =CUT
02739 #define besHOOK_FOPEN(X,Y) (pSt->pEo->pHookers->HOOK_fopen(pSt->pEo,(X),(Y)))
02740 =POD
02741 =section besHOOK_FCLOSE
02742 =H besHOOK_FCLOSE
02743 This macro calls the function R<hook_fclose>
02744 =CUT
02745 #define besHOOK_FCLOSE(X) (pSt->pEo->pHookers->HOOK_fclose(pSt->pEo,(X)))
02746 =POD
02747 =section besHOOK_SIZE
02748 =H besHOOK_SIZE
02749 This macro calls the function R<hook_size>
02750 =CUT
02751 #define besHOOK_SIZE(X) (pSt->pEo->pHookers->HOOK_size(pSt->pEo,(X)))
02752 =POD
02753 =section besHOOK_TIME_ACCESSED
02754 =H besHOOK_TIME_ACCESSED
02755 This macro calls the function R<hook_time_accessed>
02756 =CUT
02757 #define besHOOK_TIME_ACCESSED(X) (pSt->pEo->pHookers->HOOK_time_accessed(pSt->pEo,(X)))
02758 =POD
02759 =section besHOOK_TIME_MODIFIED
02760 =H besHOOK_TIME_MODIFIED
02761 This macro calls the function R<hook_time_modified>
02762 =CUT
02763 #define besHOOK_TIME_MODIFIED(X) (pSt->pEo->pHookers->HOOK_time_modified(pSt->pEo,(X)))
02764 =POD
02765 =section besHOOK_TIME_CREATED
02766 =H besHOOK_TIME_CREATED
02767 This macro calls the function R<hook_time_created>
02768 =CUT
02769 #define besHOOK_TIME_CREATED(X) (pSt->pEo->pHookers->HOOK_time_created(pSt->pEo,(X)))
02770 =POD
02771 =section besHOOK_ISDIR
02772 =H besHOOK_ISDIR
02773 This macro calls the function R<hook_isdir>
02774 =CUT
02775 #define besHOOK_ISDIR(X) (pSt->pEo->pHookers->HOOK_isdir(pSt->pEo,(X)))
02776 =POD
02777 =section besHOOK_ISREG
02778 =H besHOOK_ISREG
02779 This macro calls the function R<hook_isreg>
02780 =CUT
02781 #define besHOOK_ISREG(X) (pSt->pEo->pHookers->HOOK_isreg(pSt->pEo,(X)))
02782 =POD
02783 =section besHOOK_EXISTS
02784 =H besHOOK_EXISTS
02785 This macro calls the function R<hook_fileexists>
02786 =CUT
02787 #define besHOOK_EXISTS(X) (pSt->pEo->pHookers->HOOK_exists(pSt->pEo,(X)))
02788 =POD
02789 =section besHOOK_TRUNCATE
02790 =H besHOOK_TRUNCATE
02791 This macro calls the function R<hook_truncate>
02792 =CUT
02793 #define besHOOK_TRUNCATE(X,Y) (pSt->pEo->pHookers->HOOK_truncate(pSt->pEo,(X),(Y)))
02794 =POD
02795 =section besHOOK_FGETC
02796 =H besHOOK_FGETC
02797 This macro calls the function R<hook_fgetc>
02798 =CUT
02799 #define besHOOK_FGETC(X) (pSt->pEo->pHookers->HOOK_fgetc(pSt->pEo,(X)))
02800 =POD
02801 =section besHOOK_FREAD
02802 =H besHOOK_FREAD
02803 This macro calls the function R<hook_fread>
02804 =CUT
02805 #define besHOOK_FREAD(X,Y,Z,W) (pSt->pEo->pHookers->HOOK_fread(pSt->pEo,(X),(Y),(Z),(W)))
02806 =POD
02807 =section besHOOK_FWRITE
02808 =H besHOOK_FWRITE
02809 This macro calls the function R<hook_fwrite>
02810 =CUT
02811 #define besHOOK_FWRITE(X,Y,Z,W) (pSt->pEo->pHookers->HOOK_fwrite(pSt->pEo,(X),(Y),(Z),(W)))
02812 =POD
02813 =section besHOOK_FERROR
02814 =H besHOOK_FERROR
02815 This macro calls the function R<hook_ferror>
02816 =CUT
02817 #define besHOOK_FERROR(X) (pSt->pEo->pHookers->HOOK_ferror(pSt->pEo,(X)))
02818 =POD
02819 =section besHOOK_PUTC
02820 =H besHOOK_PUTC
02821 This macro calls the function R<hook_fputc>
02822 =CUT
02823 #define besHOOK_PUTC(X,Y) (pSt->pEo->pHookers->HOOK_fputc(pSt->pEo,(X),(Y)))
02824 =POD
02825 =section besHOOK_FLOCK
02826 =H besHOOK_FLOCK
02827 This macro calls the function R<hook_flock>
02828 =CUT
02829 #define besHOOK_FLOCK(X,Y) (pSt->pEo->pHookers->HOOK_flock(pSt->pEo,(X),(Y)))
02830 =POD
02831 =section besHOOK_LOCK
02832 =H besHOOK_LOCK
02833 This macro calls the function R<hook_lock>
02834 =CUT
02835 #define besHOOK_LOCK(X,Y,Z,W) (pSt->pEo->pHookers->HOOK_lock(pSt->pEo,(X),(Y),(Z),(W)))
02836 =POD
02837 =section besHOOK_FEOF
02838 =H besHOOK_FEOF
02839 This macro calls the function R<hook_feof>
02840 =CUT
02841 #define besHOOK_FEOF(X) (pSt->pEo->pHookers->HOOK_feof(pSt->pEo,(X)))
02842 =POD
02843 =section besHOOK_MKDIR
02844 =H besHOOK_MKDIR
02845 This macro calls the function R<hook_mkdir>
02846 =CUT
02847 #define besHOOK_MKDIR(X) (pSt->pEo->pHookers->HOOK_mkdir(pSt->pEo,(X)))
02848 =POD
02849 =section besHOOK_RMDIR
02850 =H besHOOK_RMDIR
02851 This macro calls the function R<hook_rmdir>
02852 =CUT
02853 #define besHOOK_RMDIR(X) (pSt->pEo->pHookers->HOOK_rmdir(pSt->pEo,(X)))
02854 =POD
02855 =section besHOOK_REMOVE
02856 =H besHOOK_REMOVE
02857 This macro calls the function R<hook_remove>
02858 =CUT
02859 #define besHOOK_REMOVE(X) (pSt->pEo->pHookers->HOOK_remove(pSt->pEo,(X)))
02860 =POD
02861 =section besHOOK_DELTREE
02862 =H besHOOK_DELTREE
02863 This macro calls the function R<hook_deltree>
02864 =CUT
02865 #define besHOOK_DELTREE(X) (pSt->pEo->pHookers->HOOK_deltree(pSt->pEo,(X)))
02866 =POD
02867 =section besHOOK_MAKEDIRECTORY
02868 =H besHOOK_MAKEDIRECTORY
02869 This macro calls the function R<hook_MakeDirectory>
02870 =CUT
02871 #define besHOOK_MAKEDIRECTORY(X) (pSt->pEo->pHookers->HOOK_MakeDirectory(pSt->pEo,(X)))
02872 =POD
02873 =section besHOOK_OPENDIR
02874 =H besHOOK_OPENDIR
02875 This macro calls the function R<hook_opendir>
02876 =CUT
02877 #define besHOOK_OPENDIR(X,Y) (pSt->pEo->pHookers->HOOK_opendir(pSt->pEo,(X),(Y)))
02878 =POD
02879 =section besHOOK_READDIR
02880 =H besHOOK_READDIR
02881 This macro calls the function R<hook_readdir>
02882 =CUT
02883 #define besHOOK_READDIR(X) (pSt->pEo->pHookers->HOOK_readdir(pSt->pEo,(X)))
02884 =POD
02885 =section besHOOK_CLOSEDIR
02886 =H besHOOK_CLOSEDIR
02887 This macro calls the function R<hook_closedir>
02888 =CUT
02889 #define besHOOK_CLOSEDIR(X) (pSt->pEo->pHookers->HOOK_closedir(pSt->pEo,(X)))
02890 =POD
02891 =section besHOOK_SLEEP
02892 =H besHOOK_SLEEP
02893 This macro calls the function R<hook_sleep>
02894 =CUT
02895 #define besHOOK_SLEEP(X) (pSt->pEo->pHookers->HOOK_sleep(pSt->pEo,(X)))
02896 =POD
02897 =section besHOOK_CURDIR
02898 =H besHOOK_CURDIR
02899 This macro calls the function R<hook_curdir>
02900 =CUT
02901 #define besHOOK_CURDIR(X,Y) (pSt->pEo->pHookers->HOOK_curdir(pSt->pEo,(X),(Y)))
02902 =POD
02903 =section besHOOK_CHDIR
02904 =H besHOOK_CHDIR
02905 This macro calls the function R<hook_chdir>
02906 =CUT
02907 #define besHOOK_CHDIR(X) (pSt->pEo->pHookers->HOOK_chdir(pSt->pEo,(X)))
02908 =POD
02909 =section besHOOK_CHOWN
02910 =H besHOOK_CHOWN
02911 This macro calls the function R<hook_chown>
02912 =CUT
02913 #define besHOOK_CHOWN(X,Y) (pSt->pEo->pHookers->HOOK_chown(pSt->pEo,(X),(Y)))
02914 =POD
02915 =section besHOOK_SETCREATETIME
02916 =H besHOOK_SETCREATETIME
02917 This macro calls the function R<hook_SetCreateTime>
02918 =CUT
02919 #define besHOOK_SETCREATETIME(X,Y) (pSt->pEo->pHookers->HOOK_SetCreateTime(pSt->pEo,(X),(Y)))
02920 =POD
02921 =section besHOOK_SETMODIFYTIME
02922 =H besHOOK_SETMODIFYTIME
02923 This macro calls the function R<hook_SetModifyTime>
02924 =CUT
02925 #define besHOOK_SETMODIFYTIME(X,Y) (pSt->pEo->pHookers->HOOK_SetModifyTime(pSt->pEo,(X),(Y)))
02926 =POD
02927 =section besHOOK_SETACCESSTIME
02928 =H besHOOK_SETACCESSTIME
02929 This macro calls the function R<hook_SetAccessTime>
02930 =CUT
02931 #define besHOOK_SETACCESSTIME(X,Y) (pSt->pEo->pHookers->HOOK_SetAccessTime(pSt->pEo,(X),(Y)))
02932 =POD
02933 =section besHOOK_GETHOSTNAME
02934 =H besHOOK_GETHOSTNAME
02935 This macro calls the function R<hook_GetHostName>
02936 =CUT
02937 #define besHOOK_GETHOSTNAME(X,Y) (pSt->pEo->pHookers->HOOK_GetHostName(pSt->pEo,(X),(Y)))
02938 =POD
02939 =section besHOOK_GETHOST
02940 =H besHOOK_GETHOST
02941 This macro calls the function R<hook_GetHost>
02942 =CUT
02943 #define besHOOK_GETHOST(X,Y) (pSt->pEo->pHookers->HOOK_GetHost(pSt->pEo,(X),((Y)))
02944 =POD
02945 =section besHOOK_TCPCONNECT
02946 =H besHOOK_TCPCONNECT
02947 This macro calls the function R<hook_TcpConnect>
02948 =CUT
02949 #define besHOOK_TCPCONNECT(X,Y) (pSt->pEo->pHookers->HOOK_TcpConnect(pSt->pEo,(X),(Y)))
02950 =POD
02951 =section besHOOK_TCPSEND
02952 =H besHOOK_TCPSEND
02953 This macro calls the function R<hook_TcpSend>
02954 =CUT
02955 #define besHOOK_TCPSEND(X,Y,Z) (pSt->pEo->pHookers->HOOK_TcpSend(pSt->pEo,(X),(Y),(Z)))
02956 =POD
02957 =section besHOOK_TCPRECV
02958 =H besHOOK_TCPRECV
02959 This macro calls the function R<hook_TcpRecv>
02960 =CUT
02961 #define besHOOK_TCPRECV(X,Y,Z) (pSt->pEo->pHookers->HOOK_TcpRecv(pSt->pEo,(X),(Y),(Z)))
02962 =POD
02963 =section besHOOK_TCPCLOSE
02964 =H besHOOK_TCPCLOSE
02965 This macro calls the function R<hook_TcpClose>
02966 =CUT
02967 #define besHOOK_TCPCLOSE(Y) (pSt->pEo->pHookers->HOOK_TcpClose(pSt->pEo,(X))
02968 =POD
02969 =section besHOOK_KILLPROC
02970 =H besHOOK_KILLPROC
02971 This macro calls the function R<hook_KillProc>
02972 =CUT
02973 #define besHOOK_KILLPROC(X) (pSt->pEo->pHookers->HOOK_KillProc(pSt->pEo,(X))
02974 =POD
02975 =section besHOOK_GETOWNER
02976 =H besHOOK_GETOWNER
02977 This macro calls the function R<hook_GetOwner>
02978 =CUT
02979 #define besHOOK_GETOWNER(X,Y,Z) (pSt->pEo->pHookers->HOOK_GetOwner(pSt->pEo,(X),(Y),(Z));
02980 =POD
02981 =section besHOOK_CREATEPROCESS
02982 =H besHOOK_CREATEPROCESS
02983 This macro calls the function R<hook_CreateProcess>
02984 =CUT
02985 #define besHOOK_CREATEPROCESS(X) (pSt->pEo->pHookers->HOOK_CreateProcess(pSt->pEo,(X));
02986 =POD
02987 =section besHOOK_CALLSCRIBAFUNCTION
02988 =H besHOOK_CALLSCRIBAFUNCTION
02989 This macro calls the function R<hook_CallScribaFunction>
02990 =CUT
02991 #define besHOOK_CALLSCRIBAFUNCTION(X,Y,Z,W) (pSt->pEo->pHookers->HOOK_CallScribaFunction(pSt->pEo,(X),(Y),(Z),(W)))
02992 =POD
02993 =section besSETHOOK
02994 =H besSETHOOK(X,Y)
02995 Use this macro to alter the hook function table.
02996 =CUT
02997 #define besSETHOOK(X,Y) (pSt->pEo->pHookers->HOOK_##X = Y)
02998 
02999 =POD
03000 =section besDLL_MAIN
03001 =H besDLL_MAIN
03002 
03003 process header macro makes UNIX like dll loading and unloading
03004 on Win32. This just defines a wrapper DllMain that calls _init() and
03005 _fini() that a the default library loading and unloading functions
03006 under UNIX.
03007 
03008 Use of this macro may be needed for modules that serve multi thread
03009 interpreters and share resources on the process level
03010 =CUT
03011 #ifdef WIN32
03012 #define besDLL_MAIN \
03013 BOOL __declspec(dllexport) WINAPI DllMain(\
03014   HINSTANCE hinstDLL,\
03015   DWORD fdwReason,\
03016   LPVOID lpvReserved\
03017   ){\
03018   int _init(void);\
03019   int _fini(void);\
03020   switch( fdwReason ){\
03021     case DLL_PROCESS_ATTACH:\
03022       _init();\
03023       break;\
03024     case DLL_THREAD_ATTACH: return TRUE;\
03025     case DLL_THREAD_DETACH: return TRUE;\
03026     case DLL_PROCESS_DETACH:\
03027       _fini();\
03028       break;\
03029     }\
03030   return TRUE;\
03031   }
03032 #else
03033 #define besDLL_MAIN
03034 #endif
03035 
03036 =POD
03037 =section INITLOCK
03038 =H INITLOCK
03039 
03040 Whent he process first time loads an extension and the extension wants to decide whether
03041 to unload it or keep in memory it needs a counter and a mutex to access the counter
03042 to declare the counter the extension should use the macro SUPPORT_MULTITHREAD and
03043 to initialize it it should use the macro INIT_MULTITHREAD
03044 
03045 Note that the call-back functions to handle the mutexes OS independant are not available
03046 by the time when the OS calls DllMain on NT or _init on UNIX, thus the code should call
03047 system dependant functions directly
03048 
03049 IsThisTheVeryFirstThreadCallingTheModule <- name of the function
03050 =CUT
03051 #ifdef WIN32
03052 #define INITLOCK WaitForSingleObject(mxInit,INFINITE);
03053 #define INITUNLO ReleaseSemaphore(mxInit,1,NULL);
03054 #else
03055 #define INITLOCK pthread_mutex_lock(&mxInit);
03056 #define INITUNLO pthread_mutex_unlock(&mxInit);
03057 #endif
03058 
03059 #define SUPPORT_MULTITHREAD static MUTEX mxThreadCounter,mxInit; static int iFirst;static long lThreadCounter;
03060 
03061 #ifdef WIN32
03062 #define INIT_MULTITHREAD      mxThreadCounter = CreateSemaphore(NULL,1,1,NULL);\
03063                               mxInit = CreateSemaphore(NULL,1,1,NULL);\
03064                               iFirst = 1;
03065 #define GET_THREAD_COUNTER(X) WaitForSingleObject(mxThreadCounter,INFINITE);\
03066                               (X) = lThreadCounter;\
03067                               ReleaseSemaphore(mxThreadCounter,1,NULL);
03068 #define INC_THREAD_COUNTER    WaitForSingleObject(mxThreadCounter,INFINITE);\
03069                               lThreadCounter++;\
03070                               ReleaseSemaphore(mxThreadCounter,1,NULL);
03071 #define DEC_THREAD_COUNTER    WaitForSingleObject(mxThreadCounter,INFINITE);\
03072                               lThreadCounter--;\
03073                               ReleaseSemaphore(mxThreadCounter,1,NULL);
03074 #define FINISH_MULTITHREAD    CloseHandle(mxThreadCounter);
03075 #else
03076 #define INIT_MULTITHREAD      pthread_mutex_init(&mxThreadCounter,NULL);\
03077                               pthread_mutex_init(&mxInit,NULL);\
03078                               iFirst = 1;
03079 #define GET_THREAD_COUNTER(X) pthread_mutex_lock(&mxThreadCounter);\
03080                               (X) = lThreadCounter;\
03081                               pthread_mutex_unlock(&mxThreadCounter);
03082 #define INC_THREAD_COUNTER    pthread_mutex_lock(&mxThreadCounter);\
03083                               lThreadCounter++;\
03084                               pthread_mutex_unlock(&mxThreadCounter);
03085 #define DEC_THREAD_COUNTER    pthread_mutex_lock(&mxThreadCounter);\
03086                               lThreadCounter--;\
03087                               pthread_mutex_unlock(&mxThreadCounter);
03088 #define FINISH_MULTITHREAD    pthread_mutex_destroy(&mxThreadCounter);
03089 #endif
03090 
03091 #define START_FUNCTION_TABLE(X) SLFST X[] ={
03092 #define EXPORT_MODULE_FUNCTION(X) { #X , X },
03093 #define END_FUNCTION_TABLE { NULL , NULL } };
03094 
03095 */
03096 
03097 #include <stdio.h>
03098 #include <stdarg.h>
03099 #include "basext.h"
03100 
03101 /*POD
03102 =H basext_GetArgsF()
03103 
03104 This function can be used to get arguments simple and fast in extension modules.
03105 All functionality of this function can be individually programmed using the
03106 T<besXXX> macros. Here it is to ease the programming of extension modules for most of
03107 the cases.
03108 
03109 This function should be called like
03110 
03111 =verbatim
03112   iError = besGETARGS "ldz",&l1,&d1,&s besGETARGE
03113 =noverbatim
03114 
03115 The macro T<besGETARGS> (read GET ARGument Start) hides the complexity of the
03116 function call and the macro T<besGETARGE> (read Get ARGument End) simply closes the
03117 function call.
03118 
03119 The first argument is format string. Each character specifies how the next argument
03120 should be treated.
03121 
03122 /*FUNCTION*/
03123 int basext_GetArgsF(pSupportTable pSt,
03124                     pFixSizeMemoryObject pParameters,
03125                     char *pszFormat,
03126                     ...
03127   ){
03128 /*noverbatim
03129 The following characters are recognized:
03130 
03131 =itemize
03132 =item T<i> the next argument of the function call should point to a T<long> variable.
03133            The ScriptBasic argument will be converted to T<long> using the macro
03134            T<besCONVERT2LONG> and will be stored in the T<long> variable.
03135 =item T<r> the same as T<l> except that the argument should point a T<double> and the
03136            basic argument is converted to T<double> using T<besCONVERT2DOUBLE>.
03137 =item T<z> the next argument should point to a T<char *> pointer. The function takes
03138            the next BASIC argument as string, converts it to zero terminated string
03139            allocating space for it. These variables SHOULD be released by the caller
03140            using the macro T<besFREE>.
03141 =item T<s> the next argument should point to a T<unsigned char *> pointer. The function takes
03142            the next BASIC argument as string, converting it in case conversion is needed, and
03143            sets the T<unsigned char *> pointer to point to the string. This format character
03144            should be used together with the character T<l>
03145 =item T<l> the next argument should point to a T<long> and the value of the variable
03146            will be the length of the last string atgument (either T<z> or T<s>).
03147            If there was no previous string argument the value returned will be zero.
03148 =item T<p> the next argument should point to a T<void *> pointer. The BASIC argument value
03149            should be a string of T<sizeof(void *)> characters that will be copied into the
03150            pointer argument. If the argument is not string or has not the proper size the function
03151            returns T<COMMAND_ERROR_ARGUMENT_RANGE>.
03152 =item T<[> The arguments following this character are optional. Optional arguments may be
03153            unspecified. This is the case when the BASIC function call has less number of
03154            arguments or when the actual argument value is T<undef>. In case of optional
03155            arguments the T<undef> values are converted to zero value of the appropriate
03156            type. This means 0 in case of long, 0.0 in case of double, NULL in case of pointer
03157            and zero length string in case of strings.
03158 =item T<]> Arguments following this character are mandatory (are not optional). When the
03159            function starts to process the arguments they are mandatory by default. Using this
03160            notation you can enclode the optional arguments between T<[> and T<]>. For example
03161            the format string T<"ii[z]"> means two long arguments and an optional zero terminated
03162            string argument.
03163 =item T<*> The argument is skipped. This may be used during development of a function.
03164 =noitemize
03165 
03166 The return value of the function is zero in case there is no error or the error code.
03167 CUT*/
03168   va_list marker;
03169   long ArgNr;
03170   void *argptr;
03171   char *s;
03172   long *pL;
03173   double *pD;
03174   unsigned char **ppS;
03175   void **ppV;
03176   VARIABLE Argumentum;
03177   int mandatory; /* true when we process mandatory arguments (should not be undef) */
03178   char **ppszStrAlloc;
03179   long iStrArg,iArgNr;
03180   unsigned long lLastStrLen = 0;
03181 
03182   /* allocate a string array that keeps track of all allocated zchar strings
03183      if the memory allocation fails somewhere in between the string are freed
03184      and we do not loose memory */
03185   ppszStrAlloc = (char **)besALLOC(sizeof(char *) * (iArgNr=strlen(pszFormat)));
03186   if( ppszStrAlloc == NULL )return COMMAND_ERROR_MEMORY_LOW;
03187   for( iStrArg = 0 ; iStrArg < iArgNr ; iStrArg++ )ppszStrAlloc[iStrArg] = NULL;
03188   iStrArg = 0; /* the next string */
03189   va_start(marker,pszFormat);
03190   ArgNr = 1;
03191   mandatory = 1;
03192 #define NEXT_ARG argptr = va_arg(marker, void * );
03193   NEXT_ARG
03194   for( s = pszFormat ; *s ; s++ ){
03195     switch( *s ){
03196       case '[': mandatory = 0;break;
03197       case ']': mandatory = 1;break;
03198       case '*': ArgNr++; break; /* Skip this argument */
03199       case 'l': /* Get the length of the last string either 'z' or 's' */
03200         pL = (long *)argptr;
03201         NEXT_ARG
03202         *pL = lLastStrLen;
03203         break;
03204       case 'i': /* Get a long */
03205         pL = (long *)argptr;
03206         NEXT_ARG
03207         Argumentum = besARGUMENT(ArgNr);
03208         besDEREFERENCE(Argumentum);
03209         ArgNr++;
03210         if( memory_IsUndef(Argumentum) && mandatory ){
03211           while( iStrArg -- )besFREE(ppszStrAlloc[iStrArg]);
03212           besFREE(ppszStrAlloc);
03213           return COMMAND_ERROR_MANDARG;
03214           }
03215         if( memory_IsUndef(Argumentum) ){
03216           *pL = 0;
03217           }else{
03218           Argumentum = besCONVERT2LONG(Argumentum);
03219           *pL = LONGVALUE(Argumentum);
03220           }
03221         break;
03222       case 'r': /* Get a double */
03223         pD = (double *)argptr;
03224         NEXT_ARG
03225         Argumentum = besARGUMENT(ArgNr);
03226         ArgNr++;
03227         besDEREFERENCE(Argumentum);
03228         if( memory_IsUndef(Argumentum) && mandatory ){
03229           while( iStrArg -- )besFREE(ppszStrAlloc[iStrArg]);
03230           besFREE(ppszStrAlloc);
03231           return COMMAND_ERROR_MANDARG;
03232           }
03233         if( memory_IsUndef(Argumentum) ){
03234           *pD = 0.0;
03235           }else{
03236           *pD = besGETDOUBLEVALUE(Argumentum);
03237           }
03238         break;
03239       case 'z': /* Get a zchar string */
03240         ppS = (unsigned char **)argptr;
03241         NEXT_ARG
03242         Argumentum = besARGUMENT(ArgNr);
03243         ArgNr++;
03244         besDEREFERENCE(Argumentum);
03245         if( memory_IsUndef(Argumentum) && mandatory ){
03246           while( iStrArg -- )besFREE(ppszStrAlloc[iStrArg]);
03247           besFREE(ppszStrAlloc);
03248           return COMMAND_ERROR_MANDARG;
03249           }
03250         Argumentum = besCONVERT2STRING(Argumentum);
03251         *ppS = besALLOC( (lLastStrLen = STRLEN(Argumentum))+1);
03252         if( *ppS == NULL ){
03253           while( iStrArg -- )besFREE(ppszStrAlloc[iStrArg]);
03254           besFREE(ppszStrAlloc);
03255           return COMMAND_ERROR_MEMORY_LOW;
03256           }
03257         ppszStrAlloc[iStrArg++] = *ppS;
03258         memcpy(*ppS,STRINGVALUE(Argumentum),lLastStrLen);
03259         (*ppS)[STRLEN(Argumentum)] = (char)0;
03260         break;
03261       case 'p': /* Get a pointer */
03262         ppV = (void **)argptr;
03263         NEXT_ARG
03264         Argumentum = besARGUMENT(ArgNr);
03265         ArgNr++;
03266         besDEREFERENCE(Argumentum);
03267         if( memory_IsUndef(Argumentum) && mandatory ){
03268           while( iStrArg -- )besFREE(ppszStrAlloc[iStrArg]);
03269           besFREE(ppszStrAlloc);
03270           return COMMAND_ERROR_MANDARG;
03271           }
03272         if( ! memory_IsUndef(Argumentum) && 
03273            (TYPE(Argumentum) != VTYPE_STRING || 
03274             STRLEN(Argumentum) != sizeof( void * )) ){
03275           while( iStrArg -- )besFREE(ppszStrAlloc[iStrArg]);
03276           besFREE(ppszStrAlloc);
03277           return COMMAND_ERROR_ARGUMENT_RANGE;
03278           }
03279         if( memory_IsUndef(Argumentum) )
03280           *ppV = NULL;
03281         else
03282           memcpy(ppV, STRINGVALUE(Argumentum),sizeof( void * ) );
03283         break;
03284       case 's': /* Get a string */
03285         ppS = (unsigned char **)argptr;
03286         NEXT_ARG
03287         Argumentum = besARGUMENT(ArgNr);
03288         ArgNr++;
03289         besDEREFERENCE(Argumentum);
03290         if( memory_IsUndef(Argumentum) && mandatory ){
03291           while( iStrArg -- )besFREE(ppszStrAlloc[iStrArg]);
03292           besFREE(ppszStrAlloc);
03293           return COMMAND_ERROR_MANDARG;
03294           }
03295         Argumentum = besCONVERT2STRING(Argumentum);
03296         *ppS = STRINGVALUE(Argumentum);
03297         lLastStrLen = STRLEN(Argumentum);
03298         break;
03299       }
03300     }
03301   va_end( marker );
03302   besFREE(ppszStrAlloc);
03303   return 0;
03304   }

Generated on Sun Mar 12 23:56:26 2006 for ScriptBasic by  doxygen 1.4.6-NO