--- misc/record/record-main.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/misc/record/record-main.c b/misc/record/record-main.c index eccf291..9e9eaa3 100644 --- a/misc/record/record-main.c +++ b/misc/record/record-main.c @@ -83,6 +83,7 @@ typedef struct client_context { uint64_t counter; SLIST_HEAD( , client_item ) free_items; RB_HEAD( active, client_item ) active_items; + FILE *event_stream; } client_context; static inline int item_cmp( const void *pa, const void *pb ) @@ -142,7 +143,7 @@ static int connect_client( const char *host, uint16_t port ) static void print_item( FILE *f, const client_item *item ) { - ctf_event *ctf_item; + ctf_event ctf_item; uint32_t ns; if ( item->ns != 0 ) { @@ -165,21 +166,13 @@ static void print_item( FILE *f, const client_item *item ) item->data ); - FILE *fptr = fopen("event", "a"); + ctf_item.cpu=item->cpu; + ctf_item.event=item->event; + ctf_item.data=item->data; + ctf_item.ns=ns; - if (fptr == NULL) - { - printf("Could not open file"); - return 0; - } - - ctf_item->cpu=item->cpu; - ctf_item->event=item->event; - ctf_item->data=item->data; - ctf_item->ns=ns; + fwrite( &ctf_item, sizeof( ctf_item ), 1, f ); - fprintf(fptr,ctf_item); - fclose(fptr); } static void flush_items( client_context *cctx ) @@ -215,7 +208,9 @@ static void flush_items( client_context *cctx ) RB_REMOVE( active, &cctx->active_items, x ); SLIST_INSERT_HEAD( &cctx->free_items, x, free_node ); - print_item( stdout, x ); + + print_item( cctx->event_stream, x); + } } @@ -337,6 +332,9 @@ int main( int argc, char **argv ) SLIST_INIT( &cctx.free_items ); RB_INIT( &cctx.active_items ); + FILE *event_stream=fopen("event","wb"); + cctx.event_stream=event_stream; + items = calloc( n, sizeof( *items ) ); assert( items != NULL ); @@ -358,7 +356,7 @@ int main( int argc, char **argv ) break; } } - + fclose(event_stream); rv = close( fd ); assert( rv == 0 ); -- 2.7.4 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel