1 /* This file is part of MED.
2 *
3 * COPYRIGHT (C) 1999 - 2019 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 #include <string.h>
23
24 /*
25 * - Nom de la fonction : MEDlienLire
26 * - Description : Ecrit le chemin d'accès à un maillage distant
27 * - Parametres :
28 * - fid (IN) : ID du fichier HDF courant
29 * - lienval (IN) : le chemin d'accès au fichier contenant le maillage distant
30 * - maa (IN) : le nom du lien à lire <=> nom du maillage
31 * - Resultat : 0 en cas de succes, -1 sinon
32 */
33
34 med_err
MEDlienLire(_IN med_idt fid,_OUT char * lienval,_IN char * maa)35 MEDlienLire(_IN med_idt fid, _OUT char * lienval, _IN char * maa)
36 {
37 med_err ret = 0;
38 med_idt gid;
39 char chemin[MED_TAILLE_LIENS+MED_TAILLE_NOM+1];
40
41 /*
42 * On inhibe le gestionnaire d'erreur HDF 5
43 */
44 _MEDmodeErreurVerrouiller();
45 if (MEDcheckVersion(fid) < 0) return -1;
46
47 /* SSCRUTE(maa); */
48 /* SSCRUTE(lienval); */
49 /*
50 * ouverture du groupe /LIENS/"maa"
51 */
52 strcpy(chemin,MED_LIENS);
53 strcat(chemin,maa);
54 if ((gid = _MEDdatagroupOuvrir(fid,chemin)) < 0) {
55 MESSAGE("Impossible d'ouvrir le datagroup <maa> : ");
56 SSCRUTE(maa); return -1;
57 }
58 /* SSCRUTE(maa); */
59 /* SSCRUTE(lienval); */
60
61 /*
62 * Lecture du lien
63 */
64
65 if ((ret = _MEDdatasetStringLire(gid,MED_NOM_LIE,lienval)) < 0) {
66 MESSAGE("Erreur à la lecture du dataset lienval : ");
67 SSCRUTE(lienval); return -1;
68 }
69 /* SSCRUTE(maa); */
70 /* SSCRUTE(lienval); */
71
72 /*
73 * On ferme tout
74 */
75 if ((ret = _MEDdatagroupFermer(gid)) < 0)
76 return -1;
77
78 return ret;
79 }
80