Diff for /rleda/rleda.c between versions 1.2 and 1.3

version 1.2, 2003/12/12 19:08:17 version 1.3, 2005/02/08 17:10:08
Line 1 Line 1
 /* $Id$  /* $Id$
   $State$    $State$
   $Log$    $Log$
   Revision 1.2  2003/12/12 19:08:17  brouard    Revision 1.3  2005/02/08 17:10:08  brouard
   Les variables ne sont plus toutes écrites en ligne mais avec un retour    Lit le fichier index deux fois pour n'avoir qu'un passage en SAS.
   à la ligne toutes les 5 variables.    AJoute le proc contents des fichiers créés en fin de run;
   
     Revision 1.2  2003/12/12 19:08:17  brouard
     Les variables ne sont plus toutes écrites en ligne mais avec un retour
     à la ligne toutes les 5 variables.
   
   Revision 1.1.1.1  2003/12/12 18:53:44  brouard    Revision 1.1.1.1  2003/12/12 18:53:44  brouard
   Import de rleda    Import de rleda
Line 36 Line 40
 #define ODIRSEPARATOR '/'  #define ODIRSEPARATOR '/'
 #endif  #endif
   
 char version[]="rleda-0.9.1 Programme de lecture de fichiers d'index au format LEDA convertis de l'EBCDIC en ASCII ";  char version[]="rleda-0.9.2 Programme de lecture de fichiers d'index au format LEDA convertis de l'EBCDIC en ASCII ";
 char fullversion[]="$Revision$ $Date$";  char fullversion[]="$Revision$ $Date$";
 char line[MAXLINE];  char line[MAXLINE];
 char title[MAXLINE],namevar[MAXLINE], namevara[MAXLINE];  char title[MAXLINE],namevar[MAXLINE], namevara[MAXLINE];
Line 45  char fileres[FILENAMELENGTH], filereso[F Line 49  char fileres[FILENAMELENGTH], filereso[F
 char filesas[FILENAMELENGTH]; /* SAS  file */  char filesas[FILENAMELENGTH]; /* SAS  file */
 char filelog[FILENAMELENGTH]; /* Log file */  char filelog[FILENAMELENGTH]; /* Log file */
   
 FILE *ficlog, *ficres, *ficpar, *ficparo, *ficparsas;  FILE *ficlog, *ficres, *ficdat, *ficreso, *ficsas;
   
   
 static unsigned char const ascii_to_ebcdic[] =  static unsigned char const ascii_to_ebcdic[] =
Line 231  void trzb(char *z, char *in) Line 235  void trzb(char *z, char *in)
   
 main(int argc, char *argv[])  main(int argc, char *argv[])
 {  {
   int numlinepar=0;    int numlinepar=0, ilect=0, firstpass=0;
   long nobs, ncar,ncara, ncartes, nn, nvaris=0;    long nobs=0, ncar=0,ncara=0, ncartes=0, nn=0, nvaris=0;
   long c;    long c;
   long d;    long d;
   long numlis, ntype;    long numlis, ntype;
   long n, pos;    long n, pos;
   int level, olevel;    int level, olevel, levelmax;
   char scar;    char scar;
   char s;    char s;
     char var1[4][10], varn[4][10];
   
   char pathtot[MAXLINE], path[MAXLINE], optionfile[FILENAMELENGTH], optionfilext[FILENAMEEXTLEN];    char pathtot[MAXLINE], path[MAXLINE], indexfile[FILENAMELENGTH], indexfilext[FILENAMEEXTLEN];
   char optionfilefiname[FILENAMELENGTH];    char indexfilefiname[FILENAMELENGTH];
   
   numlinepar=0;    numlinepar=0;
   if(argc <=1){    if(argc <=1){
     printf("\nEntrez le nom du fichier index binaire : ");      printf("\nEntrez le nom du fichier index binaire (dtrirdex) : ");
     scanf("%s",pathtot);      scanf("%s",pathtot);
   }    }
   else{    else{
     strcpy(pathtot,argv[1]);      strcpy(pathtot,argv[1]);
   }    }
   split(pathtot,path,optionfile,optionfilext,optionfilefiname);    split(pathtot,path,indexfile,indexfilext,indexfilefiname);
   printf("pathtot=%s,\npath=%s,\noptionfile=%s \noptionfilext=%s \noptionfilefiname=%s\n",pathtot,path,optionfile,optionfilext,optionfilefiname);    printf("pathtot=%s,\npath=%s,\nindexfile=%s \nindexfilext=%s \nindexfilefiname=%s\n",pathtot,path,indexfile,indexfilext,indexfilefiname);
   chdir(path);    chdir(path);
   
   
   /* Log file */    /* Log file */
   strcat(filelog, optionfilefiname);    strcat(filelog, indexfilefiname);
   strcat(filelog,".log");    /* */    strcat(filelog,".log");    /* */
   if((ficlog=fopen(filelog,"w"))==NULL)    {    if((ficlog=fopen(filelog,"w"))==NULL)    {
     printf("Problem with logfile %s\n",filelog);      printf("Problem with logfile %s\n",filelog);
Line 269  main(int argc, char *argv[]) Line 274  main(int argc, char *argv[])
   fprintf(ficlog,"\nEntrez le nom du fichier d'index: ");    fprintf(ficlog,"\nEntrez le nom du fichier d'index: ");
   fprintf(ficlog,"pathtot=%s\n\    fprintf(ficlog,"pathtot=%s\n\
  path=%s \n\   path=%s \n\
  optionfile=%s\n\   indexfile=%s\n\
  optionfilext=%s\n\   indexfilext=%s\n\
  optionfilefiname=%s\n",pathtot,path,optionfile,optionfilext,optionfilefiname);   indexfilefiname=%s\n",pathtot,path,indexfile,indexfilext,indexfilefiname);
   fflush(ficlog);    fflush(ficlog);
   
   
   if((ficpar=fopen(optionfile,"rb"))==NULL)    {  
     printf("Problem with optionfile %s\n",optionfile);  
     fprintf(ficlog,"Problem with optionfile %s\n",optionfile);  
     fflush(ficlog);  
     goto end;  
   }  
   
   strcpy(filereso,"o");    strcpy(filereso,"o");
   strcat(filereso,optionfilefiname);    strcat(filereso,indexfilefiname);
   strcat(filereso,".txt");    strcat(filereso,".txt");
   if((ficparo=fopen(filereso,"w"))==NULL) { /* opened on subdirectory */    if((ficreso=fopen(filereso,"w"))==NULL) { /* opened on subdirectory */
     printf("Problem with Output resultfile: %s\n", filereso);      printf("Problem with Output resultfile: %s\n", filereso);
     fprintf(ficlog,"Problem with Output resultfile: %s\n", filereso);      fprintf(ficlog,"Problem with Output resultfile: %s\n", filereso);
     fflush(ficlog);      fflush(ficlog);
     goto end;      goto end;
   }    }
   fprintf(ficparo,"Log filename:%s\n",filelog);    fprintf(ficreso,"Log filename:%s\n",filelog);
   fprintf(ficparo,"\n%s\n%s",version,fullversion);    fprintf(ficreso,"\n%s\n%s",version,fullversion);
   fprintf(ficparo,"\nEntrez le nom du fichier d'index: ");    fprintf(ficreso,"\nEntrez le nom du fichier d'index: ");
   fprintf(ficparo,"pathtot=%s\n\    fprintf(ficreso,"pathtot=%s\n\
  path=%s \n\   path=%s \n\
  optionfile=%s\n\   indexfile=%s\n\
  optionfilext=%s\n\   indexfilext=%s\n\
  optionfilefiname=%s\n",pathtot,path,optionfile,optionfilext,optionfilefiname);   indexfilefiname=%s\n",pathtot,path,indexfile,indexfilext,indexfilefiname);
   fflush(ficparo);    fflush(ficreso);
   
   strcpy(filesas,"s");    strcpy(filesas,"s");
   strcat(filesas,optionfilefiname);    strcat(filesas,indexfilefiname);
   strcat(filesas,".sas");    strcat(filesas,".sas");
   if((ficparsas=fopen(filesas,"w"))==NULL) { /* opened on subdirectory */  
     printf("Problem with Output resultfile: %s\n", filesas);  
     fprintf(ficlog,"Problem with Output resultfile: %s\n", filesas);  
     fflush(ficlog);  
     goto end;  
   }  
   fprintf(ficparsas,"*Sortie de rleda version %s *;\n* %s *;\n",version,fullversion);  
   fprintf(ficparsas,"libname %s \"%s\";\n",optionfilefiname,path);  
   fprintf(ficparsas,"filename a \"%s.dat\";\n",optionfilefiname );  
   fprintf(ficparsas,"* Ci dessous a modifier *;\n");  
   fprintf(ficparsas,"data %s.u?? (keep=??);\n",optionfilefiname);  
   fprintf(ficparsas,"infile a lrecl=500 ;\n");  
   fprintf(ficparsas,"input id 1. @; retain numero 0;\n");  
   fprintf(ficparsas,"");  
   fprintf(ficparsas,"");  
   
   printf("Le nom du fichier de sortie est %s\n",filereso);    printf("Le nom du fichier de sortie est %s\n",filereso);
   printf("Le nom du fichier SAS de sortie est %s\n",filesas);    printf("Le nom du fichier SAS de sortie est %s\n",filesas);
   
   pos=9;nvaris=0 ;    for(ilect=1;ilect<=2;ilect++){
   level=0;      pos=9;nvaris=0 ;
   while((c=getc(ficpar)) != EOF){        level=0;
     ungetc(c,ficpar);      printf("Lecture du fichier d index pour la %d fois\n",ilect);
     ntype=0;for(n=0;n<2;n++){ c=getc(ficpar); ntype+=(n+(1-n)*256)*ascii_to_ebcdic[c];}      if((ficdat=fopen(indexfile,"rb"))==NULL)    {
     fprintf(ficlog,"ntype=%d ",ntype);        printf("Problem with binary file %s\n",indexfile);
 /*     printf("ntype=%d ",ntype); */        fprintf(ficlog,"Problem with binary file %s\n",indexfile);
     switch(ntype){        fflush(ficlog);
     case 11 : /* 11*/        goto end;
       nobs=0;      }
       for(n=0;n<2;n++){      if(ilect==2){
         c=getc(ficpar);        if((ficsas=fopen(filesas,"w"))==NULL) { /* opened on subdirectory */
         d=(n+(1-n)*256)*ascii_to_ebcdic[c];          printf("Problem with Output resultfile: %s\n", filesas);
         nobs+=d;          fprintf(ficlog,"Problem with Output resultfile: %s\n", filesas);
           fflush(ficlog);
           goto end;
       }        }
       fprintf(ficlog,"nobs=%d ",nobs);        fprintf(ficsas,"*Sortie de rleda version %s *;\n* %s *;\n",version,fullversion);
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);        fprintf(ficsas,"libname %s \"%s\";\n",indexfilefiname,path);
       for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);        fprintf(ficsas,"filename a \"%s.dat\";\n",indexfilefiname );
       printf(" %s\n", title);        fprintf(ficsas,"* Ci dessous a modifier eventuellement *;\n");
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);        fprintf(ficsas,"data %s.%s0 (keep=ID)\n",indexfilefiname,indexfilefiname);
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);        for(level=1; level <=levelmax; level++){
       for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);          fprintf(ficsas,"     %s.%s%d (keep=%s--%s)\n",indexfilefiname,indexfilefiname,level,var1[level],varn[level]);
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);        }
       for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);        fprintf(ficsas,"     ;\n");
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);        fprintf(ficsas,"  infile a lrecl=500 ;\n");
       for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);        fprintf(ficsas,"  input id 1. @; \n");
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);        fprintf(ficsas,"");
       for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);        fprintf(ficsas,"");
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);      }
       for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);      while((c=getc(ficdat)) != EOF){  
       break;        ungetc(c,ficdat);
     case 12: /* 12 */        ntype=0;for(n=0;n<2;n++){ c=getc(ficdat); ntype+=(n+(1-n)*256)*ascii_to_ebcdic[c];}
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);        fprintf(ficlog,"ntype=%d ",ntype);
       for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);        /*     printf("ntype=%d ",ntype); */
       printf(" %s\n", title);        switch(ntype){
       ncartes=0;for(n=0;n<2;n++){ c=getc(ficpar); ncartes+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncartes=%d ",ncartes);        case 11 : /* 11*/
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);          nobs=0;
       for(n=0;n<8;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);          for(n=0;n<2;n++){
       olevel=level;            c=getc(ficdat);
       level=title[0]-48;            d=(n+(1-n)*256)*ascii_to_ebcdic[c];
       printf(" Niveau = %d Colonnes 1  8 = %s\n",level,title);            nobs+=d;
       fprintf(ficlog," Niveau = %d Colonnes 1  8 = %s\n",level,title);  
       fprintf(ficparo," Niveau = %d Colonnes 1   8 = %s\n",level,title);  
       if(level ==0) fprintf(ficparsas,"if id=%d then do;\n",level);  
          /*       fprintf(ficparsas,"  input @9 "); */  
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);  
       ncara=0;for(n=0;n<2;n++){ c=getc(ficpar); ncara+=(n+(1-n)*256)*ascii_to_ebcdic[c]; } fprintf(ficlog,"ncara=%d ",ncara);  
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);  
       for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);  
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);  
       for(n=0;n<2;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);  
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);  
       break;  
     case 10:  /* 10 = 142 ascii*/  
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);  
       for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"%s ",title);  
       printf(" %s\n", title);  
       trzb(namevar,title);  
       ncartes=0;for(n=0;n<2;n++){ c=getc(ficpar); ncartes+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncartes=%d ",ncartes);  
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);  
       ncara=0;for(n=0;n<2;n++){ c=getc(ficpar); ncara+=(n+(1-n)*256)*ascii_to_ebcdic[c]; } fprintf(ficlog,"ncara=%d ",ncara);  
       ncar=0;for(n=0;n<2;n++){ c=getc(ficpar); ncar+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncar=%d ",ncar);  
       printf(" %s %d\n",namevar,ncara);  
       fprintf(ficparo," %s %d\n",namevar,ncara);  
       ncar=0;for(n=0;n<2;n++){ c=getc(ficpar); ncar+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncar=%d ",ncar);  
       break;  
     case 14: /* 14 */  
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);  
       for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"%s ",title);  
       trzb(namevar,title);  
       printf("%d %20s ",level, namevar);  
       fprintf(ficparo,"%d %20s ",level, namevar);  
       fprintf(ficlog,"Variable \"%s\" \n",namevar);  
       ncartes=0;for(n=0;n<2;n++){ c=getc(ficpar); ncartes+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncartes=%d ",ncartes);  
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);  
       ncara=0;for(n=0;n<2;n++){ c=getc(ficpar); ncara+=(n+(1-n)*256)*ascii_to_ebcdic[c]; } fprintf(ficlog,"ncara=%d ",ncara);  
       printf(" %6d",ncara); /* Nombre de caractres */  
       fprintf(ficparo," %6d",ncara); /* Nombre de caract res */  
       ncar=0;for(n=0;n<2;n++){ c=getc(ficpar); ncar+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncar=%d ",ncar);  
       for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0';  fprintf(ficlog,"%s ",title);  
       trzb(namevara,title);  
       printf("%10s ", namevara); /* Association */  
       fprintf(ficparo,"%10s ", namevara); /* Association */  
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);  
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);  
       for(n=0;n<2;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0';fprintf(ficlog,"\"%s\"",title);  
       printf("%3s", title); /* Brute C ou Calcule R */  
       fprintf(ficparo,"%3s", title); /* Brute C ou Calcul e R */  
       if(strrchr(title,'C')!= 0 || strrchr(title,'G')!=0){  
         if(level!=olevel){  
           pos=9;  
           fprintf(ficparsas,";\n  output %s.u%d;\n",optionfilefiname,olevel);  
           fprintf(ficparsas,"  end\n");  
           if(level !=0) fprintf(ficparsas,";\n else if id=%d then do;\n",level);  
           fprintf(ficparsas,"  input @9 ");  
           olevel=level;  
         }          }
         printf(" %d-%d", pos, pos+(ncara-1));          fprintf(ficlog,"nobs=%d ",nobs);
         fprintf(ficparo," %d-%d", pos, pos+(ncara-1));          nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
         for(n=0;n<strlen(namevar);n++){          for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);
           if(namevar[n]=='-')          printf(" %s\n", title);
             break;          nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);
           break;
         case 12: /* 12 */
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);
           printf(" %s\n", title);
           ncartes=0;for(n=0;n<2;n++){ c=getc(ficdat); ncartes+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncartes=%d ",ncartes);
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           for(n=0;n<8;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);
           olevel=level;
           level=title[0]-48;
           printf(" Niveau = %d Colonnes 1  8 = %s\n",level,title);
           fprintf(ficlog," Niveau = %d Colonnes 1  8 = %s\n",level,title);
           fprintf(ficreso," Niveau = %d Colonnes 1   8 = %s\n",level,title);
           if(level ==0){
             if(ilect==2){
               fprintf(ficsas,"  if id=%d then do;\n",level);
             /*       fprintf(ficsas,"  input @9 "); */
             }
         }          }
         namevar[n]='\0';          nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
         fprintf(ficparsas, " %s $%d.", namevar, ncara);          ncara=0;for(n=0;n<2;n++){ c=getc(ficdat); ncara+=(n+(1-n)*256)*ascii_to_ebcdic[c]; } fprintf(ficlog,"ncara=%d ",ncara);
         pos+=ncara;nvaris++ ;          nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
         if (nvaris>=5) {          for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);
                 fprintf(ficparsas,"\n    ") ;          nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
                 nvaris=0 ;          for(n=0;n<2;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title);
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           break;
         case 10:  /* 10 = 142 ascii*/
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"%s ",title);
           printf(" %s\n", title);
           trzb(namevar,title);
           ncartes=0;for(n=0;n<2;n++){ c=getc(ficdat); ncartes+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncartes=%d ",ncartes);
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           ncara=0;for(n=0;n<2;n++){ c=getc(ficdat); ncara+=(n+(1-n)*256)*ascii_to_ebcdic[c]; } fprintf(ficlog,"ncara=%d ",ncara);
           ncar=0;for(n=0;n<2;n++){ c=getc(ficdat); ncar+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncar=%d ",ncar);
           printf(" %s %d\n",namevar,ncara);
           fprintf(ficreso," %s %d\n",namevar,ncara);
           ncar=0;for(n=0;n<2;n++){ c=getc(ficdat); ncar+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncar=%d ",ncar);
           break;
         case 14: /* 14 */
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"%s ",title);
           trzb(namevar,title);
           printf("%d %20s ", level, namevar);
           fprintf(ficreso,"%d %20s ",level, namevar);
           fprintf(ficlog,"Variable \"%s\" \n",namevar);
           ncartes=0;for(n=0;n<2;n++){ c=getc(ficdat); ncartes+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncartes=%d ",ncartes);
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           ncara=0;for(n=0;n<2;n++){ c=getc(ficdat); ncara+=(n+(1-n)*256)*ascii_to_ebcdic[c]; } fprintf(ficlog,"ncara=%d ",ncara);
           printf(" %6d",ncara); /* Nombre de caractres */
           fprintf(ficreso," %6d",ncara); /* Nombre de caract res */
           ncar=0;for(n=0;n<2;n++){ c=getc(ficdat); ncar+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncar=%d ",ncar);
           for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0';  fprintf(ficlog,"%s ",title);
           trzb(namevara,title);
           printf("%10s ", namevara); /* Association */
           fprintf(ficreso,"%10s ", namevara); /* Association */
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           for(n=0;n<2;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0';fprintf(ficlog,"\"%s\"",title);
           printf("%3s", title); /* Brute C ou Calcule R */
           fprintf(ficreso,"%3s", title); /* Brute C ou Calcul e R */
           if(strrchr(title,'C')!= 0 || strrchr(title,'G')!=0){
             if(level!=olevel){
               pos=9;
               firstpass=0;
               if(ilect==2){
                 fprintf(ficsas,"    ;\n    output %s.%s%d;\n",indexfilefiname,indexfilefiname,olevel);
                 fprintf(ficsas,"  end\n");
               }
               if(level !=0)
                 if(ilect==2){
                   fprintf(ficsas,"  ;\n  else if id=%d then do;\n",level);
                 }
               if(ilect==2){
                 fprintf(ficsas,"    input @9 ");
                 printf("  input @9 ");
               }
               if(ilect==1){
                 levelmax=level;
               }
               olevel=level;
             }
             printf(" %d-%d", pos, pos+(ncara-1));
             fprintf(ficreso," %d-%d", pos, pos+(ncara-1));
             for(n=0;n<strlen(namevar);n++){
               if(namevar[n]=='-')
                 break;
             }
             namevar[n]='\0';
             if(ilect==1){
               if(firstpass==0){
                 strcpy(var1[level],namevar);
                 printf(" Variable premiere %s, niveau %d  namevar=%s\n",var1[level],level, namevar);
                 firstpass=1;
               }
               else{
                 strcpy(varn[level],namevar);
                 printf(" Variable N %s, niveau %d  namevar=%s\n",varn[level],level, namevar);
               }
             }
             if(ilect==2){
               fprintf(ficsas, " %s $%d.", namevar, ncara);
             }
             pos+=ncara;nvaris++ ;
             if (nvaris>=5) {
               if(ilect==2){
                 fprintf(ficsas,"\n     ") ;
               }
               nvaris=0 ;
             }
         }          }
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0';fprintf(ficlog,"%s ",title);
           trzb(namevar,title);
           printf(" %10s\n", namevar); /* format */
           fprintf(ficreso," %10s", namevar); /* format */
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0';fprintf(ficlog,"%s ",title);
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           break;
         default: fprintf(ficlog,"Warning ntype=%d cas non prvu, voir les fichiers sources",ntype);
           nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);
           for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"%s ",title);
           printf(" %s\n", title);
       }        }
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);        n=0;
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);        while((c=getc(ficdat)) !='\r'){
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);          if(ncara != 0)
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);            nn= n % ncara;
       for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0';fprintf(ficlog,"%s ",title);          else
       trzb(namevar,title);            nn=0;
       printf(" %10s\n", namevar); /* format */          title[nn]=c;
       fprintf(ficparo," %10s", namevar); /* format */          if(nn==ncara-1){
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);            title[nn+1]='\0';
       for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0';fprintf(ficlog,"%s ",title);            fprintf(ficlog," \"%s\"",title);
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);            printf(" \"%s\"",title);
       break;            fprintf(ficreso," \"%s\"",title);
     default: fprintf(ficlog,"Warning ntype=%d cas non prvu, voir les fichiers sources",ntype);            n=n+1;
       nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs);          }else{
       for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"%s ",title);            n=n+1;
       printf(" %s\n", title);          }
     }  
     n=0;  
     while((c=getc(ficpar)) !='\r'){  
       nn= n % ncara;  
       title[nn]=c;  
       if(nn==ncara-1){  
         title[nn+1]='\0';  
         fprintf(ficlog," \"%s\"",title);  
         printf(" \"%s\"",title);  
         fprintf(ficparo," \"%s\"",title);  
         n=n+1;  
       }else{  
         n=n+1;  
       }        }
     }        if(c=='\r')
     if(c=='\r')          if((c=getc(ficdat))=='\n');
       if((c=getc(ficpar))=='\n');          else ungetc(c,ficdat);
       else ungetc(c,ficpar);        fprintf(ficlog,"\n");
     fprintf(ficlog,"\n");        fprintf(ficreso,"\n");
     fprintf(ficparo,"\n");      } /* End of read loop */
   }      fclose(ficdat);
   fprintf(ficparsas,";\n  output %s.u%d;\n end;\n else input;\n run;",optionfilefiname,level);    } /* End loop ilect */
   fclose(ficparsas);   
     fprintf(ficsas,"   ;\n    output %s.%s%d;\n  end;\n  else input;\nrun;\n",indexfilefiname,indexfilefiname,level);
     for(level=0; level <=levelmax; level++){
       fprintf(ficsas,"proc contents data=%s.%s%d;run;\n",indexfilefiname,indexfilefiname,level);
     }
     fclose(ficsas);
   printf("Le nom du fichier de debug est %s\n",filelog);    printf("Le nom du fichier de debug est %s\n",filelog);
   printf("Le nom du fichier du format de sortie est %s\n",filereso);    printf("Le nom du fichier du format de sortie est %s\n",filereso);
   printf("Le nom du fichier SAS de sortie est %s\n",filesas);    printf("Le nom du fichier SAS de sortie est %s\n",filesas);
   fclose(ficpar);    fclose(ficreso);
   fclose(ficparo);  
   fclose(ficlog);    fclose(ficlog);
   exit(0);    exit(0);
  end:   end:

Removed from v.1.2  
changed lines
  Added in v.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>