MEDfileStrVersionRd.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 
00019 #include <stdio.h>
00020 
00021 #include <med.h>
00022 #include <med_config.h>
00023 #include <med_outils.h>
00024 
00025 
00034 med_err
00035 MEDfileStrVersionRd(const med_idt fid,
00036                     char* const medversion)
00037 {
00038   med_err _ret = -1;
00039   med_idt _id=0;
00040   med_int _major;
00041   med_int _minor;
00042   med_int _release;
00043 
00044   int _intmajor;
00045   int _intminor;
00046   int _intrelease;
00047 
00048   /* We read the hdf attributes in the MED_INFOS hdf group */
00049   if ((_id = _MEDdatagroupOuvrir(fid,MED_INFOS)) < 0) {
00050     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_INFOS);
00051     goto ERROR;
00052   }
00053 
00054   if (_MEDattrEntierLire(_id,MED_MAJOR_NAME,&_major) < 0) {
00055     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_MAJOR_NAME);
00056     goto ERROR;
00057   }
00058 
00059   if (_MEDattrEntierLire(_id,MED_MINOR_NAME,&_minor) < 0) {
00060     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_MINOR_NAME);
00061     goto ERROR;
00062   }
00063 
00064   if (_MEDattrEntierLire(_id,MED_RELEASE_NAME,&_release) < 0) {
00065     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_RELEASE_NAME);
00066     goto ERROR;
00067   }
00068 
00069   _intmajor  = (int)  _major;
00070   _intminor  = (int)  _minor;
00071   _intrelease= (int)  _release;
00072 
00073   if (medversion)
00074     sprintf(medversion,"MED-%d.%d.%d",_intmajor,_intminor,_intrelease);
00075 
00076   _ret = 0;
00077   ERROR :
00078 
00079   /* the hdf group is closed  */
00080   if (_id > 0)
00081     if (_MEDdatagroupFermer(_id) < 0) {
00082       MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,"");
00083       _ret = -1;
00084     }
00085 
00086   return _ret;
00087 }

Généré le Mon May 16 17:10:23 2011 pour MED fichier par  doxygen 1.6.1