Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3345 → Rev 3346

/trunk/uspace/app/bdsh/cmds/modules/cat/cat.c
0,0 → 1,72
/* Automatically generated by mknewcmd on Wed Aug 13 15:41:09 PHT 2008
* This is machine generated output. The author of mknewcmd claims no
* copyright over the contents of this file. Where legally permitted, the
* contents herein are donated to the public domain.
*
* You should apply any license and copyright that you wish to this file,
* replacing this header in its entirety. */
 
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
 
#include "config.h"
#include "util.h"
#include "errors.h"
#include "entry.h"
#include "cat.h"
#include "cmds.h"
 
static char *cmdname = "cat";
 
static struct option long_options[] = {
{ "help", no_argument, 0, 'h' },
{ "version", no_argument, 0, 'v' },
{ "file", required_argument, 0, 'f' },
{ 0, 0, 0, 0 }
};
 
/* Dispays help for cat in various levels */
void * help_cmd_cat(unsigned int level)
{
printf("This is the %s help for '%s'.\n",
level ? EXT_HELP : SHORT_HELP, cmdname);
return CMD_VOID;
}
 
/* Main entry point for cat, accepts an array of arguments */
int * cmd_cat(char **argv)
{
unsigned int argc;
unsigned int i;
int c, opt_ind;
 
/* Count the arguments */
for (argc = 0; argv[argc] != NULL; argc ++);
 
printf("%s %s\n", TEST_ANNOUNCE, cmdname);
printf("%d arguments passed to %s\n", argc - 1, cmdname);
 
for (i = 1; i < argc; i++)
printf("[%d] -> %s\n", i, argv[i]);
 
for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
c = getopt_long(argc, argv, "f:hv", long_options, &opt_ind);
switch (c) {
case 'h':
help_cmd_cat(HELP_SHORT);
break;
case 'v':
printf("I have no version, sorry.\n");
break;
case 'f':
printf("File : %s\n", optarg);
break;
}
}
 
printf("argc = %d, optind = %d\n", argc, optind);
 
return CMD_SUCCESS;
}