_MEDlinkRd30.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 <med.h>
00020 #include <med_config.h>
00021 #include <med_outils.h>
00022 
00023 #include <string.h>
00024 #include <stdlib.h>
00025 
00026 void
00027 _MEDlinkRd30(int dummy, ...)
00028 {
00029   va_list params;
00030   va_start(params,dummy);
00031 
00032   const med_idt      fid        = va_arg(params, const  med_idt       );
00033   const char* const  meshname   = va_arg(params, const  char* const   );
00034         char* const  link       = va_arg(params,        char* const   );
00035   med_err *          fret       = va_arg(params,        med_err*      );
00036 
00037 
00038   med_idt        _lid=0, _root=0;
00039   med_err        _ret=-1;
00040   char           _path[MED_TAILLE_LIENS+MED_NAME_SIZE+1]=MED_LIENS;
00041   med_int        _n=0;
00042   med_filter     _filter        = MED_FILTER_INIT;
00043 
00044   /*
00045    * On inhibe le gestionnaire d'erreur HDF 5
00046    */
00047   _MEDmodeErreurVerrouiller();
00048 
00049 
00050   /*
00051    * Ouverture du DataGroup /LIENS/
00052    */
00053   if ((_root = _MEDdatagroupOuvrir(fid,_path)) < 0) {
00054       MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
00055       goto ERROR;
00056     }
00057 
00058   /*
00059    * Ouverture du /LIENS/<meshname>
00060    */
00061   if ((_lid = _MEDdatagroupOuvrir(_root,meshname)) < 0) {
00062     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,meshname);
00063     SSCRUTE(_path);goto ERROR;
00064   }
00065 
00066   strcat(_path,meshname);
00067 
00068 
00069   /*
00070    * On lit <n> sous forme d'attribut
00071    */
00072   if (_MEDattrEntierLire(_lid,MED_NOM_NBR,&_n) < 0) {
00073     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LINK_MSG);
00074     SSCRUTE(_path);SSCRUTE(MED_NOM_NBR);ISCRUTE(_n);
00075     goto ERROR;
00076   }
00077 
00078   /*
00079    * On lit le link dans un dataset
00080    */
00081   if ( MEDfilterEntityCr(fid,_n, 1, 1, MED_ALL_CONSTITUENT,
00082                          MED_NO_INTERLACE,MED_UNDEF_PFLMODE,
00083                          MED_NO_PROFILE, MED_UNDEF_SIZE, NULL, &_filter) < 0 ) {
00084     MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,MED_ERR_INTERNAL_MSG);
00085     goto ERROR;
00086   }
00087 
00088   if ( _MEDdatasetRd(_lid,MED_NOM_LIE,MED_INTERNAL_CHAR,&_filter,(unsigned char *) link) < 0) {
00089     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_DATASET,MED_NOM_LIE);SSCRUTE(_path);
00090     goto ERROR;
00091   }
00092 
00093   if ( MEDfilterClose(&_filter) < 0 ) {
00094     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_LINK_MSG); SSCRUTE(_path);
00095     goto ERROR;
00096   }
00097 
00098 
00099   _ret = 0;
00100 
00101  ERROR:
00102 
00103   if (_lid>0)            if (_MEDdatagroupFermer(_lid) < 0) {
00104     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,meshname);
00105     ISCRUTE_id(_lid);
00106   }
00107 
00108   if (_root>0)            if (_MEDdatagroupFermer(_root) < 0) {
00109     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_LIENS);
00110     ISCRUTE_id(_root);
00111   }
00112 
00113 
00114   va_end(params);
00115   *fret = _ret;
00116   return;
00117 }

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