MED fichier
MEDexitIf.c
Aller à la documentation de ce fichier.
1 /* This file is part of MED.
2  *
3  * COPYRIGHT (C) 1999 - 2016 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 <stdio.h>
20 #include <stdlib.h>
21 #include <med_exit_if.h>
22 
23 
24 /******************************************************************************
25  *
26  * - Nom de la fonction : exit_if
27  * - Description : gestion et affichage des erreurs.
28  * - Parametres :
29  * - fichier (IN) : nom du fichier.
30  * - ligne (IN) : ligne ou s'est produite l'erreur.
31  * - condition (IN) : condition a evaluer pour voir s'il y a une erreur.
32  * - message (IN) : message a afficher sur le "stderr" en cas d'erreur.
33  * - arg (IN) : parametre en complement au message.
34  *
35  ******************************************************************************/
36 void exit_if(const char * const fichier,int ligne, int condition,const char * const message, const char * const arg)
37 {
38  if (condition == 0)
39  return;
40  if (message != NULL)
41  if (arg == NULL)
42  fprintf(stderr,"%s : %d : >>>> ERREUR : %s \n",
43  fichier,ligne,message);
44  else
45  fprintf(stderr,"%s : %d : >>>> ERREUR : %s %s \n",
46  fichier,ligne,message,arg);
47  else
48  fprintf(stderr,"%s : %d : >>>> ERREUR d'allocation memoire \n",
49  fichier,ligne);
50  exit(condition);
51 }
void exit_if(const char *const fichier, int ligne, int condition, const char *const message, const char *const arg)
Definition: MEDexitIf.c:36