source: tools/tracertstats/output.c @ 1326d5f

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 1326d5f was 530bcf0, checked in by Perry Lorier <perry@…>, 13 years ago

Fix autoconf building of the gdc graph output for tracertstats

  • Property mode set to 100644
File size: 1.6 KB
Line 
1#include <inttypes.h>
2#include <lt_inttypes.h>
3#include <stdio.h>
4#include <assert.h>
5#include <stdlib.h>
6#include <string.h>
7
8#include "output.h"
9#include "config.h"
10
11struct output_type_t *output_formats[] = {
12        &output_txt,
13        &output_csv,
14        &output_html,
15#ifdef HAVE_LIBGDC
16        &output_png,
17#endif
18        NULL
19};
20
21struct 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
41void 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
49void 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_; \
60                out->data[col].d.d_ ## type_ = data; \
61        }
62
63output_set_data(str)
64output_set_data(int)
65output_set_data(float)
66output_set_data(time)
67#undef output_set_data
68
69void output_flush_row(struct output_data_t *out)
70{
71        out->format->flush(out);
72}
73
74void 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.