diff --git a/src/rrd_tool.c b/src/rrd_tool.c
index 83f7f1ec09347a2ba778aece50bdee4c7a1ac54d..454907386cb0c66a468aa49dbf7a83a044ef76bf 100644 (file)
--- a/src/rrd_tool.c
+++ b/src/rrd_tool.c
/*****************************************************************************
- * RRDtool 1.3rc2 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.9 Copyright by Tobi Oetiker, 1997-2009
*****************************************************************************
* rrd_tool.c Startup wrapper
*****************************************************************************/
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) && !defined(HAVE_CONFIG_H)
#include "../win32/config.h"
+#include <stdlib.h>
+#include <sys/stat.h>
#else
#ifdef HAVE_CONFIG_H
#include "../rrd_config.h"
int CreateArgs(
char *,
char *,
- int,
char **);
int HandleInputLine(
int,
const char *help_main =
N_("RRDtool %s"
- " Copyright 1997-2007 by Tobias Oetiker <tobi@oetiker.ch>\n"
+ " Copyright 1997-2009 by Tobias Oetiker <tobi@oetiker.ch>\n"
" Compiled %s %s\n\n"
"Usage: rrdtool [options] command command_options\n\n");
N_("* create - create a new RRD\n\n"
"\trrdtool create filename [--start|-b start time]\n"
"\t\t[--step|-s step]\n"
+ "\t\t[--no-overwrite|-O]\n"
"\t\t[DS:ds-name:DST:dst arguments]\n"
"\t\t[RRA:CF:cf arguments]\n\n");
"\t\t[-Y|--alt-y-grid]\n"
"\t\t[-y|--y-grid y-axis grid and label]\n"
"\t\t[-v|--vertical-label string] [-w|--width pixels]\n"
+ "\t\t[--right-axis scale:shift] [--right-axis-label label]\n"
+ "\t\t[--right-axis-format format]\n"
"\t\t[-h|--height pixels] [-o|--logarithmic]\n"
"\t\t[-u|--upper-limit value] [-z|--lazy]\n"
"\t\t[-l|--lower-limit value] [-r|--rigid]\n"
- "\t\t[-g|--no-legend]\n"
+ "\t\t[-g|--no-legend] [--full-size-mode]\n"
"\t\t[-F|--force-rules-legend]\n" "\t\t[-j|--only-graph]\n");
const char *help_graph2 =
N_("\t\t[-n|--font FONTTAG:size:font]\n"
"\t\t[-m|--zoom factor]\n"
"\t\t[-A|--alt-autoscale]\n"
"\t\t[-M|--alt-autoscale-max]\n"
+ "\t\t[-G|--graph-render-mode {normal,mono}]\n"
"\t\t[-R|--font-render-mode {normal,light,mono}]\n"
"\t\t[-B|--font-smoothing-threshold size]\n"
+ "\t\t[-T|--tabwidth width]\n"
"\t\t[-E|--slope-mode]\n"
"\t\t[-N|--no-gridfit]\n"
"\t\t[-X|--units-exponent value]\n"
"\t\t[--window-length integer]\n"
"\t\t[--alpha adaptation-parameter]\n");
const char *help_tune2 =
- N_(" * tune - Modify some basic properties of an RRD\n\n"
- "\t\t[--beta adaptation-parameter]\n"
+ N_("\t\t[--beta adaptation-parameter]\n"
"\t\t[--gamma adaptation-parameter]\n"
"\t\t[--gamma-deviation adaptation-parameter]\n"
"\t\t[--aberrant-reset ds-name]\n\n");
return *aLinePtr = linebuf;
bufsize += MAX_LENGTH;
if (!(linebuf = realloc(linebuf, bufsize))) {
+ free(linebuf);
perror("fgetslong: realloc");
exit(1);
}
}
- return *aLinePtr = linebuf[0] ? linebuf : 0;
+ if (linebuf[0]){
+ return *aLinePtr = linebuf;
+ }
+ free(linebuf);
+ return *aLinePtr = 0;
}
int main(
#ifdef HAVE_LOCALE_H
setlocale(LC_ALL, "");
#endif
-#ifdef HAVE_LIBINTL_H
+
+#if defined(HAVE_LIBINTL_H) && defined(BUILD_LIBINTL)
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
== 0) {
#ifdef HAVE_CHROOT
- chroot(argv[2]);
- if (errno != 0) {
- fprintf(stderr,
- "ERROR: can't change root to '%s' errno=%d\n",
- argv[2], errno);
+ if (chroot(argv[2]) != 0){
+ fprintf(stderr, "ERROR: chroot %s: %s\n", argv[2],rrd_strerror(errno));
exit(errno);
}
ChangeRoot = 1;
}
}
if (strcmp(firstdir, "")) {
- chdir(firstdir);
- if (errno != 0) {
- fprintf(stderr, "ERROR: %s\n", rrd_strerror(errno));
+ if (chdir(firstdir) != 0){
+ fprintf(stderr, "ERROR: chdir %s %s\n", firstdir,rrd_strerror(errno));
exit(errno);
}
}
while (fgetslong(&aLine, stdin)) {
+ char *aLineOrig = aLine;
if ((argc = CountArgs(aLine)) == 0) {
+ free(aLine);
printf("ERROR: not enough arguments\n");
+ continue;
}
if ((myargv = (char **) malloc((argc + 1) *
sizeof(char *))) == NULL) {
perror("malloc");
exit(1);
}
- if ((argc = CreateArgs(argv[0], aLine, argc, myargv)) < 0) {
+ if ((argc = CreateArgs(argv[0], aLine, myargv)) < 0) {
printf("ERROR: creating arguments\n");
} else {
- int ret = HandleInputLine(argc, myargv, stdout);
-
- free(myargv);
- if (ret == 0) {
+ if ( HandleInputLine(argc, myargv, stdout) == 0 ){
#if HAVE_GETRUSAGE
getrusage(RUSAGE_SELF, &myusage);
gettimeofday(¤ttime, NULL);
}
}
fflush(stdout); /* this is important for pipes to work */
- free(aLine);
+ free(myargv);
+ free(aLineOrig);
}
} else if (argc == 2) {
PrintUsage(argv[1]);
/* Reset errno to 0 before we start.
*/
- errno = 0;
if (RemoteMode) {
if (argc > 1 && strcmp("quit", argv[1]) == 0) {
- if (argc > 2) {
+ if (argc != 2) {
printf("ERROR: invalid parameter count for quit\n");
return (1);
}
}
#if defined(HAVE_OPENDIR) && defined(HAVE_READDIR) && defined(HAVE_CHDIR)
if (argc > 1 && strcmp("cd", argv[1]) == 0) {
- if (argc > 3) {
+ if (argc != 3) {
printf("ERROR: invalid parameter count for cd\n");
return (1);
}
return (1);
}
#endif
- chdir(argv[2]);
- if (errno != 0) {
- printf("ERROR: %s\n", rrd_strerror(errno));
+ if (chdir(argv[2]) != 0){
+ printf("ERROR: chdir %s %s\n", argv[2], rrd_strerror(errno));
return (1);
}
return (0);
}
if (argc > 1 && strcmp("pwd", argv[1]) == 0) {
- if (argc > 2) {
+ if (argc != 2) {
printf("ERROR: invalid parameter count for pwd\n");
return (1);
}
cwd = getcwd(NULL, MAXPATH);
if (cwd == NULL) {
- printf("ERROR: %s\n", rrd_strerror(errno));
+ printf("ERROR: getcwd %s\n", rrd_strerror(errno));
return (1);
}
printf("%s\n", cwd);
return (0);
}
if (argc > 1 && strcmp("mkdir", argv[1]) == 0) {
- if (argc > 3) {
+ if (argc != 3) {
printf("ERROR: invalid parameter count for mkdir\n");
return (1);
}
return (1);
}
#endif
- mkdir(argv[2], 0777);
- if (errno != 0) {
- printf("ERROR: %s\n", rrd_strerror(errno));
+ if(mkdir(argv[2], 0777)!=0){
+ printf("ERROR: mkdir %s: %s\n", argv[2],rrd_strerror(errno));
return (1);
}
return (0);
}
if (argc > 1 && strcmp("ls", argv[1]) == 0) {
- if (argc > 2) {
+ if (argc != 2) {
printf("ERROR: invalid parameter count for ls\n");
return (1);
}
}
closedir(curdir);
} else {
- printf("ERROR: %s\n", rrd_strerror(errno));
+ printf("ERROR: opendir .: %s\n", rrd_strerror(errno));
return (errno);
}
return (0);
else if (strcmp("dump", argv[1]) == 0)
rrd_dump(argc - 1, &argv[1]);
else if (strcmp("info", argv[1]) == 0 || strcmp("updatev", argv[1]) == 0) {
- info_t *data;
+ rrd_info_t *data;
if (strcmp("info", argv[1]) == 0)
data = rrd_info(argc - 1, &argv[1]);
else
data = rrd_update_v(argc - 1, &argv[1]);
- info_print(data);
- info_free(data);
+ rrd_info_print(data);
+ rrd_info_free(data);
}
else if (strcmp("--version", argv[1]) == 0 ||
if (rrd_xport
(argc - 1, &argv[1], &xxsize, &start, &end, &step, &col_cnt,
&legend_v, &data) != -1) {
+ char *old_locale = setlocale(LC_NUMERIC, "C");
row_cnt = (end - start) / step;
ptr = data;
printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n\n",
XML_ENCODING);
printf("<%s>\n", ROOT_TAG);
printf(" <%s>\n", META_TAG);
- printf(" <%s>%lu</%s>\n", META_START_TAG,
- (unsigned long) start + step, META_START_TAG);
+ printf(" <%s>%lld</%s>\n", META_START_TAG,
+ (long long int) start + step, META_START_TAG);
printf(" <%s>%lu</%s>\n", META_STEP_TAG, step, META_STEP_TAG);
- printf(" <%s>%lu</%s>\n", META_END_TAG, (unsigned long) end,
+ printf(" <%s>%lld</%s>\n", META_END_TAG, (long long int) end,
META_END_TAG);
printf(" <%s>%lu</%s>\n", META_ROWS_TAG, row_cnt,
META_ROWS_TAG);
printf(" <%s>\n", DATA_TAG);
for (ti = start + step; ti <= end; ti += step) {
printf(" <%s>", DATA_ROW_TAG);
- printf("<%s>%lu</%s>", COL_TIME_TAG, ti, COL_TIME_TAG);
+ printf("<%s>%lld</%s>", COL_TIME_TAG, (long long int)ti, COL_TIME_TAG);
for (j = 0; j < col_cnt; j++) {
rrd_value_t newval = DNAN;
free(data);
printf(" </%s>\n", DATA_TAG);
printf("</%s>\n", ROOT_TAG);
+ setlocale(LC_NUMERIC, old_locale);
}
free(vtag);
+
} else if (strcmp("graph", argv[1]) == 0) {
char **calcpr;
}
} else if (strcmp("graphv", argv[1]) == 0) {
- info_t *grinfo = NULL; /* 1 to distinguish it from the NULL that rrd_graph sends in */
+ rrd_info_t *grinfo = NULL; /* 1 to distinguish it from the NULL that rrd_graph sends in */
+
grinfo = rrd_graph_v(argc - 1, &argv[1]);
if (grinfo) {
- info_print(grinfo);
- info_free(grinfo);
+ rrd_info_print(grinfo);
+ rrd_info_free(grinfo);
}
} else if (strcmp("tune", argv[1]) == 0)
int CreateArgs(
char *pName,
char *aLine,
- int argc,
char **argv)
{
char *getP, *putP;
char Quote = 0;
int inArg = 0;
int len;
+ int argc = 1;
len = strlen(aLine);
/* remove trailing space and newlines */