4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since f20d66c was
530bcf0,
checked in by Perry Lorier <perry@…>, 14 years ago
|
Fix autoconf building of the gdc graph output for tracertstats
|
-
Property mode set to
100644
|
File size:
1.6 KB
|
Rev | Line | |
---|
[65cdb7f] | 1 | #include <inttypes.h> |
---|
[e3b0188] | 2 | #include <lt_inttypes.h> |
---|
[65cdb7f] | 3 | #include <stdio.h> |
---|
| 4 | #include <assert.h> |
---|
| 5 | #include <stdlib.h> |
---|
| 6 | #include <string.h> |
---|
| 7 | |
---|
| 8 | #include "output.h" |
---|
[bf7018a] | 9 | #include "config.h" |
---|
[65cdb7f] | 10 | |
---|
| 11 | struct output_type_t *output_formats[] = { |
---|
[9c13ab0] | 12 | &output_txt, |
---|
[65cdb7f] | 13 | &output_csv, |
---|
| 14 | &output_html, |
---|
[530bcf0] | 15 | #ifdef HAVE_LIBGDC |
---|
[65cdb7f] | 16 | &output_png, |
---|
[bf7018a] | 17 | #endif |
---|
[65cdb7f] | 18 | NULL |
---|
| 19 | }; |
---|
| 20 | |
---|
| 21 | struct output_data_t *output_init(char *title,char *type) |
---|
| 22 | { |
---|
| 23 | output_data_t *data = malloc(sizeof(output_data_t)); |
---|
| 24 | int i=0; |
---|
| 25 | data->title=strdup(title); |
---|
| 26 | data->labels=NULL; |
---|
| 27 | data->columns=0; |
---|
| 28 | data->data=NULL; |
---|
| 29 | while(output_formats[i]) { |
---|
| 30 | if (strcmp(output_formats[i]->name,type)==0) { |
---|
| 31 | data->format = output_formats[i]; |
---|
| 32 | return data; |
---|
| 33 | } |
---|
| 34 | ++i; |
---|
| 35 | } |
---|
| 36 | /* Not found */ |
---|
| 37 | free(data); |
---|
| 38 | return NULL; |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | void output_add_column(struct output_data_t *out,char *col) |
---|
| 42 | { |
---|
| 43 | ++out->columns; |
---|
| 44 | out->labels=realloc(out->labels,out->columns*sizeof(char *)); |
---|
| 45 | out->labels[out->columns-1]=strdup(col); |
---|
| 46 | out->data=realloc(out->data,out->columns*sizeof(struct data_t)); |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | void output_flush_headings(struct output_data_t *out) |
---|
| 50 | { |
---|
| 51 | out->format->init(out); |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | #define output_set_data(type_) \ |
---|
| 55 | void output_set_data_ ## type_(struct output_data_t *out, \ |
---|
| 56 | int col,TYPE__ ## type_ data)\ |
---|
| 57 | { \ |
---|
| 58 | assert(col>=0 && col<out->columns); \ |
---|
| 59 | out->data[col].type=TYPE_ ## type_; \ |
---|
[e3b0188] | 60 | out->data[col].d.d_ ## type_ = data; \ |
---|
[65cdb7f] | 61 | } |
---|
| 62 | |
---|
| 63 | output_set_data(str) |
---|
| 64 | output_set_data(int) |
---|
| 65 | output_set_data(float) |
---|
| 66 | output_set_data(time) |
---|
| 67 | #undef output_set_data |
---|
| 68 | |
---|
| 69 | void output_flush_row(struct output_data_t *out) |
---|
| 70 | { |
---|
| 71 | out->format->flush(out); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | void output_destroy(struct output_data_t *out) |
---|
| 75 | { |
---|
| 76 | int i; |
---|
| 77 | out->format->destroy(out); |
---|
| 78 | for(i=0;i<out->columns;++i) { |
---|
| 79 | free(out->labels[i]); |
---|
| 80 | } |
---|
| 81 | free(out->data); |
---|
| 82 | free(out->labels); |
---|
| 83 | free(out); |
---|
| 84 | } |
---|
| 85 | |
---|
Note: See
TracBrowser
for help on using the repository browser.