masqmail-0.2
view src/libident/ident.h @ 3:8c55886cacd8
man pages will be maintained in troff now
author | meillo@marmaro.de |
---|---|
date | Fri, 26 Sep 2008 21:40:10 +0200 |
parents | |
children | 26e34ae9a3e3 |
line source
1 /*
2 ** ident.h
3 **
4 ** Author: Peter Eriksson <pen@lysator.liu.se>
5 ** Intruder: Pär Emanuelsson <pell@lysator.liu.se>
6 */
8 #ifndef __IDENT_H__
9 #define __IDENT_H__
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
15 /* Sigh */
16 #ifdef __STDC__
17 # if __STDC__ == 1
18 # define IS_STDC 1
19 # endif
20 #endif
22 #ifdef __P
23 # undef __P
24 #endif
26 #ifdef IS_STDC
27 # define __P(AL) AL
29 #ifdef IN_LIBIDENT_SRC
31 # define __P1(t1,a1) \
32 (t1 a1)
34 # define __P2(t1,a1,t2,a2) \
35 (t1 a1, t2 a2)
37 # define __P3(t1,a1,t2,a2,t3,a3) \
38 (t1 a1, t2 a2, t3 a3)
40 # define __P4(t1,a1,t2,a2,t3,a3,t4,a4) \
41 (t1 a1, t2 a2, t3 a3, t4 a4)
43 # define __P5(t1,a1,t2,a2,t3,a3,t4,a4,t5,a5) \
44 (t1 a1, t2 a2, t3 a3, t4 a4, t5 a5)
46 # define __P7(t1,a1,t2,a2,t3,a3,t4,a4,t5,a5,t6,a6,t7,a7) \
47 (t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7)
48 #endif
50 #else
52 # define __P(AL) ()
54 #ifdef IN_LIBIDENT_SRC
56 # define __P1(t1,a1) (a1) \
57 t1 a1;
58 # define __P2(t1,a1,t2,a2) (a1, a2) \
59 t1 a1; \
60 t2 a2;
61 # define __P3(t1,a1,t2,a2,t3,a3) (a1, a2, a3) \
62 t1 a1; \
63 t2 a2; \
64 t3 a3;
65 # define __P4(t1,a1,t2,a2,t3,a3,t4,a4) (a1, a2, a3, a4) \
66 t1 a1; \
67 t2 a2; \
68 t3 a3; \
69 t4 a4;
70 # define __P5(t1,a1,t2,a2,t3,a3,t4,a4,t5,a5) (a1, a2, a3, a4, a5) \
71 t1 a1; \
72 t2 a2; \
73 t3 a3; \
74 t4 a4; \
75 t5 a5;
76 # define __P7(t1,a1,t2,a2,t3,a3,t4,a4,t5,a5,t6,a6,t7,a7) \
77 (a1, a2, a3, a4, a5, a6, a7) \
78 t1 a1; \
79 t2 a2; \
80 t3 a3; \
81 t4 a4; \
82 t5 a5; \
83 t6 a6; \
84 t7 a7;
85 #endif
86 #endif
88 #ifdef IS_STDC
89 # undef IS_STDC
90 #endif
92 #ifdef _AIX
93 # include <sys/select.h>
94 #endif
95 #ifdef __sgi
96 # include <bstring.h>
97 #endif
98 #include <sys/types.h>
99 #include <netinet/in.h>
100 #include <sys/time.h>
102 #if defined(VMS) && !defined(FD_SETSIZE)
103 # define FD_SETSIZE 64
104 #endif
106 /*
107 * Sigh, GCC v2 complains when using undefined struct tags
108 * in function prototypes...
109 */
110 #if defined(__GNUC__) && !defined(INADDR_ANY)
111 # define __STRUCT_IN_ADDR_P void *
112 #else
113 # define __STRUCT_IN_ADDR_P struct in_addr *
114 #endif
116 #if defined(__GNUC__) && !defined(DST_NONE)
117 # define __STRUCT_TIMEVAL_P void *
118 #else
119 # define __STRUCT_TIMEVAL_P struct timeval *
120 #endif
122 #if defined(__sgi) && defined(_POSIX_SOURCE)
123 # undef __STRUCT_TIMEVAL_P
124 # define __STRUCT_TIMEVAL_P void *
125 #endif
127 #ifndef IDBUFSIZE
128 # define IDBUFSIZE 2048
129 #endif
131 #ifndef IDPORT
132 # define IDPORT 113
133 #endif
135 typedef struct
136 {
137 int fd;
138 char buf[IDBUFSIZE];
139 } ident_t;
141 typedef struct {
142 int lport; /* Local port */
143 int fport; /* Far (remote) port */
144 char *identifier; /* Normally user name */
145 char *opsys; /* OS */
146 char *charset; /* Charset (what did you expect?) */
147 } IDENT; /* For higher-level routines */
149 /* Low-level calls and macros */
150 #define id_fileno(ID) ((ID)->fd)
152 extern ident_t * id_open __P((__STRUCT_IN_ADDR_P laddr,
153 __STRUCT_IN_ADDR_P faddr,
154 __STRUCT_TIMEVAL_P timeout));
156 extern int id_close __P((ident_t *id));
158 extern int id_query __P((ident_t *id,
159 int lport,
160 int fport,
161 __STRUCT_TIMEVAL_P timeout));
163 extern int id_parse __P((ident_t *id,
164 __STRUCT_TIMEVAL_P timeout,
165 int *lport,
166 int *fport,
167 char **identifier,
168 char **opsys,
169 char **charset));
171 /* High-level calls */
173 extern IDENT *ident_lookup __P((int fd, int timeout));
175 extern char *ident_id __P((int fd, int timeout));
177 extern IDENT *ident_query __P(( __STRUCT_IN_ADDR_P laddr, __STRUCT_IN_ADDR_P raddr, int lport, int rport, int timeout));
179 extern void ident_free __P((IDENT *id));
181 extern char id_version[];
183 #ifdef IN_LIBIDENT_SRC
185 extern char *id_strdup __P((char *str));
186 extern char *id_strtok __P((char *cp, char *cs, char *dc));
188 #endif
190 #ifdef __cplusplus
191 }
192 #endif
194 #endif