slang.h 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034
  1. #ifndef DAVIS_SLANG_H_
  2. #define DAVIS_SLANG_H_
  3. /* -*- mode: C; mode: fold; -*- */
  4. /* Copyright (c) 1992, 1999, 2001, 2002, 2003 John E. Davis
  5. * This file is part of the S-Lang library.
  6. *
  7. * You may distribute under the terms of either the GNU General Public
  8. * License or the Perl Artistic License.
  9. */
  10. #define SLANG_VERSION 10409
  11. #define SLANG_VERSION_STRING "1.4.9"
  12. /*{{{ System Dependent Macros and Typedefs */
  13. #if defined(__WATCOMC__) && defined(DOS)
  14. # ifndef __MSDOS__
  15. # define __MSDOS__
  16. # endif
  17. # ifndef DOS386
  18. # define DOS386
  19. # endif
  20. # ifndef IBMPC_SYSTEM
  21. # define IBMPC_SYSTEM
  22. # endif
  23. #endif /* __watcomc__ */
  24. #if defined(unix) || defined(__unix) || defined (_AIX) || defined(__NetBSD__)
  25. # ifndef __unix__
  26. # define __unix__ 1
  27. # endif
  28. #endif
  29. #if !defined(__GO32__)
  30. # ifdef __unix__
  31. # define REAL_UNIX_SYSTEM
  32. # endif
  33. #endif
  34. /* Set of the various defines for pc systems. This includes OS/2 */
  35. #ifdef __GO32__
  36. # ifndef __DJGPP__
  37. # define __DJGPP__ 1
  38. # endif
  39. # ifndef IBMPC_SYSTEM
  40. # define IBMPC_SYSTEM
  41. # endif
  42. #endif
  43. #ifdef __BORLANDC__
  44. # ifndef IBMPC_SYSTEM
  45. # define IBMPC_SYSTEM
  46. # endif
  47. #endif
  48. #ifdef __MSDOS__
  49. # ifndef IBMPC_SYSTEM
  50. # define IBMPC_SYSTEM
  51. # endif
  52. #endif
  53. #if defined(OS2) || defined(__os2__)
  54. # ifndef IBMPC_SYSTEM
  55. # define IBMPC_SYSTEM
  56. # endif
  57. # ifndef __os2__
  58. # define __os2__
  59. # endif
  60. #endif
  61. #if defined(__NT__) || defined(__MINGW32__) /* || defined(__CYGWIN32__) */
  62. # ifndef IBMPC_SYSTEM
  63. # define IBMPC_SYSTEM
  64. # endif
  65. #endif
  66. #if defined(IBMPC_SYSTEM) || defined(VMS)
  67. # ifdef REAL_UNIX_SYSTEM
  68. # undef REAL_UNIX_SYSTEM
  69. # endif
  70. #endif
  71. #ifdef __cplusplus
  72. extern "C" {
  73. #endif
  74. #if 0
  75. }
  76. #endif
  77. #include <stdio.h>
  78. #include <stdarg.h>
  79. #if defined(__STDC__) || defined(__BORLANDC__) || defined(__cplusplus)
  80. # include <stddef.h> /* for offsetof */
  81. #endif
  82. /* ---------------------------- Generic Macros ----------------------------- */
  83. /* __SC__ is defined for Symantec C++
  84. DOS386 is defined for -mx memory model, 32 bit DOS extender. */
  85. #if defined(__SC__) && !defined(DOS386)
  86. # include <dos.h>
  87. #endif
  88. #if defined(__BORLANDC__)
  89. # include <alloc.h>
  90. #endif
  91. #ifdef __GNUC__
  92. # define _SLATTRIBUTE_(x) __attribute__ (x)
  93. #else
  94. # define _SLATTRIBUTE_(x)
  95. #endif
  96. #define _SLATTRIBUTE_PRINTF(a,b) _SLATTRIBUTE_((format(printf,a,b)))
  97. #if defined (__cplusplus) || defined(__STDC__) || defined(IBMPC_SYSTEM)
  98. typedef void *VOID_STAR;
  99. #define SLCONST const
  100. #else
  101. typedef unsigned char *VOID_STAR;
  102. #define SLCONST
  103. #endif
  104. typedef int (*FVOID_STAR)(void);
  105. #if defined(__MSDOS__) && defined(__BORLANDC__)
  106. # define SLFREE(buf) farfree((void far *)(buf))
  107. # define SLMALLOC(x) farmalloc((unsigned long) (x))
  108. # define SLREALLOC(buf, n) farrealloc((void far *) (buf), (unsigned long) (n))
  109. # define SLCALLOC(n, m) farcalloc((unsigned long) (n), (unsigned long) (m))
  110. #else
  111. # if defined(VMS) && !defined(__DECC)
  112. # define SLFREE VAXC$FREE_OPT
  113. # define SLMALLOC VAXC$MALLOC_OPT
  114. # define SLREALLOC VAXC$REALLOC_OPT
  115. # define SLCALLOC VAXC$CALLOC_OPT
  116. # else
  117. # define SLFREE(x) free((char *)(x))
  118. # define SLMALLOC malloc
  119. # define SLREALLOC realloc
  120. # define SLCALLOC calloc
  121. # endif
  122. #endif
  123. extern char *SLdebug_malloc (unsigned long);
  124. extern char *SLdebug_calloc (unsigned long, unsigned long);
  125. extern char *SLdebug_realloc (char *, unsigned long);
  126. extern void SLdebug_free (char *);
  127. extern void SLmalloc_dump_statistics (void);
  128. extern char *SLstrcpy(register char *, register char *);
  129. extern int SLstrcmp(register char *, register char *);
  130. extern char *SLstrncpy(char *, register char *, register int);
  131. extern void SLmemset (char *, char, int);
  132. extern char *SLmemchr (register char *, register char, register int);
  133. extern char *SLmemcpy (char *, char *, int);
  134. extern int SLmemcmp (char *, char *, int);
  135. /*}}}*/
  136. /*{{{ Interpreter Typedefs */
  137. typedef unsigned char SLtype; /* This will be unsigned int in V2 */
  138. typedef struct _SLang_Name_Type
  139. {
  140. char *name;
  141. struct _SLang_Name_Type *next;
  142. char name_type;
  143. /* These values must be less than 0x10 because they map directly
  144. * to byte codes. See _slang.h.
  145. */
  146. #define SLANG_LVARIABLE 0x01
  147. #define SLANG_GVARIABLE 0x02
  148. #define SLANG_IVARIABLE 0x03 /* intrinsic variables */
  149. /* Note!!! For Macro MAKE_VARIABLE below to work, SLANG_IVARIABLE Must
  150. be 1 less than SLANG_RVARIABLE!!! */
  151. #define SLANG_RVARIABLE 0x04 /* read only variable */
  152. #define SLANG_INTRINSIC 0x05
  153. #define SLANG_FUNCTION 0x06
  154. #define SLANG_MATH_UNARY 0x07
  155. #define SLANG_APP_UNARY 0x08
  156. #define SLANG_ICONSTANT 0x09
  157. #define SLANG_DCONSTANT 0x0A
  158. #define SLANG_PVARIABLE 0x0B /* private */
  159. #define SLANG_PFUNCTION 0x0C /* private */
  160. /* Rest of fields depend on name type */
  161. }
  162. SLang_Name_Type;
  163. typedef struct
  164. {
  165. char *name;
  166. struct _SLang_Name_Type *next; /* this is for the hash table */
  167. char name_type;
  168. FVOID_STAR i_fun; /* address of object */
  169. /* Do not change this without modifying slang.c:execute_intrinsic_fun */
  170. #define SLANG_MAX_INTRIN_ARGS 7
  171. SLtype arg_types [SLANG_MAX_INTRIN_ARGS];
  172. unsigned char num_args;
  173. SLtype return_type;
  174. }
  175. SLang_Intrin_Fun_Type;
  176. typedef struct
  177. {
  178. char *name;
  179. SLang_Name_Type *next;
  180. char name_type;
  181. VOID_STAR addr;
  182. SLtype type;
  183. }
  184. SLang_Intrin_Var_Type;
  185. typedef struct
  186. {
  187. char *name;
  188. SLang_Name_Type *next;
  189. char name_type;
  190. int unary_op;
  191. }
  192. SLang_App_Unary_Type;
  193. typedef struct
  194. {
  195. char *name;
  196. SLang_Name_Type *next;
  197. char name_type;
  198. int unary_op;
  199. }
  200. SLang_Math_Unary_Type;
  201. typedef struct
  202. {
  203. char *name;
  204. SLang_Name_Type *next;
  205. char name_type;
  206. int i;
  207. }
  208. SLang_IConstant_Type;
  209. typedef struct
  210. {
  211. char *name;
  212. SLang_Name_Type *next;
  213. char name_type;
  214. double d;
  215. }
  216. SLang_DConstant_Type;
  217. typedef struct
  218. {
  219. char *field_name; /* gets replaced by slstring at run-time */
  220. unsigned int offset;
  221. SLtype type;
  222. unsigned char read_only;
  223. }
  224. SLang_IStruct_Field_Type;
  225. typedef SLCONST struct
  226. {
  227. char *field_name;
  228. unsigned int offset;
  229. SLtype type;
  230. unsigned char read_only;
  231. }
  232. SLang_CStruct_Field_Type;
  233. extern int SLadd_intrin_fun_table (SLang_Intrin_Fun_Type *, char *);
  234. extern int SLadd_intrin_var_table (SLang_Intrin_Var_Type *, char *);
  235. extern int SLadd_app_unary_table (SLang_App_Unary_Type *, char *);
  236. extern int SLadd_math_unary_table (SLang_Math_Unary_Type *, char *);
  237. extern int SLadd_iconstant_table (SLang_IConstant_Type *, char *);
  238. extern int SLadd_dconstant_table (SLang_DConstant_Type *, char *);
  239. extern int SLadd_istruct_table (SLang_IStruct_Field_Type *, VOID_STAR, char *);
  240. typedef struct _SLang_NameSpace_Type SLang_NameSpace_Type;
  241. extern int SLns_add_intrin_fun_table (SLang_NameSpace_Type *, SLang_Intrin_Fun_Type *, char *);
  242. extern int SLns_add_intrin_var_table (SLang_NameSpace_Type *, SLang_Intrin_Var_Type *, char *);
  243. extern int SLns_add_app_unary_table (SLang_NameSpace_Type *, SLang_App_Unary_Type *, char *);
  244. extern int SLns_add_math_unary_table (SLang_NameSpace_Type *, SLang_Math_Unary_Type *, char *);
  245. extern int SLns_add_iconstant_table (SLang_NameSpace_Type *, SLang_IConstant_Type *, char *);
  246. extern int SLns_add_dconstant_table (SLang_NameSpace_Type *, SLang_DConstant_Type *, char *);
  247. extern int SLns_add_istruct_table (SLang_NameSpace_Type *, SLang_IStruct_Field_Type *, VOID_STAR, char *);
  248. extern SLang_NameSpace_Type *SLns_create_namespace (char *);
  249. extern void SLns_delete_namespace (SLang_NameSpace_Type *);
  250. extern int SLns_load_file (char *, char *);
  251. extern int SLns_load_string (char *, char *);
  252. extern int (*SLns_Load_File_Hook) (char *, char *);
  253. int SLang_load_file_verbose (int);
  254. /* if non-zero, display file loading messages */
  255. typedef struct SLang_Load_Type
  256. {
  257. int type;
  258. VOID_STAR client_data;
  259. /* Pointer to data that client needs for loading */
  260. int auto_declare_globals;
  261. /* if non-zero, undefined global variables are declared as static */
  262. char *(*read)(struct SLang_Load_Type *);
  263. /* function to call to read next line from obj. */
  264. unsigned int line_num;
  265. /* Number of lines read, used for error reporting */
  266. int parse_level;
  267. /* 0 if at top level of parsing */
  268. char *name;
  269. /* Name of this object, e.g., filename. This name should be unique because
  270. * it alone determines the name space for static objects associated with
  271. * the compilable unit.
  272. */
  273. char *namespace_name;
  274. unsigned long reserved[3];
  275. /* For future expansion */
  276. } SLang_Load_Type;
  277. extern SLang_Load_Type *SLallocate_load_type (char *);
  278. extern void SLdeallocate_load_type (SLang_Load_Type *);
  279. extern SLang_Load_Type *SLns_allocate_load_type (char *, char *);
  280. /* Returns SLang_Error upon failure */
  281. extern int SLang_load_object (SLang_Load_Type *);
  282. extern int (*SLang_Load_File_Hook)(char *);
  283. extern int (*SLang_Auto_Declare_Var_Hook) (char *);
  284. extern int SLang_generate_debug_info (int);
  285. #if defined(ultrix) && !defined(__GNUC__)
  286. # ifndef NO_PROTOTYPES
  287. # define NO_PROTOTYPES
  288. # endif
  289. #endif
  290. #ifndef NO_PROTOTYPES
  291. # define _PROTO(x) x
  292. #else
  293. # define _PROTO(x) ()
  294. #endif
  295. typedef struct SL_OOBinary_Type
  296. {
  297. SLtype data_type; /* partner type for binary op */
  298. int (*binary_function)_PROTO((int,
  299. SLtype, VOID_STAR, unsigned int,
  300. SLtype, VOID_STAR, unsigned int,
  301. VOID_STAR));
  302. int (*binary_result) _PROTO((int, SLtype, SLtype, SLtype *));
  303. struct SL_OOBinary_Type *next;
  304. }
  305. SL_OOBinary_Type;
  306. typedef struct _SL_Typecast_Type
  307. {
  308. SLtype data_type; /* to_type */
  309. int allow_implicit;
  310. int (*typecast)_PROTO((SLtype, VOID_STAR, unsigned int,
  311. SLtype, VOID_STAR));
  312. struct _SL_Typecast_Type *next;
  313. }
  314. SL_Typecast_Type;
  315. typedef struct _SLang_Struct_Type SLang_Struct_Type;
  316. typedef struct _SLang_Foreach_Context_Type SLang_Foreach_Context_Type;
  317. #if 0
  318. #if defined(SL_APP_WANTS_FOREACH)
  319. typedef struct _SLang_Foreach_Context_Type SLang_Foreach_Context_Type;
  320. /* It is up to the application to define struct _SLang_Foreach_Context_Type */
  321. #else
  322. typedef int SLang_Foreach_Context_Type;
  323. #endif
  324. #endif
  325. typedef struct
  326. {
  327. unsigned char cl_class_type;
  328. #define SLANG_CLASS_TYPE_MMT 0
  329. #define SLANG_CLASS_TYPE_SCALAR 1
  330. #define SLANG_CLASS_TYPE_VECTOR 2
  331. #define SLANG_CLASS_TYPE_PTR 3
  332. unsigned int cl_data_type; /* SLANG_INTEGER_TYPE, etc... */
  333. char *cl_name; /* slstring type */
  334. unsigned int cl_sizeof_type;
  335. VOID_STAR cl_transfer_buf; /* cl_sizeof_type bytes*/
  336. /* Methods */
  337. /* Most of the method functions are prototyped:
  338. * int method (SLtype type, VOID_STAR addr);
  339. * Here, @type@ represents the type of object that the method is asked
  340. * to deal with. The second parameter @addr@ will contain the ADDRESS of
  341. * the object. For example, if type is SLANG_INT_TYPE, then @addr@ will
  342. * actually be int *. Similary, if type is SLANG_STRING_TYPE,
  343. * then @addr@ will contain the address of the string, i.e., char **.
  344. */
  345. void (*cl_destroy)_PROTO((SLtype, VOID_STAR));
  346. /* Prototype: void destroy(unsigned type, VOID_STAR val)
  347. * Called to delete/free the object */
  348. char *(*cl_string)_PROTO((SLtype, VOID_STAR));
  349. /* Prototype: char *to_string (SLtype t, VOID_STAR p);
  350. * Here p is a pointer to the object for which a string representation
  351. * is to be returned. The returned pointer is to be a MALLOCED string.
  352. */
  353. /* Prototype: void push(SLtype type, VOID_STAR v);
  354. * Push a copy of the object of type @type@ at address @v@ onto the
  355. * stack.
  356. */
  357. int (*cl_push)_PROTO((SLtype, VOID_STAR));
  358. /* Prototype: int pop(SLtype type, VOID_STAR v);
  359. * Pops value from stack and assign it to object, whose address is @v@.
  360. */
  361. int (*cl_pop)_PROTO((SLtype, VOID_STAR));
  362. int (*cl_unary_op_result_type)_PROTO((int, SLtype, SLtype *));
  363. int (*cl_unary_op)_PROTO((int, SLtype, VOID_STAR, unsigned int, VOID_STAR));
  364. int (*cl_app_unary_op_result_type)_PROTO((int, SLtype, SLtype *));
  365. int (*cl_app_unary_op)_PROTO((int, SLtype, VOID_STAR, unsigned int, VOID_STAR));
  366. /* If this function is non-NULL, it will be called for sin, cos, etc... */
  367. #define SLMATH_SIN 1
  368. #define SLMATH_COS 2
  369. #define SLMATH_TAN 3
  370. #define SLMATH_ATAN 4
  371. #define SLMATH_ASIN 5
  372. #define SLMATH_ACOS 6
  373. #define SLMATH_EXP 7
  374. #define SLMATH_LOG 8
  375. #define SLMATH_SQRT 9
  376. #define SLMATH_LOG10 10
  377. #define SLMATH_REAL 11
  378. #define SLMATH_IMAG 12
  379. #define SLMATH_SINH 13
  380. #define SLMATH_COSH 14
  381. #define SLMATH_TANH 15
  382. #define SLMATH_ATANH 16
  383. #define SLMATH_ASINH 17
  384. #define SLMATH_ACOSH 18
  385. #define SLMATH_TODOUBLE 19
  386. #define SLMATH_CONJ 20
  387. int (*cl_math_op)_PROTO((int, SLtype, VOID_STAR, unsigned int, VOID_STAR));
  388. int (*cl_math_op_result_type)_PROTO((int, SLtype, SLtype *));
  389. SL_OOBinary_Type *cl_binary_ops;
  390. SL_Typecast_Type *cl_typecast_funs;
  391. void (*cl_byte_code_destroy)_PROTO((SLtype, VOID_STAR));
  392. void (*cl_user_destroy_fun)_PROTO((SLtype, VOID_STAR));
  393. int (*cl_init_array_object)_PROTO((SLtype, VOID_STAR));
  394. int (*cl_datatype_deref)_PROTO((SLtype));
  395. SLang_Struct_Type *cl_struct_def;
  396. int (*cl_dereference) _PROTO((SLtype, VOID_STAR));
  397. int (*cl_acopy) (SLtype, VOID_STAR, VOID_STAR);
  398. int (*cl_apop) _PROTO((SLtype, VOID_STAR));
  399. int (*cl_apush) _PROTO((SLtype, VOID_STAR));
  400. int (*cl_push_literal) _PROTO((SLtype, VOID_STAR));
  401. void (*cl_adestroy)_PROTO((SLtype, VOID_STAR));
  402. int (*cl_push_intrinsic)_PROTO((SLtype, VOID_STAR));
  403. int (*cl_void_typecast)_PROTO((SLtype, VOID_STAR, unsigned int, SLtype, VOID_STAR));
  404. int (*cl_anytype_typecast)_PROTO((SLtype, VOID_STAR, unsigned int, SLtype, VOID_STAR));
  405. /* Array access functions */
  406. int (*cl_aput) (SLtype, unsigned int);
  407. int (*cl_aget) (SLtype, unsigned int);
  408. int (*cl_anew) (SLtype, unsigned int);
  409. /* length method */
  410. int (*cl_length) (SLtype, VOID_STAR, unsigned int *);
  411. /* foreach */
  412. SLang_Foreach_Context_Type *(*cl_foreach_open) (SLtype, unsigned int);
  413. void (*cl_foreach_close) (SLtype, SLang_Foreach_Context_Type *);
  414. int (*cl_foreach) (SLtype, SLang_Foreach_Context_Type *);
  415. /* Structure access: get and put (assign to) fields */
  416. int (*cl_sput) (SLtype, char *);
  417. int (*cl_sget) (SLtype, char *);
  418. /* File I/O */
  419. int (*cl_fread) (SLtype, FILE *, VOID_STAR, unsigned int, unsigned int *);
  420. int (*cl_fwrite) (SLtype, FILE *, VOID_STAR, unsigned int, unsigned int *);
  421. int (*cl_fdread) (SLtype, int, VOID_STAR, unsigned int, unsigned int *);
  422. int (*cl_fdwrite) (SLtype, int, VOID_STAR, unsigned int, unsigned int *);
  423. int (*cl_to_bool) (SLtype, int *);
  424. int (*cl_cmp)(SLtype, VOID_STAR, VOID_STAR, int *);
  425. } SLang_Class_Type;
  426. /* These are the low-level functions for building push/pop methods. They
  427. * know nothing about memory management. For SLANG_CLASS_TYPE_MMT, use the
  428. * MMT push/pop functions instead.
  429. */
  430. extern int SLclass_push_double_obj (SLtype, double);
  431. extern int SLclass_push_float_obj (SLtype, float);
  432. extern int SLclass_push_long_obj (SLtype, long);
  433. extern int SLclass_push_int_obj (SLtype, int);
  434. extern int SLclass_push_short_obj (SLtype, short);
  435. extern int SLclass_push_char_obj (SLtype, char);
  436. extern int SLclass_push_ptr_obj (SLtype, VOID_STAR);
  437. extern int SLclass_pop_double_obj (SLtype, double *);
  438. extern int SLclass_pop_float_obj (SLtype, float *);
  439. extern int SLclass_pop_long_obj (SLtype, long *);
  440. extern int SLclass_pop_int_obj (SLtype, int *);
  441. extern int SLclass_pop_short_obj (SLtype, short *);
  442. extern int SLclass_pop_char_obj (SLtype, char *);
  443. extern int SLclass_pop_ptr_obj (SLtype, VOID_STAR *);
  444. extern SLang_Class_Type *SLclass_allocate_class (char *);
  445. extern int SLclass_get_class_id (SLang_Class_Type *cl);
  446. extern int SLclass_create_synonym (char *, SLtype);
  447. extern int SLclass_is_class_defined (SLtype);
  448. extern int SLclass_dup_object (SLtype type, VOID_STAR from, VOID_STAR to);
  449. extern int SLclass_register_class (SLang_Class_Type *, SLtype, unsigned int, SLtype);
  450. extern int SLclass_set_string_function (SLang_Class_Type *, char *(*)(SLtype, VOID_STAR));
  451. extern int SLclass_set_destroy_function (SLang_Class_Type *, void (*)(SLtype, VOID_STAR));
  452. extern int SLclass_set_push_function (SLang_Class_Type *, int (*)(SLtype, VOID_STAR));
  453. extern int SLclass_set_apush_function (SLang_Class_Type *, int (*)(SLtype, VOID_STAR));
  454. extern int SLclass_set_pop_function (SLang_Class_Type *, int (*)(SLtype, VOID_STAR));
  455. extern int SLclass_set_aget_function (SLang_Class_Type *, int (*)(SLtype, unsigned int));
  456. extern int SLclass_set_aput_function (SLang_Class_Type *, int (*)(SLtype, unsigned int));
  457. extern int SLclass_set_anew_function (SLang_Class_Type *, int (*)(SLtype, unsigned int));
  458. extern int SLclass_set_sget_function (SLang_Class_Type *, int (*)(SLtype, char *));
  459. extern int SLclass_set_sput_function (SLang_Class_Type *, int (*)(SLtype, char *));
  460. extern int SLclass_set_acopy_function (SLang_Class_Type *, int (*)(SLtype, VOID_STAR, VOID_STAR));
  461. /* Typecast object on the stack to type p1. p2 and p3 should be set to 1 */
  462. extern int SLclass_typecast (SLtype, int, int);
  463. extern int SLclass_add_unary_op (SLtype,
  464. int (*) (int,
  465. SLtype, VOID_STAR, unsigned int,
  466. VOID_STAR),
  467. int (*) (int, SLtype, SLtype *));
  468. extern int
  469. SLclass_add_app_unary_op (SLtype,
  470. int (*) (int,
  471. SLtype, VOID_STAR, unsigned int,
  472. VOID_STAR),
  473. int (*) (int, SLtype, SLtype *));
  474. extern int
  475. SLclass_add_binary_op (SLtype, SLtype,
  476. int (*) (int,
  477. SLtype, VOID_STAR, unsigned int,
  478. SLtype, VOID_STAR, unsigned int,
  479. VOID_STAR),
  480. int (*) (int, SLtype, SLtype, SLtype *));
  481. extern int
  482. SLclass_add_math_op (SLtype,
  483. int (*)(int,
  484. SLtype, VOID_STAR, unsigned int,
  485. VOID_STAR),
  486. int (*)(int, SLtype, SLtype *));
  487. extern int
  488. SLclass_add_typecast (SLtype /* from */, SLtype /* to */,
  489. int (*)_PROTO((SLtype, VOID_STAR, unsigned int,
  490. SLtype, VOID_STAR)),
  491. int /* allow implicit typecasts */
  492. );
  493. extern char *SLclass_get_datatype_name (SLtype);
  494. extern double SLcomplex_abs (double *);
  495. extern double *SLcomplex_times (double *, double *, double *);
  496. extern double *SLcomplex_divide (double *, double *, double *);
  497. extern double *SLcomplex_sin (double *, double *);
  498. extern double *SLcomplex_cos (double *, double *);
  499. extern double *SLcomplex_tan (double *, double *);
  500. extern double *SLcomplex_asin (double *, double *);
  501. extern double *SLcomplex_acos (double *, double *);
  502. extern double *SLcomplex_atan (double *, double *);
  503. extern double *SLcomplex_exp (double *, double *);
  504. extern double *SLcomplex_log (double *, double *);
  505. extern double *SLcomplex_log10 (double *, double *);
  506. extern double *SLcomplex_sqrt (double *, double *);
  507. extern double *SLcomplex_sinh (double *, double *);
  508. extern double *SLcomplex_cosh (double *, double *);
  509. extern double *SLcomplex_tanh (double *, double *);
  510. extern double *SLcomplex_pow (double *, double *, double *);
  511. extern double SLmath_hypot (double x, double y);
  512. /* Not implemented yet */
  513. extern double *SLcomplex_asinh (double *, double *);
  514. extern double *SLcomplex_acosh (double *, double *);
  515. extern double *SLcomplex_atanh (double *, double *);
  516. #ifdef _SLANG_SOURCE_
  517. typedef struct _SLang_MMT_Type SLang_MMT_Type;
  518. #else
  519. typedef int SLang_MMT_Type;
  520. #endif
  521. extern void SLang_free_mmt (SLang_MMT_Type *);
  522. extern VOID_STAR SLang_object_from_mmt (SLang_MMT_Type *);
  523. extern SLang_MMT_Type *SLang_create_mmt (SLtype, VOID_STAR);
  524. extern int SLang_push_mmt (SLang_MMT_Type *);
  525. extern SLang_MMT_Type *SLang_pop_mmt (SLtype);
  526. extern void SLang_inc_mmt (SLang_MMT_Type *);
  527. /* Maximum number of dimensions of an array. */
  528. #define SLARRAY_MAX_DIMS 7
  529. typedef struct _SLang_Array_Type
  530. {
  531. SLtype data_type;
  532. unsigned int sizeof_type;
  533. VOID_STAR data;
  534. unsigned int num_elements;
  535. unsigned int num_dims;
  536. int dims [SLARRAY_MAX_DIMS];
  537. VOID_STAR (*index_fun)_PROTO((struct _SLang_Array_Type *, int *));
  538. /* This function is designed to allow a type to store an array in
  539. * any manner it chooses. This function returns the address of the data
  540. * value at the specified index location.
  541. */
  542. unsigned int flags;
  543. #define SLARR_DATA_VALUE_IS_READ_ONLY 1
  544. #define SLARR_DATA_VALUE_IS_POINTER 2
  545. #define SLARR_DATA_VALUE_IS_RANGE 4
  546. #define SLARR_DATA_VALUE_IS_INTRINSIC 8
  547. SLang_Class_Type *cl;
  548. unsigned int num_refs;
  549. void (*free_fun)_PROTO((struct _SLang_Array_Type *));
  550. VOID_STAR client_data;
  551. }
  552. SLang_Array_Type;
  553. extern int SLang_pop_array_of_type (SLang_Array_Type **, SLtype);
  554. extern int SLang_pop_array (SLang_Array_Type **, int);
  555. extern int SLang_push_array (SLang_Array_Type *, int);
  556. extern void SLang_free_array (SLang_Array_Type *);
  557. extern SLang_Array_Type *SLang_create_array (SLtype, int, VOID_STAR, int *, unsigned int);
  558. extern SLang_Array_Type *SLang_duplicate_array (SLang_Array_Type *);
  559. extern int SLang_get_array_element (SLang_Array_Type *, int *, VOID_STAR);
  560. extern int SLang_set_array_element (SLang_Array_Type *, int *, VOID_STAR);
  561. typedef int SLarray_Contract_Fun_Type (VOID_STAR xp, unsigned int increment, unsigned int num, VOID_STAR yp);
  562. typedef struct
  563. {
  564. SLtype from_type; /* if array is this type */
  565. SLtype typecast_to_type; /* typecast it to this */
  566. SLtype result_type; /* to produce this */
  567. SLarray_Contract_Fun_Type *f; /* via this function */
  568. }
  569. SLarray_Contract_Type;
  570. extern int SLarray_contract_array (SLCONST SLarray_Contract_Type *);
  571. typedef int SLarray_Map_Fun_Type (SLtype xtype, VOID_STAR xp,
  572. unsigned int increment, unsigned int num,
  573. SLtype ytype, VOID_STAR yp, VOID_STAR clientdata);
  574. typedef struct
  575. {
  576. SLtype from_type; /* if array is this type */
  577. SLtype typecast_to_type; /* typecast it to this */
  578. SLtype result_type; /* to produce this */
  579. SLarray_Map_Fun_Type *f; /* via this function */
  580. }
  581. SLarray_Map_Type;
  582. extern int SLarray_map_array_1 (SLCONST SLarray_Map_Type *,
  583. int *use_this_dim,
  584. VOID_STAR clientdata);
  585. extern int SLarray_map_array (SLCONST SLarray_Map_Type *);
  586. /*}}}*/
  587. /*{{{ Interpreter Function Prototypes */
  588. extern volatile int SLang_Error;
  589. /* Non zero if error occurs. Must be reset to zero to continue. */
  590. /* error codes, severe errors are less than 0 */
  591. #define SL_APPLICATION_ERROR -2
  592. #define SL_VARIABLE_UNINITIALIZED -3
  593. #define SL_INTERNAL_ERROR -5
  594. #define SL_STACK_OVERFLOW -6
  595. #define SL_STACK_UNDERFLOW -7
  596. #define SL_UNDEFINED_NAME -8
  597. #define SL_SYNTAX_ERROR -9
  598. #define SL_DUPLICATE_DEFINITION -10
  599. #define SL_TYPE_MISMATCH -11
  600. #define SL_OBJ_UNKNOWN -13
  601. #define SL_UNKNOWN_ERROR -14
  602. #define SL_TYPE_UNDEFINED_OP_ERROR -16
  603. #define SL_INTRINSIC_ERROR 1
  604. /* Intrinsic error is an error generated by intrinsic functions */
  605. #define SL_USER_BREAK 2
  606. #define SL_DIVIDE_ERROR 3
  607. #define SL_OBJ_NOPEN 4
  608. #define SL_USER_ERROR 5
  609. #define SL_USAGE_ERROR 6
  610. #define SL_READONLY_ERROR 7
  611. #define SL_INVALID_PARM 8
  612. #define SL_NOT_IMPLEMENTED 9
  613. #define SL_MALLOC_ERROR 10
  614. #define SL_OVERFLOW 11
  615. #define SL_FLOATING_EXCEPTION 12
  616. /* Compatibility */
  617. #define USER_BREAK SL_USER_BREAK
  618. #define INTRINSIC_ERROR SL_INTRINSIC_ERROR
  619. extern int SLang_Traceback;
  620. /* If non-zero, dump an S-Lang traceback upon error. Available as
  621. _traceback in S-Lang. */
  622. extern char *SLang_User_Prompt;
  623. /* Prompt to use when reading from stdin */
  624. extern const int SLang_Version;
  625. extern char *SLang_Version_String;
  626. extern char *SLang_Doc_Dir;
  627. extern void (*SLang_VMessage_Hook) (char *, va_list);
  628. extern void SLang_vmessage (char *, ...) _SLATTRIBUTE_PRINTF(1,2);
  629. extern void (*SLang_Error_Hook)(char *);
  630. /* Pointer to application dependent error messaging routine. By default,
  631. messages are displayed on stderr. */
  632. extern void (*SLang_Exit_Error_Hook)(char *, va_list);
  633. extern void SLang_exit_error (char *, ...) _SLATTRIBUTE_((format (printf, 1, 2), noreturn));
  634. extern void (*SLang_Dump_Routine)(char *);
  635. /* Called if S-Lang traceback is enabled as well as other debugging
  636. routines (e.g., trace). By default, these messages go to stderr. */
  637. extern void (*SLang_Interrupt)(void);
  638. /* function to call whenever inner interpreter is entered. This is
  639. a good place to set SLang_Error to USER_BREAK. */
  640. extern void (*SLang_User_Clear_Error)(void);
  641. /* function that gets called when '_clear_error' is called. */
  642. /* If non null, these call C functions before and after a slang function. */
  643. extern void (*SLang_Enter_Function)(char *);
  644. extern void (*SLang_Exit_Function)(char *);
  645. extern int SLang_Num_Function_Args;
  646. /* Functions: */
  647. extern int SLang_init_all (void);
  648. /* Initializes interpreter and all modules */
  649. extern int SLang_init_slang (void);
  650. /* This function is mandatory and must be called by all applications that
  651. * use the interpreter
  652. */
  653. extern int SLang_init_posix_process (void); /* process specific intrinsics */
  654. extern int SLang_init_stdio (void); /* fgets, etc. stdio functions */
  655. extern int SLang_init_posix_dir (void);
  656. extern int SLang_init_ospath (void);
  657. extern int SLang_init_slmath (void);
  658. /* called if math functions sin, cos, etc... are needed. */
  659. extern int SLang_init_slfile (void);
  660. extern int SLang_init_slunix (void);
  661. /* These functions are obsolte. Use init_stdio, posix_process, etc. */
  662. extern int SLang_init_slassoc (void);
  663. /* Assoc Arrays (Hashes) */
  664. extern int SLang_init_array (void);
  665. /* Additional arrays functions: transpose, etc... */
  666. extern int SLang_init_array_extra (void);
  667. /* Additional arrays functions: sum, min, max, ... */
  668. /* Dynamic linking facility */
  669. extern int SLang_init_import (void);
  670. extern int SLang_load_file (char *);
  671. /* Load a file of S-Lang code for interpreting. If the parameter is
  672. * NULL, input comes from stdin. */
  673. extern void SLang_restart(int);
  674. /* should be called if an error occurs. If the passed integer is
  675. * non-zero, items are popped off the stack; otherwise, the stack is
  676. * left intact. Any time the stack is believed to be trashed, this routine
  677. * should be called with a non-zero argument (e.g., if setjmp/longjmp is
  678. * called). */
  679. extern int SLang_byte_compile_file(char *, int);
  680. /* takes a file of S-Lang code and ``byte-compiles'' it for faster
  681. * loading. The new filename is equivalent to the old except that a `c' is
  682. * appended to the name. (e.g., init.sl --> init.slc). The second
  683. * specified the method; currently, it is not used.
  684. */
  685. extern int SLang_autoload(char *, char *);
  686. /* Automatically load S-Lang function p1 from file p2. This function
  687. is also available via S-Lang */
  688. extern int SLang_load_string(char *);
  689. /* Like SLang_load_file except input is from a null terminated string. */
  690. extern int SLdo_pop(void);
  691. /* pops item off stack and frees any memory associated with it */
  692. extern int SLdo_pop_n(unsigned int);
  693. /* pops n items off stack and frees any memory associated with them */
  694. extern int SLang_pop_datatype (SLtype *);
  695. extern int SLang_push_datatype (SLtype);
  696. extern int SLang_pop_integer(int *);
  697. extern int SLang_pop_uinteger(unsigned int *);
  698. /* pops integer *p0 from the stack. Returns 0 upon success and non-zero
  699. * if the stack is empty or a type mismatch occurs, setting SLang_Error.
  700. */
  701. extern int SLang_pop_char (char *);
  702. extern int SLang_pop_uchar (SLtype *);
  703. extern int SLang_pop_short(short *);
  704. extern int SLang_pop_ushort(unsigned short *);
  705. extern int SLang_pop_long(long *);
  706. extern int SLang_pop_ulong(unsigned long *);
  707. extern int SLang_pop_float(float *);
  708. extern int SLang_pop_double(double *, int *, int *);
  709. /* Pops double *p1 from stack. If *p3 is non-zero, *p1 was derived
  710. from the integer *p2. Returns zero upon success. */
  711. extern int SLang_pop_complex (double *, double *);
  712. extern int SLpop_string (char **);
  713. extern int SLang_pop_string(char **, int *);
  714. /* pops string *p0 from stack. If *p1 is non-zero, the string must be
  715. * freed after its use. DO NOT FREE p0 if *p1 IS ZERO! Returns 0 upon
  716. * success */
  717. extern int SLang_push_complex (double, double);
  718. extern int SLang_push_char (char);
  719. extern int SLang_push_uchar (SLtype);
  720. extern int SLang_push_integer(int);
  721. extern int SLang_push_uinteger(unsigned int);
  722. /* push integer p1 on stack */
  723. extern int SLang_push_short(short);
  724. extern int SLang_push_ushort(unsigned short);
  725. extern int SLang_push_long(long);
  726. extern int SLang_push_ulong(unsigned long);
  727. extern int SLang_push_float(float);
  728. extern int SLang_push_double(double);
  729. /* Push double onto stack */
  730. extern int SLang_push_string(char *);
  731. /* Push string p1 onto stack */
  732. extern int SLang_push_malloced_string(char *);
  733. /* The normal SLang_push_string pushes an slstring. This one converts
  734. * a normally malloced string to an slstring, and then frees the
  735. * malloced string. So, do NOT use the malloced string after calling
  736. * this routine because it will be freed! The routine returns -1 upon
  737. * error, but the string will be freed.
  738. */
  739. extern int SLang_push_null (void);
  740. extern int SLang_pop_null (void);
  741. extern int SLang_push_value (SLtype type, VOID_STAR);
  742. extern int SLang_pop_value (SLtype type, VOID_STAR);
  743. extern void SLang_free_value (SLtype type, VOID_STAR);
  744. typedef struct _SLang_Object_Type SLang_Any_Type;
  745. extern int SLang_pop_anytype (SLang_Any_Type **);
  746. extern int SLang_push_anytype (SLang_Any_Type *);
  747. extern void SLang_free_anytype (SLang_Any_Type *);
  748. #ifdef _SLANG_SOURCE_
  749. typedef struct _SLang_Ref_Type SLang_Ref_Type;
  750. #else
  751. typedef int SLang_Ref_Type;
  752. #endif
  753. extern int SLang_pop_ref (SLang_Ref_Type **);
  754. extern void SLang_free_ref (SLang_Ref_Type *);
  755. extern int SLang_assign_to_ref (SLang_Ref_Type *, SLtype, VOID_STAR);
  756. extern SLang_Name_Type *SLang_pop_function (void);
  757. extern SLang_Name_Type *SLang_get_fun_from_ref (SLang_Ref_Type *);
  758. extern void SLang_free_function (SLang_Name_Type *f);
  759. /* C structure interface */
  760. extern int SLang_push_cstruct (VOID_STAR, SLang_CStruct_Field_Type *);
  761. extern int SLang_pop_cstruct (VOID_STAR, SLang_CStruct_Field_Type *);
  762. extern void SLang_free_cstruct (VOID_STAR, SLang_CStruct_Field_Type *);
  763. extern int SLang_assign_cstruct_to_ref (SLang_Ref_Type *, VOID_STAR, SLang_CStruct_Field_Type *);
  764. extern int SLang_is_defined(char *);
  765. /* Return non-zero is p1 is defined otherwise returns 0. */
  766. extern int SLang_run_hooks(char *, unsigned int, ...);
  767. /* calls S-Lang function p1 pushing p2 strings in the variable argument
  768. * list onto the stack first.
  769. * Returns -1 upon error, 1 if hooks exists and it ran,
  770. * or 0 if hook does not exist. Thus it returns non-zero is hook was called.
  771. */
  772. /* These functions return 1 if the indicated function exists and the function
  773. * runs without error. If the function does not exist, the function returns
  774. * 0. Otherwise -1 is returned with SLang_Error set appropriately.
  775. */
  776. extern int SLexecute_function (SLang_Name_Type *);
  777. extern int SLang_execute_function(char *);
  778. extern int SLang_end_arg_list (void);
  779. extern int SLang_start_arg_list (void);
  780. extern void SLang_verror (int, char *, ...) _SLATTRIBUTE_PRINTF(2,3);
  781. extern void SLang_doerror(char *);
  782. /* set SLang_Error and display p1 as error message */
  783. extern int SLang_add_intrinsic_array (char *, /* name */
  784. SLtype, /* type */
  785. int, /* readonly */
  786. VOID_STAR, /* data */
  787. unsigned int, ...); /* num dims */
  788. extern int SLextract_list_element (char *, unsigned int, char,
  789. char *, unsigned int);
  790. extern void SLexpand_escaped_string (register char *, register char *,
  791. register char *);
  792. extern SLang_Name_Type *SLang_get_function (char *);
  793. extern void SLang_release_function (SLang_Name_Type *);
  794. extern int SLreverse_stack (int);
  795. extern int SLroll_stack (int);
  796. /* If argument p is positive, the top p objects on the stack are rolled
  797. * up. If negative, the stack is rolled down.
  798. */
  799. extern int SLdup_n (int n);
  800. /* Duplicate top n elements of stack */
  801. extern int SLang_peek_at_stack1 (void);
  802. extern int SLang_peek_at_stack (void);
  803. /* Returns type of next object on stack-- -1 upon stack underflow. */
  804. extern void SLmake_lut (unsigned char *, unsigned char *, unsigned char);
  805. extern int SLang_guess_type (char *);
  806. extern int SLstruct_create_struct (unsigned int,
  807. char **,
  808. SLtype *,
  809. VOID_STAR *);
  810. /*}}}*/
  811. /*{{{ Misc Functions */
  812. /* This is an interface to atexit */
  813. extern int SLang_add_cleanup_function (void (*)(void));
  814. extern char *SLmake_string (char *);
  815. extern char *SLmake_nstring (char *, unsigned int);
  816. /* Returns a null terminated string made from the first n characters of the
  817. * string.
  818. */
  819. /* The string created by this routine must be freed by SLang_free_slstring
  820. * and nothing else!! Also these strings must not be modified. Use
  821. * SLmake_string if you intend to modify them!!
  822. */
  823. extern char *SLang_create_nslstring (char *, unsigned int);
  824. extern char *SLang_create_slstring (char *);
  825. extern void SLang_free_slstring (char *); /* handles NULL */
  826. extern int SLang_pop_slstring (char **); /* free with SLang_free_slstring */
  827. extern char *SLang_concat_slstrings (char *a, char *b);
  828. extern char *SLang_create_static_slstring (char *); /* adds a string that will not get deleted */
  829. extern void SLstring_dump_stats (void);
  830. /* Binary strings */
  831. /* The binary string is an opaque type. Use the SLbstring_get_pointer function
  832. * to get a pointer and length.
  833. */
  834. typedef struct _SLang_BString_Type SLang_BString_Type;
  835. extern unsigned char *SLbstring_get_pointer (SLang_BString_Type *, unsigned int *);
  836. extern SLang_BString_Type *SLbstring_dup (SLang_BString_Type *);
  837. extern SLang_BString_Type *SLbstring_create (unsigned char *, unsigned int);
  838. /* The create_malloced function used the first argument which is assumed
  839. * to be a pointer to a len + 1 malloced string. The extra byte is for
  840. * \0 termination.
  841. */
  842. extern SLang_BString_Type *SLbstring_create_malloced (unsigned char *, unsigned int, int);
  843. /* Create a bstring from an slstring */
  844. extern SLang_BString_Type *SLbstring_create_slstring (char *);
  845. extern void SLbstring_free (SLang_BString_Type *);
  846. extern int SLang_pop_bstring (SLang_BString_Type **);
  847. extern int SLang_push_bstring (SLang_BString_Type *);
  848. extern char *SLmalloc (unsigned int);
  849. extern char *SLcalloc (unsigned int, unsigned int);
  850. extern void SLfree(char *); /* This function handles NULL */
  851. extern char *SLrealloc (char *, unsigned int);
  852. extern char *SLcurrent_time_string (void);
  853. extern int SLatoi(unsigned char *);
  854. extern long SLatol (unsigned char *);
  855. extern unsigned long SLatoul (unsigned char *);
  856. extern int SLang_pop_fileptr (SLang_MMT_Type **, FILE **);
  857. extern char *SLang_get_name_from_fileptr (SLang_MMT_Type *);
  858. typedef struct _SLFile_FD_Type SLFile_FD_Type;
  859. extern SLFile_FD_Type *SLfile_create_fd (char *, int);
  860. extern void SLfile_free_fd (SLFile_FD_Type *);
  861. extern int SLfile_push_fd (SLFile_FD_Type *);
  862. extern int SLfile_pop_fd (SLFile_FD_Type **);
  863. extern int SLfile_get_fd (SLFile_FD_Type *, int *);
  864. extern SLFile_FD_Type *SLfile_dup_fd (SLFile_FD_Type *f0);
  865. extern int SLang_init_posix_io (void);
  866. typedef double (*SLang_To_Double_Fun_Type)(VOID_STAR);
  867. extern SLang_To_Double_Fun_Type SLarith_get_to_double_fun (SLtype, unsigned int *);
  868. extern int SLang_set_argc_argv (int, char **);
  869. /*}}}*/
  870. /*{{{ SLang getkey interface Functions */
  871. #ifdef REAL_UNIX_SYSTEM
  872. extern int SLang_TT_Baud_Rate;
  873. extern int SLang_TT_Read_FD;
  874. #endif
  875. extern int SLang_init_tty (int, int, int);
  876. /* Initializes the tty for single character input. If the first parameter *p1
  877. * is in the range 0-255, it will be used for the abort character;
  878. * otherwise, (unix only) if it is -1, the abort character will be the one
  879. * used by the terminal. If the second parameter p2 is non-zero, flow
  880. * control is enabled. If the last parmeter p3 is zero, output processing
  881. * is NOT turned on. A value of zero is required for the screen management
  882. * routines. Returns 0 upon success. In addition, if SLang_TT_Baud_Rate ==
  883. * 0 when this function is called, SLang will attempt to determine the
  884. * terminals baud rate. As far as the SLang library is concerned, if
  885. * SLang_TT_Baud_Rate is less than or equal to zero, the baud rate is
  886. * effectively infinite.
  887. */
  888. extern void SLang_reset_tty (void);
  889. /* Resets tty to what it was prior to a call to SLang_init_tty */
  890. #ifdef REAL_UNIX_SYSTEM
  891. extern void SLtty_set_suspend_state (int);
  892. /* If non-zero argument, terminal driver will be told to react to the
  893. * suspend character. If 0, it will not.
  894. */
  895. extern int (*SLang_getkey_intr_hook) (void);
  896. #endif
  897. #define SLANG_GETKEY_ERROR 0xFFFF
  898. extern unsigned int SLang_getkey (void);
  899. /* reads a single key from the tty. If the read fails, 0xFFFF is returned. */
  900. #ifdef IBMPC_SYSTEM
  901. extern int SLgetkey_map_to_ansi (int);
  902. #endif
  903. extern int SLang_ungetkey_string (unsigned char *, unsigned int);
  904. extern int SLang_buffer_keystring (unsigned char *, unsigned int);
  905. extern int SLang_ungetkey (unsigned char);
  906. extern void SLang_flush_input (void);
  907. extern int SLang_input_pending (int);
  908. extern int SLang_Abort_Char;
  909. /* The value of the character (0-255) used to trigger SIGINT */
  910. extern int SLang_Ignore_User_Abort;
  911. /* If non-zero, pressing the abort character will not result in USER_BREAK
  912. * SLang_Error. */
  913. extern int SLang_set_abort_signal (void (*)(int));
  914. /* If SIGINT is generated, the function p1 will be called. If p1 is NULL
  915. * the SLang_default signal handler is called. This sets SLang_Error to
  916. * USER_BREAK. I suspect most users will simply want to pass NULL.
  917. */
  918. extern unsigned int SLang_Input_Buffer_Len;
  919. extern volatile int SLKeyBoard_Quit;
  920. #ifdef VMS
  921. /* If this function returns -1, ^Y will be added to input buffer. */
  922. extern int (*SLtty_VMS_Ctrl_Y_Hook) (void);
  923. #endif
  924. /*}}}*/
  925. /*{{{ SLang Keymap routines */
  926. typedef struct SLKeymap_Function_Type
  927. {
  928. char *name;
  929. int (*f)(void);
  930. }
  931. SLKeymap_Function_Type;
  932. #define SLANG_MAX_KEYMAP_KEY_SEQ 14
  933. typedef struct SLang_Key_Type
  934. {
  935. struct SLang_Key_Type *next;
  936. union
  937. {
  938. char *s;
  939. FVOID_STAR f;
  940. unsigned int keysym;
  941. }
  942. f;
  943. unsigned char type; /* type of function */
  944. #define SLKEY_F_INTERPRET 0x01
  945. #define SLKEY_F_INTRINSIC 0x02
  946. #define SLKEY_F_KEYSYM 0x03
  947. unsigned char str[SLANG_MAX_KEYMAP_KEY_SEQ + 1];/* key sequence */
  948. }
  949. SLang_Key_Type;
  950. typedef struct SLKeyMap_List_Type
  951. {
  952. char *name; /* hashed string */
  953. SLang_Key_Type *keymap;
  954. SLKeymap_Function_Type *functions; /* intrinsic functions */
  955. }
  956. SLKeyMap_List_Type;
  957. /* This is arbitrary but I have got to start somewhere */
  958. #define SLANG_MAX_KEYMAPS 30
  959. extern SLKeyMap_List_Type SLKeyMap_List[SLANG_MAX_KEYMAPS];
  960. extern char *SLang_process_keystring(char *);
  961. extern int SLkm_define_key (char *, FVOID_STAR, SLKeyMap_List_Type *);
  962. extern int SLang_define_key(char *, char *, SLKeyMap_List_Type *);
  963. /* Like define_key1 except that p2 is a string that is to be associated with
  964. * a function in the functions field of p3.
  965. */
  966. extern int SLkm_define_keysym (char *, unsigned int, SLKeyMap_List_Type *);
  967. extern void SLang_undefine_key(char *, SLKeyMap_List_Type *);
  968. extern SLKeyMap_List_Type *SLang_create_keymap(char *, SLKeyMap_List_Type *);
  969. /* create and returns a pointer to a new keymap named p1 created by copying
  970. * keymap p2. If p2 is NULL, it is up to the calling routine to initialize
  971. * the keymap.
  972. */
  973. extern char *SLang_make_keystring(unsigned char *);
  974. extern SLang_Key_Type *SLang_do_key(SLKeyMap_List_Type *, int (*)(void));
  975. /* read a key using keymap p1 with getkey function p2 */
  976. extern
  977. FVOID_STAR
  978. SLang_find_key_function(char *, SLKeyMap_List_Type *);
  979. extern SLKeyMap_List_Type *SLang_find_keymap(char *);
  980. extern int SLang_Last_Key_Char;
  981. extern int SLang_Key_TimeOut_Flag;
  982. /*}}}*/
  983. /*{{{ SLang Readline Interface */
  984. typedef struct SLang_Read_Line_Type
  985. {
  986. struct SLang_Read_Line_Type *prev, *next;
  987. unsigned char *buf;
  988. int buf_len; /* number of chars in the buffer */
  989. int num; /* num and misc are application specific*/
  990. int misc;
  991. } SLang_Read_Line_Type;
  992. /* Maximum size of display */
  993. #define SLRL_DISPLAY_BUFFER_SIZE 256
  994. typedef struct
  995. {
  996. SLang_Read_Line_Type *root, *tail, *last;
  997. unsigned char *buf; /* edit buffer */
  998. int buf_len; /* sizeof buffer */
  999. int point; /* current editing point */
  1000. int tab; /* tab width */
  1001. int len; /* current line size */
  1002. /* display variables */
  1003. int edit_width; /* length of display field */
  1004. int curs_pos; /* current column */
  1005. int start_column; /* column offset of display */
  1006. int dhscroll; /* amount to use for horiz scroll */
  1007. char *prompt;
  1008. FVOID_STAR last_fun; /* last function executed by rl */
  1009. /* These two contain an image of what is on the display */
  1010. unsigned char upd_buf1[SLRL_DISPLAY_BUFFER_SIZE];
  1011. unsigned char upd_buf2[SLRL_DISPLAY_BUFFER_SIZE];
  1012. unsigned char *old_upd, *new_upd; /* pointers to previous two buffers */
  1013. int new_upd_len, old_upd_len; /* length of output buffers */
  1014. SLKeyMap_List_Type *keymap;
  1015. /* tty variables */
  1016. unsigned int flags; /* */
  1017. #define SL_RLINE_NO_ECHO 1
  1018. #define SL_RLINE_USE_ANSI 2
  1019. #define SL_RLINE_BLINK_MATCH 4
  1020. unsigned int (*getkey)(void); /* getkey function -- required */
  1021. void (*tt_goto_column)(int);
  1022. void (*tt_insert)(char);
  1023. void (*update_hook)(unsigned char *, int, int);
  1024. /* The update hook is called with a pointer to a buffer p1 that contains
  1025. * an image of what the update hook is suppoed to produce. The length
  1026. * of the buffer is p2 and after the update, the cursor is to be placed
  1027. * in column p3.
  1028. */
  1029. /* This function is only called when blinking matches */
  1030. int (*input_pending)(int);
  1031. unsigned long reserved[4];
  1032. } SLang_RLine_Info_Type;
  1033. extern int SLang_RL_EOF_Char;
  1034. extern SLang_Read_Line_Type * SLang_rline_save_line (SLang_RLine_Info_Type *);
  1035. extern int SLang_init_readline (SLang_RLine_Info_Type *);
  1036. extern int SLang_read_line (SLang_RLine_Info_Type *);
  1037. extern int SLang_rline_insert (char *);
  1038. extern void SLrline_redraw (SLang_RLine_Info_Type *);
  1039. extern int SLang_Rline_Quit;
  1040. /*}}}*/
  1041. /*{{{ Low Level Screen Output Interface */
  1042. extern unsigned long SLtt_Num_Chars_Output;
  1043. extern int SLtt_Baud_Rate;
  1044. typedef unsigned long SLtt_Char_Type;
  1045. #define SLTT_BOLD_MASK 0x01000000UL
  1046. #define SLTT_BLINK_MASK 0x02000000UL
  1047. #define SLTT_ULINE_MASK 0x04000000UL
  1048. #define SLTT_REV_MASK 0x08000000UL
  1049. #define SLTT_ALTC_MASK 0x10000000UL
  1050. extern int SLtt_Screen_Rows;
  1051. extern int SLtt_Screen_Cols;
  1052. extern int SLtt_Term_Cannot_Insert;
  1053. extern int SLtt_Term_Cannot_Scroll;
  1054. extern int SLtt_Use_Ansi_Colors;
  1055. extern int SLtt_Ignore_Beep;
  1056. #if defined(REAL_UNIX_SYSTEM)
  1057. extern int SLtt_Force_Keypad_Init;
  1058. extern int SLang_TT_Write_FD;
  1059. #endif
  1060. #ifndef IBMPC_SYSTEM
  1061. extern char *SLtt_Graphics_Char_Pairs;
  1062. #endif
  1063. #ifndef __GO32__
  1064. #if defined(VMS) || defined(REAL_UNIX_SYSTEM)
  1065. extern int SLtt_Blink_Mode;
  1066. extern int SLtt_Use_Blink_For_ACS;
  1067. extern int SLtt_Newline_Ok;
  1068. extern int SLtt_Has_Alt_Charset;
  1069. extern int SLtt_Has_Status_Line; /* if 0, NO. If > 0, YES, IF -1, ?? */
  1070. # ifndef VMS
  1071. extern int SLtt_Try_Termcap;
  1072. # endif
  1073. #endif
  1074. #endif
  1075. #if defined(IBMPC_SYSTEM)
  1076. extern int SLtt_Msdos_Cheap_Video;
  1077. #endif
  1078. typedef unsigned short SLsmg_Char_Type;
  1079. #define SLSMG_EXTRACT_CHAR(x) ((x) & 0xFF)
  1080. #define SLSMG_EXTRACT_COLOR(x) (((x)>>8)&0xFF)
  1081. #define SLSMG_BUILD_CHAR(ch,color) (((SLsmg_Char_Type)(unsigned char)(ch))|((color)<<8))
  1082. extern int SLtt_flush_output (void);
  1083. extern void SLtt_set_scroll_region(int, int);
  1084. extern void SLtt_reset_scroll_region(void);
  1085. extern void SLtt_reverse_video (int);
  1086. extern void SLtt_bold_video (void);
  1087. extern void SLtt_begin_insert(void);
  1088. extern void SLtt_end_insert(void);
  1089. extern void SLtt_del_eol(void);
  1090. extern void SLtt_goto_rc (int, int);
  1091. extern void SLtt_delete_nlines(int);
  1092. extern void SLtt_delete_char(void);
  1093. extern void SLtt_erase_line(void);
  1094. extern void SLtt_normal_video(void);
  1095. extern void SLtt_cls(void);
  1096. extern void SLtt_beep(void);
  1097. extern void SLtt_reverse_index(int);
  1098. extern void SLtt_smart_puts(SLsmg_Char_Type *, SLsmg_Char_Type *, int, int);
  1099. extern void SLtt_write_string (char *);
  1100. extern void SLtt_putchar(char);
  1101. extern int SLtt_init_video (void);
  1102. extern int SLtt_reset_video (void);
  1103. extern void SLtt_get_terminfo(void);
  1104. extern void SLtt_get_screen_size (void);
  1105. extern int SLtt_set_cursor_visibility (int);
  1106. extern int SLtt_set_mouse_mode (int, int);
  1107. #if defined(VMS) || defined(REAL_UNIX_SYSTEM)
  1108. extern int SLtt_initialize (char *);
  1109. extern void SLtt_enable_cursor_keys(void);
  1110. extern void SLtt_set_term_vtxxx(int *);
  1111. extern void SLtt_set_color_esc (int, char *);
  1112. extern void SLtt_wide_width(void);
  1113. extern void SLtt_narrow_width(void);
  1114. extern void SLtt_set_alt_char_set (int);
  1115. extern int SLtt_write_to_status_line (char *, int);
  1116. extern void SLtt_disable_status_line (void);
  1117. # ifdef REAL_UNIX_SYSTEM
  1118. /* These are termcap/terminfo routines that assume SLtt_initialize has
  1119. * been called.
  1120. */
  1121. extern char *SLtt_tgetstr (char *);
  1122. extern int SLtt_tgetnum (char *);
  1123. extern int SLtt_tgetflag (char *);
  1124. /* The following are terminfo-only routines -- these prototypes will change
  1125. * in V2.x.
  1126. */
  1127. extern char *SLtt_tigetent (char *);
  1128. extern char *SLtt_tigetstr (char *, char **);
  1129. extern int SLtt_tigetnum (char *, char **);
  1130. # endif
  1131. #endif
  1132. extern SLtt_Char_Type SLtt_get_color_object (int);
  1133. extern void SLtt_set_color_object (int, SLtt_Char_Type);
  1134. extern void SLtt_set_color (int, char *, char *, char *);
  1135. extern void SLtt_set_mono (int, char *, SLtt_Char_Type);
  1136. extern void SLtt_add_color_attribute (int, SLtt_Char_Type);
  1137. extern void SLtt_set_color_fgbg (int, SLtt_Char_Type, SLtt_Char_Type);
  1138. /*}}}*/
  1139. /*{{{ SLang Preprocessor Interface */
  1140. typedef struct
  1141. {
  1142. int this_level;
  1143. int exec_level;
  1144. int prev_exec_level;
  1145. char preprocess_char;
  1146. char comment_char;
  1147. unsigned char flags;
  1148. #define SLPREP_BLANK_LINES_OK 1
  1149. #define SLPREP_COMMENT_LINES_OK 2
  1150. #define SLPREP_STOP_READING 4
  1151. #define SLPREP_EMBEDDED_TEXT 8
  1152. }
  1153. SLPreprocess_Type;
  1154. extern int SLprep_open_prep (SLPreprocess_Type *);
  1155. extern void SLprep_close_prep (SLPreprocess_Type *);
  1156. extern int SLprep_line_ok (char *, SLPreprocess_Type *);
  1157. extern int SLdefine_for_ifdef (char *);
  1158. /* Adds a string to the SLang #ifdef preparsing defines. SLang already
  1159. defines MSDOS, UNIX, and VMS on the appropriate system. */
  1160. extern int (*SLprep_exists_hook) (char *, char);
  1161. /*}}}*/
  1162. /*{{{ SLsmg Screen Management Functions */
  1163. extern void SLsmg_fill_region (int, int, unsigned int, unsigned int, unsigned char);
  1164. extern void SLsmg_set_char_set (int);
  1165. #ifndef IBMPC_SYSTEM
  1166. extern int SLsmg_Scroll_Hash_Border;
  1167. #endif
  1168. extern int SLsmg_suspend_smg (void);
  1169. extern int SLsmg_resume_smg (void);
  1170. extern void SLsmg_erase_eol (void);
  1171. extern void SLsmg_gotorc (int, int);
  1172. extern void SLsmg_erase_eos (void);
  1173. extern void SLsmg_reverse_video (void);
  1174. extern void SLsmg_set_color (int);
  1175. extern void SLsmg_normal_video (void);
  1176. extern void SLsmg_printf (char *, ...) _SLATTRIBUTE_PRINTF(1,2);
  1177. /* extern void SLsmg_printf (char *, ...) _SLATTRIBUTE_PRINTF(1,2); */
  1178. extern void SLsmg_vprintf (char *, va_list);
  1179. extern void SLsmg_write_string (char *);
  1180. extern void SLsmg_write_nstring (char *, unsigned int);
  1181. extern void SLsmg_write_char (char);
  1182. extern void SLsmg_write_nchars (char *, unsigned int);
  1183. extern void SLsmg_write_wrapped_string (char *, int, int, unsigned int, unsigned int, int);
  1184. extern void SLsmg_cls (void);
  1185. extern void SLsmg_refresh (void);
  1186. extern void SLsmg_touch_lines (int, unsigned int);
  1187. extern void SLsmg_touch_screen (void);
  1188. extern int SLsmg_init_smg (void);
  1189. extern int SLsmg_reinit_smg (void);
  1190. extern void SLsmg_reset_smg (void);
  1191. extern SLsmg_Char_Type SLsmg_char_at(void);
  1192. extern void SLsmg_set_screen_start (int *, int *);
  1193. extern void SLsmg_draw_hline (unsigned int);
  1194. extern void SLsmg_draw_vline (int);
  1195. extern void SLsmg_draw_object (int, int, unsigned char);
  1196. extern void SLsmg_draw_box (int, int, unsigned int, unsigned int);
  1197. extern int SLsmg_get_column(void);
  1198. extern int SLsmg_get_row(void);
  1199. extern void SLsmg_forward (int);
  1200. extern void SLsmg_write_color_chars (SLsmg_Char_Type *, unsigned int);
  1201. extern unsigned int SLsmg_read_raw (SLsmg_Char_Type *, unsigned int);
  1202. extern unsigned int SLsmg_write_raw (SLsmg_Char_Type *, unsigned int);
  1203. extern void SLsmg_set_color_in_region (int, int, int, unsigned int, unsigned int);
  1204. extern int SLsmg_Display_Eight_Bit;
  1205. extern int SLsmg_Tab_Width;
  1206. #define SLSMG_NEWLINE_IGNORED 0 /* default */
  1207. #define SLSMG_NEWLINE_MOVES 1 /* moves to next line, column 0 */
  1208. #define SLSMG_NEWLINE_SCROLLS 2 /* moves but scrolls at bottom of screen */
  1209. #define SLSMG_NEWLINE_PRINTABLE 3 /* prints as ^J */
  1210. extern int SLsmg_Newline_Behavior;
  1211. extern int SLsmg_Backspace_Moves;
  1212. #ifdef IBMPC_SYSTEM
  1213. # define SLSMG_HLINE_CHAR 0xC4
  1214. # define SLSMG_VLINE_CHAR 0xB3
  1215. # define SLSMG_ULCORN_CHAR 0xDA
  1216. # define SLSMG_URCORN_CHAR 0xBF
  1217. # define SLSMG_LLCORN_CHAR 0xC0
  1218. # define SLSMG_LRCORN_CHAR 0xD9
  1219. # define SLSMG_RTEE_CHAR 0xB4
  1220. # define SLSMG_LTEE_CHAR 0xC3
  1221. # define SLSMG_UTEE_CHAR 0xC2
  1222. # define SLSMG_DTEE_CHAR 0xC1
  1223. # define SLSMG_PLUS_CHAR 0xC5
  1224. /* There are several to choose from: 0xB0, 0xB1, and 0xB2 */
  1225. # define SLSMG_CKBRD_CHAR 0xB0
  1226. # define SLSMG_DIAMOND_CHAR 0x04
  1227. # define SLSMG_DEGREE_CHAR 0xF8
  1228. # define SLSMG_PLMINUS_CHAR 0xF1
  1229. # define SLSMG_BULLET_CHAR 0xF9
  1230. # define SLSMG_LARROW_CHAR 0x1B
  1231. # define SLSMG_RARROW_CHAR 0x1A
  1232. # define SLSMG_DARROW_CHAR 0x19
  1233. # define SLSMG_UARROW_CHAR 0x18
  1234. # define SLSMG_BOARD_CHAR 0xB2
  1235. # define SLSMG_BLOCK_CHAR 0xDB
  1236. #else
  1237. # if defined(AMIGA)
  1238. # define SLSMG_HLINE_CHAR '-'
  1239. # define SLSMG_VLINE_CHAR '|'
  1240. # define SLSMG_ULCORN_CHAR '+'
  1241. # define SLSMG_URCORN_CHAR '+'
  1242. # define SLSMG_LLCORN_CHAR '+'
  1243. # define SLSMG_LRCORN_CHAR '+'
  1244. # define SLSMG_CKBRD_CHAR '#'
  1245. # define SLSMG_RTEE_CHAR '+'
  1246. # define SLSMG_LTEE_CHAR '+'
  1247. # define SLSMG_UTEE_CHAR '+'
  1248. # define SLSMG_DTEE_CHAR '+'
  1249. # define SLSMG_PLUS_CHAR '+'
  1250. # define SLSMG_DIAMOND_CHAR '+'
  1251. # define SLSMG_DEGREE_CHAR '\\'
  1252. # define SLSMG_PLMINUS_CHAR '#'
  1253. # define SLSMG_BULLET_CHAR 'o'
  1254. # define SLSMG_LARROW_CHAR '<'
  1255. # define SLSMG_RARROW_CHAR '>'
  1256. # define SLSMG_DARROW_CHAR 'v'
  1257. # define SLSMG_UARROW_CHAR '^'
  1258. # define SLSMG_BOARD_CHAR '#'
  1259. # define SLSMG_BLOCK_CHAR '#'
  1260. # else
  1261. # define SLSMG_HLINE_CHAR 'q'
  1262. # define SLSMG_VLINE_CHAR 'x'
  1263. # define SLSMG_ULCORN_CHAR 'l'
  1264. # define SLSMG_URCORN_CHAR 'k'
  1265. # define SLSMG_LLCORN_CHAR 'm'
  1266. # define SLSMG_LRCORN_CHAR 'j'
  1267. # define SLSMG_CKBRD_CHAR 'a'
  1268. # define SLSMG_RTEE_CHAR 'u'
  1269. # define SLSMG_LTEE_CHAR 't'
  1270. # define SLSMG_UTEE_CHAR 'w'
  1271. # define SLSMG_DTEE_CHAR 'v'
  1272. # define SLSMG_PLUS_CHAR 'n'
  1273. # define SLSMG_DIAMOND_CHAR '`'
  1274. # define SLSMG_DEGREE_CHAR 'f'
  1275. # define SLSMG_PLMINUS_CHAR 'g'
  1276. # define SLSMG_BULLET_CHAR '~'
  1277. # define SLSMG_LARROW_CHAR ','
  1278. # define SLSMG_RARROW_CHAR '+'
  1279. # define SLSMG_DARROW_CHAR '.'
  1280. # define SLSMG_UARROW_CHAR '-'
  1281. # define SLSMG_BOARD_CHAR 'h'
  1282. # define SLSMG_BLOCK_CHAR '0'
  1283. # endif /* AMIGA */
  1284. #endif /* IBMPC_SYSTEM */
  1285. #ifndef IBMPC_SYSTEM
  1286. # define SLSMG_COLOR_BLACK 0x000000
  1287. # define SLSMG_COLOR_RED 0x000001
  1288. # define SLSMG_COLOR_GREEN 0x000002
  1289. # define SLSMG_COLOR_BROWN 0x000003
  1290. # define SLSMG_COLOR_BLUE 0x000004
  1291. # define SLSMG_COLOR_MAGENTA 0x000005
  1292. # define SLSMG_COLOR_CYAN 0x000006
  1293. # define SLSMG_COLOR_LGRAY 0x000007
  1294. # define SLSMG_COLOR_GRAY 0x000008
  1295. # define SLSMG_COLOR_BRIGHT_RED 0x000009
  1296. # define SLSMG_COLOR_BRIGHT_GREEN 0x00000A
  1297. # define SLSMG_COLOR_BRIGHT_BROWN 0x00000B
  1298. # define SLSMG_COLOR_BRIGHT_BLUE 0x00000C
  1299. # define SLSMG_COLOR_BRIGHT_CYAN 0x00000D
  1300. # define SLSMG_COLOR_BRIGHT_MAGENTA 0x00000E
  1301. # define SLSMG_COLOR_BRIGHT_WHITE 0x00000F
  1302. #endif
  1303. typedef struct
  1304. {
  1305. void (*tt_normal_video)(void);
  1306. void (*tt_set_scroll_region)(int, int);
  1307. void (*tt_goto_rc)(int, int);
  1308. void (*tt_reverse_index)(int);
  1309. void (*tt_reset_scroll_region)(void);
  1310. void (*tt_delete_nlines)(int);
  1311. void (*tt_cls) (void);
  1312. void (*tt_del_eol) (void);
  1313. void (*tt_smart_puts) (SLsmg_Char_Type *, SLsmg_Char_Type *, int, int);
  1314. int (*tt_flush_output) (void);
  1315. int (*tt_reset_video) (void);
  1316. int (*tt_init_video) (void);
  1317. int *tt_screen_rows;
  1318. int *tt_screen_cols;
  1319. int *tt_term_cannot_scroll;
  1320. int *tt_has_alt_charset;
  1321. int *tt_use_blink_for_acs;
  1322. char **tt_graphic_char_pairs;
  1323. long reserved[4];
  1324. }
  1325. SLsmg_Term_Type;
  1326. extern void SLsmg_set_terminal_info (SLsmg_Term_Type *);
  1327. /*}}}*/
  1328. /*{{{ SLang Keypad Interface */
  1329. #define SL_KEY_ERR 0xFFFF
  1330. #define SL_KEY_UP 0x101
  1331. #define SL_KEY_DOWN 0x102
  1332. #define SL_KEY_LEFT 0x103
  1333. #define SL_KEY_RIGHT 0x104
  1334. #define SL_KEY_PPAGE 0x105
  1335. #define SL_KEY_NPAGE 0x106
  1336. #define SL_KEY_HOME 0x107
  1337. #define SL_KEY_END 0x108
  1338. #define SL_KEY_A1 0x109
  1339. #define SL_KEY_A3 0x10A
  1340. #define SL_KEY_B2 0x10B
  1341. #define SL_KEY_C1 0x10C
  1342. #define SL_KEY_C3 0x10D
  1343. #define SL_KEY_REDO 0x10E
  1344. #define SL_KEY_UNDO 0x10F
  1345. #define SL_KEY_BACKSPACE 0x110
  1346. #define SL_KEY_ENTER 0x111
  1347. #define SL_KEY_IC 0x112
  1348. #define SL_KEY_DELETE 0x113
  1349. #define SL_KEY_F0 0x200
  1350. #define SL_KEY_F(X) (SL_KEY_F0 + X)
  1351. /* I do not intend to use keysymps > 0x1000. Applications can use those. */
  1352. /* Returns 0 upon success or -1 upon error. */
  1353. extern int SLkp_define_keysym (char *, unsigned int);
  1354. /* This function must be called AFTER SLtt_get_terminfo and not before. */
  1355. extern int SLkp_init (void);
  1356. /* By default, SLang_getkey is used as the low-level function. This hook
  1357. * allows you to specify something else.
  1358. */
  1359. extern void SLkp_set_getkey_function (int (*)(void));
  1360. /* This function uses SLang_getkey and assumes that what ever initialization
  1361. * is required for SLang_getkey has been performed. If you do not want
  1362. * SLang_getkey to be used, then specify another function via
  1363. * SLkp_set_getkey_function.
  1364. */
  1365. extern int SLkp_getkey (void);
  1366. /*}}}*/
  1367. /*{{{ SLang Scroll Interface */
  1368. typedef struct _SLscroll_Type
  1369. {
  1370. struct _SLscroll_Type *next;
  1371. struct _SLscroll_Type *prev;
  1372. unsigned int flags;
  1373. }
  1374. SLscroll_Type;
  1375. typedef struct
  1376. {
  1377. unsigned int flags;
  1378. SLscroll_Type *top_window_line; /* list element at top of window */
  1379. SLscroll_Type *bot_window_line; /* list element at bottom of window */
  1380. SLscroll_Type *current_line; /* current list element */
  1381. SLscroll_Type *lines; /* first list element */
  1382. unsigned int nrows; /* number of rows in window */
  1383. unsigned int hidden_mask; /* applied to flags in SLscroll_Type */
  1384. unsigned int line_num; /* current line number (visible) */
  1385. unsigned int num_lines; /* total number of lines (visible) */
  1386. unsigned int window_row; /* row of current_line in window */
  1387. unsigned int border; /* number of rows that form scroll border */
  1388. int cannot_scroll; /* should window scroll or recenter */
  1389. }
  1390. SLscroll_Window_Type;
  1391. extern int SLscroll_find_top (SLscroll_Window_Type *);
  1392. extern int SLscroll_find_line_num (SLscroll_Window_Type *);
  1393. extern unsigned int SLscroll_next_n (SLscroll_Window_Type *, unsigned int);
  1394. extern unsigned int SLscroll_prev_n (SLscroll_Window_Type *, unsigned int);
  1395. extern int SLscroll_pageup (SLscroll_Window_Type *);
  1396. extern int SLscroll_pagedown (SLscroll_Window_Type *);
  1397. /*}}}*/
  1398. /*{{{ Signal Routines */
  1399. typedef void SLSig_Fun_Type (int);
  1400. extern SLSig_Fun_Type *SLsignal (int, SLSig_Fun_Type *);
  1401. extern SLSig_Fun_Type *SLsignal_intr (int, SLSig_Fun_Type *);
  1402. extern int SLsig_block_signals (void);
  1403. extern int SLsig_unblock_signals (void);
  1404. extern int SLsystem (char *);
  1405. extern char *SLerrno_strerror (int);
  1406. extern int SLerrno_set_errno (int);
  1407. /*}}}*/
  1408. /*{{{ Interpreter Macro Definitions */
  1409. /* The definitions here are for objects that may be on the run-time stack.
  1410. * They are actually sub_types of literal and data main_types. The actual
  1411. * numbers are historical.
  1412. */
  1413. #define SLANG_UNDEFINED_TYPE 0x00 /* MUST be 0 */
  1414. #define SLANG_VOID_TYPE 0x01 /* also matches ANY type */
  1415. #define SLANG_INT_TYPE 0x02
  1416. #define SLANG_DOUBLE_TYPE 0x03
  1417. #define SLANG_CHAR_TYPE 0x04
  1418. #define SLANG_INTP_TYPE 0x05
  1419. /* An object of SLANG_INTP_TYPE should never really occur on the stack. Rather,
  1420. * the integer to which it refers will be there instead. It is defined here
  1421. * because it is a valid type for MAKE_VARIABLE.
  1422. */
  1423. #define SLANG_REF_TYPE 0x06
  1424. /* SLANG_REF_TYPE refers to an object on the stack that is a pointer (reference)
  1425. * to some other object.
  1426. */
  1427. #define SLANG_COMPLEX_TYPE 0x07
  1428. #define SLANG_NULL_TYPE 0x08
  1429. #define SLANG_UCHAR_TYPE 0x09
  1430. #define SLANG_SHORT_TYPE 0x0A
  1431. #define SLANG_USHORT_TYPE 0x0B
  1432. #define SLANG_UINT_TYPE 0x0C
  1433. #define SLANG_LONG_TYPE 0x0D
  1434. #define SLANG_ULONG_TYPE 0x0E
  1435. #define SLANG_STRING_TYPE 0x0F
  1436. #define SLANG_FLOAT_TYPE 0x10
  1437. #define SLANG_STRUCT_TYPE 0x11
  1438. #define SLANG_ISTRUCT_TYPE 0x12
  1439. #define SLANG_ARRAY_TYPE 0x20
  1440. #define SLANG_DATATYPE_TYPE 0x21
  1441. #define SLANG_FILE_PTR_TYPE 0x22
  1442. #define SLANG_ASSOC_TYPE 0x23
  1443. #define SLANG_ANY_TYPE 0x24
  1444. #define SLANG_BSTRING_TYPE 0x25
  1445. #define SLANG_FILE_FD_TYPE 0x26
  1446. #define _SLANG_MIN_UNUSED_TYPE 0x27
  1447. /* Compatibility */
  1448. #ifdef FLOAT_TYPE
  1449. # undef FLOAT_TYPE
  1450. #endif
  1451. #define VOID_TYPE SLANG_VOID_TYPE
  1452. #define INT_TYPE SLANG_INT_TYPE
  1453. #define INTP_TYPE SLANG_INTP_TYPE
  1454. #define FLOAT_TYPE SLANG_DOUBLE_TYPE
  1455. #define ARRAY_TYPE SLANG_ARRAY_TYPE
  1456. #define CHAR_TYPE SLANG_CHAR_TYPE
  1457. #define STRING_TYPE SLANG_STRING_TYPE
  1458. /* I am reserving values greater than or equal to 128 for user applications.
  1459. * The first 127 are reserved for S-Lang.
  1460. */
  1461. /* Binary and Unary Subtypes */
  1462. /* Since the application can define new types and can overload the binary
  1463. * and unary operators, these definitions must be present in this file.
  1464. * The current implementation assumes both unary and binary are distinct.
  1465. */
  1466. #define SLANG_PLUS 0x01
  1467. #define SLANG_MINUS 0x02
  1468. #define SLANG_TIMES 0x03
  1469. #define SLANG_DIVIDE 0x04
  1470. #define SLANG_EQ 0x05
  1471. #define SLANG_NE 0x06
  1472. #define SLANG_GT 0x07
  1473. #define SLANG_GE 0x08
  1474. #define SLANG_LT 0x09
  1475. #define SLANG_LE 0x0A
  1476. #define SLANG_POW 0x0B
  1477. #define SLANG_OR 0x0C
  1478. #define SLANG_AND 0x0D
  1479. #define SLANG_BAND 0x0E
  1480. #define SLANG_BOR 0x0F
  1481. #define SLANG_BXOR 0x10
  1482. #define SLANG_SHL 0x11
  1483. #define SLANG_SHR 0x12
  1484. #define SLANG_MOD 0x13
  1485. /* UNARY subtypes (may be overloaded) */
  1486. #define SLANG_PLUSPLUS 0x20
  1487. #define SLANG_MINUSMINUS 0x21
  1488. #define SLANG_ABS 0x22
  1489. #define SLANG_SIGN 0x23
  1490. #define SLANG_SQR 0x24
  1491. #define SLANG_MUL2 0x25
  1492. #define SLANG_CHS 0x26
  1493. #define SLANG_NOT 0x27
  1494. #define SLANG_BNOT 0x28
  1495. extern char *SLang_Error_Message;
  1496. int SLadd_intrinsic_variable (char *, VOID_STAR, unsigned char, int);
  1497. int SLadd_intrinsic_function (char *, FVOID_STAR, unsigned char, unsigned int,...);
  1498. int SLns_add_intrinsic_variable (SLang_NameSpace_Type *, char *, VOID_STAR, unsigned char, int);
  1499. int SLns_add_intrinsic_function (SLang_NameSpace_Type *, char *, FVOID_STAR, unsigned char, unsigned int,...);
  1500. #define MAKE_INTRINSIC_N(n,f,out,in,a1,a2,a3,a4,a5,a6,a7) \
  1501. {(n), NULL, SLANG_INTRINSIC, (FVOID_STAR) (f), \
  1502. {a1,a2,a3,a4,a5,a6,a7}, (in), (out)}
  1503. #define MAKE_INTRINSIC_7(n,f,out,a1,a2,a3,a4,a5,a6,a7) \
  1504. MAKE_INTRINSIC_N(n,f,out,7,a1,a2,a3,a4,a5,a6,a7)
  1505. #define MAKE_INTRINSIC_6(n,f,out,a1,a2,a3,a4,a5,a6) \
  1506. MAKE_INTRINSIC_N(n,f,out,6,a1,a2,a3,a4,a5,a6,0)
  1507. #define MAKE_INTRINSIC_5(n,f,out,a1,a2,a3,a4,a5) \
  1508. MAKE_INTRINSIC_N(n,f,out,5,a1,a2,a3,a4,a5,0,0)
  1509. #define MAKE_INTRINSIC_4(n,f,out,a1,a2,a3,a4) \
  1510. MAKE_INTRINSIC_N(n,f,out,4,a1,a2,a3,a4,0,0,0)
  1511. #define MAKE_INTRINSIC_3(n,f,out,a1,a2,a3) \
  1512. MAKE_INTRINSIC_N(n,f,out,3,a1,a2,a3,0,0,0,0)
  1513. #define MAKE_INTRINSIC_2(n,f,out,a1,a2) \
  1514. MAKE_INTRINSIC_N(n,f,out,2,a1,a2,0,0,0,0,0)
  1515. #define MAKE_INTRINSIC_1(n,f,out,a1) \
  1516. MAKE_INTRINSIC_N(n,f,out,1,a1,0,0,0,0,0,0)
  1517. #define MAKE_INTRINSIC_0(n,f,out) \
  1518. MAKE_INTRINSIC_N(n,f,out,0,0,0,0,0,0,0,0)
  1519. #define MAKE_INTRINSIC_S(n,f,r) \
  1520. MAKE_INTRINSIC_1(n,f,r,SLANG_STRING_TYPE)
  1521. #define MAKE_INTRINSIC_I(n,f,r) \
  1522. MAKE_INTRINSIC_1(n,f,r,SLANG_INT_TYPE)
  1523. #define MAKE_INTRINSIC_SS(n,f,r) \
  1524. MAKE_INTRINSIC_2(n,f,r,SLANG_STRING_TYPE,SLANG_STRING_TYPE)
  1525. #define MAKE_INTRINSIC_SI(n,f,r) \
  1526. MAKE_INTRINSIC_2(n,f,r,SLANG_STRING_TYPE,SLANG_INT_TYPE)
  1527. #define MAKE_INTRINSIC_IS(n,f,r) \
  1528. MAKE_INTRINSIC_2(n,f,r,SLANG_INT_TYPE,SLANG_STRING_TYPE)
  1529. #define MAKE_INTRINSIC_II(n,f,r) \
  1530. MAKE_INTRINSIC_2(n,f,r,SLANG_INT_TYPE,SLANG_INT_TYPE)
  1531. #define MAKE_INTRINSIC_SSS(n,f,r) \
  1532. MAKE_INTRINSIC_3(n,f,r,SLANG_STRING_TYPE,SLANG_STRING_TYPE,SLANG_STRING_TYPE)
  1533. #define MAKE_INTRINSIC_SSI(n,f,r) \
  1534. MAKE_INTRINSIC_3(n,f,r,SLANG_STRING_TYPE,SLANG_STRING_TYPE,SLANG_INT_TYPE)
  1535. #define MAKE_INTRINSIC_SIS(n,f,r) \
  1536. MAKE_INTRINSIC_3(n,f,r,SLANG_STRING_TYPE,SLANG_INT_TYPE,SLANG_STRING_TYPE)
  1537. #define MAKE_INTRINSIC_SII(n,f,r) \
  1538. MAKE_INTRINSIC_3(n,f,r,SLANG_STRING_TYPE,SLANG_INT_TYPE,SLANG_INT_TYPE)
  1539. #define MAKE_INTRINSIC_ISS(n,f,r) \
  1540. MAKE_INTRINSIC_3(n,f,r,SLANG_INT_TYPE,SLANG_STRING_TYPE,SLANG_STRING_TYPE)
  1541. #define MAKE_INTRINSIC_ISI(n,f,r) \
  1542. MAKE_INTRINSIC_3(n,f,r,SLANG_INT_TYPE,SLANG_STRING_TYPE,SLANG_INT_TYPE)
  1543. #define MAKE_INTRINSIC_IIS(n,f,r) \
  1544. MAKE_INTRINSIC_3(n,f,r,SLANG_INT_TYPE,SLANG_INT_TYPE,SLANG_STRING_TYPE)
  1545. #define MAKE_INTRINSIC_III(n,f,r) \
  1546. MAKE_INTRINSIC_3(n,f,r,SLANG_INT_TYPE,SLANG_INT_TYPE,SLANG_INT_TYPE)
  1547. #define MAKE_INTRINSIC(n, f, out, in) \
  1548. MAKE_INTRINSIC_N(n,f,out,in,0,0,0,0,0,0,0)
  1549. #define MAKE_VARIABLE(n, v, t, r) \
  1550. {n, NULL, SLANG_IVARIABLE + (r), (VOID_STAR)(v), (t)}
  1551. #define MAKE_APP_UNARY(n,op) \
  1552. {(n), NULL, SLANG_APP_UNARY, (op)}
  1553. #define MAKE_MATH_UNARY(n,op) \
  1554. {(n), NULL, SLANG_MATH_UNARY, (op)}
  1555. #define MAKE_ICONSTANT(n,val) \
  1556. {(n),NULL, SLANG_ICONSTANT, (val)}
  1557. #define MAKE_DCONSTANT(n,val) \
  1558. {(n),NULL, SLANG_DCONSTANT, (val)}
  1559. #ifndef offsetof
  1560. # define offsetof(T,F) ((unsigned int)((char *)&((T *)0L)->F - (char *)0L))
  1561. #endif
  1562. #define MAKE_ISTRUCT_FIELD(s,f,n,t,r) {(n), offsetof(s,f), (t), (r)}
  1563. #define MAKE_CSTRUCT_FIELD(s,f,n,t,r) {(n), offsetof(s,f), (t), (r)}
  1564. #define MAKE_CSTRUCT_INT_FIELD(s,f,n,r) {(n), offsetof(s,f),\
  1565. (sizeof(((s*)0L)->f)==sizeof(int))?(SLANG_INT_TYPE): \
  1566. (sizeof(((s*)0L)->f)==sizeof(short))?(SLANG_SHORT_TYPE): \
  1567. (sizeof(((s*)0L)->f)==sizeof(char))?(SLANG_CHAR_TYPE): \
  1568. SLANG_LONG_TYPE, (r)\
  1569. }
  1570. #define SLANG_END_TABLE {NULL}
  1571. #define SLANG_END_INTRIN_FUN_TABLE MAKE_INTRINSIC_0(NULL,NULL,0)
  1572. #define SLANG_END_DCONST_TABLE MAKE_DCONSTANT(NULL,0)
  1573. #define SLANG_END_MATH_UNARY_TABLE MAKE_MATH_UNARY(NULL,0)
  1574. #define SLANG_END_INTRIN_VAR_TABLE MAKE_VARIABLE(NULL,NULL,0,0)
  1575. #define SLANG_END_ICONST_TABLE MAKE_ICONSTANT(NULL,0)
  1576. #define SLANG_END_ISTRUCT_TABLE {NULL, 0, 0, 0}
  1577. #define SLANG_END_CSTRUCT_TABLE {NULL, 0, 0, 0}
  1578. /*}}}*/
  1579. /*{{{ Upper/Lowercase Functions */
  1580. extern void SLang_define_case(int *, int *);
  1581. extern void SLang_init_case_tables (void);
  1582. extern unsigned char _SLChg_UCase_Lut[256];
  1583. extern unsigned char _SLChg_LCase_Lut[256];
  1584. #define UPPER_CASE(x) (_SLChg_UCase_Lut[(unsigned char) (x)])
  1585. #define LOWER_CASE(x) (_SLChg_LCase_Lut[(unsigned char) (x)])
  1586. #define CHANGE_CASE(x) (((x) == _SLChg_LCase_Lut[(unsigned char) (x)]) ?\
  1587. _SLChg_UCase_Lut[(unsigned char) (x)] : _SLChg_LCase_Lut[(unsigned char) (x)])
  1588. /*}}}*/
  1589. /*{{{ Regular Expression Interface */
  1590. typedef struct
  1591. {
  1592. /* These must be set by calling routine. */
  1593. unsigned char *pat; /* regular expression pattern */
  1594. unsigned char *buf; /* buffer for compiled regexp */
  1595. unsigned int buf_len; /* length of buffer */
  1596. int case_sensitive; /* 1 if match is case sensitive */
  1597. /* The rest are set by SLang_regexp_compile */
  1598. int must_match; /* 1 if line must contain substring */
  1599. int must_match_bol; /* true if it must match beginning of line */
  1600. unsigned char must_match_str[16]; /* 15 char null term substring */
  1601. int osearch; /* 1 if ordinary search suffices */
  1602. unsigned int min_length; /* minimum length the match must be */
  1603. int beg_matches[10]; /* offset of start of \( */
  1604. unsigned int end_matches[10]; /* length of nth submatch
  1605. * Note that the entire match corresponds
  1606. * to \0
  1607. */
  1608. int offset; /* offset to be added to beg_matches */
  1609. int reserved[10];
  1610. } SLRegexp_Type;
  1611. extern unsigned char *SLang_regexp_match(unsigned char *,
  1612. unsigned int,
  1613. SLRegexp_Type *);
  1614. /* Returns 0 upon success. If failure, the offset into the
  1615. * pattern is returned (start = 1).
  1616. */
  1617. extern int SLang_regexp_compile (SLRegexp_Type *);
  1618. extern char *SLregexp_quote_string (char *, char *, unsigned int);
  1619. /*}}}*/
  1620. /*{{{ SLang Command Interface */
  1621. struct _SLcmd_Cmd_Type; /* Pre-declaration is needed below */
  1622. typedef struct
  1623. {
  1624. struct _SLcmd_Cmd_Type *table;
  1625. int argc;
  1626. /* Version 2.0 needs to use a union!! */
  1627. char **string_args;
  1628. int *int_args;
  1629. double *double_args;
  1630. unsigned char *arg_type;
  1631. unsigned long reserved[4];
  1632. } SLcmd_Cmd_Table_Type;
  1633. typedef struct _SLcmd_Cmd_Type
  1634. {
  1635. int (*cmdfun)(int, SLcmd_Cmd_Table_Type *);
  1636. char *cmd;
  1637. char *arg_type;
  1638. } SLcmd_Cmd_Type;
  1639. extern int SLcmd_execute_string (char *, SLcmd_Cmd_Table_Type *);
  1640. /*}}}*/
  1641. /*{{{ SLang Search Interface */
  1642. typedef struct
  1643. {
  1644. int cs; /* case sensitive */
  1645. unsigned char key[256];
  1646. int ind[256];
  1647. int key_len;
  1648. int dir;
  1649. } SLsearch_Type;
  1650. extern int SLsearch_init (char *, int, int, SLsearch_Type *);
  1651. /* This routine must first be called before any search can take place.
  1652. * The second parameter specifies the direction of the search: greater than
  1653. * zero for a forwrd search and less than zero for a backward search. The
  1654. * third parameter specifies whether the search is case sensitive or not.
  1655. * The last parameter is a pointer to a structure that is filled by this
  1656. * function and it is this structure that must be passed to SLsearch.
  1657. */
  1658. extern unsigned char *SLsearch (unsigned char *, unsigned char *, SLsearch_Type *);
  1659. /* To use this routine, you must first call 'SLsearch_init'. Then the first
  1660. * two parameters p1 and p2 serve to define the region over which the search
  1661. * is to take place. The third parameter is the structure that was previously
  1662. * initialized by SLsearch_init.
  1663. *
  1664. * The routine returns a pointer to the match if found otherwise it returns
  1665. * NULL.
  1666. */
  1667. /*}}}*/
  1668. /*{{{ SLang Pathname Interface */
  1669. /* These function return pointers to the original space */
  1670. extern char *SLpath_basename (char *);
  1671. extern char *SLpath_extname (char *);
  1672. extern int SLpath_is_absolute_path (char *);
  1673. /* Get and set the character delimiter for search paths */
  1674. extern int SLpath_get_delimiter (void);
  1675. extern int SLpath_set_delimiter (int);
  1676. /* search path for loading .sl files */
  1677. extern int SLpath_set_load_path (char *);
  1678. /* search path for loading .sl files --- returns slstring */
  1679. extern char *SLpath_get_load_path (void);
  1680. /* These return malloced strings--- NOT slstrings */
  1681. extern char *SLpath_dircat (char *, char *);
  1682. extern char *SLpath_find_file_in_path (char *, char *);
  1683. extern char *SLpath_dirname (char *);
  1684. extern int SLpath_file_exists (char *);
  1685. extern char *SLpath_pathname_sans_extname (char *);
  1686. /*}}}*/
  1687. extern int SLang_set_module_load_path (char *);
  1688. #define SLANG_MODULE(name) \
  1689. extern int init_##name##_module_ns (char *); \
  1690. extern void deinit_##name##_module (void)
  1691. #if 0
  1692. {
  1693. #endif
  1694. #ifdef __cplusplus
  1695. }
  1696. #endif
  1697. #endif /* _DAVIS_SLANG_H_ */