new rrdcgi function RRD::INTERNAL for accessing VERSION, COPYRIGHT, COMPILETIME,...
authoroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Mon, 6 Feb 2006 19:49:23 +0000 (19:49 +0000)
committeroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Mon, 6 Feb 2006 19:49:23 +0000 (19:49 +0000)
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@760 a5681a0c-68f1-0310-ab6d-d61299d08faa

doc/rrdcgi.pod
src/rrd_cgi.c

index c8152b4..9860f31 100644 (file)
@@ -138,6 +138,12 @@ If the preceding  B<RRD::GRAPH> tag contained and B<PRINT> arguments,
 then you can access their output with this tag. The I<number> argument refers to the
 number of the B<PRINT> argument. This first B<PRINT> has I<number> 0.
 
+=item RRD::INTERNAL <var>
+
+This tag gets replaced by an internal var. Currently these vars are known:
+VERSION, COPYRIGHT, COMPILETIME, OS.
+These vars represent the compiled-in values. 
+
 =back
 
 =head1 EXAMPLE 1
index c1684f7..b2195e4 100644 (file)
@@ -61,6 +61,9 @@ char* includefile(long, const char **);
 /* for how long is the output of the cgi valid ? */
 char* rrdgoodfor(long, const char **);
 
+/* return rrdcgi version string */ 
+char* rrdgetinternal(long, const char **);
+
 char* rrdstrip(char *buf);
 char* scanargs(char *line, int *argc, char ***args);
 
@@ -284,6 +287,7 @@ rrd_expand_vars(char* buffer)
                 parse(&buffer, i, "<RRD::TIME::LAST", printtimelast);
                 parse(&buffer, i, "<RRD::TIME::NOW", printtimenow);
                 parse(&buffer, i, "<RRD::TIME::STRFTIME", printstrftime);
+               parse(&buffer, i, "<RRD::INTERNAL", rrdgetinternal);
        }
        return buffer;
 }
@@ -409,6 +413,7 @@ int main(int argc, char *argv[]) {
                parse(&buffer, i, "<RRD::TIME::LAST", printtimelast);
                parse(&buffer, i, "<RRD::TIME::NOW", printtimenow);
                parse(&buffer, i, "<RRD::TIME::STRFTIME", printstrftime);
+               parse(&buffer, i, "<RRD::INTERNAL", rrdgetinternal);
        }
 
        if (!filter) {
@@ -506,11 +511,7 @@ char* rrdgetenv(long argc, const char **args) {
        if (envvar) {
                return stralloc(envvar);
        } else {
-#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
-               _snprintf(buf, sizeof(buf), "[ERROR:_getenv_'%s'_failed", args[0]);
-#else
                 snprintf(buf, sizeof(buf), "[ERROR:_getenv_'%s'_failed", args[0]);
-#endif         
                 return stralloc(buf);
        }
 }
@@ -526,11 +527,7 @@ char* rrdgetvar(long argc, const char **args) {
        if (value) {
                return stralloc(value);
        } else {
-#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
-               _snprintf(buf, sizeof(buf), "[ERROR:_getvar_'%s'_failed", args[0]);
-#else
                 snprintf(buf, sizeof(buf), "[ERROR:_getvar_'%s'_failed", args[0]);
-#endif
                return stralloc(buf);
        }
 }
@@ -549,6 +546,24 @@ char* rrdgoodfor(long argc, const char **args){
   return stralloc("");
 }
 
+char* rrdgetinternal(long argc, const char **args){
+  if (argc == 1) {
+    if( strcasecmp( args[0], "VERSION") == 0) {
+      return stralloc(PACKAGE_VERSION);
+    } else if( strcasecmp( args[0], "COPYRIGHT") == 0) {
+      return stralloc(PACKAGE_COPYRIGHT);
+    } else if( strcasecmp( args[0], "COMPILETIME") == 0) {
+      return stralloc(__DATE__ " " __TIME__);
+    } else if( strcasecmp( args[0], "OS") == 0) {
+      return stralloc(OS);
+    } else {
+      return stralloc("[ERROR: internal unknown argument]");
+    }
+  } else {
+    return stralloc("[ERROR: internal expected 1 argument]");
+  }
+}
+
 /* Format start or end times using strftime.  We always need both the
  * start and end times, because, either might be relative to the other.
  * */