summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2010-12-26 21:28:59 -0500
committerDmitri Pal <dpal@redhat.com>2011-01-03 15:00:43 -0500
commit81e90b377b432ef874fda11b6e82f6f0eb894807 (patch)
treef8a706890a95ee209e2160bf775bf96673081bd2
parentc4d2383282b898f4c5914bf720301cdcabf5eb51 (diff)
downloadding-libs-81e90b377b432ef874fda11b6e82f6f0eb894807.tar.gz
ding-libs-81e90b377b432ef874fda11b6e82f6f0eb894807.tar.xz
ding-libs-81e90b377b432ef874fda11b6e82f6f0eb894807.zip
[INI] Function to check for changes
Added function to detect changes to the configuration file.
-rw-r--r--ini/ini_configobj.h4
-rw-r--r--ini/ini_fileobj.c37
2 files changed, 39 insertions, 2 deletions
diff --git a/ini/ini_configobj.h b/ini/ini_configobj.h
index eccad71..913b91e 100644
--- a/ini/ini_configobj.h
+++ b/ini/ini_configobj.h
@@ -335,8 +335,8 @@ int ini_config_access_check(struct ini_cfgfile *file_ctx,
* - device ID
* - i-node
*/
-int ini_config_changed(struct ini_cfgfile *file_ctx,
- struct ini_cfgfile *file_ctx_saved,
+int ini_config_changed(struct ini_cfgfile *file_ctx1,
+ struct ini_cfgfile *file_ctx2,
int *changed);
diff --git a/ini/ini_fileobj.c b/ini/ini_fileobj.c
index 2d47c8f..6de9639 100644
--- a/ini/ini_fileobj.c
+++ b/ini/ini_fileobj.c
@@ -484,3 +484,40 @@ int ini_config_access_check(struct ini_cfgfile *file_ctx,
return error;
}
+
+/* Determins if two file context different by comparing
+ * - time stamp
+ * - device ID
+ * - i-node
+ */
+int ini_config_changed(struct ini_cfgfile *file_ctx1,
+ struct ini_cfgfile *file_ctx2,
+ int *changed)
+{
+
+ int error = EOK;
+
+ TRACE_FLOW_ENTRY();
+
+ if ((file_ctx1 == NULL) ||
+ (file_ctx2 == NULL) ||
+ (changed == NULL)) {
+ TRACE_ERROR_NUMBER("Invalid parameter.", EINVAL);
+ return EINVAL;
+ }
+
+ *changed = 0;
+
+ if((file_ctx1->file_stats.st_mtime !=
+ file_ctx2->file_stats.st_mtime) ||
+ (file_ctx1->file_stats.st_dev !=
+ file_ctx2->file_stats.st_dev) ||
+ (file_ctx1->file_stats.st_ino !=
+ file_ctx2->file_stats.st_ino)) {
+ TRACE_INFO_STRING("File changed!", "");
+ *changed = 1;
+ }
+
+ TRACE_FLOW_EXIT();
+ return error;
+}