1998-10-10
1998-10-10 23:10:08 by Henrik Grubbström (Grubba) <grubba@grubba.org>
-
b4616406ca7ce275dd5aed2087792dcd3459d4c8
(202 lines)
(+94/-108)
[
Show
| Annotate
]
Branch: 5.2
Added partial locale support.
Rev: server/base_server/configuration.pike:1.159
1:
- string cvs_version = "$Id: configuration.pike,v 1.158 1998/10/01 23:38:27 grubba Exp $";
+ string cvs_version = "$Id: configuration.pike,v 1.159 1998/10/10 23:10:08 grubba Exp $";
#include <module.h>
#include <roxen.h>
9:
#define CATCH(X) do { mixed err; if(err = catch{X;}) report_error(describe_backtrace(err)); } while(0)
+ // Locale support...
+ #define LOCALE roxen->locale->base_server
-
+
/* A configuration.. */
627:
{
do {
#ifndef THREADS
- object privs = Privs("Opening logfile \""+logfile+"\"");
+ object privs = Privs(LOCALE->opening_logfile(logfile));
#endif
object lf=open( logfile, "wac");
#if efun(chmod)
638:
if(!lf) {
mkdirhier(logfile);
if(!(lf=open( logfile, "wac"))) {
- report_error("Failed to open logfile. ("+logfile+")\n" +
- "No logging will take place!\n");
+ report_error(LOCALE->failed_to_open_logfile(logfile));
log_function=0;
break;
}
791:
{
float tmp;
string res="";
+ float dt = (float)(time(1) - roxen->start_time + 1);
if(!sent||!received||!hsent)
- return "Fatal error in status(): Bignum object gone.\n";
+ return(LOCALE->status_bignum_gone());
- tmp = (sent->mb()/(float)(time(1)-roxen->start_time+1));
- res = sprintf("<table><tr align=right><td><b>Sent data:</b></td><td>%.2fMB"
- "</td><td>%.2f Kbit/sec</td>",
- sent->mb(),tmp * 8192.0);
+ res = "<table>";
+ res += LOCALE->config_status(sent->mb(), (sent->mb()/dt) * 8192.0,
+ hsent->mb(), requests,
+ (((float)requests * 60.0)/dt), received->mb());
- res += sprintf("<td><b>Sent headers:</b></td><td>%.2fMB</td></tr>\n",
- hsent->mb());
-
- tmp=(((float)requests*(float)600)/
- (float)((time(1)-roxen->start_time)+1));
-
- res += sprintf("<tr align=right><td><b>Number of requests:</b></td>"
- "<td>%8d</td><td>%.2f/min</td>"
- "<td><b>Received data:</b></td><td>%.2fMB</td></tr>\n",
- requests, (float)tmp/(float)10, received->mb());
-
+
if (!zero_type(misc->ftp_users)) {
- tmp = (((float)misc->ftp_users*(float)600)/
- (float)((time(1)-roxen->start_time)+1));
-
- res += sprintf("<tr align=right><td><b>FTP users (total):</b></td>"
- "<td>%8d</td><td>%.2f/min</td>"
- "<td><b>FTP users (now):</b></td><td>%d</td></tr>\n",
- misc->ftp_users, (float)tmp/(float)10, misc->ftp_users_now);
+ res += LOCALE->ftp_status(misc->ftp_users,
+ (((float)misc->ftp_users*(float)60.0)/dt),
+ misc->ftp_users_now);
}
res += "</table><p>\n\n";
if ((roxen->configuration_interface()->more_mode) &&
(extra_statistics->ftp) && (extra_statistics->ftp->commands)) {
// FTP statistics.
- res += "<b>FTP statistics:</b><br>\n"
+ res += LOCALE->ftp_statistics() + "<br>\n"
"<ul><table>\n";
foreach(sort(indices(extra_statistics->ftp->commands)), string cmd) {
- res += sprintf("<tr align=right><td><b>%s</b></td>"
- "<td align=right>%d</td><td> time%s</td></tr>\n",
- upper_case(cmd), extra_statistics->ftp->commands[cmd],
- (extra_statistics->ftp->commands[cmd] == 1)?"":"s");
+ res += LOCALE->ftp_stat_line(upper_case(cmd),
+ extra_statistics->ftp->commands[cmd]);
}
res += "</table></ul>\n";
}
842:
public string *userinfo(string u, object|void id)
{
if(auth_module) return auth_module->userinfo(u);
- else report_warning(sprintf("userinfo(): No authorization module\n"
- "%s\n", describe_backtrace(backtrace())));
+ else report_warning(sprintf("userinfo(): %s\n"
+ "%s\n",
+ LOCALE->no_auth_module(),
+ describe_backtrace(backtrace())));
}
public string *userlist(object|void id)
{
if(auth_module) return auth_module->userlist();
- else report_warning(sprintf("userlist(): No authorization module\n"
- "%s\n", describe_backtrace(backtrace())));
+ else report_warning(sprintf("userlist(): %s\n"
+ "%s\n",
+ LOCALE->no_auth_module(),
+ describe_backtrace(backtrace())));
}
public string *user_from_uid(int u, object|void id)
{
if(auth_module)
return auth_module->user_from_uid(u);
- else report_warning(sprintf("user_from_uid(): No authorization module\n"
- "%s\n", describe_backtrace(backtrace())));
+ else report_warning(sprintf("user_from_uid(): %s\n"
+ "%s\n",
+ LOCALE->no_auth_module(),
+ describe_backtrace(backtrace())));
}
921: Inside #if defined(MODULE_LEVEL_SECURITY)
break;
case MOD_DENY: // deny ip=...
+
+ // FIXME: LOCALE?
if(level[1](id->remoteaddr))
return http_low_answer(403, "<h2>Access forbidden</h2>");
break;
974: Inside #if defined(MODULE_LEVEL_SECURITY)
};
if (err) {
- report_error(sprintf("Error during module security check:\n"
- "%s\n", describe_backtrace(err)));
+ report_error(LOCALE->module_security_error(describe_backtrace(err)));
return(1);
}
1023:
m->clear_memory_caches();
};
if (err) {
- report_error(sprintf("clear_memory_caches() failed for module %O:\n"
- "%s\n",
- otomod[m], describe_backtrace(err)));
+ report_error(LOCALE->
+ clear_memory_cache_error(otomod[m],
+ describe_backtrace(err)));
}
}
}
1156:
case 302: // redirect
if (m->extra_heads &&
(m->extra_heads->location))
- res
- = "Returned <i><b>redirect</b></i>;<br> to "
- "<a href="+(m->extra_heads->location)+">"
- "<font color=darkgreen><tt>"+
- (m->extra_heads->location)+
- "</tt></font></a><br>";
+ res = LOCALE->returned_redirect_to(m->extra_heads->location);
else
- res = "Returned redirect, but no location header\n";
+ res = LOCALE->returned_redirect_no_location();
break;
case 401:
if (m->extra_heads["www-authenticate"])
- res
- = "Returned <i><b>authentication failed</b></i>;"
- "<br> <tt>"+
- m->extra_heads["www-authenticate"]+"</tt><br>";
+ res = LOCALE->
+ returned_authenticate(m->extra_heads["www-authenticate"]);
else
- res
- = "Returned <i><b>authentication failed</b></i>.<br>";
+ res = LOCALE->returned_auth_failed();
break;
case 200:
- res
- = "Returned <i><b>ok</b></i><br>\n";
+ res = LOCALE->returned_ok();
break;
default:
- res
- = "Returned <b><tt>"+m->error+"</tt></b>.<br>\n";
+ res = LOCALE->returned_error(m->error);
}
if (!zero_type(m->len))
if (m->len<0)
- res+="No data ";
+ res += LOCALE->returned_no_data();
else
- res+=m->len+" bytes ";
+ res += LOCALE->returned_bytes(m->len);
else if (stringp(m->data))
- res+=strlen(m->data)+" bytes";
+ res += LOCALE->returned_bytes(strlen(m->data));
else if (objectp(m->file))
if (catch {
array a=m->file->stat();
- res+=(a[1]-m->file->tell())+" bytes ";
- }) res+="? bytes";
+ res += LOCALE->returned_bytes(a[1]-m->file->tell());
+ })
+ res += LOCALE->returned_unknown_bytes();
- if (m->data) res+=" (static)";
- else if (m->file) res+="(open file)";
+ if (m->data) res += LOCALE->returned_static_data();
+ else if (m->file) res += LOCALE->returned_open_file;
- if (stringp(m->extra_heads["http-content-type"]))
- res+=" of <tt>"+m->type+"</tt>\n";
- else if (stringp(m->type))
- res+=" of <tt>"+m->type+"</tt>\n";
+ if (stringp(m->extra_heads["http-content-type"]) ||
+ stringp(m->type)) {
+ res += LOCALE->returned_type(m->type);
+ }
res+="<br>";
1222: Inside #if defined(THREADS)
#ifdef THREADS
object key;
#endif
- TRACE_ENTER("Request for "+id->not_query, 0);
+ TRACE_ENTER(LOCALE->request_for(id->not_query), 0);
string file=id->not_query;
string loc;
1241: Inside #if undefined(NO_INTERNAL_HACK)
{
if(sscanf(loc, "gopher-%[^/]", loc)) // The directory icons.
{
- TRACE_LEAVE("Magic internal gopher image");
+ TRACE_LEAVE(LOCALE->magic_internal_gopher());
return internal_gopher_image(loc);
}
if(sscanf(loc, "spinner-%[^/]", loc) // Configuration interface images.
||sscanf(loc, "roxen-%[^/]", loc)) // Try /internal-roxen-power
{
- TRACE_LEAVE("Magic internal roxen image");
+ TRACE_LEAVE(LOCALE->magic_internal_roxen());
return internal_roxen_image(loc);
}
}
1256:
if(id->prestate->diract && dir_module)
{
LOCK(dir_module);
- TRACE_ENTER("Directory module", dir_module);
+ TRACE_ENTER(LOCALE->directory_module(), dir_module);
tmp = dir_module->parse_directory(id);
UNLOCK();
if(mappingp(tmp))
{
TRACE_LEAVE("");
- TRACE_LEAVE("Returning data");
+ TRACE_LEAVE(LOCALE->returning_data());
return tmp;
}
TRACE_LEAVE("");
1276: Inside #if defined(URL_MODULES)
foreach(url_modules(id), funp)
{
LOCK(funp);
- TRACE_ENTER("URL Module", funp);
+ TRACE_ENTER(LOCALE->url_module(), funp);
tmp=funp( id, file );
UNLOCK();
if(mappingp(tmp))
{
TRACE_LEAVE("");
- TRACE_LEAVE("Returning data");
+ TRACE_LEAVE(LOCALE->returning_data());
return tmp;
}
if(objectp( tmp ))
1296: Inside #if defined(URL_MODULES)
tmp = (id->conf || this_object())->low_get_file( tmp, no_magic );
else
{
- TRACE_LEAVE("Too deep recursion");
+ TRACE_LEAVE(LOCALE->too_deep_recursion());
error("Too deep recursion in roxen::get_file() while mapping "
+file+".\n");
}
1304: Inside #if defined(URL_MODULES)
nest = 0;
if(err) throw(err);
TRACE_LEAVE("");
- TRACE_LEAVE("Returned data");
+ TRACE_LEAVE(LOCALE->returning_data());
return tmp;
}
TRACE_LEAVE("");
1315: Inside #if defined(EXTENSION_MODULES)
{
foreach(tmp, funp)
{
- TRACE_ENTER("Extension Module ["+loc+"] ", funp);
+ TRACE_ENTER(LOCALE->extension_module(loc), funp);
LOCK(funp);
tmp=funp(loc, id);
UNLOCK();
1323: Inside #if defined(EXTENSION_MODULES)
{
if(!objectp(tmp))
{
- TRACE_LEAVE("Returing data");
+ TRACE_LEAVE(LOCALE->returning_data());
return tmp;
}
fid = tmp;
#ifdef MODULE_LEVEL_SECURITY
slevel = function_object(funp)->query("_seclvl");
#endif
- TRACE_LEAVE("Retured open filedescriptor."
+ TRACE_LEAVE(LOCALE->returned_fd()
#ifdef MODULE_LEVEL_SECURITY
+(slevel != id->misc->seclevel?
- ". The security level is now "+slevel:"")
+ LOCALE->seclevel_is_now(slevel):"")
#endif
);
#ifdef MODULE_LEVEL_SECURITY
1351:
loc = tmp[0];
if(!search(file, loc))
{
- TRACE_ENTER("Location Module ["+loc+"] ", tmp[1]);
+ TRACE_ENTER(LOCALE->location_module(loc), tmp[1]);
#ifdef MODULE_LEVEL_SECURITY
if(tmp2 = check_security(tmp[1], id, slevel))
if(intp(tmp2))
{
- TRACE_LEAVE("Permission to access module denied");
+ TRACE_LEAVE(LOCALE->module_access_denied());
continue;
} else {
- TRACE_LEAVE("Request denied.");
+ TRACE_LEAVE(LOCALE->request_denied());
return tmp2;
}
#endif
- TRACE_ENTER("Calling find_file()...", 0);
+ TRACE_ENTER(LOCALE->calling_find_file(), 0);
LOCK(tmp[1]);
fid=tmp[1]( file[ strlen(loc) .. ] + id->extra_extension, id);
UNLOCK();
- TRACE_LEAVE(sprintf("find_file has returned %O", fid));
+ TRACE_LEAVE(LOCALE->find_file_returned(fid));
if(fid)
{
id->virtfile = loc;
1388:
id->misc->seclevel = slevel;
#endif
if(objectp(fid))
- TRACE_LEAVE("Returned open file"
+ TRACE_LEAVE(LOCALE->returned_fd()
#ifdef MODULE_LEVEL_SECURITY
+(slevel != oslevel?
- ". The security level is now "+slevel:"")
+ LOCALE->seclevel_is_now(slevel):"")
#endif
+".");
else
- TRACE_LEAVE("Returned directory indicator"
+ TRACE_LEAVE(LOCALE->returned_directory_indicator()
#ifdef MODULE_LEVEL_SECURITY
+(oslevel != slevel?
- ". The security level is now "+slevel:"")
+ LOCALE->seclevel_is_now(slevel):"")
#endif
);
break;
1411:
// the mountpoint is /local/. It will slow things down, but...
if(file+"/" == loc)
{
- TRACE_ENTER("Automatic redirect to location module", tmp[1]);
- TRACE_LEAVE("Returning data");
+ TRACE_ENTER(LOCALE->automatic_redirect_to_location(), tmp[1]);
+ TRACE_LEAVE(LOCALE->returning_data());
return http_redirect(id->not_query + "/", id);
}
}
1422:
{
if(no_magic)
{
- TRACE_LEAVE("No magic requested. Returning -1");
+ TRACE_LEAVE(LOCALE->no_magic());
return -1;
}
if(dir_module)
{
LOCK(dir_module);
- TRACE_ENTER("Directory module", dir_module);
+ TRACE_ENTER(LOCALE->directory_module(), dir_module);
fid = dir_module->parse_directory(id);
UNLOCK();
}
else
{
- TRACE_LEAVE("No directory module. Returning 'no such file'");
+ TRACE_LEAVE(LOCALE->no_directory_module());
return 0;
}
if(mappingp(fid))
{
- TRACE_LEAVE("Returned data");
+ TRACE_LEAVE(LOCALE->returning_data());
return (mapping)fid;
}
}
1449:
(tmp=file_extension_modules(loc=extension(id->not_query), id)))
foreach(tmp, funp)
{
- TRACE_ENTER("Extension module", funp);
+ TRACE_ENTER(LOCALE->extension_module(loc), funp);
#ifdef MODULE_LEVEL_SECURITY
if(tmp=check_security(funp, id, slevel))
if(intp(tmp))
{
- TRACE_LEAVE("Permission to access module denied");
+ TRACE_LEAVE(LOCALE->module_access_denied());
continue;
}
else
{
TRACE_LEAVE("");
- TRACE_LEAVE("Permission denied");
+ TRACE_LEAVE(LOCALE->permission_denied());
return tmp;
}
#endif
1472:
if(!objectp(tmp))
{
TRACE_LEAVE("");
- TRACE_LEAVE("Returning data");
+ TRACE_LEAVE(LOCALE->returning_data());
return tmp;
}
if(fid)
destruct(fid);
- TRACE_LEAVE("Returned new open file");
+ TRACE_LEAVE(LOCALE->returned_new_open_file());
fid = tmp;
break;
} else
1490:
id->not_query += id->extension;
- TRACE_ENTER("Content-type mapping module", types_module);
+ TRACE_ENTER(LOCALE->content_type_module(), types_module);
tmp=type_from_filename(id->not_query, 1);
- TRACE_LEAVE(tmp?"Returned type "+tmp[0]+" "+tmp[1]:"Missing");
+ TRACE_LEAVE(tmp?LOCALE->returned_mime_type(tmp[0],tmp[1]):
+ LOCALE->missing_type());
if(tmp)
{
TRACE_LEAVE("");
1502:
return ([ "file":fid, ]);
}
if(!fid)
- TRACE_LEAVE("Returning 'no such file'");
+ TRACE_LEAVE(LOCALE->returned_not_found());
else
- TRACE_LEAVE("Returning data");
+ TRACE_LEAVE(LOCALE->returning_data());
return fid;
}