Update.
[glibc.git] / nscd / nscd.h
blob36fd1b300295d975a5c99726d42778205d637af7
1 /* Copyright (c) 1998, 1999 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 Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 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 /* Prototypes for global functions. */
101 /* nscd.c */
102 extern void termination_handler (int signum);
103 extern int nscd_open_socket (void);
105 /* connections.c */
106 extern void nscd_init (const char *conffile);
107 extern void close_sockets (void);
108 extern void start_threads (void);
110 /* nscd_conf.c */
111 extern int nscd_parse_file (const char *fname, struct database dbs[lastdb]);
113 /* nscd_stat.c */
114 extern void send_stats (int fd, struct database dbs[lastdb]);
115 extern int receive_print_stats (void);
117 /* cache.c */
118 extern struct hashentry *cache_search (int type, void *key, size_t len,
119 struct database *table, uid_t owner);
120 extern void cache_add (int type, void *key, size_t len,
121 const void *packet, size_t iovtotal, void *data,
122 int last, time_t t, struct database *table,
123 uid_t owner);
124 extern void prune_cache (struct database *table, time_t now);
126 /* pwdcache.c */
127 extern void addpwbyname (struct database *db, int fd, request_header *req,
128 void *key, uid_t uid);
129 extern void addpwbyuid (struct database *db, int fd, request_header *req,
130 void *key, uid_t uid);
132 /* grpcache.c */
133 extern void addgrbyname (struct database *db, int fd, request_header *req,
134 void *key, uid_t uid);
135 extern void addgrbygid (struct database *db, int fd, request_header *req,
136 void *key, uid_t uid);
138 /* hstcache.c */
139 extern void addhstbyname (struct database *db, int fd, request_header *req,
140 void *key, uid_t uid);
141 extern void addhstbyaddr (struct database *db, int fd, request_header *req,
142 void *key, uid_t uid);
143 extern void addhstbynamev6 (struct database *db, int fd, request_header *req,
144 void *key, uid_t uid);
145 extern void addhstbyaddrv6 (struct database *db, int fd, request_header *req,
146 void *key, uid_t uid);
149 #endif /* nscd.h */