fix various problems with the tcl bindings -- Peter Breitenlohner
[rrdtool.git] / bindings / tcl / tclrrd.c
index 3cc1711..ad8a8a3 100644 (file)
 #include <rrd_tool.h>
 #include <rrd_format.h>
 
-
+extern int Tclrrd_Init(Tcl_Interp *interp, int safe);
 
 extern int __getopt_initialized;
 
 
 /*
  * some rrd_XXX() functions might modify the argv strings passed to it.
- * Furthermore, they use getopt() without initializing getopt's optind
- * variable themselves. Hence, we need to do some preparation before
+ * Hence, we need to do some preparation before
  * calling the rrd library functions.
  */
 static char ** getopt_init(argc, argv)
@@ -34,8 +33,6 @@ static char ** getopt_init(argc, argv)
     char **argv2;
     int i;
     
-    optind = 0;
-
     argv2 = calloc(argc, sizeof(char *));
     for (i = 0; i < argc; i++) {
        argv2[i] = strdup(argv[i]);
@@ -170,7 +167,7 @@ Rrd_Fetch(clientData, interp, argc, argv)
     int argc;
     char *argv[];
 {
-    time_t start, end;
+    time_t start, end, j;
     unsigned long step, ds_cnt, i, ii;
     rrd_value_t *data, *datai;
     char **ds_namv;
@@ -183,7 +180,7 @@ Rrd_Fetch(clientData, interp, argc, argv)
                  &ds_cnt, &ds_namv, &data) != -1) {
         datai = data;
         listPtr = Tcl_GetObjResult(interp);
-        for (i = start; i <= end; i += step) {
+        for (j = start; j <= end; j += step) {
             for (ii = 0; ii < ds_cnt; ii++) {
                sprintf(s, "%.2f", *(datai++));
                 Tcl_ListObjAppendElement(interp, listPtr,