summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f3a56fb)
raw | patch | inline | side by side (parent: f3a56fb)
author | Florian Forster <ff@octo.it> | |
Fri, 18 Jun 2010 18:46:27 +0000 (20:46 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Fri, 18 Jun 2010 18:46:27 +0000 (20:46 +0200) |
src/graph_ident.c | patch | blob | history | |
src/graph_ident.h | patch | blob | history | |
src/graph_instance.c | patch | blob | history | |
src/graph_instance.h | patch | blob | history |
diff --git a/src/graph_ident.c b/src/graph_ident.c
index b008a56dac3ae6da05fc3e5d0b2b44b141f826fa..905e73dc96c39a568734d9fb541793ae864d5e55 100644 (file)
--- a/src/graph_ident.c
+++ b/src/graph_ident.c
#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <limits.h> /* PATH_MAX */
+#include <sys/types.h>
+#include <sys/stat.h>
#include "graph_ident.h"
#include "common.h"
#include "filesystem.h"
+#include <fcgiapp.h>
+#include <fcgi_stdio.h>
+
/*
* Data types
*/
return (strdup (buffer));
} /* }}} char *ident_to_json */
+time_t ident_get_mtime (const graph_ident_t *ident) /* {{{ */
+{
+ char *file;
+ struct stat statbuf;
+ int status;
+
+ if (ident == NULL)
+ return (0);
+
+ file = ident_to_file (ident);
+ if (file == NULL)
+ return (0);
+
+ memset (&statbuf, 0, sizeof (statbuf));
+ status = stat (file, &statbuf);
+ if (status != 0)
+ {
+ fprintf (stderr, "ident_get_mtime: stat'ing file \"%s\" failed: %s\n",
+ file, strerror (errno));
+ return (0);
+ }
+
+ free (file);
+ return (statbuf.st_mtime);
+} /* }}} time_t ident_get_mtime */
+
/* vim: set sw=2 sts=2 et fdm=marker : */
diff --git a/src/graph_ident.h b/src/graph_ident.h
index 5107011ed3dec9d9848ee874895c3cdf32df9bd5..af86c9d3c9df06b5fe2e3cd1b7bd70abd7ee3710 100644 (file)
--- a/src/graph_ident.h
+++ b/src/graph_ident.h
#ifndef GRAPH_IDENT_H
#define GRAPH_IDENT_H 1
+#include <time.h>
+
#define ANY_TOKEN "/any/"
#define ALL_TOKEN "/all/"
char *ident_to_file (const graph_ident_t *ident);
char *ident_to_json (const graph_ident_t *ident);
+time_t ident_get_mtime (const graph_ident_t *ident);
+
/* vim: set sw=2 sts=2 et fdm=marker : */
#endif /* GRAPH_IDENT_H */
diff --git a/src/graph_instance.c b/src/graph_instance.c
index 103be23860ba2b913633a9c11a4018989e670b26..bad0bcd7a6fba210dfab3458dbfee9f1a5db224f 100644 (file)
--- a/src/graph_instance.c
+++ b/src/graph_instance.c
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <time.h>
#include "graph_instance.h"
#include "graph_ident.h"
return (0);
} /* }}} int inst_describe */
+time_t inst_get_mtime (graph_instance_t *inst) /* {{{ */
+{
+ size_t i;
+ time_t mtime;
+
+ if (inst == NULL)
+ return (0);
+
+ mtime = 0;
+ for (i = 0; i < inst->files_num; i++)
+ {
+ time_t tmp;
+
+ tmp = ident_get_mtime (inst->files[i]);
+ if (mtime < tmp)
+ mtime = tmp;
+ }
+
+ return (mtime);
+} /* }}} time_t inst_get_mtime */
+
/* vim: set sw=2 sts=2 et fdm=marker : */
diff --git a/src/graph_instance.h b/src/graph_instance.h
index b90f98414d3f1c4e4b5e2e0648849af69577d656..72ab66a657f8162b8340c16cb78e37e499d3cec9 100644 (file)
--- a/src/graph_instance.h
+++ b/src/graph_instance.h
typedef int (*inst_callback_t) (graph_instance_t *inst, void *user_data);
+#include <time.h>
+
#include "graph.h"
#include "utils_array.h"
int inst_describe (graph_config_t *cfg, graph_instance_t *inst,
char *buffer, size_t buffer_size);
+time_t inst_get_mtime (graph_instance_t *inst);
+
#endif /* GRAPH_INSTANCE_H */
/* vim: set sw=2 sts=2 et fdm=marker : */