New file: lib/idcache.h
[pspp] / lib / idcache.c
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 *