Mercurial > hg > Applications > mh
comparison mts/mmdf/hosts.c @ 0:bce86c4163a3
Initial revision
author | kono |
---|---|
date | Mon, 18 Apr 2005 23:46:02 +0900 |
parents | |
children | 441a2190cfae |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bce86c4163a3 |
---|---|
1 /* hosts.c - use MMDF to get hostname information */ | |
2 #ifndef lint | |
3 static char ident[] = "@(#)$Id$"; | |
4 #endif /* lint */ | |
5 | |
6 /* LINTLIBRARY */ | |
7 | |
8 #include "../h/strings.h" | |
9 #include "util.h" | |
10 #include "mmdf.h" | |
11 #include "ch.h" | |
12 #ifdef MMDFII | |
13 #include "dm.h" | |
14 #endif /* MMDFII */ | |
15 #include "../zotnet/mts.h" | |
16 | |
17 /* | |
18 * We really should be careful with the number of fd's that this routine | |
19 * opens: the ch_seq ch_table.c module likes to keep 6 (yes, SIX) fds around | |
20 * to speed-up host lookups in the channel table. Unfortunately, after all | |
21 * of them get opened, six are always open (ch_table may close one to open | |
22 * another). The bottom line is that if repl calls post, then we get 12 | |
23 * (yes, TWELVE) fds open, with only six usable. | |
24 * | |
25 * send will close all fds >= 3 prior to invoking post. It would be nice | |
26 * if one could control ch_seq's use of fds for table lookups, but such is | |
27 * life. | |
28 * | |
29 */ | |
30 | |
31 #ifndef MMDFII | |
32 char *OfficialName (name) | |
33 register char *name; | |
34 { | |
35 register Chan *ch; | |
36 static char buffer[BUFSIZ]; | |
37 | |
38 return ((ch = ch_h2chan (name, buffer)) == (Chan *) (-1) ? NULL | |
39 : ch == (Chan *) NULL ? LocalName () | |
40 : buffer); | |
41 } | |
42 #else /* MMDFII */ | |
43 | |
44 extern char *invo_name; | |
45 | |
46 extern short ch_yloc; /* ok to intercept local names */ | |
47 | |
48 static int inited = 0; | |
49 | |
50 char *OfficialName (name) | |
51 register char *name; | |
52 { | |
53 Dmn_route route; | |
54 static char buffer[BUFSIZ]; | |
55 | |
56 if (!inited) { | |
57 mmdf_init (invo_name); | |
58 inited = 1; | |
59 } | |
60 switch (dm_v2route (name, buffer, &route)) { | |
61 case NOTOK: | |
62 case OK: | |
63 return ((ch_yloc && lexequ (name, LocalName ())) ? LocalName () | |
64 : NULL); | |
65 | |
66 default: | |
67 return buffer; | |
68 } | |
69 } | |
70 #endif /* MMDFII */ |