mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-11-04 09:02:12 +00:00 
			
		
		
		
	Merge pull request #196 from ep1cman/master
file-poller: Improved csv output
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -14,6 +14,19 @@ void term(int signum)
 | 
				
			|||||||
    done = 1;
 | 
					    done = 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// From: http://stackoverflow.com/questions/1515195/how-to-remove-n-or-t-from-a-given-string-in-c
 | 
				
			||||||
 | 
					void strip(char *s) {
 | 
				
			||||||
 | 
					    char *stripped_s = s;
 | 
				
			||||||
 | 
					    while(*s != '\0') {
 | 
				
			||||||
 | 
					        if(*s != ',' && *s != '\n') {
 | 
				
			||||||
 | 
					            *stripped_s++ = *s++;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            ++s;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    *stripped_s = '\0';
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char ** argv) {
 | 
					int main(int argc, char ** argv) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    extern char *optarg;
 | 
					    extern char *optarg;
 | 
				
			||||||
@@ -111,13 +124,9 @@ int main(int argc, char ** argv) {
 | 
				
			|||||||
        for (i = 0; i < (argc - optind); i++) {
 | 
					        for (i = 0; i < (argc - optind); i++) {
 | 
				
			||||||
            read(files_to_poll[i], buf, 1024);
 | 
					            read(files_to_poll[i], buf, 1024);
 | 
				
			||||||
            lseek(files_to_poll[i], 0, SEEK_SET);
 | 
					            lseek(files_to_poll[i], 0, SEEK_SET);
 | 
				
			||||||
 | 
					            strip(buf);
 | 
				
			||||||
            //Removes trailing "\n"
 | 
					 | 
				
			||||||
            int new_line = strlen(buf) -1;
 | 
					 | 
				
			||||||
            if (buf[new_line] == '\n')
 | 
					 | 
				
			||||||
                buf[new_line] = '\0';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            printf(",%s", buf);
 | 
					            printf(",%s", buf);
 | 
				
			||||||
 | 
					            buf[0] = '\0'; // "Empty" buffer
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        printf("\n");
 | 
					        printf("\n");
 | 
				
			||||||
        usleep(interval);
 | 
					        usleep(interval);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user