_MEDconvertStringDatasets.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 #include <hdf5.h>
00023 #include <string.h>
00024 
00025 #include "MAJ_236_300.h"
00026 
00027 /* #include <2.3.6/med23v30.h> */
00028 /* #include <2.3.6/med23v30_proto.h> */
00029 /* #include "2.3.6/med23v30_misc.h" */
00030 
00031 #define MED_TAILLE_LNOM 80
00032 #define MAX_LEN_PATH 255
00033 
00034 med_err _MEDconvertStringDatasets(med_idt id, const char *lname, const H5L_info_t *linfo, visitordatas *data) {
00035 
00036   med_err  _ret=-1,_err=-1;
00037   med_idt  _gid=0;
00038   H5O_info_t oinfo;
00039   char     _tmpbuff[MAX_LEN_PATH+1]="";
00040   int      _tmpbuffsize=0;
00041   med_int  _nbratt=0;
00042 
00043 #ifdef _DEBUG_
00044   SSCRUTE(lname);
00045 #endif
00046 
00047   if (!strcmp(lname,".")) return 0;
00048 
00049   switch ( (*linfo).type ) {
00050 
00051   case H5L_TYPE_SOFT:
00052     oinfo.type=(H5O_type_t) H5G_LINK;
00053     break;
00054   case H5L_TYPE_HARD:
00055     if ( H5Oget_info_by_name( id, lname, &oinfo, H5P_DEFAULT ) <0) {
00056       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"H5Oget_info_by_name");
00057       SSCRUTE(lname);
00058     }
00059     break;
00060   case H5L_TYPE_EXTERNAL:
00061   case H5L_TYPE_ERROR:
00062   default:
00063     MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_HDFTYPE,lname);
00064     ISCRUTE_int((*linfo).type);
00065     goto ERROR;
00066     break;
00067  }
00068 
00069   switch ( oinfo.type ) {
00070 
00071   case H5G_GROUP:
00072   case H5G_LINK:
00073     break;
00074 
00075   case H5G_DATASET:
00076 
00077     strcat(_tmpbuff,lname);
00078     _tmpbuffsize=strlen(_tmpbuff);
00079 
00080     /*
00081       Ce traitement est spécifique aux datatsets présents dans les familles
00082     */
00083 /*     SSCRUTE(_tmpbuff); */
00084 /*     SSCRUTE(&_tmpbuff[_tmpbuffsize-3]); */
00085     if ( strcmp(&_tmpbuff[_tmpbuffsize-3],MED_NOM_NOM) ) break;
00086 
00087     _tmpbuff[_tmpbuffsize-4]='\0';
00088 /*     SSCRUTE(_tmpbuff); */
00089 
00090     /*
00091      * Lecture de l'attribut MED_NOM_NBR sur le dataset
00092      */
00093     if ( _MEDattributeNumRdByName(id,_tmpbuff,MED_NOM_NBR,MED_INTERNAL_INT,
00094                                   ( unsigned char * const) &_nbratt ) < 0 ) {
00095       MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_NBR);
00096       goto ERROR;
00097     }
00098 
00099 /*     ISCRUTE(_nbratt); */
00100     _err=MAJ_236_300_string_datasets( data->gid2, _tmpbuff, MED_NOM_NOM, MED_TAILLE_LNOM,
00101                                       MED_LNAME_SIZE,_nbratt);
00102 
00103     MED_ERR_EXIT_IF( _err < 0, MED_ERR_CALL, MED_ERR_API, "MAJ_236_300_string_datasets");
00104 
00105     _tmpbuff[_tmpbuffsize-4]='/';
00106     _err = H5Adelete_by_name( data->gid2, _tmpbuff, MED_NOM_NBR, H5P_DEFAULT  );
00107 
00108     MED_ERR_EXIT_IF( _err < 0, MED_ERR_DELETE, MED_ERR_ATTRIBUTE, "MED_NOM_NBR");
00109 
00110 
00111   break;
00112 
00113   case H5G_TYPE:
00114   default:
00115     MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_HDFTYPE,lname);
00116     goto ERROR;
00117   }
00118   _ret = 0;
00119 
00120  ERROR:
00121   return _ret;
00122 }
00123 

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