shishi-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

shishi/db file.c fileutil.c internal.h


From: shishi-commit
Subject: shishi/db file.c fileutil.c internal.h
Date: Sun, 30 Nov 2003 15:05:45 -0500

CVSROOT:        /cvsroot/shishi
Module name:    shishi
Branch:         
Changes by:     Simon Josefsson <address@hidden>        03/11/30 15:05:45

Modified files:
        db             : file.c fileutil.c internal.h 

Log message:
        Fix.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/db/file.c.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/db/fileutil.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/db/internal.h.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: shishi/db/file.c
diff -u shishi/db/file.c:1.7 shishi/db/file.c:1.8
--- shishi/db/file.c:1.7        Sun Nov 30 14:38:56 2003
+++ shishi/db/file.c    Sun Nov 30 15:05:45 2003
@@ -49,7 +49,19 @@
 
 #include "internal.h"
 
-#include "fileutil.c"
+/* fileutil.c */
+extern int _shisa_isdir (const char *path);
+extern int _shisa_isdir3 (const char *path1, const char *path2,
+                         const char *path3);
+extern int _shisa_mtime4 (const char *path1, const char *path2,
+                         const char *path3, const char *path4);
+extern int _shisa_isfile4 (const char *path1, const char *path2,
+                          const char *path3, const char *path4);
+extern int _shisa_uint32link4 (const char *path1, const char *path2,
+                              const char *path3, const char *path4);
+extern int _shisa_ls (const char *path, char ***files, size_t *nfiles);
+extern int _shisa_ls2 (const char *path1, const char *path2,
+                      char ***files, size_t *nfiels);
 
 struct Shisa_file
 {
@@ -116,12 +128,8 @@
   Shisa_file *info;
   int rc;
 
-  if (!isdir (location))
-    {
-      errno = ENOTDIR;
-      perror (location);
-      return SHISA_OPEN_ERROR;
-    }
+  if (!_shisa_isdir (location))
+    return SHISA_OPEN_ERROR;
 
   *state = info = xcalloc (1, sizeof (*info));
   rc = shisa_file_cfg (dbh, info, options);
@@ -142,7 +150,7 @@
   Shisa_file *info = state;
   int rc;
 
-  rc = ls (info->path, realms, nrealms);
+  rc = _shisa_ls (info->path, realms, nrealms);
 
   return rc;
 }
@@ -155,14 +163,9 @@
                                 size_t *nprincipals)
 {
   Shisa_file *info = state;
-  char *tmp;
   int rc;
 
-  asprintf (&tmp, "%s/%s", info->path, realm);
-
-  rc = ls (tmp, principals, nprincipals);
-
-  free (tmp);
+  rc = _shisa_ls2 (info->path, realm, principals, nprincipals);
 
   return rc;
 }
@@ -177,25 +180,28 @@
   Shisa_file *info = state;
   Shisa_principal *princ;
 
-  if (!isdir3 (info->path, realm, client))
+  if (!_shisa_isdir3 (info->path, realm, client))
     return SHISA_NO_PRINCIPAL;
 
   princ = xmalloc (sizeof (*princ));
   princ->name = xstrdup (client);
   princ->realm = xstrdup (realm);
-  princ->notusedbefore = mtime4 (info->path, realm, client, "validfrom.stamp");
-  princ->isdisabled = isfile4 (info->path, realm, client, "disabled.flag");
-  princ->kvno = uint32link4 (info->path, realm, client, "latest.key");
+  princ->notusedbefore =
+    _shisa_mtime4 (info->path, realm, client, "validfrom.stamp");
+  princ->isdisabled =
+    _shisa_isfile4 (info->path, realm, client, "disabled.flag");
+  princ->kvno = _shisa_uint32link4 (info->path, realm, client, "latest.key");
   princ->lastinitialtgt =
-    mtime4 (info->path, realm, client, "lastinitaltgt.stamp");
+    _shisa_mtime4 (info->path, realm, client, "lastinitaltgt.stamp");
   princ->lastinitialrequest =
-    mtime4 (info->path, realm, client, "lastinitial.stamp");
-  princ->lasttgt = mtime4 (info->path, realm, client, "lasttgt.stamp");
-  princ->lastrenewal = mtime4 (info->path, realm, client, "lastrenewal.stamp");
+    _shisa_mtime4 (info->path, realm, client, "lastinitial.stamp");
+  princ->lasttgt = _shisa_mtime4 (info->path, realm, client, "lasttgt.stamp");
+  princ->lastrenewal =
+    _shisa_mtime4 (info->path, realm, client, "lastrenewal.stamp");
   princ->passwordexpire =
-    mtime4 (info->path, realm, client, "passwordexpire.stamp");
+    _shisa_mtime4 (info->path, realm, client, "passwordexpire.stamp");
   princ->accountexpire =
-    mtime4 (info->path, realm, client, "accountexpire.stamp");
+    _shisa_mtime4 (info->path, realm, client, "accountexpire.stamp");
 
   *ph = princ;
 
Index: shishi/db/fileutil.c
diff -u shishi/db/fileutil.c:1.1 shishi/db/fileutil.c:1.2
--- shishi/db/fileutil.c:1.1    Sun Nov 30 14:38:56 2003
+++ shishi/db/fileutil.c        Sun Nov 30 15:05:45 2003
@@ -19,7 +19,7 @@
  *
  */
 
-/* Note!  This file is #include'd by file.c. */
+#include "internal.h"
 
 /* For stat. */
 #include <sys/stat.h>
@@ -36,15 +36,19 @@
 
 #include "xreadlink.h"
 
-static int
-isdir (const char *path)
+int
+_shisa_isdir (const char *path)
 {
   struct stat buf;
   int rc;
 
   rc = stat (path, &buf);
   if (rc != 0 || !S_ISDIR (buf.st_mode))
-    return 0;
+    {
+      errno = ENOTDIR;
+      perror (path);
+      return 0;
+    }
 
   return 1;
 }
@@ -57,22 +61,22 @@
 
   asprintf (&tmp, "%s/%s", path1, path2);
 
-  rc = isdir (tmp);
+  rc = _shisa_isdir (tmp);
 
   free (tmp);
 
   return rc;
 }
 
-static int
-isdir3 (const char *path1, const char *path2, const char *path3)
+int
+_shisa_isdir3 (const char *path1, const char *path2, const char *path3)
 {
   char *tmp;
   int rc;
 
   asprintf (&tmp, "%s/%s/%s", path1, path2, path3);
 
-  rc = isdir (tmp);
+  rc = _shisa_isdir (tmp);
 
   free (tmp);
 
@@ -92,41 +96,11 @@
   return buf.st_atime;
 }
 
-static int
-mtime2 (const char *path1, const char *path2)
-{
-  char *tmp;
-  int rc;
-
-  asprintf (&tmp, "%s/%s", path1, path2);
-
-  rc = mtime (tmp);
-
-  free (tmp);
-
-  return rc;
-}
-
-static int
-mtime3 (const char *path1, const char *path2, const char *path3)
-{
-  char *tmp;
-  int rc;
-
-  asprintf (&tmp, "%s/%s/%s", path1, path2, path3);
-
-  rc = mtime (tmp);
-
-  free (tmp);
-
-  return rc;
-}
-
-static int
-mtime4 (const char *path1,
-       const char *path2,
-       const char *path3,
-       const char *path4)
+int
+_shisa_mtime4 (const char *path1,
+              const char *path2,
+              const char *path3,
+              const char *path4)
 {
   char *tmp;
   int rc;
@@ -153,11 +127,11 @@
   return 1;
 }
 
-static int
-isfile4 (const char *path1,
-       const char *path2,
-       const char *path3,
-       const char *path4)
+int
+_shisa_isfile4 (const char *path1,
+               const char *path2,
+               const char *path3,
+               const char *path4)
 {
   char *tmp;
   int rc;
@@ -185,11 +159,11 @@
   return atol (link);
 }
 
-static int
-uint32link4 (const char *path1,
-            const char *path2,
-            const char *path3,
-            const char *path4)
+int
+_shisa_uint32link4 (const char *path1,
+                   const char *path2,
+                   const char *path3,
+                   const char *path4)
 {
   char *tmp;
   int rc;
@@ -211,7 +185,7 @@
 }
 
 static int
-ls_1 (const char *path, char ***files, size_t *nfiles, DIR *dir)
+_shisa_ls_1 (const char *path, char ***files, size_t *nfiles, DIR *dir)
 {
   struct dirent *de;
   int rc;
@@ -243,8 +217,8 @@
   return SHISA_OK;
 }
 
-static int
-ls (const char *path, char ***files, size_t *nfiles)
+int
+_shisa_ls (const char *path, char ***files, size_t *nfiles)
 {
   struct dirent *de;
   DIR *dir;
@@ -257,7 +231,7 @@
       return -1;
     }
 
-  rc = ls_1 (path, files, nfiles, dir);
+  rc = _shisa_ls_1 (path, files, nfiles, dir);
   if (rc != SHISA_OK)
     {
       rc = closedir (dir);
@@ -281,4 +255,20 @@
     }
 
   return 0;
+}
+
+int
+_shisa_ls2 (const char *path1, const char *path2,
+           char ***files, size_t *nfiles)
+{
+  char *tmp;
+  int rc;
+
+  asprintf (&tmp, "%s/%s", path1, path2);
+
+  rc = _shisa_ls (tmp, files, nfiles);
+
+  free (tmp);
+
+  return rc;
 }
Index: shishi/db/internal.h
diff -u shishi/db/internal.h:1.4 shishi/db/internal.h:1.5
--- shishi/db/internal.h:1.4    Fri Nov 28 21:43:26 2003
+++ shishi/db/internal.h        Sun Nov 30 15:05:45 2003
@@ -86,6 +86,12 @@
   size_t ndbs;
 };
 
+extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
+
+/* db.c */
+extern _Shisa_backend *_shisa_find_backend (const char *name);
+
+/* file.c */
 extern int shisa_file_init (Shisa *dbh,
                            const char *location,
                            const char *options,
@@ -105,8 +111,5 @@
                                      const char *realm,
                                      Shisa_principal **ph);
 extern void shisa_file_done (Shisa *dbh, void *state);
-
-extern _Shisa_backend *_shisa_find_backend (const char *name);
-extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
 
 #endif /* _INTERNAL_H */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]