diff --git a/src/rrd_cgi.c b/src/rrd_cgi.c
index e79ecb7c1bee78fa1d6ad49a52cbe4b1167cac3e..53c104f08aaa2797bf9fa766b4d8cc4ec861def2 100644 (file)
--- a/src/rrd_cgi.c
+++ b/src/rrd_cgi.c
/*****************************************************************************
- * RRDtool 1.0.33 Copyright Tobias Oetiker, 1997 - 2000
+ * RRDtool 1.1.x Copyright Tobias Oetiker, 1997 - 2002
*****************************************************************************
* rrd_cgi.c RRD Web Page Generator
*****************************************************************************/
server_url = getenv("SERVER_URL");
}
- if (optind != argc-1) {
- fprintf(stderr, "ERROR: expected a filename\n");
- exit(1);
+ if ( (optind != argc-2 && strstr(getenv("SERVER_SOFTWARE"),"Apache/2") != NULL) && optind != argc-1) {
+ fprintf(stderr, "ERROR: expected a filename\n");
+ exit(1);
} else {
length = readfile(argv[optind], &buffer, 1);
}
char* rrdgetenv(long argc, char **args){
if (argc != 1) {
return stralloc("[ERROR: getenv faild because it did not get 1 argument only]");
- };
- return stralloc(getenv(args[0]));
+ }
+ else if (getenv(args[0]) == NULL) {
+ return stralloc("");
+ }
+ else {
+ return stralloc(getenv(args[0]));
+ }
}
char* rrdgoodfor(long argc, char **args){
}
}
+static
char* rrdstrip(char *buf){
char *start;
if (buf == NULL) return NULL;
rrd_clear_error();
return err;
}
- tm_last = *localtime(&last);
+ localtime_r(&last, &tm_last);
strftime(buf,254,args[1],&tm_last);
return buf;
}
if (buf == NULL){
return stralloc("[ERROR: allocating strftime buffer]");
};
- tm_now = *localtime(&now);
+ localtime_r(&now, &tm_now);
strftime(buf,254,args[0],&tm_now);
return buf;
}
}
/* scan aLine until an unescaped '>' arives */
+static
char* scanargs(char *aLine, long *argc, char ***args)
{
char *getP, *putP;
getP = aLine;
putP = aLine;
while (*getP && !( !Quote && (braket == 0) && ((*getP) == '>'))){
- if (*getP < ' ') *getP = ' '; /*remove all special chars*/
+ if ((unsigned)*getP < ' ') *getP = ' '; /*remove all special chars*/
switch (*getP) {
case ' ':
if (Quote){
char *
http_time(time_t *now) {
- struct tm *tmptime;
+ struct tm tmptime;
static char buf[60];
- tmptime=gmtime(now);
- strftime(buf,sizeof(buf),"%a, %d %b %Y %H:%M:%S GMT",tmptime);
+ gmtime_r(now, &tmptime);
+ strftime(buf,sizeof(buf),"%a, %d %b %Y %H:%M:%S GMT", &tmptime);
return(buf);
}