16 fputs("usage: iomenu [-n] [-N] [-k key] [-s separator] ", stderr
);
17 fputs("[-p prompt] [-l lines]\n", stderr
);
24 main(int argc
, char *argv
[])
26 int i
, exit_code
, tty_fd
= open("/dev/tty", O_RDWR
);
27 Buffer
*buffer
= NULL
;
28 Opt
*opt
= malloc(sizeof(Opt
));
30 opt
->line_numbers
= 0;
31 opt
->print_number
= 0;
32 opt
->validate_key
= CONTROL('M');
33 opt
->separator
= NULL
;
37 /* command line arguments */
38 for (i
= 1; i
< argc
; i
++) {
39 if (argv
[i
][0] != '-' || strlen(argv
[i
]) != 2)
44 opt
->line_numbers
= 1;
47 opt
->print_number
= 1;
48 opt
->line_numbers
= 1;
51 opt
->print_header
= 1;
54 opt
->validate_key
= (argv
[++i
][0] == '^') ?
55 CONTROL(toupper(argv
[i
][1])): argv
[i
][0];
58 opt
->separator
= argv
[++i
];
61 if (sscanf(argv
[++i
], "%d", &opt
->lines
) <= 0)
62 die("wrong number format after -l");
66 die("wrong string format after -p");
67 opt
->prompt
= argv
[i
];
74 /* command line arguments */
75 buffer
= fill_buffer(opt
->separator
);
77 /* set the interface */
78 draw_screen(buffer
, tty_fd
, opt
);
80 /* listen and interact to input */
81 exit_code
= input_get(buffer
, tty_fd
, opt
);
83 draw_clear(opt
->lines
);
85 /* close files descriptors and pointers, and free memory */