} *b = 0; return SLmake_string ((char *)buf); } static unsigned int bstrlen_cmd (SLang_BString_Type *b) { return b->len; } static SLang_Intrin_Fun_Type BString_Table [] = /*{{{*/ { MAKE_INTRINSIC_1("bstrlen", bstrlen_cmd, SLANG_UINT_TYPE, SLANG_BSTRING_TYPE), MAKE_INTRINSIC_0("pack", _SLpack, SLANG_VOID_TYPE), MAKE_INTRINSIC_2("unpack", _SLunpack, SLANG_VOID_TYPE, SLANG_STRING_TYPE, SLANG_BSTRING_TYPE), MAKE_INTRINSIC_1("pad_pack_format", _SLpack_pad_format, SLANG_VOID_TYPE, SLANG_STRING_TYPE), MAKE_INTRINSIC_1("sizeof_pack", _SLpack_compute_size, SLANG_UINT_TYPE, SLANG_STRING_TYPE), SLANG_END_INTRIN_FUN_TABLE }; int _SLang_init_bstring (void) { SLang_Class_Type *cl; if (NULL == (cl = SLclass_allocate_class ("BString_Type"))) return -1; (void) SLclass_set_destroy_function (cl, bstring_destroy); (void) SLclass_set_push_function (cl, bstring_push); (void) SLclass_set_string_function (cl, bstring_string);
MAKE_ICONSTANT ("ONIG_OPTION_CAPTURE_GROUP", ONIG_OPTION_CAPTURE_GROUP), SLANG_END_ICONST_TABLE }; #define DUMMY_ONIG_TYPE 0 #define O DUMMY_ONIG_TYPE #define I SLANG_INT_TYPE #define V SLANG_VOID_TYPE #define S SLANG_STRING_TYPE static SLang_Intrin_Fun_Type Onig_Intrinsics [] = { MAKE_INTRINSIC_0("onig_version", do_onig_version, S), MAKE_INTRINSIC_0("onig_new", do_onig_new, V), MAKE_INTRINSIC_0("onig_search", do_onig_search, I), MAKE_INTRINSIC_2("onig_nth_match", nth_match, V, O, I), MAKE_INTRINSIC_3("onig_nth_substr", nth_substr, V, O, S, I), MAKE_INTRINSIC_0("onig_set_warn_func", set_warn_func, V), MAKE_INTRINSIC_0("onig_set_verb_warn_func", set_verb_warn_func, V), MAKE_INTRINSIC_0("onig_get_encodings", get_encodings, V), MAKE_INTRINSIC_0("onig_get_syntaxes", get_syntaxes, V), /* MAKE_INTRINSIC_1("slang_to_pcre", slang_to_pcre, V, S), */ SLANG_END_INTRIN_FUN_TABLE }; #undef V #undef S #undef I #undef O static void destroy_onig (SLtype type, VOID_STAR f) {
if (bstr != NULL) (void) SLang_push_bstring(bstr); SLbstring_free (bstr); /* drop */ error: SLfree(buf); } #define DUMMY_ICONV_TYPE 255 #define P DUMMY_ICONV_TYPE #define V SLANG_VOID_TYPE #define S SLANG_STRING_TYPE #define B SLANG_BSTRING_TYPE static SLang_Intrin_Fun_Type ICONV_Intrinsics [] = { MAKE_INTRINSIC_2("iconv_open", _iconv_open, V, S, S), MAKE_INTRINSIC_1("iconv_close", _iconv_close, V, P), MAKE_INTRINSIC_1("iconv_reset", _iconv_reset, V, P), MAKE_INTRINSIC_1("iconv_reset_shift", _iconv_reset_shift, V, P), MAKE_INTRINSIC_2("iconv", _iconv, V, P, B), SLANG_END_INTRIN_FUN_TABLE }; #undef B #undef S #undef V #undef P static int register_iconv_type (void) { SLang_Class_Type *cl;
static int fcntl_getfl (SLFile_FD_Type *f) { return do_fcntl_2 (f, F_GETFL); } static int fcntl_setfl (SLFile_FD_Type *f, int *flags) { return do_fcntl_3_int (f, F_SETFL, *flags); } #define F SLANG_FILE_FD_TYPE #define I SLANG_INT_TYPE static SLang_Intrin_Fun_Type Fcntl_Intrinsics [] = { MAKE_INTRINSIC_1("fcntl_getfd", fcntl_getfd, I, F), MAKE_INTRINSIC_2("fcntl_setfd", fcntl_setfd, I, F, I), MAKE_INTRINSIC_1("fcntl_getfl", fcntl_getfl, I, F), MAKE_INTRINSIC_2("fcntl_setfl", fcntl_setfl, I, F, I), SLANG_END_INTRIN_FUN_TABLE }; #undef I #undef F static SLang_IConstant_Type Fcntl_Consts [] = { MAKE_ICONSTANT("FD_CLOEXEC", FD_CLOEXEC), SLANG_END_ICONST_TABLE }; int init_fcntl_module_ns (char *ns_name)
{ long q; if (-1 == SLang_get_long_qualifier (name, &q, *def)) return; SLang_push_long (q); } #include "assoc.c" #include "list.c" static void fake_import (char *); static SLang_Intrin_Fun_Type Intrinsics [] = { MAKE_INTRINSIC_S("fake_import", fake_import, VOID_TYPE), MAKE_INTRINSIC_I("exit", c_exit, VOID_TYPE), MAKE_INTRINSIC_2("check_intrin_int_qualifier", check_intrin_int_qualifier, VOID_TYPE, SLANG_STRING_TYPE, SLANG_INT_TYPE), MAKE_INTRINSIC_2("check_intrin_long_qualifier", check_intrin_long_qualifier, VOID_TYPE, SLANG_STRING_TYPE, SLANG_LONG_TYPE), MAKE_INTRINSIC_2("check_intrin_double_qualifier", check_intrin_double_qualifier, VOID_TYPE, SLANG_STRING_TYPE, SLANG_DOUBLE_TYPE), MAKE_INTRINSIC_2("check_intrin_string_qualifier", check_intrin_string_qualifier, VOID_TYPE, SLANG_STRING_TYPE, SLANG_STRING_TYPE), MAKE_INTRINSIC_1("test_char_return", test_char_return, SLANG_CHAR_TYPE, SLANG_CHAR_TYPE), MAKE_INTRINSIC_1("test_short_return", test_short_return, SLANG_SHORT_TYPE, SLANG_SHORT_TYPE), MAKE_INTRINSIC_1("test_int_return", test_int_return, SLANG_INT_TYPE, SLANG_INT_TYPE), MAKE_INTRINSIC_1("test_long_return", test_long_return, SLANG_LONG_TYPE, SLANG_LONG_TYPE), /* MAKE_INTRINSIC_1("test_float_return", test_float_return, SLANG_FLOAT_TYPE, SLANG_FLOAT_TYPE), */ #if SLANG_HAS_FLOAT MAKE_INTRINSIC_1("test_double_return", test_double_return, SLANG_DOUBLE_TYPE, SLANG_DOUBLE_TYPE), #endif MAKE_INTRINSIC_0("test_pop_mmt", test_pop_mmt, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("get_c_struct", get_c_struct, VOID_TYPE), MAKE_INTRINSIC_0("set_c_struct", set_c_struct, VOID_TYPE), MAKE_INTRINSIC_1("get_c_struct_via_ref", get_c_struct_via_ref, VOID_TYPE, SLANG_REF_TYPE),
/*{{{ intrinsics */ #define V SLANG_VOID_TYPE #define AI SLANG_ARRAY_INDEX_TYPE #define I SLANG_INT_TYPE #define U SLANG_UINT_TYPE #define F SLANG_FLOAT_TYPE #define D SLANG_DOUBLE_TYPE #define S SLANG_STRING_TYPE static SLang_Intrin_Fun_Type Math_Intrinsics [] = { MAKE_INTRINSIC_1("_make_1d_histogram", make_1d_histogram, V, I), MAKE_INTRINSIC_1("_make_2d_histogram", make_2d_histogram, V, I), MAKE_INTRINSIC_2("_fft1d", _fft1d, V, I, D), MAKE_INTRINSIC("_moment", moment, V, 0), MAKE_INTRINSIC("_median", median, V, 0), MAKE_INTRINSIC("_ks_difference", ks_difference, D, 0), MAKE_INTRINSIC_1("_ks_probability", ks_probability, D, D), MAKE_INTRINSIC_1("_seed_random", seed_random, V, SLANG_ULONG_TYPE), MAKE_INTRINSIC_1("_urand_array", urand_array, V, AI), MAKE_INTRINSIC_1("_grand_array", grand_array, V, AI), MAKE_INTRINSIC_2("_prand_array", prand_array, V, D, AI), MAKE_INTRINSIC("_prand_vec", prand_vec, V, 0), MAKE_INTRINSIC("lu_solve_intrin", lu_solve_intrin, V, 0), MAKE_INTRINSIC("svd_solve_intrin", svd_solve_intrin, V, 0), SLANG_END_INTRIN_FUN_TABLE }; #undef V
SLANG_END_INTRIN_VAR_TABLE }; #define V SLANG_VOID_TYPE #define I SLANG_INT_TYPE #define U SLANG_UINT_TYPE #define F SLANG_FLOAT_TYPE #define D SLANG_DOUBLE_TYPE #define S SLANG_STRING_TYPE static SLang_Intrin_Fun_Type Misc_Intrinsics [] = { MAKE_INTRINSIC("print_array", print_array, V, 0), MAKE_INTRINSIC_1("_isis_set_pager", isis_set_pager, V, S), MAKE_INTRINSIC("_isis_get_pager", isis_get_pager, V, 0), MAKE_INTRINSIC_2("_find_file_in_path", find_file_in_path, V, S, S), MAKE_INTRINSIC("_readcol", _readcol, V, 0), MAKE_INTRINSIC_I("_isis_set_errno", set_errno, V), SLANG_END_INTRIN_FUN_TABLE }; static char *Pivs = ISIS_VERSION_STRING; static char *Install_Prefix = INSTALL_PREFIX ; static char *Install_Prefix_Input = INSTALL_PREFIX_INPUT ; static SLang_Intrin_Var_Type Global_Intrin_Vars [] = { MAKE_VARIABLE("_isis_version_string", &Pivs, SLANG_STRING_TYPE, 1), MAKE_VARIABLE("_isis_version", &Isis_Version, SLANG_UINT_TYPE, 1), MAKE_VARIABLE("_isis_srcdir", &Isis_Srcdir, SLANG_STRING_TYPE, 1), MAKE_VARIABLE("_isis_install_prefix", &Install_Prefix, SLANG_STRING_TYPE, 1),
#define V SLANG_VOID_TYPE #define F SLANG_FILE_FD_TYPE #define B SLANG_BSTRING_TYPE #define R SLANG_REF_TYPE #define U SLANG_UINT_TYPE #define S SLANG_STRING_TYPE #define L SLANG_LONG_TYPE static SLang_Intrin_Fun_Type Fd_Name_Table [] = { MAKE_INTRINSIC_0("fileno", posix_fileno, V), MAKE_INTRINSIC_0("_fileno", posix_fileno_int, I), MAKE_INTRINSIC_0("isatty", posix_isatty, I), MAKE_INTRINSIC_0("open", posix_open, V), MAKE_INTRINSIC_3("read", posix_read, V, F, R, U), MAKE_INTRINSIC_3("lseek", posix_lseek, SLANG_C_OFF_T_TYPE, F, SLANG_C_OFF_T_TYPE, I), MAKE_INTRINSIC_2("fdopen", posix_fdopen, V, F, S), MAKE_INTRINSIC_2("write", posix_write, V, F, B), MAKE_INTRINSIC_1("dup_fd", posix_dup, V, F), MAKE_INTRINSIC_2("dup2_fd", posix_dup2, I, F, I), MAKE_INTRINSIC_1("close", posix_close, I, F), MAKE_INTRINSIC_1("_close", posix_close_fd, I, I), #if defined(TTYNAME_R) MAKE_INTRINSIC_0("ttyname", posix_ttyname, V), #endif SLANG_END_INTRIN_FUN_TABLE }; #undef I #undef V #undef F #undef B #undef R
{ getset_sockopt (0); } #define I SLANG_INT_TYPE #define V SLANG_VOID_TYPE #define F SLANG_FILE_FD_TYPE static SLang_Intrin_Fun_Type Module_Intrinsics [] = { MAKE_INTRINSIC_3("socket", socket_intrin, V, I, I, I), #ifdef HAVE_SOCKETPAIR MAKE_INTRINSIC_3("socketpair", socketpair_intrin, V, I, I, I), #endif MAKE_INTRINSIC_0("connect", connect_intrin, V), MAKE_INTRINSIC_0("bind", bind_intrin, V), MAKE_INTRINSIC_2("listen", listen_intrin, V, F, I), MAKE_INTRINSIC_0("accept", accept_intrin, V), MAKE_INTRINSIC_0("getsockopt", getsockopt_intrin, V), MAKE_INTRINSIC_0("setsockopt", setsockopt_intrin, V), SLANG_END_INTRIN_FUN_TABLE }; #undef F #undef V #undef I static SLang_IConstant_Type Module_IConstants [] = { #ifdef SOCK_STREAM MAKE_ICONSTANT("SOCK_STREAM", SOCK_STREAM), #endif #ifdef SOCK_DGRAM
SLfile_free_fd (f1); SLfile_free_fd (f0); } static SLang_IConstant_Type Module_IConstants [] = { MAKE_ICONSTANT("WNOHANG", WNOHANG), MAKE_ICONSTANT("WUNTRACED", WUNTRACED), MAKE_ICONSTANT("WCONTINUED", WCONTINUED), SLANG_END_ICONST_TABLE }; static SLang_Intrin_Fun_Type Module_Intrinsics [] = { MAKE_INTRINSIC_0("fork", fork_intrinsic, SLANG_INT_TYPE), MAKE_INTRINSIC_2("waitpid", waitpid_intrinsic, SLANG_VOID_TYPE, SLANG_INT_TYPE, SLANG_INT_TYPE), MAKE_INTRINSIC_0("execv", execv_intrin, SLANG_INT_TYPE), MAKE_INTRINSIC_0("execvp", execvp_intrin, SLANG_INT_TYPE), MAKE_INTRINSIC_0("execve", execve_intrin, SLANG_INT_TYPE), MAKE_INTRINSIC_0("pipe", pipe_intrin, SLANG_VOID_TYPE), MAKE_INTRINSIC_1("_exit", _exit_intrin, SLANG_VOID_TYPE, SLANG_INT_TYPE), SLANG_END_INTRIN_FUN_TABLE }; int init_fork_module_ns (char *ns_name) { SLang_NameSpace_Type *ns = SLns_create_namespace (ns_name); if (ns == NULL) return -1; if ((-1 == SLns_add_intrin_fun_table (ns, Module_Intrinsics, NULL))
if (-1 == list_join_internal (list, l2)) { free_list (list); return; } (void) push_list (list, 1); /* will delete upon failure */ } #define L SLANG_LIST_TYPE #define I SLANG_INT_TYPE #define A SLANG_ARRAY_INDEX_TYPE static SLang_Intrin_Fun_Type Intrin_Table [] = { MAKE_INTRINSIC_2("list_delete", list_delete_elem, SLANG_VOID_TYPE, L, A), MAKE_INTRINSIC_1("list_reverse", list_reverse, SLANG_VOID_TYPE, L), MAKE_INTRINSIC_0("list_insert", list_insert_elem, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("list_append", list_append_elem, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("list_to_array", list_to_array, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("list_new", list_new, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("list_pop", list_pop, SLANG_VOID_TYPE), MAKE_INTRINSIC_2("list_concat", list_concat, SLANG_VOID_TYPE, L, L), MAKE_INTRINSIC_2("list_join", list_join, SLANG_VOID_TYPE, L, L), MAKE_INTRINSIC_1("__push_list", push_list_elements, SLANG_VOID_TYPE, L), MAKE_INTRINSIC_1("__pop_list", pop_as_list, SLANG_VOID_TYPE, I), SLANG_END_INTRIN_FUN_TABLE }; #undef L #undef I #undef A
} return 0; } #define DUMMY_TERMIOS_TYPE ((unsigned int)-1) #define T DUMMY_TERMIOS_TYPE #define F SLANG_FILE_FD_TYPE #define I SLANG_INT_TYPE #define V SLANG_VOID_TYPE #define U SLANG_UINT_TYPE static SLang_Intrin_Fun_Type Termios_Intrinsics [] = { MAKE_INTRINSIC_1("tcdrain", tcdrain_intrin, I, F), MAKE_INTRINSIC_2("tcflow", tcflow_intrin, I, F, I), MAKE_INTRINSIC_2("tcflush", tcflush_intrin, I, F, I), MAKE_INTRINSIC_1("tcgetpgrp", tcgetpgrp_intrin, I, F), MAKE_INTRINSIC_2("tcsetpgrp", tcsetpgrp_intrin, I, F, I), MAKE_INTRINSIC_2("tcsendbreak", tcsendbreak_intrin, I, F, I), MAKE_INTRINSIC_1("tcgetattr", tcgetattr_intrin, V, F), MAKE_INTRINSIC_3("tcsetattr", tcsetattr_intrin, I, F, I, T), MAKE_INTRINSIC_1("cfgetispeed", cfgetispeed_intrin, V, T), MAKE_INTRINSIC_1("cfgetospeed", cfgetospeed_intrin, V, T), MAKE_INTRINSIC_2("cfsetispeed", cfsetispeed_intrin, I, T, U), MAKE_INTRINSIC_2("cfsetospeed", cfsetospeed_intrin, I, T, U), MAKE_INTRINSIC_1("termios_get_oflag", termios_get_oflag, I, T), MAKE_INTRINSIC_1("termios_get_iflag", termios_get_iflag, I, T), MAKE_INTRINSIC_1("termios_get_cflag", termios_get_cflag, I, T), MAKE_INTRINSIC_1("termios_get_lflag", termios_get_lflag, I, T), MAKE_INTRINSIC_1("termios_get_cc", termios_get_cc, V, T),
if (e == NULL) return; _pSLang_free_slstring ((char *) e->key); SLang_free_object (&e->value); e->key = Deleted_Key; a->num_deleted++; } #define A SLANG_ASSOC_TYPE #define S SLANG_STRING_TYPE static SLang_Intrin_Fun_Type Assoc_Table [] = { MAKE_INTRINSIC_1("assoc_get_keys", assoc_get_keys, SLANG_VOID_TYPE, A), MAKE_INTRINSIC_1("assoc_get_values", assoc_get_values, SLANG_VOID_TYPE, A), MAKE_INTRINSIC_2("assoc_key_exists", assoc_key_exists, SLANG_INT_TYPE, A, S), MAKE_INTRINSIC_2("assoc_delete_key", assoc_delete_key, SLANG_VOID_TYPE, A, S), SLANG_END_INTRIN_FUN_TABLE }; #undef A #undef S static int assoc_length (SLtype type, VOID_STAR v, unsigned int *len) { SLang_Assoc_Array_Type *a; (void) type; a = (SLang_Assoc_Array_Type *) SLang_object_from_mmt (*(SLang_MMT_Type **)v); *len = a->num_occupied - a->num_deleted; return 0;
a++; b++; } if (b == bmax) return (a0 - astart); a = a0; b = b0; } return 0; } static SLang_Intrin_Fun_Type BString_Table [] = /*{{{*/ { MAKE_INTRINSIC_1("bstrlen", bstrlen_cmd, SLANG_UINT_TYPE, SLANG_BSTRING_TYPE), MAKE_INTRINSIC_2("count_byte_occurances", count_byte_occurrences, SLANG_UINT_TYPE, SLANG_BSTRING_TYPE, SLANG_UCHAR_TYPE), MAKE_INTRINSIC_2("count_byte_occurrences", count_byte_occurrences, SLANG_UINT_TYPE, SLANG_BSTRING_TYPE, SLANG_UCHAR_TYPE), MAKE_INTRINSIC_0("pack", _pSLpack, SLANG_VOID_TYPE), MAKE_INTRINSIC_2("unpack", _pSLunpack, SLANG_VOID_TYPE, SLANG_STRING_TYPE, SLANG_BSTRING_TYPE), MAKE_INTRINSIC_1("pad_pack_format", _pSLpack_pad_format, SLANG_VOID_TYPE, SLANG_STRING_TYPE), MAKE_INTRINSIC_1("sizeof_pack", _pSLpack_compute_size, SLANG_UINT_TYPE, SLANG_STRING_TYPE), MAKE_INTRINSIC_2("is_substrbytes", issubbytes, SLANG_INT_TYPE, SLANG_BSTRING_TYPE, SLANG_BSTRING_TYPE), SLANG_END_INTRIN_FUN_TABLE }; struct _pSLang_Foreach_Context_Type { SLang_BString_Type *bstr; unsigned char *s, *smax; /* pointers into string */ int using_chars; };
if (NULL == (c = obj->c)) { SLang_verror (SL_InvalidParm_Error, "Checksum object is invalid"); return; } if (NULL == (s = SLbstring_get_pointer (b, &len))) return; (void) c->accumulate (c, s, len); } #define DUMMY_CHKSUM_TYPE ((unsigned int)-1) static SLang_Intrin_Fun_Type Intrinsics [] = { MAKE_INTRINSIC_1 ("_chksum_new", chksum_new, SLANG_VOID_TYPE, SLANG_STRING_TYPE), MAKE_INTRINSIC_2 ("_chksum_accumulate", chksum_accumulate, SLANG_VOID_TYPE, DUMMY_CHKSUM_TYPE, SLANG_BSTRING_TYPE), MAKE_INTRINSIC_1 ("_chksum_close", chksum_close, SLANG_VOID_TYPE, DUMMY_CHKSUM_TYPE), SLANG_END_INTRIN_FUN_TABLE }; static void destroy_chksum_type (SLtype type, VOID_STAR ptr) { (void) type; chksum_free (*(Chksum_Object_Type **)ptr); } static int push_chksum_type (SLtype type, VOID_STAR ptr) { (void) type; return chksum_push (*(Chksum_Object_Type **)ptr); }
MAKE_INTRINSIC_I("_pgask", _pgask, V), MAKE_INTRINSIC_0("_pgaxis", _pgaxis, V), MAKE_INTRINSIC_7("_pgband", _pgband, I, I, I, D, D, R, R, R), MAKE_INTRINSIC_0("_pgbbuf", _pgbbuf, V), MAKE_INTRINSIC_I("_pgbin", _pgbin, V), MAKE_INTRINSIC_6("_pgbox", _pgbox, V, S, D, I, S, D, I), MAKE_INTRINSIC_3("_pgcirc", _pgcirc, V, D, D, D), MAKE_INTRINSIC_0("_pgclos", _pgclos, V), MAKE_INTRINSIC_1("_pgconb", _pgconb, V, D), MAKE_INTRINSIC_3("_pgconl", _pgconl, V, S, I, I), MAKE_INTRINSIC_0("_pgconf", _pgconf, V), MAKE_INTRINSIC_0("_pgcons", _pgcons, V), MAKE_INTRINSIC_1("_pgcont", _pgcont, V, I), /* MAKE_INTRINSIC_0("_pgconx", _pgconx, V), */ MAKE_INTRINSIC_2("_pgctab", _pgctab, V, D, D), MAKE_INTRINSIC_0("_pgcurs", _pgcurs, I), MAKE_INTRINSIC_2("_pgdraw", _pgdraw, V, D, D), MAKE_INTRINSIC_0("_pgebuf", _pgebuf, V), MAKE_INTRINSIC_0("_pgend", _pgend, V), MAKE_INTRINSIC_6("_pgenv", _pgenv, V, D,D,D,D,I,I), MAKE_INTRINSIC_0("_pgeras", _pgeras, V), MAKE_INTRINSIC_5("_pgerr1", _pgerr1, V, I, D, D, D, D), MAKE_INTRINSIC_1("_pgerrb", _pgerrb, V, D), MAKE_INTRINSIC_1("_pgerrx", _pgerrx, V, D), MAKE_INTRINSIC_1("_pgerry", _pgerry, V, D), MAKE_INTRINSIC_0("_pgetxt", _pgetxt, V), MAKE_INTRINSIC_0("_pggray", _pggray, V), MAKE_INTRINSIC_3("_pghi2d", _pghi2d, V, I, D, I), MAKE_INTRINSIC_4("_pghist", _pghist, V, D, D, I, I),