Subversion Repositories HelenOS

Rev

Rev 3319 | Rev 3356 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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