/* Display a help file in a filebox */ int systemDisplayHelp(char *file) { char *fname = NULL; char buf[FILENAME_MAX]; int ret = 0; WINDOW *w = savescr(); printf("zzz"); fname = systemHelpFile(file, buf); if (!fname) { snprintf(buf, FILENAME_MAX, "The %s file is not provided on this particular floppy image.", file); use_helpfile(NULL); use_helpline(NULL); dialog_mesgbox("Sorry!", buf, -1, -1); ret = 1; } else { use_helpfile(NULL); use_helpline(NULL); dialog_textbox(file, fname, LINES, COLS); } restorescr(w); return ret; }
static int j_textbox(JUMPARGS) { *offset_add = 4; return dialog_textbox(t, av[1], numeric_arg(av, 2), numeric_arg(av, 3)); }
static void show_textbox(const char *title, const char *text, int r, int c) { int fd; fd = creat(".help.tmp", 0777); write(fd, text, strlen(text)); close(fd); while (dialog_textbox(title, ".help.tmp", r, c) < 0) ; unlink(".help.tmp"); }
/* 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; }
/* * Display a help-file as a textbox widget. */ int dialog_helpfile(const char *title, const char *file, int height, int width) { int result = DLG_EXIT_ERROR; if (!dialog_vars.in_helpfile && file != 0 && *file != '\0') { dialog_vars.in_helpfile = TRUE; result = dialog_textbox(title, file, height, width); dialog_vars.in_helpfile = FALSE; } return (result); }
void do_install(void) { int fd[2]; int status; struct pollfd pfd; screen_clear(MODULE); if (dialog_yesno(MODULE, "Do you want to start the installation?", 5, 60)) return; dialog_busy(5, 60, "Initializing installation..."); if (pipe(fd) < 0) { end_dialog(); err(1, "cannot create a pipe"); } signal(SIGCHLD, sig_chld); switch (fork()) { case 0: close(fd[1]); dup2(fd[0], STDERR_FILENO); dup2(fd[0], STDOUT_FILENO); close(fd[0]); execl(PCSYSINSTALL, "pc-sysinstall", "-c", "result.cfg", NULL); _exit(1); close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); break; case -1: close(fd[0]); close(fd[1]); break; default: { int i, ret; char buf[1]; char line[1024]; pfd.fd = fd[1]; pfd.events = POLLIN; i = 0; while (!signaled) { ret = poll(&pfd, 1, 1000); if (ret == 0) continue; if (ret < 0) break; /* XXX really optimize this */ if (read(fd[1], buf, 1) < 0) break; if (*buf == '\n') { line[i] = 0; show_progress(line); i = 0; } else { line[i] = *buf; i++; } } wait(&status); } } close(fd[0]); close(fd[1]); if (status != 0) dialog_textbox("Error occured", "/tmp/.pc-sysinstall/pc-sysinstall.log", 20, 70); else { screen_clear(MODULE); dialog_mesgbox("Installation finished", "Congratulations, you now have PC-BSD or FreeBSD " "installed\nin your system.\n\n", 7, 70); } system("/bin/sh"); exit(0); }
static void show_textbox(const char *title, const char *text, int r, int c) { dialog_clear(); dialog_textbox(title, text, r, c); }
static void show_file(const char *filename, const char *title, int r, int c) { while (dialog_textbox(title, filename, r ? r : rows, c ? c : cols) < 0) ; }