1
diff -ruN newt-0.51.6-old/whiptail.c newt-0.51.6/whiptail.c
2
--- newt-0.51.6-old/whiptail.c 2004-02-23 11:25:08.000000000 +0000
3
+++ newt-0.51.6/whiptail.c 2004-02-23 11:40:15.000000000 +0000
6
enum mode { MODE_NONE, MODE_INFOBOX, MODE_MSGBOX, MODE_YESNO, MODE_CHECKLIST,
7
MODE_INPUTBOX, MODE_RADIOLIST, MODE_MENU, MODE_GAUGE ,
9
+ MODE_TEXTBOX, MODE_PASSWORDBOX};
11
#define OPT_MSGBOX 1000
12
#define OPT_CHECKLIST 1001
14
#define OPT_RADIOLIST 1006
15
#define OPT_GAUGE 1007
16
#define OPT_INFOBOX 1008
17
+#define OPT_TEXTBOX 1009
18
#define OPT_PASSWORDBOX 1010
20
static void usage(void) {
26
+readTextFile(const char * filename)
28
+ int fd = open(filename, O_RDONLY, 0);
32
+ if ( fd < 0 || fstat(fd, &s) != 0 ) {
37
+ if ( (buf = malloc(s.st_size)) == 0 )
38
+ fprintf(stderr, "%s: too large to display.\n", filename);
40
+ if ( read(fd, buf, s.st_size) != s.st_size ) {
48
int main(int argc, const char ** argv) {
49
enum mode mode = MODE_NONE;
52
{ "scrolltext", '\0', 0, &scrollText, 0 },
53
{ "separate-output", '\0', 0, &separateOutput, 0 },
54
{ "title", '\0', POPT_ARG_STRING, &title, 0 },
55
+ { "textbox", '\0', 0, 0, OPT_TEXTBOX },
56
{ "yesno", '\0', 0, 0, OPT_YESNO },
57
{ "passwordbox", '\0', 0, 0, OPT_PASSWORDBOX },
64
+ if (mode != MODE_NONE) usage();
65
+ mode = MODE_TEXTBOX;
69
if (mode != MODE_NONE) usage();
70
mode = MODE_PASSWORDBOX;
73
if (!(text = poptGetArg(optCon))) usage();
75
+ if ( mode == MODE_TEXTBOX ) text = readTextFile(text);
77
if (!(nextArg = poptGetArg(optCon))) usage();
78
height = strtoul(nextArg, &end, 10);
85
rc = messageBox(text, height, width, MSGBOX_MSG, flags);