16 fputs("usage: iomenu ", stdout
);
17 puts("[-c] [-n] [-N] [-k key] [-s separator] [-p prompt] [-l lines]");
24 main(int argc
, char *argv
[])
27 Buffer
*buffer
= NULL
;
28 int tty_fd
= open("/dev/tty", O_RDWR
);
29 Opt
*opt
= malloc(sizeof(Opt
));
31 opt
->line_numbers
= FALSE
;
32 opt
->complete
= FALSE
;
33 opt
->print_number
= FALSE
;
34 opt
->validate_key
= CONTROL('M');
35 opt
->separator
= NULL
;
39 /* command line arguments */
40 for (i
= 1; i
< argc
; i
++) {
41 if (argv
[i
][0] == '-' && strlen(argv
[i
]) == 2) {
47 opt
->line_numbers
= TRUE
;
50 opt
->print_number
= TRUE
;
51 opt
->line_numbers
= TRUE
;
54 opt
->validate_key
= (argv
[i
++][0] == '^') ?
59 opt
->separator
= argv
[++i
];
62 if (sscanf(argv
[++i
], "%d", &opt
->lines
) <= 0)
63 die("Wrong number format after -l.");
66 opt
->prompt
= argv
[++i
];
76 /* command line arguments */
77 buffer
= fill_buffer(opt
->separator
);
79 /* set the interface */
80 filter_lines(buffer
, opt
);
81 draw_screen(buffer
, tty_fd
, opt
);
83 /* listen and interact to input */
84 input_get(buffer
, tty_fd
, opt
);
86 draw_clear(opt
->lines
);
88 /* close files descriptors and pointers, and free memory */