diff --git a/src/csv.c b/src/csv.c
index afb4f8338c5d7e2611e489338eda5a642f3c56b8..15494f450dd60a852be2b948c8356c781194c2e1 100644 (file)
--- a/src/csv.c
+++ b/src/csv.c
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
- * Florian octo Forster <octo at verplant.org>
+ * Florian octo Forster <octo at collectd.org>
* Doug MacEachern <dougm@hyperic.com>
**/
* Doug MacEachern <dougm@hyperic.com>
**/
#include "plugin.h"
#include "common.h"
#include "utils_cache.h"
#include "plugin.h"
#include "common.h"
#include "utils_cache.h"
-#include "utils_parse_option.h"
/*
* Private variables
/*
* Private variables
{
int offset;
int status;
{
int offset;
int status;
- int i;
+ size_t i;
gauge_t *rates = NULL;
assert (0 == strcmp (ds->type, vl->type));
gauge_t *rates = NULL;
assert (0 == strcmp (ds->type, vl->type));
{
int status;
{
int status;
- char *ptr;
- size_t ptr_size;
+ char *ptr = buffer;
+ size_t ptr_size = buffer_size;
time_t now;
struct tm struct_tm;
time_t now;
struct tm struct_tm;
- status = FORMAT_VL (buffer, buffer_size, vl);
+ if (datadir != NULL)
+ {
+ size_t len = strlen (datadir) + 1;
+
+ if (len >= ptr_size)
+ return (ENOBUFS);
+
+ memcpy (ptr, datadir, len);
+ ptr[len-1] = '/';
+ ptr_size -= len;
+ ptr += len;
+ }
+
+ status = FORMAT_VL (ptr, ptr_size, vl);
if (status != 0)
return (status);
if (status != 0)
return (status);
if (use_stdio)
return (0);
if (use_stdio)
return (0);
- ptr_size = buffer_size - strlen (buffer);
- ptr = buffer + strlen (buffer);
+ ptr_size -= strlen (ptr);
+ ptr += strlen (ptr);
/* "-2013-07-12" => 11 bytes */
if (ptr_size < 12)
/* "-2013-07-12" => 11 bytes */
if (ptr_size < 12)
static int csv_create_file (const char *filename, const data_set_t *ds)
{
FILE *csv;
static int csv_create_file (const char *filename, const data_set_t *ds)
{
FILE *csv;
- int i;
+ size_t i;
if (check_create_dir (filename))
return (-1);
if (check_create_dir (filename))
return (-1);
if (strcasecmp ("DataDir", key) == 0)
{
if (datadir != NULL)
if (strcasecmp ("DataDir", key) == 0)
{
if (datadir != NULL)
+ {
free (datadir);
free (datadir);
+ datadir = NULL;
+ }
if (strcasecmp ("stdout", value) == 0)
{
use_stdio = 1;
if (strcasecmp ("stdout", value) == 0)
{
use_stdio = 1;