From 5866ee2f1560e27dff4d60f09429818ab8401333 Mon Sep 17 00:00:00 2001 From: Dmitri Pal Date: Sun, 18 Mar 2012 14:56:44 -0400 Subject: Function to check for changes Added function to detect changes to the configuration file. --- ini/ini_configobj.h | 4 ++-- ini/ini_fileobj.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 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 5764933..552cedd 100644 --- a/ini/ini_fileobj.c +++ b/ini/ini_fileobj.c @@ -484,3 +484,37 @@ int ini_config_access_check(struct ini_cfgfile *file_ctx, return EOK; } + +/* Determins if two file contexts are 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) +{ + 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 EOK; +} -- cgit