+/*********************************************************************
+ *
+ * Function : file_has_been_modified
+ *
+ * Description : Helper function to check if a file has been changed
+ *
+ * Parameters :
+ * 1 : filename = The name of the file to check
+ * 2 : last_known_modification = The time of the last known
+ * modification
+ *
+ * Returns : TRUE if the file has been changed,
+ * FALSE otherwise.
+ *
+ *********************************************************************/
+static int file_has_been_modified(const char *filename, time_t last_know_modification)
+{
+ struct stat statbuf[1];
+
+ if (stat(filename, statbuf) < 0)
+ {
+ /* Error, probably file not found which counts as change. */
+ return 1;
+ }
+
+ return (last_know_modification != statbuf->st_mtime);
+}
+
+
+/*********************************************************************
+ *
+ * Function : any_loaded_file_changed
+ *
+ * Description : Helper function to check if any loaded file has been
+ * changed since the time it has been loaded.
+ *
+ * XXX: Should we cache the return value for x seconds?
+ *
+ * Parameters :
+ * 1 : files_to_check = List of files to check
+ *
+ * Returns : TRUE if any file has been changed,
+ * FALSE otherwise.
+ *
+ *********************************************************************/
+int any_loaded_file_changed(const struct client_state *csp)
+{
+ const struct file_list *file_to_check = csp->config->config_file_list;
+ int i;
+
+ if (file_has_been_modified(file_to_check->filename, file_to_check->lastmodified))
+ {
+ return TRUE;
+ }
+
+ for (i = 0; i < MAX_AF_FILES; i++)
+ {
+ if (csp->actions_list[i])
+ {
+ file_to_check = csp->actions_list[i];
+ if (file_has_been_modified(file_to_check->filename, file_to_check->lastmodified))
+ {
+ return TRUE;
+ }
+ }
+ }
+
+ for (i = 0; i < MAX_AF_FILES; i++)
+ {
+ if (csp->rlist[i])
+ {
+ file_to_check = csp->rlist[i];
+ if (file_has_been_modified(file_to_check->filename, file_to_check->lastmodified))
+ {
+ return TRUE;
+ }
+ }
+ }
+
+#ifdef FEATURE_TRUST
+ if (csp->tlist)
+ {
+ if (file_has_been_modified(csp->tlist->filename, csp->tlist->lastmodified))
+ {
+ return TRUE;
+ }
+ }
+#endif /* def FEATURE_TRUST */
+
+ return FALSE;
+}
+