New file: lib/idcache.h
authorJim Meyering <jim@meyering.net>
Sat, 18 Aug 2007 07:16:52 +0000 (07:16 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 18 Aug 2007 07:16:52 +0000 (07:16 +0000)
* NEWS: Mention the addition.
* modules/idcache (Files): Add lib/idcache.h
* lib/idcache.c: Include "idcache.h".
Don't include <sys/types.h>.
Add a FIXME comment.
Move file-scoped "static" declarations to the top.
* lib/idcache.h: New file.  Include <sys/types.h> here, instead.

ChangeLog
NEWS
lib/idcache.c
lib/idcache.h [new file with mode: 0644]
modules/idcache

index f683c2cfc0d687c4606caa167316b378d129e94f..77170822df7679879c16c73e85b01b8aea4f4a54 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-08-18  Jim Meyering  <jim@meyering.net>
+
+       New file: lib/idcache.h
+       * NEWS: Mention the addition.
+       * modules/idcache (Files): Add lib/idcache.h
+       * lib/idcache.c: Include "idcache.h".
+       Don't include <sys/types.h>.
+       Add a FIXME comment.
+       Move file-scoped "static" declarations to the top.
+       * lib/idcache.h: New file.  Include <sys/types.h> here, instead.
+
 2007-08-17  Bruno Haible  <bruno@clisp.org>
        and Paul Eggert  <eggert@cs.ucla.edu>
 
diff --git a/NEWS b/NEWS
index dfc1b46485cfb8080432477fcb451b185a7f573f..e4009e1c0fb2bbb59e8690282c8134257bc5b94b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2007-08-18  idcache         Now provides prototypes in "idcache.h".
+
 2007-08-10  xstrtol         The STRTOL_FATAL_ERROR macro is removed.
                             Use the new xstrtol_fatal function instead.
 
index 0706f007f57b33f3582eb842bc22ea3ba7cfa63e..8fb8bedc66e095947bb33318ba0b0791c4a72683 100644 (file)
@@ -1,6 +1,6 @@
 /* idcache.c -- map user and group IDs, cached for speed
 
-   Copyright (C) 1985, 1988, 1989, 1990, 1997, 1998, 2003, 2005, 2006
+   Copyright (C) 1985, 1988, 1989, 1990, 1997, 1998, 2003, 2005-2007
    Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
 
 #include <config.h>
 
+#include "idcache.h"
 #include <stddef.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/types.h>
 #include <pwd.h>
 #include <grp.h>
 
@@ -45,11 +45,24 @@ struct userid
   char name[FLEXIBLE_ARRAY_MEMBER];
 };
 
+/* FIXME: provide a function to free any malloc'd storage and reset lists,
+   so that an application can use code like this just before exiting:
+   #ifdef lint
+     idcache_clear ();
+   #endif
+*/
+
 static struct userid *user_alist;
 
 /* Each entry on list is a user name for which the first lookup failed.  */
 static struct userid *nouser_alist;
 
+/* Use the same struct as for userids.  */
+static struct userid *group_alist;
+
+/* Each entry on list is a group name for which the first lookup failed.  */
+static struct userid *nogroup_alist;
+
 /* Translate UID to a login name, with cache, or NULL if unresolved.  */
 
 char *
@@ -132,12 +145,6 @@ getuidbyname (const char *user)
   return NULL;
 }
 
-/* Use the same struct as for userids.  */
-static struct userid *group_alist;
-
-/* Each entry on list is a group name for which the first lookup failed.  */
-static struct userid *nogroup_alist;
-
 /* Translate GID to a group name, with cache, or NULL if unresolved.  */
 
 char *
diff --git a/lib/idcache.h b/lib/idcache.h
new file mode 100644 (file)
index 0000000..e7573b8
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef IDCACHE_H
+# define IDCACHE_H 1
+
+# include <sys/types.h>
+
+extern char *getuser (uid_t uid);
+extern char *getgroup (gid_t gid);
+extern uid_t *getuidbyname (const char *user);
+extern gid_t *getgidbyname (const char *group);
+
+#endif
index 97cc71498b0c8d3fbbf44525504a746bf8a76400..234864145911d314f7d4876aff5a89421d1e355c 100644 (file)
@@ -3,6 +3,7 @@ Username <--> uid and groupname <--> gid conversions, with cache for speed.
 
 Files:
 lib/idcache.c
+lib/idcache.h
 m4/idcache.m4
 
 Depends-on: