summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2c29d15)
raw | patch | inline | side by side (parent: 2c29d15)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 12 Nov 2003 22:14:26 +0000 (22:14 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 12 Nov 2003 22:14:26 +0000 (22:14 +0000) |
index 474c9c4bedde09fceb5caf15362cd137d66d09c9..afb55f08bc4711adbc6824ded14e7d6c16b2cee6 100644 (file)
}
optind=0; opterr=0;
rrd_clear_error();
- rrd_graph(items+1,argv,&calcpr,&xsize,&ysize);
+ rrd_graph(items+1,argv,&calcpr,&xsize,&ysize,NULL);
for (i=0; i < items; i++) {
free(argv[i+1]);
}
diff --git a/program/src/rrd.h b/program/src/rrd.h
index b09e316d3ce502e945fe278c68553ee54e7a8e6e..902f72ad598f993e47e5e773811341aa1635c5ba 100644 (file)
--- a/program/src/rrd.h
+++ b/program/src/rrd.h
*****************************************************************************
* $Id$
* $Log$
+ * Revision 1.7 2003/11/12 22:14:26 oetiker
+ * allow to pass an open filehandle into rrd_graph as an extra argument
+ *
* Revision 1.6 2003/11/11 19:46:21 oetiker
* replaced time_value with rrd_time_value as MacOS X introduced a struct of that name in their standard headers
*
/* main function blocks */
int rrd_create(int, char **);
int rrd_update(int, char **);
-int rrd_graph(int, char **, char ***, int *, int *);
+int rrd_graph(int, char **, char ***, int *, int *, FILE *);
int rrd_fetch(int, char **, time_t *, time_t *, unsigned long *,
unsigned long *, char ***, rrd_value_t **);
int rrd_restore(int, char **);
diff --git a/program/src/rrd_cgi.c b/program/src/rrd_cgi.c
index b49f5f52af25753aa457ede158bc7edb0f82fd28..4543044c2ad445938dad2a9c536d0bf9ab17f1d4 100644 (file)
--- a/program/src/rrd_cgi.c
+++ b/program/src/rrd_cgi.c
optind=0; /* reset gnu getopt */
opterr=0; /* reset gnu getopt */
calfree();
- if( rrd_graph(argc+1, args-1, &calcpr, &xsize, &ysize) != -1 ) {
+ if( rrd_graph(argc+1, args-1, &calcpr, &xsize, &ysize, NULL) != -1 ) {
return stralloc(calcpr[0]);
} else {
if (rrd_test_error()) {
index ef7c9b6ba450f655f83e78fac9b2232f8021e2a6..c60717fa0828784601476464480d6d33a7e2f6dd 100644 (file)
--- a/program/src/rrd_graph.c
+++ b/program/src/rrd_graph.c
if (strcmp(im->graphfile,"-")==0) {
+ fo = im->graphhandle ? im->graphhandle : stdout;
#ifdef WIN32
/* Change translation mode for stdout to BINARY */
- _setmode( _fileno( stdout ), O_BINARY );
+ _setmode( _fileno( fo ), O_BINARY );
#endif
- fo = stdout;
} else {
if ((fo = fopen(im->graphfile,"wb")) == NULL) {
rrd_set_error("Opening '%s' for write: %s",im->graphfile,
** - script parsing now in rrd_graph_script()
*/
int
-rrd_graph(int argc, char **argv, char ***prdata, int *xsize, int *ysize)
+rrd_graph(int argc, char **argv, char ***prdata, int *xsize, int *ysize, FILE *stream)
{
image_desc_t im;
rrd_graph_init(&im);
-
+ im.graphhandle = stream;
+
rrd_graph_options(argc,argv,&im);
if (rrd_test_error()) {
im_free(&im);
index a7467369987acfcc3be0c0694b701ef36acaa908..09c2f1d7fd0b302e06f8cff4da0f0fdcd348e1cb 100644 (file)
--- a/program/src/rrd_graph.h
+++ b/program/src/rrd_graph.h
/* configuration of graph */
char graphfile[MAXPATH]; /* filename for graphic */
+ FILE *graphhandle; /* FILE to use if filename is "-" */
long xsize,ysize,piesize; /* graph area size in pixels */
gfx_color_t graph_col[__GRC_END__]; /* real colors for the graph */
text_prop_t text_prop[TEXT_PROP_LAST]; /* text properties */
void pie_part(image_desc_t *, gfx_color_t, double, double, double, double, double);
int gdes_alloc(image_desc_t *);
int scan_for_col(char *, int, char *);
-int rrd_graph(int, char **, char ***, int *, int *);
+int rrd_graph(int, char **, char ***, int *, int *, FILE *);
void rrd_graph_init(image_desc_t *);
void rrd_graph_options(int, char **, image_desc_t *);
void rrd_graph_script(int, char **, image_desc_t *);
diff --git a/program/src/rrd_tool.c b/program/src/rrd_tool.c
index cfd71a938c91da56eba77e06cf8adc8786247336..d23094f8d12bfb703f3a0c2342d8d009faea8f48 100644 (file)
--- a/program/src/rrd_tool.c
+++ b/program/src/rrd_tool.c
int xsize, ysize;
int i;
int tostdout = (strcmp(argv[2],"-") == 0);
- if( rrd_graph(argc-1, &argv[1], &calcpr, &xsize, &ysize) != -1 ) {
+ if( rrd_graph(argc-1, &argv[1], &calcpr, &xsize, &ysize, NULL) != -1 ) {
if (!tostdout)
printf ("%dx%d\n",xsize,ysize);
if (calcpr) {