void silent_load(NODE *arg, char *prefix) { FILE *tmp_stream; NODE *tmp_line, *exec_list; char load_path[200]; NODE *st = valnode__caseobj(Startup); /* This procedure is called three ways: * silent_load(NIL,*argv) loads *argv * silent_load(proc,logolib) loads logolib/proc * silent_load(proc,NULL) loads proc.lg * The "/" or ".lg" is supplied by this procedure as needed. */ /* [This is no longer true! But for Windows we change FOO? to FOOQ.] * In the case that this procedure is called to load a procedure from the * logo library, it must first truncate the name of the procedure to * eight characters, to find the filename (so as to be compatible with * MS-DOS) */ if (prefix == NULL && arg == NIL) return; strcpy(load_path, (prefix == NULL ? "" : (arg == NIL ? prefix : addsep(prefix)))); if (arg != NIL) { arg = cnv_node_to_strnode(arg); if (arg == UNBOUND) return; if (!strncmp(getstrptr(arg), ".", getstrlen(arg))) return; if (!strncmp(getstrptr(arg), "..", 2)) return; if (getstrlen(arg) > 150) return; noparitylow_strnzcpy(load_path + (int)strlen(load_path), getstrptr(arg), getstrlen(arg)); if (prefix == NULL) strcat(load_path, ".lg"); /* #ifdef WIN32 */ else if (arg != NIL) { char *cp; for (cp = load_path; *cp != '\0'; cp++) if (*cp == '?') *cp = 'Q'; } /* strcpy(load_path, eight_dot_three(load_path)); */ /* #endif */ } tmp_stream = loadstream; tmp_line = current_line; loadstream = fopen(load_path, "r"); if (loadstream != NULL) { while (!(feof(loadstream)) && NOT_THROWING) { current_line = reader(loadstream, ""); exec_list =parser(current_line, TRUE); if (exec_list != NIL) eval_driver(exec_list); } fclose(loadstream); runstartup(st); } else if (arg == NIL || prefix == csls) err_logo(CANT_OPEN_ERROR, make_strnode(load_path, NULL, strlen(load_path), STRING, strnzcpy)); loadstream = tmp_stream; current_line = tmp_line; }
NODE *lload(NODE *arg) { FILE *tmp; NODE *tmp_line, *exec_list; NODE *st = valnode__caseobj(Startup); int sv_val_status = val_status; tmp = loadstream; tmp_line = vref(current_line); loadstream = open_file(car(arg), "r"); if (loadstream != NULL) { while (!feof(loadstream) && NOT_THROWING) { current_line = reref(current_line, reader(loadstream, "")); exec_list = parser(current_line, TRUE); val_status = 0; if (exec_list != NIL) eval_driver(exec_list); } fclose(loadstream); runstartup(st); val_status = sv_val_status; } else err_logo(FILE_ERROR, make_static_strnode("Could not open file")); loadstream = tmp; deref(current_line); current_line = tmp_line; return(UNBOUND); }
void runstartup(NODE *oldst) { NODE *st; st = valnode__caseobj(Startup); if (st != oldst && st != NIL && is_list(st)) { eval_driver(st); } }
void silent_load(NODE *arg, char *prefix) { FILE *tmp_stream; NODE *tmp_line, *exec_list; char load_path[200]; NODE *st = valnode__caseobj(Startup); int sv_val_status = val_status; /* This procedure is called three ways: * silent_load(NIL,*argv) loads *argv * silent_load(proc,logolib) loads logolib/proc * silent_load(proc,NULL) loads proc.lg * The "/" or ".lg" is supplied by this procedure as needed. */ if (prefix == NULL && arg == NIL) return; strcpy(load_path, (prefix == NULL ? "" : prefix)); if (arg != NIL) { arg = cnv_node_to_strnode(arg); if (arg == UNBOUND) return; #ifdef unix if (prefix != NULL) strcat(load_path, "/"); #endif noparitylow_strnzcpy(load_path + (int)strlen(load_path), getstrptr(arg), getstrlen(arg)); if (prefix == NULL) strcat(load_path, ".lg"); gcref(arg); } tmp_stream = loadstream; tmp_line = vref(current_line); loadstream = fopen(load_path, "r"); if (loadstream != NULL) { while (!feof(loadstream) && NOT_THROWING) { current_line = reref(current_line, reader(loadstream, "")); exec_list =parser(current_line, TRUE); val_status = 0; if (exec_list != NIL) eval_driver(exec_list); } fclose(loadstream); runstartup(st); val_status = sv_val_status; } else if (arg == NIL) ndprintf(stdout,"File not found: %t\n", prefix); loadstream = tmp_stream; deref(current_line); current_line = tmp_line; }
RETSIGTYPE mouse_down(int sig) { NODE *line; if (inside_gc || in_eval_save) { if (int_during_gc == 0) int_during_gc = 3; } else { line = valnode__caseobj(Buttonact); if (line != UNBOUND && line != NIL) { if (inside_evaluator) { eval_buttonact = line; } else { eval_driver(line); fix_turtle_shownness(); } } } SIGRET}
void do_keyact(int ch) { NODE *line; readchar_lookahead_buf = ch; if (inside_gc || in_eval_save) { if (int_during_gc == 0) int_during_gc = 4; } else { line = valnode__caseobj(Keyact); if (line != UNBOUND && line != NIL) { if (inside_evaluator) { eval_buttonact = line; } else { eval_driver(line); fix_turtle_shownness(); } } } }
void fileload(char *temp) { FILE *tmp; NODE *tmp_line, *exec_list, *arg; NODE *st = valnode__caseobj(Startup); int sv_val_status = val_status; int IsDirtySave; int save_yield_flag; arg = make_strnode(temp, NULL, strlen(temp), STRING, strnzcpy); IsDirtySave = IsDirty; tmp = loadstream; tmp_line = vref(current_line); loadstream = open_file(arg, "r"); if (loadstream != NULL) { save_yield_flag = yield_flag; yield_flag = 0; lsetcursorwait(); while (!feof(loadstream) && NOT_THROWING) { current_line = reref(current_line, reader(loadstream, "")); exec_list = parser(current_line, TRUE); val_status = 0; if (exec_list != NIL) eval_driver(exec_list); } fclose(loadstream); lsetcursorarrow(); yield_flag = save_yield_flag; runstartup(st); val_status = sv_val_status; } else err_logo(FILE_ERROR, make_static_strnode("Could not open file")); loadstream = tmp; deref(current_line); current_line = tmp_line; IsDirty = IsDirtySave; }
NODE *lload(NODE *arg) { FILE *tmp; NODE *tmp_line, *exec_list; NODE *st = valnode__caseobj(Startup); tmp = loadstream; tmp_line = current_line; loadstream = open_file(car(arg), "r"); if (loadstream != NULL) { while (!(feof(loadstream)) && NOT_THROWING) { current_line = reader(loadstream, ""); exec_list = parser(current_line, TRUE); if (exec_list != NIL) eval_driver(exec_list); } fclose(loadstream); save_name = car(arg); runstartup(st); } else err_logo(CANT_OPEN_ERROR, car(arg)); loadstream = tmp; current_line = tmp_line; return(UNBOUND); }
int main(int argc, char *argv[]) { NODE *exec_list = NIL; NODE *cl_tail = NIL; int argc2; char **argv2; bottom_stack = &exec_list; /*GC*/ (void) addseg(); term_init(); init(); math_init(); my_init(); signal(SIGINT, logo_stop); if (argc < 2) { if (1 || isatty(1)) // fix this. for interactive from menu bar. { char version[20]; lcleartext(NIL); strcpy(version, "5.6"); ndprintf(stdout, message_texts[WELCOME_TO], version); new_line(stdout); } } setvalnode__caseobj(LogoVersion, make_floatnode(5.6)); setflag__caseobj(LogoVersion, VAL_BURIED); argv2 = argv; argc2 = argc; if (!strcmp(*argv + strlen(*argv) - 4, "logo")) { argv++; while (--argc > 0 && strcmp(*argv, "-") && NOT_THROWING) { argv++; } } argv++; while (--argc > 0) { if (command_line == NIL) cl_tail = command_line = cons(make_static_strnode(*argv++), NIL); else { setcdr(cl_tail, cons(make_static_strnode(*argv++), NIL)); cl_tail = cdr(cl_tail); } } setvalnode__caseobj(CommandLine, command_line); silent_load(Startuplg, logolib); silent_load(Startup, NULL); /* load startup.lg */ if (!strcmp(*argv2 + strlen(*argv2) - 4, "logo")) { argv2++; while (--argc2 > 0 && strcmp(*argv2, "-") && NOT_THROWING) { silent_load(NIL, *argv2++); } } for (;;) { if (NOT_THROWING) { check_reserve_tank(); current_line = reader(stdin, "? "); if (feof(stdin) && !isatty(0)) lbye(NIL); if (NOT_THROWING) { exec_list = parser(current_line, TRUE); if (exec_list != NIL) eval_driver(exec_list); } } if (stopping_flag == THROWING) { if (isName(throw_node, Name_error)) { err_print(NULL); } else if (isName(throw_node, Name_system)) break; else if (!isName(throw_node, Name_toplevel)) { err_logo(NO_CATCH_TAG, throw_node); err_print(NULL); } stopping_flag = RUN; } if (stopping_flag == STOP || stopping_flag == OUTPUT) { /* ndprintf(stdout, "%t\n", message_texts[CANT_STOP]); */ stopping_flag = RUN; } } //prepare_to_exit(TRUE); my_finish(); exit(0); return 0; }
main(int argc, char *argv[]) { NODE *exec_list = NIL; #ifdef MEM_DEBUG extern long int mem_allocated, mem_freed; #endif #ifdef x_window x_window_init(argc, argv); #endif #ifdef mac init_mac_memory(); #endif term_init(); if (argc < 2) { if (isatty(1)) lcleartext(); printf("Welcome to Berkeley Logo version 3.0.1"); new_line(stdout); } init(); #ifdef ibm signal(SIGINT, SIG_IGN); #ifdef __ZTC__ _controlc_handler = do_ctrl_c; controlc_open(); #endif #else signal(SIGINT, logo_stop); #endif signal(SIGQUIT, logo_pause); /* SIGQUITs never happen on the IBM */ argv++; while (--argc > 0 && NOT_THROWING) { silent_load(NIL,*argv++); } for (;;) { if (NOT_THROWING) { #ifdef MEM_DEBUG printf("alloc=%d, freed=%d, used=%d\n", mem_allocated, mem_freed, mem_allocated-mem_freed); #endif current_line = reref(current_line, reader(stdin,"? ")); if (feof(stdin) && !isatty(0)) lbye(); exec_list = parser(current_line, TRUE); val_status = 0; if (exec_list != NIL) eval_driver(exec_list); } if (stopping_flag == THROWING) { if (compare_node(throw_node, Error, TRUE) == 0) { err_print(); } else if (compare_node(throw_node, System, TRUE) == 0) break; else if (compare_node(throw_node, Toplevel, TRUE) != 0) { err_logo(NO_CATCH_TAG, throw_node); err_print(); } stopping_flag = RUN; } if (stopping_flag == STOP || stopping_flag == OUTPUT) { print_node(stdout, make_static_strnode( "You must be in a procedure to use OUTPUT or STOP.\n")); stopping_flag = RUN; } } prepare_to_exit(TRUE); }
int start (int argc,char ** argv) { #else int main(int argc, char *argv[]) { #endif NODE *exec_list = NIL; NODE *cl_tail = NIL; int argc2; char **argv2; #ifdef SYMANTEC_C extern void (*openproc)(void); extern void __open_std(void); openproc = &__open_std; #endif #ifdef mac init_mac_memory(); #endif bottom_stack = &exec_list; /*GC*/ #ifndef HAVE_WX #ifdef x_window x_window_init(argc, argv); #endif #endif (void)addseg(); term_init(); init(); math_init(); #ifdef ibm signal(SIGINT, SIG_IGN); #if defined(__RZTC__) && !defined(WIN32) /* sowings */ _controlc_handler = do_ctrl_c; controlc_open(); #endif #else /* !ibm */ signal(SIGINT, logo_stop); #endif /* ibm */ #ifdef mac signal(SIGQUIT, SIG_IGN); #else /* !mac */ //signal(SIGQUIT, logo_pause); #endif /* SIGQUITs never happen on the IBM */ if (argc < 2) { #ifndef WIN32 if (1 || isatty(1)) // fix this. for interactive from menu bar. #endif { #ifdef HAVE_WX extern char *SVN; #endif char version[20]; lcleartext(NIL); #ifdef HAVE_WX strcpy(version,"6.0"); strcat(version,SVN); #else strcpy(version,"5.6"); #endif ndprintf(stdout, message_texts[WELCOME_TO], version); new_line(stdout); } } #ifdef HAVE_WX setvalnode__caseobj(LogoVersion, make_floatnode(6.0)); #else setvalnode__caseobj(LogoVersion, make_floatnode(5.6)); #endif setflag__caseobj(LogoVersion, VAL_BURIED); argv2 = argv; argc2 = argc; if (!strcmp(*argv+strlen(*argv)-4, "logo")) { argv++; while (--argc > 0 && strcmp(*argv, "-") && NOT_THROWING) { argv++; } } argv++; while (--argc > 0) { if (command_line == NIL) cl_tail = command_line = cons(make_static_strnode(*argv++), NIL); else { setcdr(cl_tail, cons(make_static_strnode(*argv++), NIL)); cl_tail = cdr(cl_tail); } } setvalnode__caseobj(CommandLine, command_line); silent_load(Startuplg, logolib); silent_load(Startup, NULL); /* load startup.lg */ if (!strcmp(*argv2+strlen(*argv2)-4, "logo")) { argv2++; while (--argc2 > 0 && strcmp(*argv2, "-") && NOT_THROWING) { silent_load(NIL,*argv2++); } } for (;;) { if (NOT_THROWING) { check_reserve_tank(); current_line = reader(stdin,"? "); #ifdef __RZTC__ (void)feof(stdin); if (!in_graphics_mode) printf(" \b"); fflush(stdout); #endif #ifndef WIN32 if (feof(stdin) && !isatty(0)) lbye(NIL); #endif #ifdef __RZTC__ if (feof(stdin)) clearerr(stdin); #endif if (NOT_THROWING) { exec_list = parser(current_line, TRUE); if (exec_list != NIL) eval_driver(exec_list); } } #ifdef HAVE_WX if (wx_leave_mainloop) { break; } #endif if (stopping_flag == THROWING) { if (isName(throw_node, Name_error)) { err_print(NULL); } else if (isName(throw_node, Name_system)) break; else if (!isName(throw_node, Name_toplevel)) { err_logo(NO_CATCH_TAG, throw_node); err_print(NULL); } stopping_flag = RUN; } if (stopping_flag == STOP || stopping_flag == OUTPUT) { /* ndprintf(stdout, "%t\n", message_texts[CANT_STOP]); */ stopping_flag = RUN; } } //prepare_to_exit(TRUE); exit(0); return 0; }