static void conf_save(void) { int stat; while (1) { cprint_init(); cprint("--inputbox"); cprint(save_config_text); cprint("11"); cprint("55"); cprint("%s", filename); stat = exec_conf(); switch(stat) { case 0: if (!input_buf[0]) return; if (!conf_write(input_buf)) return; show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60); break; case 1: show_helptext("Save Alternate Configuration", save_config_help); break; case 255: return; } } }
void on_save_activate(GtkMenuItem * menuitem, gpointer user_data) { if (conf_write(NULL)) text_insert_msg(_("Error"), _("Unable to save configuration !")); if (conf_write_autoconf()) text_insert_msg(_("Error"), _("Unable to save configuration !")); }
static void dump_rt_entry(FILE *fp, void *e) { rt_entry_t *rte = (rt_entry_t *)e; conf_write(fp, "rt_table %u, name %s", rte->id, rte->name); }
void on_save1_activate(GtkMenuItem * menuitem, gpointer user_data) { if (conf_write(NULL)) text_insert_msg(_("Error"), _("Unable to save configuration !")); config_changed = FALSE; }
static void conf_save(void) { while (1) { int res; dialog_clear(); res = dialog_inputbox(NULL, save_config_text, 11, 55, filename); switch(res) { case 0: if (!dialog_input_result[0]) return; if (!conf_write(dialog_input_result)) { set_config_filename(dialog_input_result); return; } show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60); break; case 1: show_helptext(_("Save Alternate Configuration"), save_config_help); break; case KEY_ESC: return; } } }
int main(int ac, char **av) { char *mode; int res; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); conf_parse(av[1]); conf_read(NULL); mode = getenv("MENUCONFIG_MODE"); if (mode) { if (!strcasecmp(mode, "single_menu")) single_menu_mode = 1; } tcgetattr(1, &ios_org); atexit(conf_cleanup); init_wsize(); reset_dialog(); init_dialog(NULL); set_config_filename(conf_get_configname()); do { conf(&rootmenu); dialog_clear(); if (conf_get_changed()) res = dialog_yesno(NULL, _("Do you wish to save your " "new configuration?\n" "<ESC><ESC> to continue."), 6, 60); else res = -1; } while (res == KEY_ESC); end_dialog(); switch (res) { case 0: if (conf_write(filename)) { fprintf(stderr, _("\n\n" "Error during writing of the configuration.\n" "Your configuration changes were NOT saved." "\n\n")); return 1; } case -1: printf(_("\n\n" "*** End of configuration.\n" "\n\n")); break; default: fprintf(stderr, _("\n\n" "Your configuration changes were NOT saved." "\n\n")); } return 0; }
int main(int ac, char **av) { struct symbol *sym; char *mode; int res; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); conf_parse(av[1]); conf_read(NULL); sym = sym_lookup("KERNELVERSION", 0); sym_calc_value(sym); sprintf(menu_backtitle, _("Linux Kernel v%s Configuration"), sym_get_string_value(sym)); mode = getenv("MENUCONFIG_MODE"); if (mode) { if (!strcasecmp(mode, "single_menu")) single_menu_mode = 1; } tcgetattr(1, &ios_org); atexit(conf_cleanup); init_wsize(); reset_dialog(); init_dialog(menu_backtitle); do { conf(&rootmenu); dialog_clear(); res = dialog_yesno(NULL, _("Do you wish to save your " "new kernel configuration?\n" "<ESC><ESC> to continue."), 6, 60); } while (res == KEY_ESC); end_dialog(); if (res == 0) { if (conf_write(NULL)) { fprintf(stderr, _("\n\n" "Error during writing of the kernel configuration.\n" "Your kernel configuration changes were NOT saved." "\n\n")); return 1; } printf(_("\n\n" "*** End of Linux kernel configuration.\n" "*** Execute 'make' to build the kernel or try 'make help'." "\n\n")); } else { fprintf(stderr, _("\n\n" "Your kernel configuration changes were NOT saved." "\n\n")); } return 0; }
static void dump_tcp_check(FILE *fp, void *data) { checker_t *checker = data; conf_write(fp, " Keepalive method = TCP_CHECK"); dump_checker_opts(fp, checker); }
int main(int ac, char **av) { struct symbol *sym; char *mode; int stat; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); conf_parse(av[1]); conf_read(NULL); sym = sym_lookup("KERNELVERSION", 0); sym_calc_value(sym); sprintf(menu_backtitle, _("swupdate %s Configuration"), sym_get_string_value(sym)); mode = getenv("MENUCONFIG_MODE"); if (mode) { if (!strcasecmp(mode, "single_menu")) single_menu_mode = 1; } tcgetattr(1, &ios_org); atexit(conf_cleanup); init_wsize(); conf(&rootmenu); do { cprint_init(); cprint("--yesno"); cprint(_("Do you wish to save your new configuration?")); cprint("5"); cprint("60"); stat = exec_conf(); } while (stat < 0); if (stat == 0) { if (conf_write(NULL)) { fprintf(stderr, _("\n\n" "Error during writing of the configuration.\n" "Your configuration changes were NOT saved." "\n\n")); return 1; } printf(_("\n\n" "*** End of configuration.\n" "*** Execute 'make' to build the project or try 'make help'." "\n\n")); } else { fprintf(stderr, _("\n\n" "Your configuration changes were NOT saved." "\n\n")); } return 0; }
/* * Initiate wifi scan. */ static void wifi_start_scan(void) { const enum conf_token wifi_scan_start[] = { CT_wifi, CT_scan, CT_start }; u8 val = 1; conf_write(1, wifi_scan_start, 3, ATLV_INT, &val, sizeof(val)); }
/** * Set the data which is in the selected group and value */ void config::setDouble(const char* ch_group, const char* value, double data){ group=conf_get_group(&conf,ch_group); char buffer[16]; sprintf(buffer,"%lf", data); group_set_value(group, value, buffer); fp = fopen(myfilename, "w"); conf_write(&conf, fp); eprintf("Configuration saved\n"); fclose(fp); }
int main(int ac, char **av) { struct symbol *sym; char *mode; int stat; conf_parse(av[1]); conf_read(NULL); sym = sym_lookup("KERNELRELEASE", 0); sym_calc_value(sym); sprintf(menu_backtitle, "Linux Kernel v%s Configuration", sym_get_string_value(sym)); mode = getenv("MENUCONFIG_MODE"); if (mode) { if (!strcasecmp(mode, "single_menu")) single_menu_mode = 1; } tcgetattr(1, &ios_org); atexit(conf_cleanup); init_wsize(); conf(&rootmenu); do { cprint_init(); cprint("--yesno"); cprint("Do you wish to save your new kernel configuration?"); cprint("5"); cprint("60"); stat = exec_conf(); } while (stat < 0); if (stat == 0) { if (conf_write(NULL)) { fprintf(stderr, "\n\n" "Error during writing of the kernel configuration.\n" "Your kernel configuration changes were NOT saved." "\n\n"); return 1; } printf("\n\n" "*** End of Linux kernel configuration.\n" "*** Execute 'make' to build the kernel or try 'make help'." "\n\n"); } else { fprintf(stderr, "\n\n" "Your kernel configuration changes were NOT saved." "\n\n"); } return 0; }
void dump_iprule(FILE *fp, void *rule_data) { ip_rule_t *rule = rule_data; char *buf = MALLOC(RULE_BUF_SIZE); format_iprule(rule, buf, RULE_BUF_SIZE); conf_write(fp, " %s", buf); FREE(buf); }
static void store_filename(GtkFileSelection * file_selector, gpointer user_data) { const gchar *fn; fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION (user_data)); if (conf_write(fn)) text_insert_msg(_("Error"), _("Unable to save configuration !")); gtk_widget_destroy(GTK_WIDGET(user_data)); }
static int mcpcia_write_config(struct pci_dev *dev, int where, u32 value, long mask) { struct pci_controler *hose = dev->sysdata; unsigned long addr; unsigned char type1; if (mk_conf_addr(dev, where, hose, &addr, &type1)) return PCIBIOS_DEVICE_NOT_FOUND; addr |= mask; value = __kernel_insql(value, where & 3); conf_write(addr, value, type1, hose); return PCIBIOS_SUCCESSFUL; }
static int mcpcia_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value) { struct pci_controller *hose = bus->sysdata; unsigned long addr; unsigned char type1; if (mk_conf_addr(bus, devfn, where, hose, &addr, &type1)) return PCIBIOS_DEVICE_NOT_FOUND; addr |= (size - 1) * 8; value = __kernel_insql(value, where & 3); conf_write(addr, value, type1, hose); return PCIBIOS_SUCCESSFUL; }
int main(int ac, char **av) { struct symbol *sym; char *mode; int stat; conf_parse(av[1]); conf_read(NULL); sym = sym_lookup("VERSION", 0); sym_calc_value(sym); snprintf(menu_backtitle, 128, "BusyBox v%s Configuration", sym_get_string_value(sym)); mode = getenv("MENUCONFIG_MODE"); if (mode) { if (!strcasecmp(mode, "single_menu")) single_menu_mode = 1; } tcgetattr(1, &ios_org); atexit(conf_cleanup); init_wsize(); init_dialog(); signal(SIGWINCH, winch_handler); conf(&rootmenu); end_dialog(); /* Restart dialog to act more like when lxdialog was still separate */ init_dialog(); do { stat = dialog_yesno(NULL, "Do you wish to save your new diagnostic program configuration?", 6, 60); } while (stat < 0); end_dialog(); if (stat == 0) { conf_write(NULL); printf("\n\n" "*** End of SQ diagnostic program configuration.\n"); printf("*** Execute 'make' to build the diagnostic program or try 'make help'.\n\n"); } else printf("\n\nYour diagnostic program configuration changes were NOT saved.\n\n"); return 0; }
int main(int ac, char **av) { int stat; char *mode; struct symbol *sym; conf_parse(av[1]); conf_read(NULL); sym = sym_lookup("VERSION", 0); sym_calc_value(sym); snprintf(menu_backtitle, 128, "Core v%s Configuration", sym_get_string_value(sym)); mode = getenv("MENUCONFIG_MODE"); if (mode) { if (!strcasecmp(mode, "single_menu")) single_menu_mode = 1; } tcgetattr(1, &ios_org); atexit(conf_cleanup); init_wsize(); init_dialog(); signal(SIGWINCH, winch_handler); conf(&rootmenu); end_dialog(); /* Restart dialog to act more like when lxdialog was still separate */ init_dialog(); do { stat = dialog_yesno(NULL, "Do you wish to save your new Core configuration?", 5, 60); } while (stat < 0); end_dialog(); if (stat == 0) { conf_write(NULL); printf("\n\n" "*** End of Core configuration.\n" "*** Check the top-level Makefile for additional configuration options.\n\n"); } else printf("\n\nYour Core configuration changes were NOT saved.\n\n"); return 0; }
static int handle_exit(void) { int res; dialog_clear(); if (conf_get_changed()) res = dialog_yesno(NULL, _("Do you wish to save your new configuration ?\n" "<ESC><ESC> to continue."), 6, 60); else res = -1; end_dialog(saved_x, saved_y); switch (res) { case 0: if (conf_write(filename)) { fprintf(stderr, _("\n\n" "Error while writing of the configuration.\n" "Your configuration changes were NOT saved." "\n\n")); return 1; } /* fall through */ case -1: printf(_("\n\n" "*** End of the configuration.\n" "*** Execute 'make' to start the build or try 'make help'." "\n\n")); res = 0; break; default: fprintf(stderr, _("\n\n" "Your configuration changes were NOT saved." "\n\n")); if (res != KEY_ESC) res = 0; } return res; }
static void conf_save(void) { while (1) { switch (dialog_inputbox(NULL, save_config_text, 11, 55, filename)) { case 0: if (!dialog_input_result[0]) return; if (!conf_write(dialog_input_result)) return; show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60); break; case 1: show_helptext("Save Alternate Configuration", save_config_help); break; case 255: return; } } }
int main(int ac, char **av) { const char *progname = av[0]; int opt; const char *name, *defconfig_file = NULL /* gcc uninit */; struct stat tmpstat; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); while ((opt = getopt_long(ac, av, "", long_opts, NULL)) != -1) { input_mode = (enum input_mode)opt; switch (opt) { case silentoldconfig: sync_kconfig = 1; break; case defconfig: case savedefconfig: defconfig_file = optarg; break; case randconfig: { struct timeval now; unsigned int seed; /* * Use microseconds derived seed, * compensate for systems where it may be zero */ gettimeofday(&now, NULL); seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); srand(seed); break; } case oldaskconfig: case oldconfig: case allnoconfig: case allyesconfig: case allmodconfig: case alldefconfig: case listnewconfig: case oldnoconfig: break; case '?': conf_usage(progname); exit(1); break; } } if (ac == optind) { printf(_("%s: Kconfig file missing\n"), av[0]); conf_usage(progname); exit(1); } name = av[optind]; conf_parse(name); //zconfdump(stdout); if (sync_kconfig) { name = conf_get_configname(); if (stat(name, &tmpstat)) { fprintf(stderr, _("***\n" "*** Configuration file \"%s\" not found!\n" "***\n" "*** Please run some configurator (e.g. \"make oldconfig\" or\n" "*** \"make menuconfig\" or \"make xconfig\").\n" "***\n"), name); exit(1); } } switch (input_mode) { case defconfig: if (!defconfig_file) defconfig_file = conf_get_default_confname(); if (conf_read(defconfig_file)) { printf(_("***\n" "*** Can't find default configuration \"%s\"!\n" "***\n"), defconfig_file); exit(1); } name = getenv("KCONFIG_SELINUX"); printf("KCONFIG_SELINUX(%s)\n", name); if (name) { if (conf_read_simple(name, S_DEF_USER, false)) { printf(_("***\n" "*** Can't find selinux configuration \"%s\"!\n" "***\n"), name); exit(1); } } name = getenv("KCONFIG_LOG_SELINUX"); printf("KCONFIG_LOG_SELINUX(%s)\n", name); if (name) { if (conf_read_simple(name, S_DEF_USER, false)) { printf(_("***\n" "*** Can't find selinux log configuration \"%s\"!\n" "***\n"), name); exit(1); } } name = getenv("KCONFIG_TIMA"); printf("KCONFIG_TIMA(%s)\n", name); if (name) { if (conf_read_simple(name, S_DEF_USER, false)) { printf(_("***\n" "*** Can't find tima log configuration \"%s\"!\n" "***\n"), name); exit(1); } } name = getenv("KCONFIG_VARIANT"); printf("KCONFIG_VARIANT(%s)\n", name); if (name) { if (conf_read_simple(name, S_DEF_USER, false)) { printf(_("***\n" "*** Can't find variant configuration \"%s\"!\n" "***\n"), name); exit(1); } } name = getenv("KCONFIG_DEBUG"); printf("KCONFIG_DEBUG(%s)\n", name); if (name) { if (conf_read_simple(name, S_DEF_USER, false)) { printf(_("***\n" "*** Can't find debug configuration \"%s\"!\n" "***\n"), name); exit(1); } } break; case savedefconfig: case silentoldconfig: case oldaskconfig: case oldconfig: case listnewconfig: case oldnoconfig: conf_read(NULL); break; case allnoconfig: case allyesconfig: case allmodconfig: case alldefconfig: case randconfig: name = getenv("KCONFIG_ALLCONFIG"); if (name && !stat(name, &tmpstat)) { conf_read_simple(name, S_DEF_USER, true); break; } switch (input_mode) { case allnoconfig: name = "allno.config"; break; case allyesconfig: name = "allyes.config"; break; case allmodconfig: name = "allmod.config"; break; case alldefconfig: name = "alldef.config"; break; case randconfig: name = "allrandom.config"; break; default: break; } if (!stat(name, &tmpstat)) conf_read_simple(name, S_DEF_USER, true); else if (!stat("all.config", &tmpstat)) conf_read_simple("all.config", S_DEF_USER, true); break; default: break; } if (sync_kconfig) { if (conf_get_changed()) { name = getenv("KCONFIG_NOSILENTUPDATE"); if (name && *name) { fprintf(stderr, _("\n*** The configuration requires explicit update.\n\n")); return 1; } } valid_stdin = isatty(0) && isatty(1) && isatty(2); } switch (input_mode) { case allnoconfig: conf_set_all_new_symbols(def_no); break; case allyesconfig: conf_set_all_new_symbols(def_yes); break; case allmodconfig: conf_set_all_new_symbols(def_mod); break; case alldefconfig: conf_set_all_new_symbols(def_default); break; case randconfig: conf_set_all_new_symbols(def_random); break; case defconfig: conf_set_all_new_symbols(def_default); break; case savedefconfig: break; case oldaskconfig: rootEntry = &rootmenu; conf(&rootmenu); input_mode = silentoldconfig; /* fall through */ case oldconfig: case listnewconfig: case oldnoconfig: case silentoldconfig: /* Update until a loop caused no more changes */ do { conf_cnt = 0; check_conf(&rootmenu); } while (conf_cnt && (input_mode != listnewconfig && input_mode != oldnoconfig)); break; } if (sync_kconfig) { /* silentoldconfig is used during the build so we shall update autoconf. * All other commands are only used to generate a config. */ if (conf_get_changed() && conf_write(NULL)) { fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n")); exit(1); } if (conf_write_autoconf()) { fprintf(stderr, _("\n*** Error during update of the configuration.\n\n")); return 1; } } else if (input_mode == savedefconfig) { if (conf_write_defconfig(defconfig_file)) { fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"), defconfig_file); return 1; } } else if (input_mode != listnewconfig) { if (conf_write(NULL)) { fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n")); exit(1); } } return 0; }
int main(int ac, char **av) { int i = 1; const char *name; struct stat tmpstat; if (ac > i && av[i][0] == '-') { switch (av[i++][1]) { case 'o': input_mode = ask_new; break; case 's': input_mode = ask_silent; valid_stdin = isatty(0) && isatty(1) && isatty(2); break; case 'd': input_mode = set_default; break; case 'D': input_mode = set_default; defconfig_file = av[i++]; if (!defconfig_file) { printf(_("%s: No default config file specified\n"), av[0]); exit(1); } break; case 'n': input_mode = set_no; break; case 'm': input_mode = set_mod; break; case 'y': input_mode = set_yes; break; case 'r': input_mode = set_random; srandom(time(NULL)); break; case 'h': case '?': fprintf(stderr, "See README for usage info\n"); exit(0); } } name = av[i]; if (!name) { printf(_("%s: Kconfig file missing\n"), av[0]); exit(1); } conf_parse(name); //zconfdump(stdout); switch (input_mode) { case set_default: if (!defconfig_file) defconfig_file = conf_get_default_confname(); if (conf_read(defconfig_file)) { printf("***\n" "*** Can't find default configuration \"%s\"!\n" "***\n", defconfig_file); exit(1); } break; case ask_silent: if (stat(".config", &tmpstat)) { printf(_("***\n" "*** You have not yet configured your "PROJECT_NAME"!\n" "***\n" "*** Please run some configurator (e.g. \"make oldconfig\" or\n" "*** \"make menuconfig\" or \"make xconfig\").\n" "***\n")); exit(1); } case ask_all: case ask_new: conf_read(NULL); break; case set_no: case set_mod: case set_yes: case set_random: name = getenv("KCONFIG_ALLCONFIG"); if (name && !stat(name, &tmpstat)) { conf_read_simple(name, S_DEF_USER); break; } switch (input_mode) { case set_no: name = "allno.config"; break; case set_mod: name = "allmod.config"; break; case set_yes: name = "allyes.config"; break; case set_random: name = "allrandom.config"; break; default: break; } if (!stat(name, &tmpstat)) conf_read_simple(name, S_DEF_USER); else if (!stat("all.config", &tmpstat)) conf_read_simple("all.config", S_DEF_USER); break; default: break; } if (input_mode != ask_silent) { rootEntry = &rootmenu; conf(&rootmenu); if (input_mode == ask_all) { input_mode = ask_silent; valid_stdin = 1; } } else if (sym_change_count) { name = getenv("KCONFIG_NOSILENTUPDATE"); if (name && *name) { fprintf(stderr, _("\n*** "PROJECT_NAME" configuration requires explicit update.\n\n")); return 1; } } else goto skip_check; do { conf_cnt = 0; check_conf(&rootmenu); } while (conf_cnt); if (!conf_write(NULL)) { skip_check: if (!(input_mode == ask_silent && conf_write_autoconf())) return 0; } fprintf(stderr, _("\n*** Error writing "PROJECT_NAME" configuration.\n\n")); return 1; }
int main(int ac, char **av) { int i = 1; const char *name; struct stat tmpstat; if (ac > i && av[i][0] == '-') { switch (av[i++][1]) { case 'o': input_mode = ask_new; break; case 's': input_mode = ask_silent; valid_stdin = isatty(0) && isatty(1) && isatty(2); break; case 'd': input_mode = set_default; break; case 'D': input_mode = set_default; defconfig_file = av[i++]; if (!defconfig_file) { printf("%s: No default config file specified\n", av[0]); exit(1); } break; case 'n': input_mode = set_no; break; case 'm': input_mode = set_mod; break; case 'y': input_mode = set_yes; break; case 'r': input_mode = set_random; srandom(time(NULL)); break; case 'h': case '?': printf("%s [-o|-s] config\n", av[0]); exit(0); } } name = av[i]; if (!name) { printf("%s: configuration file missing\n", av[0]); } conf_parse(name); //zconfdump(stdout); switch (input_mode) { case set_default: if (!defconfig_file) defconfig_file = conf_get_default_confname(); if (conf_read(defconfig_file)) { printf("***\n" "*** Can't find default configuration \"%s\"!\n" "***\n", defconfig_file); exit(1); } break; case ask_silent: if (stat(".config", &tmpstat)) { printf("***\n" "*** You have not yet configured axTLS!\n" "***\n" "*** Please run some configurator (e.g. \"make oldconfig\" or\n" "*** \"make menuconfig\" or \"make config\").\n" "***\n"); exit(1); } case ask_all: case ask_new: conf_read(NULL); break; default: break; } if (input_mode != ask_silent) { rootEntry = &rootmenu; conf(&rootmenu); if (input_mode == ask_all) { input_mode = ask_silent; valid_stdin = 1; } } do { conf_cnt = 0; check_conf(&rootmenu); } while (conf_cnt); if (conf_write(NULL)) { fprintf(stderr, "\n*** Error during writing of the axTLS configuration.\n\n"); return 1; } return 0; }
int main(int ac, char **av) { int saved_x, saved_y; char *mode; int res; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); conf_parse(av[1]); conf_read(NULL); mode = getenv("MENUCONFIG_MODE"); if (mode) { if (!strcasecmp(mode, "single_menu")) single_menu_mode = 1; } getyx(stdscr, saved_y, saved_x); if (init_dialog(NULL)) { fprintf(stderr, N_("Your display is too small to run Menuconfig!\n")); fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n")); return 1; } set_config_filename(conf_get_configname()); do { conf(&rootmenu); dialog_clear(); if (conf_get_changed()) res = dialog_yesno(NULL, _("Do you wish to save your " "new configuration?\n" "<ESC><ESC> to continue."), 6, 60); else res = -1; } while (res == KEY_ESC); end_dialog(saved_x, saved_y); switch (res) { case 0: if (conf_write(filename)) { fprintf(stderr, _("\n\n" "Error during writing of the configuration.\n" "Your configuration changes were NOT saved." "\n\n")); return 1; } case -1: printf(_("\n\n" "*** End of configuration.\n" "*** Execute 'make' to build or try 'make help'." "\n\n")); break; default: fprintf(stderr, _("\n\n" "Your configuration changes were NOT saved." "\n\n")); } return conf_write_autoconf(); }
/** * Kick off the daap server and wait for events. * * This starts the initial db scan, sets up the signal * handling, starts the webserver, then sits back and waits * for events, as notified by the signal handler and the * web interface. These events are communicated via flags * in the config structure. * * \param argc count of command line arguments * \param argv command line argument pointers * \returns 0 on success, -1 otherwise * * \todo split out a ws_init and ws_start, so that the * web space handlers can be registered before the webserver * starts. * */ int main(int argc, char *argv[]) { int option; char *configfile=CONFFILE; WSCONFIG ws_config; int reload=0; int start_time; int end_time; int rescan_counter=0; int old_song_count, song_count; int force_non_root=0; int skip_initial=1; int kill_server=0; int convert_conf=0; char *db_type,*db_parms,*web_root,*runas, *tmp; char **mp3_dir_array; char *servername, *iface; char *ffid = NULL; int appdir = 0; char *perr=NULL; char txtrecord[255]; void *phandle; char *plugindir; int err; char *apppath; int debuglevel=0; int plugins_loaded = 0; #ifdef ALPHA_CUSTOMIZE char *share_path; pthread_t thread1; #endif config.use_mdns=1; err_setlevel(2); config.foreground=0; while((option=getopt(argc,argv,"D:d:c:P:mfrysiuvab:Vk")) != -1) { switch(option) { case 'a': appdir = 1; break; case 'b': ffid=optarg; break; case 'd': debuglevel = atoi(optarg); err_setlevel(debuglevel); break; case 'D': if(err_setdebugmask(optarg)) { usage(argv[0]); exit(EXIT_FAILURE); } break; case 'f': config.foreground=1; err_setdest(err_getdest() | LOGDEST_STDERR); break; case 'c': configfile=optarg; break; case 'm': config.use_mdns=0; break; #ifndef WIN32 case 'P': os_set_pidfile(optarg); break; #endif case 'r': reload=1; break; case 's': skip_initial=0; break; case 'y': force_non_root=1; break; #ifdef WIN32 case 'i': os_register(); exit(EXIT_SUCCESS); break; case 'u': os_unregister(); exit(EXIT_SUCCESS); break; #endif case 'v': convert_conf=1; break; case 'k': kill_server=1; break; case 'V': fprintf(stderr,"Firefly Media Server: Version %s\n",VERSION); exit(EXIT_SUCCESS); break; default: usage(argv[0]); exit(EXIT_FAILURE); break; } } if((getuid()) && (!force_non_root) && (!convert_conf)) { fprintf(stderr,"You are not root. This is almost certainly wrong. " "If you are\nsure you want to do this, use the -y " "command-line switch\n"); exit(EXIT_FAILURE); } if(kill_server) { os_signal_server(S_STOP); exit(0); } io_init(); io_set_errhandler(main_io_errhandler); ws_set_errhandler(main_ws_errhandler); /* read the configfile, if specified, otherwise * try defaults */ config.stats.start_time=start_time=(int)time(NULL); config.stop=0; /* set appdir first, that way config resolves relative to appdir */ if(appdir) { apppath = os_apppath(argv[0]); DPRINTF(E_INF,L_MAIN,"Changing cwd to %s\n",apppath); chdir(apppath); free(apppath); configfile="mt-daapd.conf"; } if(CONF_E_SUCCESS != conf_read(configfile)) { fprintf(stderr,"Error reading config file (%s)\n",configfile); exit(EXIT_FAILURE); } if(debuglevel) /* was specified, should override the config file */ err_setlevel(debuglevel); if(convert_conf) { fprintf(stderr,"Converting config file...\n"); if(CONF_E_SUCCESS != conf_write()) { fprintf(stderr,"Error writing config file.\n"); exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); } DPRINTF(E_LOG,L_MAIN,"Firefly Version %s: Starting with debuglevel %d\n", VERSION,err_getlevel()); /* load plugins before we drop privs? Maybe... let the * plugins do stuff they might need to */ plugin_init(); if((plugindir=conf_alloc_string("plugins","plugin_dir",NULL)) != NULL) { /* instead of specifying plugins, let's walk through the directory * and load each of them */ if(!load_plugin_dir(plugindir)) { DPRINTF(E_LOG,L_MAIN,"Warning: Could not load plugins\n"); } else { plugins_loaded = TRUE; } free(plugindir); } if(!plugins_loaded) { if((!load_plugin_dir("/usr/lib/firefly/plugins")) && (!load_plugin_dir("/usr/lib/mt-daapd/plugins")) && (!load_plugin_dir("/lib/mt-daapd/plugins")) && (!load_plugin_dir("/lib/mt-daapd/plugins")) && (!load_plugin_dir("/usr/local/lib/mt-daapd/plugins")) && (!load_plugin_dir("/usr/local/lib/mt-daapd/plugins")) && (!load_plugin_dir("/opt/share/firefly/plugins")) && (!load_plugin_dir("/opt/share/mt-daapd/plugins")) && (!load_plugin_dir("/opt/lib/firefly/plugins")) && (!load_plugin_dir("/opt/lib/mt-daapd/plugins")) && (!load_plugin_dir("plugins/.libs"))) { DPRINTF(E_FATAL,L_MAIN,"plugins/plugin_dir not specified\n"); } } phandle=NULL; while((phandle=plugin_enum(phandle))) { DPRINTF(E_LOG,L_MAIN,"Plugin loaded: %s\n",plugin_get_description(phandle)); } runas = conf_alloc_string("general","runas","nobody"); #ifndef WITHOUT_MDNS if(config.use_mdns) { DPRINTF(E_LOG,L_MAIN,"Starting rendezvous daemon\n"); if(rend_init(runas)) { DPRINTF(E_FATAL,L_MAIN|L_REND,"Error in rend_init: %s\n", strerror(errno)); } } #endif if(!os_init(config.foreground,runas)) { DPRINTF(E_LOG,L_MAIN,"Could not initialize server\n"); os_deinit(); exit(EXIT_FAILURE); } free(runas); #ifdef UPNP upnp_init(); #endif /* this will require that the db be readable by the runas user */ db_type = conf_alloc_string("general","db_type","sqlite"); db_parms = conf_alloc_string("general","db_parms","/var/cache/mt-daapd"); err=db_open(&perr,db_type,db_parms); if(err) { DPRINTF(E_LOG,L_MAIN|L_DB,"Error opening db: %s\n",perr); #ifndef WITHOUT_MDNS if(config.use_mdns) { rend_stop(); } #endif os_deinit(); exit(EXIT_FAILURE); } free(db_type); free(db_parms); /* Initialize the database before starting */ DPRINTF(E_LOG,L_MAIN|L_DB,"Initializing database\n"); if(db_init(reload)) { DPRINTF(E_FATAL,L_MAIN|L_DB,"Error in db_init: %s\n",strerror(errno)); } err=db_get_song_count(&perr,&song_count); if(err != DB_E_SUCCESS) { DPRINTF(E_FATAL,L_MISC,"Error getting song count: %s\n",perr); } /* do a full reload if the db is empty */ if(!song_count) reload = 1; if(conf_get_array("general","mp3_dir",&mp3_dir_array)) { if((!skip_initial) || (reload)) { DPRINTF(E_LOG,L_MAIN|L_SCAN,"Starting mp3 scan\n"); #ifdef ALPHA_CUSTOMIZE share_path = conf_alloc_string("general", "mp3_dir", "AAA"); printf("mp3_dir_array[0] = [%s]\n", mp3_dir_array[0]); if (strlen(share_path) > 0) { Cnt_total_file(mp3_dir_array[0]); pthread_create( &thread1, NULL, (void*)process_bar, NULL); free(share_path); } #endif plugin_event_dispatch(PLUGIN_EVENT_FULLSCAN_START,0,NULL,0); start_time=(int) time(NULL); if(scan_init(mp3_dir_array)) { DPRINTF(E_LOG,L_MAIN|L_SCAN,"Error scanning MP3 files: %s\n",strerror(errno)); } if(!config.stop) { /* don't send popup when shutting down */ plugin_event_dispatch(PLUGIN_EVENT_FULLSCAN_END,0,NULL,0); err=db_get_song_count(&perr,&song_count); end_time=(int) time(NULL); DPRINTF(E_LOG,L_MAIN|L_SCAN,"Scanned %d songs in %d seconds\n", song_count,end_time - start_time); } } conf_dispose_array(mp3_dir_array); } #ifdef ALPHA_CUSTOMIZE thread_exit = 1; #endif /* start up the web server */ web_root = conf_alloc_string("general","web_root",NULL); ws_config.web_root=web_root; ws_config.port=conf_get_int("general","port",0); DPRINTF(E_LOG,L_MAIN|L_WS,"Starting web server from %s on port %d\n", ws_config.web_root, ws_config.port); config.server=ws_init(&ws_config); if(!config.server) { /* pthreads or malloc error */ DPRINTF(E_FATAL,L_MAIN|L_WS,"Error initializing web server\n"); } if(E_WS_SUCCESS != ws_start(config.server)) { /* listen or pthread error */ DPRINTF(E_FATAL,L_MAIN|L_WS,"Error starting web server\n"); } ws_registerhandler(config.server, "/",main_handler,main_auth, 0,1); #ifndef WITHOUT_MDNS if(config.use_mdns) { /* register services */ servername = conf_get_servername(); memset(txtrecord,0,sizeof(txtrecord)); txt_add(txtrecord,"txtvers=1"); txt_add(txtrecord,"Database ID=%0X",util_djb_hash_str(servername)); txt_add(txtrecord,"Machine ID=%0X",util_djb_hash_str(servername)); txt_add(txtrecord,"Machine Name=%s",servername); txt_add(txtrecord,"mtd-version=" VERSION); txt_add(txtrecord,"iTSh Version=131073"); /* iTunes 6.0.4 */ txt_add(txtrecord,"Version=196610"); /* iTunes 6.0.4 */ tmp = conf_alloc_string("general","password",NULL); if(tmp && (strlen(tmp)==0)) tmp=NULL; txt_add(txtrecord,"Password=%s",tmp ? "true" : "false"); if(tmp) free(tmp); srand((unsigned int)time(NULL)); if(ffid) { txt_add(txtrecord,"ffid=%s",ffid); } else { txt_add(txtrecord,"ffid=%08x",rand()); } DPRINTF(E_LOG,L_MAIN|L_REND,"Registering rendezvous names\n"); iface = conf_alloc_string("general","interface",""); rend_register(servername,"_http._tcp",ws_config.port,iface,txtrecord); plugin_rend_register(servername,ws_config.port,iface,txtrecord); free(servername); free(iface); } #endif end_time=(int) time(NULL); err=db_get_song_count(&perr,&song_count); if(err != DB_E_SUCCESS) { DPRINTF(E_FATAL,L_MISC,"Error getting song count: %s\n",perr); } DPRINTF(E_LOG,L_MAIN,"Serving %d songs. Startup complete in %d seconds\n", song_count,end_time-start_time); if(conf_get_int("general","rescan_interval",0) && (!reload) && (!conf_get_int("scanning","skip_first",0))) config.reload = 1; /* force a reload on start */ while(!config.stop) { if((conf_get_int("general","rescan_interval",0) && (rescan_counter > conf_get_int("general","rescan_interval",0)))) { if((conf_get_int("general","always_scan",0)) || (config_get_session_count())) { config.reload=1; } else { DPRINTF(E_DBG,L_MAIN|L_SCAN|L_DB,"Skipped bground scan... no users\n"); } rescan_counter=0; } if(config.reload) { old_song_count = song_count; start_time=(int) time(NULL); DPRINTF(E_LOG,L_MAIN|L_DB|L_SCAN,"Rescanning database\n"); if(conf_get_array("general","mp3_dir",&mp3_dir_array)) { if(config.full_reload) { config.full_reload=0; db_force_rescan(NULL); } if(scan_init(mp3_dir_array)) { DPRINTF(E_LOG,L_MAIN|L_DB|L_SCAN,"Error rescanning... bad path?\n"); } conf_dispose_array(mp3_dir_array); } config.reload=0; db_get_song_count(NULL,&song_count); DPRINTF(E_LOG,L_MAIN|L_DB|L_SCAN,"Scanned %d songs (was %d) in " "%d seconds\n",song_count,old_song_count, time(NULL)-start_time); } os_wait(MAIN_SLEEP_INTERVAL); rescan_counter += MAIN_SLEEP_INTERVAL; } DPRINTF(E_LOG,L_MAIN,"Stopping gracefully\n"); #ifndef WITHOUT_MDNS if(config.use_mdns) { DPRINTF(E_LOG,L_MAIN|L_REND,"Stopping rendezvous daemon\n"); rend_stop(); } #endif #ifdef UPNP upnp_deinit(); #endif /* Got to find a cleaner way to stop the web server. * Closing the fd of the socking accepting doesn't necessarily * cause the accept to fail on some libcs. * DPRINTF(E_LOG,L_MAIN|L_WS,"Stopping web server\n"); ws_stop(config.server); */ free(web_root); conf_close(); DPRINTF(E_LOG,L_MAIN|L_DB,"Closing database\n"); db_deinit(); DPRINTF(E_LOG,L_MAIN,"Done!\n"); os_deinit(); io_deinit(); mem_dump(); return EXIT_SUCCESS; }
int main(int ac, char **av) { const char *progname = av[0]; int opt; const char *name, *defconfig_file = NULL /* gcc uninit */; struct stat tmpstat; tty_stdio = isatty(0) && isatty(1); while ((opt = getopt_long(ac, av, "s", long_opts, NULL)) != -1) { if (opt == 's') { conf_set_message_callback(NULL); continue; } input_mode = (enum input_mode)opt; switch (opt) { case syncconfig: sync_kconfig = 1; break; case defconfig: case savedefconfig: defconfig_file = optarg; break; case randconfig: { struct timeval now; unsigned int seed; char *seed_env; /* * Use microseconds derived seed, * compensate for systems where it may be zero */ gettimeofday(&now, NULL); seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); seed_env = getenv("KCONFIG_SEED"); if( seed_env && *seed_env ) { char *endp; int tmp = (int)strtol(seed_env, &endp, 0); if (*endp == '\0') { seed = tmp; } } fprintf( stderr, "KCONFIG_SEED=0x%X\n", seed ); srand(seed); break; } case oldaskconfig: case oldconfig: case allnoconfig: case allyesconfig: case allmodconfig: case alldefconfig: case listnewconfig: case olddefconfig: break; case '?': conf_usage(progname); exit(1); break; } } if (ac == optind) { fprintf(stderr, "%s: Kconfig file missing\n", av[0]); conf_usage(progname); exit(1); } name = av[optind]; conf_parse(name); //zconfdump(stdout); if (sync_kconfig) { name = conf_get_configname(); if (stat(name, &tmpstat)) { fprintf(stderr, "***\n" "*** Configuration file \"%s\" not found!\n" "***\n" "*** Please run some configurator (e.g. \"make oldconfig\" or\n" "*** \"make menuconfig\" or \"make xconfig\").\n" "***\n", name); exit(1); } } switch (input_mode) { case defconfig: if (!defconfig_file) defconfig_file = conf_get_default_confname(); if (conf_read(defconfig_file)) { fprintf(stderr, "***\n" "*** Can't find default configuration \"%s\"!\n" "***\n", defconfig_file); exit(1); } break; case savedefconfig: case syncconfig: case oldaskconfig: case oldconfig: case listnewconfig: case olddefconfig: conf_read(NULL); break; case allnoconfig: case allyesconfig: case allmodconfig: case alldefconfig: case randconfig: name = getenv("KCONFIG_ALLCONFIG"); if (!name) break; if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) { if (conf_read_simple(name, S_DEF_USER)) { fprintf(stderr, "*** Can't read seed configuration \"%s\"!\n", name); exit(1); } break; } switch (input_mode) { case allnoconfig: name = "allno.config"; break; case allyesconfig: name = "allyes.config"; break; case allmodconfig: name = "allmod.config"; break; case alldefconfig: name = "alldef.config"; break; case randconfig: name = "allrandom.config"; break; default: break; } if (conf_read_simple(name, S_DEF_USER) && conf_read_simple("all.config", S_DEF_USER)) { fprintf(stderr, "*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n", name); exit(1); } break; default: break; } if (sync_kconfig) { if (conf_get_changed()) { name = getenv("KCONFIG_NOSILENTUPDATE"); if (name && *name) { fprintf(stderr, "\n*** The configuration requires explicit update.\n\n"); return 1; } } } switch (input_mode) { case allnoconfig: conf_set_all_new_symbols(def_no); break; case allyesconfig: conf_set_all_new_symbols(def_yes); break; case allmodconfig: conf_set_all_new_symbols(def_mod); break; case alldefconfig: conf_set_all_new_symbols(def_default); break; case randconfig: /* Really nothing to do in this loop */ while (conf_set_all_new_symbols(def_random)) ; break; case defconfig: conf_set_all_new_symbols(def_default); break; case savedefconfig: break; case oldaskconfig: rootEntry = &rootmenu; conf(&rootmenu); input_mode = oldconfig; /* fall through */ case oldconfig: case listnewconfig: case syncconfig: /* Update until a loop caused no more changes */ do { conf_cnt = 0; check_conf(&rootmenu); } while (conf_cnt); break; case olddefconfig: default: break; } if (sync_kconfig) { /* syncconfig is used during the build so we shall update autoconf. * All other commands are only used to generate a config. */ if (conf_get_changed() && conf_write(NULL)) { fprintf(stderr, "\n*** Error during writing of the configuration.\n\n"); exit(1); } if (conf_write_autoconf()) { fprintf(stderr, "\n*** Error during update of the configuration.\n\n"); return 1; } } else if (input_mode == savedefconfig) { if (conf_write_defconfig(defconfig_file)) { fprintf(stderr, "n*** Error while saving defconfig to: %s\n\n", defconfig_file); return 1; } } else if (input_mode != listnewconfig) { if (conf_write(NULL)) { fprintf(stderr, "\n*** Error during writing of the configuration.\n\n"); exit(1); } } return 0; }
int main(int ac, char **av) { int opt; const char *name; struct stat tmpstat; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); while ((opt = getopt(ac, av, "osbBdD:nmyrh")) != -1) { switch (opt) { case 'o': input_mode = ask_silent; break; case 's': input_mode = ask_silent; sync_kconfig = 1; break; case 'b': input_mode = dont_ask; break; case 'B': input_mode = dont_ask_dont_tell; break; case 'd': input_mode = set_default; break; case 'D': input_mode = set_default; defconfig_file = optarg; break; case 'n': input_mode = set_no; break; case 'm': input_mode = set_mod; break; case 'y': input_mode = set_yes; break; case 'r': { struct timeval now; unsigned int seed; /* * Use microseconds derived seed, * compensate for systems where it may be zero */ gettimeofday(&now, NULL); seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); srand(seed); input_mode = set_random; break; } case 'h': printf(_("See README for usage info\n")); exit(0); break; default: fprintf(stderr, _("See README for usage info\n")); exit(1); } } if (ac == optind) { printf(_("%s: Kconfig file missing\n"), av[0]); exit(1); } name = av[optind]; conf_parse(name); //zconfdump(stdout); if (sync_kconfig) { name = conf_get_configname(); if (stat(name, &tmpstat)) { fprintf(stderr, _("***\n" "*** You have not yet configured your kernel!\n" "*** (missing kernel config file \"%s\")\n" "***\n" "*** Please run some configurator (e.g. \"make oldconfig\" or\n" "*** \"make menuconfig\" or \"make xconfig\").\n" "***\n"), name); exit(1); } } switch (input_mode) { case set_default: if (!defconfig_file) defconfig_file = conf_get_default_confname(); if (conf_read(defconfig_file)) { printf(_("***\n" "*** Can't find default configuration \"%s\"!\n" "***\n"), defconfig_file); exit(1); } break; case ask_silent: case ask_all: case ask_new: case dont_ask: case dont_ask_dont_tell: conf_read(NULL); break; case set_no: case set_mod: case set_yes: case set_random: name = getenv("KCONFIG_ALLCONFIG"); if (name && !stat(name, &tmpstat)) { conf_read_simple(name, S_DEF_USER); break; } switch (input_mode) { case set_no: name = "allno.config"; break; case set_mod: name = "allmod.config"; break; case set_yes: name = "allyes.config"; break; case set_random: name = "allrandom.config"; break; default: break; } if (!stat(name, &tmpstat)) conf_read_simple(name, S_DEF_USER); else if (!stat("all.config", &tmpstat)) conf_read_simple("all.config", S_DEF_USER); break; default: break; } if (sync_kconfig) { if (conf_get_changed()) { name = getenv("KCONFIG_NOSILENTUPDATE"); if (name && *name) { fprintf(stderr, _("\n*** Kernel configuration requires explicit update.\n\n")); return 1; } } valid_stdin = isatty(0) && isatty(1) && isatty(2); } switch (input_mode) { case set_no: conf_set_all_new_symbols(def_no); break; case set_yes: conf_set_all_new_symbols(def_yes); break; case set_mod: conf_set_all_new_symbols(def_mod); break; case set_random: conf_set_all_new_symbols(def_random); break; case set_default: conf_set_all_new_symbols(def_default); break; case ask_new: case ask_all: rootEntry = &rootmenu; conf(&rootmenu); input_mode = ask_silent; /* fall through */ case dont_ask: case dont_ask_dont_tell: case ask_silent: /* Update until a loop caused no more changes */ do { conf_cnt = 0; check_conf(&rootmenu); } while (conf_cnt && (input_mode != dont_ask && input_mode != dont_ask_dont_tell)); break; } if (sync_kconfig) { /* silentoldconfig is used during the build so we shall update autoconf. * All other commands are only used to generate a config. */ if (conf_get_changed() && conf_write(NULL)) { fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); exit(1); } if (conf_write_autoconf()) { fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n")); return 1; } } else { if (conf_write(NULL)) { fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); exit(1); } } return return_value; }
int main(int ac, char **av) { int opt; const char *name; struct stat tmpstat; setlocale(LC_ALL, ""); bindtextdomain(OPENCONF_PACKAGE, OPENCONF_LOCALEDIR); textdomain(OPENCONF_PACKAGE); while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) { switch (opt) { case 'o': input_mode = ask_silent; break; case 's': input_mode = ask_silent; sync_kconfig = 1; break; case 'd': input_mode = set_default; break; case 'D': input_mode = set_default; defconfig_file = optarg; break; case 'n': input_mode = set_no; break; case 'm': input_mode = set_mod; break; case 'y': input_mode = set_yes; break; case 'r': input_mode = set_random; srand(time(NULL)); break; case 'h': printf("See README for usage info\n"); exit(0); break; default: fprintf(stderr, "See README for usage info\n"); exit(1); } } if (ac == optind) { printf(_("%s: Kconfig file missing\n"), av[0]); exit(1); } name = av[optind]; conf_parse(name); //zconfdump(stdout); if (sync_kconfig) { name = getenv(OPENCONF_CONFIG_ENVNAME); if (stat(name, &tmpstat)) { fprintf(stderr, "***\n" "*** You have not yet configured!\n" "*** (missing " OPENCONF_CONFIG_DEFAULT " file)\n" "***\n" "*** Please run some configurator (e.g. \"make oldconfig\" or\n" "*** \"make menuconfig\" or \"make xconfig\").\n" "***\n"); exit(1); } } switch (input_mode) { case set_default: if (!defconfig_file) defconfig_file = conf_get_default_confname(); if (conf_read(defconfig_file)) { printf("***\n" "*** Can't find default configuration \"%s\"!\n" "***\n", defconfig_file); exit(1); } break; case ask_silent: case ask_all: case ask_new: conf_read(NULL); break; case set_no: case set_mod: case set_yes: case set_random: name = getenv(OPENCONF_ALLCONFIG_ENVNAME); if (name && !stat(name, &tmpstat)) { conf_read_simple(name, S_DEF_USER); break; } switch (input_mode) { case set_no: name = OPENCONF_ALLCONFIG_ALLNO; break; case set_mod: name = OPENCONF_ALLCONFIG_ALLMOD; break; case set_yes: name = OPENCONF_ALLCONFIG_ALLYES; break; case set_random: name = OPENCONF_ALLCONFIG_ALLRANDOM; break; default: break; } if (!stat(name, &tmpstat)) conf_read_simple(name, S_DEF_USER); else if (!stat(OPENCONF_ALLCONFIG_ALL, &tmpstat)) conf_read_simple(OPENCONF_ALLCONFIG_ALL, S_DEF_USER); break; default: break; } if (sync_kconfig) { if (conf_get_changed()) { name = getenv(OPENCONF_NOSILENTUPDATE_ENVNAME); if (name && *name) { fprintf(stderr, "\n*** configuration requires explicit update.\n\n"); return 1; } } valid_stdin = isatty(0) && isatty(1) && isatty(2); } switch (input_mode) { case set_no: conf_set_all_new_symbols(def_no); break; case set_yes: conf_set_all_new_symbols(def_yes); break; case set_mod: conf_set_all_new_symbols(def_mod); break; case set_random: conf_set_all_new_symbols(def_random); break; case set_default: conf_set_all_new_symbols(def_default); break; case ask_new: case ask_all: rootEntry = &rootmenu; conf(&rootmenu); input_mode = ask_silent; /* fall through */ case ask_silent: /* Update until a loop caused no more changes */ do { conf_cnt = 0; check_conf(&rootmenu); } while (conf_cnt); break; } if (sync_kconfig) { /* silentoldconfig is used during the build so we shall update autoconf. * All other commands are only used to generate a config. */ if (conf_get_changed() && conf_write(NULL)) { fprintf(stderr, "\n*** Error during writing of the configuration.\n\n"); exit(1); } if (conf_write_autoconf()) { fprintf(stderr, "\n*** Error during update of the configuration.\n\n"); return 1; } } else { if (conf_write(NULL)) { fprintf(stderr, "\n*** Error during writing of the configuration.\n\n"); exit(1); } } return 0; }
int main(int ac, char **av) { int opt; const char *name; struct stat tmpstat; bool report = false, update = false; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); while ((opt = getopt(ac, av, "osdD:nmyrRUh")) != -1) { switch (opt) { case 'o': input_mode = ask_new; break; case 's': input_mode = ask_silent; valid_stdin = isatty(0) && isatty(1) && isatty(2); break; case 'd': input_mode = set_default; break; case 'D': input_mode = set_default; defconfig_file = optarg; break; case 'n': input_mode = set_no; break; case 'm': input_mode = set_mod; break; case 'y': input_mode = set_yes; break; case 'r': input_mode = set_random; srand(time(NULL)); break; case 'R': input_mode = set_default; report = update = true; break; case 'U': input_mode = set_default; update = true; break; case 'h': printf(_("See README for usage info\n")); exit(0); break; default: fprintf(stderr, _("See README for usage info\n")); exit(1); } } if (ac == optind) { printf(_("%s: Kconfig file missing\n"), av[0]); exit(1); } name = av[optind]; conf_parse(name); //zconfdump(stdout); switch (input_mode) { case set_default: if (update) conf_read(NULL); else { if (!defconfig_file) defconfig_file = conf_get_default_confname(); if (conf_read(defconfig_file)) { printf("***\n" "*** Can't find default configuration \"%s\"!\n" "***\n", defconfig_file); exit(1); } } break; case ask_silent: if (stat(".config", &tmpstat)) { printf(_("***\n" "*** You have not yet configured your kernel!\n" "*** (missing kernel .config file)\n" "***\n" "*** Please run some configurator (e.g. \"make oldconfig\" or\n" "*** \"make menuconfig\" or \"make xconfig\").\n" "***\n")); exit(1); } case ask_all: case ask_new: conf_read(NULL); break; case set_no: case set_mod: case set_yes: case set_random: name = getenv("KCONFIG_ALLCONFIG"); if (name && !stat(name, &tmpstat)) { conf_read_simple(name, S_DEF_USER); break; } switch (input_mode) { case set_no: name = "allno.config"; break; case set_mod: name = "allmod.config"; break; case set_yes: name = "allyes.config"; break; case set_random: name = "allrandom.config"; break; default: break; } if (!stat(name, &tmpstat)) conf_read_simple(name, S_DEF_USER); else if (!stat("all.config", &tmpstat)) conf_read_simple("all.config", S_DEF_USER); break; default: break; } if (input_mode != ask_silent) { rootEntry = &rootmenu; conf(&rootmenu); if (input_mode == ask_all) { input_mode = ask_silent; valid_stdin = 1; } } else if (conf_get_changed()) { name = getenv("KCONFIG_NOSILENTUPDATE"); if (name && *name) { fprintf(stderr, _("\n*** Kernel configuration requires explicit update.\n\n")); return 1; } } else goto skip_check; do { conf_cnt = 0; check_conf(&rootmenu); } while (conf_cnt); if (report) report_changes(); if (conf_write(NULL)) { fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); return 1; } skip_check: return 0; }
int main(int ac, char **av) { int opt; const char *name; struct stat tmpstat; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); while ((opt = getopt_long(ac, av, "", long_opts, NULL)) != -1) { input_mode = (enum input_mode)opt; switch (opt) { case silentoldconfig: sync_kconfig = 1; break; case defconfig: case savedefconfig: defconfig_file = optarg; break; case randconfig: { struct timeval now; unsigned int seed; /* * Use microseconds derived seed, * compensate for systems where it may be zero */ gettimeofday(&now, NULL); seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); srand(seed); break; } case '?': fprintf(stderr, _("See README for usage info\n")); exit(1); break; } } if (ac == optind) { printf(_("%s: Kconfig file missing\n"), av[0]); exit(1); } name = av[optind]; conf_parse(name); //zconfdump(stdout); if (sync_kconfig) { name = conf_get_configname(); if (stat(name, &tmpstat)) { fprintf(stderr, _("***\n" "*** Configuration file \"%s\" not found!\n" "***\n" "*** Please run some configurator (e.g. \"make oldconfig\" or\n" "*** \"make menuconfig\" or \"make xconfig\").\n" "***\n"), name); exit(1); } } switch (input_mode) { case defconfig: if (!defconfig_file) defconfig_file = conf_get_default_confname(); if (conf_read(defconfig_file)) { printf(_("***\n" "*** Can't find default configuration \"%s\"!\n" "***\n"), defconfig_file); exit(1); } break; case savedefconfig: case silentoldconfig: case oldaskconfig: case oldconfig: case listnewconfig: case oldnoconfig: conf_read(NULL); break; case allnoconfig: case allyesconfig: case allmodconfig: case alldefconfig: case randconfig: name = getenv("KCONFIG_ALLCONFIG"); if (name && !stat(name, &tmpstat)) { conf_read_simple(name, S_DEF_USER); break; } switch (input_mode) { case allnoconfig: name = "allno.config"; break; case allyesconfig: name = "allyes.config"; break; case allmodconfig: name = "allmod.config"; break; case alldefconfig: name = "alldef.config"; break; case randconfig: name = "allrandom.config"; break; default: break; } if (!stat(name, &tmpstat)) conf_read_simple(name, S_DEF_USER); else if (!stat("all.config", &tmpstat)) conf_read_simple("all.config", S_DEF_USER); break; default: break; } if (sync_kconfig) { if (conf_get_changed()) { name = getenv("KCONFIG_NOSILENTUPDATE"); if (name && *name) { fprintf(stderr, _("\n*** The configuration requires explicit update.\n\n")); return 1; } } valid_stdin = isatty(0) && isatty(1) && isatty(2); } switch (input_mode) { case allnoconfig: conf_set_all_new_symbols(def_no); break; case allyesconfig: conf_set_all_new_symbols(def_yes); break; case allmodconfig: conf_set_all_new_symbols(def_mod); break; case alldefconfig: conf_set_all_new_symbols(def_default); break; case randconfig: conf_set_all_new_symbols(def_random); break; case defconfig: conf_set_all_new_symbols(def_default); break; case savedefconfig: break; case oldaskconfig: rootEntry = &rootmenu; conf(&rootmenu); input_mode = silentoldconfig; /* fall through */ case oldconfig: case listnewconfig: case oldnoconfig: case silentoldconfig: /* Update until a loop caused no more changes */ do { conf_cnt = 0; check_conf(&rootmenu); } while (conf_cnt && (input_mode != listnewconfig && input_mode != oldnoconfig)); break; } if (sync_kconfig) { /* silentoldconfig is used during the build so we shall update autoconf. * All other commands are only used to generate a config. */ if (conf_get_changed() && conf_write(NULL)) { fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n")); exit(1); } if (conf_write_autoconf()) { fprintf(stderr, _("\n*** Error during update of the configuration.\n\n")); return 1; } } else if (input_mode == savedefconfig) { if (conf_write_defconfig(defconfig_file)) { fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"), defconfig_file); return 1; } } else if (input_mode != listnewconfig) { if (conf_write(NULL)) { fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n")); exit(1); } } /* This is for Intel Media SOC Gen3 Support, creates "include/linux/autoconf.h" link to be consistent with kernel versions earlier than 2.6.35 #ifdef CONFIG_ARCH_GEN3 */ if (access("include/linux/autoconf.h",0)&&(symlink("../generated/autoconf.h","include/linux/autoconf.h"))) { fprintf(stderr, _("\n*** can not symlink include/generated/autoconf.h to include/linux/autoconf.h.\n\n")); } return 0; }