home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************
- *
- * usage.c
- *
- * by J. Alan Eldridge 04/05/90
- *
- * this code is placed in the public domain
- *
- * prints usage messages for user, pausing after N lines,
- * then exits with value passed to it
- *
- *********************************************************************/
-
- #include <stdio.h>
- #include <conio.h>
-
- #include "getargs.h"
-
- #define CR '\r'
- #define NL '\n'
- #define ESC 0x1b
-
- int
- show_txt_w_pause(
- char **msg_arr,
- int nlines)
- {
- static char pause[] = "<RETURN> for more, <ESC> to quit ";
- int n;
- int c;
- char *cp;
- int retval;
-
- retval = n = 0;
- while (cp = *msg_arr++) {
- if (++n == nlines) {
- fputs(pause, stderr);
- do {
- c = getch();
- } while (c != NL && c != ESC && c != CR);
- for (n = 0; n < sizeof(pause) - 1; n++)
- fputs("\b \b", stderr);
- if (c == ESC) {
- retval = -1;
- break;
- }
- n = 0;
- }
- fputs(cp, stderr);
- fputc('\n', stderr);
- }
- return retval;
- }
-
- void
- usage(
- char **msg_arr,
- int nlines,
- int ecode)
- {
- show_txt_w_pause(msg_arr, nlines);
- exit(ecode);
- }
-
-