00001
00006 #include "guihandler.h"
00007
00114
00115
00121 unsigned int MASK = 1;
00122
00129 bool showUsage_and_setTracingVerbosity( int argc,
00131 char **argv
00133 );
00134
00135
00143 int main( int argc, char **argv )
00144 {
00145
00146 bool quit = showUsage_and_setTracingVerbosity( argc, argv );
00147
00148 if( quit )
00149 return 0;
00150
00151 assert( !quit );
00152
00153 #ifdef DEBUG
00154 printf("\n");
00155 if( MASK==0 )
00156 printf("DEBUG flag is active but no output will show (MASK = 0).\n\n");
00157 else
00158 {
00159 printf("Debug output will show:");
00160 D1(printf("\n%s",ID1));
00161 D2(printf("\n%s",ID2));
00162 D3(printf("\n%s",ID3));
00163 D4(printf("\n%s",ID4));
00164 D5(printf("\n%s",ID5));
00165 D6(printf("\n%s",ID6));
00166 D7(printf("\n%s",ID7));
00167 D8(printf("\n%s",ID8));
00168 }
00169 D1(printf("\n***** START DEBUG OUTPUT ************************************\n"));
00170 D1(printf("\nmain function START\n"));
00171 #endif
00172
00173 gui( argc, argv );
00174
00175 #ifdef DEBUG
00176 D1(printf("\nmain funtion END.\n\n"));
00177 D1(printf("\n***** END DEBUG OUTPUT ************************************\n\n"));
00178 #endif
00179
00180 return 0;
00181 }
00182
00183
00184
00185 bool showUsage_and_setTracingVerbosity( int argc, char **argv )
00186 {
00187
00188 int i = 1;
00189 for(; i<argc; i++)
00190 if( ( strcmp( argv[i] , "-h") == 0 ) ||
00191 ( strcmp( argv[i] , "--help") == 0 )
00192 ){
00193 printf("\n\nRead README for more informations.\n"\
00194 "Use the options -n to show program usage.\n\n");
00195 return true;
00196 }
00197 else
00198 if( ( strcmp( argv[i] , "-v") == 0 ) ||
00199 ( strcmp( argv[i] , "--version") == 0 )
00200 ){
00201 printf("\n\nVersion: %s\n\n",PRGVERS);
00202 return true;
00203 }
00204 else
00205 if( ( strcmp( argv[i] , "-l") == 0 ) ||
00206 ( strcmp( argv[i] , "--license") == 0 )
00207 ){
00208 printf("\n\nLicense:\n\n%s\n\n",PRGLICS);
00209 return true;
00210 }
00211 else
00212 if( ( strcmp( argv[i] , "-c") == 0 ) ||
00213 ( strcmp( argv[i] , "--credits") == 0 )
00214 ){
00215 printf( "\n\nCredits:\n\n"\
00216 "%s\n\n",PRGAUTH );
00217 return true;
00218 }
00219 else
00220 if( ( strcmp( argv[i] , "-V") == 0 ) ||
00221 ( strcmp( argv[i] , "--verbosity") == 0 )
00222 ){
00223 double control = -1;
00224 if( argc <= (i+1) ){
00225 printf( "\n\nMissing argument [VALUE]!\n\n"\
00226 "Please, show the program usage.\n\n" );
00227
00228 return true;
00229 }
00230
00231
00232 control = atoi( argv[ i+1 ] );
00233 if( ( control < 0 ) || ( control > BITMASK_MAX ) ){
00234 printf( "\n\nArgument [VALUE] (%.0lf) out of range (0-%u)!"\
00235 "\n\n", control, BITMASK_MAX );
00236
00237 return true;
00238 }
00239
00240 assert( ( control >= 0 ) && ( control <= BITMASK_MAX ) );
00241
00242 MASK = (unsigned int)control;
00243
00244 return false;
00245 }
00246 else
00247 {
00248 printf("\n\n"\
00249 "%s v%s\n%s\n"\
00250 "%s\n%s\n\n"\
00251 " Usage: %s [OPTION]\n\n"\
00252 " Default (no options and no values):\n"\
00253 " Run the program using the Graphic User Interface\n"\
00254 " and default tracing verbosity level (%u).\n\n"\
00255 " OPTIONS:\n"\
00256 " -V [VALUE],\n"\
00257 " --verbosity [VALUE] : Set tracing verbosity level\n"\
00258 " to [VALUE] (0-%u) and run\n"\
00259 " -v, --version : Display program version\n"\
00260 " -l, --license : Display program license\n"\
00261 " -h, --help : Display a little help\n"\
00262 " -c, --credits : Display program credits\n"\
00263 " -n, * : Display this informations\n\n"\
00264 " * = all parameters except just showed.\n\n"
00265 ,PRGNAME, PRGVERS, PRGCPYR
00266 ,PRGAIMS, PRGWBLK
00267 ,argv[0]
00268 ,MASK
00269 ,BITMASK_MAX
00270 );
00271 return true;
00272 }
00273
00274
00275 return false;
00276 }
00277
00278
00279