source: mainline/uspace/app/bdsh/cmds/modules/cat/cat.c@ eb9618c

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since eb9618c was 216d6fc, checked in by Tim Post <echo@…>, 17 years ago

Merge with shell @ 3241 for bdsh

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/* Automatically generated by mknewcmd on Wed Aug 13 15:41:09 PHT 2008
2 * This is machine generated output. The author of mknewcmd claims no
3 * copyright over the contents of this file. Where legally permitted, the
4 * contents herein are donated to the public domain.
5 *
6 * You should apply any license and copyright that you wish to this file,
7 * replacing this header in its entirety. */
8
9#include <stdio.h>
10#include <stdlib.h>
11#include <getopt.h>
12
13#include "config.h"
14#include "util.h"
15#include "errors.h"
16#include "entry.h"
17#include "cat.h"
18#include "cmds.h"
19
20static char *cmdname = "cat";
21
22static struct option long_options[] = {
23 { "help", no_argument, 0, 'h' },
24 { "version", no_argument, 0, 'v' },
25 { "file", required_argument, 0, 'f' },
26 { 0, 0, 0, 0 }
27};
28
29/* Dispays help for cat in various levels */
30void * help_cmd_cat(unsigned int level)
31{
32 printf("This is the %s help for '%s'.\n",
33 level ? EXT_HELP : SHORT_HELP, cmdname);
34 return CMD_VOID;
35}
36
37/* Main entry point for cat, accepts an array of arguments */
38int * cmd_cat(char **argv)
39{
40 unsigned int argc;
41 unsigned int i;
42 int c, opt_ind;
43
44 /* Count the arguments */
45 for (argc = 0; argv[argc] != NULL; argc ++);
46
47 printf("%s %s\n", TEST_ANNOUNCE, cmdname);
48 printf("%d arguments passed to %s\n", argc - 1, cmdname);
49
50 for (i = 1; i < argc; i++)
51 printf("[%d] -> %s\n", i, argv[i]);
52
53 for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
54 c = getopt_long(argc, argv, "f:hv", long_options, &opt_ind);
55 switch (c) {
56 case 'h':
57 help_cmd_cat(HELP_SHORT);
58 break;
59 case 'v':
60 printf("I have no version, sorry.\n");
61 break;
62 case 'f':
63 printf("File : %s\n", optarg);
64 break;
65 }
66 }
67
68 printf("argc = %d, optind = %d\n", argc, optind);
69
70 return CMD_SUCCESS;
71}
72
Note: See TracBrowser for help on using the repository browser.