annotate src/online.c @ 337:fe00f7952a7c

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