# MEDfichEntete.c

Aller à la documentation de ce fichier.

    00001 /*  This file is part of MED.
    00002  *
    00003  *  COPYRIGHT (C) 1999 - 2011  EDF R&D, CEA/DEN
    00004  *  MED is free software: you can redistribute it and/or modify
    00005  *  it under the terms of the GNU Lesser General Public License as published by
    00006  *  the Free Software Foundation, either version 3 of the License, or
    00007  *  (at your option) any later version.
    00008  *
    00009  *  MED is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012  *  GNU Lesser General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Lesser General Public License
    00015  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
    00016  */
    00017
    00018 #include <med.h>
    00019 #include <med_config.h>
    00020 #include <med_outils.h>
    00021
    00022 #include <string.h>
    00023
    00024 med_err
    00025 MEDfichEntete(med_idt fid, med_fich_info quoi, char str[])
    00026 {
    00027   med_idt atid, root;
    00028   med_err ret;
    00029   char locale[MED_TAILLE_DESC+1];
    00030   char chemin[MED_TAILLE_MAA+1];
    00031
    00032   switch (quoi)
    00033     {
    00034     case MED_HDF_VERSION :
    00035       strcpy(str,HDF_VERSION_ACTUELLE);
    00036       break;
    00037
    00038     case MED_VERSION :
    00039       strcpy(str,PACKAGE_VERSION);
    00040       break;
    00041
    00042     case MED_FICH_DES :
    00043       /*
    00044        * On inhibe le gestionnaire d'erreur HDF
    00045        */
    00046       _MEDmodeErreurVerrouiller();
    00047 if (MEDcheckVersion(fid) < 0) return -1;
    00048
    00049       /*
    00050        * On ouvre le Data Group racine
    00051        */
    00052       strncpy(chemin,MED_MAA,strlen(MED_MAA)-1);
    00053       chemin[MED_TAILLE_MAA-1] = '\0';
    00054       if ((root = _MEDdatagroupOuvrir(fid,chemin)) < 0)
    00055         return -1;
    00056
    00057       /*
    00058        * On regarde si l'attribut existe
    00059        * Si non => erreur
    00060        * Si oui => on le copie dans str
    00061        */
    00062       if ((ret = _MEDattrStringLire(root,MED_NOM_DESCRIPTEUR,
    00063                                     MED_TAILLE_DESC,locale)) < 0) {
    00064         _MEDdatagroupFermer(root);
    00065         return -1;
    00066       }
    00067
    00068       strcpy(str,locale);
    00069
    00070       if ( _MEDdatagroupFermer(root) < 0)
    00071         return -1;
    00072
    00073       break;
    00074
    00075     default :
    00076       return -1;
    00077     }
    00078   return 0;
    00079 }