Roxen.git/
server/
base_server/
configuration.pike
Branch:
Tag:
Non-build tags
All tags
No tags
1997-09-05
1997-09-05 12:14:05 by Henrik Grubbström (Grubba) <grubba@grubba.org>
ef7af22ea79c544327de40c77152509364f3c7f1 (
56
lines) (+
36
/-
20
)
[
Show
|
Annotate
]
Branch:
5.2
Fixed domain-setting.
Rev: server/base_server/configuration.pike:1.75
1:
-
string cvs_version = "$Id: configuration.pike,v 1.
74
1997/09/05
02
:
19
:
17
grubba Exp $";
+
string cvs_version = "$Id: configuration.pike,v 1.
75
1997/09/05
12
:
14
:
05
grubba Exp $";
#include <module.h> #include <roxen.h> /* A configuration.. */
1905:
string t, s; // ConfigurationURL is set by the 'install' script.
-
if(!
(!
l
&&
sscanf
(roxen->QUERY(ConfigurationURL)
,
"
http
://
%s
:
%*s
",
s
)))
-
{
+
if
(!l
)
{
+
f =
(roxen->QUERY(ConfigurationURL)
/
"://
");
+
if (sizeof(f) > 1) {
+
t = (replace(f[1], ({ "
:",
"/" }
)
, ({ "\0", "\0" }
))
/"\0")[0];
+
f = t/".";
+
if (sizeof(f) > 1)
{
+
s = f[1..]*".";
+
}
+
}
+
}
#if efun(gethostbyname) && efun(gethostname)
-
+
if(!s) {
f = gethostbyname(gethostname()); // First try.. if(f)
-
foreach(f, f) foreach(f, t) if(
search
(t, ".")
!=
-1
&&
!
(
int
)
t
)
+
foreach(f, f)
{
+
if (arrayp(f)) {
+
foreach(f, t)
{
+
f = t/".";
+
if
((
sizeof(f) > 1) &&
+
(replace(
t,
({
"
0", "1", "2", "3", "4", "5",
+
"6", "7", "8", "9", "
."
}
)
,
+
({ "","","","","","","","","","","" }))
!=
""))
{
+
t
= f[1..]*".";
if(!s || strlen(s) < strlen(t)) s=t;
-
+
}
+
}
+
}
+
}
+
}
#endif
-
if(!s)
-
{
+
if(!s) {
t = Stdio.read_bytes("/etc/resolv.conf");
-
if(t)
-
{
+
if(t) {
if(!sscanf(t, "domain %s\n", s)) if(!sscanf(t, "search %s%*[ \t\n]", s)) s="nowhere"; } else { s="nowhere"; }
-
} else {
-
sscanf(s, "%*s.%s", s);
+
}
-
} else {
-
sscanf(s, "%*s.%s", s);
-
}
+
if(s && strlen(s)) { if(s[-1] == '.') s=s[..strlen(s)-2];