source: tools/tracertstats/output.c @ bf7018a

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since bf7018a was bf7018a, checked in by Daniel Lawson <dlawson@…>, 16 years ago

improved detection for libgdc

  • Property mode set to 100644
File size: 1.6 KB
Line 
1#include <inttypes.h>
2#include <stdio.h>
3#include <assert.h>
4#include <stdlib.h>
5#include <string.h>
6
7#include "output.h"
8#include "config.h"
9
10struct output_type_t *output_formats[] = {
11        &output_csv,
12        &output_html,
13#if HAVE_GDC_H
14        &output_png,
15#endif
16        NULL
17};
18
19struct output_data_t *output_init(char *title,char *type)
20{
21        output_data_t *data = malloc(sizeof(output_data_t));
22        int i=0;
23        data->title=strdup(title);
24        data->labels=NULL;
25        data->columns=0;
26        data->data=NULL;
27        while(output_formats[i]) {
28                if (strcmp(output_formats[i]->name,type)==0) {
29                        data->format = output_formats[i];
30                        return data;
31                }
32                ++i;
33        }
34        /* Not found */
35        free(data);
36        return NULL;
37}
38
39void output_add_column(struct output_data_t *out,char *col)
40{
41        ++out->columns;
42        out->labels=realloc(out->labels,out->columns*sizeof(char *));
43        out->labels[out->columns-1]=strdup(col);
44        out->data=realloc(out->data,out->columns*sizeof(struct data_t));
45}
46
47void output_flush_headings(struct output_data_t *out)
48{
49        out->format->init(out);
50}
51
52#define output_set_data(type_) \
53        void output_set_data_ ## type_(struct output_data_t *out,       \
54                        int col,TYPE__ ## type_ data)\
55        {       \
56                assert(col>=0 && col<out->columns); \
57                out->data[col].type=TYPE_ ## type_; \
58                out->data[col].d_ ## type_ = data; \
59        }
60
61output_set_data(str)
62output_set_data(int)
63output_set_data(float)
64output_set_data(time)
65#undef output_set_data
66
67void output_flush_row(struct output_data_t *out)
68{
69        out->format->flush(out);
70}
71
72void output_destroy(struct output_data_t *out)
73{
74        int i;
75        out->format->destroy(out);
76        for(i=0;i<out->columns;++i) {
77                free(out->labels[i]);
78        }
79        free(out->data);
80        free(out->labels);
81        free(out);
82}
83
Note: See TracBrowser for help on using the repository browser.