int main(int c, char **v) { char buffer[BUFSIZE]=""; int b_read, len, p, ret, po; char *aux; printf("OrixFile Console / Felipe Astroza\n"); if(c < 2) return 0; of = o_open(v[1], "rw"); if(!of) { fprintf(stderr, "Unable to open file\n"); return -1; } b_read = 0; p = 0; po = PROMPT_1; prepare_console(); /* Por mientras, al continuar un buffer, no se pone un ' ' o '\n' entre medio, que seria lo mejor */ while(status) { fprintf(stdout, "%s", prompts[po]); fflush(stdout); ret = read(0, buffer + b_read, BUFSIZE - b_read - 1); if(ret == 0) break; clean_buf(buffer + b_read); len = strlen(buffer + b_read); if(len == 0) continue; aux = buffer + b_read; while(*aux) { if(*aux == '"') { if(p == 0 && ((buffer + b_read - aux) == 0? 1 : *(aux - 1) == ' ') ) { p = 1; po = PROMPT_2; } else if(p == 1) { po = PROMPT_1; p = 0; } } *aux++; } b_read += len; if(b_read >= BUFSIZE - 1 && p == 1) { fprintf(stderr, "string too long\n"); b_read = 0; p = 0; continue; } /* Listo para ser analizado */ if(p == 0) { o_exec(buffer); b_read = 0; } else continue; } o_close(of); return 0; }
int main(int argc, char **argv) { int result = 0; int i; userui_ops[0] = &userui_text_ops; userui_ops[1] = FBSPLASH_OPS; userui_ops[2] = USPLASH_OPS; active_ops = &userui_text_ops; handle_params(argc, argv); setup_signal_handlers(); open_console(); open_misc(); if (!test_run) { open_netlink(); get_nofreeze(); get_info(); } lock_memory(); prepare_console(); /* Initialise all that we can, use the first */ // active_ops = NULL; for (i = 0; i < NUM_UIS; i++) { if (userui_ops[i] && userui_ops[i]->load) { result = userui_ops[i]->load(); if (result) { if (test_run) fprintf(stderr, "Failed to initialise %s module.\n", userui_ops[i]->name); else printk("Failed to initialise %s module.\n", userui_ops[i]->name); } else if (!active_ops) active_ops = userui_ops[i]; } } if (active_ops->prepare) active_ops->prepare(); register_keypress_handler(); need_cleanup = 1; running = 1; result = nice(1); if (active_ops->memory_required) reserve_memory(active_ops->memory_required()); else reserve_memory(4*1024*1024); /* say 4MB */ enforce_lifesavers(); if (test_run) { safe_to_exit = 0; do_test_run(); return 0; } if (send_ready()) message_loop(); /* The only point we ever reach here is if message_loop crashed out. * If this is the case, we should spin for a few hours before exiting to * ensure that we don't corrupt stuff on disk (if we're past the atomic * copy). */ sleep(60*60*1); /* 1 hours */ _exit(1); }