From: oetiker Date: Thu, 24 May 2007 06:16:01 +0000 (+0000) Subject: indent all the rest of the code, and add some typedefs to indent.pro X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f706c73d5c78d6758f255afcc30da144198a6a02;p=rrdtool-all.git indent all the rest of the code, and add some typedefs to indent.pro there is now a indent makefile target git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1081 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/.indent.pro b/program/.indent.pro new file mode 100644 index 00000000..262c7e0d --- /dev/null +++ b/program/.indent.pro @@ -0,0 +1,95 @@ +--blank-lines-after-declarations +--blank-lines-after-procedures +--break-before-boolean-operator +--break-function-decl-args +--no-blank-lines-after-commas +--braces-on-if-line +--braces-on-struct-decl-line +--comment-indentation25 +--declaration-comment-column25 +--no-comment-delimiters-on-blank-lines +--cuddle-else +--continuation-indentation4 +--case-indentation0 +--else-endif-column33 +--space-after-cast +--line-comments-indentation0 +--declaration-indentation10 +--dont-format-first-column-comments +--dont-format-comments +--honour-newlines +--indent-level4 +/* changed from 0 to 4 */ +--parameter-indentation4 +--line-length78 /* changed from 75 */ +--continue-at-parentheses +--no-space-after-function-call-names +--dont-break-procedure-type +--dont-star-comments +--leave-optional-blank-lines +--dont-space-special-semicolon +--tab-size4 +/* additions by Mark */ +--case-brace-indentation0 +--leave-preprocessor-space +--no-tabs +-Trrd_t +-Tinfo_t +-Ttime_t +-Toff_t +-TTcl_Interp +-Ttm +-Tstring_arr_t +-T_ArtRgbaSVPAlphaData +-TFIFOqueue +-Tgfx_color_t +-Tgfx_node_t +-Tgfx_canvas_t +-Tvar_s +-Tcgi_s +-Tinfoval +-Tinfo_t +-TFnv32_t +-Trpnp_t +-Trpn_cdefds_t +-Trpnstack_t +-Tunival +-Tstat_head_t +-Tds_def_t +-Trra_def_t +-Tlive_head_t +-Tpdp_prep_t +-Tcdp_prep_t +-Trra_ptr_t +-Trrd_t +-Ttext_prop_t +-Tvdef_t +-Txlab_t +-Tygrid_scale_t +-Tylab_t +-Tgraph_desc_t +-Timage_desc_t +-Tafm_uint8 +-Tafm_sint8 +-Tafm_uint16 +-Tafm_sint16 +-Tafm_unicode +-Tafm_uint8 +-Tafm_sint8 +-Tafm_uint16 +-Tafm_sint16 +-Tafm_unicode +-Tafm_fontinfo +-Told_afm_fontinfo +-Tgfx_char_s +-Tgfx_string_s +-Tpdf_point +-Tsvg_dash +-Teps_font +-Teps_state +-Tpdf_buffer +-Tpdf_font +-Tpdf_state +-Trrd_value_t +-Trrd_file_t +-Tva_list diff --git a/program/Makefile.am b/program/Makefile.am index 4bbab3e1..4689aac0 100644 --- a/program/Makefile.am +++ b/program/Makefile.am @@ -47,4 +47,8 @@ site-tcl-install: all site-python-install: all cd bindings/python && $(PYTHON) setup.py install +# find . -name "*.c" -or -name "*.h" | xargs perl -0777 -n -e 'while (s/typedef\s+(?:unsigned\s+|signed\s+|unival\s+)?\S+\s+\*?([^{}\s;(]+)//){print "-T$1\n"}' +indent: + find . -name "*.c" -or -name "*.h" | xargs indent + ##END## diff --git a/program/bindings/python/rrd_extra.h b/program/bindings/python/rrd_extra.h index 99b5aa07..63c604d6 100644 --- a/program/bindings/python/rrd_extra.h +++ b/program/bindings/python/rrd_extra.h @@ -28,7 +28,7 @@ * *****************************************************************************/ #ifdef __cplusplus -extern "C" { +extern "C" { #endif #ifndef _RRD_EXTRA_H @@ -37,19 +37,29 @@ extern "C" { #include "rrd_format.h" #ifndef WIN32 -#ifndef isnan /* POSIX */ -int isnan(double value); +#ifndef isnan /* POSIX */ + int isnan( + double value); #endif -#else /* Windows only */ +#else /* Windows only */ #include #define isnan _isnan #endif -void rrd_free(rrd_t *rrd); -void rrd_init(rrd_t *rrd); + void rrd_free( + rrd_t *rrd); + void rrd_init( + rrd_t *rrd); -int rrd_open(char *file_name, FILE **in_file, rrd_t *rrd, int rdwr); -int readfile(char *file, char **buffer, int skipfirst); + int rrd_open( + char *file_name, + FILE ** in_file, + rrd_t *rrd, + int rdwr); + int readfile( + char *file, + char **buffer, + int skipfirst); #define RRD_READONLY 0 #define RRD_READWRITE 1 diff --git a/program/bindings/python/rrdtoolmodule.c b/program/bindings/python/rrdtoolmodule.c index 6f5b36c5..74b7fb09 100644 --- a/program/bindings/python/rrdtoolmodule.c +++ b/program/bindings/python/rrdtoolmodule.c @@ -48,16 +48,22 @@ extern int optind; extern int opterr; /* forward declaration to keep compiler happy */ -void initrrdtool(void); - -static int -create_args(char *command, PyObject *args, int *argc, char ***argv) +void initrrdtool( + void); + +static int create_args( + char *command, + PyObject * args, + int *argc, + char ***argv) { - PyObject *o; - int size, i; - - size = PyTuple_Size(args); - *argv = PyMem_New(char *, size + 1); + PyObject *o; + int size, i; + + size = PyTuple_Size(args); + *argv = PyMem_New(char *, + size + 1); + if (*argv == NULL) return -1; @@ -80,25 +86,26 @@ create_args(char *command, PyObject *args, int *argc, char ***argv) return 0; } -static void -destroy_args(char ***argv) +static void destroy_args( + char ***argv) { PyMem_Del(*argv); *argv = NULL; } static char PyRRD_create__doc__[] = -"create(args..): Set up a new Round Robin Database\n\ + "create(args..): Set up a new Round Robin Database\n\ create filename [--start|-b start time] \ [--step|-s step] [DS:ds-name:DST:heartbeat:min:max] \ [RRA:CF:xff:steps:rows]"; -static PyObject * -PyRRD_create(PyObject UNUSED(*self), PyObject *args) +static PyObject *PyRRD_create( + PyObject UNUSED(*self), + PyObject * args) { - PyObject *r; - char **argv; - int argc; + PyObject *r; + char **argv; + int argc; if (create_args("create", args, &argc, &argv) < 0) return NULL; @@ -117,16 +124,17 @@ PyRRD_create(PyObject UNUSED(*self), PyObject *args) } static char PyRRD_update__doc__[] = -"update(args..): Store a new set of values into the rrd\n" -" update filename [--template|-t ds-name[:ds-name]...] " -"N|timestamp:value[:value...] [timestamp:value[:value...] ...]"; + "update(args..): Store a new set of values into the rrd\n" + " update filename [--template|-t ds-name[:ds-name]...] " + "N|timestamp:value[:value...] [timestamp:value[:value...] ...]"; -static PyObject * -PyRRD_update(PyObject UNUSED(*self), PyObject *args) +static PyObject *PyRRD_update( + PyObject UNUSED(*self), + PyObject * args) { - PyObject *r; - char **argv; - int argc; + PyObject *r; + char **argv; + int argc; if (create_args("update", args, &argc, &argv) < 0) return NULL; @@ -145,19 +153,20 @@ PyRRD_update(PyObject UNUSED(*self), PyObject *args) } static char PyRRD_fetch__doc__[] = -"fetch(args..): fetch data from an rrd.\n" -" fetch filename CF [--resolution|-r resolution] " -"[--start|-s start] [--end|-e end]"; + "fetch(args..): fetch data from an rrd.\n" + " fetch filename CF [--resolution|-r resolution] " + "[--start|-s start] [--end|-e end]"; -static PyObject * -PyRRD_fetch(PyObject UNUSED(*self), PyObject *args) +static PyObject *PyRRD_fetch( + PyObject UNUSED(*self), + PyObject * args) { - PyObject *r; - rrd_value_t *data, *datai; - unsigned long step, ds_cnt; - time_t start, end; - int argc; - char **argv, **ds_namv; + PyObject *r; + rrd_value_t *data, *datai; + unsigned long step, ds_cnt; + time_t start, end; + int argc; + char **argv, **ds_namv; if (create_args("fetch", args, &argc, &argv) < 0) return NULL; @@ -169,10 +178,10 @@ PyRRD_fetch(PyObject UNUSED(*self), PyObject *args) r = NULL; } else { /* Return : - ((start, end, step), (name1, name2, ...), [(data1, data2, ..), ...]) */ - PyObject *range_tup, *dsnam_tup, *data_list, *t; - unsigned long i, j, row; - rrd_value_t dv; + ((start, end, step), (name1, name2, ...), [(data1, data2, ..), ...]) */ + PyObject *range_tup, *dsnam_tup, *data_list, *t; + unsigned long i, j, row; + rrd_value_t dv; row = ((end - start) / step + 1); @@ -186,14 +195,14 @@ PyRRD_fetch(PyObject UNUSED(*self), PyObject *args) datai = data; - PyTuple_SET_ITEM(range_tup, 0, PyInt_FromLong((long)start)); - PyTuple_SET_ITEM(range_tup, 1, PyInt_FromLong((long)end)); - PyTuple_SET_ITEM(range_tup, 2, PyInt_FromLong((long)step)); + PyTuple_SET_ITEM(range_tup, 0, PyInt_FromLong((long) start)); + PyTuple_SET_ITEM(range_tup, 1, PyInt_FromLong((long) end)); + PyTuple_SET_ITEM(range_tup, 2, PyInt_FromLong((long) step)); for (i = 0; i < ds_cnt; i++) PyTuple_SET_ITEM(dsnam_tup, i, PyString_FromString(ds_namv[i])); - for (i = 0; i < row; i ++) { + for (i = 0; i < row; i++) { t = PyTuple_New(ds_cnt); PyList_SET_ITEM(data_list, i, t); @@ -203,14 +212,14 @@ PyRRD_fetch(PyObject UNUSED(*self), PyObject *args) PyTuple_SET_ITEM(t, j, Py_None); Py_INCREF(Py_None); } else { - PyTuple_SET_ITEM(t, j, PyFloat_FromDouble((double)dv)); + PyTuple_SET_ITEM(t, j, PyFloat_FromDouble((double) dv)); } } } for (i = 0; i < ds_cnt; i++) free(ds_namv[i]); - free(ds_namv); /* rrdtool don't use PyMem_Malloc :) */ + free(ds_namv); /* rrdtool don't use PyMem_Malloc :) */ free(data); } @@ -219,54 +228,56 @@ PyRRD_fetch(PyObject UNUSED(*self), PyObject *args) } static char PyRRD_graph__doc__[] = -"graph(args..): Create a graph based on data from one or several RRD\n" -" graph filename [-s|--start seconds] " -"[-e|--end seconds] [-x|--x-grid x-axis grid and label] " -"[-y|--y-grid y-axis grid and label] [--alt-y-grid] [--alt-y-mrtg] " -"[--alt-autoscale] [--alt-autoscale-max] [--units-exponent] value " -"[-v|--vertical-label text] [-w|--width pixels] [-h|--height pixels] " -"[-i|--interlaced] " -"[-f|--imginfo formatstring] [-a|--imgformat GIF|PNG|GD] " -"[-B|--background value] [-O|--overlay value] " -"[-U|--unit value] [-z|--lazy] [-o|--logarithmic] " -"[-u|--upper-limit value] [-l|--lower-limit value] " -"[-g|--no-legend] [-r|--rigid] [--step value] " -"[-b|--base value] [-c|--color COLORTAG#rrggbb] " -"[-t|--title title] [DEF:vname=rrd:ds-name:CF] " -"[CDEF:vname=rpn-expression] [PRINT:vname:CF:format] " -"[GPRINT:vname:CF:format] [COMMENT:text] " -"[HRULE:value#rrggbb[:legend]] [VRULE:time#rrggbb[:legend]] " -"[LINE{1|2|3}:vname[#rrggbb[:legend]]] " -"[AREA:vname[#rrggbb[:legend]]] " -"[STACK:vname[#rrggbb[:legend]]]"; - -static PyObject * -PyRRD_graph(PyObject UNUSED(*self), PyObject *args) + "graph(args..): Create a graph based on data from one or several RRD\n" + " graph filename [-s|--start seconds] " + "[-e|--end seconds] [-x|--x-grid x-axis grid and label] " + "[-y|--y-grid y-axis grid and label] [--alt-y-grid] [--alt-y-mrtg] " + "[--alt-autoscale] [--alt-autoscale-max] [--units-exponent] value " + "[-v|--vertical-label text] [-w|--width pixels] [-h|--height pixels] " + "[-i|--interlaced] " + "[-f|--imginfo formatstring] [-a|--imgformat GIF|PNG|GD] " + "[-B|--background value] [-O|--overlay value] " + "[-U|--unit value] [-z|--lazy] [-o|--logarithmic] " + "[-u|--upper-limit value] [-l|--lower-limit value] " + "[-g|--no-legend] [-r|--rigid] [--step value] " + "[-b|--base value] [-c|--color COLORTAG#rrggbb] " + "[-t|--title title] [DEF:vname=rrd:ds-name:CF] " + "[CDEF:vname=rpn-expression] [PRINT:vname:CF:format] " + "[GPRINT:vname:CF:format] [COMMENT:text] " + "[HRULE:value#rrggbb[:legend]] [VRULE:time#rrggbb[:legend]] " + "[LINE{1|2|3}:vname[#rrggbb[:legend]]] " + "[AREA:vname[#rrggbb[:legend]]] " "[STACK:vname[#rrggbb[:legend]]]"; + +static PyObject *PyRRD_graph( + PyObject UNUSED(*self), + PyObject * args) { - PyObject *r; - char **argv, **calcpr; - int argc, xsize, ysize, i; - double ymin, ymax; + PyObject *r; + char **argv, **calcpr; + int argc, xsize, ysize, i; + double ymin, ymax; + if (create_args("graph", args, &argc, &argv) < 0) return NULL; - if (rrd_graph(argc, argv, &calcpr, &xsize, &ysize, NULL, &ymin, &ymax) == -1) { + if (rrd_graph(argc, argv, &calcpr, &xsize, &ysize, NULL, &ymin, &ymax) == + -1) { PyErr_SetString(ErrorObject, rrd_get_error()); rrd_clear_error(); r = NULL; } else { r = PyTuple_New(3); - PyTuple_SET_ITEM(r, 0, PyInt_FromLong((long)xsize)); - PyTuple_SET_ITEM(r, 1, PyInt_FromLong((long)ysize)); + PyTuple_SET_ITEM(r, 0, PyInt_FromLong((long) xsize)); + PyTuple_SET_ITEM(r, 1, PyInt_FromLong((long) ysize)); if (calcpr) { - PyObject *e, *t; - + PyObject *e, *t; + e = PyList_New(0); PyTuple_SET_ITEM(r, 2, e); - for(i = 0; calcpr[i]; i++) { + for (i = 0; calcpr[i]; i++) { t = PyString_FromString(calcpr[i]); PyList_Append(e, t); Py_DECREF(t); @@ -284,17 +295,18 @@ PyRRD_graph(PyObject UNUSED(*self), PyObject *args) } static char PyRRD_tune__doc__[] = -"tune(args...): Modify some basic properties of a Round Robin Database\n" -" tune filename [--heartbeat|-h ds-name:heartbeat] " -"[--minimum|-i ds-name:min] [--maximum|-a ds-name:max] " -"[--data-source-type|-d ds-name:DST] [--data-source-rename|-r old-name:new-name]"; - -static PyObject * -PyRRD_tune(PyObject UNUSED(*self), PyObject *args) + "tune(args...): Modify some basic properties of a Round Robin Database\n" + " tune filename [--heartbeat|-h ds-name:heartbeat] " + "[--minimum|-i ds-name:min] [--maximum|-a ds-name:max] " + "[--data-source-type|-d ds-name:DST] [--data-source-rename|-r old-name:new-name]"; + +static PyObject *PyRRD_tune( + PyObject UNUSED(*self), + PyObject * args) { - PyObject *r; - char **argv; - int argc; + PyObject *r; + char **argv; + int argc; if (create_args("tune", args, &argc, &argv) < 0) return NULL; @@ -313,14 +325,15 @@ PyRRD_tune(PyObject UNUSED(*self), PyObject *args) } static char PyRRD_first__doc__[] = -"first(filename): Return the timestamp of the first data sample in an RRD"; + "first(filename): Return the timestamp of the first data sample in an RRD"; -static PyObject * -PyRRD_first(PyObject UNUSED(*self), PyObject *args) +static PyObject *PyRRD_first( + PyObject UNUSED(*self), + PyObject * args) { - PyObject *r; - int argc, ts; - char **argv; + PyObject *r; + int argc, ts; + char **argv; if (create_args("first", args, &argc, &argv) < 0) return NULL; @@ -330,21 +343,22 @@ PyRRD_first(PyObject UNUSED(*self), PyObject *args) rrd_clear_error(); r = NULL; } else - r = PyInt_FromLong((long)ts); + r = PyInt_FromLong((long) ts); destroy_args(&argv); return r; } static char PyRRD_last__doc__[] = -"last(filename): Return the timestamp of the last data sample in an RRD"; + "last(filename): Return the timestamp of the last data sample in an RRD"; -static PyObject * -PyRRD_last(PyObject UNUSED(*self), PyObject *args) +static PyObject *PyRRD_last( + PyObject UNUSED(*self), + PyObject * args) { - PyObject *r; - int argc, ts; - char **argv; + PyObject *r; + int argc, ts; + char **argv; if (create_args("last", args, &argc, &argv) < 0) return NULL; @@ -354,22 +368,23 @@ PyRRD_last(PyObject UNUSED(*self), PyObject *args) rrd_clear_error(); r = NULL; } else - r = PyInt_FromLong((long)ts); + r = PyInt_FromLong((long) ts); destroy_args(&argv); return r; } static char PyRRD_resize__doc__[] = -"resize(args...): alters the size of an RRA.\n" -" resize filename rra-num GROW|SHRINK rows"; + "resize(args...): alters the size of an RRA.\n" + " resize filename rra-num GROW|SHRINK rows"; -static PyObject * -PyRRD_resize(PyObject UNUSED(*self), PyObject *args) +static PyObject *PyRRD_resize( + PyObject UNUSED(*self), + PyObject * args) { - PyObject *r; - char **argv; - int argc, ts; + PyObject *r; + char **argv; + int argc, ts; if (create_args("resize", args, &argc, &argv) < 0) return NULL; @@ -388,18 +403,19 @@ PyRRD_resize(PyObject UNUSED(*self), PyObject *args) } static char PyRRD_info__doc__[] = -"info(filename): extract header information from an rrd"; + "info(filename): extract header information from an rrd"; -static PyObject * -PyRRD_info(PyObject UNUSED(*self), PyObject *args) +static PyObject *PyRRD_info( + PyObject UNUSED(*self), + PyObject * args) { - PyObject *r, *t, *ds; - rrd_t rrd; - FILE *in_file; - char *filename; - unsigned long i, j; + PyObject *r, *t, *ds; + rrd_t rrd; + FILE *in_file; + char *filename; + unsigned long i, j; - if (! PyArg_ParseTuple(args, "s:info", &filename)) + if (!PyArg_ParseTuple(args, "s:info", &filename)) return NULL; if (rrd_open(filename, &in_file, &rrd, RRD_READONLY) == -1) { @@ -437,7 +453,7 @@ PyRRD_info(PyObject UNUSED(*self), PyObject *args) Py_DECREF(ds); for (i = 0; i < rrd.stat_head->ds_cnt; i++) { - PyObject *d; + PyObject *d; d = PyDict_New(); PyDict_SetItemString(ds, rrd.ds_def[i].ds_nam, d); @@ -445,12 +461,14 @@ PyRRD_info(PyObject UNUSED(*self), PyObject *args) DICTSET_STR(d, "ds_name", rrd.ds_def[i].ds_nam); DICTSET_STR(d, "type", rrd.ds_def[i].dst); - DICTSET_CNT(d, "minimal_heartbeat", rrd.ds_def[i].par[DS_mrhb_cnt].u_cnt); + DICTSET_CNT(d, "minimal_heartbeat", + rrd.ds_def[i].par[DS_mrhb_cnt].u_cnt); DICTSET_VAL(d, "min", rrd.ds_def[i].par[DS_min_val].u_val); DICTSET_VAL(d, "max", rrd.ds_def[i].par[DS_max_val].u_val); DICTSET_STR(d, "last_ds", rrd.pdp_prep[i].last_ds); DICTSET_VAL(d, "value", rrd.pdp_prep[i].scratch[PDP_val].u_val); - DICTSET_CNT(d, "unknown_sec", rrd.pdp_prep[i].scratch[PDP_unkn_sec_cnt].u_cnt); + DICTSET_CNT(d, "unknown_sec", + rrd.pdp_prep[i].scratch[PDP_unkn_sec_cnt].u_cnt); } ds = PyList_New(rrd.stat_head->rra_cnt); @@ -458,7 +476,7 @@ PyRRD_info(PyObject UNUSED(*self), PyObject *args) Py_DECREF(ds); for (i = 0; i < rrd.stat_head->rra_cnt; i++) { - PyObject *d, *cdp; + PyObject *d, *cdp; d = PyDict_New(); PyList_SET_ITEM(ds, i, d); @@ -473,15 +491,17 @@ PyRRD_info(PyObject UNUSED(*self), PyObject *args) Py_DECREF(cdp); for (j = 0; j < rrd.stat_head->ds_cnt; j++) { - PyObject *cdd; + PyObject *cdd; cdd = PyDict_New(); PyList_SET_ITEM(cdp, j, cdd); DICTSET_VAL(cdd, "value", - rrd.cdp_prep[i*rrd.stat_head->ds_cnt+j].scratch[CDP_val].u_val); + rrd.cdp_prep[i * rrd.stat_head->ds_cnt + + j].scratch[CDP_val].u_val); DICTSET_CNT(cdd, "unknown_datapoints", - rrd.cdp_prep[i*rrd.stat_head->ds_cnt+j].scratch[CDP_unkn_pdp_cnt].u_cnt); + rrd.cdp_prep[i * rrd.stat_head->ds_cnt + + j].scratch[CDP_unkn_pdp_cnt].u_cnt); } } @@ -494,16 +514,16 @@ PyRRD_info(PyObject UNUSED(*self), PyObject *args) #define meth(name, func, doc) {name, (PyCFunction)func, METH_VARARGS, doc} static PyMethodDef _rrdtool_methods[] = { - meth("create", PyRRD_create, PyRRD_create__doc__), - meth("update", PyRRD_update, PyRRD_update__doc__), - meth("fetch", PyRRD_fetch, PyRRD_fetch__doc__), - meth("graph", PyRRD_graph, PyRRD_graph__doc__), - meth("tune", PyRRD_tune, PyRRD_tune__doc__), - meth("first", PyRRD_first, PyRRD_first__doc__), - meth("last", PyRRD_last, PyRRD_last__doc__), - meth("resize", PyRRD_resize, PyRRD_resize__doc__), - meth("info", PyRRD_info, PyRRD_info__doc__), - {NULL, NULL,0,NULL} + meth("create", PyRRD_create, PyRRD_create__doc__), + meth("update", PyRRD_update, PyRRD_update__doc__), + meth("fetch", PyRRD_fetch, PyRRD_fetch__doc__), + meth("graph", PyRRD_graph, PyRRD_graph__doc__), + meth("tune", PyRRD_tune, PyRRD_tune__doc__), + meth("first", PyRRD_first, PyRRD_first__doc__), + meth("last", PyRRD_last, PyRRD_last__doc__), + meth("resize", PyRRD_resize, PyRRD_resize__doc__), + meth("info", PyRRD_info, PyRRD_info__doc__), + {NULL, NULL, 0, NULL} }; #define SET_INTCONSTANT(dict, value) \ @@ -516,10 +536,10 @@ static PyMethodDef _rrdtool_methods[] = { Py_DECREF(t); /* Initialization function for the module */ -void -initrrdtool(void) +void initrrdtool( + void) { - PyObject *m, *d, *t; + PyObject *m, *d, *t; /* Create the module and add the functions */ m = Py_InitModule("rrdtool", _rrdtool_methods); diff --git a/program/bindings/ruby/main.c b/program/bindings/ruby/main.c index b2eaa68e..32bd8cff 100644 --- a/program/bindings/ruby/main.c +++ b/program/bindings/ruby/main.c @@ -7,33 +7,39 @@ #include typedef struct string_arr_t { - int len; - char **strings; + int len; + char **strings; } string_arr; -VALUE mRRD; -VALUE rb_eRRDError; +VALUE mRRD; +VALUE rb_eRRDError; + +typedef int ( + *RRDFUNC) ( + int argc, + char **argv); -typedef int (*RRDFUNC)(int argc, char ** argv); #define RRD_CHECK_ERROR \ if (rrd_test_error()) \ rb_raise(rb_eRRDError, rrd_get_error()); \ rrd_clear_error(); -string_arr string_arr_new(VALUE rb_strings) +string_arr string_arr_new( + VALUE rb_strings) { string_arr a; - char buf[64]; - int i; - + char buf[64]; + int i; + Check_Type(rb_strings, T_ARRAY); a.len = RARRAY(rb_strings)->len + 1; a.strings = malloc(a.len * sizeof(char *)); - a.strings[0] = "dummy"; /* first element is a dummy element */ + a.strings[0] = "dummy"; /* first element is a dummy element */ for (i = 0; i < a.len - 1; i++) { - VALUE v = rb_ary_entry(rb_strings, i); + VALUE v = rb_ary_entry(rb_strings, i); + switch (TYPE(v)) { case T_STRING: a.strings[i + 1] = strdup(STR2CSTR(v)); @@ -51,9 +57,10 @@ string_arr string_arr_new(VALUE rb_strings) return a; } -void string_arr_delete(string_arr a) +void string_arr_delete( + string_arr a) { - int i; + int i; /* skip dummy first entry */ for (i = 1; i < a.len; i++) { @@ -63,14 +70,17 @@ void string_arr_delete(string_arr a) free(a.strings); } -void reset_rrd_state() +void reset_rrd_state( + ) { - optind = 0; + optind = 0; opterr = 0; rrd_clear_error(); } -VALUE rrd_call(RRDFUNC func, VALUE args) +VALUE rrd_call( + RRDFUNC func, + VALUE args) { string_arr a; @@ -79,38 +89,42 @@ VALUE rrd_call(RRDFUNC func, VALUE args) func(a.len, a.strings); string_arr_delete(a); - RRD_CHECK_ERROR - - return Qnil; + RRD_CHECK_ERROR return Qnil; } -VALUE rb_rrd_create(VALUE self, VALUE args) +VALUE rb_rrd_create( + VALUE self, + VALUE args) { return rrd_call(rrd_create, args); } -VALUE rb_rrd_dump(VALUE self, VALUE args) +VALUE rb_rrd_dump( + VALUE self, + VALUE args) { return rrd_call(rrd_dump, args); } -VALUE rb_rrd_fetch(VALUE self, VALUE args) +VALUE rb_rrd_fetch( + VALUE self, + VALUE args) { string_arr a; unsigned long i, j, k, step, ds_cnt; rrd_value_t *raw_data; - char **raw_names; - VALUE data, names, result; - time_t start, end; + char **raw_names; + VALUE data, names, result; + time_t start, end; a = string_arr_new(args); reset_rrd_state(); - rrd_fetch(a.len, a.strings, &start, &end, &step, &ds_cnt, &raw_names, &raw_data); + rrd_fetch(a.len, a.strings, &start, &end, &step, &ds_cnt, &raw_names, + &raw_data); string_arr_delete(a); - RRD_CHECK_ERROR + RRD_CHECK_ERROR names = rb_ary_new(); - names = rb_ary_new(); for (i = 0; i < ds_cnt; i++) { rb_ary_push(names, rb_str_new2(raw_names[i])); free(raw_names[i]); @@ -120,7 +134,8 @@ VALUE rb_rrd_fetch(VALUE self, VALUE args) k = 0; data = rb_ary_new(); for (i = start; i <= end; i += step) { - VALUE line = rb_ary_new2(ds_cnt); + VALUE line = rb_ary_new2(ds_cnt); + for (j = 0; j < ds_cnt; j++) { rb_ary_store(line, j, rb_float_new(raw_data[k])); k++; @@ -128,7 +143,7 @@ VALUE rb_rrd_fetch(VALUE self, VALUE args) rb_ary_push(data, line); } free(raw_data); - + result = rb_ary_new2(4); rb_ary_store(result, 0, INT2FIX(start)); rb_ary_store(result, 1, INT2FIX(end)); @@ -137,22 +152,23 @@ VALUE rb_rrd_fetch(VALUE self, VALUE args) return result; } -VALUE rb_rrd_graph(VALUE self, VALUE args) +VALUE rb_rrd_graph( + VALUE self, + VALUE args) { string_arr a; - char **calcpr, **p; - VALUE result, print_results; - int xsize, ysize; - double ymin, ymax; + char **calcpr, **p; + VALUE result, print_results; + int xsize, ysize; + double ymin, ymax; a = string_arr_new(args); reset_rrd_state(); rrd_graph(a.len, a.strings, &calcpr, &xsize, &ysize, NULL, &ymin, &ymax); string_arr_delete(a); - RRD_CHECK_ERROR + RRD_CHECK_ERROR result = rb_ary_new2(3); - result = rb_ary_new2(3); print_results = rb_ary_new(); p = calcpr; for (p = calcpr; p && *p; p++) { @@ -207,10 +223,12 @@ VALUE rb_rrd_info(VALUE self, VALUE args) } */ -VALUE rb_rrd_last(VALUE self, VALUE args) +VALUE rb_rrd_last( + VALUE self, + VALUE args) { string_arr a; - time_t last; + time_t last; a = string_arr_new(args); reset_rrd_state(); @@ -218,31 +236,39 @@ VALUE rb_rrd_last(VALUE self, VALUE args) string_arr_delete(a); RRD_CHECK_ERROR - - return rb_funcall(rb_cTime, rb_intern("at"), 1, INT2FIX(last)); + return rb_funcall(rb_cTime, rb_intern("at"), 1, INT2FIX(last)); } -VALUE rb_rrd_resize(VALUE self, VALUE args) +VALUE rb_rrd_resize( + VALUE self, + VALUE args) { return rrd_call(rrd_resize, args); } -VALUE rb_rrd_restore(VALUE self, VALUE args) +VALUE rb_rrd_restore( + VALUE self, + VALUE args) { return rrd_call(rrd_restore, args); } -VALUE rb_rrd_tune(VALUE self, VALUE args) +VALUE rb_rrd_tune( + VALUE self, + VALUE args) { return rrd_call(rrd_tune, args); } -VALUE rb_rrd_update(VALUE self, VALUE args) +VALUE rb_rrd_update( + VALUE self, + VALUE args) { return rrd_call(rrd_update, args); } -void Init_RRD() +void Init_RRD( + ) { mRRD = rb_define_module("RRD"); rb_eRRDError = rb_define_class("RRDError", rb_eStandardError); diff --git a/program/bindings/tcl/tclrrd.c b/program/bindings/tcl/tclrrd.c index 11d25dfa..a58a6c26 100644 --- a/program/bindings/tcl/tclrrd.c +++ b/program/bindings/tcl/tclrrd.c @@ -27,8 +27,10 @@ # define CONST84 #endif -extern int Tclrrd_Init(Tcl_Interp *interp); -extern int Tclrrd_SafeInit(Tcl_Interp *interp); +extern int Tclrrd_Init( + Tcl_Interp *interp); +extern int Tclrrd_SafeInit( + Tcl_Interp *interp); /* @@ -37,147 +39,165 @@ extern int Tclrrd_SafeInit(Tcl_Interp *interp); * Hence, we need to do some preparation before * calling the rrd library functions. */ -static char ** getopt_init(int argc, CONST84 char *argv[]) +static char **getopt_init( + int argc, + CONST84 char *argv[]) { - char **argv2; - int i; - + char **argv2; + int i; + argv2 = calloc(argc, sizeof(char *)); for (i = 0; i < argc; i++) { - argv2[i] = strdup(argv[i]); + argv2[i] = strdup(argv[i]); } return argv2; } -static void getopt_cleanup(int argc, char **argv2) +static void getopt_cleanup( + int argc, + char **argv2) { - int i; - + int i; + for (i = 0; i < argc; i++) { - if (argv2[i] != NULL) { - free(argv2[i]); - } + if (argv2[i] != NULL) { + free(argv2[i]); + } } free(argv2); } -static void getopt_free_element(argv2, argn) - char *argv2[]; - int argn; +static void getopt_free_element( + argv2, + argn) + char *argv2[]; + int argn; { if (argv2[argn] != NULL) { - free(argv2[argn]); - argv2[argn] = NULL; + free(argv2[argn]); + argv2[argn] = NULL; } } -static void getopt_squieeze(argc, argv2) - int *argc; - char *argv2[]; +static void getopt_squieeze( + argc, + argv2) + int *argc; + char *argv2[]; { - int i, null_i = 0, argc_tmp = *argc; + int i, null_i = 0, argc_tmp = *argc; for (i = 0; i < argc_tmp; i++) { - if (argv2[i] == NULL) { - (*argc)--; - } else { - argv2[null_i++] = argv2[i]; - } + if (argv2[i] == NULL) { + (*argc)--; + } else { + argv2[null_i++] = argv2[i]; + } } } /* Thread-safe version */ -static int -Rrd_Create(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[]) +static int Rrd_Create( + ClientData clientData, + Tcl_Interp *interp, + int argc, + CONST84 char *argv[]) { - int argv_i; - char **argv2; - char *parsetime_error = NULL; - time_t last_up = time(NULL) - 10; - long int long_tmp; - unsigned long int pdp_step = 300; - struct rrd_time_value last_up_tv; + int argv_i; + char **argv2; + char *parsetime_error = NULL; + time_t last_up = time(NULL) - 10; + long int long_tmp; + unsigned long int pdp_step = 300; + struct rrd_time_value last_up_tv; argv2 = getopt_init(argc, argv); for (argv_i = 1; argv_i < argc; argv_i++) { - if (!strcmp(argv2[argv_i], "--start") || !strcmp(argv2[argv_i], "-b")) { - if (argv_i++>=argc) { - Tcl_AppendResult(interp, "RRD Error: option '", - argv2[argv_i - 1], "' needs an argument", (char *) NULL); - getopt_cleanup(argc, argv2); - return TCL_ERROR; - } - if ((parsetime_error = parsetime(argv2[argv_i], &last_up_tv))) { - Tcl_AppendResult(interp, "RRD Error: invalid time format: '", - argv2[argv_i], "'", (char *) NULL); - getopt_cleanup(argc, argv2); - return TCL_ERROR; - } - if (last_up_tv.type == RELATIVE_TO_END_TIME || - last_up_tv.type == RELATIVE_TO_START_TIME) { - Tcl_AppendResult(interp, "RRD Error: specifying time relative to the 'start' ", - "or 'end' makes no sense here", (char *) NULL); - getopt_cleanup(argc, argv2); - return TCL_ERROR; - } - last_up = mktime(&last_up_tv.tm) + last_up_tv.offset; - if (last_up < 3600*24*365*10) { - Tcl_AppendResult(interp, "RRD Error: the first entry to the RRD should be after 1980", - (char *) NULL); - getopt_cleanup(argc, argv2); - return TCL_ERROR; - } - getopt_free_element(argv2, argv_i - 1); - getopt_free_element(argv2, argv_i); - } else if (!strcmp(argv2[argv_i], "--step") || !strcmp(argv2[argv_i], "-s")) { - if (argv_i++>=argc) { - Tcl_AppendResult(interp, "RRD Error: option '", - argv2[argv_i - 1], "' needs an argument", (char *) NULL); - getopt_cleanup(argc, argv2); - return TCL_ERROR; - } - long_tmp = atol(argv2[argv_i]); - if (long_tmp < 1) { - Tcl_AppendResult(interp, "RRD Error: step size should be no less than one second", - (char *) NULL); - getopt_cleanup(argc, argv2); - return TCL_ERROR; - } - pdp_step = long_tmp; - getopt_free_element(argv2, argv_i - 1); - getopt_free_element(argv2, argv_i); - } else if (!strcmp(argv2[argv_i], "--")) { - getopt_free_element(argv2, argv_i); - break; - } else if (argv2[argv_i][0]=='-') { - Tcl_AppendResult(interp, "RRD Error: unknown option '", - argv2[argv_i], "'", (char *) NULL); - getopt_cleanup(argc, argv2); - return TCL_ERROR; - } + if (!strcmp(argv2[argv_i], "--start") || !strcmp(argv2[argv_i], "-b")) { + if (argv_i++ >= argc) { + Tcl_AppendResult(interp, "RRD Error: option '", + argv2[argv_i - 1], "' needs an argument", + (char *) NULL); + getopt_cleanup(argc, argv2); + return TCL_ERROR; + } + if ((parsetime_error = parsetime(argv2[argv_i], &last_up_tv))) { + Tcl_AppendResult(interp, "RRD Error: invalid time format: '", + argv2[argv_i], "'", (char *) NULL); + getopt_cleanup(argc, argv2); + return TCL_ERROR; + } + if (last_up_tv.type == RELATIVE_TO_END_TIME || + last_up_tv.type == RELATIVE_TO_START_TIME) { + Tcl_AppendResult(interp, + "RRD Error: specifying time relative to the 'start' ", + "or 'end' makes no sense here", + (char *) NULL); + getopt_cleanup(argc, argv2); + return TCL_ERROR; + } + last_up = mktime(&last_up_tv.tm) +last_up_tv.offset; + if (last_up < 3600 * 24 * 365 * 10) { + Tcl_AppendResult(interp, + "RRD Error: the first entry to the RRD should be after 1980", + (char *) NULL); + getopt_cleanup(argc, argv2); + return TCL_ERROR; + } + getopt_free_element(argv2, argv_i - 1); + getopt_free_element(argv2, argv_i); + } else if (!strcmp(argv2[argv_i], "--step") + || !strcmp(argv2[argv_i], "-s")) { + if (argv_i++ >= argc) { + Tcl_AppendResult(interp, "RRD Error: option '", + argv2[argv_i - 1], "' needs an argument", + (char *) NULL); + getopt_cleanup(argc, argv2); + return TCL_ERROR; + } + long_tmp = atol(argv2[argv_i]); + if (long_tmp < 1) { + Tcl_AppendResult(interp, + "RRD Error: step size should be no less than one second", + (char *) NULL); + getopt_cleanup(argc, argv2); + return TCL_ERROR; + } + pdp_step = long_tmp; + getopt_free_element(argv2, argv_i - 1); + getopt_free_element(argv2, argv_i); + } else if (!strcmp(argv2[argv_i], "--")) { + getopt_free_element(argv2, argv_i); + break; + } else if (argv2[argv_i][0] == '-') { + Tcl_AppendResult(interp, "RRD Error: unknown option '", + argv2[argv_i], "'", (char *) NULL); + getopt_cleanup(argc, argv2); + return TCL_ERROR; + } } getopt_squieeze(&argc, argv2); if (argc < 2) { - Tcl_AppendResult(interp, "RRD Error: needs rrd filename", - (char *) NULL); - getopt_cleanup(argc, argv2); - return TCL_ERROR; + Tcl_AppendResult(interp, "RRD Error: needs rrd filename", + (char *) NULL); + getopt_cleanup(argc, argv2); + return TCL_ERROR; } rrd_create_r(argv2[1], pdp_step, last_up, argc - 2, argv2 + 2); getopt_cleanup(argc, argv2); - + if (rrd_test_error()) { - Tcl_AppendResult(interp, "RRD Error: ", - rrd_get_error(), (char *) NULL); + Tcl_AppendResult(interp, "RRD Error: ", + rrd_get_error(), (char *) NULL); rrd_clear_error(); - return TCL_ERROR; + return TCL_ERROR; } return TCL_OK; @@ -186,13 +206,16 @@ Rrd_Create(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *ar /* Thread-safe version */ -static int -Rrd_Dump(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[]) +static int Rrd_Dump( + ClientData clientData, + Tcl_Interp *interp, + int argc, + CONST84 char *argv[]) { if (argc < 2) { - Tcl_AppendResult(interp, "RRD Error: needs rrd filename", - (char *) NULL); - return TCL_ERROR; + Tcl_AppendResult(interp, "RRD Error: needs rrd filename", + (char *) NULL); + return TCL_ERROR; } rrd_dump_r(argv[1], NULL); @@ -200,10 +223,10 @@ Rrd_Dump(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv /* NOTE: rrd_dump() writes to stdout. No interaction with TCL. */ if (rrd_test_error()) { - Tcl_AppendResult(interp, "RRD Error: ", - rrd_get_error(), (char *) NULL); + Tcl_AppendResult(interp, "RRD Error: ", + rrd_get_error(), (char *) NULL); rrd_clear_error(); - return TCL_ERROR; + return TCL_ERROR; } return TCL_OK; @@ -212,24 +235,27 @@ Rrd_Dump(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv /* Thread-safe version */ -static int -Rrd_Last(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[]) +static int Rrd_Last( + ClientData clientData, + Tcl_Interp *interp, + int argc, + CONST84 char *argv[]) { - time_t t; - + time_t t; + if (argc < 2) { - Tcl_AppendResult(interp, "RRD Error: needs rrd filename", - (char *) NULL); - return TCL_ERROR; + Tcl_AppendResult(interp, "RRD Error: needs rrd filename", + (char *) NULL); + return TCL_ERROR; } t = rrd_last_r(argv[1]); if (rrd_test_error()) { - Tcl_AppendResult(interp, "RRD Error: ", - rrd_get_error(), (char *) NULL); + Tcl_AppendResult(interp, "RRD Error: ", + rrd_get_error(), (char *) NULL); rrd_clear_error(); - return TCL_ERROR; + return TCL_ERROR; } Tcl_SetIntObj(Tcl_GetObjResult(interp), t); @@ -240,147 +266,159 @@ Rrd_Last(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv /* Thread-safe version */ -static int -Rrd_Update(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[]) +static int Rrd_Update( + ClientData clientData, + Tcl_Interp *interp, + int argc, + CONST84 char *argv[]) { - int argv_i; - char **argv2, *template = NULL; - + int argv_i; + char **argv2, *template = NULL; + argv2 = getopt_init(argc, argv); for (argv_i = 1; argv_i < argc; argv_i++) { - if (!strcmp(argv2[argv_i], "--template") || !strcmp(argv2[argv_i], "-t")) { - if (argv_i++>=argc) { - Tcl_AppendResult(interp, "RRD Error: option '", - argv2[argv_i - 1], "' needs an argument", (char *) NULL); - if (template != NULL) { - free(template); - } - getopt_cleanup(argc, argv2); - return TCL_ERROR; - } - if (template != NULL) { - free(template); - } - template = strdup(argv2[argv_i]); - getopt_free_element(argv2, argv_i - 1); - getopt_free_element(argv2, argv_i); - } else if (!strcmp(argv2[argv_i], "--")) { - getopt_free_element(argv2, argv_i); - break; - } else if (argv2[argv_i][0]=='-') { - Tcl_AppendResult(interp, "RRD Error: unknown option '", - argv2[argv_i], "'", (char *) NULL); - if (template != NULL) { - free(template); - } - getopt_cleanup(argc, argv2); - return TCL_ERROR; - } + if (!strcmp(argv2[argv_i], "--template") + || !strcmp(argv2[argv_i], "-t")) { + if (argv_i++ >= argc) { + Tcl_AppendResult(interp, "RRD Error: option '", + argv2[argv_i - 1], "' needs an argument", + (char *) NULL); + if (template != NULL) { + free(template); + } + getopt_cleanup(argc, argv2); + return TCL_ERROR; + } + if (template != NULL) { + free(template); + } + template = strdup(argv2[argv_i]); + getopt_free_element(argv2, argv_i - 1); + getopt_free_element(argv2, argv_i); + } else if (!strcmp(argv2[argv_i], "--")) { + getopt_free_element(argv2, argv_i); + break; + } else if (argv2[argv_i][0] == '-') { + Tcl_AppendResult(interp, "RRD Error: unknown option '", + argv2[argv_i], "'", (char *) NULL); + if (template != NULL) { + free(template); + } + getopt_cleanup(argc, argv2); + return TCL_ERROR; + } } getopt_squieeze(&argc, argv2); if (argc < 2) { - Tcl_AppendResult(interp, "RRD Error: needs rrd filename", - (char *) NULL); - if (template != NULL) { - free(template); - } - getopt_cleanup(argc, argv2); - return TCL_ERROR; + Tcl_AppendResult(interp, "RRD Error: needs rrd filename", + (char *) NULL); + if (template != NULL) { + free(template); + } + getopt_cleanup(argc, argv2); + return TCL_ERROR; } rrd_update_r(argv2[1], template, argc - 2, argv2 + 2); if (template != NULL) { - free(template); + free(template); } getopt_cleanup(argc, argv2); if (rrd_test_error()) { - Tcl_AppendResult(interp, "RRD Error: ", - rrd_get_error(), (char *) NULL); + Tcl_AppendResult(interp, "RRD Error: ", + rrd_get_error(), (char *) NULL); rrd_clear_error(); - return TCL_ERROR; + return TCL_ERROR; } return TCL_OK; } -static int -Rrd_Lastupdate(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[]) +static int Rrd_Lastupdate( + ClientData clientData, + Tcl_Interp *interp, + int argc, + CONST84 char *argv[]) { - time_t last_update; - char **argv2; - char **ds_namv; - char **last_ds; - char s[30]; - Tcl_Obj *listPtr; - unsigned long ds_cnt, i; - - argv2 = getopt_init(argc, argv); - if (rrd_lastupdate(argc-1, argv2, &last_update, - &ds_cnt, &ds_namv, &last_ds) == 0) { - listPtr = Tcl_GetObjResult(interp); - for (i=0; iis< a Tcl fileID - */ - if (!(mode & TCL_WRITABLE)) { - Tcl_AppendResult(interp, "channel \"", argv[1], - "\" wasn't opened for writing", (char *) NULL); - return TCL_ERROR; - } - /* - * Must flush channel to make sure any buffered data is written before - * rrd_graph() writes to the stream - */ - if (Tcl_Flush(channel) != TCL_OK) { - Tcl_AppendResult(interp, "flush failed for \"", argv[1], "\": ", - strerror(Tcl_GetErrno()), (char *) NULL); - return TCL_ERROR; - } - if (Tcl_GetChannelHandle(channel, TCL_WRITABLE, &fd1) != TCL_OK) { - Tcl_AppendResult(interp, "cannot get file descriptor associated with \"", - argv[1], "\"", (char *) NULL); - return TCL_ERROR; - } - /* - * Must dup() file descriptor so we can fclose(stream), otherwise the fclose() - * would close Tcl's file descriptor - */ - if ((fd2 = dup((int)fd1)) == -1) { - Tcl_AppendResult(interp, "dup() failed for file descriptor associated with \"", - argv[1], "\": ", strerror(errno), (char *) NULL); - return TCL_ERROR; - } - /* - * rrd_graph() wants a FILE* - */ - if ((stream = fdopen(fd2, "wb")) == NULL) { - Tcl_AppendResult(interp, "fdopen() failed for file descriptor associated with \"", - argv[1], "\": ", strerror(errno), (char *) NULL); - close(fd2); /* plug potential file descriptor leak */ - return TCL_ERROR; - } - - save = argv[1]; - argv[1] = "-"; - argv2 = getopt_init(argc, argv); - argv[1] = save; + /* + * It >is< a Tcl fileID + */ + if (!(mode & TCL_WRITABLE)) { + Tcl_AppendResult(interp, "channel \"", argv[1], + "\" wasn't opened for writing", (char *) NULL); + return TCL_ERROR; + } + /* + * Must flush channel to make sure any buffered data is written before + * rrd_graph() writes to the stream + */ + if (Tcl_Flush(channel) != TCL_OK) { + Tcl_AppendResult(interp, "flush failed for \"", argv[1], "\": ", + strerror(Tcl_GetErrno()), (char *) NULL); + return TCL_ERROR; + } + if (Tcl_GetChannelHandle(channel, TCL_WRITABLE, &fd1) != TCL_OK) { + Tcl_AppendResult(interp, + "cannot get file descriptor associated with \"", + argv[1], "\"", (char *) NULL); + return TCL_ERROR; + } + /* + * Must dup() file descriptor so we can fclose(stream), otherwise the fclose() + * would close Tcl's file descriptor + */ + if ((fd2 = dup((int) fd1)) == -1) { + Tcl_AppendResult(interp, + "dup() failed for file descriptor associated with \"", + argv[1], "\": ", strerror(errno), (char *) NULL); + return TCL_ERROR; + } + /* + * rrd_graph() wants a FILE* + */ + if ((stream = fdopen(fd2, "wb")) == NULL) { + Tcl_AppendResult(interp, + "fdopen() failed for file descriptor associated with \"", + argv[1], "\": ", strerror(errno), (char *) NULL); + close(fd2); /* plug potential file descriptor leak */ + return TCL_ERROR; + } + + save = argv[1]; + argv[1] = "-"; + argv2 = getopt_init(argc, argv); + argv[1] = save; } else { - Tcl_ResetResult(interp); /* clear error from Tcl_GetChannel() */ - argv2 = getopt_init(argc, argv); + Tcl_ResetResult(interp); /* clear error from Tcl_GetChannel() */ + argv2 = getopt_init(argc, argv); } - rc = rrd_graph(argc, argv2, &calcpr, &xsize, &ysize, stream, &ymin, &ymax); + rc = rrd_graph(argc, argv2, &calcpr, &xsize, &ysize, stream, &ymin, + &ymax); getopt_cleanup(argc, argv2); if (stream != NULL) - fclose(stream); /* plug potential malloc & file descriptor leak */ + fclose(stream); /* plug potential malloc & file descriptor leak */ if (rc != -1) { sprintf(dimensions, "%d %d", xsize, ysize); Tcl_AppendResult(interp, dimensions, (char *) NULL); if (calcpr) { #if 0 - int i; - - for(i = 0; calcpr[i]; i++){ + int i; + + for (i = 0; calcpr[i]; i++) { printf("%s\n", calcpr[i]); free(calcpr[i]); - } + } #endif free(calcpr); } } if (rrd_test_error()) { - Tcl_AppendResult(interp, "RRD Error: ", - rrd_get_error(), (char *) NULL); + Tcl_AppendResult(interp, "RRD Error: ", + rrd_get_error(), (char *) NULL); rrd_clear_error(); - return TCL_ERROR; + return TCL_ERROR; } return TCL_OK; @@ -491,20 +536,23 @@ Rrd_Graph(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *arg -static int -Rrd_Tune(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[]) +static int Rrd_Tune( + ClientData clientData, + Tcl_Interp *interp, + int argc, + CONST84 char *argv[]) { - char **argv2; - + char **argv2; + argv2 = getopt_init(argc, argv); rrd_tune(argc, argv2); getopt_cleanup(argc, argv2); if (rrd_test_error()) { - Tcl_AppendResult(interp, "RRD Error: ", - rrd_get_error(), (char *) NULL); + Tcl_AppendResult(interp, "RRD Error: ", + rrd_get_error(), (char *) NULL); rrd_clear_error(); - return TCL_ERROR; + return TCL_ERROR; } return TCL_OK; @@ -512,20 +560,23 @@ Rrd_Tune(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv -static int -Rrd_Resize(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[]) +static int Rrd_Resize( + ClientData clientData, + Tcl_Interp *interp, + int argc, + CONST84 char *argv[]) { - char **argv2; - + char **argv2; + argv2 = getopt_init(argc, argv); rrd_resize(argc, argv2); getopt_cleanup(argc, argv2); if (rrd_test_error()) { - Tcl_AppendResult(interp, "RRD Error: ", - rrd_get_error(), (char *) NULL); + Tcl_AppendResult(interp, "RRD Error: ", + rrd_get_error(), (char *) NULL); rrd_clear_error(); - return TCL_ERROR; + return TCL_ERROR; } return TCL_OK; @@ -533,20 +584,23 @@ Rrd_Resize(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *ar -static int -Rrd_Restore(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[]) +static int Rrd_Restore( + ClientData clientData, + Tcl_Interp *interp, + int argc, + CONST84 char *argv[]) { - char **argv2; - + char **argv2; + argv2 = getopt_init(argc, argv); rrd_restore(argc, argv2); getopt_cleanup(argc, argv2); if (rrd_test_error()) { - Tcl_AppendResult(interp, "RRD Error: ", - rrd_get_error(), (char *) NULL); + Tcl_AppendResult(interp, "RRD Error: ", + rrd_get_error(), (char *) NULL); rrd_clear_error(); - return TCL_ERROR; + return TCL_ERROR; } return TCL_OK; @@ -559,39 +613,40 @@ Rrd_Restore(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *a */ typedef struct { - char *name; /* Name of the command. */ - Tcl_CmdProc *proc; /* Procedure for command. */ - int hide; /* Hide if safe interpreter */ + char *name; /* Name of the command. */ + Tcl_CmdProc *proc; /* Procedure for command. */ + int hide; /* Hide if safe interpreter */ } CmdInfo; static CmdInfo rrdCmds[] = { - { "Rrd::create", Rrd_Create, 1 }, /* Thread-safe version */ - { "Rrd::dump", Rrd_Dump, 0 }, /* Thread-safe version */ - { "Rrd::last", Rrd_Last, 0 }, /* Thread-safe version */ - { "Rrd::lastupdate", Rrd_Lastupdate, 0 }, /* Thread-safe version */ - { "Rrd::update", Rrd_Update, 1 }, /* Thread-safe version */ - { "Rrd::fetch", Rrd_Fetch, 0 }, - { "Rrd::graph", Rrd_Graph, 1 }, /* Due to RRD's API, a safe - interpreter cannot create - a graph since it writes to - a filename supplied by the - caller */ - { "Rrd::tune", Rrd_Tune, 1 }, - { "Rrd::resize", Rrd_Resize, 1 }, - { "Rrd::restore", Rrd_Restore, 1 }, - { (char *) NULL, (Tcl_CmdProc *) NULL, 0 } + {"Rrd::create", Rrd_Create, 1}, /* Thread-safe version */ + {"Rrd::dump", Rrd_Dump, 0}, /* Thread-safe version */ + {"Rrd::last", Rrd_Last, 0}, /* Thread-safe version */ + {"Rrd::lastupdate", Rrd_Lastupdate, 0}, /* Thread-safe version */ + {"Rrd::update", Rrd_Update, 1}, /* Thread-safe version */ + {"Rrd::fetch", Rrd_Fetch, 0}, + {"Rrd::graph", Rrd_Graph, 1}, /* Due to RRD's API, a safe + interpreter cannot create + a graph since it writes to + a filename supplied by the + caller */ + {"Rrd::tune", Rrd_Tune, 1}, + {"Rrd::resize", Rrd_Resize, 1}, + {"Rrd::restore", Rrd_Restore, 1}, + {(char *) NULL, (Tcl_CmdProc *) NULL, 0} }; -static int -init(Tcl_Interp *interp, int safe) -{ - CmdInfo *cmdInfoPtr; +static int init( + Tcl_Interp *interp, + int safe) +{ + CmdInfo *cmdInfoPtr; Tcl_CmdInfo info; - if ( Tcl_InitStubs(interp,TCL_VERSION,0) == NULL ) - return TCL_ERROR; + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) + return TCL_ERROR; if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 1) == NULL) { return TCL_ERROR; @@ -604,65 +659,65 @@ init(Tcl_Interp *interp, int safe) Tcl_SetVar2(interp, "rrd", "version", VERSION, TCL_GLOBAL_ONLY); for (cmdInfoPtr = rrdCmds; cmdInfoPtr->name != NULL; cmdInfoPtr++) { - /* - * Check if the command already exists and return an error - * to ensure we detect name clashes while loading the Rrd - * extension. - */ - if (Tcl_GetCommandInfo(interp, cmdInfoPtr->name, &info)) { - Tcl_AppendResult(interp, "command \"", cmdInfoPtr->name, - "\" already exists", (char *) NULL); - return TCL_ERROR; - } - if (safe && cmdInfoPtr->hide) { + /* + * Check if the command already exists and return an error + * to ensure we detect name clashes while loading the Rrd + * extension. + */ + if (Tcl_GetCommandInfo(interp, cmdInfoPtr->name, &info)) { + Tcl_AppendResult(interp, "command \"", cmdInfoPtr->name, + "\" already exists", (char *) NULL); + return TCL_ERROR; + } + if (safe && cmdInfoPtr->hide) { #if 0 - /* - * Turns out the one cannot hide a command in a namespace - * due to a limitation of Tcl, one can only hide global - * commands. Thus, if we created the commands without - * the Rrd:: namespace in a safe interpreter, then the - * "unsafe" commands could be hidden -- which would allow - * an owning interpreter either un-hiding them or doing - * an "interp invokehidden". If the Rrd:: namespace is - * used, then it's still possible for the owning interpreter - * to fake out the missing commands: - * - * # Make all Rrd::* commands available in master interperter - * package require Rrd - * set safe [interp create -safe] - * # Make safe Rrd::* commands available in safe interperter - * interp invokehidden $safe -global load ./tclrrd1.2.11.so - * # Provide the safe interpreter with the missing commands - * $safe alias Rrd::update do_update $safe - * proc do_update {which_interp $args} { - * # Do some checking maybe... - * : - * return [eval Rrd::update $args] - * } - * - * Our solution for now is to just not create the "unsafe" - * commands in a safe interpreter. - */ - if (Tcl_HideCommand(interp, cmdInfoPtr->name, cmdInfoPtr->name) != TCL_OK) - return TCL_ERROR; + /* + * Turns out the one cannot hide a command in a namespace + * due to a limitation of Tcl, one can only hide global + * commands. Thus, if we created the commands without + * the Rrd:: namespace in a safe interpreter, then the + * "unsafe" commands could be hidden -- which would allow + * an owning interpreter either un-hiding them or doing + * an "interp invokehidden". If the Rrd:: namespace is + * used, then it's still possible for the owning interpreter + * to fake out the missing commands: + * + * # Make all Rrd::* commands available in master interperter + * package require Rrd + * set safe [interp create -safe] + * # Make safe Rrd::* commands available in safe interperter + * interp invokehidden $safe -global load ./tclrrd1.2.11.so + * # Provide the safe interpreter with the missing commands + * $safe alias Rrd::update do_update $safe + * proc do_update {which_interp $args} { + * # Do some checking maybe... + * : + * return [eval Rrd::update $args] + * } + * + * Our solution for now is to just not create the "unsafe" + * commands in a safe interpreter. + */ + if (Tcl_HideCommand(interp, cmdInfoPtr->name, cmdInfoPtr->name) != + TCL_OK) + return TCL_ERROR; #endif - } - else - Tcl_CreateCommand(interp, cmdInfoPtr->name, cmdInfoPtr->proc, - (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + } else + Tcl_CreateCommand(interp, cmdInfoPtr->name, cmdInfoPtr->proc, + (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); } if (Tcl_PkgProvide(interp, "Rrd", VERSION) != TCL_OK) { - return TCL_ERROR; + return TCL_ERROR; } return TCL_OK; } -int -Tclrrd_Init(Tcl_Interp *interp) -{ - return init(interp, 0); +int Tclrrd_Init( + Tcl_Interp *interp) +{ + return init(interp, 0); } /* @@ -670,8 +725,8 @@ Tclrrd_Init(Tcl_Interp *interp) * Using rrdtool in a safe interpreter has very limited functionality. It's * tempting to just return TCL_ERROR and forget about it. */ -int -Tclrrd_SafeInit(Tcl_Interp *interp) -{ - return init(interp, 1); +int Tclrrd_SafeInit( + Tcl_Interp *interp) +{ + return init(interp, 1); } diff --git a/program/libraries/afm/test-afm.c b/program/libraries/afm/test-afm.c index 8347ad6a..16cfc8b5 100644 --- a/program/libraries/afm/test-afm.c +++ b/program/libraries/afm/test-afm.c @@ -1,17 +1,22 @@ #include "rrd_afm.h" #include -FILE *fp; +FILE *fp; + +static void make_tests( + void); +static void print( + const char *s); +double y = 0; -static void make_tests(void); -static void print(const char *s); -double y = 0; //static const char *font = "Times-Roman"; static const char *font = "Times Bold Italic"; + //static const char *font = "Courier"; //static const char *font = "Courier Bold Oblique"; -void make_tests() +void make_tests( + ) { #ifdef __APPLE__ #define charset_legend "Macintosh charset" @@ -28,81 +33,91 @@ void make_tests() #define aa "\xA5" #define NBSP "\x00A0" #endif - print(AE); /* very wide char */ - print(AE AE AE AE AE AE AE AE AE AE AE AE AE AE AE); - print(charset_legend); - print("S,"); - print("sfil"); - print("Hello, world"); - print("AVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAV"); - print("AAAAAAAAAAAAAAAAAAVVVVVVVVVVVVVVVVVV"); - print("fiffififfififfififfififfififfififfi"); - print("fi"); - print("fil"); - print("fifififififififififififififififififififififififififi"); - print(AE "bleskiver med gl"oe"gg. " NBSP NBSP NBSP NBSP NBSP NBSP NBSP - AE" Fywerhus: 'A "ae" u "aa" "ae" "oe" i "ae" fywer'."); - print("Ingef"ae"rp"ae"rer med karamelsauce. R"oe"dgr"oe"d med fl"oe"de."); - print("(Optional.) Ligature sequence where successor and ligature are both names. The current character may join ..."); + print(AE); /* very wide char */ + print(AE AE AE AE AE AE AE AE AE AE AE AE AE AE AE); + print(charset_legend); + print("S,"); + print("sfil"); + print("Hello, world"); + print("AVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAV"); + print("AAAAAAAAAAAAAAAAAAVVVVVVVVVVVVVVVVVV"); + print("fiffififfififfififfififfififfififfi"); + print("fi"); + print("fil"); + print("fifififififififififififififififififififififififififi"); + print(AE "bleskiver med gl" oe "gg. " NBSP NBSP NBSP NBSP NBSP NBSP NBSP + AE " Fywerhus: 'A " ae " u " aa " " ae " " oe " i " ae " fywer'."); + print("Ingef" ae "rp" ae "rer med karamelsauce. R" oe "dgr" oe "d med fl" + oe "de."); + print + ("(Optional.) Ligature sequence where successor and ligature are both names. The current character may join ..."); } -static void vline(double x, double y1, double y2) +static void vline( + double x, + double y1, + double y2) { - fprintf(fp, "\n", - x, y1, x, y2); + fprintf(fp, "\n", x, y1, x, y2); } -static void print(const char *s) +static void print( + const char *s) { - double size = 12; - double x = 10; - double width = afm_get_text_width(0, font, size, 4, s); - unsigned char *up = (unsigned char*)s; - fprintf(stderr, "Width = %f for '%s'\n", width, s); - y += 10; - vline(x, y, y + 5); - fprintf(fp, "", x, y, size); - while (*up) { - unsigned char ch = afm_host2unicode(*up); - if (ch < 127) - putc(ch, fp); - else - fprintf(fp, "&#%d;", ch); - up++; - } - fputs("\n", fp); - vline(x + width, y, y + 5); - y += 1.1 * size; + double size = 12; + double x = 10; + double width = afm_get_text_width(0, font, size, 4, s); + unsigned char *up = (unsigned char *) s; + + fprintf(stderr, "Width = %f for '%s'\n", width, s); + y += 10; + vline(x, y, y + 5); + fprintf(fp, "", x, y, + size); + while (*up) { + unsigned char ch = afm_host2unicode(*up); + + if (ch < 127) + putc(ch, fp); + else + fprintf(fp, "&#%d;", ch); + up++; + } + fputs("\n", fp); + vline(x + width, y, y + 5); + y += 1.1 * size; } -static void header() +static void header( + ) { - fprintf(fp, - "\n" - "\n" - "\n", font); - } + fprintf(fp, + "\n" + "\n" + "\n", font); +} -static void footer() +static void footer( + ) { - fputs("\n", fp); + fputs("\n", fp); } -int main() +int main( + ) { - fp = fopen("test.svg", "w"); - if (fp == NULL) { - fprintf(stderr, "Can't create output.\n"); - exit(1); - } - header(); - make_tests(); - footer(); - fclose(fp); - return 0; + fp = fopen("test.svg", "w"); + if (fp == NULL) { + fprintf(stderr, "Can't create output.\n"); + exit(1); + } + header(); + make_tests(); + footer(); + fclose(fp); + return 0; } - diff --git a/program/src/.indent.pro b/program/src/.indent.pro deleted file mode 100644 index c64b08b3..00000000 --- a/program/src/.indent.pro +++ /dev/null @@ -1,39 +0,0 @@ ---blank-lines-after-declarations ---blank-lines-after-procedures ---break-before-boolean-operator ---break-function-decl-args ---no-blank-lines-after-commas ---braces-on-if-line ---braces-on-struct-decl-line ---comment-indentation25 ---declaration-comment-column25 ---no-comment-delimiters-on-blank-lines ---cuddle-else ---continuation-indentation4 ---case-indentation0 ---else-endif-column33 ---space-after-cast ---line-comments-indentation0 ---declaration-indentation10 ---dont-format-first-column-comments ---dont-format-comments ---honour-newlines ---indent-level4 -/* changed from 0 to 4 */ ---parameter-indentation4 ---line-length78 /* changed from 75 */ ---continue-at-parentheses ---no-space-after-function-call-names ---dont-break-procedure-type ---dont-star-comments ---leave-optional-blank-lines ---dont-space-special-semicolon ---tab-size4 -/* additions by Mark */ ---case-brace-indentation0 ---leave-preprocessor-space ---no-tabs --T rrd_t --T info_t --T time_t --T off_t diff --git a/program/src/hash_32.c b/program/src/hash_32.c index 04736963..7885c3ed 100644 --- a/program/src/hash_32.c +++ b/program/src/hash_32.c @@ -102,7 +102,7 @@ Fnv32_t fnv_32_buf( hval *= FNV_32_PRIME; /* xor the bottom with the current octet */ - hval ^= (Fnv32_t) * bp++; + hval ^= (Fnv32_t) *bp++; } /* return our new hash value */ @@ -141,7 +141,7 @@ Fnv32_t fnv_32_str( hval *= FNV_32_PRIME; /* xor the bottom with the current octet */ - hval ^= (Fnv32_t) * s++; + hval ^= (Fnv32_t) *s++; } /* return our new hash value */ diff --git a/program/src/parsetime.c b/program/src/parsetime.c index 508546a2..71af0657 100644 --- a/program/src/parsetime.c +++ b/program/src/parsetime.c @@ -531,16 +531,22 @@ static char *plus_minus( prev_multiplier = sc_tokid; switch (sc_tokid) { case YEARS: - ptv->tm.tm_year += (op == PLUS) ? delta : -delta; + ptv->tm. tm_year += ( + op == PLUS) ? delta : -delta; + return TIME_OK; case MONTHS: - ptv->tm.tm_mon += (op == PLUS) ? delta : -delta; + ptv->tm. tm_mon += ( + op == PLUS) ? delta : -delta; + return TIME_OK; case WEEKS: delta *= 7; /* FALLTHRU */ case DAYS: - ptv->tm.tm_mday += (op == PLUS) ? delta : -delta; + ptv->tm. tm_mday += ( + op == PLUS) ? delta : -delta; + return TIME_OK; case HOURS: ptv->offset += (op == PLUS) ? delta * 60 * 60 : -delta * 60 * 60; @@ -626,12 +632,13 @@ static char *tod( sprintf(sc_token, "%d", hour); return TIME_OK; } - ptv->tm.tm_hour = hour; - ptv->tm.tm_min = minute; - ptv->tm.tm_sec = 0; + ptv->tm. tm_hour = hour; + ptv->tm. tm_min = minute; + ptv->tm. tm_sec = 0; + if (ptv->tm.tm_hour == 24) { - ptv->tm.tm_hour = 0; - ptv->tm.tm_mday++; + ptv->tm. tm_hour = 0; + ptv->tm. tm_mday++; } return TIME_OK; } /* tod */ @@ -662,9 +669,10 @@ static char *assign_date( panic(e("won't handle dates before epoch (01/01/1970), sorry")); } - ptv->tm.tm_mday = mday; - ptv->tm.tm_mon = mon; - ptv->tm.tm_year = year; + ptv->tm. tm_mday = mday; + ptv->tm. tm_mon = mon; + ptv->tm. tm_year = year; + return TIME_OK; } /* assign_date */ @@ -681,13 +689,15 @@ static char *day( switch (sc_tokid) { case YESTERDAY: - ptv->tm.tm_mday--; + ptv->tm. tm_mday--; + /* FALLTRHU */ case TODAY: /* force ourselves to stay in today - no further processing */ token(); break; case TOMORROW: - ptv->tm.tm_mday++; + ptv->tm. tm_mday++; + token(); break; @@ -713,6 +723,7 @@ static char *day( token(); } else year = ptv->tm.tm_year; + try(assign_date(ptv, mday, mon, year)); break; @@ -726,7 +737,9 @@ static char *day( /* do a particular day of the week */ wday = (sc_tokid - SUN); - ptv->tm.tm_mday += (wday - ptv->tm.tm_wday); + ptv->tm. tm_mday += ( + wday - ptv->tm.tm_wday); + token(); break; /* @@ -745,6 +758,7 @@ static char *day( mon = atol(sc_token); if (mon > 10 * 365 * 24 * 60 * 60) { ptv->tm = *localtime(&mon); + token(); break; } @@ -836,7 +850,7 @@ char *parsetime( ptv->type = ABSOLUTE_TIME; ptv->offset = 0; ptv->tm = *localtime(&now); - ptv->tm.tm_isdst = -1; /* mk time can figure this out for us ... */ + ptv->tm. tm_isdst = -1; /* mk time can figure this out for us ... */ token(); switch (sc_tokid) { @@ -850,12 +864,13 @@ char *parsetime( case END: ptv->type = RELATIVE_TO_END_TIME; KeepItRelative: - ptv->tm.tm_sec = 0; - ptv->tm.tm_min = 0; - ptv->tm.tm_hour = 0; - ptv->tm.tm_mday = 0; - ptv->tm.tm_mon = 0; - ptv->tm.tm_year = 0; + ptv->tm. tm_sec = 0; + ptv->tm. tm_min = 0; + ptv->tm. tm_hour = 0; + ptv->tm. tm_mday = 0; + ptv->tm. tm_mon = 0; + ptv->tm. tm_year = 0; + /* FALLTHRU */ case NOW: { @@ -878,18 +893,19 @@ char *parsetime( long hour_sv = ptv->tm.tm_hour; long year_sv = ptv->tm.tm_year; - ptv->tm.tm_hour = 30; - ptv->tm.tm_year = 30000; + ptv->tm. tm_hour = 30; + ptv->tm. tm_year = 30000; + try(tod(ptv)) try(day(ptv)) if (ptv->tm.tm_hour == 30 && ptv->tm.tm_year != 30000) { try(tod(ptv)) } if (ptv->tm.tm_hour == 30) { - ptv->tm.tm_hour = hour_sv; + ptv->tm. tm_hour = hour_sv; } if (ptv->tm.tm_year == 30000) { - ptv->tm.tm_year = year_sv; + ptv->tm. tm_year = year_sv; } }; break; @@ -930,9 +946,10 @@ char *parsetime( ptv->tm.tm_mday++; ptv->tm.tm_wday++; } *//* shifting does not makes sense here ... noon is noon */ - ptv->tm.tm_hour = hr; - ptv->tm.tm_min = 0; - ptv->tm.tm_sec = 0; + ptv->tm. tm_hour = hr; + ptv->tm. tm_min = 0; + ptv->tm. tm_sec = 0; + token(); try(day(ptv)); break; @@ -963,7 +980,8 @@ char *parsetime( panic(e("unparsable trailing text: '...%s%s'", sc_token, sct)); } - ptv->tm.tm_isdst = -1; /* for mktime to guess DST status */ + ptv->tm. tm_isdst = -1; /* for mktime to guess DST status */ + if (ptv->type == ABSOLUTE_TIME) if (mktime(&ptv->tm) == -1) { /* normalize & check */ /* can happen for "nonexistent" times, e.g. around 3am */ @@ -1007,6 +1025,7 @@ int proc_start_end( tmtmp.tm_mday += start_tv->tm.tm_mday; tmtmp.tm_mon += start_tv->tm.tm_mon; tmtmp.tm_year += start_tv->tm.tm_year; + *start = mktime(&tmtmp) + start_tv->offset; } else { *start = mktime(&(start_tv->tm)) + start_tv->offset; @@ -1019,6 +1038,7 @@ int proc_start_end( tmtmp.tm_mday += end_tv->tm.tm_mday; tmtmp.tm_mon += end_tv->tm.tm_mon; tmtmp.tm_year += end_tv->tm.tm_year; + *end = mktime(&tmtmp) + end_tv->offset; } else { *end = mktime(&(end_tv->tm)) + end_tv->offset; diff --git a/program/src/rrd.h b/program/src/rrd.h index 1b79af33..a7fe7597 100644 --- a/program/src/rrd.h +++ b/program/src/rrd.h @@ -152,7 +152,7 @@ extern "C" { unsigned long *step, unsigned long *ds_cnt, char ***ds_namv, - rrd_value_t ** data); + rrd_value_t **data); int rrd_dump_r( const char *filename, char *outname); diff --git a/program/src/rrd_afm.c b/program/src/rrd_afm.c index 3c53fdd6..a6cdd40d 100644 --- a/program/src/rrd_afm.c +++ b/program/src/rrd_afm.c @@ -119,7 +119,7 @@ double afm_get_descender( } static int afm_find_char_index( - const afm_fontinfo * fontinfo, + const afm_fontinfo *fontinfo, afm_cunicode ch1) { int idx = ch1 - 32; @@ -155,7 +155,7 @@ static int afm_find_char_index( #if ENABLE_LIGATURES static afm_cunicode afm_find_combined_ligature( - const afm_fontinfo * fontinfo, + const afm_fontinfo *fontinfo, afm_cunicode ch1, afm_cunicode ch2) { @@ -188,7 +188,7 @@ static afm_cunicode afm_find_combined_ligature( static long afm_find_kern( - const afm_fontinfo * fontinfo, + const afm_fontinfo *fontinfo, int kern_idx, afm_cunicode ch2) { diff --git a/program/src/rrd_create.c b/program/src/rrd_create.c index 43d608ec..d36cf3cf 100644 --- a/program/src/rrd_create.c +++ b/program/src/rrd_create.c @@ -62,7 +62,7 @@ int rrd_create( return (-1); } - last_up = mktime(&last_up_tv.tm) + last_up_tv.offset; + last_up = mktime(&last_up_tv.tm) +last_up_tv.offset; if (last_up < 3600 * 24 * 365 * 10) { rrd_set_error diff --git a/program/src/rrd_dump.c b/program/src/rrd_dump.c index d839bf65..56ebda76 100644 --- a/program/src/rrd_dump.c +++ b/program/src/rrd_dump.c @@ -134,7 +134,7 @@ int rrd_dump_r( } else { /* DST_CDEF */ char *str = NULL; - rpn_compact2str((rpn_cdefds_t *) & (rrd.ds_def[i].par[DS_cdef]), + rpn_compact2str((rpn_cdefds_t *) &(rrd.ds_def[i].par[DS_cdef]), rrd.ds_def, &str); fprintf(out_file, "\t\t %s \n", str); free(str); diff --git a/program/src/rrd_fetch.c b/program/src/rrd_fetch.c index 42ddceba..a995fec2 100644 --- a/program/src/rrd_fetch.c +++ b/program/src/rrd_fetch.c @@ -67,7 +67,7 @@ int rrd_fetch( * will be changed to represent reality */ unsigned long *ds_cnt, /* number of data sources in file */ char ***ds_namv, /* names of data sources */ - rrd_value_t ** data) + rrd_value_t **data) { /* two dimensional array containing the data */ @@ -171,7 +171,7 @@ int rrd_fetch_r( * will be changed to represent reality */ unsigned long *ds_cnt, /* number of data sources in file */ char ***ds_namv, /* names of data_sources */ - rrd_value_t ** data) + rrd_value_t **data) { /* two dimensional array containing the data */ enum cf_en cf_idx; @@ -193,7 +193,7 @@ int rrd_fetch_fn( * will be changed to represent reality */ unsigned long *ds_cnt, /* number of data sources in file */ char ***ds_namv, /* names of data_sources */ - rrd_value_t ** data) + rrd_value_t **data) { /* two dimensional array containing the data */ long i, ii; time_t cal_start, cal_end, rra_start_time, rra_end_time; diff --git a/program/src/rrd_gfx.c b/program/src/rrd_gfx.c index 872c02cc..62088ddb 100644 --- a/program/src/rrd_gfx.c +++ b/program/src/rrd_gfx.c @@ -56,7 +56,7 @@ static void compute_string_bbox( /* create a freetype glyph string */ gfx_string gfx_string_create( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, FT_Face face, const char *text, int rotation, @@ -69,7 +69,7 @@ static void gfx_string_destroy( static gfx_node_t *gfx_new_node( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, enum gfx_en type) { gfx_node_t *node = art_new(gfx_node_t, 1); @@ -119,7 +119,7 @@ gfx_canvas_t *gfx_new_canvas( /* create a new line */ gfx_node_t *gfx_new_line( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, double X0, double Y0, double X1, @@ -131,7 +131,7 @@ gfx_node_t *gfx_new_line( } gfx_node_t *gfx_new_dashed_line( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, double X0, double Y0, double X1, @@ -173,7 +173,7 @@ gfx_node_t *gfx_new_dashed_line( /* create a new area */ gfx_node_t *gfx_new_area( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, double X0, double Y0, double X1, @@ -218,7 +218,7 @@ gfx_node_t *gfx_new_area( /* add a point to a line or to an area */ int gfx_add_point( - gfx_node_t * node, + gfx_node_t *node, double x, double y) { @@ -256,7 +256,7 @@ int gfx_add_point( } void gfx_close_path( - gfx_node_t * node) + gfx_node_t *node) { node->closed_path = 1; if (node->path[0].code == ART_MOVETO_OPEN) @@ -265,7 +265,7 @@ void gfx_close_path( /* create a text node */ gfx_node_t *gfx_new_text( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, double x, double y, gfx_color_t color, @@ -308,7 +308,7 @@ gfx_node_t *gfx_new_text( } int gfx_render( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, art_u32 width, art_u32 height, gfx_color_t background, @@ -343,7 +343,7 @@ static void gfx_string_destroy( double gfx_get_text_width( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, double start, char *font, double size, @@ -365,7 +365,7 @@ double gfx_get_text_width( } double gfx_get_text_width_libart( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, double UNUSED(start), char *font, double size, @@ -399,7 +399,7 @@ double gfx_get_text_width_libart( } static void gfx_libart_close_path( - gfx_node_t * node, + gfx_node_t *node, ArtVpath ** vec) { /* libart must have end==start for closed paths, @@ -455,7 +455,7 @@ static void compute_string_bbox( /* create a free type glyph string */ gfx_string gfx_string_create( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, FT_Face face, const char *text, int rotation, @@ -644,7 +644,7 @@ static int gfx_save_png( /* render grafics into png image */ int gfx_render_png( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, art_u32 width, art_u32 height, gfx_color_t background, @@ -926,7 +926,7 @@ int gfx_render_png( /* free memory used by nodes this will also remove memory required for associated paths and svcs ... but not for text strings */ int gfx_destroy( - gfx_canvas_t * canvas) + gfx_canvas_t *canvas) { gfx_node_t *next, *node = canvas->firstnode; @@ -1040,7 +1040,7 @@ typedef struct { #if PDF_CALC_DEBUG static void pdf_dump_calc( - gfx_node_t * node, + gfx_node_t *node, pdf_coords * g) { fprintf(stderr, "PDF CALC =============================\n"); @@ -1077,7 +1077,7 @@ static void pdf_dump_calc( static void pdf_rotate( pdf_coords * g, - pdf_point * p) + pdf_point *p) { double x2 = g->cos_r * p->x - g->sin_r * p->y; double y2 = g->sin_r * p->x + g->cos_r * p->y; @@ -1091,7 +1091,7 @@ static void pdf_rotate( static void pdf_calc( int page_height, - gfx_node_t * node, + gfx_node_t *node, pdf_coords * g) { pdf_point a, b, c; @@ -1385,8 +1385,8 @@ static void svg_write_color( } static void svg_get_dash( - gfx_node_t * node, - svg_dash * d) + gfx_node_t *node, + svg_dash *d) { double offset; int mult; @@ -1416,8 +1416,8 @@ static void svg_get_dash( } static int svg_dash_equal( - svg_dash * a, - svg_dash * b) + svg_dash *a, + svg_dash *b) { if (a->dash_enable != b->dash_enable) return 0; @@ -1431,7 +1431,7 @@ static int svg_dash_equal( static void svg_common_path_attributes( FILE * fp, - gfx_node_t * node) + gfx_node_t *node) { svg_dash dash_info; @@ -1469,7 +1469,7 @@ static int svg_path_straight_segment( double lastA, double currentA, double currentB, - gfx_node_t * node, + gfx_node_t *node, int segment_idx, int isx, char absChar, @@ -1501,7 +1501,7 @@ static int svg_path_straight_segment( static void svg_path( FILE * fp, - gfx_node_t * node, + gfx_node_t *node, int multi) { int i; @@ -1563,7 +1563,7 @@ static void svg_path( static void svg_multi_path( FILE * fp, - gfx_node_t ** nodeR) + gfx_node_t **nodeR) { /* optimize for multiple paths with the same color, penwidth, etc. */ int num = 1; @@ -1599,7 +1599,7 @@ static void svg_multi_path( static void svg_area( FILE * fp, - gfx_node_t * node) + gfx_node_t *node) { int i; double startX = 0, startY = 0; @@ -1645,7 +1645,7 @@ static void svg_area( static void svg_text( FILE * fp, - gfx_node_t * node) + gfx_node_t *node) { pdf_coords g; const char *fontname; @@ -1689,7 +1689,7 @@ static void svg_text( } int gfx_render_svg( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, art_u32 width, art_u32 height, gfx_color_t background, @@ -1786,7 +1786,7 @@ typedef struct eps_state { } eps_state; static void eps_set_color( - eps_state * state, + eps_state *state, gfx_color_t color) { #if USE_EPS_FAKE_ALPHA @@ -1812,8 +1812,8 @@ static void eps_set_color( } static int eps_add_font( - eps_state * state, - gfx_node_t * node) + eps_state *state, + gfx_node_t *node) { /* The fonts list could be postponed to the end using (atend), but let's be nice and have them in the header. */ @@ -1836,7 +1836,7 @@ static int eps_add_font( } static void eps_list_fonts( - eps_state * state, + eps_state *state, const char *dscName) { eps_font *ef; @@ -1863,7 +1863,7 @@ static void eps_list_fonts( } static void eps_define_fonts( - eps_state * state) + eps_state *state) { eps_font *ef; @@ -1885,7 +1885,7 @@ static void eps_define_fonts( } static int eps_prologue( - eps_state * state) + eps_state *state) { gfx_node_t *node; @@ -1926,7 +1926,7 @@ static int eps_prologue( } static void eps_clear_dash( - eps_state * state) + eps_state *state) { if (!state->has_dash) return; @@ -1935,8 +1935,8 @@ static void eps_clear_dash( } static void eps_write_linearea( - eps_state * state, - gfx_node_t * node) + eps_state *state, + gfx_node_t *node) { int i; FILE *fp = state->fp; @@ -2020,8 +2020,8 @@ static void eps_write_linearea( } static void eps_write_text( - eps_state * state, - gfx_node_t * node) + eps_state *state, + gfx_node_t *node) { FILE *fp = state->fp; const char *ps_font = afm_get_font_postscript_name(node->filename); @@ -2116,7 +2116,7 @@ static void eps_write_text( } static int eps_write_content( - eps_state * state) + eps_state *state) { gfx_node_t *node; @@ -2136,7 +2136,7 @@ static int eps_write_content( } int gfx_render_eps( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, art_u32 width, art_u32 height, gfx_color_t background, @@ -2217,8 +2217,8 @@ typedef struct pdf_state { } pdf_state; static void pdf_init_buffer( - pdf_state * state, - pdf_buffer * buf) + pdf_state *state, + pdf_buffer *buf) { int initial_size = 32; @@ -2245,7 +2245,7 @@ static void pdf_init_buffer( } static void pdf_put( - pdf_buffer * buf, + pdf_buffer *buf, const char *text, int len) { @@ -2273,7 +2273,7 @@ static void pdf_put( } static void pdf_put_char( - pdf_buffer * buf, + pdf_buffer *buf, char c) { if (buf->alloc_size >= buf->current_size + 1) { @@ -2287,20 +2287,20 @@ static void pdf_put_char( } static void pdf_puts( - pdf_buffer * buf, + pdf_buffer *buf, const char *text) { pdf_put(buf, text, strlen(text)); } static void pdf_indent( - pdf_buffer * buf) + pdf_buffer *buf) { pdf_puts(buf, "\t"); } static void pdf_putsi( - pdf_buffer * buf, + pdf_buffer *buf, const char *text) { pdf_indent(buf); @@ -2308,7 +2308,7 @@ static void pdf_putsi( } static void pdf_putint( - pdf_buffer * buf, + pdf_buffer *buf, int i) { char tmp[20]; @@ -2318,7 +2318,7 @@ static void pdf_putint( } static void pdf_putnumber( - pdf_buffer * buf, + pdf_buffer *buf, double d) { char tmp[50]; @@ -2328,7 +2328,7 @@ static void pdf_putnumber( } static void pdf_put_string_contents_wide( - pdf_buffer * buf, + pdf_buffer *buf, const afm_char * text) { const afm_char *p = text; @@ -2375,7 +2375,7 @@ static void pdf_put_string_contents_wide( } static void pdf_put_string_contents( - pdf_buffer * buf, + pdf_buffer *buf, const char *text) { #ifdef HAVE_MBSTOWCS @@ -2408,8 +2408,8 @@ static void pdf_put_string_contents( } static void pdf_init_object( - pdf_state * state, - pdf_buffer * buf) + pdf_state *state, + pdf_buffer *buf) { pdf_init_buffer(state, buf); buf->id = ++state->last_obj_id; @@ -2418,17 +2418,17 @@ static void pdf_init_object( } static void pdf_init_dict( - pdf_state * state, - pdf_buffer * buf) + pdf_state *state, + pdf_buffer *buf) { pdf_init_object(state, buf); buf->is_dict = 1; } static void pdf_set_color( - pdf_buffer * buf, + pdf_buffer *buf, gfx_color_t color, - gfx_color_t * current_color, + gfx_color_t *current_color, const char *op) { #if USE_PDF_FAKE_ALPHA @@ -2456,22 +2456,22 @@ static void pdf_set_color( } static void pdf_set_stroke_color( - pdf_buffer * buf, + pdf_buffer *buf, gfx_color_t color) { pdf_set_color(buf, color, &buf->state->stroke_color, "RG"); } static void pdf_set_fill_color( - pdf_buffer * buf, + pdf_buffer *buf, gfx_color_t color) { pdf_set_color(buf, color, &buf->state->fill_color, "rg"); } static pdf_font *pdf_find_font( - pdf_state * state, - gfx_node_t * node) + pdf_state *state, + gfx_node_t *node) { const char *ps_font = afm_get_font_postscript_name(node->filename); pdf_font *ef; @@ -2484,8 +2484,8 @@ static pdf_font *pdf_find_font( } static void pdf_add_font( - pdf_state * state, - gfx_node_t * node) + pdf_state *state, + gfx_node_t *node) { pdf_font *ef = pdf_find_font(state, node); @@ -2523,7 +2523,7 @@ static void pdf_add_font( } static void pdf_create_fonts( - pdf_state * state) + pdf_state *state) { gfx_node_t *node; @@ -2534,8 +2534,8 @@ static void pdf_create_fonts( } static void pdf_write_linearea( - pdf_state * state, - gfx_node_t * node) + pdf_state *state, + gfx_node_t *node) { int i; pdf_buffer *s = &state->graph_stream; @@ -2613,8 +2613,8 @@ static void pdf_write_linearea( static void pdf_write_matrix( - pdf_state * state, - gfx_node_t * node, + pdf_state *state, + gfx_node_t *node, pdf_coords * g, int useTM) { @@ -2637,8 +2637,8 @@ static void pdf_write_matrix( } static void pdf_write_text( - pdf_state * state, - gfx_node_t * node, + pdf_state *state, + gfx_node_t *node, int last_was_text, int next_is_text) { @@ -2688,7 +2688,7 @@ static void pdf_write_text( } static void pdf_write_content( - pdf_state * state) + pdf_state *state) { gfx_node_t *node; int last_was_text = 0, next_is_text; @@ -2709,7 +2709,7 @@ static void pdf_write_content( } static void pdf_init_document( - pdf_state * state) + pdf_state *state) { pdf_init_buffer(state, &state->pdf_header); pdf_init_dict(state, &state->catalog_obj); @@ -2726,7 +2726,7 @@ static void pdf_init_document( } static void pdf_setup_document( - pdf_state * state) + pdf_state *state) { const char *creator = "RRDtool " PACKAGE_VERSION " Tobias Oetiker, http://tobi.oetiker.ch"; @@ -2770,7 +2770,7 @@ static void pdf_setup_document( } static void pdf_write_string_to_file( - pdf_state * state, + pdf_state *state, const char *text) { fputs(text, state->fp); @@ -2778,8 +2778,8 @@ static void pdf_write_string_to_file( } static void pdf_write_buf_to_file( - pdf_state * state, - pdf_buffer * buf) + pdf_state *state, + pdf_buffer *buf) { char tmp[40]; @@ -2806,7 +2806,7 @@ static void pdf_write_buf_to_file( } static void pdf_write_to_file( - pdf_state * state) + pdf_state *state) { pdf_buffer *buf = state->first_buffer; int xref_pos; @@ -2839,7 +2839,7 @@ static void pdf_write_to_file( } static void pdf_free_resources( - pdf_state * state) + pdf_state *state) { pdf_buffer *buf = state->first_buffer; @@ -2858,7 +2858,7 @@ static void pdf_free_resources( } int gfx_render_pdf( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, art_u32 width, art_u32 height, gfx_color_t UNUSED(background), diff --git a/program/src/rrd_gfx.h b/program/src/rrd_gfx.h index dcfe48f2..dacdd694 100644 --- a/program/src/rrd_gfx.h +++ b/program/src/rrd_gfx.h @@ -61,7 +61,7 @@ gfx_canvas_t *gfx_new_canvas( /* create a new line */ gfx_node_t *gfx_new_line( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, double X0, double Y0, double X1, @@ -70,7 +70,7 @@ gfx_node_t *gfx_new_line( gfx_color_t color); gfx_node_t *gfx_new_dashed_line( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, double X0, double Y0, double X1, @@ -82,7 +82,7 @@ gfx_node_t *gfx_new_dashed_line( /* create a new area */ gfx_node_t *gfx_new_area( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, double X0, double Y0, double X1, @@ -93,18 +93,18 @@ gfx_node_t *gfx_new_area( /* add a point to a line or to an area */ int gfx_add_point( - gfx_node_t * node, + gfx_node_t *node, double x, double y); /* close current path so it ends at the same point as it started */ void gfx_close_path( - gfx_node_t * node); + gfx_node_t *node); /* create a text node */ gfx_node_t *gfx_new_text( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, double x, double y, gfx_color_t color, @@ -118,7 +118,7 @@ gfx_node_t *gfx_new_text( /* measure width of a text string */ double gfx_get_text_width( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, double start, char *font, double size, @@ -128,7 +128,7 @@ double gfx_get_text_width( /* save image to file */ int gfx_render( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, art_u32 width, art_u32 height, gfx_color_t background, @@ -137,18 +137,18 @@ int gfx_render( /* free memory used by nodes this will also remove memory required for node chain and associated material */ int gfx_destroy( - gfx_canvas_t * canvas); + gfx_canvas_t *canvas); /* PNG support*/ int gfx_render_png( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, art_u32 width, art_u32 height, gfx_color_t background, FILE * fo); double gfx_get_text_width_libart( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, double start, char *font, double size, @@ -158,7 +158,7 @@ double gfx_get_text_width_libart( /* SVG support */ int gfx_render_svg( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, art_u32 width, art_u32 height, gfx_color_t background, @@ -166,7 +166,7 @@ int gfx_render_svg( /* EPS support */ int gfx_render_eps( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, art_u32 width, art_u32 height, gfx_color_t background, @@ -174,7 +174,7 @@ int gfx_render_eps( /* PDF support */ int gfx_render_pdf( - gfx_canvas_t * canvas, + gfx_canvas_t *canvas, art_u32 width, art_u32 height, gfx_color_t background, diff --git a/program/src/rrd_graph.c b/program/src/rrd_graph.c index 51542104..f33cfc3d 100644 --- a/program/src/rrd_graph.c +++ b/program/src/rrd_graph.c @@ -164,7 +164,7 @@ gfx_color_t graph_col[] = /* default colors */ /* initialize with xtr(im,0); */ int xtr( - image_desc_t * im, + image_desc_t *im, time_t mytime) { static double pixie; @@ -178,7 +178,7 @@ int xtr( /* translate data values into y coordinates */ double ytr( - image_desc_t * im, + image_desc_t *im, double value) { static double pixie; @@ -306,7 +306,7 @@ enum text_prop_en text_prop_conv( #undef conv_if int im_free( - image_desc_t * im) + image_desc_t *im) { unsigned long i, ii; @@ -332,7 +332,7 @@ int im_free( /* find SI magnitude symbol for the given number*/ void auto_scale( - image_desc_t * im, /* image description */ + image_desc_t *im, /* image description */ double *value, char **symb_ptr, double *magfact) @@ -391,7 +391,7 @@ static const int si_symbcenter = 6; /* find SI magnitude symbol for the numbers on the y-axis*/ void si_unit( - image_desc_t * im /* image description */ + image_desc_t *im /* image description */ ) { @@ -426,7 +426,7 @@ void si_unit( /* move min and max values around to become sensible */ void expand_range( - image_desc_t * im) + image_desc_t *im) { double sensiblevalues[] = { 1000.0, 900.0, 800.0, 750.0, 700.0, 600.0, 500.0, 400.0, 300.0, 250.0, @@ -521,7 +521,7 @@ void expand_range( } void apply_gridfit( - image_desc_t * im) + image_desc_t *im) { if (isnan(im->minval) || isnan(im->maxval)) return; @@ -604,7 +604,7 @@ void reduce_data( time_t *end, /* ... by the application will be ... */ unsigned long *step, /* ... adjusted to represent reality */ unsigned long *ds_cnt, /* number of data sources in file */ - rrd_value_t ** data) + rrd_value_t **data) { /* two dimensional array containing the data */ int i, reduce_factor = ceil((double) (*step) / (double) cur_step); unsigned long col, dst_row, row_cnt, start_offset, end_offset, skiprows = @@ -772,7 +772,7 @@ void reduce_data( relevant rrds ... */ int data_fetch( - image_desc_t * im) + image_desc_t *im) { int i, ii; int skip; @@ -867,7 +867,7 @@ long find_var_wrapper( /* find gdes containing var*/ long find_var( - image_desc_t * im, + image_desc_t *im, char *key) { long ii; @@ -904,7 +904,7 @@ long lcd( /* run the rpn calculator on all the VDEF and CDEF arguments */ int data_calc( - image_desc_t * im) + image_desc_t *im) { int gdi; @@ -1102,7 +1102,7 @@ int data_calc( /* massage data so, that we get one value for each x coordinate in the graph */ int data_proc( - image_desc_t * im) + image_desc_t *im) { long i, ii; double pixstep = (double) (im->end - im->start) @@ -1261,49 +1261,58 @@ time_t find_first_time( struct tm tm; localtime_r(&start, &tm); + switch (baseint) { case TMT_SECOND: - tm.tm_sec -= tm.tm_sec % basestep; + tm. tm_sec -= tm.tm_sec % basestep; + break; case TMT_MINUTE: - tm.tm_sec = 0; - tm.tm_min -= tm.tm_min % basestep; + tm. tm_sec = 0; + tm. tm_min -= tm.tm_min % basestep; + break; case TMT_HOUR: - tm.tm_sec = 0; - tm.tm_min = 0; - tm.tm_hour -= tm.tm_hour % basestep; + tm. tm_sec = 0; + tm. tm_min = 0; + tm. tm_hour -= tm.tm_hour % basestep; + break; case TMT_DAY: /* we do NOT look at the basestep for this ... */ - tm.tm_sec = 0; - tm.tm_min = 0; - tm.tm_hour = 0; + tm. tm_sec = 0; + tm. tm_min = 0; + tm. tm_hour = 0; + break; case TMT_WEEK: /* we do NOT look at the basestep for this ... */ - tm.tm_sec = 0; - tm.tm_min = 0; - tm.tm_hour = 0; - tm.tm_mday -= tm.tm_wday - 1; /* -1 because we want the monday */ + tm. tm_sec = 0; + tm. tm_min = 0; + tm. tm_hour = 0; + tm. tm_mday -= tm.tm_wday - 1; /* -1 because we want the monday */ + if (tm.tm_wday == 0) - tm.tm_mday -= 7; /* we want the *previous* monday */ + tm. tm_mday -= 7; /* we want the *previous* monday */ + break; case TMT_MONTH: - tm.tm_sec = 0; - tm.tm_min = 0; - tm.tm_hour = 0; - tm.tm_mday = 1; - tm.tm_mon -= tm.tm_mon % basestep; + tm. tm_sec = 0; + tm. tm_min = 0; + tm. tm_hour = 0; + tm. tm_mday = 1; + tm. tm_mon -= tm.tm_mon % basestep; + break; case TMT_YEAR: - tm.tm_sec = 0; - tm.tm_min = 0; - tm.tm_hour = 0; - tm.tm_mday = 1; - tm.tm_mon = 0; - tm.tm_year -= (tm.tm_year + 1900) % basestep; + tm. tm_sec = 0; + tm. tm_min = 0; + tm. tm_hour = 0; + tm. tm_mday = 1; + tm. tm_mon = 0; + tm. tm_year -= ( + tm.tm_year + 1900) %basestep; } return mktime(&tm); @@ -1320,28 +1329,35 @@ time_t find_next_time( time_t madetime; localtime_r(¤t, &tm); + do { switch (baseint) { case TMT_SECOND: - tm.tm_sec += basestep; + tm. tm_sec += basestep; + break; case TMT_MINUTE: - tm.tm_min += basestep; + tm. tm_min += basestep; + break; case TMT_HOUR: - tm.tm_hour += basestep; + tm. tm_hour += basestep; + break; case TMT_DAY: - tm.tm_mday += basestep; + tm. tm_mday += basestep; + break; case TMT_WEEK: - tm.tm_mday += 7 * basestep; + tm. tm_mday += 7 * basestep; + break; case TMT_MONTH: - tm.tm_mon += basestep; + tm. tm_mon += basestep; + break; case TMT_YEAR: - tm.tm_year += basestep; + tm. tm_year += basestep; } madetime = mktime(&tm); } while (madetime == -1); /* this is necessary to skip impssible times @@ -1354,7 +1370,7 @@ time_t find_next_time( /* calculate values required for PRINT and GPRINT functions */ int print_calc( - image_desc_t * im, + image_desc_t *im, char ***prdata) { long i, ii, validsteps; @@ -1536,7 +1552,7 @@ int print_calc( /* place legends with color spots */ int leg_place( - image_desc_t * im) + image_desc_t *im) { /* graph labels */ int interleg = im->text_prop[TEXT_PROP_LEGEND].size * 2.0; @@ -1708,7 +1724,7 @@ int leg_place( int calc_horizontal_grid( - image_desc_t * im) + image_desc_t *im) { double range; double scaledrange; @@ -1804,7 +1820,7 @@ int calc_horizontal_grid( } int draw_horizontal_grid( - image_desc_t * im) + image_desc_t *im) { int i; double scaledstep; @@ -1946,7 +1962,7 @@ static int AlmostEqual2sComplement( /* logaritmic horizontal grid */ int horizontal_log_grid( - image_desc_t * im) + image_desc_t *im) { double yloglab[][10] = { {1.0, 10., 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, @@ -2174,7 +2190,7 @@ int horizontal_log_grid( void vertical_grid( - image_desc_t * im) + image_desc_t *im) { int xlab_sel; /* which sort of label and grid ? */ time_t ti, tilab, timajor; @@ -2291,7 +2307,7 @@ void vertical_grid( void axis_paint( - image_desc_t * im) + image_desc_t *im) { /* draw x and y axis */ /* gfx_new_line ( im->canvas, im->xorigin+im->xsize,im->yorigin, @@ -2321,7 +2337,7 @@ void axis_paint( } void grid_paint( - image_desc_t * im) + image_desc_t *im) { long i; int res = 0; @@ -2458,7 +2474,7 @@ void grid_paint( *****************************************************/ int lazy_check( - image_desc_t * im) + image_desc_t *im) { FILE *fd = NULL; int size = 1; @@ -2487,7 +2503,7 @@ int lazy_check( #ifdef WITH_PIECHART void pie_part( - image_desc_t * im, + image_desc_t *im, gfx_color_t color, double PieCenterX, double PieCenterY, @@ -2539,7 +2555,7 @@ void pie_part( #endif int graph_size_location( - image_desc_t * im, + image_desc_t *im, int elements #ifdef WITH_PIECHART , @@ -2737,7 +2753,7 @@ int graph_size_location( /* draw that picture thing ... */ int graph_paint( - image_desc_t * im, + image_desc_t *im, char ***calcpr) { int i, ii; @@ -3190,7 +3206,7 @@ int graph_paint( *****************************************************/ int gdes_alloc( - image_desc_t * im) + image_desc_t *im) { im->gdes_c++; @@ -3344,7 +3360,7 @@ int rrd_graph( } void rrd_graph_init( - image_desc_t * im) + image_desc_t *im) { unsigned int i; @@ -3439,7 +3455,7 @@ void rrd_graph_init( void rrd_graph_options( int argc, char *argv[], - image_desc_t * im) + image_desc_t *im) { int stroff; char *parsetime_error = NULL; @@ -3841,7 +3857,7 @@ void rrd_graph_options( } int rrd_graph_color( - image_desc_t * im, + image_desc_t *im, char *var, char *err, int optional) diff --git a/program/src/rrd_graph_helper.c b/program/src/rrd_graph_helper.c index 06a0ed1a..0c1c7d80 100644 --- a/program/src/rrd_graph_helper.c +++ b/program/src/rrd_graph_helper.c @@ -51,71 +51,71 @@ int rrd_parse_find_gf( const char *const, unsigned int *const, - graph_desc_t * const); + graph_desc_t *const); int rrd_parse_legend( const char *const, unsigned int *const, - graph_desc_t * const); + graph_desc_t *const); int rrd_parse_color( const char *const, - graph_desc_t * const); + graph_desc_t *const); int rrd_parse_CF( const char *const, unsigned int *const, - graph_desc_t * const, + graph_desc_t *const, enum cf_en *const); int rrd_parse_print( const char *const, unsigned int *const, - graph_desc_t * const, - image_desc_t * const); + graph_desc_t *const, + image_desc_t *const); int rrd_parse_shift( const char *const, unsigned int *const, - graph_desc_t * const, - image_desc_t * const); + graph_desc_t *const, + image_desc_t *const); int rrd_parse_xport( const char *const, unsigned int *const, - graph_desc_t * const, - image_desc_t * const); + graph_desc_t *const, + image_desc_t *const); int rrd_parse_PVHLAST( const char *const, unsigned int *const, - graph_desc_t * const, - image_desc_t * const); + graph_desc_t *const, + image_desc_t *const); int rrd_parse_make_vname( const char *const, unsigned int *const, - graph_desc_t * const, - image_desc_t * const); + graph_desc_t *const, + image_desc_t *const); int rrd_parse_find_vname( const char *const, unsigned int *const, - graph_desc_t * const, - image_desc_t * const); + graph_desc_t *const, + image_desc_t *const); int rrd_parse_def( const char *const, unsigned int *const, - graph_desc_t * const, - image_desc_t * const); + graph_desc_t *const, + image_desc_t *const); int rrd_parse_vdef( const char *const, unsigned int *const, - graph_desc_t * const, - image_desc_t * const); + graph_desc_t *const, + image_desc_t *const); int rrd_parse_cdef( const char *const, unsigned int *const, - graph_desc_t * const, - image_desc_t * const); + graph_desc_t *const, + image_desc_t *const); int rrd_parse_find_gf( const char *const line, unsigned int *const eaten, - graph_desc_t * const gdp) + graph_desc_t *const gdp) { char funcname[11], c1 = 0; int i = 0; @@ -207,7 +207,7 @@ int rrd_parse_find_gf( int rrd_parse_legend( const char *const line, unsigned int *const eaten, - graph_desc_t * const gdp) + graph_desc_t *const gdp) { int i; @@ -230,7 +230,7 @@ int rrd_parse_legend( int rrd_parse_color( const char *const string, - graph_desc_t * const gdp) + graph_desc_t *const gdp) { unsigned int r = 0, g = 0, b = 0, a = 0, i; @@ -273,7 +273,7 @@ int rrd_parse_color( int rrd_parse_CF( const char *const line, unsigned int *const eaten, - graph_desc_t * const gdp, + graph_desc_t *const gdp, enum cf_en *cf) { char symname[CF_NAM_SIZE]; @@ -308,8 +308,8 @@ int rrd_parse_CF( int rrd_parse_find_vname( const char *const line, unsigned int *const eaten, - graph_desc_t * const gdp, - image_desc_t * const im) + graph_desc_t *const gdp, + image_desc_t *const im) { char tmpstr[MAX_VNAME_LEN + 1]; int i; @@ -343,8 +343,8 @@ int rrd_parse_find_vname( int rrd_parse_print( const char *const line, unsigned int *const eaten, - graph_desc_t * const gdp, - image_desc_t * const im) + graph_desc_t *const gdp, + image_desc_t *const im) { /* vname:CF:format in case of DEF-based vname ** vname:CF:format in case of CDEF-based vname @@ -389,8 +389,8 @@ int rrd_parse_print( int rrd_parse_shift( const char *const line, unsigned int *const eaten, - graph_desc_t * const gdp, - image_desc_t * const im) + graph_desc_t *const gdp, + image_desc_t *const im) { int i; @@ -449,8 +449,8 @@ int rrd_parse_shift( int rrd_parse_xport( const char *const line, unsigned int *const eaten, - graph_desc_t * const gdp, - image_desc_t * const im) + graph_desc_t *const gdp, + image_desc_t *const im) { if ((gdp->vidx = rrd_parse_find_vname(line, eaten, gdp, im)) < 0) return 1; @@ -488,8 +488,8 @@ int rrd_parse_xport( int rrd_parse_PVHLAST( const char *const line, unsigned int *const eaten, - graph_desc_t * const gdp, - image_desc_t * const im) + graph_desc_t *const gdp, + image_desc_t *const im) { int i, j, k; int colorfound = 0; @@ -739,8 +739,8 @@ int rrd_parse_PVHLAST( int rrd_parse_make_vname( const char *const line, unsigned int *const eaten, - graph_desc_t * const gdp, - image_desc_t * const im) + graph_desc_t *const gdp, + image_desc_t *const im) { char tmpstr[MAX_VNAME_LEN + 10]; int i = 0; @@ -765,8 +765,8 @@ int rrd_parse_make_vname( int rrd_parse_def( const char *const line, unsigned int *const eaten, - graph_desc_t * const gdp, - image_desc_t * const im) + graph_desc_t *const gdp, + image_desc_t *const im) { int i = 0; char command[7]; /* step, start, end, reduce */ @@ -890,8 +890,8 @@ int rrd_parse_def( int rrd_parse_vdef( const char *const line, unsigned int *const eaten, - graph_desc_t * const gdp, - image_desc_t * const im) + graph_desc_t *const gdp, + image_desc_t *const im) { char tmpstr[MAX_VNAME_LEN + 1]; /* vname\0 */ int i = 0; @@ -928,8 +928,8 @@ int rrd_parse_vdef( int rrd_parse_cdef( const char *const line, unsigned int *const eaten, - graph_desc_t * const gdp, - image_desc_t * const im) + graph_desc_t *const gdp, + image_desc_t *const im) { dprintf("- parsing '%s'\n", &line[*eaten]); if (rrd_parse_make_vname(line, eaten, gdp, im)) @@ -947,7 +947,7 @@ int rrd_parse_cdef( void rrd_graph_script( int argc, char *argv[], - image_desc_t * const im, + image_desc_t *const im, int optno) { int i; diff --git a/program/src/rrd_hw.c b/program/src/rrd_hw.c index e432fa27..e8494161 100644 --- a/program/src/rrd_hw.c +++ b/program/src/rrd_hw.c @@ -27,7 +27,7 @@ int update_seasonal( unsigned long rra_idx, unsigned long ds_idx, unsigned short CDP_scratch_idx, - rrd_value_t * seasonal_coef); + rrd_value_t *seasonal_coef); int update_devpredict( rrd_t *rrd, unsigned long cdp_idx, @@ -40,7 +40,7 @@ int update_devseasonal( unsigned long rra_idx, unsigned long ds_idx, unsigned short CDP_scratch_idx, - rrd_value_t * seasonal_dev); + rrd_value_t *seasonal_dev); int update_failures( rrd_t *rrd, unsigned long cdp_idx, @@ -146,9 +146,9 @@ int lookup_seasonal( rrd_t *rrd, unsigned long rra_idx, unsigned long rra_start, - rrd_file_t * rrd_file, + rrd_file_t *rrd_file, unsigned long offset, - rrd_value_t ** seasonal_coef) + rrd_value_t **seasonal_coef) { unsigned long pos_tmp; @@ -205,7 +205,7 @@ int update_seasonal( unsigned long rra_idx, unsigned long ds_idx, unsigned short CDP_scratch_idx, - rrd_value_t * seasonal_coef) + rrd_value_t *seasonal_coef) { /* TODO: extract common if subblocks in the wake of I/O optimization */ rrd_value_t intercept, seasonal; @@ -342,7 +342,7 @@ int update_devseasonal( unsigned long rra_idx, unsigned long ds_idx, unsigned short CDP_scratch_idx, - rrd_value_t * seasonal_dev) + rrd_value_t *seasonal_dev) { rrd_value_t prediction = 0, seasonal_coef = DNAN; rra_def_t *current_rra = &(rrd->rra_def[rra_idx]); @@ -591,7 +591,7 @@ int apply_smoother( rrd_t *rrd, unsigned long rra_idx, unsigned long rra_start, - rrd_file_t * rrd_file) + rrd_file_t *rrd_file) { unsigned long i, j, k; unsigned long totalbytes; @@ -753,7 +753,7 @@ int apply_smoother( * seasonal, and seasonal deviation for the specified data source. */ void reset_aberrant_coefficients( rrd_t *rrd, - rrd_file_t * rrd_file, + rrd_file_t *rrd_file, unsigned long ds_idx) { unsigned long cdp_idx, rra_idx, i; @@ -823,7 +823,7 @@ void reset_aberrant_coefficients( } void init_hwpredict_cdp( - cdp_prep_t * cdp) + cdp_prep_t *cdp) { cdp->scratch[CDP_hw_intercept].u_val = DNAN; cdp->scratch[CDP_hw_last_intercept].u_val = DNAN; @@ -834,7 +834,7 @@ void init_hwpredict_cdp( } void init_seasonal_cdp( - cdp_prep_t * cdp) + cdp_prep_t *cdp) { cdp->scratch[CDP_hw_seasonal].u_val = DNAN; cdp->scratch[CDP_hw_last_seasonal].u_val = DNAN; @@ -849,7 +849,7 @@ int update_aberrant_CF( unsigned long rra_idx, unsigned long ds_idx, unsigned short CDP_scratch_idx, - rrd_value_t * seasonal_coef) + rrd_value_t *seasonal_coef) { rrd->cdp_prep[cdp_idx].scratch[CDP_scratch_idx].u_val = pdp_val; switch (current_cf) { @@ -895,7 +895,7 @@ unsigned long MyMod( /* a standard fixed-capacity FIF0 queue implementation * No overflow checking is performed. */ int queue_alloc( - FIFOqueue ** q, + FIFOqueue **q, int capacity) { *q = (FIFOqueue *) malloc(sizeof(FIFOqueue)); @@ -913,13 +913,13 @@ int queue_alloc( } int queue_isempty( - FIFOqueue * q) + FIFOqueue *q) { return (q->head % q->capacity == q->tail); } void queue_push( - FIFOqueue * q, + FIFOqueue *q, rrd_value_t value) { q->queue[(q->tail)++] = value; @@ -927,14 +927,14 @@ void queue_push( } rrd_value_t queue_pop( - FIFOqueue * q) + FIFOqueue *q) { q->head = q->head % q->capacity; return q->queue[(q->head)++]; } void queue_dealloc( - FIFOqueue * q) + FIFOqueue *q) { free(q->queue); free(q); diff --git a/program/src/rrd_hw.h b/program/src/rrd_hw.h index 06314b66..357cc402 100644 --- a/program/src/rrd_hw.h +++ b/program/src/rrd_hw.h @@ -13,7 +13,7 @@ int update_aberrant_CF( unsigned long rra_idx, unsigned long ds_idx, unsigned short CDP_scratch_idx, - rrd_value_t * seasonal_coef); + rrd_value_t *seasonal_coef); int create_hw_contingent_rras( rrd_t *rrd, unsigned short period, @@ -22,9 +22,9 @@ int lookup_seasonal( rrd_t *rrd, unsigned long rra_idx, unsigned long rra_start, - rrd_file_t * rrd_file, + rrd_file_t *rrd_file, unsigned long offset, - rrd_value_t ** seasonal_coef); + rrd_value_t **seasonal_coef); void erase_violations( rrd_t *rrd, unsigned long cdp_idx, @@ -33,10 +33,10 @@ int apply_smoother( rrd_t *rrd, unsigned long rra_idx, unsigned long rra_start, - rrd_file_t * rrd_file); + rrd_file_t *rrd_file); void reset_aberrant_coefficients( rrd_t *rrd, - rrd_file_t * rrd_file, + rrd_file_t *rrd_file, unsigned long ds_idx); void init_hwpredict_cdp( cdp_prep_t *); @@ -52,14 +52,14 @@ typedef struct FIFOqueue { } FIFOqueue; int queue_alloc( - FIFOqueue ** q, + FIFOqueue **q, int capacity); void queue_dealloc( - FIFOqueue * q); + FIFOqueue *q); void queue_push( - FIFOqueue * q, + FIFOqueue *q, rrd_value_t value); int queue_isempty( - FIFOqueue * q); + FIFOqueue *q); rrd_value_t queue_pop( - FIFOqueue * q); + FIFOqueue *q); diff --git a/program/src/rrd_info.c b/program/src/rrd_info.c index 4582e2a8..d0d9db5b 100644 --- a/program/src/rrd_info.c +++ b/program/src/rrd_info.c @@ -136,7 +136,7 @@ info_t *rrd_info_r( { char *buffer = NULL; - rpn_compact2str((rpn_cdefds_t *) & (rrd.ds_def[i].par[DS_cdef]), + rpn_compact2str((rpn_cdefds_t *) &(rrd.ds_def[i].par[DS_cdef]), rrd.ds_def, &buffer); info.u_str = buffer; cd = info_push(cd, diff --git a/program/src/rrd_open.c b/program/src/rrd_open.c index e7eed20a..db4715b3 100644 --- a/program/src/rrd_open.c +++ b/program/src/rrd_open.c @@ -240,7 +240,7 @@ rrd_file_t *rrd_open( /* Close a reference to an rrd_file. */ int rrd_close( - rrd_file_t * rrd_file) + rrd_file_t *rrd_file) { int ret = 0; @@ -256,7 +256,7 @@ int rrd_close( /* Set position of rrd_file. */ off_t rrd_seek( - rrd_file_t * rrd_file, + rrd_file_t *rrd_file, off_t off, int whence) { @@ -281,7 +281,7 @@ off_t rrd_seek( /* Get current position in rrd_file. */ off_t rrd_tell( - rrd_file_t * rrd_file) + rrd_file_t *rrd_file) { return rrd_file->pos; } @@ -289,7 +289,7 @@ off_t rrd_tell( /* read count bytes into buffer buf, starting at rrd_file->pos. * Returns the number of bytes read. */ ssize_t rrd_read( - rrd_file_t * rrd_file, + rrd_file_t *rrd_file, void *buf, size_t count) { @@ -310,7 +310,7 @@ ssize_t rrd_read( /* write count bytes from buffer buf to the current position * rrd_file->pos of rrd_file->fd. */ ssize_t rrd_write( - rrd_file_t * rrd_file, + rrd_file_t *rrd_file, const void *buf, size_t count) { @@ -330,7 +330,7 @@ ssize_t rrd_write( /* flush all data pending to be written to FD. */ void rrd_flush( - rrd_file_t * rrd_file) + rrd_file_t *rrd_file) { if (fdatasync(rrd_file->fd) != 0) { rrd_set_error("flushing fd %d: %s", rrd_file->fd, diff --git a/program/src/rrd_rpncalc.c b/program/src/rrd_rpncalc.c index d1ab0dea..9078b300 100644 --- a/program/src/rrd_rpncalc.c +++ b/program/src/rrd_rpncalc.c @@ -19,8 +19,8 @@ int tzoffset( time_t); /* used to implement LTIME */ short rpn_compact( - rpnp_t * rpnp, - rpn_cdefds_t ** rpnc, + rpnp_t *rpnp, + rpn_cdefds_t **rpnc, short *count) { short i; @@ -61,7 +61,7 @@ short rpn_compact( } rpnp_t *rpn_expand( - rpn_cdefds_t * rpnc) + rpn_cdefds_t *rpnc) { short i; rpnp_t *rpnp; @@ -93,8 +93,8 @@ rpnp_t *rpn_expand( * str: out string, memory is allocated by the function, must be freed by the * the caller */ void rpn_compact2str( - rpn_cdefds_t * rpnc, - ds_def_t * ds_def, + rpn_cdefds_t *rpnc, + ds_def_t *ds_def, char **str) { unsigned short i, offset = 0; @@ -278,8 +278,8 @@ long lookup_DS( rpnp_t *rpn_parse( void *key_hash, const char *const expr_const, - long (*lookup) (void *, - char *)) + long (*lookup) (void *, + char *)) { int pos = 0; char *expr; @@ -394,7 +394,7 @@ rpnp_t *rpn_parse( } void rpnstack_init( - rpnstack_t * rpnstack) + rpnstack_t *rpnstack) { rpnstack->s = NULL; rpnstack->dc_stacksize = 0; @@ -402,7 +402,7 @@ void rpnstack_init( } void rpnstack_free( - rpnstack_t * rpnstack) + rpnstack_t *rpnstack) { if (rpnstack->s != NULL) free(rpnstack->s); @@ -434,10 +434,10 @@ static int rpn_compare_double( * 0 on success */ short rpn_calc( - rpnp_t * rpnp, - rpnstack_t * rpnstack, + rpnp_t *rpnp, + rpnstack_t *rpnstack, long data_idx, - rrd_value_t * output, + rrd_value_t *output, int output_idx) { int rpi; diff --git a/program/src/rrd_rpncalc.h b/program/src/rrd_rpncalc.h index 516718c9..cc751361 100644 --- a/program/src/rrd_rpncalc.h +++ b/program/src/rrd_rpncalc.h @@ -46,9 +46,9 @@ typedef struct rpnstack_t { } rpnstack_t; void rpnstack_init( - rpnstack_t * rpnstack); + rpnstack_t *rpnstack); void rpnstack_free( - rpnstack_t * rpnstack); + rpnstack_t *rpnstack); void parseCDEF_DS( const char *def, @@ -59,14 +59,14 @@ long lookup_DS( char *ds_name); short rpn_compact( - rpnp_t * rpnp, - rpn_cdefds_t ** rpnc, + rpnp_t *rpnp, + rpn_cdefds_t **rpnc, short *count); rpnp_t *rpn_expand( - rpn_cdefds_t * rpnc); + rpn_cdefds_t *rpnc); void rpn_compact2str( - rpn_cdefds_t * rpnc, - ds_def_t * ds_def, + rpn_cdefds_t *rpnc, + ds_def_t *ds_def, char **str); rpnp_t *rpn_parse( void *key_hash, @@ -74,10 +74,10 @@ rpnp_t *rpn_parse( long (*lookup) (void *, char *)); short rpn_calc( - rpnp_t * rpnp, - rpnstack_t * rpnstack, + rpnp_t *rpnp, + rpnstack_t *rpnstack, long data_idx, - rrd_value_t * output, + rrd_value_t *output, int output_idx); #endif diff --git a/program/src/rrd_tool.h b/program/src/rrd_tool.h index 020ff40e..e888c1f5 100644 --- a/program/src/rrd_tool.h +++ b/program/src/rrd_tool.h @@ -124,7 +124,7 @@ extern "C" { unsigned long *step, unsigned long *ds_cnt, char ***ds_namv, - rrd_value_t ** data); + rrd_value_t **data); void rrd_free( rrd_t *rrd); @@ -138,23 +138,23 @@ extern "C" { rrd_t *rrd, unsigned rdwr); int rrd_close( - rrd_file_t * rrd_file); + rrd_file_t *rrd_file); ssize_t rrd_read( - rrd_file_t * rrd_file, + rrd_file_t *rrd_file, void *buf, size_t count); ssize_t rrd_write( - rrd_file_t * rrd_file, + rrd_file_t *rrd_file, const void *buf, size_t count); void rrd_flush( - rrd_file_t * rrd_file); + rrd_file_t *rrd_file); off_t rrd_seek( - rrd_file_t * rrd_file, + rrd_file_t *rrd_file, off_t off, int whence); off_t rrd_tell( - rrd_file_t * rrd_file); + rrd_file_t *rrd_file); int readfile( const char *file, char **buffer, diff --git a/program/src/rrd_update.c b/program/src/rrd_update.c index c1849f39..a34da715 100644 --- a/program/src/rrd_update.c +++ b/program/src/rrd_update.c @@ -551,6 +551,7 @@ int _rrd_update( } current_time = mktime(&ds_tv.tm) + ds_tv.offset; + current_time_usec = 0; /* FIXME: how to handle usecs here ? */ } else if (strcmp(updvals[0], "N") == 0) { diff --git a/program/src/rrd_xport.c b/program/src/rrd_xport.c index 10c020f0..ac2295bc 100644 --- a/program/src/rrd_xport.c +++ b/program/src/rrd_xport.c @@ -51,7 +51,7 @@ int rrd_xport( * will be changed to represent reality */ unsigned long *col_cnt, /* number of data columns in the result */ char ***legend_v, /* legend entries */ - rrd_value_t ** data) + rrd_value_t **data) { /* two dimensional array containing the data */ image_desc_t im; @@ -159,7 +159,7 @@ int rrd_xport( int rrd_xport_fn( - image_desc_t * im, + image_desc_t *im, time_t *start, time_t *end, /* which time frame do you want ? * will be changed to represent reality */ @@ -167,7 +167,7 @@ int rrd_xport_fn( * will be changed to represent reality */ unsigned long *col_cnt, /* number of data columns in the result */ char ***legend_v, /* legend entries */ - rrd_value_t ** data) + rrd_value_t **data) { /* two dimensional array containing the data */ int i = 0, j = 0; diff --git a/program/win32/config.h b/program/win32/config.h index 965d5252..9d2603ea 100644 --- a/program/win32/config.h +++ b/program/win32/config.h @@ -37,14 +37,14 @@ #define finite _finite #define snprintf _snprintf #define vsnprintf _vsnprintf -#define strftime strftime_ +#define strftime strftime_ #define NO_NULL_REALLOC 1 #if NO_NULL_REALLOC # define rrd_realloc(a,b) ( (a) == NULL ? malloc( (b) ) : realloc( (a) , (b) )) #else # define rrd_realloc(a,b) realloc((a), (b)) -#endif +#endif /* Vertical label angle: 90.0 (default) or 270.0 */ #define RRDGRAPH_YLEGEND_ANGLE 90.0 @@ -56,5 +56,4 @@ /* #define DEBUG 1 */ -#endif /* CONFIG_H */ - +#endif /* CONFIG_H */