Projet Informatique Théorique 2016
Instructions et Documentation
outils.h
1 /*
2  * Ce fichier fait partie d'un projet de programmation donné en Licence 3
3  * à l'Université de Bordeaux.
4  *
5  * Copyright (C) 2014 Adrien Boussicault
6  *
7  * This Library is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This Library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this Library. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 #ifndef __OUTILS_H__
23 #define __OUTILS_H__
24 
25 #include <stdio.h>
26 #include <stdlib.h>
27 
28 #define DEBUG(x) do { fprintf(stderr,"DEBUG : %s - ligne : %d, fichier : %s\n", (x), __LINE__, __FILE__ ); } while(0)
29 #define DEBUGO(x) do { fprintf(stdout,"DEBUG : %s - ligne : %d, fichier : %s\n", (x), __LINE__, __FILE__ ); } while(0)
30 #define ERREUR(x) do { fprintf(stderr,"ERREUR : %s - ligne : %d, fichier : %s\n", (x), __LINE__, __FILE__ ); exit(EXIT_FAILURE); } while(0)
31 
32 void* xmalloc( size_t n );
33 void xfree( void* ptr );
34 
35 #define TEST(y,x) do { x &= (y); if(!(y)){ fprintf(stdout, "\033[31mEchec du test %s() -- ligne : %d, fichier : %s\033[0m\n", __FUNCTION__, __LINE__, __FILE__ ); } } while(0)
36 #define TEST1(x) test( x, __LINE__)
37 
38 #define A_FAIRE do { fprintf(stdout,"A FAIRE ! - ligne : %d, fichier : %s, fonction : %s( )\n", __LINE__, __FILE__, __FUNCTION__ ); } while(0)
39 #define A_FAIRE_RETURN(x) do { fprintf(stdout,"A FAIRE ! - ligne : %d, fichier : %s, fonction : %s( )\n", __LINE__, __FILE__, __FUNCTION__ ); return x; } while(0)
40 
41 int test( int result, int ligne );
42 
43 #endif
44