* amd/info_file.c (file_init_or_mtime): consolidate identical
authorErez Zadok <ezk@cs.sunysb.edu>
Tue, 8 Mar 2005 02:51:30 +0000 (02:51 +0000)
committerErez Zadok <ezk@cs.sunysb.edu>
Tue, 8 Mar 2005 02:51:30 +0000 (02:51 +0000)
file_init and file_mtime into one function.

ChangeLog
amd/info_file.c
amd/mapc.c

index f968da101302b66044d02932a02a54e82f786ca5..81835c98cfb878cffdadb01efe9e368759a9fc34 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-03-07  Erez Zadok  <ezk@cs.sunysb.edu>
+
+       * amd/info_file.c (file_init_or_mtime): consolidate identical
+       file_init and file_mtime into one function.
+
 2005-03-05  Erez Zadok  <ezk@cs.sunysb.edu>
 
        * doc/am-utils.texi (Program Filesystem): if umount/unmount are
index 5d147e577f75430cb490f973d6c1360af185f03e..27d99169c88be2a0c2e1a63f4c2137ef6f0e5f6b 100644 (file)
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: info_file.c,v 1.12 2005/01/03 20:56:45 ezk Exp $
+ * $Id: info_file.c,v 1.13 2005/03/08 02:51:30 ezk Exp $
  *
  */
 
 #define        MAX_LINE_LEN    1500
 
 /* forward declarations */
-int file_init(mnt_map *m, char *map, time_t *tp);
+int file_init_or_mtime(mnt_map *m, char *map, time_t *tp);
 int file_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *));
 int file_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp);
-int file_mtime(mnt_map *m, char *map, time_t *tp);
 
 
 static int
@@ -96,7 +95,12 @@ read_line(char *buf, int size, FILE *fp)
  * Try to locate a key in a file
  */
 static int
-search_or_reload_file(FILE *fp, char *map, char *key, char **val, mnt_map *m, void (*fn) (mnt_map *m, char *, char *))
+file_search_or_reload(FILE *fp,
+                     char *map,
+                     char *key,
+                     char **val,
+                     mnt_map *m,
+                     void (*fn) (mnt_map *m, char *, char *))
 {
   char key_val[MAX_LINE_LEN];
   int chuck = 0;
@@ -202,7 +206,7 @@ file_open(char *map, time_t *tp)
 
 
 int
-file_init(mnt_map *m, char *map, time_t *tp)
+file_init_or_mtime(mnt_map *m, char *map, time_t *tp)
 {
   FILE *mapf = file_open(map, tp);
 
@@ -220,7 +224,7 @@ file_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *))
   FILE *mapf = file_open(map, (time_t *) 0);
 
   if (mapf) {
-    int error = search_or_reload_file(mapf, map, 0, 0, m, fn);
+    int error = file_search_or_reload(mapf, map, 0, 0, m, fn);
     (void) fclose(mapf);
     return error;
   }
@@ -240,23 +244,10 @@ file_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
       *tp = t;
       error = -1;
     } else {
-      error = search_or_reload_file(mapf, map, key, pval, 0, 0);
+      error = file_search_or_reload(mapf, map, key, pval, 0, 0);
     }
     (void) fclose(mapf);
     return error;
   }
   return errno;
 }
-
-
-int
-file_mtime(mnt_map *m, char *map, time_t *tp)
-{
-  FILE *mapf = file_open(map, tp);
-
-  if (mapf) {
-    (void) fclose(mapf);
-    return 0;
-  }
-  return errno;
-}
index be1173532fee6dd51593a96676a18232dac1d5ac..6953cb41aeaf6823fda5df9d865ee5e2f44bc034 100644 (file)
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: mapc.c,v 1.22 2005/01/18 03:01:24 ib42 Exp $
+ * $Id: mapc.c,v 1.23 2005/03/08 02:51:30 ezk Exp $
  *
  */
 
@@ -200,10 +200,9 @@ extern int ndbm_mtime(mnt_map *, char *, time_t *);
 
 /* FILE MAPS */
 #ifdef HAVE_MAP_FILE
-extern int file_init(mnt_map *, char *, time_t *);
+extern int file_init_or_mtime(mnt_map *, char *, time_t *);
 extern int file_reload(mnt_map *, char *, add_fn *);
 extern int file_search(mnt_map *, char *, char *, char **, time_t *);
-extern int file_mtime(mnt_map *, char *, time_t *);
 #endif /* HAVE_MAP_FILE */
 
 
@@ -299,11 +298,11 @@ static map_type maptypes[] =
 #ifdef HAVE_MAP_FILE
   {
     "file",
-    file_init,
+    file_init_or_mtime,
     file_reload,
     NULL,                      /* isup function */
     file_search,
-    file_mtime,
+    file_init_or_mtime,
     MAPC_ALL
   },
 #endif /* HAVE_MAP_FILE */