summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a9e8ad5)
raw | patch | inline | side by side (parent: a9e8ad5)
author | octo <octo> | |
Fri, 14 Apr 2006 07:41:40 +0000 (07:41 +0000) | ||
committer | octo <octo> | |
Fri, 14 Apr 2006 07:41:40 +0000 (07:41 +0000) |
src/common.c | patch | blob | history |
diff --git a/src/common.c b/src/common.c
index 0b603fa876dcd9b823584fa355bd66087ab5a94b..56ae326a810eada2c828e292f58d0f15c5e673b3 100644 (file)
--- a/src/common.c
+++ b/src/common.c
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);