diff --git a/bindings/tcl/tclrrd.c b/bindings/tcl/tclrrd.c
index 0f3ba6041901e1b25c19a1c7e6c19c9f3ebc26fc..869d6c781147f528fd81a98adf03db607434c330 100644 (file)
--- a/bindings/tcl/tclrrd.c
+++ b/bindings/tcl/tclrrd.c
* See the file "COPYING" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * $Id: tclrrd.c 1306 2008-03-15 10:39:48Z oetiker $
+ * $Id$
*/
/* Thread-safe version */
static int Rrd_Create(
- ClientData clientData,
+ ClientData __attribute__((unused)) clientData,
Tcl_Interp *interp,
int argc,
CONST84 char *argv[])
time_t last_up = time(NULL) - 10;
long int long_tmp;
unsigned long int pdp_step = 300;
- struct rrd_time_value last_up_tv;
+ rrd_time_value_t last_up_tv;
argv2 = getopt_init(argc, argv);
getopt_cleanup(argc, argv2);
return TCL_ERROR;
}
- if ((parsetime_error = parsetime(argv2[argv_i], &last_up_tv))) {
+ if ((parsetime_error = rrd_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;
}
- rrd_create_r(argv2[1], pdp_step, last_up, argc - 2, argv2 + 2);
+ rrd_create_r(argv2[1], pdp_step, last_up, argc - 2,
+ (const char **)argv2 + 2);
getopt_cleanup(argc, argv2);
/* Thread-safe version */
static int Rrd_Dump(
- ClientData clientData,
+ ClientData __attribute__((unused)) clientData,
Tcl_Interp *interp,
int argc,
CONST84 char *argv[])
return TCL_OK;
}
+/* Thread-safe version */
+static int Rrd_Flushcached(
+ ClientData __attribute__((unused)) 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;
+ }
+
+ rrd_flushcached(argc, (char**)argv);
+
+ if (rrd_test_error()) {
+ Tcl_AppendResult(interp, "RRD Error: ",
+ rrd_get_error(), (char *) NULL);
+ rrd_clear_error();
+ return TCL_ERROR;
+ }
+
+ return TCL_OK;
+}
/* Thread-safe version */
static int Rrd_Last(
- ClientData clientData,
+ ClientData __attribute__((unused)) clientData,
Tcl_Interp *interp,
int argc,
CONST84 char *argv[])
/* Thread-safe version */
static int Rrd_Update(
- ClientData clientData,
+ ClientData __attribute__((unused)) clientData,
Tcl_Interp *interp,
int argc,
CONST84 char *argv[])
return TCL_ERROR;
}
- rrd_update_r(argv2[1], template, argc - 2, argv2 + 2);
+ rrd_update_r(argv2[1], template, argc - 2, (const char **)argv2 + 2);
if (template != NULL) {
free(template);
}
static int Rrd_Lastupdate(
- ClientData clientData,
+ ClientData __attribute__((unused)) clientData,
Tcl_Interp *interp,
int argc,
CONST84 char *argv[])
Tcl_Obj *listPtr;
unsigned long ds_cnt, i;
+ /* TODO: support for rrdcached */
+ if (argc != 2) {
+ Tcl_AppendResult(interp, "RRD Error: needs a single rrd filename",
+ (char *) NULL);
+ return TCL_ERROR;
+ }
+
argv2 = getopt_init(argc, argv);
- if (rrd_lastupdate(argc - 1, argv2, &last_update,
+ if (rrd_lastupdate_r(argv2[1], &last_update,
&ds_cnt, &ds_namv, &last_ds) == 0) {
listPtr = Tcl_GetObjResult(interp);
for (i = 0; i < ds_cnt; i++) {
}
static int Rrd_Fetch(
- ClientData clientData,
+ ClientData __attribute__((unused)) clientData,
Tcl_Interp *interp,
int argc,
CONST84 char *argv[])
static int Rrd_Graph(
- ClientData clientData,
+ ClientData __attribute__((unused)) clientData,
Tcl_Interp *interp,
int argc,
CONST84 char *argv[])
* Must dup() file descriptor so we can fclose(stream), otherwise the fclose()
* would close Tcl's file descriptor
*/
- if ((fd2 = dup((int) fd1)) == -1) {
+ if ((fd2 = dup((int)fd1)) == -1) {
Tcl_AppendResult(interp,
"dup() failed for file descriptor associated with \"",
argv[1], "\": ", strerror(errno), (char *) NULL);
static int Rrd_Tune(
- ClientData clientData,
+ ClientData __attribute__((unused)) clientData,
Tcl_Interp *interp,
int argc,
CONST84 char *argv[])
static int Rrd_Resize(
- ClientData clientData,
+ ClientData __attribute__((unused)) clientData,
Tcl_Interp *interp,
int argc,
CONST84 char *argv[])
static int Rrd_Restore(
- ClientData clientData,
+ ClientData __attribute__((unused)) clientData,
Tcl_Interp *interp,
int argc,
CONST84 char *argv[])
static CmdInfo rrdCmds[] = {
{"Rrd::create", Rrd_Create, 1}, /* Thread-safe version */
{"Rrd::dump", Rrd_Dump, 0}, /* Thread-safe version */
+ {"Rrd::flushcached", Rrd_Flushcached, 0},
{"Rrd::last", Rrd_Last, 0}, /* Thread-safe version */
{"Rrd::lastupdate", Rrd_Lastupdate, 0}, /* Thread-safe version */
{"Rrd::update", Rrd_Update, 1}, /* Thread-safe version */
if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL)
return TCL_ERROR;
- if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 1) == NULL) {
+ if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 0) == NULL) {
return TCL_ERROR;
}