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

📄 slang.h

📁 MC Linux/Unix 终端下文件管理器
💻 H
📖 第 1 页 / 共 5 页
字号:
/* This function uses SLang_getkey and assumes that what ever initialization * is required for SLang_getkey has been performed.  If you do not want  * SLang_getkey to be used, then specify another function via * SLkp_set_getkey_function. */extern int SLkp_getkey (void);/*}}}*//*{{{ SLang Scroll Interface */typedef struct _SLscroll_Type{   struct _SLscroll_Type *next;   struct _SLscroll_Type *prev;   unsigned int flags;}SLscroll_Type;typedef struct{   unsigned int flags;   SLscroll_Type *top_window_line;   /* list element at top of window */   SLscroll_Type *bot_window_line;   /* list element at bottom of window */   SLscroll_Type *current_line;    /* current list element */   SLscroll_Type *lines;	       /* first list element */   unsigned int nrows;		       /* number of rows in window */   unsigned int hidden_mask;	       /* applied to flags in SLscroll_Type */   unsigned int line_num;	       /* current line number (visible) */   unsigned int num_lines;	       /* total number of lines (visible) */   unsigned int window_row;	       /* row of current_line in window */   unsigned int border;		       /* number of rows that form scroll border */   int cannot_scroll;		       /* should window scroll or recenter */}SLscroll_Window_Type;extern int SLscroll_find_top (SLscroll_Window_Type *);extern int SLscroll_find_line_num (SLscroll_Window_Type *);extern unsigned int SLscroll_next_n (SLscroll_Window_Type *, unsigned int);extern unsigned int SLscroll_prev_n (SLscroll_Window_Type *, unsigned int);extern int SLscroll_pageup (SLscroll_Window_Type *);extern int SLscroll_pagedown (SLscroll_Window_Type *);/*}}}*//*{{{ Signal Routines */typedef void SLSig_Fun_Type (int);extern SLSig_Fun_Type *SLsignal (int, SLSig_Fun_Type *);extern SLSig_Fun_Type *SLsignal_intr (int, SLSig_Fun_Type *);extern int SLsig_block_signals (void);extern int SLsig_unblock_signals (void);extern int SLsystem (char *);extern char *SLerrno_strerror (int);extern int SLerrno_set_errno (int);/*}}}*//*{{{ Interpreter Macro Definitions *//* The definitions here are for objects that may be on the run-time stack. * They are actually sub_types of literal and data main_types.  The actual * numbers are historical. */#define SLANG_UNDEFINED_TYPE	0x00   /* MUST be 0 */#define SLANG_VOID_TYPE		0x01   /* also matches ANY type */#define SLANG_INT_TYPE 		0x02#define SLANG_DOUBLE_TYPE	0x03#define SLANG_CHAR_TYPE		0x04#define SLANG_INTP_TYPE		0x05/* An object of SLANG_INTP_TYPE should never really occur on the stack.  Rather, * the integer to which it refers will be there instead.  It is defined here * because it is a valid type for MAKE_VARIABLE. */#define SLANG_REF_TYPE		0x06/* SLANG_REF_TYPE refers to an object on the stack that is a pointer (reference) * to some other object. */#define SLANG_COMPLEX_TYPE	0x07#define SLANG_NULL_TYPE		0x08#define SLANG_UCHAR_TYPE	0x09#define SLANG_SHORT_TYPE	0x0A#define SLANG_USHORT_TYPE	0x0B#define SLANG_UINT_TYPE		0x0C#define SLANG_LONG_TYPE		0x0D#define SLANG_ULONG_TYPE	0x0E#define SLANG_STRING_TYPE	0x0F#define SLANG_FLOAT_TYPE	0x10#define SLANG_STRUCT_TYPE	0x11#define SLANG_ISTRUCT_TYPE 	0x12#define SLANG_ARRAY_TYPE	0x20#define SLANG_DATATYPE_TYPE	0x21#define SLANG_FILE_PTR_TYPE	0x22#define SLANG_ASSOC_TYPE	0x23#define SLANG_ANY_TYPE		0x24#define SLANG_BSTRING_TYPE	0x25#define SLANG_FILE_FD_TYPE	0x26/* Compatibility */#ifdef FLOAT_TYPE# undef FLOAT_TYPE#endif#define VOID_TYPE SLANG_VOID_TYPE#define INT_TYPE SLANG_INT_TYPE#define INTP_TYPE SLANG_INTP_TYPE#define FLOAT_TYPE SLANG_DOUBLE_TYPE#define ARRAY_TYPE SLANG_ARRAY_TYPE#define CHAR_TYPE SLANG_CHAR_TYPE#define STRING_TYPE SLANG_STRING_TYPE/* I am reserving values greater than or equal to 128 for user applications. * The first 127 are reserved for S-Lang. *//* Binary and Unary Subtypes *//* Since the application can define new types and can overload the binary * and unary operators, these definitions must be present in this file. * The current implementation assumes both unary and binary are distinct. */#define SLANG_PLUS		0x01#define SLANG_MINUS		0x02#define SLANG_TIMES		0x03#define SLANG_DIVIDE		0x04#define SLANG_EQ		0x05#define SLANG_NE		0x06#define SLANG_GT		0x07#define SLANG_GE		0x08#define SLANG_LT		0x09#define SLANG_LE		0x0A#define SLANG_POW		0x0B#define SLANG_OR		0x0C#define SLANG_AND		0x0D#define SLANG_BAND		0x0E#define SLANG_BOR		0x0F#define SLANG_BXOR		0x10#define SLANG_SHL		0x11#define SLANG_SHR		0x12#define SLANG_MOD		0x13/* UNARY subtypes  (may be overloaded) */#define SLANG_PLUSPLUS		0x20#define SLANG_MINUSMINUS	0x21#define SLANG_ABS		0x22#define SLANG_SIGN		0x23#define SLANG_SQR		0x24#define SLANG_MUL2		0x25#define SLANG_CHS		0x26#define SLANG_NOT		0x27#define SLANG_BNOT		0x28extern char *SLang_Error_Message;int SLadd_intrinsic_variable (char *, VOID_STAR, unsigned char, int);int SLadd_intrinsic_function (char *, FVOID_STAR, unsigned char, unsigned int,...);int SLns_add_intrinsic_variable (SLang_NameSpace_Type *, char *, VOID_STAR, unsigned char, int);int SLns_add_intrinsic_function (SLang_NameSpace_Type *, char *, FVOID_STAR, unsigned char, unsigned int,...);#define MAKE_INTRINSIC_N(n,f,out,in,a1,a2,a3,a4,a5,a6,a7) \    {(n), NULL, SLANG_INTRINSIC, (FVOID_STAR) (f), \      {a1,a2,a3,a4,a5,a6,a7}, (in), (out)}#define MAKE_INTRINSIC_7(n,f,out,a1,a2,a3,a4,a5,a6,a7) \    MAKE_INTRINSIC_N(n,f,out,7,a1,a2,a3,a4,a5,a6,a7)#define MAKE_INTRINSIC_6(n,f,out,a1,a2,a3,a4,a5,a6) \    MAKE_INTRINSIC_N(n,f,out,6,a1,a2,a3,a4,a5,a6,0)#define MAKE_INTRINSIC_5(n,f,out,a1,a2,a3,a4,a5) \    MAKE_INTRINSIC_N(n,f,out,5,a1,a2,a3,a4,a5,0,0)#define MAKE_INTRINSIC_4(n,f,out,a1,a2,a3,a4) \    MAKE_INTRINSIC_N(n,f,out,4,a1,a2,a3,a4,0,0,0)#define MAKE_INTRINSIC_3(n,f,out,a1,a2,a3) \    MAKE_INTRINSIC_N(n,f,out,3,a1,a2,a3,0,0,0,0)#define MAKE_INTRINSIC_2(n,f,out,a1,a2) \    MAKE_INTRINSIC_N(n,f,out,2,a1,a2,0,0,0,0,0)#define MAKE_INTRINSIC_1(n,f,out,a1) \    MAKE_INTRINSIC_N(n,f,out,1,a1,0,0,0,0,0,0)#define MAKE_INTRINSIC_0(n,f,out) \    MAKE_INTRINSIC_N(n,f,out,0,0,0,0,0,0,0,0)#define MAKE_INTRINSIC_S(n,f,r) \   MAKE_INTRINSIC_1(n,f,r,SLANG_STRING_TYPE)#define MAKE_INTRINSIC_I(n,f,r) \   MAKE_INTRINSIC_1(n,f,r,SLANG_INT_TYPE)#define MAKE_INTRINSIC_SS(n,f,r) \   MAKE_INTRINSIC_2(n,f,r,SLANG_STRING_TYPE,SLANG_STRING_TYPE)#define MAKE_INTRINSIC_SI(n,f,r) \   MAKE_INTRINSIC_2(n,f,r,SLANG_STRING_TYPE,SLANG_INT_TYPE)#define MAKE_INTRINSIC_IS(n,f,r) \   MAKE_INTRINSIC_2(n,f,r,SLANG_INT_TYPE,SLANG_STRING_TYPE)#define MAKE_INTRINSIC_II(n,f,r) \   MAKE_INTRINSIC_2(n,f,r,SLANG_INT_TYPE,SLANG_INT_TYPE)#define MAKE_INTRINSIC_SSS(n,f,r) \   MAKE_INTRINSIC_3(n,f,r,SLANG_STRING_TYPE,SLANG_STRING_TYPE,SLANG_STRING_TYPE)#define MAKE_INTRINSIC_SSI(n,f,r) \   MAKE_INTRINSIC_3(n,f,r,SLANG_STRING_TYPE,SLANG_STRING_TYPE,SLANG_INT_TYPE)#define MAKE_INTRINSIC_SIS(n,f,r) \   MAKE_INTRINSIC_3(n,f,r,SLANG_STRING_TYPE,SLANG_INT_TYPE,SLANG_STRING_TYPE)#define MAKE_INTRINSIC_SII(n,f,r) \   MAKE_INTRINSIC_3(n,f,r,SLANG_STRING_TYPE,SLANG_INT_TYPE,SLANG_INT_TYPE)#define MAKE_INTRINSIC_ISS(n,f,r) \   MAKE_INTRINSIC_3(n,f,r,SLANG_INT_TYPE,SLANG_STRING_TYPE,SLANG_STRING_TYPE)#define MAKE_INTRINSIC_ISI(n,f,r) \   MAKE_INTRINSIC_3(n,f,r,SLANG_INT_TYPE,SLANG_STRING_TYPE,SLANG_INT_TYPE)#define MAKE_INTRINSIC_IIS(n,f,r) \   MAKE_INTRINSIC_3(n,f,r,SLANG_INT_TYPE,SLANG_INT_TYPE,SLANG_STRING_TYPE)#define MAKE_INTRINSIC_III(n,f,r) \   MAKE_INTRINSIC_3(n,f,r,SLANG_INT_TYPE,SLANG_INT_TYPE,SLANG_INT_TYPE)#define MAKE_INTRINSIC(n, f, out, in) \    MAKE_INTRINSIC_N(n,f,out,in,0,0,0,0,0,0,0)#define MAKE_VARIABLE(n, v, t, r)     \    {n, NULL, SLANG_IVARIABLE + (r), (VOID_STAR)(v), (t)}#define MAKE_APP_UNARY(n,op) \    {(n), NULL, SLANG_APP_UNARY, (op)}#define MAKE_MATH_UNARY(n,op) \    {(n), NULL, SLANG_MATH_UNARY, (op)}#define MAKE_ICONSTANT(n,val) \    {(n),NULL, SLANG_ICONSTANT, (val)}#define MAKE_DCONSTANT(n,val) \    {(n),NULL, SLANG_DCONSTANT, (val)}#ifndef offsetof# define offsetof(T,F) ((unsigned int)((char *)&((T *)0L)->F - (char *)0L))#endif#define MAKE_ISTRUCT_FIELD(s,f,n,t,r) {(n), offsetof(s,f), (t), (r)}#define SLANG_END_TABLE {NULL}#define SLANG_END_INTRIN_FUN_TABLE MAKE_INTRINSIC_0(NULL,NULL,0)#define SLANG_END_DCONST_TABLE MAKE_DCONSTANT(NULL,0)#define SLANG_END_MATH_UNARY_TABLE MAKE_MATH_UNARY(NULL,0)#define SLANG_END_INTRIN_VAR_TABLE MAKE_VARIABLE(NULL,NULL,0,0)#define SLANG_END_ICONST_TABLE MAKE_ICONSTANT(NULL,0)#define SLANG_END_ISTRUCT_TABLE {NULL, 0, 0, 0}   /*}}}*//*{{{ Upper/Lowercase Functions */extern void SLang_define_case(int *, int *);extern void SLang_init_case_tables (void);extern unsigned char _SLChg_UCase_Lut[256];extern unsigned char _SLChg_LCase_Lut[256];#define UPPER_CASE(x) (_SLChg_UCase_Lut[(unsigned char) (x)])#define LOWER_CASE(x) (_SLChg_LCase_Lut[(unsigned char) (x)])#define CHANGE_CASE(x) (((x) == _SLChg_LCase_Lut[(unsigned char) (x)]) ?\			_SLChg_UCase_Lut[(unsigned char) (x)] : _SLChg_LCase_Lut[(unsigned char) (x)])/*}}}*//*{{{ Regular Expression Interface */typedef struct{   /* These must be set by calling routine. */   unsigned char *pat;		       /* regular expression pattern */   unsigned char *buf;		       /* buffer for compiled regexp */   unsigned int buf_len;	       /* length of buffer */   int case_sensitive;		       /* 1 if match is case sensitive  */   /* The rest are set by SLang_regexp_compile */   int must_match;		       /* 1 if line must contain substring */   int must_match_bol;		       /* true if it must match beginning of line */   unsigned char must_match_str[16];   /* 15 char null term substring */   int osearch;			       /* 1 if ordinary search suffices */   unsigned int min_length;	       /* minimum length the match must be */   int beg_matches[10];		       /* offset of start of \( */   unsigned int end_matches[10];       /* length of nth submatch					* Note that the entire match corresponds					* to \0					*/   int offset;			       /* offset to be added to beg_matches */   int reserved[10];} SLRegexp_Type;extern unsigned char *SLang_regexp_match(unsigned char *,					 unsigned int,					 SLRegexp_Type *);/* Returns 0 upon success.  If failure, the offset into the * pattern is returned (start = 1). */extern int SLang_regexp_compile (SLRegexp_Type *);extern char *SLregexp_quote_string (char *, char *, unsigned int);/*}}}*//*{{{ SLang Command Interface */struct _SLcmd_Cmd_Type; /* Pre-declaration is needed below */typedef struct{   struct _SLcmd_Cmd_Type *table;   int argc;   /* Version 2.0 needs to use a union!! */   char **string_args;   int *int_args;   double *double_args;   unsigned char *arg_type;   unsigned long reserved[4];} SLcmd_Cmd_Table_Type;typedef struct _SLcmd_Cmd_Type{   int (*cmdfun)(int, SLcmd_Cmd_Table_Type *);   char *cmd;   char *arg_type;} SLcmd_Cmd_Type;extern int SLcmd_execute_string (char *, SLcmd_Cmd_Table_Type *);/*}}}*//*{{{ SLang Search Interface */typedef struct{   int cs;			       /* case sensitive */   unsigned char key[256];   int ind[256];   int key_len;   int dir;} SLsearch_Type;extern int SLsearch_init (char *, int, int, SLsearch_Type *);/* This routine must first be called before any search can take place. * The second parameter specifies the direction of the search: greater than * zero for a forwrd search and less than zero for a backward search.  The * third parameter specifies whether the search is case sensitive or not. * The last parameter is a pointer to a structure that is filled by this * function and it is this structure that must be passed to SLsearch. */extern unsigned char *SLsearch (unsigned char *, unsigned char *, SLsearch_Type *);/* To use this routine, you must first call 'SLsearch_init'.  Then the first * two parameters p1 and p2 serve to define the region over which the search * is to take place.  The third parameter is the structure that was previously * initialized by SLsearch_init. * * The routine returns a pointer to the match if found otherwise it returns * NULL. *//*}}}*//*{{{ SLang Pathname Interface *//* These function return pointers to the original space */extern char *SLpath_basename (char *);extern char *SLpath_extname (char *);extern int SLpath_is_absolute_path (char *);/* These return malloced strings--- NOT slstrings */extern char *SLpath_dircat (char *, char *);extern char *SLpath_find_file_in_path (char *, char *);extern char *SLpath_dirname (char *);extern int SLpath_file_exists (char *);extern char *SLpath_pathname_sans_extname (char *);/*}}}*/extern int SLang_set_module_load_path (char *);#define SLANG_MODULE(name) \   extern int init_##name##_module_ns (char *); \   extern void deinit_##name##_module (void)#if 0{#endif#ifdef __cplusplus}#endif#endif  /* _DAVIS_SLANG_H_ */

⌨️ 快捷键说明

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