Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3318 → Rev 3319

/branches/shell/uspace/app/bdsh/cmds/modules/cat/cat.c
8,6 → 8,8
 
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
 
#include "config.h"
#include "util.h"
#include "errors.h"
17,6 → 19,13
 
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)
{
30,22 → 39,34
{
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", argc - 1, cmdname);
printf("%d arguments passed to %s\n", argc - 1, cmdname);
 
if (argc < 2) {
printf("\n");
return CMD_SUCCESS;
}
 
printf(":\n");
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;
}