Verbose option added
authorFrancoisGrondin <francois.grondin2@usherbrooke.ca>
Thu, 21 Sep 2017 20:22:40 +0000 (16:22 -0400)
committerFrancoisGrondin <francois.grondin2@usherbrooke.ca>
Thu, 21 Sep 2017 20:22:40 +0000 (16:22 -0400)
demo/main.c

index 84a6c396d62ff16a95dd1d099b5a51a2c2e277f9..a29b82b0f291012fdbcf5674e66d346acb4d12e2 100644 (file)
 
             file_config = (char *) NULL;
             file_ios = (char *) NULL;
+            char verbose = 0x00;
 
             type = processing_multithread;
 
-            while ((c = getopt(argc,argv, "hc:i:s")) != -1) {
+            while ((c = getopt(argc,argv, "hc:i:sv")) != -1) {
 
                 switch(c) {
 
 
                     break;
 
+                    case 'v':
+
+                        verbose = 0x01;
+
+                    break;
+
                 }
 
             }
         // | Copyright                                            |
         // +------------------------------------------------------+ 
 
+            if (verbose == 0x01) {
+
             printf("+--------------------------------------------+\n");
             printf("|    ODAS (Open embeddeD Audition System)    |\n");
             printf("+--------------------------------------------+\n");
             printf("| Version: 1.0                               |\n");
             printf("+--------------------------------------------+\n");
 
+            }
+
         // +------------------------------------------------------+
         // | Single thread                                        |
         // +------------------------------------------------------+  
             // | Configure                                        |
             // +--------------------------------------------------+ 
 
-                printf("  + Initializing configurations...... "); fflush(stdout); 
+                if (verbose == 0x01) printf("  + Initializing configurations...... "); fflush(stdout); 
 
                 cfgs = configs_construct(file_config, file_ios);
 
-                printf("[Done]\n");
+                if (verbose == 0x01) printf("[Done]\n");
 
             // +--------------------------------------------------+
             // | Construct                                        |
             // +--------------------------------------------------+  
 
-                printf("  + Initializing objects............. "); fflush(stdout); 
+                if (verbose == 0x01) printf("  + Initializing objects............. "); fflush(stdout); 
 
                 objs = objects_construct(cfgs);    
                 
-                printf("[Done]\n");   
+                if (verbose == 0x01) printf("[Done]\n");   
 
             // +--------------------------------------------------+
             // | Processing                                       |
             // +--------------------------------------------------+  
 
-                printf("  + Processing....................... "); fflush(stdout);
+                if (verbose == 0x01) printf("  + Processing....................... "); fflush(stdout);
 
                 threads_single_open(objs);
                 stopProcess = 0;
                 while((threads_single_process(objs, prf) == 0) && (stopProcess == 0));
                 threads_single_close(objs);
 
-                printf("[Done]\n");
+                if (verbose == 0x01) printf("[Done]\n");
 
             // +--------------------------------------------------+
             // | Free memory                                      |
             // +--------------------------------------------------+  
 
-                printf("  + Free memory...................... "); fflush(stdout);
+                if (verbose == 0x01) printf("  + Free memory...................... "); fflush(stdout);
 
                 objects_destroy(objs);
                 configs_destroy(cfgs);
                 free((void *) file_config);
                 free((void *) file_ios);
 
-                printf("[Done]\n");
+                if (verbose == 0x01) printf("[Done]\n");
 
             // +--------------------------------------------------+
             // | Results                                          |
             // +--------------------------------------------------+  
 
-                profiler_printf(prf);
+                if (verbose == 0x01) profiler_printf(prf);
 
                 profiler_destroy(prf);
 
             // | Configure                                        |
             // +--------------------------------------------------+ 
 
-                printf("  + Initializing configurations...... "); fflush(stdout); 
+                if (verbose == 0x01) printf("  + Initializing configurations...... "); fflush(stdout); 
 
                 cfgs = configs_construct(file_config, file_ios);
 
-                printf("[Done]\n");
+                if (verbose == 0x01) printf("[Done]\n");
 
             // +--------------------------------------------------+
             // | Construct                                        |
             // +--------------------------------------------------+  
 
-                printf("  + Initializing objects............. "); fflush(stdout); 
+                if (verbose == 0x01) printf("  + Initializing objects............. "); fflush(stdout); 
                 
                 aobjs = aobjects_construct(cfgs);    
 
-                printf("[Done]\n");                         
+                if (verbose == 0x01) printf("[Done]\n");                         
 
             // +--------------------------------------------------+
             // | Launch threads                                   |
 
                 signal(SIGINT, sighandler);
 
-                printf("  + Launch threads................... "); fflush(stdout); 
+                if (verbose == 0x01) printf("  + Launch threads................... "); fflush(stdout); 
 
                 threads_multiple_start(aobjs);
 
-                printf("[Done]\n");
+                if (verbose == 0x01) printf("[Done]\n");
 
             // +--------------------------------------------------+
             // | Wait                                             |
             // +--------------------------------------------------+  
 
-                printf("  + Threads running.................. "); fflush(stdout); 
+                if (verbose == 0x01) printf("  + Threads running.................. "); fflush(stdout); 
                 
                 threads_multiple_join(aobjs);
 
-                printf("[Done]\n");
+                if (verbose == 0x01) printf("[Done]\n");
 
             // +--------------------------------------------------+
             // | Free memory                                      |
             // +--------------------------------------------------+  
 
-                printf("  + Free memory...................... "); fflush(stdout);
+                if (verbose == 0x01) printf("  + Free memory...................... "); fflush(stdout);
 
                 aobjects_destroy(aobjs);
                 configs_destroy(cfgs);
                 free((void *) file_config);
                 free((void *) file_ios);
 
-                printf("[Done]\n");
+                if (verbose == 0x01) printf("[Done]\n");
 
             }