MED fichier: Fichier source de MEDfileObjectExist.c

MED fichier

- Documentation MED
- Guides d'utilisation
- Guides de référence

MEDfileObjectExist.c
Aller à la documentation de ce fichier.
1 /* This file is part of MED.
2 *
3 * COPYRIGHT (C) 1999 - 2015 EDF R&D, CEA/DEN
4 * MED is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * MED is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with MED. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18
19 #include <med.h>
20 #include <med_config.h>
21 #include <med_outils.h>
22
23 #include <string.h>
24
25
26 /*
27 Les objets de class medclass dont il est ici question sont représentés par des noms de groupes
28 dans le modèle HDF.
29 */
30 #define MY_CASE(OBJ)\
31 case MED_##OBJ :\
32 strcpy(_link,MED_##OBJ##_GRP);\
33 _objsize = MED_##OBJ##_GRP_SIZE;\
34 break;
35
46 med_err
47 MEDfileObjectExist(const med_idt fid,
48 const med_class medclass,
49 const char * const objectname,
50 med_bool * const objectexist )
51 {
52 med_idt _fid = 0;
53 med_err _ret = -1;
54 char _link[2*MED_NAME_SIZE+1]="";
55 med_bool _datagroupexist=MED_FALSE,_isasoftlink=MED_FALSE;
56 int _objsize = 0;
57
58 /*
59 * On inhibe le gestionnaire d'erreur HDF
60 */
61 _MEDmodeErreurVerrouiller();
62
63 *objectexist = MED_FALSE;
64 /*
65 * Give access to the class object in the local file
66 */
67 switch(medclass) {
68
69 MY_CASE(MESH);
70 MY_CASE(MESH_SUPPORT);
71 MY_CASE(ELSTRUCT);
72 MY_CASE(FAMILY);
73 MY_CASE(EQUIVALENCE);
74 MY_CASE(JOINT);
75 MY_CASE(FIELD);
76 MY_CASE(LOCALIZATION);
77 MY_CASE(PROFILE);
78 MY_CASE(INTERPOLATION);
79 MY_CASE(NUMERICAL_DATA);
80
81 default :
82 MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_CLASS,_link);
83 goto ERROR;
84 }
85
86 strncpy(_link+_objsize,objectname,MED_NAME_SIZE+1);
87 _link[2*MED_NAME_SIZE]='\0';
88
89 if( _MEDdatagroupExist(fid,_link,&_datagroupexist,&_isasoftlink) < 0 ) {
90 MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDdatagroupExist");
91 SSCRUTE(_link);goto ERROR;
92 }
93
94 if ( _datagroupexist ) *objectexist = MED_TRUE;
95
96 _ret=0;
97 ERROR:
98
99 return _ret;
100 }
101
med_err
herr_t med_err
Definition: med.h:325
med_class
med_class
Definition: med.h:183
med_config.h
MED_ERR_CLASS
#define MED_ERR_CLASS
Definition: med_err.h:127
MY_CASE
#define MY_CASE(OBJ)
Definition: MEDfileObjectExist.c:30
med_outils.h
med.h
MED_ERR_CALL
#define MED_ERR_CALL
Definition: med_err.h:45
MED_TRUE
Definition: med.h:255
_MEDdatagroupExist
MEDC_EXPORT med_err _MEDdatagroupExist(const med_idt gid, const char *const datagroupname, med_bool *const datagroupexist, med_bool *const isasoftlink)
MED_ERR_RANGE
#define MED_ERR_RANGE
Definition: med_err.h:31
_MEDmodeErreurVerrouiller
MEDC_EXPORT void _MEDmodeErreurVerrouiller(void)
med_idt
hid_t med_idt
Definition: med.h:324
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition: med.h:77
MED_FALSE
Definition: med.h:255
med_bool
med_bool
Definition: med.h:255
MEDfileObjectExist
med_err MEDfileObjectExist(const med_idt fid, const med_class medclass, const char *const objectname, med_bool *const objectexist)
Interroge le fichier fid pour tester l'existence de l'objet objectname de type medclass.
Definition: MEDfileObjectExist.c:47
MED_ERR_API
#define MED_ERR_API
Definition: med_err.h:108
SSCRUTE
#define SSCRUTE(chaine)
Definition: med_utils.h:315
MED_ERR_
#define MED_ERR_(rt, r1, r2, r3)
Definition: med_utils.h:158