~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/scripts/docproc.c

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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>
  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         pid_t pid;
 22 
 23 
 24         if(chdir(getenv("TOPDIR")))
 25         {
 26                 perror("chdir");
 27                 exit(1);
 28         }
 29         
 30         /*
 31          *      Build the exec array ahead of time.
 32          */
 33         vec[0]="kernel-doc";
 34         vec[1]="-docbook";
 35         for(i=1;vp<8189;i++)
 36         {
 37                 if(argv[i]==NULL)
 38                         break;
 39                 vec[vp++]=type;
 40                 vec[vp++]=argv[i];
 41         }
 42         vec[vp++]=buf+2;
 43         vec[vp++]=NULL;
 44         
 45         /*
 46          *      Now process the template
 47          */
 48          
 49         while(fgets(buf, 1024, stdin))
 50         {
 51                 if(*buf!='!') {
 52                         printf("%s", buf);
 53                         continue;
 54                 }
 55 
 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;
 73                                 }
 74 
 75                                 if (snarf) {
 76                                         snarf = 0;
 77                                         fvec[vp++] = type;
 78                                         fvec[vp++] = &buf[i];
 79                                 }
 80                         }
 81                         fvec[vp++] = &buf[2];
 82                         fvec[vp] = NULL;
 83                         svec = fvec;
 84                 } else
 85                 {
 86                         fprintf(stderr, "Unknown ! escape.\n");
 87                         exit(1);
 88                 }
 89                 switch(pid=fork())
 90                 {
 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);
100                 }
101         }
102         exit(0);
103 }
104 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.