home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mesa5.zip / mesa5src.zip / Utils / Convert / convert.cpp next >
C/C++ Source or Header  |  2002-11-26  |  1KB  |  57 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int Convert(char *filefrom, char *fileto);
  6.  
  7. int main(int n, char *par[])
  8. {
  9.    if(n < 3)
  10.    {  printf("Convert typedef functions to VAC3 acceptable form\n");
  11.       printf("Convert FileFrom FileTo\n");
  12.    }
  13.    Convert(par[1], par[2]);
  14. }
  15.  
  16. int Convert(char *filefrom, char *fileto)
  17. {  FILE *fp, *fpto;
  18.    char str[1024], *pstr;
  19.    char str1[1024], *pstr1, *pstr2, *pstrout;
  20.    char str2[1024];
  21.  
  22.    int i,is,n,n1, dn;  
  23.    fp = fopen(filefrom,"r");
  24.    fpto = fopen(fileto,"w");
  25.    n = n1=0;
  26.    for(;;)
  27.    {  pstr = fgets(str, 1023,fp);
  28.       if(pstr == NULL)
  29.               break;
  30.       is = 0;
  31.       if(strstr(str,"typedef") )
  32.       {  pstr1 = strstr(str,"(APIENTRY * P");
  33.          pstrout = &str1[0];
  34.          if(pstr1)
  35.          {  n1++;
  36.             dn = (int) (pstr1 - &str[0]); 
  37.             dn += 10; 
  38.             strncpy(str1,str,dn);
  39.             str1[dn] = 0;
  40.             is = 1;
  41.             strcat(str1, &str[dn+3]);  
  42.             fputs(str1,fpto);
  43.             pstr1 = &str[dn+3];
  44.             pstr2 = strstr(pstr1 ,")");
  45.             *pstr2 = 0;
  46.             fprintf(fpto,"typedef %s *P%s;\n",pstr1,pstr1 );
  47.          }
  48.       } 
  49.       if(!is)
  50.       { fputs(str,fpto);
  51.       }   
  52.       n++; 
  53.    } 
  54.    fclose(fp);
  55.    fclose(fpto);
  56.    printf("n=%i,n1=%i\n",n,n1);  
  57. }