⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 slang.h

📁 一个C格式的脚本处理函数库源代码,可让你的C程序具有执行C格式的脚本文件
💻 H
📖 第 1 页 / 共 5 页
字号:
   /* These functions are obsolte.  Use init_stdio, posix_process, etc. */extern int SLang_init_slassoc (void);/* Assoc Arrays (Hashes) */extern int SLang_init_array (void);/* Additional arrays functions: transpose, etc... */extern int SLang_init_array_extra (void);/* Additional arrays functions: sum, min, max, ... *//* Dynamic linking facility */extern int SLang_init_import (void);   extern int SLang_load_file (char *);   /* Load a file of S-Lang code for interpreting.  If the parameter is    * NULL, input comes from stdin. */   extern void SLang_restart(int);   /* should be called if an error occurs.  If the passed integer is    * non-zero, items are popped off the stack; otherwise, the stack is    * left intact.  Any time the stack is believed to be trashed, this routine    * should be called with a non-zero argument (e.g., if setjmp/longjmp is    * called). */   extern int SLang_byte_compile_file(char *, int);   /* takes a file of S-Lang code and ``byte-compiles'' it for faster    * loading.  The new filename is equivalent to the old except that a `c' is    * appended to the name.  (e.g., init.sl --> init.slc).  The second    * specified the method; currently, it is not used.    */   extern int SLang_autoload(char *, char *);   /* Automatically load S-Lang function p1 from file p2.  This function      is also available via S-Lang */   extern int SLang_load_string(char *);   /* Like SLang_load_file except input is from a null terminated string. */   extern int SLdo_pop(void);   /* pops item off stack and frees any memory associated with it */   extern int SLdo_pop_n(unsigned int);   /* pops n items off stack and frees any memory associated with them */extern int SLang_pop_datatype (SLtype *);extern int SLang_push_datatype (SLtype);extern int SLang_pop_integer(int *);extern int SLang_pop_uinteger(unsigned int *);   /* pops integer *p0 from the stack.  Returns 0 upon success and non-zero    * if the stack is empty or a type mismatch occurs, setting SLang_Error.    */extern int SLang_pop_char (char *);extern int SLang_pop_uchar (SLtype *);extern int SLang_pop_short(short *);extern int SLang_pop_ushort(unsigned short *);extern int SLang_pop_long(long *);extern int SLang_pop_ulong(unsigned long *);extern int SLang_pop_float(float *);extern int SLang_pop_double(double *, int *, int *);   /* Pops double *p1 from stack.  If *p3 is non-zero, *p1 was derived      from the integer *p2. Returns zero upon success. */   extern int SLang_pop_complex (double *, double *);   extern int SLpop_string (char **);   extern int SLang_pop_string(char **, int *);   /* pops string *p0 from stack.  If *p1 is non-zero, the string must be    * freed after its use.  DO NOT FREE p0 if *p1 IS ZERO! Returns 0 upon    * success */   extern int SLang_push_complex (double, double);   extern int SLang_push_char (char);   extern int SLang_push_uchar (SLtype);   extern int SLang_push_integer(int);   extern int SLang_push_uinteger(unsigned int);   /* push integer p1 on stack */   extern int SLang_push_short(short);   extern int SLang_push_ushort(unsigned short);   extern int SLang_push_long(long);   extern int SLang_push_ulong(unsigned long);   extern int SLang_push_float(float);   extern int SLang_push_double(double);   /* Push double onto stack */   extern int SLang_push_string(char *);   /* Push string p1 onto stack */   extern int SLang_push_malloced_string(char *);   /* The normal SLang_push_string pushes an slstring.  This one converts    * a normally malloced string to an slstring, and then frees the     * malloced string.  So, do NOT use the malloced string after calling    * this routine because it will be freed!  The routine returns -1 upon     * error, but the string will be freed.    */extern int SLang_push_null (void);extern int SLang_pop_null (void);extern int SLang_push_value (SLtype type, VOID_STAR);extern int SLang_pop_value (SLtype type, VOID_STAR);extern void SLang_free_value (SLtype type, VOID_STAR);typedef struct _SLang_Object_Type SLang_Any_Type;extern int SLang_pop_anytype (SLang_Any_Type **);extern int SLang_push_anytype (SLang_Any_Type *);extern void SLang_free_anytype (SLang_Any_Type *);#ifdef _SLANG_SOURCE_typedef struct _SLang_Ref_Type SLang_Ref_Type;#elsetypedef int SLang_Ref_Type;#endifextern int SLang_pop_ref (SLang_Ref_Type **);extern void SLang_free_ref (SLang_Ref_Type *);extern int SLang_assign_to_ref (SLang_Ref_Type *, SLtype, VOID_STAR);extern SLang_Name_Type *SLang_pop_function (void);extern SLang_Name_Type *SLang_get_fun_from_ref (SLang_Ref_Type *);extern void SLang_free_function (SLang_Name_Type *f);/* C structure interface */extern int SLang_push_cstruct (VOID_STAR, SLang_CStruct_Field_Type *);extern int SLang_pop_cstruct (VOID_STAR, SLang_CStruct_Field_Type *);extern void SLang_free_cstruct (VOID_STAR, SLang_CStruct_Field_Type *);extern int SLang_assign_cstruct_to_ref (SLang_Ref_Type *, VOID_STAR, SLang_CStruct_Field_Type *);   extern int SLang_is_defined(char *);   /* Return non-zero is p1 is defined otherwise returns 0. */   extern int SLang_run_hooks(char *, unsigned int, ...);   /* calls S-Lang function p1 pushing p2 strings in the variable argument    * list onto the stack first.    * Returns -1 upon error, 1 if hooks exists and it ran,    * or 0 if hook does not exist.  Thus it returns non-zero is hook was called.    *//* These functions return 1 if the indicated function exists and the function * runs without error.  If the function does not exist, the function returns * 0.  Otherwise -1 is returned with SLang_Error set appropriately. */extern int SLexecute_function (SLang_Name_Type *);extern int SLang_execute_function(char *);extern int SLang_end_arg_list (void);extern int SLang_start_arg_list (void);extern void SLang_verror (int, char *, ...) _SLATTRIBUTE_PRINTF(2,3);extern void SLang_doerror(char *);   /* set SLang_Error and display p1 as error message */extern int SLang_add_intrinsic_array (char *,   /* name */				      SLtype,   /* type */				      int,   /* readonly */				      VOID_STAR,   /* data */				      unsigned int, ...);   /* num dims */extern int SLextract_list_element (char *, unsigned int, char,				   char *, unsigned int);extern void SLexpand_escaped_string (register char *, register char *,				     register char *);extern SLang_Name_Type *SLang_get_function (char *);extern void SLang_release_function (SLang_Name_Type *);extern int SLreverse_stack (int);extern int SLroll_stack (int);/* If argument p is positive, the top p objects on the stack are rolled * up.  If negative, the stack is rolled down. */extern int SLdup_n (int n);/* Duplicate top n elements of stack */extern int SLang_peek_at_stack1 (void);extern int SLang_peek_at_stack (void);/* Returns type of next object on stack-- -1 upon stack underflow. */extern void SLmake_lut (unsigned char *, unsigned char *, unsigned char);   extern int SLang_guess_type (char *);extern int SLstruct_create_struct (unsigned int,				   char **,				   SLtype *,				   VOID_STAR *);/*}}}*//*{{{ Misc Functions *//* This is an interface to atexit */extern int SLang_add_cleanup_function (void (*)(void));extern char *SLmake_string (char *);extern char *SLmake_nstring (char *, unsigned int);/* Returns a null terminated string made from the first n characters of the * string. *//* The string created by this routine must be freed by SLang_free_slstring * and nothing else!!  Also these strings must not be modified.  Use * SLmake_string if you intend to modify them!! */extern char *SLang_create_nslstring (char *, unsigned int);extern char *SLang_create_slstring (char *);extern void SLang_free_slstring (char *);    /* handles NULL */extern int SLang_pop_slstring (char **);   /* free with SLang_free_slstring */extern char *SLang_concat_slstrings (char *a, char *b);extern char *SLang_create_static_slstring (char *);   /* adds a string that will not get deleted */extern void SLstring_dump_stats (void);/* Binary strings *//* The binary string is an opaque type.  Use the SLbstring_get_pointer function * to get a pointer and length. */typedef struct _SLang_BString_Type SLang_BString_Type;extern unsigned char *SLbstring_get_pointer (SLang_BString_Type *, unsigned int *);extern SLang_BString_Type *SLbstring_dup (SLang_BString_Type *);extern SLang_BString_Type *SLbstring_create (unsigned char *, unsigned int);/* The create_malloced function used the first argument which is assumed * to be a pointer to a len + 1 malloced string.  The extra byte is for * \0 termination. */extern SLang_BString_Type *SLbstring_create_malloced (unsigned char *, unsigned int, int);/* Create a bstring from an slstring */extern SLang_BString_Type *SLbstring_create_slstring (char *);extern void SLbstring_free (SLang_BString_Type *);extern int SLang_pop_bstring (SLang_BString_Type **);extern int SLang_push_bstring (SLang_BString_Type *);extern char *SLmalloc (unsigned int);extern char *SLcalloc (unsigned int, unsigned int);extern void SLfree(char *);	       /* This function handles NULL */extern char *SLrealloc (char *, unsigned int);extern char *SLcurrent_time_string (void);extern int SLatoi(unsigned char *);extern long SLatol (unsigned char *);extern unsigned long SLatoul (unsigned char *);extern int SLang_pop_fileptr (SLang_MMT_Type **, FILE **);extern char *SLang_get_name_from_fileptr (SLang_MMT_Type *);typedef struct _SLFile_FD_Type SLFile_FD_Type;extern SLFile_FD_Type *SLfile_create_fd (char *, int);extern void SLfile_free_fd (SLFile_FD_Type *);extern int SLfile_push_fd (SLFile_FD_Type *);extern int SLfile_pop_fd (SLFile_FD_Type **);extern int SLfile_get_fd (SLFile_FD_Type *, int *);extern SLFile_FD_Type *SLfile_dup_fd (SLFile_FD_Type *f0);extern int SLang_init_posix_io (void);typedef double (*SLang_To_Double_Fun_Type)(VOID_STAR);extern SLang_To_Double_Fun_Type SLarith_get_to_double_fun (SLtype, unsigned int *);extern int SLang_set_argc_argv (int, char **);/*}}}*//*{{{ SLang getkey interface Functions */#ifdef REAL_UNIX_SYSTEMextern int SLang_TT_Baud_Rate;extern int SLang_TT_Read_FD;#endifextern int SLang_init_tty (int, int, int);/* Initializes the tty for single character input.  If the first parameter *p1 * is in the range 0-255, it will be used for the abort character; * otherwise, (unix only) if it is -1, the abort character will be the one * used by the terminal.  If the second parameter p2 is non-zero, flow * control is enabled.  If the last parmeter p3 is zero, output processing * is NOT turned on.  A value of zero is required for the screen management * routines. Returns 0 upon success. In addition, if SLang_TT_Baud_Rate == * 0 when this function is called, SLang will attempt to determine the * terminals baud rate.  As far as the SLang library is concerned, if * SLang_TT_Baud_Rate is less than or equal to zero, the baud rate is * effectively infinite. */extern void SLang_reset_tty (void);/* Resets tty to what it was prior to a call to SLang_init_tty */#ifdef REAL_UNIX_SYSTEMextern void SLtty_set_suspend_state (int);   /* If non-zero argument, terminal driver will be told to react to the    * suspend character.  If 0, it will not.    */extern int (*SLang_getkey_intr_hook) (void);#endif#define SLANG_GETKEY_ERROR 0xFFFFextern unsigned int SLang_getkey (void);/* reads a single key from the tty.  If the read fails,  0xFFFF is returned. */#ifdef IBMPC_SYSTEMextern int SLgetkey_map_to_ansi (int);#endifextern int SLang_ungetkey_string (unsigned char *, unsigned int);extern int SLang_buffer_keystring (unsigned char *, unsigned int);extern int SLang_ungetkey (unsigned char);extern void SLang_flush_input (void);extern int SLang_input_pending (int);extern int SLang_Abort_Char;/* The value of the character (0-255) used to trigger SIGINT */extern int SLang_Ignore_User_Abort;/* If non-zero, pressing the abort character will not result in USER_BREAK * SLang_Error. */extern int SLang_set_abort_signal (void (*)(int));/* If SIGINT is generated, the function p1 will be called.  If p1 is NULL * the SLang_default signal handler is called.  This sets SLang_Error to * USER_BREAK.  I suspect most users will simply want to pass NULL. */extern unsigned int SLang_Input_Buffer_Len;extern volatile int SLKeyBoard_Quit;#ifdef VMS/* If this function returns -1, ^Y will be added to input buffer. */extern int (*SLtty_VMS_Ctrl_Y_Hook) (void);#endif/*}}}*//*{{{ SLang Keymap routines */typedef struct SLKeymap_Function_Type{   char *name;   int (*f)(void);}SLKeymap_Function_Type;#define SLANG_MAX_KEYMAP_KEY_SEQ	14typedef struct SLang_Key_Type{   struct SLang_Key_Type *next;   union     {	char *s;	FVOID_STAR f;	unsigned int keysym;     }     f;   unsigned char type;	       /* type of function */#define SLKEY_F_INTERPRET	0x01#define SLKEY_F_INTRINSIC	0x02#define SLKEY_F_KEYSYM		0x03   unsigned char str[SLANG_MAX_KEYMAP_KEY_SEQ + 1];/* key sequence */}SLang_Key_Type;typedef struct SLKeyMap_List_Type{   char *name;			       /* hashed string */   SLang_Key_Type *keymap;   SLKeymap_Function_Type *functions;  /* intrinsic functions */}SLKeyMap_List_Type;/* This is arbitrary but I have got to start somewhere */#define SLANG_MAX_KEYMAPS 30extern SLKeyMap_List_Type SLKeyMap_List[SLANG_MAX_KEYMAPS];extern char *SLang_process_keystring(char *);extern int SLkm_define_key (char *, FVOID_STAR, SLKeyMap_List_Type *);extern int SLang_define_key(char *, char *, SLKeyMap_List_Type *);/* Like define_key1 except that p2 is a string that is to be associated with * a function in the functions field of p3. */extern int SLkm_define_keysym (char *, unsigned int, SLKeyMap_List_Type *);extern void SLang_undefine_key(char *, SLKeyMap_List_Type *);extern SLKeyMap_List_Type *SLang_create_keymap(char *, SLKeyMap_List_Type *);/* create and returns a pointer to a new keymap named p1 created by copying * keymap p2.  If p2 is NULL, it is up to the calling routine to initialize * the keymap. */extern char *SLang_make_keystring(unsigned char *);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -