(Hash Search Function): Describe that memory must be cleared before calling hcreate_r.
[glibc.git] / nscd / nscd.h
blob11a30176df2522a8653b41899f8bc6bb2ad13bdb
1 /* Copyright (c) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@suse.de>, 1998.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #ifndef _NSCD_H
21 #define _NSCD_H 1
23 #include <pthread.h>
24 #include <time.h>
25 #include <sys/uio.h>
27 /* The declarations for the request and response types are in the file
28 "nscd-client.h", which should contain everything needed by client
29 functions. */
30 #include "nscd-client.h"
33 /* Handle databases. */
34 typedef enum
36 pwddb,
37 grpdb,
38 hstdb,
39 lastdb
40 } dbtype;
43 /* Structure for one hash table entry. */
44 struct hashentry
46 request_type type; /* Which type of dataset. */
47 size_t len; /* Length of key. */
48 void *key; /* Pointer to key. */
49 uid_t owner; /* If secure table, this is the owner. */
50 struct hashentry *next; /* Next entry in this hash bucket list. */
51 time_t timeout; /* Time when this entry becomes invalid. */
52 ssize_t total; /* Number of bytes in PACKET. */
53 const void *packet; /* Records for the result. */
54 void *data; /* The malloc()ed respond record. */
55 int last; /* Nonzero if DATA should be free()d. */
56 struct hashentry *dellist; /* Next record to be deleted. */
59 /* Structure describing one database. */
60 struct database
62 pthread_rwlock_t lock;
64 int enabled;
65 int check_file;
66 const char *filename;
67 time_t file_mtime;
68 size_t module;
70 const struct iovec *disabled_iov;
72 unsigned long int postimeout;
73 unsigned long int negtimeout;
75 unsigned long int poshit;
76 unsigned long int neghit;
77 unsigned long int posmiss;
78 unsigned long int negmiss;
80 struct hashentry **array;
84 /* Global variables. */
85 extern const char *dbnames[lastdb];
86 extern const char *serv2str[LASTREQ];
88 extern const struct iovec pwd_iov_disabled;
89 extern const struct iovec grp_iov_disabled;
90 extern const struct iovec hst_iov_disabled;
92 /* Number of threads to run. */
93 extern int nthreads;
95 /* Tables for which we cache data with uid */
96 extern int secure[lastdb];
97 extern int secure_in_use; /* Is one of the above 1 ? */
99 /* User name to run server processes as */
100 extern const char *server_user;
102 /* Prototypes for global functions. */
104 /* nscd.c */
105 extern void termination_handler (int signum) __attribute__ ((__noreturn__));
106 extern int nscd_open_socket (void);
108 /* connections.c */
109 extern void nscd_init (const char *conffile);
110 extern void close_sockets (void);
111 extern void start_threads (void) __attribute__ ((__noreturn__));
113 /* nscd_conf.c */
114 extern int nscd_parse_file (const char *fname, struct database dbs[lastdb]);
116 /* nscd_stat.c */
117 extern void send_stats (int fd, struct database dbs[lastdb]);
118 extern int receive_print_stats (void) __attribute__ ((__noreturn__));
120 /* cache.c */
121 extern struct hashentry *cache_search (int type, void *key, size_t len,
122 struct database *table, uid_t owner);
123 extern void cache_add (int type, void *key, size_t len,
124 const void *packet, size_t iovtotal, void *data,
125 int last, time_t t, struct database *table,
126 uid_t owner);
127 extern void prune_cache (struct database *table, time_t now);
129 /* pwdcache.c */
130 extern void addpwbyname (struct database *db, int fd, request_header *req,
131 void *key, uid_t uid);
132 extern void addpwbyuid (struct database *db, int fd, request_header *req,
133 void *key, uid_t uid);
135 /* grpcache.c */
136 extern void addgrbyname (struct database *db, int fd, request_header *req,
137 void *key, uid_t uid);
138 extern void addgrbygid (struct database *db, int fd, request_header *req,
139 void *key, uid_t uid);
141 /* hstcache.c */
142 extern void addhstbyname (struct database *db, int fd, request_header *req,
143 void *key, uid_t uid);
144 extern void addhstbyaddr (struct database *db, int fd, request_header *req,
145 void *key, uid_t uid);
146 extern void addhstbynamev6 (struct database *db, int fd, request_header *req,
147 void *key, uid_t uid);
148 extern void addhstbyaddrv6 (struct database *db, int fd, request_header *req,
149 void *key, uid_t uid);
152 #endif /* nscd.h */