summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0f330bc)
raw | patch | inline | side by side (parent: 0f330bc)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 6 Apr 2005 22:40:53 +0000 (22:40 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 6 Apr 2005 22:40:53 +0000 (22:40 +0000) |
12 files changed:
diff --git a/program/src/rrd_afm.c b/program/src/rrd_afm.c
index b9996f45a6690390ef41ea3a2119957a997a6d30..04abde5751c3fd1c59968d3a1c7e5ba85f09ea6e 100644 (file)
--- a/program/src/rrd_afm.c
+++ b/program/src/rrd_afm.c
* rrd_afm.h Parsing afm tables to find width of strings.
****************************************************************************/
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
#include "../confignt/config.h"
#else
#include "config.h"
diff --git a/program/src/rrd_cgi.c b/program/src/rrd_cgi.c
index 5fc5a6235ba740a7d896306723ea6cec45e51417..dac2755cac22392e5c5ebda12f507f28a60299dc 100644 (file)
--- a/program/src/rrd_cgi.c
+++ b/program/src/rrd_cgi.c
if (envvar) {
return stralloc(envvar);
} else {
-#ifdef WIN32
+#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]);
if (value) {
return stralloc(value);
} else {
-#ifdef WIN32
+#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]);
index 0152dd1a801348d10c0401f8a54331d753de7562..367d3524f1e7c662d5c20d191da9685475e00987 100644 (file)
--- a/program/src/rrd_graph.c
+++ b/program/src/rrd_graph.c
#include "rrd_tool.h"
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
#include <io.h>
#include <fcntl.h>
#endif
/* some constant definitions */
-#ifdef WIN32
-char rrd_win_default_font[80];
-#endif
#ifndef RRD_DEFAULT_FONT
/* there is special code later to pick Cour.ttf when running on windows */
if (strcmp(im->graphfile,"-")==0) {
fo = im->graphhandle ? im->graphhandle : stdout;
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
/* Change translation mode for stdout to BINARY */
_setmode( _fileno( fo ), O_BINARY );
#endif
for(i=0;i<DIM(graph_col);i++)
im->graph_col[i]=graph_col[i];
-#ifdef WIN32
+
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
{
char *windir;
+ char rrd_win_default_font[1000];
windir = getenv("windir");
/* %windir% is something like D:\windows or C:\winnt */
if (windir != NULL) {
- strcpy(rrd_win_default_font,windir);
+ strncpy(rrd_win_default_font,windir,999);
+ rrd_win_default_font[999] = '\0';
strcat(rrd_win_default_font,"\\fonts\\cour.ttf");
- for(i=0;i<DIM(text_prop);i++)
- strcpy(text_prop[i].font,rrd_win_default_font);
- }
+ for(i=0;i<DIM(text_prop);i++){
+ strncpy(text_prop[i].font,rrd_win_default_font,sizeof(text_prop[i].font)-1);
+ text_prop[i].font[sizeof(text_prop[i].font)-1] = '\0';
+ }
}
#endif
+ {
+ char *deffont;
+ deffont = getenv("RRD_DEFAULT_FONT");
+ /* %windir% is something like D:\windows or C:\winnt */
+ if (deffont != NULL) {
+ for(i=0;i<DIM(text_prop);i++){
+ strncpy(text_prop[i].font,deffont,sizeof(text_prop[i].font)-1);
+ text_prop[i].font[sizeof(text_prop[i].font)-1] = '\0';
+ }
+ }
+ }
for(i=0;i<DIM(text_prop);i++){
im->text_prop[i].size = text_prop[i].size;
strcpy(im->text_prop[i].font,text_prop[i].font);
&im->xlab_user.precis,
&stroff) == 7 && stroff != 0){
strncpy(im->xlab_form, optarg+stroff, sizeof(im->xlab_form) - 1);
+ im->xlab_form[sizeof(im->xlab_form)-1] = '\0';
if((int)(im->xlab_user.gridtm = tmt_conv(scan_gtm)) == -1){
rrd_set_error("unknown keyword %s",scan_gtm);
return;
index ce0873e5ed37003c7e4c12dd7ae29866870aae0a..f40555d29cc38aa88a5d644839e2549d921cb096 100644 (file)
#include "rrd_nan_inf.h"
-#if defined(WIN32)
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
#include <math.h>
diff --git a/program/src/rrd_open.c b/program/src/rrd_open.c
index 2ceabae1eeb3ee9dbd72f5ef10007c7b6c5e5c0a..5f5a08ee08f9114a51e1d896102178d5c0f5d62b 100644 (file)
--- a/program/src/rrd_open.c
+++ b/program/src/rrd_open.c
rrd_init(rrd);
if (rdwr == RRD_READONLY) {
-#ifndef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
mode = "r";
#else
mode = "rb";
#endif
} else {
-#ifndef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
mode = "r+";
#else
mode = "rb+";
index 3857f96f7ec98bd7c89ebc595fd0d4da476aa4c8..3315c69cc28b102755ed9b77d1c94931c2bfe26b 100644 (file)
#include "rrd_rpncalc.h"
#include <fcntl.h>
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
#include <io.h>
#define open _open
#define close _close
if (strcmp("-",file_name)==0){
rrd_file= stdout;
} else {
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
fdflags = O_RDWR|O_BINARY|O_CREAT;
#else
fdflags = O_WRONLY|O_CREAT;
index 21ec8f00de2d07456f1bb5550d8c3d72a0a3a45e..73bef2f5a8bd936d668ef718d2c0c9ad9e708b95 100644 (file)
if (rpnc[i].op == OP_NUMBER) {
/* convert a short into a string */
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
_itoa(rpnc[i].val,buffer,10);
#else
sprintf(buffer,"%d",rpnc[i].val);
diff --git a/program/src/rrd_tool.c b/program/src/rrd_tool.c
index e2bd1db381387cf5317555aa1b175935a77a0d1e..e6caff77b7cb799455df5cdb7dcde768428ab42b 100644 (file)
--- a/program/src/rrd_tool.c
+++ b/program/src/rrd_tool.c
char help_main[] =
"RRDtool 1.2rc3 Copyright 1997-2005 by Tobias Oetiker <tobi@oetiker.ch>\n"
-#ifndef WIN32
- " Compiled " MAKE_TIMESTAMP "\n\n"
-#else
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
" Compiled " __DATE__ " " __TIME__ "\n\n"
+#else
+ " Compiled " MAKE_TIMESTAMP "\n\n"
#endif
"Usage: rrdtool [options] command command_options\n\n";
diff --git a/program/src/rrd_tool.h b/program/src/rrd_tool.h
index f39cbe3d536c06cedf2ff870f8e04fda34a7db9d..37f4a7ed53447dd5b2d4945b690d8191955e86a0 100644 (file)
--- a/program/src/rrd_tool.h
+++ b/program/src/rrd_tool.h
#ifndef _RRD_TOOL_H
#define _RRD_TOOL_H
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
#include "../confignt/config.h"
#else
#ifdef HAVE_CONFIG_H
#include "rrd.h"
-#ifndef WIN32
-
-/* unix-only includes */
-#ifndef isnan
-int isnan(double value);
-#endif
-
-#else
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
/* Win32 only includes */
char* ctime_r(const time_t *timep, char* result);
struct tm* gmtime_r(const time_t *timep, struct tm* result);
char *strtok_r(char *str, const char *sep, char **last);
+
+#else
+
+/* unix-only includes */
+#ifndef isnan
+int isnan(double value);
+#endif
+
#endif
/* local include files -- need to be after the system ones */
index 728db8e163de711f81682ba7c438bfd822568d7b..0f0bf3d5eae3fd0ab982c6289b7404d8a75270b0 100644 (file)
--- a/program/src/rrd_update.c
+++ b/program/src/rrd_update.c
#include <sys/mman.h>
#endif
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
#include <sys/locking.h>
#include <sys/stat.h>
#include <io.h>
#include "rrd_is_thread_safe.h"
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
/*
* WIN32 does not have gettimeofday and struct timeval. This is a quick and dirty
* replacement.
* critical except during the burning cycles. */
if (schedule_smooth)
{
-#ifndef WIN32
- rrd_file = fopen(filename,"r+");
-#else
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
rrd_file = fopen(filename,"rb+");
+#else
+ rrd_file = fopen(filename,"r+");
#endif
rra_start = rra_begin;
for (i = 0; i < rrd.stat_head -> rra_cnt; ++i)
rrd_fd = fileno(rrdfile);
{
-#ifndef WIN32
- struct flock lock;
- lock.l_type = F_WRLCK; /* exclusive write lock */
- lock.l_len = 0; /* whole file */
- lock.l_start = 0; /* start of file */
- lock.l_whence = SEEK_SET; /* end of file */
-
- rcstat = fcntl(rrd_fd, F_SETLK, &lock);
-#else
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
struct _stat st;
if ( _fstat( rrd_fd, &st ) == 0 ) {
} else {
rcstat = -1;
}
+#else
+ struct flock lock;
+ lock.l_type = F_WRLCK; /* exclusive write lock */
+ lock.l_len = 0; /* whole file */
+ lock.l_start = 0; /* start of file */
+ lock.l_whence = SEEK_SET; /* end of file */
+
+ rcstat = fcntl(rrd_fd, F_SETLK, &lock);
#endif
}
index 158d7262382e1514175a10a581ecf37d7a1718e6..43f84f975e40b14cc5d9fadc5af0dcd11b45bc08 100644 (file)
--- a/program/src/rrd_xport.c
+++ b/program/src/rrd_xport.c
#include "rrd_graph.h"
#include "rrd_xport.h"
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
#include <io.h>
#include <fcntl.h>
#endif
index e61cea412bed02642f2e0bd18c168a3f31c4f699..ed9b3f81ba98df4a37898d2c92d81c084e91f07c 100644 (file)
--- a/program/src/rrdupdate.c
+++ b/program/src/rrdupdate.c
#include <sys/types.h>
#include <fcntl.h>
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
#include <sys/locking.h>
#include <sys/stat.h>
#include <io.h>
* critical except during the burning cycles. */
if (schedule_smooth)
{
-#ifndef WIN32
- rrd_file = fopen(argv[optind],"r+");
-#else
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
rrd_file = fopen(argv[optind],"rb+");
+#else
+ rrd_file = fopen(argv[optind],"r+");
#endif
rra_start = rra_begin;
for (i = 0; i < rrd.stat_head -> rra_cnt; ++i)
rrd_fd = fileno(rrdfile);
{
-#ifndef WIN32
- struct flock lock;
- lock.l_type = F_WRLCK; /* exclusive write lock */
- lock.l_len = 0; /* whole file */
- lock.l_start = 0; /* start of file */
- lock.l_whence = SEEK_SET; /* end of file */
-
- stat = fcntl(rrd_fd, F_SETLK, &lock);
-#else
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
struct _stat st;
if ( _fstat( rrd_fd, &st ) == 0 ) {
} else {
stat = -1;
}
+#else
+ struct flock lock;
+ lock.l_type = F_WRLCK; /* exclusive write lock */
+ lock.l_len = 0; /* whole file */
+ lock.l_start = 0; /* start of file */
+ lock.l_whence = SEEK_SET; /* end of file */
+
+ stat = fcntl(rrd_fd, F_SETLK, &lock);
#endif
}