File: tester3.c

package info (click to toggle)
notion 4.0.2%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,676 kB
  • sloc: ansic: 47,508; sh: 2,096; makefile: 603; perl: 270
file content (72 lines) | stat: -rw-r--r-- 1,751 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * libtu/tester3.c
 *
 * Copyright (c) Tuomo Valkonen 1999-2002.
 *
 * You may distribute and modify this library under the terms of either
 * the Clarified Artistic License or the GNU LGPL, version 2.1 or later.
 */

#include <stdio.h>

#include "util.h"
#include "misc.h"
#include "optparser.h"


static const char usage[]=
    "Usage: $p [options]\n"
    "\n"
    "Where options are:\n"
    "$o\n";


static OptParserOpt opts[]={
    {'o',    "opt", OPT_ARG, "OPTION", "foo bar baz quk asdf jkl lk dfgh quik aaaa bbbb cccc dddd eeee ffff"},
    {'f',    "file", OPT_ARG, "FILE", "asdfsadlflkjasdflkjasdflkjasdflkjas dlfjkasdflkjasdflkjasdfasdfljasdfkasdjlfkasdlfjasdlfjklkasjdfasdflkjasd asdljfasldf  asdlfkasdlf asfdlk asdfljkadsflasdflasdlkfjasdlfasdlflskflasdfalsdf"},
    {'v',    "view",    0, NULL, "asfasdf"},
    {'z',    "zip", 0, NULL, "asdfasdf"},
    {'x',    "extract", 0, NULL, "asdfasdf"},
    {0, NULL, 0, NULL, NULL}
};

static OptParserCommonInfo tester3_cinfo={
    NULL,
    usage,
    NULL
};


int main(int argc, char *argv[])
{
    int opt;

    libtu_init(argv[0]);

    optparser_init(argc, argv, OPTP_NO_DASH, opts, &tester3_cinfo);

    while((opt=optparser_get_opt())){
        switch(opt){
        case 'o':
            printf("opt: %s\n", optparser_get_arg());
            break;
        case 'f':
            printf("file: %s\n", optparser_get_arg());
            break;
        case 'v':
            printf("view\n");
            break;
        case 'z':
            printf("zip\n");
            break;
        case 'x':
            printf("extract\n");
            break;
        default:
            optparser_print_error();
            return 1;
        }
    }
    return 0;
}