File: options.c

package info (click to toggle)
icmake 7.12.5-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,776 kB
  • ctags: 1,494
  • sloc: ansic: 7,785; makefile: 3,724; sh: 302; cpp: 95
file content (92 lines) | stat: -rw-r--r-- 2,646 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
                                O P T I O N S . C
*/

#include "icmake.h"

int options (char **argv, int *argc)
{
    register int
        c;
    char
        *cp;
    char
        pid_string[30];                     /* used with -x */

    while ((c = getopt(argc, argv)) != -1)
    {
        switch (c)
        {
            case 'a':
                about();
            break;

            case 'b':
                flags |= f_blunt;
            break;

            case 'c':
                flags |= f_compiler;
            break;

            case 'i':
                flags |= f_icmake;          /* flag icmake taken literally  */
                if (!(source_name = getoptval(argc, argv)))
                    error("-i requires source-filename");
                return getoptindex();       /* and return the index of args */
                                            /* to icm-exec */
            case 'p':
                flags |= f_preprocessor;
            break;

            case 'q':
                flags |= f_quiet;           /* no banner */
            break;

            case 't':
                flags |= f_tmpbim | f_icmake; /* flag use temporary bimfile  */

                if (!(cp = getoptval(argc, argv)))
                    error("-t requires temporary bim-filename");

                while (*cp == ' ')          /* skip initial blanks in optval*/
                    cp++;

                                            /* build pid-string */
                sprintf(pid_string, "%d", getpid());
                                            /* destination with pid-extension */
                dest_name = xstrdup(change_ext(cp, pid_string));
                                            
                strcat(pid_string, "a");    /* temp. pim-file extension */
                temporary = xstrdup(change_ext(cp, pid_string));

                source_name = argv[1];
            return getoptindex() + 1;       /* index of remaining args */
                                            /* + 1 for the extra arg on the */
                                            /* #!/...-x... line */

            case '-':
                return getoptindex();       /* return index of args to icm-exec
                                            */
        }
    }
    return *argc;
                                            /* return index of args to icm-exec
                                            */
}

/*
int flags;

void main(int argc, char **argv)
{
    options(argv, &argc);

    printf("flags: %x\n"
            "arguments:\n"
            ,
            flags);
    while (argc--)
        puts(*argv++);
}
*/