}
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]);
}
*****************************************************************************
* $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 **);
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()) {
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);
/* 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 *);
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) {