1 #include <string.h> 2 #include "misc.h" 3 4 void val(void *p) 5 { 6 if (p) 7 out("OK\n"); 8 else 9 out("failed\n"); 10 } 11 12 void val(status_t status) 13 { 14 if (status == B_OK) 15 out("OK\n"); 16 else 17 out("failed, 0x%08x, %s\n",status,strerror(status)); 18 } 19 20 void val_size(ssize_t size) 21 { 22 if (size >= 0) 23 out("OK\n"); 24 else 25 out("failed, size %" B_PRIdSSIZE ", error %s\n", size, strerror(size)); 26 } 27 28 void wait() 29 { 30 out("press enter to continue\n"); 31 getchar(); 32 } 33 34 void out(const char *format,...) 35 { 36 static bigtime_t start = 0; 37 if (start == 0) 38 start = system_time(); 39 printf("%3.4f ",(system_time()-start) / 1E6); 40 va_list ap; 41 va_start(ap,format); 42 vfprintf(stdout,format,ap); 43 va_end(ap); 44 fflush(0); 45 } 46