#include "global.h" #include "fdlib.h" #include "backend.h" #include "module.h" #include "object.h" #include "lex.h" #include "pike_types.h" #include "builtin_functions.h" #include "array.h" #include "stralloc.h" #include "interpret.h" #include "pike_error.h" #include "pike_macros.h" #include "callback.h" #include "signal_handler.h" #include "threads.h" #include "dynamic_load.h" #include "gc.h" #include "multiset.h" #include "mapping.h" #include "cpp.h" #include "main.h" #include "operators.h" #include "rbtree.h" #include "pike_security.h" #include "constants.h" #include "version.h" #include "program.h" #include "pike_rusage.h" #include "module_support.h" #include "opcodes.h" static char master_location[MAXPATHLEN*2]; static void set_master(const char *file) { if (strlen(file) >= MAXPATHLEN*2 ) { fprintf(stderr, "Too long path to master: \"%s\" (limit:%"PRINTPTRDIFFT"d)\n", file, MAXPATHLEN*2 ); exit(1); } strcpy(master_location, file); } static void set_default_master(void) { set_master(getenv("PIKE_MASTER")); } int main(int argc, char ** argv) { JMP_BUF back; int num = 0; struct object *m; set_default_master(); init_pike(argv, master_location); init_pike_runtime(exit); add_pike_string_constant("__master_cookie", master_location, strlen(master_location)); if(SETJMP(back)) { if(throw_severity == THROW_EXIT) { num=throw_value.u.integer; }else{ if (throw_value.type == T_OBJECT && throw_value.u.object->prog == master_load_error_program && !get_master()) { /* Report this specific error in a nice way. Since there's no * master it'd be reported with a raw error dump otherwise. */ struct generic_error_struct *err; dynamic_buffer buf; dynbuf_string s; struct svalue t; *(Pike_sp++) = throw_value; dmalloc_touch_svalue(Pike_sp-1); throw_value.type=T_INT; err = (struct generic_error_struct *) get_storage (Pike_sp[-1].u.object, generic_error_program); t.type = PIKE_T_STRING; t.u.string = err->error_message; init_buf(&buf); describe_svalue(&t,0,0); s=complex_free_buf(&buf); fputs(s.str, stderr); free(s.str); } else call_handle_error(); num=10; } }else{ if ((m = load_pike_master())) { back.severity=THROW_EXIT; pike_push_argv(argc, argv); // pike_push_env(); push_text("int foo(){write(\"bar!\\n\"); return 1;}"); f_compile(1); apply_svalue( Pike_sp-1, 0 ); push_text("foo"); f_index(2); apply_svalue( Pike_sp-1, 0); if(Pike_sp[-1].type == T_INT) { printf("got an int, its value is %d!\n", Pike_sp[-1].u.integer); } pop_stack(); num=0; } else { num = -1; } UNSETJMP(back); pike_do_exit(num); return num; } }