Branch: Tag:

1998-10-10

1998-10-10 20:18:13 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Added some localization support (try replacing the "standard" on
line 84 with "svenska").

Rev: server/base_server/roxen.pike:1.244

1:   /* -  * $Id: roxen.pike,v 1.243 1998/10/10 07:04:24 peter Exp $ +  * $Id: roxen.pike,v 1.244 1998/10/10 20:18:13 grubba Exp $    *    * The Roxen Challenger main program.    *
8:      // ABS and suicide systems contributed freely by Francesco Chemolli    - constant cvs_version = "$Id: roxen.pike,v 1.243 1998/10/10 07:04:24 peter Exp $"; + constant cvs_version = "$Id: roxen.pike,v 1.244 1998/10/10 20:18:13 grubba Exp $";         // Some headerfiles
80:   int startpid, roxenpid;   object roxen=this_object(), current_configuration;    + // Locale support + object locale = Locale.Roxen.standard; + #define LOCALE locale->base_server +  +    program Configuration; /*set in create*/      array configurations = ({});
288:    return;       case 24: -  report_fatal("Out of sockets. Restarting server gracefully.\n"); +  report_fatal(LOCALE->out_of_sockets());    low_shutdown(-1);    return;    }    }   #ifdef FD_DEBUG -  mark_fd( file->query_fd(), "Connection from "+file->query_address()); +  mark_fd( file->query_fd(), +  LOCALE->out_of_sockets(file->query_address()));   #endif    pn[-1](file,pn[1]);   #ifdef SOCKET_DEBUG
351:    }    } while(1);    }) { -  report_error("Uncaught error in handler thread: " + -  describe_backtrace(q) + -  "Client will not get any response from Roxen.\n"); +  report_error(LOCALE->uncaught_error(describe_backtrace(q)));    if (q = catch {h = 0;}) { -  report_error("Uncaught error in handler thread: " + -  describe_backtrace(q) + -  "Client will not get any response from Roxen.\n"); +  report_error(LOCALE-> +  uncaught_error(describe_backtrace(q)));    }    }    }
454:    {    port = Stdio.Port( "stdin", accept_callback );    port->set_id(port); -  if(port->errno()) -  { -  report_error("Cannot listen to stdin.\n" -  "Errno is "+port->errno()+"\n"); +  if(port->errno()) { +  report_error(LOCALE->stdin_is_quiet(port->errno()));    }    } else {    port = Stdio.Port();
475: Inside #if defined(SOCKET_DEBUG)
  #ifdef SOCKET_DEBUG    perror("SOCKETS: -> Failed.\n");   #endif -  report_warning("Failed to open socket on "+ether+":"+port_no+ -  " (already bound?)\nErrno is: "+ port->errno()+"\n" -  "Retrying...\n"); +  report_warning(LOCALE-> +  socket_already_bound_retry(ether, port_no, +  port->errno()));    sleep(1);   #if defined(THREADS) && 0    if(!port->bind(port_no, 0, ether))
485:    if(!port->bind(port_no, accept_callback, ether))   #endif    { -  report_error("Failed to open socket on "+ether+":"+port_no+ -  " (already bound?)\nErrno is: "+ port->errno()+"\n"); +  report_warning(LOCALE-> +  socket_already_bound(ether, port_no, port->errno()));    return 0;    }    }
530:    };    loading_config_interface = 0;    if(!configuration_interface_obj) { -  report_error(sprintf("Failed to load the configuration interface!\n%s\n", -  describe_backtrace(err))); +  report_error(LOCALE-> +  configuration_interface_failed(describe_backtrace(err)));    }    }    return configuration_interface_obj;
540:   // Unload the configuration interface   void unload_configuration_interface()   { -  report_notice("Unloading the configuration interface\n"); +  report_notice(LOCALE->unload_configuration_interface());       configuration_interface_obj = 0;    loading_config_interface = 0;
652:    if(foo=Stdio.read_bytes(file))    parse_supports_string(foo);    else -  report_error("Supports: Cannot include file "+file+"\n"); +  report_error(LOCALE->supports_bad_include(file));    } else if(sscanf(foo, "#define %[^ ] %s", name, to)) {    name -= "\t";    foo_defines[name] = to;
706:    aggregate_multiset(@negative_supports(gazonk)),    })});    }) { -  report_error(sprintf("Failed to parse supports regexp:\n%s\n", -  describe_backtrace(err))); +  report_error(LOCALE->supports_bad_regexp(describe_backtrace(err)));    }    }    }
739:    perror("Got new supports data from www.roxen.com\n");    perror("Replacing old file with new data.\n");   #ifndef THREADS -  object privs=Privs("Replacing etc/supports"); +  object privs=Privs(LOCALE->replacing_supports());   #endif    mv("etc/supports", "etc/supports~");    Stdio.write_file("etc/supports", new);
891:    perror("Restoring unique user ID information. (" + current_user_id_number    + ")\n");   #ifdef FD_DEBUG -  mark_fd(current_user_id_file->query_fd(), "Unique user ID logfile.\n"); +  mark_fd(current_user_id_file->query_fd(), LOCALE->unique_uid_logfile());   #endif   }   
919:    string res="";    array foo = ({0.0, 0.0, 0.0, 0.0, 0});    if(!sizeof(configurations)) -  return "<B>No virtual servers enabled</B>\n"; +  return LOCALE->no_servers_enabled();       foreach(configurations, object conf)    {
936:       for(tmp = 1; tmp < 4; tmp ++)    { +  // FIXME: LOCALE? +     if(foo[tmp] < 1024.0)    foo[tmp] = sprintf("%.2f MB", foo[tmp]);    else
948:    int min = uptime/60 - hrs*60;    hrs -= days*24;    -  res = sprintf("<table>" -  "<tr><td><b>Version:</b></td><td colspan=2>%s</td></tr>\n" -  "<tr><td><b>Booted on:</b></td><td colspan=2>%s</td></tr>\n" -  "<tr><td><b>Time to boot:</b></td>" -  "<td>%d sec</td></tr>\n" -  "<tr><td><b>Uptime:</b></td>" -  "<td colspan=2>%d day%s, %02d:%02d:%02d</td></tr>\n" -  "<tr><td colspan=3>&nbsp;</td></tr>\n" -  "<tr><td><b>Sent data:</b></td><td>%s" -  "</td><td>%.2f Kbit/sec</td></tr><tr>\n", -  real_version, ctime(boot_time), start_time-boot_time, -  days, (days==1?"":"s"), hrs, min, uptime%60, -  foo[1], foo[0] * 8192.0); -  -  res += "<td><b>Sent headers:</b></td><td>"+ foo[2] +"</td></tr>\n"; -  +     tmp=(int)((foo[4]*600.0)/(uptime+1));    -  res += (sprintf("<tr><td><b>Number of requests:</b></td>" -  "<td>%8d</td><td>%.2f/min</td></tr>\n" -  "<tr><td><b>Received data:</b></td>" -  "<td>%s</td></tr>\n", +  return(LOCALE->full_status(real_version, boot_time, start_time-boot_time, +  days, hrs, min, uptime%60, +  foo[1], foo[0] * 8192.0, foo[2],    foo[4], (float)tmp/(float)10, foo[3])); -  -  return res +"</table>"; +    }      
1021: Inside #if undefined(NO_COMPAT)
   mixed *u;       if(objectp(file)) s=file->stat(); -  if(!s || sizeof(s)<5) return "A. Nonymous"; +  if(!s || sizeof(s)<5) return LOCALE->anonymous_user();    uid=s[5];    u=user_from_uid(uid, id);    if(u) return u[0]; -  return "A. Nonymous"; +  return LOCALE->anonymous_user();   }      #endif /* !NO_COMPAT */
1371: Inside #if undefined(__NT__) and #if efun(setuid)
   setgid((int)g);   #endif    setuid((int)u); -  report_notice("Setting UID permanently to "+u+" and GID to "+g+"\n"); +  report_notice(LOCALE->setting_uid_gid_permanently((int)u, (int)g));    } else {   #endif   #if efun(setegid) && defined(SET_EFFECTIVE)
1384:   #else    setuid((int)u);   #endif -  report_notice("Setting UID to "+u+" and GID to "+g+"\n"); +  report_notice(LOCALE->setting_uid_gid((int)u, (int)g));    return 1;   #if efun(setuid)    }
1419:    // werror(sprintf("%O\n", roxen->config_stat_cache));    int modified;    -  report_notice("Reloading configuration files from disk\n"); +  report_notice(LOCALE->reloading_config_interface());    roxen->configs = ([]);    roxen->setvars(roxen->retrieve("Variables", 0));    roxen->initiate_configuration_port( 0 );
1461:    {    conf = roxen->enable_configuration(config);    }) { -  report_error("Error while enabling configuration "+config+":\n"+ -  describe_backtrace(err)+"\n"); +  report_error(LOCALE-> +  error_enabling_configuration(config, +  describe_backtrace(err)));    continue;    }    }
1471:    conf->start();    conf->enable_all_modules();    }) { -  report_error("Error while enabling configuration "+config+":\n"+ -  describe_backtrace(err)+"\n"); +  report_error(LOCALE-> +  error_enabling_configuration(config, +  describe_backtrace(err)));    continue;    }    new_confs += ({ conf });
1481:    foreach(roxen->configurations - new_confs, conf)    {    modified = 1; -  report_notice("Disabling old configuration "+conf->name+"\n"); +  report_notice(LOCALE->disabling_configuration(conf->name));    if (conf->server_ports) {    // Roxen 1.2.26 or later    Array.map(values(conf->server_ports), conf->do_dest);
1503:    object cf = Configuration(name);    configurations += ({ cf });    current_configuration = cf; -  report_notice("Enabled the virtual server \""+name+"\".\n"); +  report_notice(LOCALE->enabled_server(name));       return cf;   }
1603:   private void define_global_variables( int argc, array (string) argv )   {    int p; +  +  // FIXME: LOCALE! +     globvar("set_cookie", 0, "Set unique user id cookies", TYPE_FLAG,    "If set to Yes, all users of your server whose clients support "    "cookies will get a unique 'user-id-cookie', this can then be "
2059:    foreach(QUERY(ConfigPorts), port) {    if ((< "ssl", "ssleay" >)[port[1]]) {    // Obsolete versions of the SSL protocol. -  report_warning("Obsolete SSL protocol-module \""+port[1]+"\".\n" -  "Converted to SSL3.\n"); +  report_warning(LOCALE->obsolete_ssl(port[1]));    port[1] = "ssl3";    }    string key = MKPORTKEY(port);    if (!configuration_ports[key]) { -  report_notice(sprintf("New configuration port: %s\n", key)); +  report_notice(LOCALE->new_config_port(key));    new_ports[key] = port;    } else {    // This is needed not to delete old unchanged ports.
2076:    // Then disable the old ones that are no more.    foreach(indices(configuration_ports), string key) {    if (zero_type(new_ports[key])) { -  report_notice(sprintf("Disabling configuration port: %s...\n", key)); +  report_notice(LOCALE->disable_config_port(key));    object o = configuration_ports[key];    if (main_configuration_port == o) {    main_configuration_port = 0;
2086:    if (err = catch{    destruct(o);    }) { -  report_warning(sprintf("Error disabling configuration port: %s:\n" -  "%s\n", key, describe_backtrace(err))); +  report_warning(LOCALE-> +  error_disabling_config_port(key, +  describe_backtrace(err)));    }    o = 0; // Be sure that there are no references left...    }
2107:    function rp;    array tmp;    if(!requestprogram) { -  report_error("No request program for "+port[1]+"\n"); +  report_error(LOCALE->no_request_program(port[1]));    continue;    }    if(rp = requestprogram()->real_port)
2118:    // secret files.    object privs;    if(port[0] < 1024) -  privs = Privs("Opening listen port below 1024"); +  privs = Privs(LOCALE->opening_low_port());    if(o=create_listen_socket(port[0],0,port[2],requestprogram,port)) { -  report_notice(sprintf("Opening configuration port: %s\n", key)); +  report_notice(LOCALE->opening_config_port(key));    if (!main_configuration_port) {    main_configuration_port = o;    }    configuration_ports[key] = o;    } else { -  report_error(sprintf("The configuration port %s " -  "could not be opened\n", key)); +  report_error(LOCALE->could_not_open_config_port(key));    }    };    if (erro) { -  report_error(sprintf("Failed to open configuration port %s:\n" -  "%s\n", key, +  report_error(LOCALE->open_config_port_failed(key,    (stringp(erro)?erro:describe_backtrace(erro))));    }    }    }    if(!main_configuration_port)    { -  report_error("No configuration ports could be created.\n" -  "Is roxen already running?\n"); +  report_error(LOCALE->no_config_port());    if(first)    exit( -1 ); // Restart.    }
2252:    allmodules[ file-("."+extension(file)) ] = module_info;    } else {    // Disabled module. -  report_notice(sprintf("Module %O is disabled.\n", path+file)); +  report_notice(LOCALE->disabled_module(path+file));    }    } else {    // Load failed.
2270:    }    }    if(strlen(_master->errors)) { -  report_debug("Compilation errors found while scanning modules in "+ -  d+":\n"+ _master->errors+"\n"); +  report_debug(LOCALE->module_compilation_errors(d, _master->errors));    }    _master->set_inhibit_compile_errors(0);    }
2281:   {    string file, path;    mixed err; -  report_notice("Scanning module directories for modules"); +  report_notice(LOCALE->scanning_for_modules());    if (!allmodules) {    allmodules=copy_value(somemodules);    }
2291:    array err;    err = catch(scan_module_dir( path ));    if(err) { -  report_error("While scanning module dir (\""+path+"\"): " + -  describe_backtrace(err) + "\n"); +  report_error(LOCALE->module_scan_error(path, describe_backtrace(err)));    }    }    catch {
2301:    Stdio.write_file(".module_stat_cache", encode_value(module_stat_cache));    Stdio.write_file(".allmodules", encode_value(allmodules));    }; -  report_notice("Done with module directory scan. Found "+ -  sizeof(allmodules)+" modules.\n"); +  report_notice(LOCALE->module_scan_done(sizeof(allmodules)));   }      // =================================================
2454:   {    object o;    int i; -  perror("Interrupt request received. Exiting,\n"); +  roxen_perror("Interrupt request received. Exiting,\n");    die_die_die=1;   // trace(9);    if(++_recurse > 4)
2494:   #endif /* THREADS */    add_constant("roxen", 0); // Paranoia...    exit(-1); // Restart. -  perror("Odd. I am not dead yet.\n"); +  roxen_perror("Odd. I am not dead yet.\n");    }    }, 0.1);    call_out(lambda(){
2530:       add_constant("write", perror);    -  report_notice("Starting roxen\n"); +  report_notice(LOCALE->starting_roxen());      #ifdef FD_DEBUG    mark_fd(0, "Stdin");
2556:    argv -= ({ 0 });    argc = sizeof(argv);    -  perror("Restart initiated at "+ctime(time())); +  roxen_perror("Restart initiated at "+ctime(time()));       define_global_variables(argc, argv);   #ifdef ENABLE_NEIGHBOURHOOD
2592:    QUERY(next_supports_update)-time());       if(set_u_and_gid()) -  perror("Setting UID and GID ...\n"); +  roxen_perror("Setting UID and GID ...\n");      #ifdef THREADS    start_handler_threads();
2613:    catch { signal(signum(sig), shutdown); };    }    -  report_notice("Roxen started in "+(time()-start_time)+" seconds.\n"); +  report_notice(LOCALE->roxen_started(time()-start_time));   #ifdef __RUN_TRACE    trace(1);   #endif
2637:    case "cachedir":    if(!sscanf(value, "%*s/roxen_cache"))    { +  // FIXME: LOCALE?    object node;    node = (configuration_interface()->root->descend("Globals", 1)->    descend("Proxy disk cache: Base Cache Dir", 1));
2650:    case "MyWorldLocation":    if(strlen(value)<7 || value[-1] != '/' ||    !(sscanf(value,"%*s://%*s/")==2)) -  return "The URL should follow this format: protocol://computer[:port]/"; +  return(LOCALE->url_format());    break;       case "abs_engage":