From dc9484f5465a7f99163c4848e4ad45bf2df528f5 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 18 Aug 2007 07:16:52 +0000 Subject: [PATCH] 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 . Add a FIXME comment. Move file-scoped "static" declarations to the top. * lib/idcache.h: New file. Include here, instead. --- ChangeLog | 11 +++++++++++ NEWS | 2 ++ lib/idcache.c | 23 +++++++++++++++-------- lib/idcache.h | 11 +++++++++++ modules/idcache | 1 + 5 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 lib/idcache.h diff --git a/ChangeLog b/ChangeLog index f683c2cfc0..77170822df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-08-18 Jim Meyering + + 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 . + Add a FIXME comment. + Move file-scoped "static" declarations to the top. + * lib/idcache.h: New file. Include here, instead. + 2007-08-17 Bruno Haible and Paul Eggert diff --git a/NEWS b/NEWS index dfc1b46485..e4009e1c0f 100644 --- 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. diff --git a/lib/idcache.c b/lib/idcache.c index 0706f007f5..8fb8bedc66 100644 --- a/lib/idcache.c +++ b/lib/idcache.c @@ -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 @@ -19,10 +19,10 @@ #include +#include "idcache.h" #include #include #include -#include #include #include @@ -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 index 0000000000..e7573b83f7 --- /dev/null +++ b/lib/idcache.h @@ -0,0 +1,11 @@ +#ifndef IDCACHE_H +# define IDCACHE_H 1 + +# include + +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 diff --git a/modules/idcache b/modules/idcache index 97cc71498b..2348641459 100644 --- a/modules/idcache +++ b/modules/idcache @@ -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: -- 2.30.2