Diff for /rpl/src/formateur_fichiers.c between versions 1.84 and 1.85

version 1.84, 2015/03/26 11:10:46 version 1.85, 2015/03/26 16:12:31
Line 3106  formateur_fichier(struct_processus *s_et Line 3106  formateur_fichier(struct_processus *s_et
          * 1110 0 XXX               fonction de longueur XXX           * 1110 0 XXX               fonction de longueur XXX
          * 1110 10 LL               fonction de longueur integer*LL           * 1110 10 LL               fonction de longueur integer*LL
          *           *
            * 1111 XXXXX               page 2
            * 1111 XXXXX 000000001     entier long
            * 1111 XXXXX 000000010     réel long
            * 1111 XXXXX 000000011     complexe long
            *
          * Les longueurs indiquées par le champ LL suivent l'en-tête :           * Les longueurs indiquées par le champ LL suivent l'en-tête :
          *      00 : integer*1           *      00 : integer*1
          *      01 : integer*2           *      01 : integer*2
Line 3732  formateur_fichier(struct_processus *s_et Line 3737  formateur_fichier(struct_processus *s_et
                                 0, 0, ' ', 'U', longueur_effective, recursivite,                                  0, 0, ' ', 'U', longueur_effective, recursivite,
                                 export_fichier)) == NULL)                                  export_fichier)) == NULL)
                         {                          {
                               free(chaine);
                             return(NULL);                              return(NULL);
                         }                          }
                     }                      }
Line 3744  formateur_fichier(struct_processus *s_et Line 3750  formateur_fichier(struct_processus *s_et
                                 0, 0, 'N', 'U', longueur_effective, recursivite,                                  0, 0, 'N', 'U', longueur_effective, recursivite,
                                 export_fichier)) == NULL)                                  export_fichier)) == NULL)
                         {                          {
                               free(chaine);
                             return(NULL);                              return(NULL);
                         }                          }
                     }                      }
Line 3772  formateur_fichier(struct_processus *s_et Line 3779  formateur_fichier(struct_processus *s_et
                 }                  }
                 else                  else
                 {                  {
                       format_degenere = d_faux;
   
                     if ((format_chaine = conversion_majuscule(                      if ((format_chaine = conversion_majuscule(
                             s_etat_processus, (unsigned char *)                              s_etat_processus, (unsigned char *)
                             (*(*l_element_courant_format).donnee).objet))                              (*(*l_element_courant_format).donnee).objet))
Line 3967  formateur_fichier(struct_processus *s_et Line 3976  formateur_fichier(struct_processus *s_et
 /*  /*
 --------------------------------------------------------------------------------  --------------------------------------------------------------------------------
   Table    Table
     Bits de poids fort : 1001
 --------------------------------------------------------------------------------  --------------------------------------------------------------------------------
 */  */
   
               chaine = malloc(sizeof(unsigned char));
   
               if (chaine == NULL)
               {
                   (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   return(NULL);
               }
   
               type_binaire = 0x90;
               longueur_liste = (*((struct_tableau *) (*s_objet).objet))
                       .nombre_elements;
   
               if (longueur_liste < (1LL << 3))
               {
                   chaine[0] = (unsigned char) (type_binaire |
                           (longueur_liste & 0x7));
               }
               else if (longueur_liste < (1LL << 8))
               {
                   chaine[0] = (unsigned char) (type_binaire | 0x08);
               }
               else if (longueur_liste < (1LL << 16))
               {
                   chaine[0] = (unsigned char ) (type_binaire | 0x09);
               }
               else if (longueur_liste < (1LL << 32))
               {
                   chaine[0] = (unsigned char) (type_binaire | 0x0A);
               }
               else
               {
                   chaine[0] = (unsigned char) (type_binaire | 0x0B);
               }
   
               longueur_totale = 1;
   
               if ((chaine[0] & 0x8) != 0)
               { // Longueur sur un entier distinct de l'en-tête
                   switch(chaine[0] & 0x03)
                   {
                       case 0x00 :
                       {
                           longueur_totale += 1;
   
                           if ((chaine = realloc(chaine,
                                   ((size_t) longueur_totale) *
                                   sizeof(unsigned char))) == NULL)
                           {
                               (*s_etat_processus).erreur_systeme =
                                       d_es_allocation_memoire;
                               return(NULL);
                           }
   
                           chaine[longueur_totale - 1] =
                                   (unsigned char) (longueur_liste & 0xFF);
                           break;
                       }
   
                       case 0x01 :
                       {
                           longueur_totale += 2;
   
                           if ((chaine = realloc(chaine,
                                   ((size_t) longueur_totale) *
                                   sizeof(unsigned char))) == NULL)
                           {
                               (*s_etat_processus).erreur_systeme =
                                       d_es_allocation_memoire;
                               return(NULL);
                           }
   
                           chaine[longueur_totale - 2] =
                                   (unsigned char) ((longueur_liste >> 8) & 0xFF);
                           chaine[longueur_totale - 1] =
                                   (unsigned char) (longueur_liste & 0xFF);
                           break;
                       }
   
                       case 0x02 :
                       {
                           longueur_totale += 4;
   
                           if ((chaine = realloc(chaine,
                                   ((size_t) longueur_totale) *
                                   sizeof(unsigned char))) == NULL)
                           {
                               (*s_etat_processus).erreur_systeme =
                                       d_es_allocation_memoire;
                               return(NULL);
                           }
   
                           chaine[longueur_totale - 4] =
                                   (unsigned char) ((longueur_liste >> 24) & 0xFF);
                           chaine[longueur_totale - 3] =
                                   (unsigned char) ((longueur_liste >> 16) & 0xFF);
                           chaine[longueur_totale - 2] =
                                   (unsigned char) ((longueur_liste >> 8) & 0xFF);
                           chaine[longueur_totale - 1] =
                                   (unsigned char) (longueur_liste & 0xFF);
                           break;
                       }
   
                       case 0x03 :
                       {
                           longueur_totale += 8;
   
                           if ((chaine = realloc(chaine,
                                   ((size_t) longueur_totale) *
                                   sizeof(unsigned char))) == NULL)
                           {
                               (*s_etat_processus).erreur_systeme =
                                       d_es_allocation_memoire;
                               return(NULL);
                           }
   
                           chaine[longueur_totale - 8] =
                                   (unsigned char) ((longueur_liste >> 56) & 0xFF);
                           chaine[longueur_totale - 7] =
                                   (unsigned char) ((longueur_liste >> 48) & 0xFF);
                           chaine[longueur_totale - 6] =
                                   (unsigned char) ((longueur_liste >> 40) & 0xFF);
                           chaine[longueur_totale - 5] =
                                   (unsigned char) ((longueur_liste >> 32) & 0xFF);
                           chaine[longueur_totale - 4] =
                                   (unsigned char) ((longueur_liste >> 24) & 0xFF);
                           chaine[longueur_totale - 3] =
                                   (unsigned char) ((longueur_liste >> 16) & 0xFF);
                           chaine[longueur_totale - 2] =
                                   (unsigned char) ((longueur_liste >> 8) & 0xFF);
                           chaine[longueur_totale - 1] =
                                   (unsigned char) (longueur_liste & 0xFF);
                           break;
                       }
   
                       default :
                       {
                           BUG(1, printf("Internal format error\n"));
                       }
                   }
               }
   
               if ((*s_format).type == CHN)
               {
                   if ((format_chaine = conversion_majuscule(
                           s_etat_processus, (unsigned char *)
                           (*s_format).objet)) == NULL)
                   {
                       (*s_etat_processus).erreur_systeme =
                               d_es_allocation_memoire;
                       return(NULL);
                   }
   
                   if (strncmp("INTEGER*", format_chaine, 8) == 0)
                   {
                       format_sortie = 'I';
                       position_1 = 8;
                   }
                   else if (strncmp("LOGICAL*", format_chaine, 8) == 0)
                   {
                       format_sortie = 'L';
                       position_1 = 8;
                   }
                   else if (strncmp("REAL*", format_chaine, 5) == 0)
                   {
                       format_sortie = 'R';
                       position_1 = 5;
                   }
                   else if (strncmp("COMPLEX*", format_chaine, 8) == 0)
                   {
                       format_sortie = 'C';
                       position_1 = 8;
                   }
                   else if (strncmp("CHARACTER*", format_chaine, 10) == 0)
                   {
                       format_sortie = 'S';
                       position_1 = 10;
                       format_degenere = d_vrai;
                   }
                   else if (strcmp("NATIVE*(*)", format_chaine) == 0)
                   {
                       format_sortie = 'N';
                       position_1 = 7;
                       format_degenere = d_vrai;
                   }
                   else
                   {
                       free(chaine);
                       free(format_chaine);
   
                       (*s_etat_processus).erreur_execution =
                               d_ex_erreur_format_fichier;
                       return(NULL);
                   }
   
                   if (format_chaine[position_1] == d_code_fin_chaine)
                   {
                       free(chaine);
                       free(format_chaine);
   
                       (*s_etat_processus).erreur_execution =
                               d_ex_erreur_format_fichier;
                       return(NULL);
                   }
   
                   if (strcmp(&(format_chaine[position_1]), "(*)") != 0)
                   {
                       if (sscanf(&(format_chaine[position_1]), "%lld",
                               &longueur) != 1)
                       {
                           free(chaine);
                           free(format_chaine);
   
                           (*s_etat_processus).erreur_execution =
                                   d_ex_erreur_format_fichier;
                           return(NULL);
                       }
   
                       longueur_champ = longueur;
                   }
                   else
                   {
                       longueur_champ = -1;
                       longueur = -1;
                   }
   
                   free(format_chaine);
   
                   for(i = 0; i < longueur_liste; i++)
                   {
                       if ((chaine_formatee = formateur_fichier(s_etat_processus,
                               (*((struct_tableau *) (*s_objet).objet))
                               .elements[i], (*s_format).objet,
                               longueur, longueur_champ,
                               format_sortie, type, longueur_effective,
                               recursivite, export_fichier)) == NULL)
                       {
                           free(chaine);
                           return(NULL);
                       }
                   }
               }
               else if ((*s_format).type == TBL)
               {
               }
               else
               {
                   free(chaine);
   
                   (*s_etat_processus).erreur_execution =
                           d_ex_erreur_format_fichier;
                   return(NULL);
               }
   
               // A FIXER
   
   
               /*
               while((l_element_courant != NULL) &&
                       (l_element_courant_format != NULL))
               {
                   if ((((*(*l_element_courant_format).donnee).type == LST)
                           && ((*(*l_element_courant).donnee).type == LST)) ||
                           (((*(*l_element_courant_format).donnee).type == TBL)
                           && ((*(*l_element_courant).donnee).type == TBL)))
                   {
                       if (format_sortie != 'N')
                       {
                           if ((chaine_formatee = formateur_fichier(
                                   s_etat_processus,
                                   (*l_element_courant).donnee,
                                   (*l_element_courant_format).donnee,
                                   0, 0, ' ', 'U', longueur_effective, recursivite,
                                   export_fichier)) == NULL)
                           {
                               return(NULL);
                           }
                       }
                       else
                       {
                           if ((chaine_formatee = formateur_fichier(
                                   s_etat_processus,
                                   (*l_element_courant).donnee,
                                   (*l_element_courant_format).donnee,
                                   0, 0, 'N', 'U', longueur_effective, recursivite,
                                   export_fichier)) == NULL)
                           {
                               return(NULL);
                           }
                       }
   
                       if ((chaine = realloc(chaine, ((size_t) (longueur_totale +
                               (*longueur_effective))) * sizeof(unsigned char)))
                               == NULL)
                       {
                           (*s_etat_processus).erreur_systeme =
                                   d_es_allocation_memoire;
                           return(NULL);
                       }
   
                       memcpy(&(chaine[longueur_totale]), chaine_formatee,
                               (size_t) (*longueur_effective));
                       longueur_totale += (*longueur_effective);
                       free(chaine_formatee);
                   }
                   else if ((*(*l_element_courant_format).donnee).type != CHN)
                   {
                       free(chaine);
   
                       (*s_etat_processus).erreur_execution =
                               d_ex_erreur_format_fichier;
                       return(NULL);
                   }
                   else
                   {
                       if ((format_chaine = conversion_majuscule(
                               s_etat_processus, (unsigned char *)
                               (*(*l_element_courant_format).donnee).objet))
                               == NULL)
                       {
                           (*s_etat_processus).erreur_systeme =
                                   d_es_allocation_memoire;
                           return(NULL);
                       }
   
                       if (strncmp("INTEGER*", format_chaine, 8) == 0)
                       {
                           format_sortie = 'I';
                           position_1 = 8;
                       }
                       else if (strncmp("LOGICAL*", format_chaine, 8) == 0)
                       {
                           format_sortie = 'L';
                           position_1 = 8;
                       }
                       else if (strncmp("REAL*", format_chaine, 5) == 0)
                       {
                           format_sortie = 'R';
                           position_1 = 5;
                       }
                       else if (strncmp("COMPLEX*", format_chaine, 8) == 0)
                       {
                           format_sortie = 'C';
                           position_1 = 8;
                       }
                       else if (strncmp("CHARACTER*", format_chaine, 10) == 0)
                       {
                           format_sortie = 'S';
                           position_1 = 10;
                           format_degenere = d_vrai;
                       }
                       else if (strcmp("NATIVE*(*)", format_chaine) == 0)
                       {
                           format_sortie = 'N';
                           position_1 = 7;
                           format_degenere = d_vrai;
                       }
                       else
                       {
                           free(chaine);
                           free(format_chaine);
   
                           (*s_etat_processus).erreur_execution =
                                   d_ex_erreur_format_fichier;
                           return(NULL);
                       }
   
                       if (format_chaine[position_1] == d_code_fin_chaine)
                       {
                           free(chaine);
                           free(format_chaine);
   
                           (*s_etat_processus).erreur_execution =
                                   d_ex_erreur_format_fichier;
                           return(NULL);
                       }
   
                       if (strcmp(&(format_chaine[position_1]), "(*)") != 0)
                       {
                           if (sscanf(&(format_chaine[position_1]), "%lld",
                                   &longueur) != 1)
                           {
                               free(chaine);
                               free(format_chaine);
   
                               (*s_etat_processus).erreur_execution =
                                       d_ex_erreur_format_fichier;
                               return(NULL);
                           }
   
                           longueur_champ = longueur;
                       }
                       else
                       {
                           longueur_champ = -1;
                           longueur = -1;
                       }
   
                       free(format_chaine);
   
                       // Si le format_sortie vaut 'N', on remplace le format par
                       // { "native*(*)" }. L'intérêt est de pouvoir traiter une
                       // liste par un format "native*(*)".
   
                       if ((format_sortie == 'N') && ((*(*l_element_courant)
                               .donnee).type == LST))
                       {
                           if ((s_format_tmp = allocation(s_etat_processus, LST))
                                   == NULL)
                           {
                               return(NULL);
                           }
   
                           if (((*s_format_tmp).objet = allocation_maillon(
                                   s_etat_processus)) == NULL)
                           {
                               return(NULL);
                           }
   
                           (*((struct_liste_chainee *) (*s_format_tmp).objet))
                                   .suivant = NULL;
   
                           if (((*((struct_liste_chainee *) (*s_format_tmp).objet))
                                   .donnee = allocation(s_etat_processus, CHN))
                                   == NULL)
                           {
                               return(NULL);
                           }
   
                           if (((*(*((struct_liste_chainee *) (*s_format_tmp)
                                   .objet)).donnee).objet = malloc(11 *
                                   sizeof(unsigned char))) == NULL)
                           {
                               (*s_etat_processus).erreur_systeme =
                                       d_es_allocation_memoire;
                               return(NULL);
                           }
   
                           strcpy((unsigned char *) (*(*((struct_liste_chainee *)
                                   (*s_format_tmp).objet)).donnee).objet,
                                   "native*(*)");
                       }
                       else
                       {
                           if ((s_format_tmp = copie_objet(s_etat_processus,
                                   s_format, 'P')) == NULL)
                           {
                               return(NULL);
                           }
                       }
   
                       if ((chaine_formatee = formateur_fichier(s_etat_processus,
                               (*l_element_courant).donnee, s_format_tmp,
                               longueur, longueur_champ, format_sortie, type,
                               longueur_effective, recursivite, export_fichier))
                               == NULL)
                       {
                           liberation(s_etat_processus, s_format_tmp);
                           free(chaine);
                           return(NULL);
                       }
   
                       liberation(s_etat_processus, s_format_tmp);
   
                       if ((chaine = realloc(chaine,
                               ((size_t) (longueur_totale + (*longueur_effective)))
                               * sizeof(unsigned char))) == NULL)
                       {
                           (*s_etat_processus).erreur_systeme =
                                   d_es_allocation_memoire;
                           return(NULL);
                       }
   
                       memcpy(&(chaine[longueur_totale]), chaine_formatee,
                               (size_t) (*longueur_effective));
                       longueur_totale += (*longueur_effective);
                       free(chaine_formatee);
                   }
   
                   if (format_sortie != 'N')
                   {
                       l_element_courant_format =
                               (*l_element_courant_format).suivant;
                   }
   
                   nombre_elements++;
                   l_element_courant = (*l_element_courant).suivant;
               }
   
               if (format_sortie != 'N')
               {
                   if ((l_element_courant != NULL) ||
                           (l_element_courant_format != NULL))
                   {
                       free(chaine);
   
                       (*s_etat_processus).erreur_execution =
                               d_ex_erreur_format_fichier;
                       return(NULL);
                   }
               }
           */
   
               (*longueur_effective) = longueur_totale;
         }          }
         else if ((*s_objet).type == MCX)          else if ((*s_objet).type == MCX)
         {          {
Line 3978  formateur_fichier(struct_processus *s_et Line 4492  formateur_fichier(struct_processus *s_et
   Matrice complexe    Matrice complexe
 --------------------------------------------------------------------------------  --------------------------------------------------------------------------------
 */  */
   
               if (format_sortie == 'N')
               {
                   format_sortie = 'C';
                   longueur = 16;
               }
   
               if (format_sortie != 'C')
               {
                   (*s_etat_processus).erreur_execution =
                           d_ex_erreur_format_fichier;
                   return(NULL);
               }
   
               longueur_objet = (*((struct_matrice *) (*s_objet).objet))
                       .nombre_lignes * (*((struct_matrice *) (*s_objet).objet))
                       .nombre_colonnes;
   
               if (((*((struct_matrice *) (*s_objet).objet)).nombre_lignes
                       < (1LL << 8)) && ((*((struct_matrice *) (*s_objet).objet))
                       .nombre_colonnes < (1LL << 8)))
               {
                   // Taille sur un octet
                   if ((chaine = malloc((size_t) ((*longueur_effective) =
                           (3 + (longueur_objet * longueur)))
                           * sizeof(unsigned char))) == NULL)
                   {
                       (*s_etat_processus).erreur_systeme =
                               d_es_allocation_memoire;
                       return(NULL);
                   }
   
                   chaine[0] = 0xD2;
                   chaine[1] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes & 0xFF);
                   chaine[2] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes & 0xFF);
                   chaine_offset = chaine + 3;
               }
               else if (((*((struct_matrice *) (*s_objet).objet)).nombre_lignes
                       < (1LL << 16)) && ((*((struct_matrice *) (*s_objet).objet))
                       .nombre_colonnes < (1LL << 16)))
               {
                   // Taille sur deux octets
                   if ((chaine = malloc((size_t) ((*longueur_effective) =
                           (5 + (longueur_objet * longueur)))
                           * sizeof(unsigned char))) == NULL)
                   {
                       (*s_etat_processus).erreur_systeme =
                               d_es_allocation_memoire;
                       return(NULL);
                   }
   
                   chaine[0] = 0xD6;
                   chaine[1] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 8) & 0xFF);
                   chaine[2] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes & 0xFF);
                   chaine[3] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 8) & 0xFF);
                   chaine[4] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes & 0xFF);
                   chaine_offset = chaine + 5;
               }
               else if (((*((struct_matrice *) (*s_objet).objet)).nombre_lignes
                       < (1LL << 32)) && ((*((struct_matrice *) (*s_objet).objet))
                       .nombre_colonnes < (1LL << 32)))
               {
                   // Taille sur quatre octets
                   if ((chaine = malloc((size_t) (((*longueur_effective) =
                           9 + (longueur_objet * longueur)))
                           * sizeof(unsigned char))) == NULL)
                   {
                       (*s_etat_processus).erreur_systeme =
                               d_es_allocation_memoire;
                       return(NULL);
                   }
   
                   chaine[0] = 0xDA;
                   chaine[1] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 24) & 0xFF);
                   chaine[2] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 16) & 0xFF);
                   chaine[3] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 8) & 0xFF);
                   chaine[4] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes & 0xFF);
                   chaine[5] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 24) & 0xFF);
                   chaine[6] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 16) & 0xFF);
                   chaine[7] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 8) & 0xFF);
                   chaine[8] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes & 0xFF);
                   chaine_offset = chaine + 9;
               }
               else
               {
                   // Taille sur huit octets
                   if ((chaine = malloc((size_t) ((*longueur_effective) =
                           (17 + (longueur_objet * longueur)))
                           * sizeof(unsigned char))) == NULL)
                   {
                       (*s_etat_processus).erreur_systeme =
                               d_es_allocation_memoire;
                       return(NULL);
                   }
   
                   chaine[0] = 0xDE;
                   chaine[1] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 56) & 0xFF);
                   chaine[2] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 48) & 0xFF);
                   chaine[3] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 40) & 0xFF);
                   chaine[4] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 32) & 0xFF);
                   chaine[5] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 24) & 0xFF);
                   chaine[6] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 16) & 0xFF);
                   chaine[7] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 8) & 0xFF);
                   chaine[8] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes & 0xFF);
                   chaine[9] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 56) & 0xFF);
                   chaine[10] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 48) & 0xFF);
                   chaine[11] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 40) & 0xFF);
                   chaine[12] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 32) & 0xFF);
                   chaine[13] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 24) & 0xFF);
                   chaine[14] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 16) & 0xFF);
                   chaine[15] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 8) & 0xFF);
                   chaine[16] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes & 0xFF);
                   chaine_offset = chaine + 17;
               }
   
               switch(longueur)
               {
                   case 8:
                   {
                       break;
                   }
   
                   default:
                   case 16:
                   {
                       chaine[0] |= 0x01;
                       break;
                   }
               }
   
               for(i = 0; i < (*((struct_matrice *) (*s_objet).objet))
                       .nombre_lignes; i++)
               {
                   for(j = 0; j < (*((struct_matrice *) (*s_objet).objet))
                           .nombre_colonnes; j++)
                   {
                       if ((chaine_tampon = formateur_fichier_binaire_nombre(
                               s_etat_processus, &(((complex16 **)
                               (*((struct_matrice *) (*s_objet).objet)).tableau)
                               [i][j]), 'R', format_sortie,
                               longueur, &longueur_element)) == NULL)
                       {
                           free(chaine);
                           return(NULL);
                       }
   
                       memcpy(chaine_offset + (((i * (*((struct_matrice *)
                               (*s_objet).objet)).nombre_colonnes) + j) *
                               longueur), chaine_tampon + 1, (size_t) longueur);
                       free(chaine_tampon);
                   }
               }
         }          }
         else if ((*s_objet).type == MIN)          else if ((*s_objet).type == MIN)
         {          {
Line 3987  formateur_fichier(struct_processus *s_et Line 4683  formateur_fichier(struct_processus *s_et
   Matrice entière    Matrice entière
 --------------------------------------------------------------------------------  --------------------------------------------------------------------------------
 */  */
   
               if (format_sortie == 'N')
               {
                   format_sortie = 'I';
                   longueur = 8;
               }
   
               if ((format_sortie != 'I') && (format_sortie != 'R')
                       && (format_sortie != 'C'))
               {
                   (*s_etat_processus).erreur_execution =
                           d_ex_erreur_format_fichier;
                   return(NULL);
               }
   
               longueur_objet = (*((struct_matrice *) (*s_objet).objet))
                       .nombre_lignes * (*((struct_matrice *) (*s_objet).objet))
                       .nombre_colonnes;
   
               if (((*((struct_matrice *) (*s_objet).objet)).nombre_lignes
                       < (1LL << 8)) && ((*((struct_matrice *) (*s_objet).objet))
                       .nombre_colonnes < (1LL << 8)))
               {
                   // Taille sur un octet
                   if ((chaine = malloc((size_t) ((*longueur_effective) =
                           (3 + (longueur_objet * longueur)))
                           * sizeof(unsigned char))) == NULL)
                   {
                       (*s_etat_processus).erreur_systeme =
                               d_es_allocation_memoire;
                       return(NULL);
                   }
   
                   chaine[0] = 0x00;
                   chaine[1] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes & 0xFF);
                   chaine[2] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes & 0xFF);
                   chaine_offset = chaine + 3;
               }
               else if (((*((struct_matrice *) (*s_objet).objet)).nombre_lignes
                       < (1LL << 16)) && ((*((struct_matrice *) (*s_objet).objet))
                       .nombre_colonnes < (1LL << 16)))
               {
                   // Taille sur deux octets
                   if ((chaine = malloc((size_t) ((*longueur_effective) =
                           (5 + (longueur_objet * longueur)))
                           * sizeof(unsigned char))) == NULL)
                   {
                       (*s_etat_processus).erreur_systeme =
                               d_es_allocation_memoire;
                       return(NULL);
                   }
   
                   chaine[0] = 0x04;
                   chaine[1] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 8) & 0xFF);
                   chaine[2] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes & 0xFF);
                   chaine[3] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 8) & 0xFF);
                   chaine[4] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes & 0xFF);
                   chaine_offset = chaine + 5;
               }
               else if (((*((struct_matrice *) (*s_objet).objet)).nombre_lignes
                       < (1LL << 32)) && ((*((struct_matrice *) (*s_objet).objet))
                       .nombre_colonnes < (1LL << 32)))
               {
                   // Taille sur quatre octets
                   if ((chaine = malloc((size_t) (((*longueur_effective) =
                           9 + (longueur_objet * longueur)))
                           * sizeof(unsigned char))) == NULL)
                   {
                       (*s_etat_processus).erreur_systeme =
                               d_es_allocation_memoire;
                       return(NULL);
                   }
   
                   chaine[0] = 0x08;
                   chaine[1] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 24) & 0xFF);
                   chaine[2] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 16) & 0xFF);
                   chaine[3] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 8) & 0xFF);
                   chaine[4] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes & 0xFF);
                   chaine[5] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 24) & 0xFF);
                   chaine[6] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 16) & 0xFF);
                   chaine[7] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 8) & 0xFF);
                   chaine[8] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes & 0xFF);
                   chaine_offset = chaine + 9;
               }
               else
               {
                   // Taille sur huit octets
                   if ((chaine = malloc((size_t) ((*longueur_effective) =
                           (17 + (longueur_objet * longueur)))
                           * sizeof(unsigned char))) == NULL)
                   {
                       (*s_etat_processus).erreur_systeme =
                               d_es_allocation_memoire;
                       return(NULL);
                   }
   
                   chaine[0] = 0x0C;
                   chaine[1] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 56) & 0xFF);
                   chaine[2] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 48) & 0xFF);
                   chaine[3] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 40) & 0xFF);
                   chaine[4] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 32) & 0xFF);
                   chaine[5] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 24) & 0xFF);
                   chaine[6] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 16) & 0xFF);
                   chaine[7] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 8) & 0xFF);
                   chaine[8] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes & 0xFF);
                   chaine[9] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 56) & 0xFF);
                   chaine[10] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 48) & 0xFF);
                   chaine[11] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 40) & 0xFF);
                   chaine[12] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 32) & 0xFF);
                   chaine[13] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 24) & 0xFF);
                   chaine[14] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 16) & 0xFF);
                   chaine[15] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 8) & 0xFF);
                   chaine[16] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes & 0xFF);
                   chaine_offset = chaine + 17;
               }
   
               switch(format_sortie)
               {
                   default:
                   case 'I':
                   {
                       switch(longueur)
                       {
                           case 1:
                           {
                               break;
                           }
   
                           case 2:
                           {
                               chaine[0] |= 0x01;
                               break;
                           }
   
                           case 4:
                           {
                               chaine[0] |= 0x02;
                               break;
                           }
   
                           default:
                           case 8:
                           {
                               chaine[0] |= 0x03;
                               break;
                           }
                       }
   
                       chaine[0] |= 0x30;
                       break;
                   }
   
                   case 'R':
                   {
                       switch(longueur)
                       {
                           case 4:
                           {
                               break;
                           }
   
                           default:
                           case 8:
                           {
                               chaine[0] |= 0x01;
                               break;
                           }
                       }
   
                       chaine[0] |= 0xC0;
                       break;
                   }
   
                   case 'C':
                   {
                       switch(longueur)
                       {
                           case 8:
                           {
                               break;
                           }
   
                           default:
                           case 16:
                           {
                               chaine[0] |= 0x01;
                               break;
                           }
                       }
   
                       chaine[0] |= 0xD0;
                       break;
                   }
               }
   
               for(i = 0; i < (*((struct_matrice *) (*s_objet).objet))
                       .nombre_lignes; i++)
               {
                   for(j = 0; j < (*((struct_matrice *) (*s_objet).objet))
                           .nombre_colonnes; j++)
                   {
                       if ((chaine_tampon = formateur_fichier_binaire_nombre(
                               s_etat_processus, &(((integer8 **)
                               (*((struct_matrice *) (*s_objet).objet)).tableau)
                               [i][j]), 'I', format_sortie,
                               longueur, &longueur_element)) == NULL)
                       {
                           free(chaine);
                           return(NULL);
                       }
   
                       memcpy(chaine_offset + (((i * (*((struct_matrice *)
                               (*s_objet).objet)).nombre_colonnes) + j) *
                               longueur), chaine_tampon + 1, (size_t) longueur);
                       free(chaine_tampon);
                   }
               }
         }          }
         else if ((*s_objet).type == MRL)          else if ((*s_objet).type == MRL)
         {          {
Line 3996  formateur_fichier(struct_processus *s_et Line 4939  formateur_fichier(struct_processus *s_et
   Matrice réelle    Matrice réelle
 --------------------------------------------------------------------------------  --------------------------------------------------------------------------------
 */  */
               if (format_sortie == 'N')
               {
                   format_sortie = 'R';
                   longueur = 8;
               }
   
               if ((format_sortie != 'R') && (format_sortie != 'C'))
               {
                   (*s_etat_processus).erreur_execution =
                           d_ex_erreur_format_fichier;
                   return(NULL);
               }
   
               longueur_objet = (*((struct_matrice *) (*s_objet).objet))
                       .nombre_lignes * (*((struct_matrice *) (*s_objet).objet))
                       .nombre_colonnes;
   
               if (((*((struct_matrice *) (*s_objet).objet)).nombre_lignes
                       < (1LL << 8)) && ((*((struct_matrice *) (*s_objet).objet))
                       .nombre_colonnes < (1LL << 8)))
               {
                   // Taille sur un octet
                   if ((chaine = malloc((size_t) ((*longueur_effective) =
                           (3 + (longueur_objet * longueur)))
                           * sizeof(unsigned char))) == NULL)
                   {
                       (*s_etat_processus).erreur_systeme =
                               d_es_allocation_memoire;
                       return(NULL);
                   }
   
                   chaine[0] = 0xC2;
                   chaine[1] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes & 0xFF);
                   chaine[2] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes & 0xFF);
                   chaine_offset = chaine + 3;
               }
               else if (((*((struct_matrice *) (*s_objet).objet)).nombre_lignes
                       < (1LL << 16)) && ((*((struct_matrice *) (*s_objet).objet))
                       .nombre_colonnes < (1LL << 16)))
               {
                   // Taille sur deux octets
                   if ((chaine = malloc((size_t) ((*longueur_effective) =
                           (5 + (longueur_objet * longueur)))
                           * sizeof(unsigned char))) == NULL)
                   {
                       (*s_etat_processus).erreur_systeme =
                               d_es_allocation_memoire;
                       return(NULL);
                   }
   
                   chaine[0] = 0xC6;
                   chaine[1] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 8) & 0xFF);
                   chaine[2] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes & 0xFF);
                   chaine[3] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 8) & 0xFF);
                   chaine[4] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes & 0xFF);
                   chaine_offset = chaine + 5;
               }
               else if (((*((struct_matrice *) (*s_objet).objet)).nombre_lignes
                       < (1LL << 32)) && ((*((struct_matrice *) (*s_objet).objet))
                       .nombre_colonnes < (1LL << 32)))
               {
                   // Taille sur quatre octets
                   if ((chaine = malloc((size_t) (((*longueur_effective) =
                           9 + (longueur_objet * longueur)))
                           * sizeof(unsigned char))) == NULL)
                   {
                       (*s_etat_processus).erreur_systeme =
                               d_es_allocation_memoire;
                       return(NULL);
                   }
   
                   chaine[0] = 0xCA;
                   chaine[1] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 24) & 0xFF);
                   chaine[2] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 16) & 0xFF);
                   chaine[3] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 8) & 0xFF);
                   chaine[4] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes & 0xFF);
                   chaine[5] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 24) & 0xFF);
                   chaine[6] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 16) & 0xFF);
                   chaine[7] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 8) & 0xFF);
                   chaine[8] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes & 0xFF);
                   chaine_offset = chaine + 9;
               }
               else
               {
                   // Taille sur huit octets
                   if ((chaine = malloc((size_t) ((*longueur_effective) =
                           (17 + (longueur_objet * longueur)))
                           * sizeof(unsigned char))) == NULL)
                   {
                       (*s_etat_processus).erreur_systeme =
                               d_es_allocation_memoire;
                       return(NULL);
                   }
   
                   chaine[0] = 0xCE;
                   chaine[1] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 56) & 0xFF);
                   chaine[2] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 48) & 0xFF);
                   chaine[3] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 40) & 0xFF);
                   chaine[4] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 32) & 0xFF);
                   chaine[5] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 24) & 0xFF);
                   chaine[6] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 16) & 0xFF);
                   chaine[7] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes >> 8) & 0xFF);
                   chaine[8] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_lignes & 0xFF);
                   chaine[9] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 56) & 0xFF);
                   chaine[10] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 48) & 0xFF);
                   chaine[11] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 40) & 0xFF);
                   chaine[12] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 32) & 0xFF);
                   chaine[13] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 24) & 0xFF);
                   chaine[14] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 16) & 0xFF);
                   chaine[15] = (unsigned char) (((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes >> 8) & 0xFF);
                   chaine[16] = (unsigned char) ((*((struct_matrice *)
                           (*s_objet).objet)).nombre_colonnes & 0xFF);
                   chaine_offset = chaine + 17;
               }
   
               switch(format_sortie)
               {
                   default:
                   case 'R':
                   {
                       switch(longueur)
                       {
                           case 4:
                           {
                               break;
                           }
   
                           default:
                           case 8:
                           {
                               chaine[0] |= 0x01;
                               break;
                           }
                       }
   
                       break;
                   }
   
                   case 'C':
                   {
                       switch(longueur)
                       {
                           case 8:
                           {
                               break;
                           }
   
                           default:
                           case 16:
                           {
                               chaine[0] |= 0x01;
                               break;
                           }
                       }
   
                       chaine[0] |= 0x10;
                       break;
                   }
               }
   
               for(i = 0; i < (*((struct_matrice *) (*s_objet).objet))
                       .nombre_lignes; i++)
               {
                   for(j = 0; j < (*((struct_matrice *) (*s_objet).objet))
                           .nombre_colonnes; j++)
                   {
                       if ((chaine_tampon = formateur_fichier_binaire_nombre(
                               s_etat_processus, &(((real8 **)
                               (*((struct_matrice *) (*s_objet).objet)).tableau)
                               [i][j]), 'R', format_sortie,
                               longueur, &longueur_element)) == NULL)
                       {
                           free(chaine);
                           return(NULL);
                       }
   
                       memcpy(chaine_offset + (((i * (*((struct_matrice *)
                               (*s_objet).objet)).nombre_colonnes) + j) *
                               longueur), chaine_tampon + 1, (size_t) longueur);
                       free(chaine_tampon);
                   }
               }
         }          }
         else if ((*s_objet).type == NOM)          else if ((*s_objet).type == NOM)
         {          {
Line 4268  formateur_fichier(struct_processus *s_et Line 5422  formateur_fichier(struct_processus *s_et
   
                 memcpy(chaine_offset + (i * longueur), chaine_tampon + 1,                  memcpy(chaine_offset + (i * longueur), chaine_tampon + 1,
                         (size_t) longueur);                          (size_t) longueur);
                   free(chaine_tampon);
             }              }
         }          }
         else if ((*s_objet).type == VIN)          else if ((*s_objet).type == VIN)
Line 4376  formateur_fichier(struct_processus *s_et Line 5531  formateur_fichier(struct_processus *s_et
                 default:                  default:
                 case 'I':                  case 'I':
                 {                  {
                       switch(longueur)
                       {
                           case 1:
                           {
                               break;
                           }
   
                           case 2:
                           {
                               chaine[0] |= 0x01;
                               break;
                           }
   
                           case 4:
                           {
                               chaine[0] |= 0x02;
                               break;
                           }
   
                           default:
                           case 8:
                           {
                               chaine[0] |= 0x03;
                               break;
                           }
                       }
   
                     break;                      break;
                 }                  }
   
                 case 'R':                  case 'R':
                 {                  {
                     chaine[0] |= 0x80;                      switch(longueur)
                     break;                      {
                 }                          case 4:
                           {
                               break;
                           }
   
                 case 'C':                          default:
                 {                          case 8:
                     chaine[0] |= 0x90;                          {
                     break;                              chaine[0] |= 0x01;
                 }                              break;
             }                          }
                       }
   
             switch(longueur)                      chaine[0] |= 0x80;
             {  
                 case 1:  
                 {  
                     break;                      break;
                 }                  }
   
                 case 2:                  case 'C':
                 {                  {
                     chaine[0] |= 0x01;                      switch(longueur)
                     break;                      {
                 }                          case 8:
                           {
                               break;
                           }
   
                 case 4:                          default:
                 {                          case 16:
                     chaine[0] |= 0x02;                          {
                     break;                              chaine[0] |= 0x01;
                 }                              break;
                           }
                       }
   
                 default:                      chaine[0] |= 0x90;
                 case 8:  
                 {  
                     chaine[0] |= 0x03;  
                     break;                      break;
                 }                  }
             }              }
Line 4432  formateur_fichier(struct_processus *s_et Line 5617  formateur_fichier(struct_processus *s_et
   
                 memcpy(chaine_offset + (i * longueur), chaine_tampon + 1,                  memcpy(chaine_offset + (i * longueur), chaine_tampon + 1,
                         (size_t) longueur);                          (size_t) longueur);
                   free(chaine_tampon);
             }              }
         }          }
         else if ((*s_objet).type == VRL)          else if ((*s_objet).type == VRL)
Line 4577  formateur_fichier(struct_processus *s_et Line 5763  formateur_fichier(struct_processus *s_et
   
                 memcpy(chaine_offset + (i * longueur), chaine_tampon + 1,                  memcpy(chaine_offset + (i * longueur), chaine_tampon + 1,
                         (size_t) longueur);                          (size_t) longueur);
                   free(chaine_tampon);
             }              }
         }          }
         else          else

Removed from v.1.84  
changed lines
  Added in v.1.85


CVSweb interface <joel.bertrand@systella.fr>