remove trailing whitespace at end of lines
[reactos.git] / rosapps / mc / slang / slang.h
1 #ifndef DAVIS_SLANG_H_
2 #define DAVIS_SLANG_H_
3 /* -*- mode: C; mode: fold; -*- */
4 /* Copyright (c) 1992, 1995 John E. Davis
5 * All rights reserved.
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 9938
11 /*{{{ System Dependent Macros and Typedefs */
12
13 #if defined(__WATCOMC__) && !defined(__QNX__)
14 # ifndef msdos
15 # define msdos
16 # endif
17 # ifndef DOS386
18 # define DOS386
19 # endif
20 # ifndef FLOAT_TYPE
21 # define FLOAT_TYPE
22 # endif
23 # ifndef pc_system
24 # define pc_system
25 # endif
26 #endif /* __watcomc__ */
27
28 #ifdef unix
29 # ifndef __unix__
30 # define __unix__ 1
31 # endif
32 #endif
33
34 #ifndef __GO32__
35 # ifdef __unix__
36 # define REAL_UNIX_SYSTEM
37 # endif
38 #endif
39
40 /* Set of the various defines for pc systems. This includes OS/2 */
41 #ifdef __MSDOS__
42 # ifndef msdos
43 # define msdos
44 # endif
45 # ifndef pc_system
46 # define pc_system
47 # endif
48 #endif
49
50 #ifdef __GO32__
51 # ifndef pc_system
52 # define pc_system
53 # endif
54 # ifdef REAL_UNIX_SYSTEM
55 # undef REAL_UNIX_SYSTEM
56 # endif
57 #endif
58
59 #if defined(__EMX__) && defined(OS2)
60 # ifndef pc_system
61 # define pc_system
62 # endif
63 # ifndef __os2__
64 # define __os2__
65 # endif
66 #endif
67
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 #if 0
72 }
73 #endif
74 /* ---------------------------- Generic Macros ----------------------------- */
75
76 /* __SC__ is defined for Symantec C++
77 DOS386 is defined for -mx memory model, 32 bit DOS extender. */
78
79 #ifdef VOID
80 # undef VOID
81 #endif
82
83 #if defined(msdos) && !defined(DOS386) & !defined(__WIN32__) && !defined(__GO32__)
84 # ifdef __SC__
85 # include <dos.h>
86 # endif
87 typedef void *VOID_STAR;
88 # define VOID void
89 # include <alloc.h>
90 #else
91 # if defined (__cplusplus) || defined(__STDC__)
92 typedef void *VOID_STAR;
93 # define VOID void
94 # else
95 typedef unsigned char *VOID_STAR;
96 # define VOID unsigned char
97 # endif
98 #endif
99
100 #if 1
101 typedef int (*FVOID_STAR)(void);
102 #else
103 # define FVOID_STAR VOID_STAR
104 #endif
105
106 #if defined(msdos) && !defined(DOS386) && !defined(__GO32__) && !defined(__WIN32__)
107 # define SLFREE(buf) farfree((void far *)(buf))
108 # define SLMALLOC(x) farmalloc((unsigned long) (x))
109 # define SLREALLOC(buf, n) farrealloc((void far *) (buf), (unsigned long) (n))
110 # define SLCALLOC(n, m) farcalloc((unsigned long) (n), (unsigned long) (m))
111 #else
112 # if defined(VMS) && !defined(__DECC)
113 # define SLFREE VAXC$FREE_OPT
114 # define SLMALLOC VAXC$MALLOC_OPT
115 # define SLREALLOC VAXC$REALLOC_OPT
116 # define SLCALLOC VAXC$CALLOC_OPT
117 # else
118 # define SLFREE(x) free((char *)(x))
119 # define SLMALLOC malloc
120 # if defined(__cplusplus) && !defined(__BEOS__)
121 # define SLREALLOC(p,n) realloc((malloc_t) (p), (n))
122 # else
123 # define SLREALLOC realloc
124 # endif
125 # define SLCALLOC calloc
126 # endif
127 #endif
128
129 #ifdef SL_MALLOC_DEBUG
130 # undef SLMALLOC
131 # undef SLCALLOC
132 # undef SLREALLOC
133 # undef SLFREE
134 # define SLMALLOC(x) SLdebug_malloc((unsigned long) (x))
135 # define SLFREE(x) SLdebug_free((unsigned char *)(x))
136 # define SLCALLOC(n, m) SLdebug_calloc((unsigned long) (n), (unsigned long)(m))
137 # define SLREALLOC(p, x) SLdebug_realloc((unsigned char *)(p), (unsigned long)(x))
138 #endif /* SL_MALLOC_DEBUG */
139
140 extern unsigned char *SLdebug_malloc (unsigned long);
141 extern unsigned char *SLdebug_calloc (unsigned long, unsigned long);
142 extern unsigned char *SLdebug_realloc (unsigned char *, unsigned long);
143 extern void SLdebug_free (unsigned char *);
144 extern void SLmalloc_dump_statistics (void);
145 extern char *SLstrcpy(register char *, register char *);
146 extern int SLstrcmp(register char *, register char *);
147 extern char *SLstrncpy(char *, register char *, register int);
148
149 extern void SLmemset (char *, char, int);
150 extern char *SLmemchr (register char *, register char, register int);
151 extern char *SLmemcpy (char *, char *, int);
152 extern int SLmemcmp (char *, char *, int);
153
154 #ifdef float64
155 # undef float64
156 #endif
157
158 #ifndef FLOAT64_TYPEDEFED
159 # define FLOAT64_TYPEDEFED
160 typedef double float64;
161 #endif
162
163
164 /*}}}*/
165
166 /*{{{ Interpreter Typedefs */
167
168 #define SLANG_MAX_NAME_LEN 30
169 /* maximum length of an identifier */
170 /* first char in identifiers is the hash */
171
172 /* Note that long is used for addresses instead of void *. The reason for
173 * this is that I have a gut feeling that sizeof (long) > sizeof(void *)
174 * on some machines. This is certainly the case for MSDOS where addresses
175 * can be 16 bit.
176 */
177 typedef struct SLang_Name_Type
178 {
179 #ifdef SLANG_STATS
180 int n; /* number of times referenced */
181 #endif
182 char name[SLANG_MAX_NAME_LEN + 2]; /* [0] is hash */
183
184 unsigned char sub_type;
185
186 /* Values for main_type may be as follows. The particlular values are
187 * for compatability.
188 */
189 #define SLANG_LVARIABLE 0x01
190 #define SLANG_INTRINSIC 0x06
191 #define SLANG_FUNCTION 0x07
192 #define SLANG_GVARIABLE 0x0D
193 #define SLANG_IVARIABLE 0x0E /* intrinsic variables */
194 /* Note!!! For Macro MAKE_VARIABLE below to work, SLANG_IVARIABLE Must
195 be 1 less than SLANG_RVARIABLE!!! */
196 #define SLANG_RVARIABLE 0x0F /* read only variable */
197 unsigned char main_type;
198 long addr;
199 }
200 SLang_Name_Type;
201
202
203 typedef struct SLang_Load_Type
204 {
205 long name; /* file name, string address, ... */
206 long handle; /* FILE *, string address, etc... */
207
208 char *ptr; /* input pointer to next line in object
209 * to be read.
210 */
211 /* Things below here are used by S-Lang. */
212 int type; /* 'F' = file, 'S' = String, etc.. */
213 char *buf; /* buffer for file, etc... */
214 char *(*read)(struct SLang_Load_Type *); /* function to call to read obj */
215 int n; /* line number, etc... */
216 char token[256]; /* token to be parsed */
217 int ofs; /* offset from buf where last read
218 * took place
219 */
220 int top_level; /* 1 if at top level of parsing */
221 } SLang_Load_Type;
222
223 #if defined(ultrix) && !defined(__GNUC__)
224 # ifndef NO_PROTOTYPES
225 # define NO_PROTOTYPES
226 # endif
227 #endif
228
229 #ifndef NO_PROTOTYPES
230 # define _PROTO(x) x
231 #else
232 # define _PROTO(x) ()
233 #endif
234
235 typedef struct SL_OOBinary_Type
236 {
237 unsigned char sub_type; /* partner type for binary op */
238
239 /* The function take the binary op as first argument, the operand types
240 * form the second and third parameters and the last two parameters are
241 * pointers to the objects themselves. It is up to the function to push
242 * the result on the stack. It must return 1 if it handled the operation
243 * return zero if the operation is not defined.
244 */
245 int (*binary_function)_PROTO((int, unsigned char, unsigned char,
246 VOID_STAR, VOID_STAR));
247
248 struct SL_OOBinary_Type *next;
249 }
250 SL_OOBinary_Type;
251
252 typedef struct
253 {
254 /* Methods */
255 void (*destroy)_PROTO((VOID_STAR));
256 /* called to delete/free the object */
257 char *(*string)_PROTO((VOID_STAR));
258 /* returns a string representation of the object */
259 int (*unary_function)_PROTO((int, unsigned char, VOID_STAR));
260 /* unary operation function */
261 SL_OOBinary_Type *binary_ops;
262
263 int (*copy_function)_PROTO((unsigned char, VOID_STAR));
264 /* This function is called do make a copy of the object */
265 } SLang_Class_Type;
266
267 extern SLang_Class_Type *SLang_Registered_Types[256];
268
269 typedef struct
270 {
271 unsigned char main_type; /* SLANG_RVARIABLE, etc.. */
272 unsigned char sub_type; /* int, string, etc... */
273 long *obj; /* address of user structure */
274
275 /* Everything below is considered private */
276 unsigned int count; /* number of references */
277 }
278 SLuser_Object_Type;
279
280
281 /*}}}*/
282 /*{{{ Interpreter Function Prototypes */
283
284 extern volatile int SLang_Error;
285 /* Non zero if error occurs. Must be reset to zero to continue. */
286
287 extern int SLang_Traceback;
288 /* If non-zero, dump an S-Lang traceback upon error. Available as
289 _traceback in S-Lang. */
290
291 extern char *SLang_User_Prompt;
292 /* Prompt to use when reading from stdin */
293 extern int SLang_Version;
294
295 extern void (*SLang_Error_Routine)(char *);
296 /* Pointer to application dependent error messaging routine. By default,
297 messages are displayed on stderr. */
298
299 extern void (*SLang_Exit_Error_Hook)(char *);
300 extern void SLang_exit_error (char *);
301 extern void (*SLang_Dump_Routine)(char *);
302 /* Called if S-Lang traceback is enabled as well as other debugging
303 routines (e.g., trace). By default, these messages go to stderr. */
304
305 extern void (*SLang_Interrupt)(void);
306 /* function to call whenever inner interpreter is entered. This is
307 a good place to set SLang_Error to USER_BREAK. */
308
309 extern void (*SLang_User_Clear_Error)(void);
310 /* function that gets called when '_clear_error' is called. */
311 extern int (*SLang_User_Open_Slang_Object)(SLang_Load_Type *);
312 extern int (*SLang_User_Close_Slang_Object)(SLang_Load_Type *);
313 /* user defined loading routines. */
314
315
316 /* If non null, these call C functions before and after a slang function. */
317 extern void (*SLang_Enter_Function)(char *);
318 extern void (*SLang_Exit_Function)(char *);
319
320
321 /* Functions: */
322
323 extern int init_SLang(void);
324 /* This function is mandatory and must be called by all applications */
325 extern int init_SLfiles(void);
326 /* called if fputs, fgets, etc are need in S-Lang */
327 extern int init_SLmath(void);
328 /* called if math functions sin, cos, etc... are needed. */
329
330 extern int init_SLunix(void);
331 /* unix system functions chmod, stat, etc... */
332
333 extern int init_SLmatrix(void);
334
335 extern int SLang_add_table(SLang_Name_Type *, char *);
336 /* add application dependent function table p1 to S-Lang. A name p2 less
337 * than 32 characters must also be supplied.
338 * Returns 0 upon failure or 1 upon success. */
339
340 extern int SLang_add_global_variable (char *);
341 extern int SLang_load_object(SLang_Load_Type *);
342 extern int SLang_load_file(char *);
343 /* Load a file of S-Lang code for interpreting. If the parameter is
344 NULL, input comes from stdin. */
345
346 extern void SLang_restart(int);
347 /* should be called if an error occurs. If the passed integer is
348 * non-zero, items are popped off the stack; otherwise, the stack is
349 * left intact. Any time the stack is believed to be trashed, this routine
350 * should be called with a non-zero argument (e.g., if setjmp/longjmp is
351 * called). */
352
353 extern void SLang_byte_compile_file(char *, int *);
354 /* takes a file of S-Lang code and ``byte-compiles'' it for faster
355 * loading. The new filename is equivalent to the old except that a `c' is
356 * appended to the name. (e.g., init.sl --> init.slc). If the second
357 * parameter is non-zero, preprocess the file only.
358 */
359
360 extern void SLang_autoload(char *, char *);
361 /* Automatically load S-Lang function p1 from file p2. This function
362 is also available via S-Lang */
363
364 extern char *SLang_load_string(char *);
365 /* Like SLang_load_file except input is from a null terminated string. */
366
367 extern void SLang_do_pop(void);
368 /* pops item off stack and frees any memory associated with it */
369
370 extern int SLang_pop_integer(int *);
371 /* pops integer *p0 from the stack. Returns 0 upon success and non-zero
372 * if the stack is empty or a type mismatch occurs, setting SLang_Error.
373 */
374
375 extern int SLpop_string (char **);
376 extern int SLang_pop_string(char **, int *);
377 /* pops string *p0 from stack. If *p1 is non-zero, the string must be
378 * freed after its use. DO NOT FREE p0 if *p1 IS ZERO! Returns 0 upon
379 * success */
380
381 extern int SLang_pop_float(float64 *, int *, int *);
382 /* Pops float *p1 from stack. If *p3 is non-zero, *p1 was derived
383 from the integer *p2. Returns zero upon success. */
384
385 extern SLuser_Object_Type *SLang_pop_user_object (unsigned char);
386 extern void SLang_free_user_object (SLuser_Object_Type *);
387 extern void SLang_free_intrinsic_user_object (SLuser_Object_Type *);
388 /* This is like SLang_free_user_object but is meant to free those
389 * that have been declared as intrinsic variables by the application.
390 * Normally an application would never need to call this.
391 */
392
393 extern void SLang_push_user_object (SLuser_Object_Type *);
394 extern SLuser_Object_Type *SLang_create_user_object (unsigned char);
395
396 extern int SLang_add_unary_op (unsigned char, FVOID_STAR);
397 extern int SLang_add_binary_op (unsigned char, unsigned char, FVOID_STAR);
398 extern int SLang_register_class (unsigned char, FVOID_STAR, FVOID_STAR);
399 extern int SLang_add_copy_operation (unsigned char, FVOID_STAR);
400
401 extern long *SLang_pop_pointer(unsigned char *, unsigned char *, int *);
402 /* Returns a pointer to object of type *p1,*p2 on top of stack.
403 If *p3 is non-zero, the Object must be freed after use. */
404
405
406 extern void SLang_push_float(float64);
407 /* Push Float onto stack */
408
409 extern void SLang_push_string(char *);
410 /* Push string p1 onto stack */
411
412 extern void SLang_push_integer(int);
413 /* push integer p1 on stack */
414
415 extern void SLang_push_malloced_string(char *);
416 /* The normal SLang_push_string mallocs space for the string. This one
417 does not. DO NOT FREE IT IF YOU USE THIS ROUTINE */
418
419 extern int SLang_is_defined(char *);
420 /* Return non-zero is p1 is defined otherwise returns 0. */
421
422 extern int SLang_run_hooks(char *, char *, char *);
423 /* calls S-Lang function p1 pushing strings p2 and p3 onto the stack
424 * first. If either string is NULL, it is not pushed. If p1 is not
425 * defined, 0 is returned. */
426
427 extern int SLang_execute_function(char *);
428 /* Call S-Lang function p1. Returns 0 if the function is not defined
429 * and 1 if it is.
430 */
431
432 extern char *SLang_find_name(char *);
433 /* Return a pointer to p1 in table if it is defined. Returns NULL
434 * otherwise. This is useful when one wants to avoid redundant strings.
435 */
436
437 extern char *SLang_rpn_interpret(char *);
438 /* Interpret string as reverse polish notation */
439
440 extern void SLang_doerror(char *);
441 /* set SLang_Error and display p1 as error message */
442
443 extern SLuser_Object_Type *SLang_add_array(char *, long *,
444 int, int, int, int,
445 unsigned char, unsigned char);
446 /* This function has not been tested thoroughly yet. Its purpose is to
447 * allow a S-Lang procedure to access a C array. For example, suppose that
448 * you have an array of 100 ints defined as:
449 *
450 * int c_array[100];
451 *
452 * By calling something like:
453 *
454 * SLang_add_array ("array_name", (long *) c_array, 1, 100, 0, 0,
455 * 'i', SLANG_IVARIABLE);
456 *
457 * the array can be accessed by the name 'array_name'. This function
458 * returns -1 upon failure. The 3rd argument specifies the dimension
459 * of the array, the 4th, and 5th arguments specify how many elements
460 * there are in the x,y, and z directions. The last argument must
461 * be one of:
462 *
463 * SLANG_IVARIABLE: indicates array is writable
464 * SLANG_RVARIABLE: indicates array is read only
465 *
466 * Returns NULL upon failure.
467 */
468
469
470 extern int SLang_free_array_handle (int);
471 /* This routine may be called by application to free array handle created by
472 * the application. Returns 0 upon success, -1 if the handle is invalid and
473 * -2 if the handle is not associated with a C array.
474 */
475
476 extern char *SLang_extract_list_element(char *, int *, int*);
477 extern void SLexpand_escaped_string (register char *, register char *,
478 register char *);
479
480 extern SLang_Name_Type *SLang_get_function (char *);
481 /* The parameter is the name of a user defined S-Lang function. This
482 * routine returns NULL if the function does not exist or it returns the
483 * a pointer to it in an internal S-Lang table. This pointer can be used
484 * by 'SLexecute_function' to call the function directly from C.
485 */
486
487 extern void SLexecute_function(SLang_Name_Type *);
488 /* This function allows an application to call a S-Lang function from within
489 * the C program. The parameter must be non-NULL and must have been
490 * previously obtained by a call to 'SLang_get_function'.
491 */
492 extern void SLroll_stack (int *);
493 /* If argument *p is positive, the top |*p| objects on the stack are rolled
494 * up. If negative, the stack is rolled down.
495 */
496
497 extern void SLmake_lut (unsigned char *, unsigned char *, unsigned char);
498
499 extern int SLang_guess_type (char *);
500
501
502 /*}}}*/
503
504 /*{{{ Misc Functions */
505
506 extern char *SLmake_string (char *);
507 extern char *SLmake_nstring (char *, unsigned int);
508 /* Returns a null terminated string made from the first n characters of the
509 * string.
510 */
511
512 extern char *SLcurrent_time_string (void);
513
514 extern int SLatoi(unsigned char *);
515
516 extern int SLang_extract_token(char **, char *, int);
517 /* returns 0 upon failure and non-zero upon success. The first parameter
518 * is a pointer to the input stream which this function will bump along.
519 * The second parameter is the buffer where the token is placed. The third
520 * parameter is used internally by the S-Lang library and should be 0 for
521 * user applications.
522 */
523
524 /*}}}*/
525
526 /*{{{ SLang getkey interface Functions */
527
528 #ifdef REAL_UNIX_SYSTEM
529 extern int SLang_TT_Baud_Rate;
530 extern int SLang_TT_Read_FD;
531 #endif
532
533 extern int SLang_init_tty (int, int, int);
534 /* Initializes the tty for single character input. If the first parameter *p1
535 * is in the range 0-255, it will be used for the abort character;
536 * otherwise, (unix only) if it is -1, the abort character will be the one
537 * used by the terminal. If the second parameter p2 is non-zero, flow
538 * control is enabled. If the last parmeter p3 is zero, output processing
539 * is NOT turned on. A value of zero is required for the screen management
540 * routines. Returns 0 upon success. In addition, if SLang_TT_Baud_Rate ==
541 * 0 when this function is called, SLang will attempt to determine the
542 * terminals baud rate. As far as the SLang library is concerned, if
543 * SLang_TT_Baud_Rate is less than or equal to zero, the baud rate is
544 * effectively infinite.
545 */
546
547 extern void SLang_reset_tty (void);
548 /* Resets tty to what it was prior to a call to SLang_init_tty */
549 #ifdef REAL_UNIX_SYSTEM
550 extern void SLtty_set_suspend_state (int);
551 /* If non-zero argument, terminal driver will be told to react to the
552 * suspend character. If 0, it will not.
553 */
554 extern int (*SLang_getkey_intr_hook) (void);
555 #endif
556
557 #define SLANG_GETKEY_ERROR 0xFFFF
558 extern unsigned int SLang_getkey (void);
559 /* reads a single key from the tty. If the read fails, 0xFFFF is returned. */
560
561 extern void SLang_ungetkey_string (unsigned char *, unsigned int);
562 extern void SLang_buffer_keystring (unsigned char *, unsigned int);
563 extern void SLang_ungetkey (unsigned char);
564 extern void SLang_flush_input (void);
565 extern int SLang_input_pending (int);
566 extern int SLang_Abort_Char;
567 /* The value of the character (0-255) used to trigger SIGINT */
568 extern int SLang_Ignore_User_Abort;
569 /* If non-zero, pressing the abort character will not result in USER_BREAK
570 * SLang_Error. */
571
572 extern void SLang_set_abort_signal (void (*)(int));
573 /* If SIGINT is generated, the function p1 will be called. If p1 is NULL
574 * the SLang_default signal handler is called. This sets SLang_Error to
575 * USER_BREAK. I suspect most users will simply want to pass NULL.
576 */
577
578 extern volatile int SLKeyBoard_Quit;
579
580 #ifdef VMS
581 /* If this function returns -1, ^Y will be added to input buffer. */
582 extern int (*SLtty_VMS_Ctrl_Y_Hook) (void);
583 #endif
584 /*}}}*/
585
586 /*{{{ SLang Keymap routines */
587
588 typedef struct SLKeymap_Function_Type
589 {
590 char *name;
591 int (*f)(void);
592 }
593 SLKeymap_Function_Type;
594
595 typedef struct SLang_Key_Type
596 {
597 unsigned char str[13]; /* key sequence */
598 #define SLKEY_F_INTERPRET 0x01
599 #define SLKEY_F_INTRINSIC 0x02
600 #define SLKEY_F_KEYSYM 0x03
601 unsigned char type; /* type of function */
602 #ifdef SLKEYMAP_OBSOLETE
603 VOID_STAR f; /* function to invoke */
604 #else
605 union
606 {
607 char *s;
608 FVOID_STAR f;
609 unsigned int keysym;
610 }
611 f;
612 #endif
613 struct SLang_Key_Type *next; /* */
614 }
615 SLang_Key_Type;
616
617 #define MAX_KEYMAP_NAME_LEN 8
618 typedef struct SLKeyMap_List_Type
619 {
620 char name[MAX_KEYMAP_NAME_LEN + 1];
621 SLang_Key_Type *keymap;
622 SLKeymap_Function_Type *functions; /* intrinsic functions */
623 }
624 SLKeyMap_List_Type;
625
626 /* This is arbitrary but I have got to start somewhere */
627 #ifdef msdos
628 #define SLANG_MAX_KEYMAPS 10
629 #else
630 #define SLANG_MAX_KEYMAPS 30
631 #endif
632
633 extern SLKeyMap_List_Type SLKeyMap_List[SLANG_MAX_KEYMAPS]; /* these better be inited to 0! */
634
635
636 extern char *SLang_process_keystring(char *);
637
638 #ifdef SLKEYMAP_OBSOLETE
639 extern int SLang_define_key1(char *, VOID_STAR, unsigned int, SLKeyMap_List_Type *);
640 /* define key p1 in keymap p4 to invoke function p2. If type p3 is given by
641 * SLKEY_F_INTRINSIC, p2 is an intrinsic function, else it is a string to be
642 * passed to the interpreter for evaluation. The return value is important.
643 * It returns 0 upon success, -1 upon malloc error, and -2 if the key is
644 * inconsistent. SLang_Error is set upon error. */
645 #else
646 extern int SLkm_define_key (char *, FVOID_STAR, SLKeyMap_List_Type *);
647 #endif
648
649 extern int SLang_define_key(char *, char *, SLKeyMap_List_Type *);
650 /* Like define_key1 except that p2 is a string that is to be associated with
651 * a function in the functions field of p3. This routine calls define_key1.
652 */
653
654 extern int SLkm_define_keysym (char *, unsigned int, SLKeyMap_List_Type *);
655
656 extern void SLang_undefine_key(char *, SLKeyMap_List_Type *);
657
658 extern SLKeyMap_List_Type *SLang_create_keymap(char *, SLKeyMap_List_Type *);
659 /* create and returns a pointer to a new keymap named p1 created by copying
660 * keymap p2. If p2 is NULL, it is up to the calling routine to initialize
661 * the keymap.
662 */
663
664 extern char *SLang_make_keystring(unsigned char *);
665
666 extern SLang_Key_Type *SLang_do_key(SLKeyMap_List_Type *, int (*)(void));
667 /* read a key using keymap p1 with getkey function p2 */
668
669 extern
670 #ifdef SLKEYMAP_OBSOLETE
671 VOID_STAR
672 #else
673 FVOID_STAR
674 #endif
675 SLang_find_key_function(char *, SLKeyMap_List_Type *);
676
677 extern SLKeyMap_List_Type *SLang_find_keymap(char *);
678
679 extern int SLang_Last_Key_Char;
680 extern int SLang_Key_TimeOut_Flag;
681
682
683 /*}}}*/
684
685 /*{{{ SLang Readline Interface */
686
687 typedef struct SLang_Read_Line_Type
688 {
689 struct SLang_Read_Line_Type *prev, *next;
690 unsigned char *buf;
691 int buf_len; /* number of chars in the buffer */
692 int num; /* num and misc are application specific*/
693 int misc;
694 } SLang_Read_Line_Type;
695
696 /* Maximum size of display */
697 #define SLRL_DISPLAY_BUFFER_SIZE 256
698
699 typedef struct
700 {
701 SLang_Read_Line_Type *root, *tail, *last;
702 unsigned char *buf; /* edit buffer */
703 int buf_len; /* sizeof buffer */
704 int point; /* current editing point */
705 int tab; /* tab width */
706 int len; /* current line size */
707
708 /* display variables */
709 int edit_width; /* length of display field */
710 int curs_pos; /* current column */
711 int start_column; /* column offset of display */
712 int dhscroll; /* amount to use for horiz scroll */
713 char *prompt;
714
715 FVOID_STAR last_fun; /* last function executed by rl */
716
717 /* These two contain an image of what is on the display */
718 unsigned char upd_buf1[SLRL_DISPLAY_BUFFER_SIZE];
719 unsigned char upd_buf2[SLRL_DISPLAY_BUFFER_SIZE];
720 unsigned char *old_upd, *new_upd; /* pointers to previous two buffers */
721 int new_upd_len, old_upd_len; /* length of output buffers */
722
723 SLKeyMap_List_Type *keymap;
724
725 /* tty variables */
726 unsigned int flags; /* */
727 #define SL_RLINE_NO_ECHO 1
728 #define SL_RLINE_USE_ANSI 2
729 unsigned int (*getkey)(void); /* getkey function -- required */
730 void (*tt_goto_column)(int);
731 void (*tt_insert)(char);
732 void (*update_hook)(unsigned char *, int, int);
733 /* The update hook is called with a pointer to a buffer p1 that contains
734 * an image of what the update hook is suppoed to produce. The length
735 * of the buffer is p2 and after the update, the cursor is to be placed
736 * in column p3.
737 */
738 } SLang_RLine_Info_Type;
739
740 extern int SLang_RL_EOF_Char;
741
742 extern SLang_Read_Line_Type * SLang_rline_save_line (SLang_RLine_Info_Type *);
743 extern int SLang_init_readline (SLang_RLine_Info_Type *);
744 extern int SLang_read_line (SLang_RLine_Info_Type *);
745 extern int SLang_rline_insert (char *);
746 extern void SLrline_redraw (SLang_RLine_Info_Type *);
747 extern int SLang_Rline_Quit;
748
749 /*}}}*/
750
751 /*{{{ Low Level Screen Output Interface */
752
753 extern unsigned long SLtt_Num_Chars_Output;
754 extern int SLtt_Baud_Rate;
755
756 typedef unsigned long SLtt_Char_Type;
757
758 #define SLTT_BOLD_MASK 0x01000000
759 #define SLTT_BLINK_MASK 0x02000000
760 #define SLTT_ULINE_MASK 0x04000000
761 #define SLTT_REV_MASK 0x08000000
762 #define SLTT_ALTC_MASK 0x10000000
763
764 extern int SLtt_Screen_Rows;
765 extern int SLtt_Screen_Cols;
766 extern int SLtt_Term_Cannot_Insert;
767 extern int SLtt_Term_Cannot_Scroll;
768 extern int SLtt_Use_Ansi_Colors;
769 extern int SLtt_Ignore_Beep;
770 #if defined(REAL_UNIX_SYSTEM)
771 extern int SLtt_Force_Keypad_Init;
772 #endif
773
774 #ifndef __GO32__
775 #if defined(VMS) || defined(REAL_UNIX_SYSTEM)
776 extern int SLtt_Blink_Mode;
777 extern int SLtt_Use_Blink_For_ACS;
778 extern int SLtt_Newline_Ok;
779 extern int SLtt_Has_Alt_Charset;
780 extern int SLtt_Has_Status_Line; /* if 0, NO. If > 0, YES, IF -1, ?? */
781 # ifndef VMS
782 extern int SLtt_Try_Termcap;
783 # endif
784 #endif
785 #endif
786
787 #ifdef msdos
788 extern int SLtt_Msdos_Cheap_Video;
789 #endif
790
791
792 extern int SLtt_flush_output (void);
793 extern void SLtt_set_scroll_region(int, int);
794 extern void SLtt_reset_scroll_region(void);
795 extern void SLtt_reverse_video (int);
796 extern void SLtt_bold_video (void);
797 extern void SLtt_begin_insert(void);
798 extern void SLtt_end_insert(void);
799 extern void SLtt_del_eol(void);
800 extern void SLtt_goto_rc (int, int);
801 extern void SLtt_delete_nlines(int);
802 extern void SLtt_delete_char(void);
803 extern void SLtt_erase_line(void);
804 extern void SLtt_normal_video(void);
805 extern void SLtt_cls(void);
806 extern void SLtt_beep(void);
807 extern void SLtt_reverse_index(int);
808 extern void SLtt_smart_puts(unsigned short *, unsigned short *, int, int);
809 extern void SLtt_write_string (char *);
810 extern void SLtt_putchar(char);
811 extern void SLtt_init_video (void);
812 extern void SLtt_reset_video (void);
813 extern void SLtt_get_terminfo(void);
814 extern void SLtt_get_screen_size (void);
815 extern int SLtt_set_cursor_visibility (int);
816
817 #if defined(VMS) || defined(REAL_UNIX_SYSTEM)
818 extern void SLtt_enable_cursor_keys(void);
819 extern void SLtt_set_term_vtxxx(int *);
820 extern void SLtt_set_color_esc (int, char *);
821 extern void SLtt_wide_width(void);
822 extern void SLtt_narrow_width(void);
823 extern int SLtt_set_mouse_mode (int, int);
824 extern void SLtt_set_alt_char_set (int);
825 extern int SLtt_write_to_status_line (char *, int);
826 extern void SLtt_disable_status_line (void);
827 # ifdef REAL_UNIX_SYSTEM
828 extern char *SLtt_tgetstr (char *);
829 extern int SLtt_tgetnum (char *);
830 extern int SLtt_tgetflag (char *);
831 extern char *SLtt_tigetent (char *);
832 extern char *SLtt_tigetstr (char *, char **);
833 extern int SLtt_tigetnum (char *, char **);
834 # endif
835 #endif
836
837 extern SLtt_Char_Type SLtt_get_color_object (int);
838 extern void SLtt_set_color_object (int, SLtt_Char_Type);
839 extern void SLtt_set_color (int, char *, char *, char *);
840 extern void SLtt_set_mono (int, char *, SLtt_Char_Type);
841 extern void SLtt_add_color_attribute (int, SLtt_Char_Type);
842 extern void SLtt_set_color_fgbg (int, SLtt_Char_Type, SLtt_Char_Type);
843
844 /*}}}*/
845
846 /*{{{ SLang Preprocessor Interface */
847
848 typedef struct
849 {
850 int this_level;
851 int exec_level;
852 int prev_exec_level;
853 char preprocess_char;
854 char comment_char;
855 unsigned char flags;
856 #define SLPREP_BLANK_LINES_OK 1
857 #define SLPREP_COMMENT_LINES_OK 2
858 }
859 SLPreprocess_Type;
860
861 extern int SLprep_open_prep (SLPreprocess_Type *);
862 extern void SLprep_close_prep (SLPreprocess_Type *);
863 extern int SLprep_line_ok (char *, SLPreprocess_Type *);
864 extern int SLdefine_for_ifdef (char *);
865 /* Adds a string to the SLang #ifdef preparsing defines. SLang already
866 defines MSDOS, UNIX, and VMS on the appropriate system. */
867 extern int (*SLprep_exists_hook) (char *, char);
868
869
870 /*}}}*/
871
872 /*{{{ SLsmg Screen Management Functions */
873
874 #include <stdarg.h>
875 extern void SLsmg_fill_region (int, int, int, int, unsigned char);
876 #ifndef pc_system
877 extern void SLsmg_set_char_set (int);
878 extern int SLsmg_Scroll_Hash_Border;
879 #endif
880 extern void SLsmg_suspend_smg (void);
881 extern void SLsmg_resume_smg (void);
882 extern void SLsmg_erase_eol (void);
883 extern void SLsmg_gotorc (int, int);
884 extern void SLsmg_erase_eos (void);
885 extern void SLsmg_reverse_video (void);
886 extern void SLsmg_set_color (int);
887 extern void SLsmg_normal_video (void);
888 extern void SLsmg_printf (char *, ...);
889 extern void SLsmg_vprintf (char *, va_list);
890 extern void SLsmg_write_string (char *);
891 extern void SLsmg_write_nstring (char *, int);
892 extern void SLsmg_write_char (char);
893 extern void SLsmg_write_nchars (char *, int);
894 extern void SLsmg_write_wrapped_string (char *, int, int, int, int, int);
895 extern void SLsmg_cls (void);
896 extern void SLsmg_refresh (void);
897 extern void SLsmg_touch_lines (int, int);
898 extern int SLsmg_init_smg (void);
899 extern void SLsmg_reset_smg (void);
900 extern unsigned short SLsmg_char_at(void);
901 extern void SLsmg_set_screen_start (int *, int *);
902 extern void SLsmg_draw_hline (int);
903 extern void SLsmg_draw_vline (int);
904 extern void SLsmg_draw_object (int, int, unsigned char);
905 extern void SLsmg_draw_box (int, int, int, int);
906 extern int SLsmg_get_column(void);
907 extern int SLsmg_get_row(void);
908 extern void SLsmg_forward (int);
909 extern void SLsmg_write_color_chars (unsigned short *, unsigned int);
910 extern unsigned int SLsmg_read_raw (unsigned short *, unsigned int);
911 extern unsigned int SLsmg_write_raw (unsigned short *, unsigned int);
912
913 extern int SLsmg_Display_Eight_Bit;
914 extern int SLsmg_Tab_Width;
915 extern int SLsmg_Newline_Moves;
916 extern int SLsmg_Backspace_Moves;
917
918 #ifdef pc_system
919 # define SLSMG_HLINE_CHAR 0xC4
920 # define SLSMG_VLINE_CHAR 0xB3
921 # define SLSMG_ULCORN_CHAR 0xDA
922 # define SLSMG_URCORN_CHAR 0xBF
923 # define SLSMG_LLCORN_CHAR 0xC0
924 # define SLSMG_LRCORN_CHAR 0xD9
925 # define SLSMG_RTEE_CHAR 0xB4
926 # define SLSMG_LTEE_CHAR 0xC3
927 # define SLSMG_UTEE_CHAR 0xC2
928 # define SLSMG_DTEE_CHAR 0xC1
929 # define SLSMG_PLUS_CHAR 0xC5
930 /* There are several to choose from: 0xB0, 0xB1, and 0xB2 */
931 # define SLSMG_CKBRD_CHAR 0xB0
932 #else
933 # define SLSMG_HLINE_CHAR 'q'
934 # define SLSMG_VLINE_CHAR 'x'
935 # define SLSMG_ULCORN_CHAR 'l'
936 # define SLSMG_URCORN_CHAR 'k'
937 # define SLSMG_LLCORN_CHAR 'm'
938 # define SLSMG_LRCORN_CHAR 'j'
939 # define SLSMG_CKBRD_CHAR 'a'
940 # define SLSMG_RTEE_CHAR 'u'
941 # define SLSMG_LTEE_CHAR 't'
942 # define SLSMG_UTEE_CHAR 'w'
943 # define SLSMG_DTEE_CHAR 'v'
944 # define SLSMG_PLUS_CHAR 'n'
945 #endif
946
947 #ifndef pc_system
948 # define SLSMG_COLOR_BLACK 0x000000
949 # define SLSMG_COLOR_RED 0x000001
950 # define SLSMG_COLOR_GREEN 0x000002
951 # define SLSMG_COLOR_BROWN 0x000003
952 # define SLSMG_COLOR_BLUE 0x000004
953 # define SLSMG_COLOR_MAGENTA 0x000005
954 # define SLSMG_COLOR_CYAN 0x000006
955 # define SLSMG_COLOR_LGRAY 0x000007
956 # define SLSMG_COLOR_GRAY 0x000008
957 # define SLSMG_COLOR_BRIGHT_RED 0x000009
958 # define SLSMG_COLOR_BRIGHT_GREEN 0x00000A
959 # define SLSMG_COLOR_BRIGHT_BROWN 0x00000B
960 # define SLSMG_COLOR_BRIGHT_BLUE 0x00000C
961 # define SLSMG_COLOR_BRIGHT_CYAN 0x00000D
962 # define SLSMG_COLOR_BRIGHT_MAGENTA 0x00000E
963 # define SLSMG_COLOR_BRIGHT_WHITE 0x00000F
964 #endif
965
966 /*}}}*/
967
968 /*{{{ SLang Keypad Interface */
969
970 #define SL_KEY_ERR 0xFFFF
971
972 #define SL_KEY_UP 0x101
973 #define SL_KEY_DOWN 0x102
974 #define SL_KEY_LEFT 0x103
975 #define SL_KEY_RIGHT 0x104
976 #define SL_KEY_PPAGE 0x105
977 #define SL_KEY_NPAGE 0x106
978 #define SL_KEY_HOME 0x107
979 #define SL_KEY_END 0x108
980 #define SL_KEY_A1 0x109
981 #define SL_KEY_A3 0x10A
982 #define SL_KEY_B2 0x10B
983 #define SL_KEY_C1 0x10C
984 #define SL_KEY_C3 0x10D
985 #define SL_KEY_REDO 0x10E
986 #define SL_KEY_UNDO 0x10F
987 #define SL_KEY_BACKSPACE 0x110
988 #define SL_KEY_ENTER 0x111
989 #define SL_KEY_IC 0x112
990 #define SL_KEY_DELETE 0x113
991
992 #define SL_KEY_F0 0x200
993 #define SL_KEY_F(X) (SL_KEY_F0 + X)
994
995 /* I do not intend to use keysymps > 0x1000. Applications can use those. */
996 /* Returns 0 upon success or -1 upon error. */
997 int SLkp_define_keysym (char *, unsigned int);
998
999 /* This function must be called AFTER SLtt_get_terminfo and not before. */
1000 extern int SLkp_init (void);
1001
1002 /* This function uses SLang_getkey and assumes that what ever initialization
1003 * is required for SLang_getkey has been performed.
1004 */
1005 extern int SLkp_getkey (void);
1006
1007 /*}}}*/
1008
1009 /*{{{ SLang Scroll Interface */
1010
1011 typedef struct _SLscroll_Type
1012 {
1013 struct _SLscroll_Type *next;
1014 struct _SLscroll_Type *prev;
1015 unsigned int flags;
1016 }
1017 SLscroll_Type;
1018
1019 typedef struct
1020 {
1021 unsigned int flags;
1022 SLscroll_Type *top_window_line; /* list element at top of window */
1023 SLscroll_Type *bot_window_line; /* list element at bottom of window */
1024 SLscroll_Type *current_line; /* current list element */
1025 SLscroll_Type *lines; /* first list element */
1026 unsigned int nrows; /* number of rows in window */
1027 unsigned int hidden_mask; /* applied to flags in SLscroll_Type */
1028 unsigned int line_num; /* current line number (visible) */
1029 unsigned int num_lines; /* total number of lines (visible) */
1030 unsigned int window_row; /* row of current_line in window */
1031 unsigned int border; /* number of rows that form scroll border */
1032 int cannot_scroll; /* should window scroll or recenter */
1033 }
1034 SLscroll_Window_Type;
1035
1036 extern int SLscroll_find_top (SLscroll_Window_Type *);
1037 extern int SLscroll_find_line_num (SLscroll_Window_Type *);
1038 extern unsigned int SLscroll_next_n (SLscroll_Window_Type *, unsigned int);
1039 extern unsigned int SLscroll_prev_n (SLscroll_Window_Type *, unsigned int);
1040 extern int SLscroll_pageup (SLscroll_Window_Type *);
1041 extern int SLscroll_pagedown (SLscroll_Window_Type *);
1042
1043 /*}}}*/
1044
1045 /*{{{ Signal Routines */
1046
1047 typedef void SLSig_Fun_Type (int);
1048 extern SLSig_Fun_Type *SLsignal (int, SLSig_Fun_Type *);
1049 extern SLSig_Fun_Type *SLsignal_intr (int, SLSig_Fun_Type *);
1050 #ifndef pc_system
1051 extern int SLsig_block_signals (void);
1052 extern int SLsig_unblock_signals (void);
1053 #endif
1054 /*}}}*/
1055
1056 /*{{{ Interpreter Macro Definitions */
1057
1058 /* This value is a main_type just like the other main_types defined
1059 * near the definition of SLang_Name_Type. Applications should avoid using
1060 * this so if you do not understands its role, do not use it.
1061 */
1062 #define SLANG_DATA 0x30 /* real objects which may be destroyed */
1063
1064 /* Subtypes */
1065
1066 /* The definitions here are for objects that may be on the run-time stack.
1067 * They are actually sub_types of literal and data main_types.
1068 */
1069 #define VOID_TYPE 1
1070 #define INT_TYPE 2
1071 #ifdef FLOAT_TYPE
1072 # undef FLOAT_TYPE
1073 # define FLOAT_TYPE 3
1074 #endif
1075 #define CHAR_TYPE 4
1076 #define INTP_TYPE 5
1077 /* An object of INTP_TYPE should never really occur on the stack. Rather,
1078 * the integer to which it refers will be there instead. It is defined here
1079 * because it is a valid type for MAKE_VARIABLE.
1080 */
1081
1082 #define SLANG_OBJ_TYPE 6
1083 /* SLANG_OBJ_TYPE refers to an object on the stack that is a pointer to
1084 * some other object.
1085 */
1086
1087 #if 0
1088 /* This is not ready yet. */
1089 # define SLANG_NOOP 9
1090 #endif
1091
1092 /* Everything above string should correspond to a pointer in the object
1093 * structure. See do_binary (slang.c) for exploitation of this fact.
1094 */
1095 #define STRING_TYPE 10
1096 /* Array type MUST be the smallest number for SLuser_Object_Type structs */
1097 #define ARRAY_TYPE 20
1098 /* I am reserving values greater than or equal to user applications. The
1099 * first 99 are used for S-Lang.
1100 */
1101
1102
1103 /* Binary and Unary Subtypes */
1104 /* Since the application can define new types and can overload the binary
1105 * and unary operators, these definitions must be present in this file.
1106 */
1107 #define SLANG_PLUS 1
1108 #define SLANG_MINUS 2
1109 #define SLANG_TIMES 3
1110 #define SLANG_DIVIDE 4
1111 #define SLANG_EQ 5
1112 #define SLANG_NE 6
1113 #define SLANG_GT 7
1114 #define SLANG_GE 8
1115 #define SLANG_LT 9
1116 #define SLANG_LE 10
1117
1118 /* UNARY subtypes (may be overloaded) */
1119 #define SLANG_ABS 11
1120 #define SLANG_SIGN 12
1121 #define SLANG_SQR 13
1122 #define SLANG_MUL2 14
1123 #define SLANG_CHS 15
1124
1125 /* error codes, severe errors are less than 0 */
1126 #define SL_INVALID_PARM -6
1127 #define SL_MALLOC_ERROR -5
1128 #define INTERNAL_ERROR -4
1129 #define UNKNOWN_ERROR -3
1130 #define STACK_OVERFLOW -1
1131 #define STACK_UNDERFLOW -2
1132 #define INTRINSIC_ERROR 1
1133 /* Intrinsic error is an error generated by intrinsic functions */
1134 #define USER_BREAK 2
1135 #define UNDEFINED_NAME 3
1136 #define SYNTAX_ERROR 4
1137 #define DUPLICATE_DEFINITION 5
1138 #define TYPE_MISMATCH 6
1139 #define READONLY_ERROR 7
1140 #define DIVIDE_ERROR 8
1141 /* object could not be opened */
1142 #define SL_OBJ_NOPEN 9
1143 /* unknown object */
1144 #define SL_OBJ_UNKNOWN 10
1145
1146 extern char *SLang_Error_Message;
1147
1148 extern void SLadd_name(char *, long, unsigned char, unsigned char);
1149 extern void SLadd_at_handler (long *, char *);
1150
1151 #define SLANG_MAKE_ARGS(out, in) ((unsigned char)(out) | ((unsigned short) (in) << 4))
1152
1153 #ifdef SLANG_STATS
1154
1155 #define MAKE_INTRINSIC(n, f, out, in) \
1156 {0, n, (out | (in << 4)), SLANG_INTRINSIC, (long) f}
1157
1158 #define MAKE_VARIABLE(n, v, t, r) \
1159 {0, n, t, (SLANG_IVARIABLE + r), (long) v}
1160
1161 #else
1162 #define MAKE_INTRINSIC(n, f, out, in) \
1163 {n, (out | (in << 4)), SLANG_INTRINSIC, (long) f}
1164
1165 #define MAKE_VARIABLE(n, v, t, r) \
1166 {n, t, (SLANG_IVARIABLE + r), (long) v}
1167 #endif
1168
1169 #define SLANG_END_TABLE MAKE_INTRINSIC("", 0, 0, 0)
1170
1171
1172 /*}}}*/
1173
1174 /*{{{ Upper/Lowercase Functions */
1175
1176 extern void SLang_define_case(int *, int *);
1177 extern void SLang_init_case_tables (void);
1178
1179 extern unsigned char Chg_UCase_Lut[256];
1180 extern unsigned char Chg_LCase_Lut[256];
1181 #define UPPER_CASE(x) (Chg_UCase_Lut[(unsigned char) (x)])
1182 #define LOWER_CASE(x) (Chg_LCase_Lut[(unsigned char) (x)])
1183 #define CHANGE_CASE(x) (((x) == Chg_LCase_Lut[(unsigned char) (x)]) ?\
1184 Chg_UCase_Lut[(unsigned char) (x)] : Chg_LCase_Lut[(unsigned char) (x)])
1185
1186
1187 /*}}}*/
1188
1189 /*{{{ Regular Expression Interface */
1190
1191 typedef struct
1192 {
1193 unsigned char *pat; /* regular expression pattern */
1194 unsigned char *buf; /* buffer for compiled regexp */
1195 unsigned int buf_len; /* length of buffer */
1196 int case_sensitive; /* 1 if match is case sensitive */
1197 int must_match; /* 1 if line must contain substring */
1198 int must_match_bol; /* true if it must match beginning of line */
1199 unsigned char must_match_str[16]; /* 15 char null term substring */
1200 int osearch; /* 1 if ordinary search suffices */
1201 unsigned int min_length; /* minimum length the match must be */
1202 int beg_matches[10]; /* offset of start of \( */
1203 unsigned int end_matches[10]; /* length of nth submatch
1204 * Note that the entire match corresponds
1205 * to \0
1206 */
1207 int offset; /* offset to be added to beg_matches */
1208 } SLRegexp_Type;
1209
1210 extern unsigned char *SLang_regexp_match(unsigned char *,
1211 unsigned int,
1212 SLRegexp_Type *);
1213 extern int SLang_regexp_compile (SLRegexp_Type *);
1214 extern char *SLregexp_quote_string (char *, char *, unsigned int);
1215
1216
1217 /*}}}*/
1218
1219 /*{{{ SLang Command Interface */
1220
1221 #define SLCMD_MAX_ARGS 10
1222 struct _SLcmd_Cmd_Type; /* Pre-declaration is needed below */
1223 typedef struct
1224 {
1225 struct _SLcmd_Cmd_Type *table;
1226 int argc;
1227 char *string_args[SLCMD_MAX_ARGS];
1228 int int_args[SLCMD_MAX_ARGS];
1229 float64 float_args[SLCMD_MAX_ARGS];
1230 unsigned char arg_type[SLCMD_MAX_ARGS];
1231 } SLcmd_Cmd_Table_Type;
1232
1233
1234 typedef struct _SLcmd_Cmd_Type
1235 {
1236 int (*cmdfun)(int, SLcmd_Cmd_Table_Type *);
1237 char cmd[32];
1238 char arg_type[SLCMD_MAX_ARGS];
1239 } SLcmd_Cmd_Type;
1240
1241 extern int SLcmd_execute_string (char *, SLcmd_Cmd_Table_Type *);
1242
1243 /*}}}*/
1244
1245 /*{{{ SLang Search Interface */
1246
1247 typedef struct
1248 {
1249 int cs; /* case sensitive */
1250 unsigned char key[256];
1251 int ind[256];
1252 int key_len;
1253 int dir;
1254 } SLsearch_Type;
1255
1256 extern int SLsearch_init (char *, int, int, SLsearch_Type *);
1257 /* This routine must first be called before any search can take place.
1258 * The second parameter specifies the direction of the search: greater than
1259 * zero for a forwrd search and less than zero for a backward search. The
1260 * third parameter specifies whether the search is case sensitive or not.
1261 * The last parameter is a pointer to a structure that is filled by this
1262 * function and it is this structure that must be passed to SLsearch.
1263 */
1264
1265 unsigned char *SLsearch (unsigned char *, unsigned char *, SLsearch_Type *);
1266 /* To use this routine, you must first call 'SLsearch_init'. Then the first
1267 * two parameters p1 and p2 serve to define the region over which the search
1268 * is to take place. The third parameter is the structure that was previously
1269 * initialized by SLsearch_init.
1270 *
1271 * The routine returns a pointer to the match if found otherwise it returns
1272 * NULL.
1273 */
1274
1275 /*}}}*/
1276
1277 #if 0
1278 {
1279 #endif
1280 #ifdef __cplusplus
1281 }
1282 #endif
1283
1284 #endif /* _DAVIS_SLANG_H_ */