switchs.c 784 Bytes
Newer Older
hark's avatar
hark committed
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
#include <stdio.h>
#include "switchs.h"

int main(int argc, char **argv) {
     switchs(argv[1]) {
        cases("foo")
        cases("bar")
            printf("foo or bar (case sensitive)\n");
            break;

        icases("pi")
            printf("pi or Pi or pI or PI (case insensitive)\n");
            break;

        cases_re("^D.*",0)
            printf("Something that start with D (case sensitive)\n");
            break;

        cases_re("^E.*",REG_ICASE)
            printf("Something that start with E (case insensitive)\n");
            break;

        cases("1")
            printf("1\n");

        cases("2")
            printf("2\n");
            break;

        defaults
            printf("No match\n");
            break;
    } switchs_end;
 
    return 0;
}