Document lots of new features and syntax.
[fwd] / bres.h
1 /* -*-c-*-
2 *
3 * $Id: bres.h,v 1.2 1999/07/26 23:27:22 mdw Exp $
4 *
5 * Background reverse name resolution
6 *
7 * (c) 1999 Straylight/Edgeware
8 */
9
10 /*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of the `fw' port forwarder.
13 *
14 * `fw' is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * `fw' is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with `fw'; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 */
28
29 /*----- Revision history --------------------------------------------------*
30 *
31 * $Log: bres.h,v $
32 * Revision 1.2 1999/07/26 23:27:22 mdw
33 * Change copyright notice.
34 *
35 * Revision 1.1.1.1 1999/07/01 08:56:23 mdw
36 * Initial revision.
37 *
38 */
39
40 #ifndef RES_H
41 #define RES_H
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47 /*----- Header files ------------------------------------------------------*/
48
49 #include <sys/types.h>
50
51 #include <sys/socket.h>
52 #include <netinet/in.h>
53 #include <arpa/inet.h>
54
55 #include <mLib/sel.h>
56 #include <mLib/selbuf.h>
57
58 /*----- Data structures ---------------------------------------------------*/
59
60 /* --- Client allocated request block --- */
61
62 typedef struct bres_client {
63 struct bres_client *next, *prev; /* Queue of waiting resolve jobs */
64 struct bres_server *rs; /* Pointer to attached server */
65 struct in_addr addr; /* Address to be resolved */
66 void (*func)(const char */*host*/, void */*p*/); /* Handler function */
67 void *p; /* Argument for handler function */
68 } bres_client;
69
70 /* --- Server maintained resolver blocks --- */
71
72 typedef struct bres_server {
73 struct bres_server *next, *prev; /* Doubly-linked list of servers */
74 pid_t kid; /* Process id of server process */
75 selbuf b; /* Input line-buffer selector */
76 sel_timer t; /* Timeout for idle servers */
77 int fd; /* File descriptor for writing */
78 struct bres_client *rc; /* Pointer to attached client */
79 } bres_server;
80
81 /*----- Functions provided ------------------------------------------------*/
82
83 /* --- @bres_abort@ --- *
84 *
85 * Arguments: @bres_client *rc@ = pointer to client block
86 *
87 * Returns: ---
88 *
89 * Use: Removes a queued job.
90 */
91
92 extern void bres_abort(bres_client */*rc*/);
93
94 /* --- @bres_resolve@ --- *
95 *
96 * Arguments: @bres_client *rc@ = pointer to client block
97 * @struct in_addr addr@ = address to resolve
98 * @void (*func)(const char *host, void *p)@ = handler function
99 * @void *p@ = argument for handler function
100 *
101 * Returns: ---
102 *
103 * Use: Adds a resolver job to the queue. The job will be processed
104 * when there's a spare resolver process to deal with it.
105 */
106
107 extern void bres_resolve(bres_client */*rc*/, struct in_addr /*addr*/,
108 void (*/*func*/)(const char */*host*/, void */*p*/),
109 void */*p*/);
110
111 /* --- @bres_init@ --- *
112 *
113 * Arguments: @sel_state *s@ = pointer to select multiplexor
114 *
115 * Returns: ---
116 *
117 * Use: Initializes the background resolver for use.
118 */
119
120 extern void bres_init(sel_state */*s*/);
121
122 /*----- That's all, folks -------------------------------------------------*/
123
124 #ifdef __cplusplus
125 }
126 #endif
127
128 #endif