* 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"
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]);
#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;
#include "rrd_nan_inf.h"
-#if defined(WIN32)
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
#include <math.h>
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+";
#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;
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);
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";
#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 */
#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
}
#include "rrd_graph.h"
#include "rrd_xport.h"
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
#include <io.h>
#include <fcntl.h>
#endif
#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
}