Mercurial > masqmail
comparison src/mservdetect.c @ 164:5b621742b2e7
removed the mserver feature
i.e. the functionality itself in the code
the `mserver' value of online_detect and `mserver_iface' config options
and the --enable-mserver configure option
All functionality, however, is still available through mservdetect
author | meillo@marmaro.de |
---|---|
date | Thu, 08 Jul 2010 22:01:33 +0200 |
parents | 26e34ae9a3e3 |
children | bd7c52a36b0c |
comparison
equal
deleted
inserted
replaced
163:3914d7cabfbc | 164:5b621742b2e7 |
---|---|
14 You should have received a copy of the GNU General Public License | 14 You should have received a copy of the GNU General Public License |
15 along with this program; if not, write to the Free Software | 15 along with this program; if not, write to the Free Software |
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 */ | 17 */ |
18 | 18 |
19 /* | 19 |
20 #include "config.h" | |
20 #include "masqmail.h" | 21 #include "masqmail.h" |
21 #include "readsock.h" | 22 #include "readsock.h" |
22 #include "mserver.h" | |
23 */ | |
24 | 23 |
25 #include "config.h" | |
26 | 24 |
27 /* ugly hack */ | 25 gchar* |
28 #ifndef ENABLE_MSERVER | 26 mserver_detect_online(interface * iface) |
29 #define ENABLE_MSERVER 1 | 27 { |
30 #include "mserver.c" | 28 struct sockaddr_in saddr; |
31 #else | 29 gchar *ret = NULL; |
32 #include "masqmail.h" | 30 |
33 #include "readsock.h" | 31 if (init_sockaddr(&saddr, iface)) { |
34 #include "mserver.h" | 32 int sock = socket(PF_INET, SOCK_STREAM, 0); |
35 #endif /* ENABLE_MSERVER */ | 33 int dup_sock; |
34 if (connect(sock, (struct sockaddr *) (&saddr), sizeof(saddr)) == 0) { | |
35 FILE *in, *out; | |
36 char buf[256]; | |
37 | |
38 dup_sock = dup(sock); | |
39 out = fdopen(sock, "w"); | |
40 in = fdopen(dup_sock, "r"); | |
41 | |
42 if (read_sockline(in, buf, 256, 15, READSOCKL_CHUG)) { | |
43 if (strncmp(buf, "READY", 5) == 0) { | |
44 fprintf(out, "STAT\n"); | |
45 fflush(out); | |
46 if (read_sockline(in, buf, 256, 15, READSOCKL_CHUG)) { | |
47 if (strncmp(buf, "DOWN", 4) == 0) { | |
48 ret = NULL; | |
49 } else if (strncmp(buf, "UP", 2) == 0) { | |
50 gchar *p = buf + 3; | |
51 while ((*p != ':') && *p) | |
52 p++; | |
53 if (*p) { | |
54 *p = 0; | |
55 p++; | |
56 if ((atoi(p) >= 0) && *p) | |
57 ret = g_strdup(buf + 3); | |
58 } else | |
59 logwrite(LOG_ALERT, "unexpected response from mserver after STAT cmd: %s", buf); | |
60 } else { | |
61 logwrite(LOG_ALERT, "unexpected response from mserver after STAT cmd: %s", buf); | |
62 } | |
63 } | |
64 } | |
65 fprintf(out, "QUIT"); | |
66 fflush(out); | |
67 | |
68 close(sock); | |
69 close(dup_sock); | |
70 fclose(in); | |
71 fclose(out); | |
72 } | |
73 } | |
74 } | |
75 return ret; | |
76 } | |
77 | |
36 | 78 |
37 void | 79 void |
38 logwrite(int pri, const char *fmt, ...) | 80 logwrite(int pri, const char *fmt, ...) |
39 { | 81 { |
40 va_list args; | 82 va_list args; |