Kill st_fstype member.
[linux-2.6/linux-mips.git] / scripts / docproc.c
blob465a604a33e10d97d0dc56742c740e96abe0a2a7
1 #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>
8 /*
9 * A simple filter for the templates
12 int main(int argc, char *argv[])
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 pid_t pid;
24 if(chdir(getenv("TOPDIR")))
26 perror("chdir");
27 exit(1);
31 * Build the exec array ahead of time.
33 vec[0]="kernel-doc";
34 vec[1]="-docbook";
35 for(i=1;vp<8189;i++)
37 if(argv[i]==NULL)
38 break;
39 vec[vp++]=type;
40 vec[vp++]=argv[i];
42 vec[vp++]=buf+2;
43 vec[vp++]=NULL;
46 * Now process the template
49 while(fgets(buf, 1024, stdin))
51 if(*buf!='!') {
52 printf("%s", buf);
53 continue;
56 fflush(stdout);
57 svec = vec;
58 if(buf[1]=='E')
59 strcpy(type, "-function");
60 else if(buf[1]=='I')
61 strcpy(type, "-nofunction");
62 else if(buf[1]=='F') {
63 int snarf = 0;
64 fvec[0] = "kernel-doc";
65 fvec[1] = "-docbook";
66 strcpy (type, "-function");
67 vp = 2;
68 for (i = 2; buf[i]; i++) {
69 if (buf[i] == ' ' || buf[i] == '\n') {
70 buf[i] = '\0';
71 snarf = 1;
72 continue;
75 if (snarf) {
76 snarf = 0;
77 fvec[vp++] = type;
78 fvec[vp++] = &buf[i];
81 fvec[vp++] = &buf[2];
82 fvec[vp] = NULL;
83 svec = fvec;
84 } else
86 fprintf(stderr, "Unknown ! escape.\n");
87 exit(1);
89 switch(pid=fork())
91 case -1:
92 perror("fork");
93 exit(1);
94 case 0:
95 execvp("scripts/kernel-doc", svec);
96 perror("exec scripts/kernel-doc");
97 exit(1);
98 default:
99 waitpid(pid, NULL,0);
102 exit(0);