* Add (remote) dump support to rrdcached <Tobias Hintze>
+* Constify argv argument to library functions
+ Without this users of library function that want to pass in const strings need to duplicate them to avoid compiler warnings
+
RRDtool 1.8.0 - 2022-03-13
==========================
extern void rrd_freemem(void *mem);
extern int luaopen_rrd (lua_State * L);
-typedef int (*RRD_FUNCTION)(int, char **);
-typedef rrd_info_t *(RRD_FUNCTION_V)(int, char **);
+typedef int (*RRD_FUNCTION)(int, const char **);
+typedef rrd_info_t *(RRD_FUNCTION_V)(int, const char **);
/**********************************************************/
rrd_clear_error();
}
-static char **make_argv(const char *cmd, lua_State * L)
+static const char **make_argv(const char *cmd, lua_State * L)
{
- char **argv;
+ const char **argv;
int i;
int argc = lua_gettop(L) + 1;
luaL_error(L, "Can't allocate memory for arguments array", cmd);
/* fprintf(stderr, "Args:\n"); */
- argv[0] = (char *) cmd; /* Dummy arg. Cast to (char *) because rrd */
- /* functions don't expect (const * char) */
+ argv[0] = cmd;
/* fprintf(stderr, "%s\n", argv[0]); */
for (i=1; i<argc; i++) {
/* accepts string or number */
if (lua_isstring(L, i) || lua_isnumber(L, i)) {
- if (!(argv[i] = (char *) lua_tostring (L, i))) {
+ if (!(argv[i] = lua_tostring (L, i))) {
/* raise an error and never return */
luaL_error(L, "%s - error duplicating string area for arg #%d",
cmd, i);
static int
rrd_common_call (lua_State *L, const char *cmd, RRD_FUNCTION rrd_function)
{
- char **argv;
+ const char **argv;
int argc = lua_gettop(L) + 1;
argv = make_argv(cmd, L);
static int
lua_rrd_infocall(lua_State *L, const char *cmd, RRD_FUNCTION_V rrd_function)
{
- char **argv;
+ const char **argv;
rrd_info_t *p, *data;
int argc = lua_gettop(L) + 1;
lua_rrd_fetch (lua_State * L)
{
int argc = lua_gettop(L) + 1;
- char **argv = make_argv("fetch", L);
+ const char **argv = make_argv("fetch", L);
unsigned long i, j, step, ds_cnt;
rrd_value_t *data, *p;
char **names;
{
time_t first;
int argc = lua_gettop(L) + 1;
- char **argv = make_argv("first", L);
+ const char **argv = make_argv("first", L);
reset_rrd_state();
first = rrd_first(argc, argv);
free(argv);
{
time_t last;
int argc = lua_gettop(L) + 1;
- char **argv = make_argv("last", L);
+ const char **argv = make_argv("last", L);
reset_rrd_state();
last = rrd_last(argc, argv);
free(argv);
lua_rrd_graph (lua_State * L)
{
int argc = lua_gettop(L) + 1;
- char **argv = make_argv("last", L);
+ const char **argv = make_argv("last", L);
char **calcpr;
int i, xsize, ysize;
double ymin, ymax;
strcpy(argv[i+1],handle); \
} \
rrd_clear_error();\
- RETVAL=name(items+1,argv); \
+ RETVAL = name(items + 1, (const char **)argv); \
for (i=0; i < items; i++) {\
- free(argv[i+1]);\
+ free((void *)argv[i+1]);\
} \
- free(argv);\
+ free((void *)argv);\
\
if (rrd_test_error()) XSRETURN_UNDEF;
strcpy(argv[i+1],handle); \
} \
rrd_clear_error(); \
- data=name(items+1, argv); \
+ data = name(items + 1, (const char **)argv); \
for (i=0; i < items; i++) { \
- free(argv[i+1]); \
+ free((void *)argv[i+1]); \
} \
- free(argv); \
+ free((void *)argv); \
if (rrd_test_error()) XSRETURN_UNDEF; \
hash = newHV(); \
save=data; \
/* Check the eval first */
if (SvTRUE(ERRSV)) {
rrd_set_error("perl callback failed: %s",SvPV_nolen(ERRSV));
- POPs; /* there is undef on top of the stack when there is an error
+ (void)POPs; /* there is undef on top of the stack when there is an error
and call_sv was initiated with G_EVAL|G_SCALER */
goto error_out;
}
#ifdef HAVE_RRD_GRAPH
-SV *
+void
rrd_graph(...)
PROTOTYPE: @
PREINIT:
strcpy(argv[i+1],handle);
}
rrd_clear_error();
- rrd_graph(items+1,argv,&calcpr,&xsize,&ysize,NULL,&ymin,&ymax);
+ rrd_graph(items+1,(const char **)argv,&calcpr,&xsize,&ysize,NULL,&ymin,&ymax);
for (i=0; i < items; i++) {
free(argv[i+1]);
}
#endif /* HAVE_RRD_GRAPH */
-SV *
+void
rrd_fetch(...)
PROTOTYPE: @
PREINIT:
strcpy(argv[i+1],handle);
}
rrd_clear_error();
- rrd_fetch(items+1,argv,&start,&end,&step,&ds_cnt,&ds_namv,&data);
+ rrd_fetch(items+1,(const char **)argv,&start,&end,&step,&ds_cnt,&ds_namv,&data);
for (i=0; i < items; i++) {
free(argv[i+1]);
}
PUSHs(sv_2mortal(newRV_noinc((SV*)names)));
PUSHs(sv_2mortal(newRV_noinc((SV*)retar)));
-SV *
+void
rrd_fetch_cb_register(cb)
SV * cb
CODE:
SvSetSV(rrd_fetch_cb_svptr,cb);
rrd_fetch_cb_register(rrd_fetch_cb_wrapper);
-SV *
+void
rrd_times(start, end)
char *start
char *end
PUSHs(sv_2mortal(newSVuv(start_tmp)));
PUSHs(sv_2mortal(newSVuv(end_tmp)));
-int
+void
rrd_xport(...)
PROTOTYPE: @
PREINIT:
strcpy(argv[i+1],handle);
}
rrd_clear_error();
- rrd_xport(items+1,argv,&xsize,&start,&end,&step,&col_cnt,&legend_v,&data);
+ rrd_xport(items+1,(const char **)argv,&xsize,&start,&end,&step,&col_cnt,&legend_v,&data);
for (i=0; i < items; i++) {
free(argv[i+1]);
}
OUTPUT:
RETVAL
-SV*
+void
rrd_list(...)
PROTOTYPE: @
PREINIT:
char **argv;
AV *list;
PPCODE:
- argv = (char **) malloc((items+1)*sizeof(char *));
+ argv = malloc((items+1)*sizeof(char *));
argv[0] = "dummy";
for (i = 0; i < items; i++) {
rrd_clear_error();
- data = rrd_list(items+1, argv);
+ data = rrd_list(items+1, (const char **)argv);
for (i=0; i < items; i++) {
free(argv[i+1]);
* @return Zero if the function succeeds, otherwise -1
*/
static int
-convert_args(char *command, PyObject *args, char ***rrdtool_argv, int *rrdtool_argc)
+convert_args(char *command, PyObject *args, const char ***rrdtool_argv, int *rrdtool_argc)
{
PyObject *o, *lo;
int i, j, args_count, argv_count, element_count;
}
}
- *rrdtool_argv = PyMem_New(char *, element_count + 1);
+ *rrdtool_argv = PyMem_New(const char *, element_count + 1);
if (*rrdtool_argv == NULL)
return -1;
* Destroy argument vector.
*/
static void
-destroy_args(char ***rrdtool_argv)
+destroy_args(const char ***rrdtool_argv)
{
PyMem_Del(*rrdtool_argv);
*rrdtool_argv = NULL;
static PyObject *
_rrdtool_create(PyObject *Py_UNUSED(self), PyObject *args)
{
- char **rrdtool_argv = NULL;
+ const char **rrdtool_argv = NULL;
int rrdtool_argc = 0;
PyObject *ret;
int status;
static PyObject *
_rrdtool_dump(PyObject *Py_UNUSED(self), PyObject *args)
{
- char **rrdtool_argv = NULL;
+ const char **rrdtool_argv = NULL;
int rrdtool_argc = 0;
PyObject *ret;
int status;
static PyObject *
_rrdtool_update(PyObject *Py_UNUSED(self), PyObject *args)
{
- char **rrdtool_argv = NULL;
+ const char **rrdtool_argv = NULL;
int rrdtool_argc = 0;
PyObject *ret;
int status;
static PyObject *
_rrdtool_updatev(PyObject *Py_UNUSED(self), PyObject *args)
{
- char **rrdtool_argv = NULL;
+ const char **rrdtool_argv = NULL;
int rrdtool_argc = 0;
PyObject *ret;
rrd_info_t *data;
static PyObject *
_rrdtool_fetch(PyObject *Py_UNUSED(self), PyObject *args)
{
- char **rrdtool_argv = NULL;
+ const char **rrdtool_argv = NULL;
int rrdtool_argc = 0;
PyObject *ret, *range_tup, *dsnam_tup, *data_list, *t;
rrd_value_t *data, *datai, dv;
static PyObject *
_rrdtool_flushcached(PyObject *Py_UNUSED(self), PyObject *args)
{
- char **rrdtool_argv = NULL;
+ const char **rrdtool_argv = NULL;
int rrdtool_argc = 0;
PyObject *ret;
int status;
static PyObject *
_rrdtool_graph(PyObject *Py_UNUSED(self), PyObject *args)
{
- char **rrdtool_argv = NULL;
+ const char **rrdtool_argv = NULL;
int rrdtool_argc = 0;
PyObject *ret;
int xsize, ysize, i, status;
static PyObject *
_rrdtool_graphv(PyObject *Py_UNUSED(self), PyObject *args)
{
- char **rrdtool_argv = NULL;
+ const char **rrdtool_argv = NULL;
int rrdtool_argc = 0;
PyObject *ret;
rrd_info_t *data;
static PyObject *
_rrdtool_xport(PyObject *Py_UNUSED(self), PyObject *args)
{
- char **rrdtool_argv = NULL;
+ const char **rrdtool_argv = NULL;
int rrdtool_argc = 0;
PyObject *ret;
int xsize, status;
static PyObject *
_rrdtool_list(PyObject *Py_UNUSED(self), PyObject *args)
{
- char **rrdtool_argv = NULL;
+ const char **rrdtool_argv = NULL;
int rrdtool_argc = 0;
PyObject *ret, *str;
char *data, *ptr, *end;
static PyObject *
_rrdtool_tune(PyObject *Py_UNUSED(self), PyObject *args)
{
- char **rrdtool_argv = NULL;
+ const char **rrdtool_argv = NULL;
int rrdtool_argc = 0;
PyObject *ret;
int status;
static PyObject *
_rrdtool_first(PyObject *Py_UNUSED(self), PyObject *args)
{
- char **rrdtool_argv = NULL;
+ const char **rrdtool_argv = NULL;
int rrdtool_argc = 0;
PyObject *ret;
int ts;
static PyObject *
_rrdtool_last(PyObject *Py_UNUSED(self), PyObject *args)
{
- char **rrdtool_argv = NULL;
+ const char **rrdtool_argv = NULL;
int rrdtool_argc = 0;
PyObject *ret;
int ts;
static PyObject *
_rrdtool_resize(PyObject *Py_UNUSED(self), PyObject *args)
{
- char **rrdtool_argv = NULL;
+ const char **rrdtool_argv = NULL;
int rrdtool_argc = 0;
PyObject *ret;
int status;
static PyObject *
_rrdtool_info(PyObject *Py_UNUSED(self), PyObject *args)
{
- char **rrdtool_argv = NULL;
+ const char **rrdtool_argv = NULL;
int rrdtool_argc = 0;
PyObject *ret;
rrd_info_t *data;
static PyObject *
_rrdtool_lastupdate(PyObject *Py_UNUSED(self), PyObject *args)
{
- char **rrdtool_argv = NULL;
+ const char **rrdtool_argv = NULL;
int rrdtool_argc = 0;
PyObject *ret, *ds_dict, *lastupd;
int status;
typedef struct string_arr_t {
int len;
- char **strings;
+ const char **strings;
} string_arr;
VALUE mRRD;
typedef int (
*RRDFUNC) (
int argc,
- char **argv);
+ const char **argv);
typedef rrd_info_t *(
*RRDINFOFUNC) (
int argc,
- char **argv);
+ const char **argv);
#define RRD_CHECK_ERROR \
if (rrd_test_error()) \
/* skip dummy first entry */
for (i = 1; i < a.len; i++) {
- free(a.strings[i]);
+ free((void *)a.strings[i]);
}
- free(a.strings);
+ free((void *)a.strings);
}
void reset_rrd_state(
#include <stdlib.h>
#include "../../src/rrd_tool.h"
#include "../../src/rrd_format.h"
+#include "../../src/unused.h"
/* support pre-8.4 tcl */
* Hence, we need to do some preparation before
* calling the rrd library functions.
*/
-static char **getopt_init(
+static const char **getopt_init(
int argc,
CONST84 char *argv[])
{
- char **argv2;
+ const char **argv2;
int i;
argv2 = calloc(argc, sizeof(char *));
for (i = 0; i < argc; i++) {
- argv2[i] = strdup(argv[i]);
+ argv2[i] = argv[i];
}
return argv2;
}
static void getopt_cleanup(
- int argc,
- char **argv2)
+ int UNUSED(argc),
+ const char **argv2)
{
- int i;
-
- for (i = 0; i < argc; i++) {
- if (argv2[i] != NULL) {
- free(argv2[i]);
- }
- }
- free(argv2);
+ free((void *)argv2);
}
static void getopt_free_element(
- char *argv2[],
+ const char *argv2[],
int argn)
{
if (argv2[argn] != NULL) {
- free(argv2[argn]);
argv2[argn] = NULL;
}
}
static void getopt_squieeze(
int *argc,
- char *argv2[])
+ const char *argv2[])
{
int i, null_i = 0, argc_tmp = *argc;
CONST84 char *argv[])
{
int argv_i;
- char **argv2;
+ const char **argv2;
char *parsetime_error = NULL;
time_t last_up = time(NULL) - 10;
long int long_tmp;
return TCL_ERROR;
}
- rrd_flushcached(argc, (char**)argv);
+ rrd_flushcached(argc, argv);
if (rrd_test_error()) {
Tcl_AppendResult(interp, "RRD Error: ",
CONST84 char *argv[])
{
int argv_i;
- char **argv2, *template = NULL;
+ const char **argv2, *template = NULL;
argv2 = getopt_init(argc, argv);
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]);
+ template = argv2[argv_i];
getopt_free_element(argv2, argv_i - 1);
getopt_free_element(argv2, argv_i);
} else if (!strcmp(argv2[argv_i], "--")) {
} 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 (argc < 2) {
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, (const char **)argv2 + 2);
- if (template != NULL) {
- free(template);
- }
getopt_cleanup(argc, argv2);
if (rrd_test_error()) {
{
int status = TCL_OK;
rrd_info_t *data;
- char **argv2;
/* TODO: support for rrdcached */
if (argc != 2) {
return TCL_ERROR;
}
- argv2 = getopt_init(argc, argv);
-
- data = rrd_info_r(argv2[1]);
+ data = rrd_info_r(argv[1]);
if (data) {
Tcl_SetObjResult(interp, convert_info(data));
status = TCL_ERROR;
}
- getopt_cleanup(argc, argv2);
return status;
}
CONST84 char *argv[])
{
time_t last_update;
- char **argv2;
char **ds_namv;
char **last_ds;
char s[30];
return TCL_ERROR;
}
- argv2 = getopt_init(argc, argv);
- if (rrd_lastupdate_r(argv2[1], &last_update,
+ if (rrd_lastupdate_r(argv[1], &last_update,
&ds_cnt, &ds_namv, &last_ds) == 0) {
listPtr = Tcl_GetObjResult(interp);
for (i = 0; i < ds_cnt; i++) {
free(ds_namv);
}
}
- getopt_cleanup(argc, argv2);
return TCL_OK;
}
char **ds_namv;
Tcl_Obj *listPtr;
char s[30];
- char **argv2;
- argv2 = getopt_init(argc, argv);
- if (rrd_fetch(argc, argv2, &start, &end, &step,
+ if (rrd_fetch(argc, argv, &start, &end, &step,
&ds_cnt, &ds_namv, &data) != -1) {
datai = data;
listPtr = Tcl_GetObjResult(interp);
free(ds_namv);
free(data);
}
- getopt_cleanup(argc, argv2);
if (rrd_test_error()) {
Tcl_AppendResult(interp, "RRD Error: ",
int rc, xsize, ysize;
double ymin, ymax;
char dimensions[50];
- char **argv2;
+ const char **argv2;
CONST84 char *save;
/*
int argc,
CONST84 char *argv[])
{
- char **argv2;
-
- argv2 = getopt_init(argc, argv);
- rrd_tune(argc, argv2);
- getopt_cleanup(argc, argv2);
+ rrd_tune(argc, argv);
if (rrd_test_error()) {
Tcl_AppendResult(interp, "RRD Error: ",
int argc,
CONST84 char *argv[])
{
- char **argv2;
-
- argv2 = getopt_init(argc, argv);
- rrd_resize(argc, argv2);
- getopt_cleanup(argc, argv2);
+ rrd_resize(argc, argv);
if (rrd_test_error()) {
Tcl_AppendResult(interp, "RRD Error: ",
int argc,
CONST84 char *argv[])
{
- char **argv2;
-
- argv2 = getopt_init(argc, argv);
- rrd_restore(argc, argv2);
- getopt_cleanup(argc, argv2);
+ rrd_restore(argc, argv);
if (rrd_test_error()) {
Tcl_AppendResult(interp, "RRD Error: ",
#define options_argv(i) \
((i) < options->argc ? options->argv[i] : NULL)
-void optparse_init(struct optparse *options, int argc, char **argv)
+void optparse_init(struct optparse *options, int argc, const char **argv)
{
options->argv = argv;
options->argc = argc;
static void
permute(struct optparse *options, int index)
{
- char *nonoption = options->argv[index];
+ const char *nonoption = options->argv[index];
for (int i = index; i < options->optind - 1; i++)
options->argv[i] = options->argv[i + 1];
options->argv[options->optind - 1] = nonoption;
options->errmsg[0] = '\0';
options->optopt = 0;
options->optarg = NULL;
- char *option = options_argv(options->optind);
+ const char *option = options_argv(options->optind);
if (option == NULL) {
return -1;
} else if (is_dashdash(option)) {
option += options->subopt + 1;
options->optopt = option[0];
int type = argtype(optstring, option[0]);
- char *next = options_argv(options->optind + 1);
+ const char *next = options_argv(options->optind + 1);
switch (type) {
case -1:
opterror(options, "invalid option -- '%c'", option[0]);
return 0;
}
-char *optparse_arg(struct optparse *options)
+const char *optparse_arg(struct optparse *options)
{
options->subopt = 0;
- char *option = options->argv[options->optind];
+ const char *option = options->argv[options->optind];
if (option != NULL)
options->optind++;
return option;
int *longindex)
{
// printf("%i < %i\n",options->optind,options->argc);
- char *option = options_argv(options->optind);
+ const char *option = options_argv(options->optind);
if (option == NULL) {
return -1;
} else if (is_dashdash(option)) {
*/
struct optparse {
- char **argv;
+ const char **argv;
int argc;
int permute;
int optind;
/**
* Initializes the parser state.
*/
-void optparse_init(struct optparse *options, int argc, char **argv);
+void optparse_init(struct optparse *options, int argc, const char **argv);
/**
* Read the next option in the argv array.
* subcommand returned by optparse_arg(). This function allows you to
* ignore the value of optind.
*/
-char *optparse_arg(struct optparse *options);
+const char *optparse_arg(struct optparse *options);
#endif
/* main function blocks */
int rrd_create(
int,
- char **);
+ const char **);
rrd_info_t *rrd_info(
int,
- char **);
+ const char **);
rrd_info_t *rrd_info_push(
rrd_info_t *,
char *,
rrd_info_t *);
char *rrd_list(
int,
- char **);
+ const char **);
char *rrd_list_r(
int,
- char *dirname);
+ const char *dirname);
int rrd_update(
int,
- char **);
+ const char **);
rrd_info_t *rrd_update_v(
int,
- char **);
+ const char **);
int rrd_graph(
int,
- char **,
+ const char **,
char ***,
int *,
int *,
double *);
rrd_info_t *rrd_graph_v(
int,
- char **);
+ const char **);
int rrd_fetch(
int,
- char **,
+ const char **,
time_t *,
time_t *,
unsigned long *,
rrd_value_t **);
int rrd_restore(
int,
- char **);
+ const char **);
int rrd_dump(
int,
- char **);
+ const char **);
int rrd_tune(
int,
- char **);
+ const char **);
time_t rrd_last(
int,
- char **);
+ const char **);
int rrd_lastupdate(
int argc,
- char **argv);
+ const char **argv);
time_t rrd_first(
int,
- char **);
+ const char **);
int rrd_resize(
int,
- char **);
+ const char **);
char *rrd_strversion(
void);
double rrd_version(
void);
int rrd_xport(
int,
- char **,
+ const char **,
int *,
time_t *,
time_t *,
rrd_value_t **);
int rrd_flushcached(
int argc,
- char **argv);
+ const char **argv);
void rrd_freemem(
void *mem);
const char **argv);
int rrd_dump_opt_r(
const char *filename,
- char *outname,
+ const char *outname,
int opt_noheader);
int rrd_dump_r(
const char *filename,
static char *scanargs(
char *line,
int *argc,
- char ***args);
+ const char ***args);
/* format at-time specified times using strftime */
static char *printstrftime(
}
/* expand those RRD:* directives that can be used recursively */
-static char *rrd_expand_vars(
+static const char *rrd_expand_vars(
char *buffer)
{
int i;
int main(
int argc,
- char *argv[])
+ const char *argv[])
{
char *buffer;
long i;
}
calfree();
if (rrd_graph
- (argc + 1, (char **) args - 1, &calcpr, &xsize, &ysize, NULL, &ymin,
+ (argc + 1, args - 1, &calcpr, &xsize, &ysize, NULL, &ymin,
&ymax) != -1) {
return stralloc(calcpr[0]);
} else {
/* not raising argc in step with args - 1 since the last argument
will be used below for strftime */
- last = rrd_last(argc, (char **) args - 1);
+ last = rrd_last(argc, args - 1);
if (rrd_test_error()) {
char err[4096];
static char *scanargs(
char *line,
int *argument_count,
- char ***arguments)
+ const char ***arguments)
{
char *getP; /* read cursor */
char *putP; /* write cursor */
/* local array of arguments while parsing */
int argc = 1;
- char **argv;
- char **argv_tmp; /* temp variable for realloc() */
+ const char **argv;
+ const char **argv_tmp; /* temp variable for realloc() */
#ifdef DEBUG_PARSER
printf("<-- scanargs(%s) -->\n", line);
/* create initial argument array of char pointers */
argsz = 32;
- argv = (char **) malloc(argsz * sizeof(char *));
+ argv = malloc(argsz * sizeof(char *));
if (!argv) {
return NULL;
}
if (argc == argsz - 2) {
/* resize argument array */
argsz *= 2;
- argv_tmp = (char **) rrd_realloc(argv, argsz * sizeof(char *));
+ argv_tmp = rrd_realloc(argv, argsz * sizeof(char *));
if (*argv_tmp == NULL) {
return NULL;
}
/* the name of the vairable ... */
char *val;
long valln;
- char **args;
+ const char **args;
char *end;
long end_offset;
int argc;
/* make sure we do not shrink the mallocd block */
size_t newbufsize = i + strlen(end) + valln + 1;
- *buf = (char *) rrd_realloc(*buf, newbufsize);
+ *buf = rrd_realloc(*buf, newbufsize);
if (*buf == NULL) {
perror("Realoc buf:");
int rrd_create(
int argc,
- char **argv)
+ const char **argv)
{
struct optparse_long longopts[] = {
{"start", 'b', OPTPARSE_REQUIRED},
HANDLER_PROTO)
{ /* {{{ */
int status;
- char** argv = NULL;
+ const char** argv = NULL;
int argc, argc_tmp;
char* i;
int rc;
goto done;
}
- if ((argv = (char **) malloc(argc * sizeof(char*))) == NULL) {
+ if ((argv = malloc(argc * sizeof(char*))) == NULL) {
rc = send_response(sock, RESP_ERR, "%s\n", rrd_strerror(ENOMEM));
goto done;
}
argc_tmp += 1;
}
- status = rrd_tune_r(file, argc, (const char **)argv);
+ status = rrd_tune_r(file, argc, argv);
if (status != 0) {
rc = send_response(sock, RESP_ERR, "Got error %s\n", rrd_get_error());
goto done;
rc = send_response(sock, RESP_OK, "Success\n");
done:
free(file);
- free(argv);
+ free((void *)argv);
return rc;
}
static int read_options(
int argc,
- char **argv)
+ const char **argv)
{ /* {{{ */
struct optparse_long longopts[] = {
{NULL, 'a', OPTPARSE_REQUIRED},
int main(
int argc,
- char **argv)
+ const char **argv)
{
int status;
int rrd_dump_opt_r(
const char *filename,
- char *outname,
+ const char *outname,
int opt_noheader)
{
FILE *out_file;
int rrd_dump(
int argc,
- char **argv)
+ const char **argv)
{
int opt;
struct optparse_long longopts[] = {
int rrd_fetch(
int argc,
- char **argv,
+ const char **argv,
time_t *start,
time_t *end, /* which time frame do you want ?
* will be changed to represent reality */
time_t rrd_first(
int argc,
- char **argv)
+ const char **argv)
{
struct optparse_long longopts[] = {
{"rraindex", 129, OPTPARSE_REQUIRED},
#include "rrd_tool.h"
#include "rrd_client.h"
-int rrd_flushcached (int argc, char **argv)
+int rrd_flushcached (int argc, const char **argv)
{
struct optparse_long longopts[] = {
{"daemon", 'd', OPTPARSE_REQUIRED},
/* Now just a wrapper around rrd_graph_v */
int rrd_graph(
int argc,
- char **argv,
+ const char **argv,
char ***prdata,
int *xsize,
int *ysize,
rrd_info_t *rrd_graph_v(
int argc,
- char **argv)
+ const char **argv)
{
image_desc_t im;
rrd_info_t *grinfo;
void rrd_graph_options(
int argc,
- char *argv[],
+ const char **argv,
struct optparse *poptions,
image_desc_t *im)
{
void rrd_graph_options(
int,
- char **,
+ const char **,
struct optparse *,
image_desc_t *);
void rrd_graph_script(
int,
- char **,
+ const char **,
image_desc_t *const,
int);
int rrd_graph_color(
void rrd_graph_script(
int argc,
- char *argv[],
+ const char **argv,
image_desc_t *const im,
int optno)
{
rrd_info_t *rrd_info(
int argc,
- char **argv)
+ const char **argv)
{
struct optparse_long longopts[] = {
{"daemon", 'd', OPTPARSE_REQUIRED},
time_t rrd_last(
int argc,
- char **argv)
+ const char **argv)
{
char *opt_daemon = NULL;
time_t lastupdate;
#include "rrd_client.h"
#include <stdarg.h>
-int rrd_lastupdate (int argc, char **argv)
+int rrd_lastupdate (int argc, const char **argv)
{
struct optparse_long longopts[] = {
{"daemon", 'd', OPTPARSE_REQUIRED},
return (char *)&(string[index]);
}
-static char *rrd_list_rec(int recursive, char *root, char *dirname)
+static char *rrd_list_rec(int recursive, const char *root, const char *dirname)
{
#define SANE_ASPRINTF2(_dest_str, _format, ...) \
if (asprintf(&_dest_str, _format, __VA_ARGS__) == -1) { \
return out;
}
-char *rrd_list_r(int recursive, char *dirname)
+char *rrd_list_r(int recursive, const char *dirname)
{
#define SANE_ASPRINTF(_dest_str, _format, ...) \
if (asprintf(&_dest_str, _format, __VA_ARGS__) == -1) { \
return rrd_list_rec(recursive, dirname, dirname);
}
-char *rrd_list(int argc, char **argv)
+char *rrd_list(int argc, const char **argv)
{
char *opt_daemon = NULL;
int status;
}
int handle_modify(const rrd_t *in, const char *outfilename,
- int argc, char **argv, int optidx,
+ int argc, const char **argv, int optidx,
int newstep) {
// parse add/remove options
int rc = -1;
} rra_mod_op_t;
int handle_modify(const rrd_t *in, const char *outfilename,
- int argc, char **argv, int optind,
+ int argc, const char **argv, int optind,
int newstep);
typedef union {
int rrd_resize(
int argc,
- char **argv)
+ const char **argv)
{
- char *infilename, outfilename[11] = "resize.rrd";
+ const char *infilename, outfilename[11] = "resize.rrd";
rrd_t rrdold, rrdnew;
rrd_value_t buffer;
int version;
int rrd_restore(
int argc,
- char **argv)
+ const char **argv)
{
struct optparse_long longopts[] = {
{"range-check", 'r', OPTPARSE_NONE},
static void PrintUsage(
- char *cmd);
+ const char *cmd);
static int CountArgs(
char *aLine);
static int CreateArgs(
+ const char *,
char *,
- char *,
- char **);
+ const char **);
static int HandleInputLine(
int,
- char **,
+ const char **,
FILE *);
int RemoteMode = 0;
int ChangeRoot = 0;
static void PrintUsage(
- char *cmd)
+ const char *cmd)
{
#ifdef BUILD_DATE
int main(
int argc,
- char *argv[])
+ const char *argv[])
{
- char **myargv;
+ const char **myargv;
char *aLine;
- char *firstdir = "";
+ const char *firstdir = "";
#ifdef MUST_DISABLE_SIGFPE
signal(SIGFPE, SIG_IGN);
printf("ERROR: not enough arguments\n");
continue;
}
- if ((myargv = (char **) malloc((argc + 1) *
+ if ((myargv = malloc((argc + 1) *
sizeof(char *))) == NULL) {
perror("malloc");
exit(1);
resolving them portably is not really simple. */
static int HandleInputLine(
int argc,
- char **argv,
+ const char **argv,
FILE * out)
{
#if defined(HAVE_OPENDIR) && defined (HAVE_READDIR)
* CreateArgs - take a string (aLine) and tokenize
*/
static int CreateArgs(
- char *pName,
+ const char *pName,
char *aLine,
- char **argv)
+ const char **argv)
{
char *getP, *putP;
- char **pargv = argv;
+ const char **pargv = argv;
char Quote = 0;
int inArg = 0;
int len;
int rrd_tune(
int argc,
- char **argv)
+ const char **argv)
{
char *opt_daemon = NULL;
const char *in_filename = NULL;
rrd_info_t *rrd_update_v(
int argc,
- char **argv)
+ const char **argv)
{
struct optparse_long longopts[] = {
{"template", 't', OPTPARSE_REQUIRED},
int rrd_update(
int argc,
- char **argv)
+ const char **argv)
{
struct optparse_long longopts[] = {
{"template", 't', OPTPARSE_REQUIRED},
int rrd_xport(
int argc,
- char **argv,
+ const char **argv,
int UNUSED(*xsize),
time_t *start,
time_t *end, /* which time frame do you want ?
int argc,
char **argv)
{
+ const char **cargv = (const char **)argv;
char *name=basename(argv[0]);
rrd_info_t *info;
if (!strcmp(name, "rrdcreate")) {
- rrd_create(argc, argv);
+ rrd_create(argc, cargv);
}
else if (!strcmp(name, "rrdinfo")) {
- info=rrd_info(argc, argv);
+ info=rrd_info(argc, cargv);
rrd_info_print(info);
rrd_info_free(info);
}
else {
- rrd_update(argc, argv);
+ rrd_update(argc, cargv);
}
if (rrd_test_error()) {