~ubuntu-branches/ubuntu/saucy/rrdtool/saucy-proposed

« back to all changes in this revision

Viewing changes to src/rrd_xport.c

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2010-07-22 08:07:01 UTC
  • mfrom: (1.2.8 upstream) (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100722080701-k46mgdfz6euxwqsm
Tags: 1.4.3-1ubuntu1
* Merge from debian unstable, Remaining changes:
  - debian/control: Don't build against ruby1.9 as we don't want
    it in main.
* require libdbi >= 0.8.3 to prevent aborts when using dbi datasources

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/****************************************************************************
2
 
 * RRDtool 1.3.8  Copyright by Tobi Oetiker, 1997-2009
 
2
 * RRDtool 1.4.3  Copyright by Tobi Oetiker, 1997-2010
3
3
 ****************************************************************************
4
4
 * rrd_xport.c  export RRD data 
5
5
 ****************************************************************************/
10
10
#include "rrd_graph.h"
11
11
#include "rrd_xport.h"
12
12
#include "unused.h"
 
13
#include "rrd_client.h"
13
14
 
14
15
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
15
16
#include <io.h>
53
54
    char ***legend_v,   /* legend entries */
54
55
    rrd_value_t **data)
55
56
{                       /* two dimensional array containing the data */
56
 
 
57
57
    image_desc_t im;
58
58
    time_t    start_tmp = 0, end_tmp = 0;
59
59
    rrd_time_value_t start_tv, end_tv;
60
60
    char     *parsetime_error = NULL;
 
61
    char     *opt_daemon = NULL;
 
62
 
61
63
    struct option long_options[] = {
62
64
        {"start", required_argument, 0, 's'},
63
65
        {"end", required_argument, 0, 'e'},
64
66
        {"maxrows", required_argument, 0, 'm'},
65
67
        {"step", required_argument, 0, 261},
66
68
        {"enumds", no_argument, 0, 262},    /* these are handled in the frontend ... */
 
69
        {"daemon", required_argument, 0, 'd'},
67
70
        {0, 0, 0, 0}
68
71
    };
69
72
 
79
82
        int       option_index = 0;
80
83
        int       opt;
81
84
 
82
 
        opt = getopt_long(argc, argv, "s:e:m:", long_options, &option_index);
 
85
        opt = getopt_long(argc, argv, "s:e:m:d:", long_options, &option_index);
83
86
 
84
87
        if (opt == EOF)
85
88
            break;
109
112
                return -1;
110
113
            }
111
114
            break;
 
115
        case 'd':
 
116
        {
 
117
            if (opt_daemon != NULL)
 
118
            {
 
119
                rrd_set_error ("You cannot specify --daemon "
 
120
                        "more than once.");
 
121
                return (-1);
 
122
            }
 
123
 
 
124
            opt_daemon = strdup(optarg);
 
125
            if (opt_daemon == NULL)
 
126
            {
 
127
                rrd_set_error("strdup error");
 
128
                return -1;
 
129
            }
 
130
            break;
 
131
        }
 
132
 
112
133
        case '?':
113
134
            rrd_set_error("unknown option '%s'", argv[optind - 1]);
114
135
            return -1;
147
168
        return (-1);
148
169
    }
149
170
 
 
171
    {   /* try to connect to rrdcached */
 
172
        int status = rrdc_connect(opt_daemon);
 
173
        if (opt_daemon) free(opt_daemon);
 
174
        if (status != 0) return status;
 
175
    }
 
176
 
150
177
    if (rrd_xport_fn(&im, start, end, step, col_cnt, legend_v, data) == -1) {
151
178
        im_free(&im);
152
179
        return -1;
228
255
            ref_list[xport_counter++] = i;
229
256
            *step_list_ptr = im->gdes[im->gdes[i].vidx].step;
230
257
            /* printf("%s:%lu\n",im->gdes[i].legend,*step_list_ptr); */
231
 
            *step_list_ptr++;
 
258
            step_list_ptr++;
232
259
            /* reserve room for one legend entry */
233
260
            /* is FMT_LEG_LEN + 5 the correct size? */
234
261
            if ((legend_list[j] =
259
286
    free(step_list);
260
287
    
261
288
    *start =  im->start - im->start % (*step);
262
 
    *end = im->end - im->end % (*step);
 
289
    *end = im->end - im->end % (*step) + (*step);
263
290
    
264
291
 
265
292
    /* room for rearranged data */