masqmail

view src/libident/ident.h @ 266:ab39047ffe44

refactored mode_accept()
author markus schnalke <meillo@marmaro.de>
date Fri, 03 Dec 2010 11:30:24 -0300
parents 08114f7dcc23
children
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 int fd;
137 char buf[IDBUFSIZE];
138 } ident_t;
140 typedef struct {
141 int lport; /* Local port */
142 int fport; /* Far (remote) port */
143 char *identifier; /* Normally user name */
144 char *opsys; /* OS */
145 char *charset; /* Charset (what did you expect?) */
146 } IDENT; /* For higher-level routines */
148 /* Low-level calls and macros */
149 #define id_fileno(ID) ((ID)->fd)
151 extern ident_t *id_open __P((__STRUCT_IN_ADDR_P laddr, __STRUCT_IN_ADDR_P faddr, __STRUCT_TIMEVAL_P timeout));
153 extern int id_close __P((ident_t * id));
155 extern int id_query __P((ident_t * id, int lport, int fport, __STRUCT_TIMEVAL_P timeout));
157 extern int id_parse __P((ident_t * id, __STRUCT_TIMEVAL_P timeout, int *lport, int *fport, char **identifier, char **opsys, char **charset));
159 /* High-level calls */
161 extern IDENT *ident_lookup __P((int fd, int timeout));
163 extern char *ident_id __P((int fd, int timeout));
165 extern IDENT *ident_query __P((__STRUCT_IN_ADDR_P laddr, __STRUCT_IN_ADDR_P raddr, int lport, int rport, int timeout));
167 extern void ident_free __P((IDENT * id));
169 extern char id_version[];
171 #ifdef IN_LIBIDENT_SRC
173 extern char *id_strdup __P((char *str));
174 extern char *id_strtok __P((char *cp, char *cs, char *dc));
176 #endif
178 #ifdef __cplusplus
179 }
180 #endif
181 #endif