diff options
author | jkh <jkh@FreeBSD.org> | 1999-02-01 06:08:21 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1999-02-01 06:08:21 +0000 |
commit | d02485ce0ba6462c7c8ec2094955ac533cd73daa (patch) | |
tree | 14ed723cbe769fe220e55ec628ee14146de7b4d0 /sys/boot/common/commands.c | |
parent | 81596f0f40afeff4a9e4d4f5c4deef52145afce2 (diff) | |
download | FreeBSD-src-d02485ce0ba6462c7c8ec2094955ac533cd73daa.zip FreeBSD-src-d02485ce0ba6462c7c8ec2094955ac533cd73daa.tar.gz |
Whoops! Forgot to include Mr. Sobray's more command in the last set
of commits.
Submitted by: Daniel C. Sobral <dcs@newsguy.com>
Diffstat (limited to 'sys/boot/common/commands.c')
-rw-r--r-- | sys/boot/common/commands.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/sys/boot/common/commands.c b/sys/boot/common/commands.c index fe0eb54..00b93d8 100644 --- a/sys/boot/common/commands.c +++ b/sys/boot/common/commands.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: commands.c,v 1.8 1999/01/09 02:34:48 msmith Exp $ + * $Id: commands.c,v 1.9 1999/01/11 06:41:31 msmith Exp $ */ #include <stand.h> @@ -35,6 +35,7 @@ char *command_errmsg; char command_errbuf[256]; /* XXX should have procedural interface for setting, size limit? */ +static int page_file(char *filename); /* * Help is read from a formatted text file. @@ -384,6 +385,50 @@ command_read(int argc, char *argv[]) } /* + * File pager + */ +COMMAND_SET(more, "more", "show contents of a file", command_more); + +static int +command_more(int argc, char *argv[]) +{ + int i; + int res; + char line[80]; + + res=0; + pager_open(); + for (i = 1; (i < argc) && (res == 0); i++) { + sprintf(line, "*** FILE %s BEGIN ***\n", argv[i]); + pager_output(line); + res = page_file(argv[i]); + if (!res) { + sprintf(line, "*** FILE %s END ***\n", argv[i]); + pager_output(line); + } + } + pager_close(); + + if (res == 0) + return CMD_OK; + else + return CMD_ERROR; +} + +static int +page_file(char *filename) +{ + int result; + + result = pager_file(filename); + + if (result == -1) + sprintf(command_errbuf, "error showing %s", filename); + + return result; +} + +/* * List all disk-like devices */ COMMAND_SET(lsdev, "lsdev", "list all devices", command_lsdev); |