int init_socket_module_ns (char *ns_name) { SLang_NameSpace_Type *ns; if (SocketError == -1) { if (-1 == (SocketError = SLerr_new_exception (SL_RunTime_Error, "SocketError", "Socket Error"))) return -1; if (-1 == (SocketHerrnoError = SLerr_new_exception (SocketError, "SocketHError", "Socket h_errno Error"))) return -1; } if (Socket_Type_Id == -1) { (void) SLfile_create_clientdata_id (&Socket_Type_Id); } if (NULL == (ns = SLns_create_namespace (ns_name))) return -1; if ((-1 == SLns_add_intrin_fun_table (ns, Module_Intrinsics, NULL)) || (-1 == SLns_add_iconstant_table (ns, Module_IConstants, NULL))) return -1; if (-1 == SLns_add_intrinsic_variable(ns, "h_errno", (VOID_STAR)&Module_H_Errno, SLANG_INT_TYPE, 1)) return -1; return 0; }
int init_slsmg_module_ns (char *ns_name) { static int inited = 0; SLang_NameSpace_Type *ns = SLns_create_namespace (ns_name); if (ns == NULL) return -1; if ((-1 == SLns_add_intrin_fun_table (ns, Smg_Intrinsics, "__SLSMG__")) || (-1 == SLns_add_iconstant_table (ns, Smg_Constants, NULL))) return -1; if ((-1 == SLns_add_intrinsic_variable(ns, "SLsmg_Display_Eight_Bit", (VOID_STAR)&SLsmg_Display_Eight_Bit, SLANG_INT_TYPE, 0)) || (-1 == SLns_add_intrinsic_variable(ns, "SLsmg_Tab_Width", (VOID_STAR)&SLsmg_Tab_Width, SLANG_INT_TYPE, 0)) || (-1 == SLns_add_intrinsic_variable(ns, "SLsmg_Newline_Behavior", (VOID_STAR)&SLsmg_Newline_Behavior, SLANG_INT_TYPE, 0)) || (-1 == SLns_add_intrinsic_variable(ns, "SLsmg_Backspace_Moves", (VOID_STAR)&SLsmg_Backspace_Moves, SLANG_INT_TYPE, 0)) || (-1 == SLns_add_intrinsic_variable(ns, "SLsmg_Screen_Rows", (VOID_STAR)&SLtt_Screen_Rows, SLANG_INT_TYPE, 0)) || (-1 == SLns_add_intrinsic_variable(ns, "SLsmg_Screen_Cols", (VOID_STAR)&SLtt_Screen_Cols, SLANG_INT_TYPE, 0))) return -1; if (inited == 0) { inited = 1; SLtt_get_terminfo (); } Smg_Initialized = 0; return 0; }
int init_slsmg_module_ns (char *ns_name) { SLang_NameSpace_Type *ns; static int inited = 0; if (inited == 0) { #if defined(VMS) || defined(REAL_UNIX_SYSTEM) int status; char *term = getenv ("TERM"); if (term == NULL) { SLang_verror (SL_Application_Error, "The TERM environment variable is not set"); return -1; } status = SLtt_initialize (term); if (status == -1) { SLang_verror (SL_RunTime_Error, "Cannot deduce properties for '%s' terminal", term); return -1; } if (status < 0) { SLang_verror (SL_RunTime_Error, "The terminal '%s' lacks sufficient capabilities for controlling it", term); return -1; } #else SLtt_get_terminfo (); #endif inited = 1; } ns = SLns_create_namespace (ns_name); if (ns == NULL) return -1; if ((-1 == SLns_add_intrin_fun_table (ns, Smg_Intrinsics, "__SLSMG__")) || (-1 == SLns_add_iconstant_table (ns, Smg_Constants, NULL))) return -1; if ((-1 == SLns_add_intrinsic_variable(ns, "SLsmg_Display_Eight_Bit", (VOID_STAR)&SLsmg_Display_Eight_Bit, SLANG_INT_TYPE, 0)) || (-1 == SLns_add_intrinsic_variable(ns, "SLsmg_Tab_Width", (VOID_STAR)&SLsmg_Tab_Width, SLANG_INT_TYPE, 0)) || (-1 == SLns_add_intrinsic_variable(ns, "SLsmg_Newline_Behavior", (VOID_STAR)&SLsmg_Newline_Behavior, SLANG_INT_TYPE, 0)) || (-1 == SLns_add_intrinsic_variable(ns, "SLsmg_Backspace_Moves", (VOID_STAR)&SLsmg_Backspace_Moves, SLANG_INT_TYPE, 0)) || (-1 == SLns_add_intrinsic_variable(ns, "SLsmg_Screen_Rows", (VOID_STAR)&SLtt_Screen_Rows, SLANG_INT_TYPE, 0)) || (-1 == SLns_add_intrinsic_variable(ns, "SLsmg_Screen_Cols", (VOID_STAR)&SLtt_Screen_Cols, SLANG_INT_TYPE, 0))) return -1; Smg_Initialized = 0; return 0; }
int SLns_add_istruct_table (SLang_NameSpace_Type *ns, SLang_IStruct_Field_Type *fields, VOID_STAR addr, char *name) { _SLang_IStruct_Type *s; SLang_IStruct_Field_Type *f; if (-1 == init_intrin_struct ()) return -1; if (addr == NULL) { SLang_verror (SL_INVALID_PARM, "SLadd_istruct_table: address must be non-NULL"); return -1; } if (fields == NULL) return -1; /* Make the field names slstrings so that only the pointers need to be * compared. However, this table may have been already been added for * another instance of the intrinsic object. So, check for the presence * of an slstring. */ f = fields; while (f->field_name != NULL) { char *fname; fname = SLang_create_slstring (f->field_name); if (fname == NULL) return -1; /* Here is the check for the slstring */ if (f->field_name == fname) SLang_free_slstring (fname); else /* replace string literal with slstring */ f->field_name = fname; f++; } s = (_SLang_IStruct_Type *)SLmalloc (sizeof (_SLang_IStruct_Type)); if (s == NULL) return -1; memset ((char *)s, 0, sizeof (_SLang_IStruct_Type)); if (NULL == (s->name = SLang_create_slstring (name))) { SLfree ((char *) s); return -1; } s->addr = addr; s->fields = fields; if (-1 == SLns_add_intrinsic_variable (ns, name, (VOID_STAR) s, SLANG_ISTRUCT_TYPE, 1)) { SLang_free_slstring (s->name); SLfree ((char *) s); return -1; } return 0; }