Ejemplo n.º 1
0
static void search_conf(void)
{
	struct symbol **sym_arr;
	struct gstr res;
	char *dialog_input;
	int dres;
again:
	dialog_clear();
	dres = dialog_inputbox(_("Search Configuration Parameter"),
			      _("Enter CONFIG_ (sub)string to search for "
				"(with or without \"CONFIG\")"),
			      10, 75, "");
	switch (dres) {
	case 0:
		break;
	case 1:
		show_helptext(_("Search Configuration"), search_help);
		goto again;
	default:
		return;
	}

	/* strip CONFIG_ if necessary */
	dialog_input = dialog_input_result;
	if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0)
		dialog_input += 7;

	sym_arr = sym_re_search(dialog_input);
	res = get_relations_str(sym_arr);
	free(sym_arr);
	show_textbox(_("Search Results"), str_get(&res), 0, 0);
	str_free(&res);
}
Ejemplo n.º 2
0
static void conf_load(void)
{

	while (1) {
		int res;
		dialog_clear();
		res = dialog_inputbox(NULL, load_config_text,
				      11, 55, filename);
		switch(res) {
		case 0:
			if (!dialog_input_result[0])
				return;
			if (!conf_read(dialog_input_result)) {
				set_config_filename(dialog_input_result);
				sym_set_change_count(1);
				return;
			}
			show_textbox(NULL, _("File does not exist!"), 5, 38);
			break;
		case 1:
			show_helptext(_("Load Alternate Configuration"), load_config_help);
			break;
		case KEY_ESC:
			return;
		}
	}
}
Ejemplo n.º 3
0
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;
        }
    }
}
Ejemplo n.º 4
0
int
main(int argc, char **argv)
{
	int retval;
	unsigned char *tresult;

	init_dialog();
	use_helpfile("ftree2.test");
	use_helpline("Press Arrows, Tab, Enter or F1");
	retval = dialog_ftree("ftree2.test", '\t',
		"ftree dialog box example",
		"xterm widget tree from preprocess editres(1) dump", 
		-1, -1, 15,
                            &tresult);

	dialog_update();
	
	dialog_clear();
	
	end_dialog();

	if (!retval)
	{
 		puts(tresult);
  		free(tresult);
  	}
  	
	exit(retval);
}
Ejemplo n.º 5
0
Archivo: util.c Proyecto: whble/trunk
/*
 * Do some initialization for dialog
 */
int init_dialog(const char *backtitle)
{
	int height, width;

	initscr();		/* Init curses */

	/* Get current cursor position for signal handler in mconf.c */
	getyx(stdscr, saved_y, saved_x);

	getmaxyx(stdscr, height, width);
	if (height < 19 || width < 80) {
		endwin();
		return -ERRDISPLAYTOOSMALL;
	}

	dlg.backtitle = backtitle;
	color_setup(getenv("MENUCONFIG_COLOR"));

	keypad(stdscr, TRUE);
	cbreak();
	noecho();
	dialog_clear();

	return 0;
}
Ejemplo n.º 6
0
static void search_conf(void)
{
	struct symbol **sym_arr;
	struct gstr res;
	int dres;
again:
	dialog_clear();
	dres = dialog_inputbox(_("Search Configuration Parameter"),
			      _("Enter CONFIG_ (sub)string to search for (omit CONFIG_)"),
			      10, 75, "");
	switch (dres) {
	case 0:
		break;
	case 1:
		show_helptext(_("Search Configuration"), search_help);
		goto again;
	default:
		return;
	}

	sym_arr = sym_re_search(dialog_input_result);
	res = get_relations_str(sym_arr);
	free(sym_arr);
	show_textbox(_("Search Results"), str_get(&res), 0, 0);
	str_free(&res);
}
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
0
static int 
_menu1_fw_action(dialogMenuItem * self)
{
	dialog_clear();
	init_dialog();
	main_fw_menu();
	return DITEM_SUCCESS | DITEM_RESTORE | DITEM_CONTINUE;
}
Ejemplo n.º 9
0
static void conf_choice(struct menu *menu)
{
	const char *prompt = _(menu_get_prompt(menu));
	struct menu *child;
	struct symbol *active;

	active = sym_get_choice_value(menu->sym);
	while (1) {
		int res;
		int selected;
		item_reset();

		current_menu = menu;
		for (child = menu->list; child; child = child->next) {
			if (!menu_is_visible(child))
				continue;
			if (child->sym)
				item_make("%s", _(menu_get_prompt(child)));
			else {
				item_make("*** %s ***", _(menu_get_prompt(child)));
				item_set_tag(':');
			}
			item_set_data(child);
			if (child->sym == active)
				item_set_selected(1);
			if (child->sym == sym_get_choice_value(menu->sym))
				item_set_tag('X');
		}
		dialog_clear();
		res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"),
					_(radiolist_instructions),
					 15, 70, 6);
		selected = item_activate_selected();
		switch (res) {
		case 0:
			if (selected) {
				child = item_data();
				if (!child->sym)
					break;

				sym_set_tristate_value(child->sym, yes);
			}
			return;
		case 1:
			if (selected) {
				child = item_data();
				show_help(child);
				active = child->sym;
			} else
				show_help(menu);
			break;
		case KEY_ESC:
			return;
		case -ERRDISPLAYTOOSMALL:
			return;
		}
	}
}
Ejemplo n.º 10
0
static int 
_menu1_re_action(dialogMenuItem * self)
{
	dialog_clear();
	end_dialog();
	endwin();
	system("/sbin/reboot");
	exit(0);
}
Ejemplo n.º 11
0
int _afm_flush(dialogMenuItem *self)
{
	dialog_clear();
	system("/sbin/ipfw -q flush");
	unlink("/etc/rules");

   dialog_msgbox("ClosedBSD", "Ruleset has been cleared.", -1, -1, 1); 
	return DITEM_SUCCESS | DITEM_RESTORE | DITEM_CONTINUE;
}
Ejemplo n.º 12
0
void
systemSuspendDialog(void)
{

    oldW  = savescr();
    dialog_clear();
    dialog_update();
    end_dialog();
    DialogActive = FALSE;
}
Ejemplo n.º 13
0
int 
main_menu()
{
	int retval;

	retval = dialog_menu("ClosedBSD Configuration Menu", "Please select the appropriate option:", -1, -1, 8, -8, menu1, NULL, NULL, NULL);

	dialog_clear();

	return 0;
}
Ejemplo n.º 14
0
Archivo: util.c Proyecto: 4pao/openwrt
/*
 * Do some initialization for dialog
 */
void init_dialog(void)
{
	initscr();		/* Init curses */
	keypad(stdscr, TRUE);
	cbreak();
	noecho();

	if (use_colors)		/* Set up colors */
		color_setup();

	dialog_clear();
}
Ejemplo n.º 15
0
/* Kick it off, James! */
int
main(int argc, unsigned char *argv[])
{
  int retval;

  init_dialog();

  retval = dialog_textbox("This is dialog_textbox() in action with /etc/passwd", "/etc/passwd", 10, 60);
  dialog_clear();
  fprintf(stderr, "returned value for dialog_textbox was %d\n", retval);

  end_dialog();
  return 0;
}
Ejemplo n.º 16
0
/* Kick it off, James! */
int
main(int argc, char **argv)
{
  int retval;

  init_dialog();

  retval = dialog_dselect(".", "*");
  dialog_clear();
  fprintf(stderr, "returned value for dialog_dselect was %d\n", retval);

  end_dialog();
  return 0;
}
Ejemplo n.º 17
0
int _afi_manual(dialogMenuItem *self)
{
	char result[256];
	int ret;

	dialog_clear();
	bzero(result, sizeof(result));

	ret = dialog_inputbox("ClosedBSD: Manual IPFW rule addition", "Type in the rule manually.  These are some sample rules that illustrate the syntax\n\n 'add allow all from any to any'\n 'add deny tcp from echelon.gov'\n 'add deny all from evilcrackers.org'\n 'add allow all from 192.168.202.0 to any out'\n\n", -1, -1, result);

	if (ret == 0)
		raw_add_rule(result);

	return DITEM_SUCCESS | DITEM_RESTORE | DITEM_CONTINUE;
}
Ejemplo n.º 18
0
/* Kick it off, James! */
int
main(int argc, char **argv)
{
  int retval;

  init_dialog();

  retval = dialog_msgbox("This is dialog_msgbox() in action with pause on", "Hi there.  Please press return now.",
			 -1, -1, 1);
  dialog_clear();
  fprintf(stderr, "returned value for dialog_msgbox was %d\n", retval);

  end_dialog();
  return 0;
}
Ejemplo n.º 19
0
int 
proto_pipe()
{
	WINDOW *w;

	dialog_clear();

	w = newwin(22, 76, 1, 1);
	_std_window(w, " ClosedBSD: Load Balancing Manager ");

	ip_list(w, "IP Address : Port", 2, 43);

	sleep(2);

	return DITEM_SUCCESS | DITEM_RESTORE | DITEM_CONTINUE;
}
Ejemplo n.º 20
0
static int 
_menu1_sa_action(dialogMenuItem * self)
{
	int ret;

	dialog_clear();
	dialog_msgbox("ClosedBSD", "Please insert a floppy diskette and press a key.", -1, -1, 1);

	dialog_clear();
	if ((ret = system("/sbin/mount /dev/fd0 /mnt")) != 0) {
		dialog_clear();
		dialog_msgbox("ClosedBSD", "This floppy is not formatted.  Press a key to format. (This may take a few minutes)", -1, -1, 1);

		dialog_clear();
		dialog_gauge("ClosedBSD", "Formatting /dev/fd0", 10, 1, 7, 70, 10);
		if ((ret = system("/sbin/fdformat -y /dev/fd0 >/dev/null")) != 0) {
			dialog_clear();
			dialog_msgbox("ClosedBSD", "Some error occured during 'fdformat'.  Contact [email protected].", -1, -1, 1);
			return DITEM_SUCCESS | DITEM_RESTORE | DITEM_CONTINUE;
		}
		dialog_gauge("ClosedBSD", "Formatting /dev/fd0", 10, 1, 7, 70, 30);
		if ((ret = system("/sbin/disklabel -w -r /dev/fd0 fd1440 >/dev/null")) != 0) {
			dialog_clear();
			dialog_msgbox("ClosedBSD", "Some error occured during 'disklabel'.  Contact [email protected].", -1, -1, 1);
			return DITEM_SUCCESS | DITEM_RESTORE | DITEM_CONTINUE;
		}
		dialog_gauge("ClosedBSD", "Formatting /dev/fd0", 10, 1, 7, 70, 60);
		if ((ret = system("/sbin/newfs -T fd1440 /dev/fd0 fd1440 >/dev/null")) != 0) {
			dialog_clear();
			dialog_msgbox("ClosedBSD", "Some error occured during 'newfs'.  Contact [email protected].", -1, -1, 1);
			return DITEM_SUCCESS | DITEM_RESTORE | DITEM_CONTINUE;
		}
		dialog_gauge("ClosedBSD", "Formatting /dev/fd0", 10, 1, 7, 70, 100);
		if ((ret = system("/sbin/mount /dev/fd0 /mnt >/dev/null")) != 0) {
			dialog_clear();
			dialog_msgbox("ClosedBSD", "Unable to mount floppy.  Contact [email protected].", -1, -1, 1);
			return DITEM_SUCCESS | DITEM_RESTORE | DITEM_CONTINUE;
		}
		system("/sbin/writetcnp");
	} else
		system("/sbin/umount /dev/fd0");
	system("/sbin/writetcnp");

	return DITEM_SUCCESS | DITEM_RESTORE | DITEM_CONTINUE;
}
Ejemplo n.º 21
0
/* Kick it off, James! */
int
main(int argc, char **argv)
{
    int retval;
    
    init_dialog();
    
    retval = dialog_checklist("this is dialog_checklist() in action, test #2",
			      "Same as before, but now we relabel the buttons and override the OK action.",
			      -1, -1, 4, -4, menu3 + 2, (char *)TRUE);
    dialog_clear();
    fprintf(stderr, "returned value for dialog_checklist was %d\n", retval);
    
    end_dialog();
    return 0;
}
Ejemplo n.º 22
0
/* Kick it off, James! */
int
main(int argc, char **argv)
{
  char *retval;

  init_dialog();

  retval = dialog_fselect(".", "*.[ch]");
  dialog_clear();
  if (retval)
    fprintf(stderr, "returned value for dialog_fselect was %s\n", retval);
  else
    fprintf(stderr, "returned value for dialog_fselect was NULL\n");

  end_dialog();
  return 0;
}
Ejemplo n.º 23
0
/* Kick it off, James! */
int
main(int argc, char **argv)
{
    int retval;

    init_dialog();

    retval = dialog_menu("this is dialog_menu() in action, test #1",
                         "this simple menu shows off some of the straight-forward features\n"
                         "of the new menu system's action dispatch hooks.  Select Cancel to leave",
                         -1, -1, 3, -3, menu1, NULL, NULL, NULL);
    dialog_clear();
    fprintf(stderr, "returned value for dialog_menu was %d\n", retval);

    end_dialog();
    return 0;
}
Ejemplo n.º 24
0
/* Kick it off, James! */
int
main(int argc, char **argv)
{
    int retval;
    
    init_dialog();
    
    retval = dialog_radiolist("this is dialog_radiolist() in action, test #2",
			      "Welcome to \"The Love Blender!\" - America's favorite game show\n"
			      "where YOU, the contestant, get to choose which of these two\n"
			      "fine specimens of humanity will go home together, whether they\n"
			      "like it or not!", -1, -1, 7, -7, menu6, NULL);
    dialog_clear();
    fprintf(stderr, "I'm sure that %s and %s will be very happy together!\n", bachelor, bachelette);
    
    end_dialog();
    return 0;
}
Ejemplo n.º 25
0
/* Kick it off, James! */
int
main(int argc, char **argv)
{
    int retval;
    
    init_dialog();
    
    
    retval = dialog_checklist("this is dialog_checklist() in action, test #3",
			      "Now we show off some of the button 'styles' one can create.",
			      -1, -1, 7, -7, menu4, NULL);
    dialog_clear();
    fprintf(stderr, "spent $%d on %s%s%s books\n", spending, german_book ? " german" : "",
	    italian_book ? " italian" : "", slang_book ? " slang" : "");
    
    end_dialog();
    return 0;
}
Ejemplo n.º 26
0
/*
 * Do some initialization for dialog
 */
void
init_dialog (void)
{
#ifdef LOCALE
    setlocale(LC_CTYPE, "");    /* required by ncurses on linux UTF-8 console */
#endif
    initscr ();			/* Init curses */
    keypad (stdscr, TRUE);
    cbreak ();
    noecho ();


    if (use_colors)	/* Set up colors */
	color_setup ();


    dialog_clear ();
}
Ejemplo n.º 27
0
/* Kick it off, James! */
int
main(int argc, char **argv)
{
  int retval;
  unsigned char result[128];

  init_dialog();

  strcpy(result, "not this!");
  retval = dialog_inputbox("this is dialog_inputbox() in action, test #1",
		       "Enter something really profound below, please.",
		       -1, -1, result);
  dialog_clear();
  fprintf(stderr, "returned value for dialog_inputbox was %d (%s)\n", retval, result);

  end_dialog();
  return 0;
}
Ejemplo n.º 28
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;
}
Ejemplo n.º 29
0
/* Kick it off, James! */
int
main(int argc, char **argv)
{
    int retval;
    
    init_dialog();
    
    
    DialogX = 5;
    DialogY = 1;
    retval = dialog_menu("Do you have the GUTS?",
			 "C'mon, macho man!  Do you have what it takes to do something REALLY\n"
			 "dangerous and stupid?  WHAT ARE YOU WAITING FOR?!",
			 -1, -1, 3, -3, doit + 2, (char *)TRUE, NULL, NULL);
    dialog_clear();
    fprintf(stderr, "returned value for dialog_menu was %d\n", retval);
    
    end_dialog();
    return 0;
}
Ejemplo n.º 30
0
/* Kick it off, James! */
int
main(int argc, unsigned char *argv[])
{
  int retval;
  unsigned char result[128];

  init_dialog();

  result[0]='\0';
  DialogInputAttrs |= DITEM_NO_ECHO;
  retval = dialog_inputbox("this is dialog_inputbox() in action, test #2 (no echo)",
		       "Enter something really secret below, please.",
		       -1, -1, result);
  DialogInputAttrs &= DITEM_NO_ECHO;
  dialog_clear();
  fprintf(stderr, "returned value for dialog_inputbox was %d (%s)\n", retval, result);

  end_dialog();
  return 0;
}