#include #include #include #include #include #include #include static void erroropen (const char *fname) { fprintf (stderr,"Can't open file %s (%s)\n",fname,strerror(errno)); exit (-1); } int main (int argc, char *argv[]) { int ret = -1; if (argc < 2){ fprintf (stderr,"tlproto: Transform .tlcc file into .cc for the proto utility\n"); }else{ char *tb[argc]; for (int i=1; i and token FILE *fin = fopen (arg,"r"); if (fin == NULL){ erroropen (arg); }else{ FILE *fout = fopen (newfile,"w"); if (fout == NULL){ erroropen (arg); }else{ char buf[1000]; bool outputon = true; while (fgets(buf,sizeof(buf)-1,fin)!=NULL){ if (strncmp(buf,"",5)==0 || strncmp(buf,"",6)==0){ fprintf (fout,"//%s",buf); }else if (strncmp(buf,"",6)==0){ outputon = true; }else if (outputon){ fputs (buf,fout); } } fclose (fout); } fclose (fin); } argv[i] = strdup(newfile); tb[i] = argv[i]; } } if (fork()==0){ execvp ("proto",argv); } int status; wait (&status); ret = WIFEXITED(status) ? 0 : -1; for (int i=1; i