Update.
[glibc.git] / nscd / nscd.h
blob9177235911f9544c282ab3fa1b7a9881e613a955
1 /* Copyright (c) 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.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 struct hashentry *next; /* Next entry in this hash bucket list. */
50 time_t timeout; /* Time when this entry becomes invalid. */
51 ssize_t total; /* Number of bytes in PACKET. */
52 const void *packet; /* Records for the result. */
53 void *data; /* The malloc()ed respond record. */
54 int last; /* Nonzero if DATA should be free()d. */
55 struct hashentry *dellist; /* Next record to be deleted. */
58 /* Structure describing one database. */
59 struct database
61 pthread_rwlock_t lock;
63 int enabled;
64 int check_file;
65 const char *filename;
66 time_t file_mtime;
67 size_t module;
69 const struct iovec *disabled_iov;
71 unsigned long int postimeout;
72 unsigned long int negtimeout;
74 unsigned long int poshit;
75 unsigned long int neghit;
76 unsigned long int posmiss;
77 unsigned long int negmiss;
79 struct hashentry **array;
83 /* Global variables. */
84 extern const char *dbnames[lastdb];
85 extern const char *serv2str[LASTREQ];
87 extern const struct iovec pwd_iov_disabled;
88 extern const struct iovec grp_iov_disabled;
89 extern const struct iovec hst_iov_disabled;
91 /* Number of threads to run. */
92 extern int nthreads;
95 /* Prototypes for global functions. */
97 /* nscd.c */
98 extern void termination_handler (int signum);
99 extern int nscd_open_socket (void);
101 /* connections.c */
102 extern void nscd_init (const char *conffile);
103 extern void close_sockets (void);
104 extern void start_threads (void);
106 /* nscd_conf.c */
107 extern int nscd_parse_file (const char *fname, struct database dbs[lastdb]);
109 /* nscd_stat.c */
110 extern void send_stats (int fd, struct database dbs[lastdb]);
111 extern int receive_print_stats (void);
113 /* cache.c */
114 extern struct hashentry *cache_search (int type, void *key, size_t len,
115 struct database *table);
116 extern void cache_add (int type, void *key, size_t len,
117 const void *packet, size_t iovtotal, void *data,
118 int last, time_t t, struct database *table);
119 extern void prune_cache (struct database *table, time_t now);
121 /* pwdcache.c */
122 extern void addpwbyname (struct database *db, int fd, request_header *req,
123 void *key);
124 extern void addpwbyuid (struct database *db, int fd, request_header *req,
125 void *key);
127 /* grpcache.c */
128 extern void addgrbyname (struct database *db, int fd, request_header *req,
129 void *key);
130 extern void addgrbygid (struct database *db, int fd, request_header *req,
131 void *key);
133 /* hstcache.c */
134 extern void addhstbyname (struct database *db, int fd, request_header *req,
135 void *key);
136 extern void addhstbyaddr (struct database *db, int fd, request_header *req,
137 void *key);
138 extern void addhstbynamev6 (struct database *db, int fd, request_header *req,
139 void *key);
140 extern void addhstbyaddrv6 (struct database *db, int fd, request_header *req,
141 void *key);
144 #endif /* nscd.h */