Line 0
Link Here
|
|
|
1 |
--- src/apcaccess.c.orig 2007-08-03 18:17:38.000000000 +0300 |
2 |
+++ src/apcaccess.c 2008-02-27 09:30:39.352400647 +0200 |
3 |
@@ -62,11 +62,19 @@ |
4 |
int main(int argc, char **argv) |
5 |
{ |
6 |
int mode = 0; |
7 |
+ UPSINFO *ups = NULL; |
8 |
+ |
9 |
+ char *cfgfile = APCCONF; |
10 |
+ struct stat cfgstat; |
11 |
|
12 |
#ifdef HAVE_MINGW |
13 |
WSA_Init(); /* init MS networking */ |
14 |
#endif |
15 |
|
16 |
+ ups = attach_ups(ups); |
17 |
+ if (!ups) |
18 |
+ Error_abort0(_("Cannot attach SYSV IPC.\n")); |
19 |
+ |
20 |
if (argc < 2) { |
21 |
/* Assume user wants "status" */ |
22 |
mode = 2; |
23 |
@@ -87,6 +95,20 @@ |
24 |
*p++ = 0; |
25 |
port = atoi(p); |
26 |
} |
27 |
+ } else { |
28 |
+ /* check configuration so local NISIP and NISPORT variables can be used as |
29 |
+ defaults */ |
30 |
+ if (!stat(cfgfile, &cfgstat)) { |
31 |
+ check_for_config(ups, cfgfile); |
32 |
+ |
33 |
+ if (ups) { |
34 |
+ if (ups->nisip && ups->nisip[0]) |
35 |
+ host = ups->nisip; |
36 |
+ |
37 |
+ if (ups->statusport) |
38 |
+ port = ups->statusport; |
39 |
+ } |
40 |
+ } |
41 |
} |
42 |
|
43 |
if (!*host || strcmp(host, "0.0.0.0") == 0) |
44 |
@@ -101,5 +123,7 @@ |
45 |
Error_abort0(_("Strange mode\n")); |
46 |
} |
47 |
|
48 |
+ detach_ups(ups); |
49 |
+ |
50 |
return 0; |
51 |
} |