OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [scripts/] [docproc.c] - Blame information for rev 1275

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
#include <stdio.h>
2
#include <stdlib.h>
3
#include <string.h>
4
#include <unistd.h>
5
#include <sys/types.h>
6
#include <sys/wait.h>
7
 
8
/*
9
 *      A simple filter for the templates
10
 */
11
 
12
int main(int argc, char *argv[])
13
{
14
        char buf[1024];
15
        char *vec[8192];
16
        char *fvec[200];
17
        char **svec;
18
        char type[64];
19
        int i;
20
        int vp=2;
21
        int ret=0;
22
        pid_t pid;
23
 
24
 
25
        if(chdir(getenv("TOPDIR")))
26
        {
27
                perror("chdir");
28
                exit(1);
29
        }
30
 
31
        /*
32
         *      Build the exec array ahead of time.
33
         */
34
        vec[0]="kernel-doc";
35
        vec[1]="-docbook";
36
        for(i=1;vp<8189;i++)
37
        {
38
                if(argv[i]==NULL)
39
                        break;
40
                vec[vp++]=type;
41
                vec[vp++]=argv[i];
42
        }
43
        vec[vp++]=buf+2;
44
        vec[vp++]=NULL;
45
 
46
        /*
47
         *      Now process the template
48
         */
49
 
50
        while(fgets(buf, 1024, stdin))
51
        {
52
                if(*buf!='!') {
53
                        printf("%s", buf);
54
                        continue;
55
                }
56
 
57
                fflush(stdout);
58
                svec = vec;
59
                if(buf[1]=='E')
60
                        strcpy(type, "-function");
61
                else if(buf[1]=='I')
62
                        strcpy(type, "-nofunction");
63
                else if(buf[1]=='F') {
64
                        int snarf = 0;
65
                        fvec[0] = "kernel-doc";
66
                        fvec[1] = "-docbook";
67
                        strcpy (type, "-function");
68
                        vp = 2;
69
                        for (i = 2; buf[i]; i++) {
70
                                if (buf[i] == ' ' || buf[i] == '\n') {
71
                                        buf[i] = '\0';
72
                                        snarf = 1;
73
                                        continue;
74
                                }
75
 
76
                                if (snarf) {
77
                                        snarf = 0;
78
                                        fvec[vp++] = type;
79
                                        fvec[vp++] = &buf[i];
80
                                }
81
                        }
82
                        fvec[vp++] = &buf[2];
83
                        fvec[vp] = NULL;
84
                        svec = fvec;
85
                } else
86
                {
87
                        fprintf(stderr, "Unknown ! escape.\n");
88
                        exit(1);
89
                }
90
                switch(pid=fork())
91
                {
92
                case -1:
93
                        perror("fork");
94
                        exit(1);
95
                case  0:
96
                        execvp("scripts/kernel-doc", svec);
97
                        perror("exec scripts/kernel-doc");
98
                        exit(1);
99
                default:
100
                        waitpid(pid, &ret ,0);
101
                }
102
        }
103
        exit(ret);
104
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.