return (strlen (dst));
}
+int strsubstitute (char *str, char c_from, char c_to)
+{
+ int ret;
+
+ if (str == NULL)
+ return (-1);
+
+ ret = 0;
+ while (*str != '\0')
+ {
+ if (*str == c_from)
+ {
+ *str = c_to;
+ ret++;
+ }
+ str++;
+ }
+
+ return (ret);
+}
+
int escape_slashes (char *buf, int buf_len)
{
int i;
return (-1);
}
+ fprintf (log, "epoch");
for (i = 0; i < ds_num; i++)
{
char *name;
char *tmp;
- name = index (ds_def[i], ':');
+ name = strchr (ds_def[i], ':');
if (name == NULL)
{
syslog (LOG_WARNING, "Invalid DS definition '%s' for %s",
}
name += 1;
- tmp = index(name, ':');
+ tmp = strchr (name, ':');
if (tmp == NULL)
{
syslog (LOG_WARNING, "Invalid DS definition '%s' for %s",
return (-1);
}
- if (i != 0)
- fprintf (log, ":");
- fprintf(log, "%.*s", (tmp - name), name);
+ /* The `%.*s' is needed because there is no null-byte behind
+ * the name. */
+ fprintf(log, ",%.*s", (tmp - name), name);
}
fprintf(log, "\n");
fclose(log);
struct stat statbuf;
char full_file[1024];
+ /* Cook the values a bit: Substitute colons with commas */
+ strsubstitute (values, ':', ',');
+
/* host == NULL => local mode */
if (host != NULL)
{
time_t now;
struct tm *tm;
+ /* TODO: Find a way to minimize the calls to `localtime', since
+ * they are pretty expensive.. */
now = time (NULL);
tm = localtime (&now);