void ui_usb_mode_change(bool b_host_mode) { ui_init(); }
int main(int argc, char **argv) { if (strcmp(basename(argv[0]), "recovery") != 0) { if (strstr(argv[0], "flash_image") != NULL) return flash_image_main(argc, argv); if (strstr(argv[0], "volume") != NULL) return volume_main(argc, argv); if (strstr(argv[0], "edify") != NULL) return edify_main(argc, argv); if (strstr(argv[0], "dump_image") != NULL) return dump_image_main(argc, argv); if (strstr(argv[0], "erase_image") != NULL) return erase_image_main(argc, argv); if (strstr(argv[0], "mkyaffs2image") != NULL) return mkyaffs2image_main(argc, argv); if (strstr(argv[0], "unyaffs") != NULL) return unyaffs_main(argc, argv); if (strstr(argv[0], "nandroid")) return nandroid_main(argc, argv); if (strstr(argv[0], "reboot")) return reboot_main(argc, argv); #ifdef BOARD_RECOVERY_HANDLES_MOUNT if (strstr(argv[0], "mount") && argc == 2 && !strstr(argv[0], "umount")) { load_volume_table(); return ensure_path_mounted(argv[1]); } #endif if (strstr(argv[0], "poweroff")){ return reboot_main(argc, argv); } if (strstr(argv[0], "setprop")) return setprop_main(argc, argv); return busybox_driver(argc, argv); } __system("/sbin/postrecoveryboot.sh"); int is_user_initiated_recovery = 0; time_t start = time(NULL); // If these fail, there's not really anywhere to complain... freopen(TEMPORARY_LOG_FILE, "a", stdout); setbuf(stdout, NULL); freopen(TEMPORARY_LOG_FILE, "a", stderr); setbuf(stderr, NULL); printf("Starting recovery on %s", ctime(&start)); ui_init(); ui_print(EXPAND(RECOVERY_VERSION)"\n"); load_volume_table(); process_volumes(); LOGI("Processing arguments.\n"); get_args(&argc, &argv); int previous_runs = 0; const char *send_intent = NULL; const char *update_package = NULL; const char *encrypted_fs_mode = NULL; int wipe_data = 0, wipe_cache = 0; int toggle_secure_fs = 0; encrypted_fs_info encrypted_fs_data; LOGI("Checking arguments.\n"); int arg; while ((arg = getopt_long(argc, argv, "", OPTIONS, NULL)) != -1) { switch (arg) { case 'p': previous_runs = atoi(optarg); break; case 's': send_intent = optarg; break; case 'u': update_package = optarg; break; case 'w': #ifndef BOARD_RECOVERY_ALWAYS_WIPES wipe_data = wipe_cache = 1; #endif break; case 'c': wipe_cache = 1; break; case 'e': encrypted_fs_mode = optarg; toggle_secure_fs = 1; break; case 't': ui_show_text(1); break; case '?': LOGE("Invalid command argument\n"); continue; } } LOGI("device_recovery_start()\n"); device_recovery_start(); printf("Command:"); for (arg = 0; arg < argc; arg++) { printf(" \"%s\"", argv[arg]); } printf("\n"); if (update_package) { // For backwards compatibility on the cache partition only, if // we're given an old 'root' path "CACHE:foo", change it to // "/cache/foo". if (strncmp(update_package, "CACHE:", 6) == 0) { int len = strlen(update_package) + 10; char* modified_path = malloc(len); strlcpy(modified_path, "/cache/", len); strlcat(modified_path, update_package+6, len); printf("(replacing path \"%s\" with \"%s\")\n", update_package, modified_path); update_package = modified_path; } } printf("\n"); property_list(print_property, NULL); printf("\n"); int status = INSTALL_SUCCESS; if (toggle_secure_fs) { if (strcmp(encrypted_fs_mode,"on") == 0) { encrypted_fs_data.mode = MODE_ENCRYPTED_FS_ENABLED; ui_print("Enabling Encrypted FS.\n"); } else if (strcmp(encrypted_fs_mode,"off") == 0) { encrypted_fs_data.mode = MODE_ENCRYPTED_FS_DISABLED; ui_print("Disabling Encrypted FS.\n"); } else { ui_print("Error: invalid Encrypted FS setting.\n"); status = INSTALL_ERROR; } // Recovery strategy: if the data partition is damaged, disable encrypted file systems. // This preventsthe device recycling endlessly in recovery mode. if ((encrypted_fs_data.mode == MODE_ENCRYPTED_FS_ENABLED) && (read_encrypted_fs_info(&encrypted_fs_data))) { ui_print("Encrypted FS change aborted, resetting to disabled state.\n"); encrypted_fs_data.mode = MODE_ENCRYPTED_FS_DISABLED; } if (status != INSTALL_ERROR) { if (erase_volume("/data")) { ui_print("Data wipe failed.\n"); status = INSTALL_ERROR; } else if (erase_volume("/cache")) { ui_print("Cache wipe failed.\n"); status = INSTALL_ERROR; } else if ((encrypted_fs_data.mode == MODE_ENCRYPTED_FS_ENABLED) && (restore_encrypted_fs_info(&encrypted_fs_data))) { ui_print("Encrypted FS change aborted.\n"); status = INSTALL_ERROR; } else { ui_print("Successfully updated Encrypted FS.\n"); status = INSTALL_SUCCESS; } } } else if (update_package != NULL) { status = install_package(update_package); if (status != INSTALL_SUCCESS) ui_print("Installation aborted.\n"); } else if (wipe_data) { if (device_wipe_data()) status = INSTALL_ERROR; if (erase_volume("/data")) status = INSTALL_ERROR; if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) ui_print("Data wipe failed.\n"); } else if (wipe_cache) { if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) ui_print("Cache wipe failed.\n"); } else { LOGI("Checking for extendedcommand...\n"); status = INSTALL_ERROR; // No command specified // we are starting up in user initiated recovery here // let's set up some default options signature_check_enabled = 0; script_assert_enabled = 0; is_user_initiated_recovery = 1; ui_set_show_text(1); ui_set_background(BACKGROUND_ICON_CLOCKWORK); if (extendedcommand_file_exists()) { LOGI("Running extendedcommand...\n"); int ret; if (0 == (ret = run_and_remove_extendedcommand())) { status = INSTALL_SUCCESS; ui_set_show_text(0); } else { handle_failure(ret); } } else { LOGI("Skipping execution of extendedcommand, file not found...\n"); } } if (status != INSTALL_SUCCESS && !is_user_initiated_recovery) { ui_set_show_text(1); ui_set_background(BACKGROUND_ICON_ERROR); } if (status != INSTALL_SUCCESS || ui_text_visible()) { prompt_and_wait(); } // If there is a radio image pending, reboot now to install it. maybe_install_firmware_update(send_intent); // Otherwise, get ready to boot the main system... finish_recovery(send_intent); if(!poweroff) ui_print("Rebooting...\n"); else ui_print("Shutting down...\n"); sync(); reboot((!poweroff) ? RB_AUTOBOOT : RB_POWER_OFF); return EXIT_SUCCESS; }
void ui_usb_mode_change(bool b_host_mode) { UNUSED(b_host_mode); ui_init(); }
int main(int argc, char **argv) { time_t start = time(NULL); // If these fail, there's not really anywhere to complain... freopen(TEMPORARY_LOG_FILE, "a", stdout); setbuf(stdout, NULL); freopen(TEMPORARY_LOG_FILE, "a", stderr); setbuf(stderr, NULL); printf("Starting recovery on %s", ctime(&start)); device_ui_init(&ui_parameters); ui_init(); ui_set_background(BACKGROUND_ICON_INSTALLING); load_volume_table(); get_args(&argc, &argv); int previous_runs = 0; const char *send_intent = NULL; const char *update_package = NULL; int wipe_data = 0, wipe_cache = 0; //check delta update first handle_deltaupdate_status(); int arg; while ((arg = getopt_long(argc, argv, "", OPTIONS, NULL)) != -1) { switch (arg) { case 'p': previous_runs = atoi(optarg); break; case 's': send_intent = optarg; break; case 'u': update_package = optarg; break; case 'w': wipe_data = wipe_cache = 1; break; case 'c': wipe_cache = 1; break; case 't': ui_show_text(1); break; case '?': LOGE("Invalid command argument\n"); continue; } } device_recovery_start(); printf("Command:"); for (arg = 0; arg < argc; arg++) { printf(" \"%s\"", argv[arg]); } printf("\n"); if (update_package) { // For backwards compatibility on the cache partition only, if // we're given an old 'root' path "CACHE:foo", change it to // "/cache/foo". if (strncmp(update_package, "CACHE:", 6) == 0) { int len = strlen(update_package) + 10; char* modified_path = malloc(len); strlcpy(modified_path, "/cache/", len); strlcat(modified_path, update_package+6, len); printf("(replacing path \"%s\" with \"%s\")\n", update_package, modified_path); update_package = modified_path; } } printf("\n"); property_list(print_property, NULL); printf("\n"); int status = INSTALL_SUCCESS; if (update_package != NULL) { status = install_package(update_package, &wipe_cache, TEMPORARY_INSTALL_FILE); if (status == INSTALL_SUCCESS && wipe_cache) { if (erase_volume("/cache")) { LOGE("Cache wipe (requested by package) failed."); } } if (status != INSTALL_SUCCESS) ui_print("Installation aborted.\n"); } else if (wipe_data) { if (device_wipe_data()) status = INSTALL_ERROR; if (erase_volume("/data")) status = INSTALL_ERROR; if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) ui_print("Data wipe failed.\n"); } else if (wipe_cache) { if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) ui_print("Cache wipe failed.\n"); } else { status = INSTALL_ERROR; // No command specified } if (status != INSTALL_SUCCESS) ui_set_background(BACKGROUND_ICON_ERROR); if (status != INSTALL_SUCCESS || ui_text_visible()) { prompt_and_wait(); } // Otherwise, get ready to boot the main system... finish_recovery(send_intent); ui_print("Rebooting...\n"); android_reboot(ANDROID_RB_RESTART, 0, 0); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { /* * Alloc the global structures * We can access these structs via the macro in ec_globals.h */ globals_alloc(); GBL_PROGRAM = strdup(EC_PROGRAM); GBL_VERSION = strdup(EC_VERSION); SAFE_CALLOC(GBL_DEBUG_FILE, strlen(EC_PROGRAM) + strlen("-") + strlen(EC_VERSION) + strlen("_debug.log") + 1, sizeof(char)); sprintf(GBL_DEBUG_FILE, "%s-%s_debug.log", GBL_PROGRAM, EC_VERSION); DEBUG_INIT(); DEBUG_MSG("main -- here we go !!"); /* initialize the filter mutex */ filter_init_mutex(); /* register the main thread as "init" */ ec_thread_register(EC_PTHREAD_SELF, "init", "initialization phase"); /* activate the signal handler */ signal_handler(); /* ettercap copyright */ fprintf(stdout, "\n" EC_COLOR_BOLD "%s %s" EC_COLOR_END " copyright %s %s\n\n", GBL_PROGRAM, GBL_VERSION, EC_COPYRIGHT, EC_AUTHORS); /* getopt related parsing... */ parse_options(argc, argv); /* check the date */ time_check(); /* load the configuration file */ load_conf(); /* * get the list of available interfaces * * this function will not return if the -I option was * specified on command line. it will instead print the * list and exit */ capture_getifs(); /* initialize the user interface */ ui_init(); /* initialize the network subsystem */ network_init(); /* * always disable the kernel ip forwarding (except when reading from file). * the forwarding will be done by ettercap. */ if(!GBL_OPTIONS->read && !GBL_OPTIONS->unoffensive && !GBL_OPTIONS->only_mitm) { disable_ip_forward(); #ifdef OS_LINUX if (!GBL_OPTIONS->read) disable_interface_offload(); #endif /* binds ports and set redirect for ssl wrapper */ if(GBL_SNIFF->type == SM_UNIFIED && GBL_OPTIONS->ssl_mitm) ssl_wrap_init(); } /* * drop root privileges * we have already opened the sockets with high privileges * we don't need anymore root privs. */ drop_privs(); /***** !! NO PRIVS AFTER THIS POINT !! *****/ /* load all the plugins */ plugin_load_all(); /* print how many dissectors were loaded */ conf_dissectors(); /* load the mac-fingerprints */ manuf_init(); /* load the tcp-fingerprints */ fingerprint_init(); /* load the services names */ services_init(); /* load http known fileds for user/pass */ http_fields_init(); #ifdef HAVE_EC_LUA /* Initialize lua */ ec_lua_init(); #endif /* set the encoding for the UTF-8 visualization */ set_utf8_encoding((u_char*)GBL_CONF->utf8_encoding); /* print all the buffered messages */ if (GBL_UI->type == UI_TEXT) USER_MSG("\n"); ui_msg_flush(MSG_ALL); /**** INITIALIZATION PHASE TERMINATED ****/ /* * we are interested only in the mitm attack i * if entered, this function will not return... */ if (GBL_OPTIONS->only_mitm) only_mitm(); /* create the dispatcher thread */ ec_thread_new("top_half", "dispatching module", &top_half, NULL); /* this thread becomes the UI then displays it */ ec_thread_register(EC_PTHREAD_SELF, GBL_PROGRAM, "the user interface"); ui_start(); /******************************************** * reached only when the UI is shutted down ********************************************/ /* Call all the proper stop methods to ensure * that no matter what UI was selected, everything is * turned off gracefully */ clean_exit(0); return 0; //Never reaches here }
void running_machine::start() { /* initialize basic can't-fail systems here */ fileio_init(this); config_init(this); input_init(this); output_init(this); state_init(this); state_save_allow_registration(this, true); palette_init(this); render_init(this); ui_init(this); generic_machine_init(this); generic_video_init(this); generic_sound_init(this); /* initialize the timers and allocate a soft_reset timer this must be done before cpu_init so that CPU's can allocate timers */ timer_init(this); m_soft_reset_timer = timer_alloc(this, static_soft_reset, NULL); /* init the osd layer */ osd_init(this); /* initialize the base time (needed for doing record/playback) */ time(&m_base_time); /* initialize the input system and input ports for the game this must be done before memory_init in order to allow specifying callbacks based on input port tags */ time_t newbase = input_port_init(this, m_game.ipt); if (newbase != 0) m_base_time = newbase; /* intialize UI input */ ui_input_init(this); /* initialize the streams engine before the sound devices start */ streams_init(this); /* first load ROMs, then populate memory, and finally initialize CPUs these operations must proceed in this order */ rom_init(this); memory_init(this); watchdog_init(this); /* allocate the gfx elements prior to device initialization */ gfx_init(this); /* initialize natural keyboard support */ inputx_init(this); /* initialize image devices */ image_init(this); /* start up the devices */ m_devicelist.start_all(); /* call the game driver's init function this is where decryption is done and memory maps are altered so this location in the init order is important */ ui_set_startup_text(this, "Initializing...", true); if (m_game.driver_init != NULL) (*m_game.driver_init)(this); /* finish image devices init process */ image_postdevice_init(this); /* start the video and audio hardware */ video_init(this); tilemap_init(this); crosshair_init(this); sound_init(this); /* initialize the debugger */ if ((debug_flags & DEBUG_FLAG_ENABLED) != 0) debugger_init(this); /* call the driver's _START callbacks */ if (m_config.m_machine_start != NULL) (*m_config.m_machine_start)(this); if (m_config.m_sound_start != NULL) (*m_config.m_sound_start)(this); if (m_config.m_video_start != NULL) (*m_config.m_video_start)(this); /* set up the cheat engine */ cheat_init(this); /* set up the hiscore engine */ hiscore_init(this); /* disallow save state registrations starting here */ state_save_allow_registration(this, false); }
static void main_init(void) { /* add our icon path in case we aren't installed in the system prefix */ gchar *path; #ifdef G_OS_WIN32 gchar *install_dir = win32_get_installation_dir(); path = g_build_filename(install_dir, "share", "icons", NULL); g_free(install_dir); #else path = g_build_filename(GEANY_DATADIR, "icons", NULL); #endif gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), path); g_free(path); /* inits */ ui_init_stock_items(); ui_init_builder(); main_widgets.window = NULL; app->project = NULL; ui_widgets.open_fontsel = NULL; ui_widgets.open_colorsel = NULL; ui_widgets.prefs_dialog = NULL; main_status.main_window_realized = FALSE; file_prefs.tab_order_ltr = FALSE; file_prefs.tab_order_beside = FALSE; main_status.quitting = FALSE; ignore_callback = FALSE; app->tm_workspace = tm_get_workspace(); ui_prefs.recent_queue = g_queue_new(); ui_prefs.recent_projects_queue = g_queue_new(); main_status.opening_session_files = FALSE; main_widgets.window = create_window1(); /* add recent projects to the Project menu */ ui_widgets.recent_projects_menuitem = ui_lookup_widget(main_widgets.window, "recent_projects1"); ui_widgets.recent_projects_menu_menubar = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(ui_widgets.recent_projects_menuitem), ui_widgets.recent_projects_menu_menubar); /* store important pointers for later reference */ main_widgets.toolbar = toolbar_init(); main_widgets.sidebar_notebook = ui_lookup_widget(main_widgets.window, "notebook3"); main_widgets.notebook = ui_lookup_widget(main_widgets.window, "notebook1"); main_widgets.editor_menu = create_edit_menu1(); main_widgets.tools_menu = ui_lookup_widget(main_widgets.window, "tools1_menu"); main_widgets.message_window_notebook = ui_lookup_widget(main_widgets.window, "notebook_info"); main_widgets.project_menu = ui_lookup_widget(main_widgets.window, "menu_project1_menu"); ui_widgets.toolbar_menu = create_toolbar_popup_menu1(); ui_init(); /* set widget names for matching with .gtkrc-2.0 */ gtk_widget_set_name(main_widgets.window, "GeanyMainWindow"); gtk_widget_set_name(ui_widgets.toolbar_menu, "GeanyToolbarMenu"); gtk_widget_set_name(main_widgets.editor_menu, "GeanyEditMenu"); gtk_widget_set_name(ui_lookup_widget(main_widgets.window, "menubar1"), "GeanyMenubar"); gtk_widget_set_name(main_widgets.toolbar, "GeanyToolbar"); gtk_window_set_default_size(GTK_WINDOW(main_widgets.window), GEANY_WINDOW_DEFAULT_WIDTH, GEANY_WINDOW_DEFAULT_HEIGHT); }
void corange_init(const char* core_assets_path) { /* Attach signal handlers */ signal(SIGABRT, corange_signal); signal(SIGFPE, corange_signal); signal(SIGILL, corange_signal); signal(SIGINT, corange_signal); signal(SIGSEGV, corange_signal); signal(SIGTERM, corange_signal); logout = fopen("output.log", "w"); at_error(corange_error); at_warning(corange_warning); at_debug(corange_debug); /* Starting Corange */ debug("Starting Corange..."); /* Graphics Manager */ debug("Creating Graphics Manager..."); graphics_init(); /* Audio Manager */ debug("Creating Audio Manager..."); audio_init(); /* Joystick Manager */ debug("Creating Joystick Manager..."); joystick_init(); /* Network Manager */ debug("Creating Network Manager..."); net_init(); /* Asset Manager */ debug("Creating Asset Manager..."); debug("Core Assets At '%s' ...", core_assets_path); asset_init(); asset_add_path_variable(P("$CORANGE"), P(core_assets_path)); asset_handler(renderable, "bmf", bmf_load_file, renderable_delete); asset_handler(renderable, "obj", obj_load_file, renderable_delete); asset_handler(renderable, "smd", smd_load_file, renderable_delete); asset_handler(renderable, "ply", ply_load_file, renderable_delete); asset_handler(skeleton, "skl", skl_load_file, skeleton_delete); asset_handler(animation, "ani", ani_load_file, animation_delete); asset_handler(cmesh, "col", col_load_file, cmesh_delete); asset_handler(terrain, "raw", raw_load_file, terrain_delete); asset_handler(texture, "bmp", bmp_load_file, texture_delete); asset_handler(texture, "tga", tga_load_file, texture_delete); asset_handler(texture, "dds", dds_load_file, texture_delete); asset_handler(texture, "lut", lut_load_file, texture_delete); asset_handler(texture, "acv", acv_load_file, texture_delete); asset_handler(shader, "vs" , vs_load_file, shader_delete); asset_handler(shader, "fs" , fs_load_file, shader_delete); asset_handler(shader, "gs" , gs_load_file, shader_delete); asset_handler(shader, "tcs" , tcs_load_file, shader_delete); asset_handler(shader, "tes" , tes_load_file, shader_delete); asset_handler(config, "cfg", cfg_load_file, config_delete); asset_handler(lang, "lang", lang_load_file, lang_delete); asset_handler(font, "fnt", font_load_file, font_delete); asset_handler(material, "mat", mat_load_file, material_delete); asset_handler(effect, "effect" , effect_load_file, effect_delete); asset_handler(sound, "wav", wav_load_file, sound_delete); asset_handler(music, "ogg", ogg_load_file, music_delete); asset_handler(music, "mp3", mp3_load_file, music_delete); /* Entity Manager */ debug("Creating Entity Manager..."); entity_init(); entity_handler(static_object, static_object_new, static_object_delete); entity_handler(animated_object, animated_object_new, animated_object_delete); entity_handler(physics_object, physics_object_new, physics_object_delete); entity_handler(instance_object, instance_object_new, instance_object_delete); entity_handler(camera, camera_new, camera_delete); entity_handler(light, light_new, light_delete); entity_handler(landscape, landscape_new, landscape_delete); entity_handler(particles, particles_new, particles_delete); /* UI Manager */ debug("Creating UI Manager..."); ui_init(); ui_handler(ui_rectangle, ui_rectangle_new, ui_rectangle_delete, ui_rectangle_event, ui_rectangle_update, ui_rectangle_render); ui_handler(ui_text, ui_text_new, ui_text_delete, ui_text_event, ui_text_update, ui_text_render); ui_handler(ui_spinner, ui_spinner_new, ui_spinner_delete, ui_spinner_event, ui_spinner_update, ui_spinner_render); ui_handler(ui_button, ui_button_new, ui_button_delete, ui_button_event, ui_button_update, ui_button_render); ui_handler(ui_textbox, ui_textbox_new, ui_textbox_delete, ui_textbox_event, ui_textbox_update, ui_textbox_render); ui_handler(ui_browser, ui_browser_new, ui_browser_delete, ui_browser_event, ui_browser_update, ui_browser_render); ui_handler(ui_toast, ui_toast_new, ui_toast_delete, ui_toast_event, ui_toast_update, ui_toast_render); ui_handler(ui_dialog, ui_dialog_new, ui_dialog_delete, ui_dialog_event, ui_dialog_update, ui_dialog_render); ui_handler(ui_listbox, ui_listbox_new, ui_listbox_delete, ui_listbox_event, ui_listbox_update, ui_listbox_render); ui_handler(ui_option, ui_option_new, ui_option_delete, ui_option_event, ui_option_update, ui_option_render); ui_handler(ui_slider, ui_slider_new, ui_slider_delete, ui_slider_event, ui_slider_update, ui_slider_render); debug("Finished!"); }
int main(int argc, char **argv) { if (strstr(argv[0], "recovery") == NULL) { if (strstr(argv[0], "flash_image") != NULL) return flash_image_main(argc, argv); if (strstr(argv[0], "dump_image") != NULL) return dump_image_main(argc, argv); if (strstr(argv[0], "erase_image") != NULL) return erase_image_main(argc, argv); if (strstr(argv[0], "mkyaffs2image") != NULL) return mkyaffs2image_main(argc, argv); if (strstr(argv[0], "unyaffs") != NULL) return unyaffs_main(argc, argv); if (strstr(argv[0], "amend")) return amend_main(argc, argv); if (strstr(argv[0], "nandroid")) return nandroid_main(argc, argv); if (strstr(argv[0], "reboot")) return reboot_main(argc, argv); if (strstr(argv[0], "setprop")) return setprop_main(argc, argv); return busybox_driver(argc, argv); } __system("/sbin/postrecoveryboot.sh"); create_fstab(); int is_user_initiated_recovery = 0; time_t start = time(NULL); // If these fail, there's not really anywhere to complain... freopen(TEMPORARY_LOG_FILE, "a", stdout); setbuf(stdout, NULL); freopen(TEMPORARY_LOG_FILE, "a", stderr); setbuf(stderr, NULL); fprintf(stderr, "Starting recovery on %s", ctime(&start)); ui_init(); ui_print(EXPAND(RECOVERY_VERSION)"\n"); #ifdef BOARD_GOAPK_DEFY ui_print(EXPAND(RECOVERY_VERSION_GOAPK)"\n"); ui_print(EXPAND(RECOVERY_VERSION_QUN)"\n"); #endif get_args(&argc, &argv); int previous_runs = 0; const char *send_intent = NULL; const char *update_package = NULL; int wipe_data = 0, wipe_cache = 0; int arg; while ((arg = getopt_long(argc, argv, "", OPTIONS, NULL)) != -1) { switch (arg) { case 'p': previous_runs = atoi(optarg); break; case 's': send_intent = optarg; break; case 'u': update_package = optarg; break; case 'w': wipe_data = wipe_cache = 1; break; case 'c': wipe_cache = 1; break; case '?': LOGE("Invalid command argument\n"); continue; } } device_recovery_start(); fprintf(stderr, "Command:"); for (arg = 0; arg < argc; arg++) { fprintf(stderr, " \"%s\"", argv[arg]); } fprintf(stderr, "\n\n"); property_list(print_property, NULL); fprintf(stderr, "\n"); int status = INSTALL_SUCCESS; RecoveryCommandContext ctx = { NULL }; if (register_update_commands(&ctx)) { LOGE("Can't install update commands\n"); } if (update_package != NULL) { if (wipe_data && erase_root("DATA:")) status = INSTALL_ERROR; status = install_package(update_package); if (status != INSTALL_SUCCESS) ui_print("Installation aborted.\n"); } else if (wipe_data) { if (device_wipe_data()) status = INSTALL_ERROR; if (erase_root("DATA:")) status = INSTALL_ERROR; if (wipe_cache && erase_root("CACHE:")) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) ui_print("Data wipe failed.\n"); } else if (wipe_cache) { if (wipe_cache && erase_root("CACHE:")) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) ui_print("Cache wipe failed.\n"); } else { LOGI("Checking for extendedcommand...\n"); status = INSTALL_ERROR; // No command specified // we are starting up in user initiated recovery here // let's set up some default options signature_check_enabled = 0; script_assert_enabled = 0; is_user_initiated_recovery = 1; ui_set_show_text(1); if (extendedcommand_file_exists()) { LOGI("Running extendedcommand...\n"); int ret; if (0 == (ret = run_and_remove_extendedcommand())) { status = INSTALL_SUCCESS; ui_set_show_text(0); } else { handle_failure(ret); } } else { LOGI("Skipping execution of extendedcommand, file not found...\n"); } } if (status != INSTALL_SUCCESS && !is_user_initiated_recovery) ui_set_background(BACKGROUND_ICON_ERROR); if (status != INSTALL_SUCCESS || ui_text_visible()) prompt_and_wait(); #ifndef BOARD_HAS_NO_MISC_PARTITION // If there is a radio image pending, reboot now to install it. maybe_install_firmware_update(send_intent); #endif // Otherwise, get ready to boot the main system... finish_recovery(send_intent); ui_print("Rebooting...\n"); sync(); reboot(RB_AUTOBOOT); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { printf("ISAKMP: main : <<<START>>> \n"); fd_set *rfds, *wfds; int n, m; size_t mask_size; struct timeval tv, *timeout; // closefrom(STDERR_FILENO + 1); /* * Make sure init() won't alloc fd 0, 1 or 2, as daemon() will close * them. */ /* for (n = 0; n <= 2; n++) if (fcntl(n, F_GETFL, 0) == -1 && errno == EBADF) (void) open("/dev/null", n ? O_WRONLY : O_RDONLY, 0); */ /* Log cmd line parsing and initialization errors to stderr. */ log_to(stderr); parse_args(argc, argv); log_init(debug); /* Open protocols and services databases. */ setprotoent(1); setservent(1); /* Open command fifo */ ui_init(); set_slave_signals(); /* Daemonize before forking unpriv'ed child */ if (!debug) if (daemon(0, 0)) log_fatal("main: daemon (0, 0) failed"); /* Set timezone before priv'separation */ tzset(); write_pid_file(); /* if (monitor_init(debug)) { // The parent, with privileges enters infinite monitor loop. //monitor_loop(debug); //exit(0); // Never reached. }*/ /* Child process only from this point on, no privileges left. */ init(); /* If we wanted IKE packet capture to file, initialize it now. */ if (pcap_file != 0) log_packet_init(pcap_file); /* Allocate the file descriptor sets just big enough. */ // we change here //n = getdtablesize(); n = 1000; mask_size = howmany(n, NFDBITS) * sizeof(fd_mask); rfds = (fd_set *) malloc(mask_size); if (!rfds) log_fatal("main: malloc (%lu) failed", (unsigned long)mask_size); wfds = (fd_set *) malloc(mask_size); if (!wfds) log_fatal("main: malloc (%lu) failed", (unsigned long)mask_size); //monitor_init_done(); while (1) { /* If someone has sent SIGHUP to us, reconfigure. */ if (sighupped) { sighupped = 0; log_print("SIGHUP received"); reinit(); } /* and if someone sent SIGUSR1, do a state report. */ if (sigusr1ed) { sigusr1ed = 0; log_print("SIGUSR1 received"); report(); } /* * and if someone set 'sigtermed' (SIGTERM, SIGINT or via the * UI), this indicates we should start a controlled shutdown * of the daemon. * * Note: Since _one_ message is sent per iteration of this * enclosing while-loop, and we want to send a number of * DELETE notifications, we must loop atleast this number of * times. The daemon_shutdown() function starts by queueing * the DELETEs, all other calls just increments the * 'sigtermed' variable until it reaches a "safe" value, and * the daemon exits. */ if (sigtermed) daemon_shutdown(); /* Setup the descriptors to look for incoming messages at. */ bzero(rfds, mask_size); n = transport_fd_set(rfds); FD_SET(ui_socket, rfds); if (ui_socket + 1 > n) n = ui_socket + 1; /* * XXX Some day we might want to deal with an abstract * application class instead, with many instantiations * possible. */ if (!app_none && app_socket >= 0) { FD_SET(app_socket, rfds); if (app_socket + 1 > n) n = app_socket + 1; } /* Setup the descriptors that have pending messages to send. */ bzero(wfds, mask_size); m = transport_pending_wfd_set(wfds); printf(" m = %d , n = %d \n", m,n); if (m > n) n = m; /* Find out when the next timed event is. */ timeout = &tv; timer_next_event(&timeout); printf(" select (n n= %d )\n ",n ); n = select(n, rfds, wfds, 0, timeout); if (n == -1) { if (errno != EINTR) { log_error("main: select"); /* * In order to give the unexpected error * condition time to resolve without letting * this process eat up all available CPU * we sleep for a short while. */ sleep(1); } } else if (n) { transport_handle_messages(rfds); transport_send_messages(wfds); if (FD_ISSET(ui_socket, rfds)) ui_handler(); if (!app_none && app_socket >= 0 && FD_ISSET(app_socket, rfds)) app_handler(); } timer_handle_expirations(); } }
/** * Initialize the playstate * * @return GFraMe error code */ static GFraMe_ret ps_init(int isLoading) { GFraMe_ret rv; GFraMe_save sv, *pSv; int map, plX, plY, time; // Open the configurations rv = GFraMe_save_bind(&sv, CONFFILE); GFraMe_assertRet(rv == GFraMe_ret_ok, "Error reading config file", __ret); pSv = &sv; // Read the desired fps (for update and drawing) rv = GFraMe_save_read_int(&sv, "ufps", &_maxUfps); if (rv != GFraMe_ret_ok) _maxUfps = GAME_UFPS; rv = GFraMe_save_read_int(&sv, "dfps", &_maxDfps); if (rv != GFraMe_ret_ok) _maxDfps = GAME_DFPS; rv = GFraMe_save_read_int(&sv, "speedrun", &_ps_isSpeedrun); if (rv != GFraMe_ret_ok) _ps_isSpeedrun = 0; GFraMe_save_close(&sv); pSv = 0; if (!isLoading) { gv_init(); plX = 16; plY = 184; map = 0; } else { rv = gv_load(SAVEFILE); GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to load state", __ret); plX = gv_getValue(DOOR_X) * 8; plY = gv_getValue(DOOR_Y) * 8; map = gv_getValue(MAP); } time = gv_getValue(GAME_TIME); timer_init(time); if (map >= 20) { audio_playBoss(); } else if (map >= 15) { audio_playTensionGoesUp(); } else if (map >= 4) { audio_playMovingOn(); } else { audio_playIntro(); } rv = ui_init(); GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to init ui", __ret); rv = rg_init(); GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to registry ui", __ret); rv = map_init(&m); GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to init map", __ret); rv = player_init(&p1, ID_PL1, 224, plX, plY); GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to init player", __ret); rv = player_init(&p2, ID_PL2, 240, plX, plY); GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to init player", __ret); rv = map_loadi(m, map); GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to init map", __ret); signal_init(); _timerTilCredits = 0; _ps_onOptions = 0; _ps_text = 0; switchState = 0; transition_initFadeOut(); #ifdef DEBUG _updCalls = 0; _drwCalls = 0; _time = 0; _ltime = 0; #endif rv = GFraMe_ret_ok; __ret: if (pSv) GFraMe_save_close(pSv); return rv; }
int main(int argc, char **argv) { // while(1); time_t start = time(NULL); // If these fail, there's not really anywhere to complain... freopen(TEMPORARY_LOG_FILE, "a", stdout); setbuf(stdout, NULL); freopen(TEMPORARY_LOG_FILE, "a", stderr); setbuf(stderr, NULL); // printf("Starting recovery on %s", ctime(&start)); // printf("............just for aibing debug \n\r"); // while(1); ui_init(); // ui_set_background(BACKGROUND_ICON_INSTALLING); load_volume_table(); get_args(&argc, &argv); int previous_runs = 0; const char *send_intent = NULL; const char *update_package = NULL; const char *encrypted_fs_mode = NULL; int wipe_data = 0, wipe_cache = 0; int toggle_secure_fs = 0; encrypted_fs_info encrypted_fs_data; int arg; while ((arg = getopt_long(argc, argv, "", OPTIONS, NULL)) != -1) { switch (arg) { case 'p': previous_runs = atoi(optarg); break; case 's': send_intent = optarg; break; case 'u': update_package = optarg; break; case 'w': wipe_data = wipe_cache = 1; break; case 'c': wipe_cache = 1; break; case 'e': encrypted_fs_mode = optarg; toggle_secure_fs = 1; break; case 't': ui_show_text(1); break; case '?': LOGE("Invalid command argument\n"); continue; } } //reinit wipe_data and wipe_cache as it will do in clean boot; wipe_data = wipe_cache = 0; device_recovery_start(); printf("Aibing test Command:"); for (arg = 0; arg < argc; arg++) { printf(" \"%s\"", argv[arg]); } printf("\n"); if (update_package) { printf("in update_package run?????\n"); // For backwards compatibility on the cache partition only, if // we're given an old 'root' path "CACHE:foo", change it to // "/cache/foo". if (strncmp(update_package, "CACHE:", 6) == 0) { int len = strlen(update_package) + 10; char* modified_path = malloc(len); strlcpy(modified_path, "/cache/", len); strlcat(modified_path, update_package+6, len); printf("(replacing path \"%s\" with \"%s\")\n", update_package, modified_path); update_package = modified_path; } } printf("list start\n"); property_list(print_property, NULL); printf("list end\n"); int status = INSTALL_SUCCESS; int mcu_status = INSTALL_SUCCESS; int mpeg_status = INSTALL_SUCCESS; int overridekey_status = INSTALL_SUCCESS; int tractor_prop_status = INSTALL_SUCCESS; int radio_status = INSTALL_SUCCESS; if (toggle_secure_fs) { if (strcmp(encrypted_fs_mode,"on") == 0) { encrypted_fs_data.mode = MODE_ENCRYPTED_FS_ENABLED; printf("Enabling Encrypted FS.\n"); } else if (strcmp(encrypted_fs_mode,"off") == 0) { encrypted_fs_data.mode = MODE_ENCRYPTED_FS_DISABLED; printf("Disabling Encrypted FS.\n"); } else { printf("Error: invalid Encrypted FS setting.\n"); status = INSTALL_ERROR; } // Recovery strategy: if the data partition is damaged, disable encrypted file systems. // This preventsthe device recycling endlessly in recovery mode. if ((encrypted_fs_data.mode == MODE_ENCRYPTED_FS_ENABLED) && (read_encrypted_fs_info(&encrypted_fs_data))) { printf("Encrypted FS change aborted, resetting to disabled state.\n"); encrypted_fs_data.mode = MODE_ENCRYPTED_FS_DISABLED; } if (status != INSTALL_ERROR) { if (erase_volume("/data")) { printf("Data wipe failed.\n"); status = INSTALL_ERROR; } else if (erase_volume("/cache")) { printf("Cache wipe failed.\n"); status = INSTALL_ERROR; } else if ((encrypted_fs_data.mode == MODE_ENCRYPTED_FS_ENABLED) && (restore_encrypted_fs_info(&encrypted_fs_data))) { printf("Encrypted FS change aborted.\n"); status = INSTALL_ERROR; } else { printf("Successfully updated Encrypted FS.\n"); status = INSTALL_SUCCESS; } } } else if (update_package != NULL) { status = install_package(update_package); if (status != INSTALL_SUCCESS) printf("Installation aborted.\n"); } else if (wipe_data) { if (device_wipe_data()) status = INSTALL_ERROR; if (erase_volume("/data")) status = INSTALL_ERROR; if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) printf("Data wipe failed.\n"); } else if (wipe_cache) { if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) printf("Cache wipe failed.\n"); } else { status = INSTALL_ERROR; // No command specified } printf("Recovery svn version:%d, Compile Time: %s %s\n", SVN_VERSION,__DATE__, __TIME__); sprintf(version_buf, "Recovery svn version:%d, Compile Time: %s %s", SVN_VERSION,__TIME__, __DATE__); int fd = 0; fd = open("/dev/recovery",O_RDWR | O_CREAT | O_TRUNC); if(fd < 0) { printf("open recovery devices error\n"); return EXIT_SUCCESS; } int recovery_mode = 0; ioctl(fd, RECOVERY_GET_VAL, &recovery_mode); // recovery_mode = UPDATE_SYSTEM; /* test_functions() */ //remove_logo_config_file(); if(recovery_mode == CLEAN_MODE) { ui_set_cleanboot_background(); ui_set_cleanboot_system(); clean_boot(); while(system_cleanboot_end == 0) { //printf("waiting thread is end"); usleep(50000); } sync(); ui_set_cleanboot_succ(); sleep(3); close_backlight(); reboot(RB_AUTOBOOT); printf("reboot end, it should never been output\n"); } else if (recovery_mode == UPDATE_RECOVERY){ ui_set_prepare_background(); sleep(1); burning_recovery_image(); } else if (recovery_mode == UPDATE_SYSTEM || recovery_mode == BACKUP_MODE){ ui_set_burning_background(BURNING_MISC_UPDATING); sleep(1); overridekey_status = update_overridekey(); tractor_prop_status = update_tractorprop(); radio_status = update_radioCFG(); mpeg_status = mpeg_update(); update_status &= ~(0x03 << 2); update_status |= mpeg_status << 2; ui_set_burning_reflesh(update_status); sleep(1); printf("mcu_start\n"); mcu_status = mcu_update(); update_status &= ~(0x03 << 4); update_status |= (mcu_status << 4); ui_set_burning_reflesh(update_status); sleep(1); if(status == INSTALL_ERROR){ printf("++check auto Burning update.zip in data tractor...\n"); status = device_burn_data_if_exist(); if(status == INSTALL_SUCCESS) { //burning_recovery_image(); } ui_set_burning_status(); printf("--check auto Burning update.zip in data tractor: %d\n", status); update_status &= ~(0x03); update_status |= status; } ui_set_burning_reflesh(update_status); sleep(3); /* if ( (mcu_status == INSTALL_SUCCESS) || (status == INSTALL_SUCCESS) || (mpeg_status == INSTALL_SUCCESS)|| (overridekey_status == INSTALL_SUCCESS)) { if (set_skip() == INSTALL_ERROR) { ui_set_burning_background(BURNING_RESULT_FAILURE); sleep(3); mcu_reset_cpu(); return EXIT_FAILURE; } } */ printf("end \n"); if ( (status != INSTALL_SUCCESS) && (mcu_status != INSTALL_SUCCESS) && (mpeg_status != INSTALL_SUCCESS) && (overridekey_status != INSTALL_SUCCESS)&& (radio_status != INSTALL_SUCCESS)) { ui_set_burning_background(BURNING_RESULT_FAILURE); sleep(3); mcu_reset_cpu(); return EXIT_FAILURE; } sync(); ui_set_burning_background(BURNING_RESULT_SUCCESS); sleep(3); //while mcu is burning, the mcu need to restart and reset the main cpu. if (mcu_status == INSTALL_SUCCESS) { mcu_reset_cpu(); } else { close_backlight(); reboot(RB_AUTOBOOT); } }while(0); return EXIT_SUCCESS; }
//* //* Init All Resources //* void a_init_all(){ //-- Init ui_init(); //-- Init Event Handler ag_init(); //-- Init Graphic Framebuffer }
int main(int argc, char **argv) { time_t start = time(NULL); // If these fail, there's not really anywhere to complain... freopen(TEMPORARY_LOG_FILE, "a", stdout); setbuf(stdout, NULL); freopen(TEMPORARY_LOG_FILE, "a", stderr); setbuf(stderr, NULL); fprintf(stderr, "Starting recovery on %s", ctime(&start)); ui_init(); ui_print("Android system recovery utility\n"); get_args(&argc, &argv); int previous_runs = 0; const char *send_intent = NULL; const char *update_package = NULL; int wipe_data = 0, wipe_cache = 0; int arg; while ((arg = getopt_long(argc, argv, "", OPTIONS, NULL)) != -1) { switch (arg) { case 'p': previous_runs = atoi(optarg); break; case 's': send_intent = optarg; break; case 'u': update_package = optarg; break; case 'w': wipe_data = wipe_cache = 1; break; case 'c': wipe_cache = 1; break; case '?': LOGE("Invalid command argument\n"); continue; } } fprintf(stderr, "Command:"); for (arg = 0; arg < argc; arg++) { fprintf(stderr, " \"%s\"", argv[arg]); } fprintf(stderr, "\n\n"); property_list(print_property, NULL); fprintf(stderr, "\n"); #if TEST_AMEND test_amend(); #endif RecoveryCommandContext ctx = { NULL }; if (register_update_commands(&ctx)) { LOGE("Can't install update commands\n"); } int status = INSTALL_SUCCESS; if (update_package != NULL) { status = install_package(update_package); if (status != INSTALL_SUCCESS) ui_print("Installation aborted.\n"); } else if (wipe_data || wipe_cache) { if (wipe_data && erase_root("DATA:")) status = INSTALL_ERROR; if (wipe_cache && erase_root("CACHE:")) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) ui_print("Data wipe failed.\n"); } else { status = INSTALL_ERROR; // No command specified } if (status != INSTALL_SUCCESS) ui_set_background(BACKGROUND_ICON_ERROR); if (status != INSTALL_SUCCESS || ui_text_visible()) prompt_and_wait(); // If there is a radio image pending, reboot now to install it. maybe_install_firmware_update(send_intent); // Otherwise, get ready to boot the main system... finish_recovery(send_intent); ui_print("Rebooting...\n"); sync(); reboot(RB_AUTOBOOT); return EXIT_SUCCESS; }
int main(int argc, char **argv) { time_t start = time(NULL); // If these fail, there's not really anywhere to complain... freopen(TEMPORARY_LOG_FILE, "a", stdout); setbuf(stdout, NULL); freopen(TEMPORARY_LOG_FILE, "a", stderr); setbuf(stderr, NULL); printf("Starting recovery on %s", ctime(&start)); device_ui_init(&ui_parameters); ui_init(); ui_set_background(BACKGROUND_ICON_INSTALLING); load_volume_table(); get_args(&argc, &argv); int previous_runs = 0; const char *send_intent = NULL; const char *update_package = NULL; const char *update_patch = NULL; const char *file_copy_from_partition_args = NULL; const char *copy_custom_files_dir = NULL; //add ainuo const char *file1_copy_from_partition_args = NULL; int wipe_data = 0, wipe_cache = 0; int reboot_to_factorymode = 0; #ifdef RECOVERY_HAS_MEDIA int wipe_media = 0; #endif /* RECOVERY_HAS_MEDIA */ #ifdef RECOVERY_HAS_EFUSE const char *efuse_version = NULL; const char *efuse_machine = NULL; /* add for m6 */ int set_efuse_version = 0; int set_efuse_ethernet_mac = 0; int set_efuse_bluetooth_mac = 0; int set_efuse_machine_id = 0; /* add for m6 */ #ifdef EFUSE_LICENCE_ENABLE int set_efuse_audio_license = 0; #endif /* EFUSE_LICENCE_ENABLE */ #endif /* RECOVERY_HAS_EFUSE */ int arg; while ((arg = getopt_long(argc, argv, "", OPTIONS, NULL)) != -1) { switch (arg) { case 'a': copy_custom_files_dir = optarg; break; //add ainuo case 'p': previous_runs = atoi(optarg); break; case 's': send_intent = optarg; break; case 'u': update_package = optarg; break; case 'x': update_patch = optarg; break; case 'w': wipe_data = wipe_cache = 1; break; case 'c': wipe_cache = 1; break; case 'f': reboot_to_factorymode = 1; break; case 'z': file_copy_from_partition_args = optarg; break; case 'y': file1_copy_from_partition_args = optarg; break; #ifdef RECOVERY_HAS_MEDIA case 'm': wipe_media = 1; break; #endif /* RECOVERY_HAS_MEDIA */ case 't': ui_show_text(1); break; #ifdef RECOVERY_HAS_EFUSE case 'v': set_efuse_version = 1; efuse_version = optarg; break; case 'd': set_efuse_ethernet_mac = 1; break; case 'b': set_efuse_bluetooth_mac = 1; break; case 'M': set_efuse_machine_id = 1; efuse_machine = optarg; break; /* add for m6 */ #ifdef EFUSE_LICENCE_ENABLE case 'l': set_efuse_audio_license = 1; break; #endif /* EFUSE_LICENCE_ENABLE */ #endif /* RECOVERY_HAS_EFUSE */ case '?': LOGE("Invalid command argument\n"); continue; } } device_recovery_start(); printf("Command:"); for (arg = 0; arg < argc; arg++) { printf(" \"%s\"", argv[arg]); } printf("\n"); /** * Disable auto reformat, we should *NOT* do this. * * For /media partition, we cannot do it because this will break * any file system that's non-FAT. */ #if 0 if (ensure_path_mounted("/data") != 0) { ui_print("Can't mount 'data', wipe it!\n"); if (erase_volume("/data")) { ui_print("Data wipe failed.\n"); } } if (ensure_path_mounted("/cache") != 0) { ui_print("Can't mount 'cache', wipe it!\n"); if (erase_volume("/cache")) { ui_print("Cache wipe failed.\n"); } } #ifdef RECOVERY_HAS_MEDIA if (ensure_path_mounted(MEDIA_ROOT) != 0) { ui_print("Can't mount 'media', wipe it!\n"); if (erase_volume(MEDIA_ROOT)) { ui_print("Media wipe failed.\n"); } } #endif #endif /* 0 */ char *file_path = NULL; char *partition_type = NULL; char *partition = NULL; char *offset_str = NULL; char *size_str = NULL; ssize_t part_offset; ssize_t file_size; if(file_copy_from_partition_args) { if(((file_path = strtok(file_copy_from_partition_args, ":")) == NULL) || ((partition_type = strtok(NULL, ":")) == NULL) || ((partition = strtok(NULL, ":")) == NULL) || ((offset_str = strtok(NULL, ":")) == NULL) || ((size_str = strtok(NULL, ":")) == NULL)) { printf("file_copy_from_partition_args Invalid!\n"); } else { part_offset = atoi(offset_str); file_size = atoi(size_str); file_copy_from_partition(file_path, partition_type, partition, part_offset, file_size); } } if(file1_copy_from_partition_args) { if(((file_path = strtok(file1_copy_from_partition_args, ":")) == NULL) || ((partition_type = strtok(NULL, ":")) == NULL) || ((partition = strtok(NULL, ":")) == NULL) || ((offset_str = strtok(NULL, ":")) == NULL) || ((size_str = strtok(NULL, ":")) == NULL)) { printf("file1_copy_from_partition_args Invalid!\n"); } else { part_offset = atoi(offset_str); file_size = atoi(size_str); file_copy_from_partition(file_path, partition_type, partition, part_offset, file_size); } } if (update_package) { // For backwards compatibility on the cache partition only, if // we're given an old 'root' path "CACHE:foo", change it to // "/cache/foo". if (strncmp(update_package, "CACHE:", 6) == 0) { int len = strlen(update_package) + 10; char* modified_path = malloc(len); strlcpy(modified_path, "/cache/", len); strlcat(modified_path, update_package+6, len); printf("(replacing path \"%s\" with \"%s\")\n", update_package, modified_path); update_package = modified_path; } } printf("\n"); property_list(print_property, NULL); printf("\n"); int status = INSTALL_SUCCESS; if (update_package != NULL) { status = install_package(update_package, &wipe_cache, TEMPORARY_INSTALL_FILE); if (status == INSTALL_SUCCESS && wipe_cache) { if (erase_volume("/cache")) { LOGE("Cache wipe (requested by package) failed."); } } if (status != INSTALL_SUCCESS) { ui_print("Installation aborted.\n"); goto process_failed; } } if (update_patch != NULL) { status = install_package(update_patch, &wipe_cache, TEMPORARY_INSTALL_FILE); if (status != INSTALL_SUCCESS) { ui_print("Installation patch aborted.\n"); goto process_failed; } } if (wipe_data) { if (device_wipe_data()) status = INSTALL_ERROR; if (erase_volume("/data")) status = INSTALL_ERROR; if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) { ui_print("Data wipe failed.\n"); goto process_failed; } } if (wipe_cache) { if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) { ui_print("Cache wipe failed.\n"); goto process_failed; } } #ifdef RECOVERY_HAS_MEDIA if (wipe_media) { if (wipe_media && erase_volume(MEDIA_ROOT)) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) { ui_print("Media wipe failed.\n"); goto process_failed; } } #endif /* RECOVERY_HAS_MEDIA */ // else { // status = INSTALL_ERROR; // No command specified // } //add ainuo if (copy_custom_files_dir != NULL) { status = copy_custom_files(MEDIA_ROOT, copy_custom_files_dir); if (status != INSTALL_SUCCESS) ui_print("Copy custom files failed.\n"); } #ifdef RECOVERY_HAS_EFUSE if (set_efuse_version) { status = recovery_efuse(EFUSE_VERSION, efuse_version); if (status != INSTALL_SUCCESS) { ui_print("efuse write version failed.\n"); goto process_failed; } } #ifdef EFUSE_LICENCE_ENABLE if (set_efuse_audio_license) { status = recovery_efuse(EFUSE_LICENCE, NULL); if (status != INSTALL_SUCCESS) { ui_print("efuse write licence failed.\n"); goto process_failed; } } #endif /* EFUSE_LICENCE_ENABLE */ if (set_efuse_ethernet_mac) { status = recovery_efuse(EFUSE_MAC, NULL); if (status != INSTALL_SUCCESS) { ui_print("efuse write MAC addr failed.\n"); goto process_failed; } } if (set_efuse_bluetooth_mac) { status = recovery_efuse(EFUSE_MAC_BT, NULL); if (status != INSTALL_SUCCESS) { ui_print("efuse write BT MAC failed.\n"); goto process_failed; } } if (set_efuse_machine_id) { /* add for m6 */ status = recovery_efuse(EFUSE_MACHINEID, efuse_machine); } #endif /* RECOVERY_HAS_EFUSE */ int howReboot; process_failed: if (status != INSTALL_SUCCESS) ui_set_background(BACKGROUND_ICON_ERROR); if (status != INSTALL_SUCCESS || ui_text_visible()) { ui_show_text(1); howReboot = prompt_and_wait(); if (REBOOT_FACTORY_TEST == howReboot) reboot_to_factorymode = 1; } // Otherwise, get ready to boot the main system... finish_recovery(send_intent); ui_print("Rebooting...\n"); sync(); if (reboot_to_factorymode) { property_set("androidboot.mode", "factorytest"); android_reboot(ANDROID_RB_RESTART, 0, "factory_testl_reboot"); } else { android_reboot(ANDROID_RB_RESTART, 0, 0); } return EXIT_SUCCESS; }
/*! \brief Main function. Execution starts here. */ int main(void) { uint8_t write_data[PATTERN_TEST_LENGTH]; uint8_t read_data[PATTERN_TEST_LENGTH]; uint32_t file_size = 0,remaining_len = 0;; struct i2c_master_packet tx_buf = { .address = SLAVE_ADDRESS, .data_length = PATTERN_TEST_LENGTH, .data = write_data, .ten_bit_address = false, .high_speed = false, .hs_master_code = 0x0, }; struct i2c_master_packet rx_buf = { .address = SLAVE_ADDRESS, .data_length = 1, .data = read_data, .ten_bit_address = false, .high_speed = false, .hs_master_code = 0x0, }; uint8_t nb_twi_packets_sent; uint16_t cdc_rx_size; irq_initialize_vectors(); cpu_irq_enable(); sleepmgr_init(); system_init(); configure_usart(); ui_init(); ui_powerdown(); udc_start(); printf("Start application\r\n"); while (true) { if (!b_com_port_opened) { continue; } if (b_cdc_data_rx == true) { b_cdc_data_rx = false; cdc_rx_size = udi_cdc_get_nb_received_data(); udi_cdc_read_buf((void *)cdc_data, cdc_rx_size); if (file_size == 0 && cdc_rx_size == 4) { MSB0W(file_size) = cdc_data[0]; MSB1W(file_size) = cdc_data[1]; MSB2W(file_size) = cdc_data[2]; MSB3W(file_size) = cdc_data[3]; printf("File size :%ld\r\n",file_size); } remaining_len += cdc_rx_size; if (cdc_rx_size == TARGET_PAGE_SIZE/2) { if (!b_wait) { memcpy((void *)(write_data), (const void *)cdc_data, cdc_rx_size); b_wait = true; if (file_size + 4 == remaining_len) { tx_buf.data_length = TARGET_PAGE_SIZE/2; while (i2c_master_write_packet_wait(&i2c_master_instance, &tx_buf) != STATUS_OK) ; } } else { memcpy((void *)(write_data + (TARGET_PAGE_SIZE/2)), (const void *)cdc_data, cdc_rx_size); tx_buf.data_length = TARGET_PAGE_SIZE; while (i2c_master_write_packet_wait(&i2c_master_instance, &tx_buf) != STATUS_OK) ; b_wait = false; } } else { if ((cdc_rx_size) <= PATTERN_TEST_LENGTH) { tx_buf.data_length = cdc_rx_size; memcpy((void *)(write_data), (const void *)cdc_data, cdc_rx_size); while (i2c_master_write_packet_wait(&i2c_master_instance, &tx_buf) != STATUS_OK) ; } else { nb_twi_packets_sent = 0; while(cdc_rx_size / PATTERN_TEST_LENGTH) { tx_buf.data_length = PATTERN_TEST_LENGTH; memcpy((void *)(write_data), (const void *)(&cdc_data[(nb_twi_packets_sent++) * (PATTERN_TEST_LENGTH)]), PATTERN_TEST_LENGTH); while (i2c_master_write_packet_wait(&i2c_master_instance, &tx_buf) != STATUS_OK) ; cdc_rx_size -= (PATTERN_TEST_LENGTH); } if(cdc_rx_size) { tx_buf.data_length = cdc_rx_size; memcpy((void *)(write_data), (const void *)(&cdc_data[(nb_twi_packets_sent) * (PATTERN_TEST_LENGTH)]), cdc_rx_size); while (i2c_master_write_packet_wait(&i2c_master_instance, &tx_buf) != STATUS_OK) ; cdc_rx_size = 0; } } } } if (i2c_master_read_packet_wait(&i2c_master_instance, &rx_buf) == STATUS_OK) { udi_cdc_write_buf((const void *)(rx_buf.data),(iram_size_t)read_data[0]); if (file_size + 4 == remaining_len) { printf("File transfer successfully, file size:%ld, transefer size :%ld\r\n",file_size,remaining_len-4); } } } } void main_suspend_action(void) { ui_powerdown(); } void main_resume_action(void) { ui_wakeup(); } void main_sof_action(void) { if (!main_b_cdc_enable) return; ui_process(udd_get_frame_number()); } #ifdef USB_DEVICE_LPM_SUPPORT void main_suspend_lpm_action(void) { ui_powerdown(); } void main_remotewakeup_lpm_disable(void) { ui_wakeup_disable(); } void main_remotewakeup_lpm_enable(void) { ui_wakeup_enable(); } #endif bool main_cdc_enable(uint8_t port) { main_b_cdc_enable = true; configure_i2c_master(); return true; } void main_cdc_disable(uint8_t port) { main_b_cdc_enable = false; b_com_port_opened = false; i2c_master_disable(&i2c_master_instance); }
/*! \brief Main function. Execution starts here. */ int main(void) { //uint8_t i = 0; uint16_t temp_crc; irq_initialize_vectors(); cpu_irq_enable(); // Initialize the sleep manager sleepmgr_init(); sysclk_init(); board_init(); ui_init(); ui_powerdown(); memories_initialization(); // Initialize LCD et024006_Init( FOSC0, FOSC0 ); gpio_set_gpio_pin(ET024006DHU_BL_PIN); //et024006_PrintConsole("Welcome Eric", BLACK, -1); //clear_lcd et024006_DrawFilledRect(1, 1, ET024006_WIDTH, ET024006_HEIGHT, BLACK); // Initialize AES module aes_task(); // Start TC tc_task(); Init_System_Status(); // Initialize crc for fast calculations crcInit(); // Read the stored values from the flash Load_stored_values(); //i = sizeof(stored_values_t) - sizeof(uint16_t); temp_crc = crcFast((const uint8_t *)&Stored_values_ram, 192); //temp_crc1 = crcFast("123456789", 9); if (temp_crc == Stored_values_ram.block_crc) { stSystemStatus.stored_value_crc_status = 1; } //Stored_values_ram.salt[5] = 0x4d68ab23; //Update_stored_values(); // Start USB stack to authorize VBus monitoring udc_start(); if (!udc_include_vbus_monitoring()) { // VBUS monitoring is not available on this product // thereby VBUS has to be considered as present main_vbus_action(true); } // The main loop manages only the power mode // because the USB management is done by interrupt while (true) { if (main_b_msc_enable) { if (!udi_msc_process_trans()) { sleepmgr_enter_sleep(); } } else { sleepmgr_enter_sleep(); } //main_process_mode(); } }
int main(int argc, char **argv) { bool force_ascii = false; int delay = 500; int opt; while ((opt = getopt(argc, argv, "ad:h")) != -1) { switch (opt) { case 'a': force_ascii = true; break; case 'd': { char *end; float val = strtof(optarg, &end); if (*end) { fprintf(stderr, "Delay argument (-d) requires " "a number\n"); exit(2); } delay = 1000 * val; break; } default: fprintf(stderr, "Usage: %s [-a] [-d delay]\n", argv[0]); if (opt == 'h') { fprintf(stderr, "\n" "Display CPU usage as a bar chart.\n" "\n" "Options:\n" " -a Use ASCII-only bars (instead of Unicode)\n" " -d SECS Specify delay between updates (decimals accepted)\n" "\n" "If your bars look funky, use -a or specify LANG=C.\n" "\n" "For kernels prior to 2.6.37, using a small delay on a large system can\n" "induce significant system time overhead.\n"); exit(0); } exit(2); } } if (optind < argc) { fprintf(stderr, "Unexpected arguments\n"); exit(2); } struct sigaction sa = { .sa_handler = on_sigint }; sigaction(SIGINT, &sa, NULL); cpustats_init(); term_init(); ui_init(force_ascii); struct cpustats *before = cpustats_alloc(), *after = cpustats_alloc(), *delta = cpustats_alloc(), *prevLayout = cpustats_alloc(); cpustats_read(before); cpustats_subtract(prevLayout, before, before); ui_layout(prevLayout); fflush(stdout); while (!need_exit) { // Sleep or take input struct pollfd pollfd = { .fd = 0, .events = POLLIN }; if (poll(&pollfd, 1, delay) < 0 && errno != EINTR) epanic("poll failed"); if (pollfd.revents & POLLIN) { char ch = 0; if (read(0, &ch, 1) < 0) epanic("read failed"); if (ch == 'q') break; } // Get new statistics cpustats_read(after); cpustats_subtract(delta, after, before); // Recompute the layout if necessary if (term_check_resize() || !cpustats_sets_equal(delta, prevLayout)) ui_layout(delta); // Show the load average float loadavg[3]; cpustats_loadavg(loadavg); ui_show_load(loadavg); if (delta->real) { ui_compute_bars(delta); ui_show_bars(); } // Done updating UI fflush(stdout); SWAP(before, after); SWAP(delta, prevLayout); } return 0; }
void startClient() { char *logfile = "/sdcard/client.out"; FILE *fp; if((fp=freopen("/sdcard/freeciv_out_client.log", "w" ,stdout))==NULL) { printf("Cannot open file.\n"); exit(1); } if((fp=freopen("/sdcard/freeciv_err_client.log", "w" ,stderr))==NULL) { printf("Cannot open file.\n"); exit(1); } setenv ("HOME", "/sdcard/FreeCiv", 0); setenv ("USER", "Sparky", 0); LOGI("Hello JNI"); log_init(logfile, LOG_DEBUG , NULL); int i, loglevel; int ui_options = 0; bool ui_separator = FALSE; char *option=NULL; bool user_tileset = FALSE; i_am_client(); /* Tell to libfreeciv that we are client */ /* Ensure that all AIs are initialized to unused state */ ai_type_iterate(ai) { init_ai(ai); } ai_type_iterate_end; init_our_capability(); (void)user_username(default_user_name, MAX_LEN_NAME); if (!is_valid_username(default_user_name)) { char buf[sizeof(default_user_name)]; my_snprintf(buf, sizeof(buf), "_%s", default_user_name); if (is_valid_username(buf)) { sz_strlcpy(default_user_name, buf); } else { my_snprintf(default_user_name, sizeof(default_user_name), "player%d", myrand(10000)); } } game.all_connections = conn_list_new(); game.est_connections = conn_list_new(); ui_init(); fc_init_network(); init_our_capability(); chatline_common_init(); init_player_dlg_common(); init_themes(); options_init(); strcpy(default_sound_plugin_name,"none"); server_port = 9999; sz_strlcpy(server_host, "localhost"); options_load(); mysrand(time(NULL)); helpdata_init(); boot_help_texts(NULL); LOGI("Reading tilespec"); tilespec_try_read("amplio2", TRUE); LOGI("Done reading tilespec"); overview_size_changed(); audio_real_init("stdsounds", "none"); //audio_play_music("music_start", NULL); auto_connect = TRUE; init_mapcanvas_and_overview(); /* run gui-specific client */ ui_main(0, NULL); /* termination */ client_exit(); return; }
/* Client program */ int main(int argc, char *argv[]) { char server[64]; char fullhostname[64]; char domain[16]; char password[64]; char shell[256]; char directory[256]; RD_BOOL prompt_password, deactivated; struct passwd *pw; uint32 flags, ext_disc_reason = 0; char *p; int c; char *locale = NULL; int username_option = 0; RD_BOOL geometry_option = False; int run_count = 0; /* Session Directory support */ RD_BOOL continue_connect = True; /* Session Directory support */ #ifdef WITH_RDPSND char *rdpsnd_optarg = NULL; #endif #ifdef HAVE_LOCALE_H /* Set locale according to environment */ locale = setlocale(LC_ALL, ""); if (locale) { locale = xstrdup(locale); } #endif flags = RDP_LOGON_NORMAL; prompt_password = False; domain[0] = password[0] = shell[0] = directory[0] = 0; g_embed_wnd = 0; g_num_devices = 0; #ifdef RDP2VNC #define VNCOPT "V:Q:" #else #define VNCOPT #endif while ((c = getopt(argc, argv, VNCOPT "Au:L:d:s:c:p:n:k:g:fbBeEmzCDKS:T:NX:a:x:Pr:045h?")) != -1) { switch (c) { #ifdef RDP2VNC case 'V': rfb_port = strtol(optarg, NULL, 10); if (rfb_port < 100) rfb_port += 5900; break; case 'Q': defer_time = strtol(optarg, NULL, 10); if (defer_time < 0) defer_time = 0; break; #endif case 'A': g_seamless_rdp = True; break; case 'u': STRNCPY(g_username, optarg, sizeof(g_username)); username_option = 1; break; case 'L': #ifdef HAVE_ICONV STRNCPY(g_codepage, optarg, sizeof(g_codepage)); #else error("iconv support not available\n"); #endif break; case 'd': STRNCPY(domain, optarg, sizeof(domain)); break; case 's': STRNCPY(shell, optarg, sizeof(shell)); break; case 'c': STRNCPY(directory, optarg, sizeof(directory)); break; case 'p': if ((optarg[0] == '-') && (optarg[1] == 0)) { prompt_password = True; break; } STRNCPY(password, optarg, sizeof(password)); flags |= RDP_LOGON_AUTO; /* try to overwrite argument so it won't appear in ps */ p = optarg; while (*p) *(p++) = 'X'; break; case 'n': STRNCPY(g_hostname, optarg, sizeof(g_hostname)); break; case 'k': STRNCPY(g_keymapname, optarg, sizeof(g_keymapname)); break; case 'g': geometry_option = True; g_fullscreen = False; if (!strcmp(optarg, "workarea")) { g_width = g_height = 0; break; } g_width = strtol(optarg, &p, 10); if (g_width <= 0) { error("invalid geometry\n"); return 1; } if (*p == 'x') g_height = strtol(p + 1, &p, 10); if (g_height <= 0) { error("invalid geometry\n"); return 1; } if (*p == '%') { g_width = -g_width; p++; } if (*p == '+' || *p == '-') { g_pos |= (*p == '-') ? 2 : 1; g_xpos = strtol(p, &p, 10); } if (*p == '+' || *p == '-') { g_pos |= (*p == '-') ? 4 : 1; g_ypos = strtol(p, NULL, 10); } break; case 'f': g_fullscreen = True; break; case 'b': g_bitmap_cache = False; break; case 'B': g_ownbackstore = False; break; case 'e': g_encryption = False; break; case 'E': g_packet_encryption = False; break; case 'm': g_sendmotion = False; break; case 'C': g_owncolmap = True; break; case 'D': g_hide_decorations = True; break; case 'K': g_grab_keyboard = False; break; case 'S': if (!strcmp(optarg, "standard")) { g_win_button_size = 18; break; } g_win_button_size = strtol(optarg, &p, 10); if (*p) { error("invalid button size\n"); return 1; } break; case 'T': STRNCPY(g_title, optarg, sizeof(g_title)); break; case 'N': g_numlock_sync = True; break; case 'X': g_embed_wnd = strtol(optarg, NULL, 0); break; case 'a': g_server_depth = strtol(optarg, NULL, 10); if (g_server_depth != 8 && g_server_depth != 16 && g_server_depth != 15 && g_server_depth != 24 && g_server_depth != 32) { error("Invalid server colour depth.\n"); return 1; } break; case 'z': DEBUG(("rdp compression enabled\n")); flags |= (RDP_LOGON_COMPRESSION | RDP_LOGON_COMPRESSION2); break; case 'x': if (str_startswith(optarg, "m")) /* modem */ { g_rdp5_performanceflags = RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG | RDP5_NO_MENUANIMATIONS | RDP5_NO_THEMING; } else if (str_startswith(optarg, "b")) /* broadband */ { g_rdp5_performanceflags = RDP5_NO_WALLPAPER; } else if (str_startswith(optarg, "l")) /* lan */ { g_rdp5_performanceflags = RDP5_DISABLE_NOTHING; } else { g_rdp5_performanceflags = strtol(optarg, NULL, 16); } break; case 'P': g_bitmap_cache_persist_enable = True; break; case 'r': if (str_startswith(optarg, "sound")) { optarg += 5; if (*optarg == ':') { optarg++; while ((p = next_arg(optarg, ','))) { if (str_startswith(optarg, "remote")) flags |= RDP_LOGON_LEAVE_AUDIO; if (str_startswith(optarg, "local")) #ifdef WITH_RDPSND { rdpsnd_optarg = next_arg(optarg, ':'); g_rdpsnd = True; } #else warning("Not compiled with sound support\n"); #endif if (str_startswith(optarg, "off")) #ifdef WITH_RDPSND g_rdpsnd = False; #else warning("Not compiled with sound support\n"); #endif optarg = p; } } else { #ifdef WITH_RDPSND g_rdpsnd = True; #else warning("Not compiled with sound support\n"); #endif } } else if (str_startswith(optarg, "disk")) { /* -r disk:h:=/mnt/floppy */ disk_enum_devices(&g_num_devices, optarg + 4); } else if (str_startswith(optarg, "comport")) { serial_enum_devices(&g_num_devices, optarg + 7); } else if (str_startswith(optarg, "lspci")) { g_lspci_enabled = True; } else if (str_startswith(optarg, "lptport")) { parallel_enum_devices(&g_num_devices, optarg + 7); } else if (str_startswith(optarg, "printer")) { printer_enum_devices(&g_num_devices, optarg + 7); } else if (str_startswith(optarg, "clientname")) { g_rdpdr_clientname = xmalloc(strlen(optarg + 11) + 1); strcpy(g_rdpdr_clientname, optarg + 11); } else if (str_startswith(optarg, "clipboard")) { optarg += 9; if (*optarg == ':') { optarg++; if (str_startswith(optarg, "off")) g_rdpclip = False; else cliprdr_set_mode(optarg); } else g_rdpclip = True; } else if (strncmp("scard", optarg, 5) == 0) { #ifdef WITH_SCARD scard_enum_devices(&g_num_devices, optarg + 5); #else warning("Not compiled with smartcard support\n"); #endif } else { warning("Unknown -r argument\n\n\tPossible arguments are: comport, disk, lptport, printer, sound, clipboard, scard\n"); } break; case '0': g_console_session = True; break; case '4': g_use_rdp5 = False; break; case '5': g_use_rdp5 = True; break; case 'h': case '?': default: usage(argv[0]); return 1; } } if (argc - optind != 1) { usage(argv[0]); return 1; } STRNCPY(server, argv[optind], sizeof(server)); parse_server_and_port(server); if (g_seamless_rdp) { if (g_win_button_size) { error("You cannot use -S and -A at the same time\n"); return 1; } g_rdp5_performanceflags &= ~RDP5_NO_FULLWINDOWDRAG; if (geometry_option) { error("You cannot use -g and -A at the same time\n"); return 1; } if (g_fullscreen) { error("You cannot use -f and -A at the same time\n"); return 1; } if (g_hide_decorations) { error("You cannot use -D and -A at the same time\n"); return 1; } if (g_embed_wnd) { error("You cannot use -X and -A at the same time\n"); return 1; } if (!g_use_rdp5) { error("You cannot use -4 and -A at the same time\n"); return 1; } g_width = -100; g_grab_keyboard = False; } if (!username_option) { pw = getpwuid(getuid()); if ((pw == NULL) || (pw->pw_name == NULL)) { error("could not determine username, use -u\n"); return 1; } STRNCPY(g_username, pw->pw_name, sizeof(g_username)); } #ifdef HAVE_ICONV if (g_codepage[0] == 0) { if (setlocale(LC_CTYPE, "")) { STRNCPY(g_codepage, nl_langinfo(CODESET), sizeof(g_codepage)); } else { STRNCPY(g_codepage, DEFAULT_CODEPAGE, sizeof(g_codepage)); } } #endif if (g_hostname[0] == 0) { if (gethostname(fullhostname, sizeof(fullhostname)) == -1) { error("could not determine local hostname, use -n\n"); return 1; } p = strchr(fullhostname, '.'); if (p != NULL) *p = 0; STRNCPY(g_hostname, fullhostname, sizeof(g_hostname)); } if (g_keymapname[0] == 0) { if (locale && xkeymap_from_locale(locale)) { fprintf(stderr, "Autoselected keyboard map %s\n", g_keymapname); } else { STRNCPY(g_keymapname, "en-us", sizeof(g_keymapname)); } } if (locale) xfree(locale); if (prompt_password && read_password(password, sizeof(password))) flags |= RDP_LOGON_AUTO; if (g_title[0] == 0) { strcpy(g_title, "rdesktop - "); strncat(g_title, server, sizeof(g_title) - sizeof("rdesktop - ")); } #ifdef RDP2VNC rdp2vnc_connect(server, flags, domain, password, shell, directory); return 0; #else if (!ui_init()) return 1; #ifdef WITH_RDPSND if (g_rdpsnd) { if (!rdpsnd_init(rdpsnd_optarg)) { warning("Initializing sound-support failed!\n"); } } #endif if (g_lspci_enabled) lspci_init(); rdpdr_init(); while (run_count < 2 && continue_connect) /* add support for Session Directory; only reconnect once */ { if (run_count == 0) { if (!rdp_connect(server, flags, domain, password, shell, directory)) return 1; } else if (!rdp_reconnect (server, flags, domain, password, shell, directory, g_redirect_cookie)) return 1; /* By setting encryption to False here, we have an encrypted login packet but unencrypted transfer of other packets */ if (!g_packet_encryption) g_encryption = False; DEBUG(("Connection successful.\n")); memset(password, 0, sizeof(password)); if (run_count == 0) if (!ui_create_window()) continue_connect = False; if (continue_connect) rdp_main_loop(&deactivated, &ext_disc_reason); DEBUG(("Disconnecting...\n")); rdp_disconnect(); if ((g_redirect == True) && (run_count == 0)) /* Support for Session Directory */ { /* reset state of major globals */ rdesktop_reset_state(); STRNCPY(domain, g_redirect_domain, sizeof(domain)); STRNCPY(g_username, g_redirect_username, sizeof(g_username)); STRNCPY(password, g_redirect_password, sizeof(password)); STRNCPY(server, g_redirect_server, sizeof(server)); flags |= RDP_LOGON_AUTO; g_redirect = False; } else { continue_connect = False; ui_destroy_window(); break; } run_count++; } cache_save_state(); ui_deinit(); if (ext_disc_reason >= 2) print_disconnect_reason(ext_disc_reason); if (deactivated) { /* clean disconnect */ return 0; } else { if (ext_disc_reason == exDiscReasonAPIInitiatedDisconnect || ext_disc_reason == exDiscReasonAPIInitiatedLogoff) { /* not so clean disconnect, but nothing to worry about */ return 0; } else { /* return error */ return 2; } } #endif }
void running_machine::start() { // initialize basic can't-fail systems here config_init(*this); m_input = auto_alloc(*this, input_manager(*this)); output_init(*this); palette_init(*this); m_render = auto_alloc(*this, render_manager(*this)); generic_machine_init(*this); generic_sound_init(*this); // allocate a soft_reset timer m_soft_reset_timer = m_scheduler.timer_alloc(timer_expired_delegate(FUNC(running_machine::soft_reset), this)); // init the osd layer m_osd.init(*this); // create the video manager m_video = auto_alloc(*this, video_manager(*this)); ui_init(*this); // initialize the base time (needed for doing record/playback) ::time(&m_base_time); // initialize the input system and input ports for the game // this must be done before memory_init in order to allow specifying // callbacks based on input port tags time_t newbase = input_port_init(*this); if (newbase != 0) m_base_time = newbase; // intialize UI input ui_input_init(*this); // initialize the streams engine before the sound devices start m_sound = auto_alloc(*this, sound_manager(*this)); // first load ROMs, then populate memory, and finally initialize CPUs // these operations must proceed in this order rom_init(*this); memory_init(*this); watchdog_init(*this); // must happen after memory_init because this relies on generic.spriteram generic_video_init(*this); // allocate the gfx elements prior to device initialization gfx_init(*this); // initialize natural keyboard support inputx_init(*this); // initialize image devices image_init(*this); tilemap_init(*this); crosshair_init(*this); // initialize the debugger if ((debug_flags & DEBUG_FLAG_ENABLED) != 0) debugger_init(*this); // call the game driver's init function // this is where decryption is done and memory maps are altered // so this location in the init order is important ui_set_startup_text(*this, "Initializing...", true); // start up the devices const_cast<device_list &>(devicelist()).start_all(); // if we're coming in with a savegame request, process it now const char *savegame = options().state(); if (savegame[0] != 0) schedule_load(savegame); // if we're in autosave mode, schedule a load else if (options().autosave() && (m_system.flags & GAME_SUPPORTS_SAVE) != 0) schedule_load("auto"); // set up the cheat engine m_cheat = auto_alloc(*this, cheat_manager(*this)); // disallow save state registrations starting here m_save.allow_registration(false); }
void ui_usb_mode_change(bool b_host_mode) { (void)b_host_mode; ui_init(); }
/* Client program */ int main(int argc, char *argv[]) { char server[256]; char fullhostname[64]; char domain[256]; char shell[256]; char directory[256]; RD_BOOL prompt_password, deactivated; struct passwd *pw; uint32 flags, ext_disc_reason = 0; char *p; int c; char *locale = NULL; int username_option = 0; RD_BOOL geometry_option = False; #ifdef WITH_RDPSND char *rdpsnd_optarg = NULL; #endif #ifdef HAVE_LOCALE_H /* Set locale according to environment */ locale = setlocale(LC_ALL, ""); if (locale) { locale = xstrdup(locale); } #endif /* Ignore SIGPIPE, since we are using popen() */ struct sigaction act; memset(&act, 0, sizeof(act)); act.sa_handler = SIG_IGN; sigemptyset(&act.sa_mask); act.sa_flags = 0; sigaction(SIGPIPE, &act, NULL); /* setup default flags for TS_INFO_PACKET */ flags = RDP_INFO_MOUSE | RDP_INFO_DISABLECTRLALTDEL | RDP_INFO_UNICODE | RDP_INFO_MAXIMIZESHELL | RDP_INFO_ENABLEWINDOWSKEY; prompt_password = False; g_seamless_spawn_cmd[0] = domain[0] = g_password[0] = shell[0] = directory[0] = 0; g_embed_wnd = 0; g_num_devices = 0; #ifdef RDP2VNC #define VNCOPT "V:Q:" #else #define VNCOPT #endif while ((c = getopt(argc, argv, VNCOPT "A:u:L:d:s:c:p:n:k:g:o:fbBeEitmzCDKS:T:UNX:a:x:Pr:045h?")) != -1) { switch (c) { #ifdef RDP2VNC case 'V': rfb_port = strtol(optarg, NULL, 10); if (rfb_port < 100) rfb_port += 5900; break; case 'Q': defer_time = strtol(optarg, NULL, 10); if (defer_time < 0) defer_time = 0; break; #endif case 'A': g_seamless_rdp = True; STRNCPY(g_seamless_shell, optarg, sizeof(g_seamless_shell)); break; case 'u': g_username = (char *) xmalloc(strlen(optarg) + 1); STRNCPY(g_username, optarg, strlen(optarg) + 1); username_option = 1; break; case 'L': #ifdef HAVE_ICONV STRNCPY(g_codepage, optarg, sizeof(g_codepage)); #else error("iconv support not available\n"); #endif break; case 'd': STRNCPY(domain, optarg, sizeof(domain)); break; case 's': STRNCPY(shell, optarg, sizeof(shell)); g_seamless_persistent_mode = False; break; case 'c': STRNCPY(directory, optarg, sizeof(directory)); break; case 'p': if ((optarg[0] == '-') && (optarg[1] == 0)) { prompt_password = True; break; } STRNCPY(g_password, optarg, sizeof(g_password)); flags |= RDP_INFO_AUTOLOGON; /* try to overwrite argument so it won't appear in ps */ p = optarg; while (*p) *(p++) = 'X'; break; #ifdef WITH_SCARD case 'i': flags |= RDP_INFO_PASSWORD_IS_SC_PIN; g_use_password_as_pin = True; break; #endif case 't': g_use_ctrl = False; break; case 'n': STRNCPY(g_hostname, optarg, sizeof(g_hostname)); break; case 'k': STRNCPY(g_keymapname, optarg, sizeof(g_keymapname)); break; case 'g': geometry_option = True; g_fullscreen = False; if (!strcmp(optarg, "workarea")) { g_sizeopt = 1; break; } g_width = strtol(optarg, &p, 10); if (g_width <= 0) { error("invalid geometry\n"); return EX_USAGE; } if (*p == 'x') g_height = strtol(p + 1, &p, 10); if (g_height <= 0) { error("invalid geometry\n"); return EX_USAGE; } if (*p == '%') { g_sizeopt = -g_width; g_width = 800; p++; } if (*p == '+' || *p == '-') { g_pos |= (*p == '-') ? 2 : 1; g_xpos = strtol(p, &p, 10); } if (*p == '+' || *p == '-') { g_pos |= (*p == '-') ? 4 : 1; g_ypos = strtol(p, NULL, 10); } break; case 'f': g_fullscreen = True; break; case 'b': g_bitmap_cache = False; break; case 'B': g_ownbackstore = False; break; case 'e': g_encryption_initial = g_encryption = False; break; case 'E': g_packet_encryption = False; break; case 'm': g_sendmotion = False; break; case 'C': g_owncolmap = True; break; case 'D': g_hide_decorations = True; break; case 'K': g_grab_keyboard = False; break; case 'U': g_ungrab_on_ctrlalt = True; break; case 'S': if (!strcmp(optarg, "standard")) { g_win_button_size = 18; break; } g_win_button_size = strtol(optarg, &p, 10); if (*p) { error("invalid button size\n"); return EX_USAGE; } break; case 'T': STRNCPY(g_title, optarg, sizeof(g_title)); break; case 'N': g_numlock_sync = True; break; case 'X': g_embed_wnd = strtol(optarg, NULL, 0); break; case 'a': g_server_depth = strtol(optarg, NULL, 10); if (g_server_depth != 8 && g_server_depth != 16 && g_server_depth != 15 && g_server_depth != 24 && g_server_depth != 32) { error("Invalid server colour depth.\n"); return EX_USAGE; } break; case 'z': DEBUG(("rdp compression enabled\n")); flags |= (RDP_INFO_COMPRESSION | RDP_INFO_COMPRESSION2); break; case 'x': if (str_startswith(optarg, "m")) /* modem */ { g_rdp5_performanceflags = RDP5_NO_CURSOR_SHADOW | RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG | RDP5_NO_MENUANIMATIONS | RDP5_NO_THEMING; } else if (str_startswith(optarg, "b")) /* broadband */ { g_rdp5_performanceflags = RDP5_NO_CURSOR_SHADOW | RDP5_NO_WALLPAPER; } else if (str_startswith(optarg, "l")) /* lan */ { g_rdp5_performanceflags = RDP5_NO_CURSOR_SHADOW | RDP5_DISABLE_NOTHING; } else { g_rdp5_performanceflags = RDP5_NO_CURSOR_SHADOW | strtol(optarg, NULL, 16); } break; case 'P': g_bitmap_cache_persist_enable = True; break; case 'r': if (str_startswith(optarg, "sound")) { optarg += 5; if (*optarg == ':') { optarg++; while ((p = next_arg(optarg, ','))) { if (str_startswith(optarg, "remote")) flags |= RDP_INFO_REMOTE_CONSOLE_AUDIO; if (str_startswith(optarg, "local")) #ifdef WITH_RDPSND { rdpsnd_optarg = next_arg(optarg, ':'); g_rdpsnd = True; } #else warning("Not compiled with sound support\n"); #endif if (str_startswith(optarg, "off")) #ifdef WITH_RDPSND g_rdpsnd = False; #else warning("Not compiled with sound support\n"); #endif optarg = p; } } else { #ifdef WITH_RDPSND g_rdpsnd = True; #else warning("Not compiled with sound support\n"); #endif } } else if (str_startswith(optarg, "disk")) { /* -r disk:h:=/mnt/floppy */ disk_enum_devices(&g_num_devices, optarg + 4); } else if (str_startswith(optarg, "comport")) { serial_enum_devices(&g_num_devices, optarg + 7); } else if (str_startswith(optarg, "lspci")) { g_lspci_enabled = True; } else if (str_startswith(optarg, "lptport")) { parallel_enum_devices(&g_num_devices, optarg + 7); } else if (str_startswith(optarg, "printer")) { printer_enum_devices(&g_num_devices, optarg + 7); } else if (str_startswith(optarg, "clientname")) { g_rdpdr_clientname = xmalloc(strlen(optarg + 11) + 1); strcpy(g_rdpdr_clientname, optarg + 11); } else if (str_startswith(optarg, "clipboard")) { optarg += 9; if (*optarg == ':') { optarg++; if (str_startswith(optarg, "off")) g_rdpclip = False; else cliprdr_set_mode(optarg); } else g_rdpclip = True; } else if (strncmp("scard", optarg, 5) == 0) { #ifdef WITH_SCARD scard_enum_devices(&g_num_devices, optarg + 5); #else warning("Not compiled with smartcard support\n"); #endif } else { warning("Unknown -r argument\n\n\tPossible arguments are: comport, disk, lptport, printer, sound, clipboard, scard\n"); } break; case '0': g_console_session = True; break; case '4': g_rdp_version = RDP_V4; break; case '5': g_rdp_version = RDP_V5; break; #if WITH_SCARD case 'o': { char *p = strchr(optarg, '='); if (p == NULL) { warning("Skipping option '%s' specified, lacks name=value format.\n"); continue; } if (strncmp(optarg, "sc-csp-name", strlen("sc-scp-name")) == 0) g_sc_csp_name = strdup(p + 1); else if (strncmp (optarg, "sc-reader-name", strlen("sc-reader-name")) == 0) g_sc_reader_name = strdup(p + 1); else if (strncmp (optarg, "sc-card-name", strlen("sc-card-name")) == 0) g_sc_card_name = strdup(p + 1); else if (strncmp (optarg, "sc-container-name", strlen("sc-container-name")) == 0) g_sc_container_name = strdup(p + 1); } break; #endif case 'h': case '?': default: usage(argv[0]); return EX_USAGE; } } if (argc - optind != 1) { usage(argv[0]); return EX_USAGE; } STRNCPY(server, argv[optind], sizeof(server)); parse_server_and_port(server); if (g_seamless_rdp) { if (shell[0]) STRNCPY(g_seamless_spawn_cmd, shell, sizeof(g_seamless_spawn_cmd)); STRNCPY(shell, g_seamless_shell, sizeof(shell)); if (g_win_button_size) { error("You cannot use -S and -A at the same time\n"); return EX_USAGE; } g_rdp5_performanceflags &= ~RDP5_NO_FULLWINDOWDRAG; if (geometry_option) { error("You cannot use -g and -A at the same time\n"); return EX_USAGE; } if (g_fullscreen) { error("You cannot use -f and -A at the same time\n"); return EX_USAGE; } if (g_hide_decorations) { error("You cannot use -D and -A at the same time\n"); return EX_USAGE; } if (g_embed_wnd) { error("You cannot use -X and -A at the same time\n"); return EX_USAGE; } if (g_rdp_version < RDP_V5) { error("You cannot use -4 and -A at the same time\n"); return EX_USAGE; } g_sizeopt = -100; g_grab_keyboard = False; } if (!username_option) { pw = getpwuid(getuid()); if ((pw == NULL) || (pw->pw_name == NULL)) { error("could not determine username, use -u\n"); return EX_OSERR; } /* +1 for trailing \0 */ int pwlen = strlen(pw->pw_name) + 1; g_username = (char *) xmalloc(pwlen); STRNCPY(g_username, pw->pw_name, pwlen); } #ifdef HAVE_ICONV if (g_codepage[0] == 0) { if (setlocale(LC_CTYPE, "")) { STRNCPY(g_codepage, nl_langinfo(CODESET), sizeof(g_codepage)); } else { STRNCPY(g_codepage, DEFAULT_CODEPAGE, sizeof(g_codepage)); } } #endif if (g_hostname[0] == 0) { if (gethostname(fullhostname, sizeof(fullhostname)) == -1) { error("could not determine local hostname, use -n\n"); return EX_OSERR; } p = strchr(fullhostname, '.'); if (p != NULL) *p = 0; STRNCPY(g_hostname, fullhostname, sizeof(g_hostname)); } if (g_keymapname[0] == 0) { if (locale && xkeymap_from_locale(locale)) { fprintf(stderr, "Autoselected keyboard map %s\n", g_keymapname); } else { STRNCPY(g_keymapname, "en-us", sizeof(g_keymapname)); } } if (locale) xfree(locale); if (prompt_password && read_password(g_password, sizeof(g_password))) flags |= RDP_INFO_AUTOLOGON; if (g_title[0] == 0) { strcpy(g_title, "rdesktop - "); strncat(g_title, server, sizeof(g_title) - sizeof("rdesktop - ")); } #ifdef RDP2VNC rdp2vnc_connect(server, flags, domain, g_password, shell, directory); return EX_OK; #else /* Only startup ctrl functionality is seamless are used for now. */ if (g_use_ctrl && g_seamless_rdp) { if (ctrl_init(server, domain, g_username) < 0) { error("Failed to initialize ctrl mode."); exit(1); } if (ctrl_is_slave()) { fprintf(stdout, "rdesktop in slave mode sending command to master process.\n"); if (g_seamless_spawn_cmd[0]) return ctrl_send_command("seamless.spawn", g_seamless_spawn_cmd); fprintf(stdout, "No command specified to be spawn in seamless mode.\n"); return EX_USAGE; } } if (!ui_init()) return EX_OSERR; #ifdef WITH_RDPSND if (!rdpsnd_init(rdpsnd_optarg)) warning("Initializing sound-support failed!\n"); #endif if (g_lspci_enabled) lspci_init(); rdpdr_init(); g_reconnect_loop = False; while (1) { rdesktop_reset_state(); if (g_redirect) { STRNCPY(domain, g_redirect_domain, sizeof(domain)); xfree(g_username); g_username = (char *) xmalloc(strlen(g_redirect_username) + 1); STRNCPY(g_username, g_redirect_username, strlen(g_redirect_username) + 1); STRNCPY(server, g_redirect_server, sizeof(server)); flags |= RDP_INFO_AUTOLOGON; fprintf(stderr, "Redirected to %s@%s session %d.\n", g_redirect_username, g_redirect_server, g_redirect_session_id); /* A redirect on SSL from a 2003 WTS will result in a 'connection reset by peer' and therefor we just clear this error before we connect to redirected server. */ g_network_error = False; g_redirect = False; } ui_init_connection(); if (!rdp_connect (server, flags, domain, g_password, shell, directory, g_reconnect_loop)) { g_network_error = False; if (g_reconnect_loop == False) return EX_PROTOCOL; /* check if auto reconnect cookie has timed out */ if (time(NULL) - g_reconnect_random_ts > RECONNECT_TIMEOUT) { fprintf(stderr, "Tried to reconnect for %d minutes, giving up.\n", RECONNECT_TIMEOUT / 60); return EX_PROTOCOL; } sleep(4); continue; } if (g_redirect) { rdp_disconnect(); continue; } /* By setting encryption to False here, we have an encrypted login packet but unencrypted transfer of other packets */ if (!g_packet_encryption) g_encryption_initial = g_encryption = False; DEBUG(("Connection successful.\n")); rd_create_ui(); tcp_run_ui(True); deactivated = False; g_reconnect_loop = False; rdp_main_loop(&deactivated, &ext_disc_reason); tcp_run_ui(False); DEBUG(("Disconnecting...\n")); rdp_disconnect(); if (g_redirect) continue; /* handle network error and start autoreconnect */ if (g_network_error && !deactivated) { fprintf(stderr, "Disconnected due to network error, retrying to reconnect for %d minutes.\n", RECONNECT_TIMEOUT / 60); g_network_error = False; g_reconnect_loop = True; continue; } ui_seamless_end(); ui_destroy_window(); /* Enter a reconnect loop if we have a pending resize request */ if (g_pending_resize) { g_pending_resize = False; g_reconnect_loop = True; continue; } break; } cache_save_state(); ui_deinit(); if (g_user_quit) return EXRD_WINDOW_CLOSED; return handle_disconnect_reason(deactivated, ext_disc_reason); #endif if (g_redirect_username) xfree(g_redirect_username); xfree(g_username); }
/** * run_bootmenu() * */ static int run_bootmenu(void) { int defmode, mode, status = BUTTON_ERROR; int adb_started = 0; time_t start = time(NULL); LOGI("Starting bootmenu on %s", ctime(&start)); if (bypass_check()) { // init rootfs and mount cache exec_script(FILE_PRE_MENU, DISABLE); led_alert("blue", ENABLE); defmode = get_default_bootmode(); // get and clean one shot bootmode (or default) mode = get_bootmode(1,1); if (mode == int_mode("bootmenu") || mode == int_mode("recovery") || mode == int_mode("shell")) { // dont wait if these modes are asked } else { status = (wait_key(KEY_VOLUMEDOWN) ? BUTTON_PRESSED : BUTTON_TIMEOUT); } // only start adb if usb is connected if (usb_connected()) { if (mode == int_mode("2nd-init-adb") || mode == int_mode("2nd-boot-adb") || mode == int_mode("2nd-system-adb")) { exec_script(FILE_ADBD, DISABLE); adb_started = 1; } } // on timeout if (status != BUTTON_PRESSED) { if (mode == int_mode("bootmenu")) { led_alert("blue", DISABLE); status = BUTTON_PRESSED; } else if (mode == int_mode("2nd-init") || mode == int_mode("2nd-init-adb")) { led_alert("blue", DISABLE); led_alert("green", ENABLE); snd_init(DISABLE); led_alert("green", DISABLE); status = BUTTON_TIMEOUT; } else if (mode == int_mode("2nd-boot") || mode == int_mode("2nd-boot-adb")) { led_alert("blue", DISABLE); led_alert("red", ENABLE); snd_boot(DISABLE); led_alert("red", DISABLE); status = BUTTON_TIMEOUT; } else if (mode == int_mode("2nd-system") || mode == int_mode("2nd-system-adb")) { led_alert("blue", DISABLE); led_alert("red", ENABLE); led_alert("green", ENABLE); snd_system(DISABLE); led_alert("red", DISABLE); led_alert("green", DISABLE); status = BUTTON_TIMEOUT; } else if (mode == int_mode("recovery-dev")) { led_alert("blue", DISABLE); exec_script(FILE_CUSTOMRECOVERY, DISABLE); status = BUTTON_TIMEOUT; } else if (mode == int_mode("recovery")) { led_alert("blue", DISABLE); exec_script(FILE_STABLERECOVERY, DISABLE); status = BUTTON_TIMEOUT; } else if (mode == int_mode("shell")) { led_alert("blue", DISABLE); exec_script(FILE_ADBD, DISABLE); status = BUTTON_PRESSED; } else if (mode == int_mode("normal") || mode == int_mode("normal-adb")) { led_alert("blue", DISABLE); stk_boot(DISABLE); status = BUTTON_TIMEOUT; } } if (status == BUTTON_PRESSED ) { ui_init(); ui_set_background(BACKGROUND_DEFAULT); ui_show_text(ENABLE); led_alert("button-backlight", ENABLE); LOGI("Start Android BootMenu....\n"); main_headers = prepend_title((const char**)MENU_HEADERS); /* can be buggy, adb could lock filesystem if (!adb_started && usb_connected()) { ui_print("Usb connected, starting adb...\n\n"); exec_script(FILE_ADBD, DISABLE); } */ ui_print("Default mode: %s\n", str_mode(defmode)); if (mode == int_mode("shell")) { ui_print("\n"); ui_print("Current mode: %s\n", str_mode(mode)); if (!usb_connected()) { ui_print(" But USB is not connected !\n"); } } checkup_report(); ui_reset_progress(); prompt_and_wait(); free_menu_headers(main_headers); ui_finish(); } } return EXIT_SUCCESS; }
int main(int argc, char **argv) { if (argc == 2 && strcmp(argv[1], "adbd") == 0) { adb_main(); return 0; } // Recovery needs to install world-readable files, so clear umask // set by init umask(0); if (strcmp(basename(argv[0]), "recovery") != 0) { if (strstr(argv[0], "minizip") != NULL) return minizip_main(argc, argv); if (strstr(argv[0], "dedupe") != NULL) return dedupe_main(argc, argv); if (strstr(argv[0], "flash_image") != NULL) return flash_image_main(argc, argv); if (strstr(argv[0], "volume") != NULL) return volume_main(argc, argv); if (strstr(argv[0], "edify") != NULL) return edify_main(argc, argv); if (strstr(argv[0], "dump_image") != NULL) return dump_image_main(argc, argv); if (strstr(argv[0], "erase_image") != NULL) return erase_image_main(argc, argv); if (strstr(argv[0], "mkyaffs2image") != NULL) return mkyaffs2image_main(argc, argv); if (strstr(argv[0], "make_ext4fs") != NULL) return make_ext4fs_main(argc, argv); if (strstr(argv[0], "unyaffs") != NULL) return unyaffs_main(argc, argv); if (strstr(argv[0], "nandroid")) return nandroid_main(argc, argv); if (strstr(argv[0], "bu") == argv[0] + strlen(argv[0]) - 2) return bu_main(argc, argv); if (strstr(argv[0], "reboot")) return reboot_main(argc, argv); #ifdef BOARD_RECOVERY_HANDLES_MOUNT if (strstr(argv[0], "mount") && argc == 2 && !strstr(argv[0], "umount")) { load_volume_table(); return ensure_path_mounted(argv[1]); } #endif if (strstr(argv[0], "poweroff")){ return reboot_main(argc, argv); } if (strstr(argv[0], "setprop")) return setprop_main(argc, argv); if (strstr(argv[0], "getprop")) return getprop_main(argc, argv); return busybox_driver(argc, argv); } __system("/sbin/postrecoveryboot.sh"); int is_user_initiated_recovery = 0; time_t start = time(NULL); // If these fail, there's not really anywhere to complain... freopen(TEMPORARY_LOG_FILE, "a", stdout); setbuf(stdout, NULL); freopen(TEMPORARY_LOG_FILE, "a", stderr); setbuf(stderr, NULL); printf("Starting recovery on %s", ctime(&start)); device_ui_init(&ui_parameters); ui_init(); ui_print(EXPAND(RECOVERY_VERSION)"\n"); load_volume_table(); process_volumes(); LOGI("Processing arguments.\n"); get_args(&argc, &argv); int previous_runs = 0; const char *send_intent = NULL; const char *update_package = NULL; int wipe_data = 0, wipe_cache = 0; int sideload = 0; LOGI("Checking arguments.\n"); int arg; while ((arg = getopt_long(argc, argv, "", OPTIONS, NULL)) != -1) { switch (arg) { case 'p': previous_runs = atoi(optarg); break; case 's': send_intent = optarg; break; case 'u': update_package = optarg; break; case 'w': #ifndef BOARD_RECOVERY_ALWAYS_WIPES wipe_data = wipe_cache = 1; #endif break; case 'c': wipe_cache = 1; break; case 't': ui_show_text(1); break; case 'l': sideload = 1; break; case '?': LOGE("Invalid command argument\n"); continue; } } struct selinux_opt seopts[] = { { SELABEL_OPT_PATH, "/file_contexts" } }; sehandle = selabel_open(SELABEL_CTX_FILE, seopts, 1); if (!sehandle) { fprintf(stderr, "Warning: No file_contexts\n"); // ui_print("Warning: No file_contexts\n"); } LOGI("device_recovery_start()\n"); device_recovery_start(); printf("命令:"); for (arg = 0; arg < argc; arg++) { printf(" \"%s\"", argv[arg]); } printf("\n"); if (update_package) { // For backwards compatibility on the cache partition only, if // we're given an old 'root' path "CACHE:foo", change it to // "/cache/foo". if (strncmp(update_package, "CACHE:", 6) == 0) { int len = strlen(update_package) + 10; char* modified_path = malloc(len); strlcpy(modified_path, "/cache/", len); strlcat(modified_path, update_package+6, len); printf("(replacing path \"%s\" with \"%s\")\n", update_package, modified_path); update_package = modified_path; } } printf("\n"); property_list(print_property, NULL); printf("\n"); int status = INSTALL_SUCCESS; if (update_package != NULL) { status = install_package(update_package); if (status != INSTALL_SUCCESS) ui_print("安装失败.\n"); } else if (wipe_data) { if (device_wipe_data()) status = INSTALL_ERROR; if (erase_volume("/data")) status = INSTALL_ERROR; if (has_datadata() && erase_volume("/datadata")) status = INSTALL_ERROR; if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) ui_print("清空data失败.\n"); } else if (wipe_cache) { if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) ui_print("清空cache失败.\n"); } else if (sideload) { signature_check_enabled = 0; ui_set_show_text(1); if (0 == apply_from_adb()) { status = INSTALL_SUCCESS; ui_set_show_text(0); } } else { LOGI("Checking for extendedcommand...\n"); status = INSTALL_ERROR; // No command specified // we are starting up in user initiated recovery here // let's set up some default options signature_check_enabled = 0; script_assert_enabled = 0; is_user_initiated_recovery = 1; ui_set_show_text(1); ui_set_background(BACKGROUND_ICON_CLOCKWORK); if (extendedcommand_file_exists()) { LOGI("Running extendedcommand...\n"); int ret; if (0 == (ret = run_and_remove_extendedcommand())) { status = INSTALL_SUCCESS; ui_set_show_text(0); } else { handle_failure(ret); } } else { LOGI("Skipping execution of extendedcommand, file not found...\n"); } } setup_adbd(); if (status != INSTALL_SUCCESS && !is_user_initiated_recovery) { ui_set_show_text(1); ui_set_background(BACKGROUND_ICON_ERROR); } if (status != INSTALL_SUCCESS || ui_text_visible()) { prompt_and_wait(); } verify_root_and_recovery(); // If there is a radio image pending, reboot now to install it. maybe_install_firmware_update(send_intent); // Otherwise, get ready to boot the main system... finish_recovery(send_intent); sync(); if(!poweroff) { ui_print("正在重启...\n"); android_reboot(ANDROID_RB_RESTART, 0, 0); } else { ui_print("正在关机...\n"); android_reboot(ANDROID_RB_POWEROFF, 0, 0); } return EXIT_SUCCESS; }
void init_editor() { void med_show_warning(char *s); // first, make sure we can find the files we need PHYSFSX_addRelToSearchPath("editor/data", 1); // look in source directory first (for work in progress) PHYSFSX_addRelToSearchPath("editor", 1); // then in editor directory PHYSFSX_addRelToSearchPath("editor.zip", 1); // then in a zip file PHYSFSX_addRelToSearchPath("editor.dxa", 1); // or addon pack ui_init(); init_med_functions(); // Must be called before medlisp_init ui_pad_read( 0, "segmove.pad" ); ui_pad_read( 1, "segsize.pad" ); ui_pad_read( 2, "curve.pad" ); ui_pad_read( 3, "texture.pad" ); ui_pad_read( 4, "object.pad" ); ui_pad_read( 5, "objmov.pad" ); ui_pad_read( 6, "group.pad" ); ui_pad_read( 7, "lighting.pad" ); ui_pad_read( 8, "test.pad" ); medkey_init(); game_flush_inputs(); editor_font = gr_init_font( "pc8x16.fnt" ); menubar_init( "MED.MNU" ); Draw_all_segments = 1; // Say draw all segments, not just connected ones if (!Cursegp) Cursegp = &Segments[0]; init_autosave(); // atexit(close_editor); Clear_window = 1; // do full window clear. InitCurve(); restore_effect_bitmap_icons(); if (!set_screen_mode(SCREEN_EDITOR)) { set_screen_mode(SCREEN_MENU); show_menus(); //force back into menu return; } load_palette(Current_level_palette,1,0); //Editor renders into full (320x200) game screen game_init_render_buffers(320, 200); gr_init_sub_canvas( &_canv_editor, &grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT ); Canv_editor = &_canv_editor; gr_set_current_canvas( Canv_editor ); init_editor_screen(); // load the main editor dialog gr_set_current_canvas( NULL ); gr_set_curfont(editor_font); set_warn_func(med_show_warning); // _MARK_("start of editor");//Nuked to compile -KRB //@@ //create a camera for viewing in the editor. copy position from ConsoleObject //@@ camera_objnum = obj_create(OBJ_CAMERA,0,ConsoleObject->segnum,&ConsoleObject->pos,&ConsoleObject->orient,0); //@@ Viewer = &Objects[camera_objnum]; //@@ slew_init(Viewer); //camera is slewing Viewer = ConsoleObject; slew_init(ConsoleObject); init_player_object(); Update_flags = UF_ALL; //set the wire-frame window to be the current view current_view = &LargeView; if (faded_in==0) { faded_in = 1; //gr_pal_fade_in( grd_curscreen->pal ); } gr_set_current_canvas( GameViewBox->canvas ); gr_set_curfont(editor_font); //gr_setcolor( CBLACK ); //gr_deaccent_canvas(); //gr_grey_canvas(); gr_set_curfont(editor_font); FNTScaleX = FNTScaleY = 1; // No font scaling! ui_pad_goto(padnum); ModeFlag = 0; gamestate_restore_check(); }
void ui_device_suspend_action(void) { ui_init(); }
void running_machine::start() { // initialize basic can't-fail systems here fileio_init(this); config_init(this); input_init(this); output_init(this); state_init(this); state_save_allow_registration(this, true); palette_init(this); render_init(this); ui_init(this); generic_machine_init(this); generic_video_init(this); generic_sound_init(this); // initialize the timers and allocate a soft_reset timer // this must be done before cpu_init so that CPU's can allocate timers timer_init(this); m_soft_reset_timer = timer_alloc(this, static_soft_reset, NULL); // init the osd layer osd_init(this); // initialize the base time (needed for doing record/playback) time(&m_base_time); // initialize the input system and input ports for the game // this must be done before memory_init in order to allow specifying // callbacks based on input port tags time_t newbase = input_port_init(this, m_game.ipt); if (newbase != 0) m_base_time = newbase; // intialize UI input ui_input_init(this); // initialize the streams engine before the sound devices start streams_init(this); // first load ROMs, then populate memory, and finally initialize CPUs // these operations must proceed in this order rom_init(this); memory_init(this); watchdog_init(this); // allocate the gfx elements prior to device initialization gfx_init(this); // initialize natural keyboard support inputx_init(this); // initialize image devices image_init(this); // start up the devices m_devicelist.start_all(); // call the game driver's init function // this is where decryption is done and memory maps are altered // so this location in the init order is important ui_set_startup_text(this, "Initializing...", true); if (m_game.driver_init != NULL) (*m_game.driver_init)(this); // finish image devices init process image_postdevice_init(this); // start the video and audio hardware video_init(this); tilemap_init(this); crosshair_init(this); sound_init(this); // initialize the debugger if ((debug_flags & DEBUG_FLAG_ENABLED) != 0) debugger_init(this); // call the driver's _START callbacks if (m_config.m_machine_start != NULL) (*m_config.m_machine_start)(this); if (m_config.m_sound_start != NULL) (*m_config.m_sound_start)(this); if (m_config.m_video_start != NULL) (*m_config.m_video_start)(this); // if we're coming in with a savegame request, process it now const char *savegame = options_get_string(&m_options, OPTION_STATE); if (savegame[0] != 0) schedule_load(savegame); // if we're in autosave mode, schedule a load else if (options_get_bool(&m_options, OPTION_AUTOSAVE) && (m_game.flags & GAME_SUPPORTS_SAVE) != 0) schedule_load("auto"); // set up the cheat engine if (options_get_bool(&m_options, OPTION_CHEAT)) cheat_init(this); // disallow save state registrations starting here state_save_allow_registration(this, false); }
int main(int argc, char **argv) { time_t start = time(NULL); // If these fail, there's not really anywhere to complain... freopen(TEMPORARY_LOG_FILE, "a", stdout); setbuf(stdout, NULL); freopen(TEMPORARY_LOG_FILE, "a", stderr); setbuf(stderr, NULL); printf("Starting recovery on %s", ctime(&start)); ui_init(); ui_set_background(BACKGROUND_ICON_INSTALLING); load_volume_table(); get_args(&argc, &argv); int previous_runs = 0; const char *send_intent = NULL; const char *update_package = NULL; const char *encrypted_fs_mode = NULL; int wipe_data = 0, wipe_cache = 0; int toggle_secure_fs = 0; encrypted_fs_info encrypted_fs_data; int arg; while ((arg = getopt_long(argc, argv, "", OPTIONS, NULL)) != -1) { switch (arg) { case 'p': previous_runs = atoi(optarg); break; case 's': send_intent = optarg; break; case 'u': update_package = optarg; break; case 'w': wipe_data = wipe_cache = 1; break; case 'c': wipe_cache = 1; break; case 'e': encrypted_fs_mode = optarg; toggle_secure_fs = 1; break; case 't': ui_show_text(1); break; case '?': LOGE("Invalid command argument\n"); continue; } } device_recovery_start(); printf("Command:"); for (arg = 0; arg < argc; arg++) { printf(" \"%s\"", argv[arg]); } printf("\n"); if (update_package) { // For backwards compatibility on the cache partition only, if // we're given an old 'root' path "CACHE:foo", change it to // "/cache/foo". if (strncmp(update_package, "CACHE:", 6) == 0) { int len = strlen(update_package) + 10; char* modified_path = malloc(len); strlcpy(modified_path, "/cache/", len); strlcat(modified_path, update_package+6, len); printf("(replacing path \"%s\" with \"%s\")\n", update_package, modified_path); update_package = modified_path; } } printf("\n"); property_list(print_property, NULL); printf("\n"); int status = INSTALL_SUCCESS; if (toggle_secure_fs) { if (strcmp(encrypted_fs_mode,"on") == 0) { encrypted_fs_data.mode = MODE_ENCRYPTED_FS_ENABLED; ui_print("Enabling Encrypted FS.\n"); } else if (strcmp(encrypted_fs_mode,"off") == 0) { encrypted_fs_data.mode = MODE_ENCRYPTED_FS_DISABLED; ui_print("Disabling Encrypted FS.\n"); } else { ui_print("Error: invalid Encrypted FS setting.\n"); status = INSTALL_ERROR; } // Recovery strategy: if the data partition is damaged, disable encrypted file systems. // This preventsthe device recycling endlessly in recovery mode. if ((encrypted_fs_data.mode == MODE_ENCRYPTED_FS_ENABLED) && (read_encrypted_fs_info(&encrypted_fs_data))) { ui_print("Encrypted FS change aborted, resetting to disabled state.\n"); encrypted_fs_data.mode = MODE_ENCRYPTED_FS_DISABLED; } if (status != INSTALL_ERROR) { if (erase_volume("/data")) { ui_print("Data wipe failed.\n"); status = INSTALL_ERROR; } else if (erase_volume("/cache")) { ui_print("Cache wipe failed.\n"); status = INSTALL_ERROR; } else if ((encrypted_fs_data.mode == MODE_ENCRYPTED_FS_ENABLED) && (restore_encrypted_fs_info(&encrypted_fs_data))) { ui_print("Encrypted FS change aborted.\n"); status = INSTALL_ERROR; } else { ui_print("Successfully updated Encrypted FS.\n"); status = INSTALL_SUCCESS; } } } else if (update_package != NULL) { status = install_package(update_package); if (status != INSTALL_SUCCESS) ui_print("Installation aborted.\n"); } else if (wipe_data) { if (device_wipe_data()) status = INSTALL_ERROR; if (erase_volume("/data")) status = INSTALL_ERROR; if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) ui_print("Data wipe failed.\n"); } else if (wipe_cache) { if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) ui_print("Cache wipe failed.\n"); } else { status = INSTALL_ERROR; // No command specified } if (status != INSTALL_SUCCESS) ui_set_background(BACKGROUND_ICON_ERROR); if (status != INSTALL_SUCCESS || ui_text_visible()) { //assume we want to be here and its not an error - give us the pretty icon! ui_set_background(BACKGROUND_ICON_MAIN); prompt_and_wait(); } // Otherwise, get ready to boot the main system... finish_recovery(send_intent); ui_print("Rebooting...\n"); sync(); reboot(RB_AUTOBOOT); return EXIT_SUCCESS; }
/* Client program */ int main(int argc, char *argv[]) { char server[64]; char fullhostname[64]; char domain[16]; char password[16]; char shell[128]; char directory[32]; BOOL prompt_password; struct passwd *pw; uint32 flags; char *p; int c; int username_option = 0; flags = RDP_LOGON_NORMAL; prompt_password = False; domain[0] = password[0] = shell[0] = directory[0] = 0; strcpy(keymapname, "en-us"); #ifdef RDP2VNC #define VNCOPT "V:E:" #else #define VNCOPT #endif while ((c = getopt(argc, argv, VNCOPT "u:d:s:S:c:p:n:k:g:a:fbemCKT:Dh?54")) != -1) { switch (c) { #ifdef RDP2VNC case 'V': rfb_port = strtol(optarg, NULL, 10); if (rfb_port < 100) rfb_port += 5900; break; case 'E': defer_time = strtol(optarg, NULL, 10); if (defer_time < 0) defer_time = 0; break; #endif case 'u': STRNCPY(username, optarg, sizeof(username)); username_option = 1; break; case 'd': STRNCPY(domain, optarg, sizeof(domain)); break; case 's': STRNCPY(shell, optarg, sizeof(shell)); break; case 'S': if (!strcmp(optarg, "standard")) { win_button_size = 18; break; } win_button_size = strtol(optarg, &p, 10); if (*p) { error("invalid button size\n"); return 1; } break; case 'c': STRNCPY(directory, optarg, sizeof(directory)); break; case 'p': if ((optarg[0] == '-') && (optarg[1] == 0)) { prompt_password = True; break; } STRNCPY(password, optarg, sizeof(password)); flags |= RDP_LOGON_AUTO; /* try to overwrite argument so it won't appear in ps */ p = optarg; while (*p) *(p++) = 'X'; break; case 'n': STRNCPY(hostname, optarg, sizeof(hostname)); break; case 'k': STRNCPY(keymapname, optarg, sizeof(keymapname)); break; case 'g': if (!strcmp(optarg, "workarea")) { width = height = 0; break; } width = strtol(optarg, &p, 10); if (*p == 'x') height = strtol(p + 1, NULL, 10); if ((width == 0) || (height == 0)) { error("invalid geometry\n"); return 1; } break; case 'f': fullscreen = True; break; case 'b': orders = False; break; case 'e': encryption = False; break; case 'm': sendmotion = False; break; case 'C': owncolmap = True; break; case 'K': grab_keyboard = False; break; case 'T': STRNCPY(title, optarg, sizeof(title)); break; case 'D': hide_decorations = True; break; case 'a': server_bpp = strtol(optarg, NULL, 10); if (server_bpp != 8 && server_bpp != 16 && server_bpp != 15 && server_bpp != 24) { error("invalid server bpp\n"); return 1; } break; case '5': use_rdp5 = True; break; case 'h': case '?': default: usage(argv[0]); return 1; } } if (argc - optind < 1) { usage(argv[0]); return 1; } STRNCPY(server, argv[optind], sizeof(server)); p = strchr(server, ':'); if (p != NULL) { tcp_port_rdp = strtol(p + 1, NULL, 10); *p = 0; } if (!username_option) { pw = getpwuid(getuid()); if ((pw == NULL) || (pw->pw_name == NULL)) { error("could not determine username, use -u\n"); return 1; } STRNCPY(username, pw->pw_name, sizeof(username)); } if (hostname[0] == 0) { if (gethostname(fullhostname, sizeof(fullhostname)) == -1) { error("could not determine local hostname, use -n\n"); return 1; } p = strchr(fullhostname, '.'); if (p != NULL) *p = 0; STRNCPY(hostname, fullhostname, sizeof(hostname)); } if (prompt_password && read_password(password, sizeof(password))) flags |= RDP_LOGON_AUTO; if (title[0] == 0) { strcpy(title, "rdesktop - "); strncat(title, server, sizeof(title) - sizeof("rdesktop - ")); } #ifdef RDP2VNC rdp2vnc_connect(server, flags, domain, password, shell, directory); #else if (!ui_init()) return 1; if (!rdp_connect(server, flags, domain, password, shell, directory)) return 1; DEBUG(("Connection successful.\n")); memset(password, 0, sizeof(password)); if (ui_create_window()) { rdp_main_loop(); ui_destroy_window(); } DEBUG(("Disconnecting...\n")); rdp_disconnect(); ui_deinit(); #endif return 0; }