annotate src/online.c @ 434:f2a7271746d1 default tip

Removes Freshmeat.net from the docs The site, which was later renamed to freecode.com, is no longer maintained (contains only a static copy).
author markus schnalke <meillo@marmaro.de>
date Sat, 07 Feb 2015 11:45:07 +0100
parents b27f66555ba8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
1 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
2 ** MasqMail
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
3 ** Copyright (C) 1999-2001 Oliver Kurth
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
4 ** Copyright (C) 2008, 2010 markus schnalke <meillo@marmaro.de>
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
5 **
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
6 ** This program is free software; you can redistribute it and/or modify
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
7 ** it under the terms of the GNU General Public License as published by
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
8 ** the Free Software Foundation; either version 2 of the License, or
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
9 ** (at your option) any later version.
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
10 **
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
11 ** This program is distributed in the hope that it will be useful,
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
14 ** GNU General Public License for more details.
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
15 **
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
16 ** You should have received a copy of the GNU General Public License
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
17 ** along with this program; if not, write to the Free Software
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
18 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
19 */
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
20
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
21 #include <sys/wait.h>
15
f671821d8222 code beautifying; 0 -> \0 if appropriate
meillo@marmaro.de
parents: 10
diff changeset
22
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
23 #include "masqmail.h"
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
24 #include "peopen.h"
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
25
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
26
310
f10a56dc7481 reworked online_detect to the simpler online_query
meillo@marmaro.de
parents: 279
diff changeset
27 gchar*
f10a56dc7481 reworked online_detect to the simpler online_query
meillo@marmaro.de
parents: 279
diff changeset
28 online_query()
279
1aa107c6b1e5 moved some code around
markus schnalke <meillo@marmaro.de>
parents: 262
diff changeset
29 {
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 310
diff changeset
30 gchar *pipe = conf.online_query;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
31 pid_t pid;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
32 void (*old_signal) (int);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
33 int status;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
34 FILE *in;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
35 gchar *name = NULL;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
36
310
f10a56dc7481 reworked online_detect to the simpler online_query
meillo@marmaro.de
parents: 279
diff changeset
37 if (!conf.online_query) {
f10a56dc7481 reworked online_detect to the simpler online_query
meillo@marmaro.de
parents: 279
diff changeset
38 return NULL;
f10a56dc7481 reworked online_detect to the simpler online_query
meillo@marmaro.de
parents: 279
diff changeset
39 }
f10a56dc7481 reworked online_detect to the simpler online_query
meillo@marmaro.de
parents: 279
diff changeset
40 DEBUG(3) debugf("online query `%s'\n", pipe);
f10a56dc7481 reworked online_detect to the simpler online_query
meillo@marmaro.de
parents: 279
diff changeset
41
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
42 old_signal = signal(SIGCHLD, SIG_DFL);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
43
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
44 in = peopen(pipe, "r", environ, &pid);
310
f10a56dc7481 reworked online_detect to the simpler online_query
meillo@marmaro.de
parents: 279
diff changeset
45 if (!in) {
33
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
46 logwrite(LOG_ALERT, "could not open pipe '%s': %s\n", pipe, strerror(errno));
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
47 signal(SIGCHLD, old_signal);
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
48 return NULL;
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
49 }
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
50
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
51 gchar output[256];
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
52 if (fgets(output, 255, in)) {
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
53 g_strchomp(g_strchug(output));
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
54 if (strlen(output) == 0) {
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
55 logwrite(LOG_ALERT, "only whitespace connection name\n");
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
56 name = NULL;
18
99c09ed776c1 fixed empty or only-whitespace connection names
meillo@marmaro.de
parents: 15
diff changeset
57 } else {
33
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
58 name = g_strdup(output);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
59 }
33
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
60 } else {
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
61 logwrite(LOG_ALERT, "nothing read from pipe %s\n", pipe);
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
62 name = NULL;
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
63 }
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
64 fclose(in);
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
65 waitpid(pid, &status, 0);
262
fc1c6425c024 s/EXIT_SUCCESS/0/ && s/EXIT_FAILURE/1/
markus schnalke <meillo@marmaro.de>
parents: 208
diff changeset
66 if (WEXITSTATUS(status) != 0) {
33
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
67 g_free(name);
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
68 name = NULL;
e1004fcc93c9 flattened conditional nesting
meillo@marmaro.de
parents: 19
diff changeset
69 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
70
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
71 signal(SIGCHLD, old_signal);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
72
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
73 return name;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
74 }