Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 # ifndef __UTILITES_H__
00020 # define __UTILITES_H__
00021
00022
00023
00024
00025 #ifdef _IN
00026 #error _IN already defined
00027 #endif
00028 #define _IN
00029
00030 #ifdef _OUT
00031 #error _OUT already defined
00032 #endif
00033 #define _OUT
00034
00035 #ifdef _INOUT
00036 #error _INOUT already defined
00037 #endif
00038 #define _INOUT
00039
00040 #ifdef _UNUSED
00041 #error _UNUSED already defined
00042 #endif
00043 #define _UNUSED
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 # define ICI {\
00055 fflush(stdout);\
00056 fprintf(stderr, "%s [%d] : " , __FILE__ , __LINE__ ) ;\
00057 fflush(stderr) ;\
00058 }
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 # ifdef INFOS_COMPILATION
00070 # error INFOS_COMPILATION already defined
00071 # endif
00072 # define INFOS_COMPILATION {\
00073 fflush(stderr);\
00074 fprintf(stdout, "%s [%d] : " , __FILE__ , __LINE__ ) ;\
00075 fprintf(stdout,"Compilation le %s" , __DATE__);\
00076 fprintf(stdout," a %s" , __TIME__ );\
00077 fprintf(stdout,"\n\n\n" );\
00078 fflush(stdout) ;\
00079 }
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 # ifdef ATTENTE
00091 # error ATTENTE already defined
00092 # endif
00093 # define ATTENTE(secondes) {\
00094 ICI ;\
00095 fprintf( stderr, "ATTENTE de %d secondes" , secondes);\
00096 fflush(stderr) ;\
00097 sleep(secondes) ;\
00098 fprintf( stderr, "\n" );\
00099 fflush(stderr) ;\
00100 }
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 # ifdef EXECUTION
00111 # error EXECUTION already defined
00112 # endif
00113 # ifdef INTERRUPTION
00114 # error INTERRUPTION already defined
00115 # endif
00116 # ifdef ISCRUTE
00117 # error ISCRUTE already defined
00118 # endif
00119 # ifdef RSCRUTE
00120 # error RSCRUTE already defined
00121 # endif
00122 # ifdef SSCRUTE
00123 # error SSCRUTE already defined
00124 # endif
00125 # ifdef CSCRUTE
00126 # error CSCRUTE already defined
00127 # endif
00128 # ifdef XSCRUTE
00129 # error XSCRUTE already defined
00130 # endif
00131 # ifdef MESSAGE
00132 # error MESSAGE already defined
00133 # endif
00134
00135
00136
00137
00138
00139 # ifdef _DEBOG_
00140
00141
00142
00143
00144 # define EXECUTION(instruction) {\
00145 ICI ;\
00146 fprintf( stderr,"INSTRUCTION %s" , #instruction ) ;\
00147 fflush(stderr);\
00148 instruction ;\
00149 fflush(stdout);\
00150 fprintf( stderr," FRANCHIE\n" ) ;\
00151 fflush(stderr);\
00152 }
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 # define INTERRUPTION(code) {\
00164 ICI ;\
00165 fprintf( stderr," INTERRUPTION code = %d",code) ;\
00166 fprintf(stderr,"\n") ;\
00167 exit(code) ;\
00168 }
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179 # ifndef ASSERT
00180 # define ASSERT(condition) if( !(condition) ){\
00181 ICI ;\
00182 fprintf(stderr,"condition %s VIOLEE\n",#condition);\
00183 INTERRUPTION(17);\
00184 }
00185 # endif
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 # define ISCRUTE(entier) {\
00196 ICI ;\
00197 fprintf(stderr,"%s = %d\n",#entier,entier) ;\
00198 fflush(stderr) ;\
00199 }
00200 # define RSCRUTE(reel) {\
00201 ICI ;\
00202 fprintf(stderr,"%s = %f\n",#reel,reel) ;\
00203 fflush(stderr) ;\
00204 }
00205 # define XSCRUTE(pointeur) {\
00206 ICI ;\
00207 fprintf(stderr,"%s = %x\n",#pointeur,pointeur) ;\
00208 fflush(stderr) ;\
00209 }
00210 # define CSCRUTE(car) {\
00211 ICI ;\
00212 fprintf(stderr,"%s = %c\n",#car,car) ;\
00213 fflush(stderr) ;\
00214 }
00215 # define SSCRUTE(chaine) {\
00216 ICI ;\
00217 fprintf(stderr,"%s = \"%s\"\n",#chaine,chaine) ;\
00218 fflush(stderr) ;\
00219 }
00220 # define MESSAGE(chaine) {\
00221 ICI ;\
00222 fprintf(stderr,"%s\n",chaine) ;\
00223 fflush(stderr) ;\
00224 }
00225 # define FIN(nom) {\
00226 ICI ;\
00227 fprintf( stderr , "} FIN %s\n\n\n" , nom ) ;\
00228 fflush(stderr) ;\
00229 }
00230 # define DEBUT(nom) {\
00231 fprintf( stderr , "\n\n\n") ;\
00232 ICI ;\
00233 fprintf( stderr , "{ DEBUT %s\n" , nom ) ;\
00234 fflush(stderr) ;\
00235 }
00236
00237
00238 # else
00239
00240
00241
00242 # define EXECUTION(instruction) instruction
00243 # define INTERRUPTION(code)
00244
00245 # ifndef ASSERT
00246 # define ASSERT(condition)
00247 # endif
00248
00249 # define ISCRUTE(entier)
00250 # define RSCRUTE(reel)
00251 # define CSCRUTE(car)
00252 # define SSCRUTE(chaine)
00253 # define MESSAGE(chaine)
00254 # define DEBUT(nom)
00255 # define FIN(nom)
00256
00257
00258 # endif
00259
00260
00261 # endif