Mercurial > masqmail
annotate src/libident/id_query.c @ 203:45acc5727493
removed --with-glib-static configure option
linking glib statically is interesting if no other program uses it
on today's systems glib is widely used
if one cares on linking statically, he can link everything statically
the special case for glib will not get special care anymore
author | meillo@marmaro.de |
---|---|
date | Fri, 16 Jul 2010 14:48:17 +0200 |
parents | 26e34ae9a3e3 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 ** id_query.c Transmit a query to an IDENT server | |
3 ** | |
4 ** Author: Peter Eriksson <pen@lysator.liu.se> | |
5 */ | |
6 | |
7 #ifdef NeXT3 | |
8 # include <libc.h> | |
9 #endif | |
10 | |
11 #include <stdio.h> | |
12 #include <errno.h> | |
13 #include <signal.h> | |
14 | |
15 #ifdef HAVE_ANSIHEADERS | |
16 # include <stdlib.h> | |
17 # include <string.h> | |
18 # include <unistd.h> | |
19 #endif | |
20 | |
21 #include <sys/types.h> | |
22 #include <sys/wait.h> | |
23 #include <sys/time.h> | |
24 | |
25 #ifdef _AIX | |
26 # include <sys/select.h> | |
27 #endif | |
28 | |
29 #ifdef _AIX | |
30 # include <sys/select.h> | |
31 #endif | |
32 #ifdef VMS | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
33 # include <sys/socket.h> /* for fd_set */ |
0 | 34 #endif |
35 #define IN_LIBIDENT_SRC | |
36 #include "ident.h" | |
37 | |
38 | |
39 /* | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
40 int |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
41 id_query __P4(ident_t *, id, int, lport, int, fport, struct timeval *, timeout) |
0 | 42 */ |
43 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
44 int |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
45 id_query __P((ident_t * id, int lport, int fport, __STRUCT_TIMEVAL_P timeout)) |
0 | 46 { |
47 #ifdef SIGRETURNTYPE | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
48 SIGRETURNTYPE(*old_sig) (); |
0 | 49 #else |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
50 void (*old_sig) __P((int)); |
0 | 51 #endif |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
52 int res; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
53 char buf[80]; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
54 fd_set ws; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
55 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
56 sprintf(buf, "%d , %d\r\n", lport, fport); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
57 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
58 if (timeout) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
59 FD_ZERO(&ws); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
60 FD_SET(id->fd, &ws); |
0 | 61 |
62 #ifdef __hpux | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
63 if ((res = select(FD_SETSIZE, (int *) 0, (int *) &ws, (int *) 0, timeout)) < 0) |
0 | 64 #else |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
65 if ((res = select(FD_SETSIZE, (fd_set *) 0, &ws, (fd_set *) 0, timeout)) < 0) |
0 | 66 #endif |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
67 return -1; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
68 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
69 if (res == 0) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
70 errno = ETIMEDOUT; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
71 return -1; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
72 } |
0 | 73 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
74 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
75 old_sig = signal(SIGPIPE, SIG_IGN); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
76 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
77 res = write(id->fd, buf, strlen(buf)); |
0 | 78 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
79 signal(SIGPIPE, old_sig); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
80 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
81 return res; |
0 | 82 } |