diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2000-03-19 01:28:40 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2000-03-19 01:28:40 +0000 |
commit | 8abb719409c9060a7c0676f76e9182c1e0b8ca46 (patch) | |
tree | b88cc5a6cd513a04a512b7e6215c873c90a1c5dd /scripts/docproc.c | |
parent | f01bd7aeafd95a08aafc9e3636bb26974df69d82 (diff) |
Merge with 2.3.99-pre1.
Diffstat (limited to 'scripts/docproc.c')
-rw-r--r-- | scripts/docproc.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/scripts/docproc.c b/scripts/docproc.c new file mode 100644 index 000000000..0c23e87c1 --- /dev/null +++ b/scripts/docproc.c @@ -0,0 +1,78 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/wait.h> + +/* + * A simple filter for the templates + */ + +int main(int argc, char *argv[]) +{ + char buf[1024]; + char *vec[1024]; + char type[64]; + int i; + int vp=2; + pid_t pid; + + + if(chdir(getenv("TOPDIR"))) + { + perror("chdir"); + exit(1); + } + + /* + * Build the exec array ahead of time. + */ + vec[0]="kernel-doc"; + vec[1]="-docbook"; + for(i=1;vp<1021;i++) + { + if(argv[i]==NULL) + break; + vec[vp++]=type; + vec[vp++]=argv[i]; + } + vec[vp++]=buf+2; + vec[vp++]=NULL; + + /* + * Now process the template + */ + + while(fgets(buf, 1024, stdin)) + { + if(*buf!='!') + printf("%s", buf); + else + { + fflush(stdout); + if(buf[1]=='E') + strcpy(type, "-function"); + else if(buf[1]=='I') + strcpy(type, "-nofunction"); + else + { + fprintf(stderr, "Unknown ! escape.\n"); + exit(1); + } + switch(pid=fork()) + { + case -1: + perror("fork"); + exit(1); + case 0: + execvp("scripts/kernel-doc", vec); + perror("exec"); + exit(1); + default: + waitpid(pid, NULL,0); + } + } + } + exit(0); +} |