int user_open_source (char **argv, int argc, double area, double cosx, double cosy, double cosz) { char *file; int status; if (-1 == init_slang ()) return -1; file = argv[0]; if ((argc == 0) || (NULL == (file = argv[0]))) { fprintf (stderr, "No filename specified for the slang source\n"); return -1; } if (0 != SLang_load_file (file)) { fprintf (stderr, "Encountered a problem loading %s\n", file); return -1; } if (NULL == (Open_Source = SLang_get_function ("user_open_source"))) { fprintf (stderr, "%s failed to define user_open_source\n", file); return -1; } if (NULL == (Create_Ray = SLang_get_function ("user_create_ray"))) { fprintf (stderr, "%s failed to define user_create_ray\n", file); return -1; } if ((-1 == SLang_start_arg_list ()) || (-1 == push_c_string_array (argv, argc)) || (-1 == SLang_push_double (area)) || (-1 == SLang_push_double (cosx)) || (-1 == SLang_push_double (cosy)) || (-1 == SLang_push_double (cosz)) || (-1 == SLang_end_arg_list ()) || (-1 == SLexecute_function (Open_Source)) || (-1 == SLang_pop_integer (&status))) { SLang_verror (0, "Error occured processing user_open_source in %s", file); return -1; } return status; }
SLang_Name_Type *SLang_pop_function (void) { SLang_Ref_Type *ref; SLang_Name_Type *f; if (SLang_peek_at_stack () == SLANG_STRING_TYPE) { char *name; if (-1 == SLang_pop_slstring (&name)) return NULL; if (NULL == (f = SLang_get_function (name))) { _pSLang_verror (SL_UNDEFINED_NAME, "Function %s does not exist", name); SLang_free_slstring (name); return NULL; } SLang_free_slstring (name); return f; } if (-1 == SLang_pop_ref (&ref)) return NULL; f = SLang_get_fun_from_ref (ref); SLang_free_ref (ref); return f; }