示例#1
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);
}
示例#2
0
static int
display_menu(void)
{
	int	ret=0;
	int	maxx,maxy;
	int	curr;

	do_init_dialog();
	getmaxyx(stdscr, maxy, maxx);
	dialog_vars.help_button=1;
	dialog_vars.item_help=1;
loop:
	switch(ret=dlg_checklist("Welcome to pkg_cleanup.", "These are the leaf packages installed on your system\nChose the packages to deinstall. Help will display the package description.", maxy-1, maxx, maxy-9, menulen, menu, " X", FLAG_CHECK, &curr)) {
		case DLG_EXIT_HELP: {
			char *p = read_desc(menu[curr].ITEM_PROMPT);
			if(p) {
				dialog_vars.help_button=0;
				dialog_msgbox(menu[curr].ITEM_DATA, p, maxy-4, maxx-4, TRUE);
				dialog_vars.help_button=1;
				free(p);
			}
			goto loop;
		}
		case 0:
			ret=0;
			break;
		default:
			ret=-1;
			break;
	}
	dialog_vars.help_button=0;
	dialog_vars.item_help=0;
	end_dialog();
	return(ret);
}
示例#3
0
static int 
_menu1_sh_action(dialogMenuItem * self)
{
	dialog_clear();
	end_dialog();
	exit(0);
}
示例#4
0
/* Run some general command */
int
systemExecute(char *command)
{
    int status;
    struct termios foo;
    WINDOW *w = savescr();

    dialog_clear();
    dialog_update();
    end_dialog();
    DialogActive = FALSE;
    if (tcgetattr(0, &foo) != -1) {
	foo.c_cc[VERASE] = '\010';
	tcsetattr(0, TCSANOW, &foo);
    }
    if (!Fake)
	status = system(command);
    else {
	status = 0;
	msgDebug("systemExecute:  Faked execution of `%s'\n", command);
    }
    DialogActive = TRUE;
    restorescr(w);
    return status;
}
示例#5
0
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;
}
示例#6
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;
}
示例#7
0
void MainWindow::reinitScreen()
{
    /* FIXME: there must be a better way to do this */
    end_dialog();
    erase();
    init_dialog(stdin, stdout);
    dlg_put_backtitle();
}
示例#8
0
文件: mconf.c 项目: ChenBoTang/ARM
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;
}
示例#9
0
文件: mconf.c 项目: WTHsieh/diag
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;
}
示例#10
0
static int 
_menu1_re_action(dialogMenuItem * self)
{
	dialog_clear();
	end_dialog();
	endwin();
	system("/sbin/reboot");
	exit(0);
}
示例#11
0
int main(int argc, char *argv[])
{
	
	init_dialog(); 
	_afm_menu();

	end_dialog();

	return 0;		
}
示例#12
0
void
systemSuspendDialog(void)
{

    oldW  = savescr();
    dialog_clear();
    dialog_update();
    end_dialog();
    DialogActive = FALSE;
}
示例#13
0
static int
keep_going(void)
{
	int ret;

	do_init_dialog();
	ret = !dialog_yesno(NULL,"Do you want to process the new leaves packages?",-1,-1);
	end_dialog();
	return(ret);
}
示例#14
0
int
main(int argc, char **argv)
{
	int retval;
	unsigned char *tresult;
	char comstr[BUFSIZ];

	init_dialog();
	do {
		use_helpline("Press OK for listing directory");
		retval = dialog_tree(names, 
			sizeof(names)/sizeof(unsigned char *) - 1,
			 '/',
			"tree dialog box example",
			"Typical find -x / -type d output", 
			-1, -1, 15,
                        	    &tresult);
		
		if (retval)
			break;
		
		use_helpline(NULL);
		(void)snprintf(comstr, sizeof(comstr), 
			"ls -CF %s", tresult);

		retval = dialog_prgbox(
			comstr, 
			comstr, 20, 60, TRUE, TRUE);

		dialog_clear();
  		
		retval = dialog_tree(names1, 
			sizeof(names1)/sizeof(unsigned char *),
			 ':',
			"tree dialog box example",
			"Other tree", 
			-1, -1, 5,
                        	    &tresult);
		if (!retval)
		{
	  		dialog_clear();
  		}
	} while (!retval);

	dialog_update();
	
	dialog_clear();
	
	end_dialog();
  	
	exit(retval);
}
示例#15
0
static int
shell_fire(dialogMenuItem *self)
{
	end_dialog();
	if (fork() == 0) {
		execl("/bin/tcsh", "tcsh", NULL);
		_exit(1);
	} else {
		wait(NULL);
	}

	return (0);
}
示例#16
0
/* Goes through the glob contents, looking for zero-length +REQUIRED-BY */
static int
read_pkglist(int loops)
{
	FILE	*pkg;
	char	line[1024];
	char	*p;

	do_init_dialog();
	dialog_msgbox(NULL, "Searching for leaves", 5, 23, FALSE);
	fflush(stdout);
	pkg=popen("/usr/sbin/pkg query -e \"%#r=0 && %k=0\" \"%n-%v\\t%c\"", "r");
	if(!pkg) {
		fputs("Error executing pkg.\n", stderr);
		return -1;
	}
	while(fgets(line, sizeof(line), pkg)!=NULL) {
		for(p=strchr(line, 0)-1; p>line && isspace(*p); p--)
			*p=0;
		p=strtok(line, "\t");
		p=strtok(NULL, "\0");
		add_item(line, p?p:"");
	}
	if(WEXITSTATUS(pclose(pkg)) && menulen==0) {
		fputs("pkg returned an error.\n", stderr);
		return -1;
	}
	dlg_clear();
	if(menulen==0) {
		if(loops)
			dialog_msgbox(NULL, "No new leaves found", 5, 23, TRUE);
		else
			dialog_msgbox(NULL, "No leaves found", 5, 19, TRUE);
		end_dialog();
		return(-1);
	}
	end_dialog();
	return(0);
}
示例#17
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;
}
示例#18
0
/* Kick it off, James! */
int
main(int argc, char **argv)
{
  int i;

  init_dialog();

  for (i = 0; i <= 100; i++) {
    dialog_gauge("Gas tank", "When this gets 100% full, you'd better yank out the nozzle!", 10, 1, 7, 70, i);
    usleep(30000);
  }
  end_dialog();
  return 0;
}
示例#19
0
文件: partedit.c 项目: coyizumi/cs111
static void
sigint_handler(int sig)
{
	struct gmesh mesh;

	/* Revert all changes and exit dialog-mode cleanly on SIGINT */
	geom_gettree(&mesh);
	gpart_revert_all(&mesh);
	geom_deletetree(&mesh);

	end_dialog();

	exit(1);
}
示例#20
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;
}
示例#21
0
static int ping_button_callback( SsdWidget widget, const char *new_value ) {

   if ( ( widget != NULL ) && !strcmp(widget->name, "Next") )
   {
      ping_button_handler();
   }

#ifdef ANDROID
   end_button_callback ( NULL, NULL );
#else
   end_dialog();
#endif

   return 1;
}
示例#22
0
文件: msg.c 项目: asdlei00/freebsd
/* 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;
}
示例#23
0
int 
delete_rule()
{
	FILE *stream = NULL;
	int i = 0;
	char buf[256];
	char pr[3];
	char *s;

	dialog_clear();

	stream = fopen(RULESCRIPT, "r");
	if (stream == NULL) {
		end_dialog();
		return -1;
	}
	dialog_clear();

	bzero(rlist, sizeof(rlist));

	while (fgets(buf, sizeof(buf), stream) != NULL) {
		if (strlen(buf) > 1) {
			buf[strlen(buf) - 1] = '\0';
			if (i < 9)
				snprintf(pr, sizeof(pr), "0%d", i + 1);
			else
				snprintf(pr, sizeof(pr), "%d", i + 1);

			strtok(strdup(buf), "q");
			s = strtok(NULL, "q");
			rlist[i].prompt = strdup(pr);
			rlist[i].title = s;
			rlist[i].checked = NULL;
			rlist[i].fire = drop_rule;
			i++;
		}
	}

	if (i == 0) {
		dialog_msgbox("ClosedBSD", "There are no rules to delete    ", -1, -1, 1);
		fclose(stream);
		return DITEM_SUCCESS | DITEM_RESTORE | DITEM_CONTINUE;
	}
	fclose(stream);
	dialog_menu("ClosedBSD", "Please select a rule to remove", -1, -1, i, -i, rlist, NULL, NULL, NULL);

	return 0;
}
示例#24
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;
}
示例#25
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;
}
示例#26
0
文件: dpv.c 项目: coyizumi/cs111
static int
operate_on_lines(struct dpv_file_node *file, int out)
{
	char *p;
	int progress;
	ssize_t r, w;

	if (operate_common(file, out) < 0)
		return (-1);

	/* [Re-]Fill the buffer */
	if ((r = read(fd, buf, bsize)) <= 0) {
		if (fd != STDIN_FILENO)
			close(fd);
		fd = -1;
		file->status = DPV_STATUS_DONE;
		return (100);
	}
	buf[r] = '\0';

	/* [Re-]Dump the buffer */
	if (out >= 0) {
		if ((w = write(out, buf, r)) < 0) {
			end_dialog();
			err(EXIT_FAILURE, "output");
		}
		fsync(out);
	}

	/* Process the buffer for number of lines */
	for (p = buf; p != NULL && *p != '\0';)
		if ((p = strchr(p, '\n')) != NULL)
			dpv_overall_read++, p++, file->read++;

	/* Calculate percentage of completion (if possible) */
	if (file->length >= 0) {
		progress = (file->read * 100 / file->length);

		/* If no_overrun, do not return 100% until read >= length */
		if (no_overrun && progress == 100 && file->read < file->length)
			progress--;
			
		return (progress);
	} else
		return (-1);
}
示例#27
0
int run(int argc, char **argv)
{
	FILE *input = stdin;
	dialog_state.output = stderr;
	char *ptr;

	fwutil_i18ninit(__FILE__);
	init_dialog(input, dialog_state.output);
	fwdialog_backtitle(_("RAID configuration"));

	ptr = ask_mode();
	free(ptr);

	if(argv!=NULL)
		end_dialog();
	return(0);
}
示例#28
0
文件: menu1.c 项目: asdlei00/freebsd
/* 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;
}
示例#29
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;
}
示例#30
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;
}