835c6c | 2001-06-17 | Martin Nilsson | |
|
f41b98 | 2009-05-07 | Martin Stjernholm | |
|
835c6c | 2001-06-17 | Martin Nilsson | |
|
920f06 | 2013-02-05 | Build system | |
|
fb2336 | 2001-12-04 | Martin Stjernholm | |
|
79ca87 | 2000-11-24 | Per Hedbor | | #define LocaleString Locale.DeferredLocale|string
|
2a9898 | 1997-04-19 | Henrik Grubbström (Grubba) | |
|
c2d7aa | 2004-04-13 | Martin Stjernholm | | mixed x = Calendar.Timezone;
|
6d6bc8 | 2001-06-24 | Martin Nilsson | |
|
20bcc7 | 2000-03-13 | Martin Nilsson | |
|
09ff05 | 1998-10-03 | Henrik Grubbström (Grubba) | |
|
2a9898 | 1997-04-19 | Henrik Grubbström (Grubba) | |
|
40dd28 | 1999-11-23 | Per Hedbor | | #include <stat.h>
|
5d98ea | 2012-01-07 | Martin Stjernholm | | #include <roxen.h>
|
e41c9d | 2017-04-21 | Henrik Grubbström (Grubba) | |
#define LOC_S(X,Y) _STR_LOCALE("roxen_start",X,Y)
#define LOC_M(X,Y) _STR_LOCALE("roxen_message",X,Y)
#define CALL_M(X,Y) _LOCALE_FUN("roxen_message",X,Y)
|
56881b | 1997-08-27 | Henrik Grubbström (Grubba) | |
|
0ceeee | 1997-08-31 | Henrik Grubbström (Grubba) | |
|
56881b | 1997-08-27 | Henrik Grubbström (Grubba) | |
|
fc4039 | 2008-08-15 | Martin Stjernholm | | private __builtin.__master new_master;
|
56881b | 1997-08-27 | Henrik Grubbström (Grubba) | |
|
f2a5d9 | 2015-06-12 | Henrik Grubbström (Grubba) | | #if constant(spider)
|
8f81d8 | 2001-01-03 | Per Hedbor | | constant s = spider;
|
f2a5d9 | 2015-06-12 | Henrik Grubbström (Grubba) | | #endif
|
8f81d8 | 2001-01-03 | Per Hedbor | |
|
1efb70 | 2006-08-16 | Henrik Grubbström (Grubba) | |
|
a87a0d | 2006-11-17 | Martin Stjernholm | |
|
1efb70 | 2006-08-16 | Henrik Grubbström (Grubba) | |
|
8f81d8 | 2001-01-03 | Per Hedbor | | int remove_dumped;
|
74e390 | 2000-12-30 | Per Hedbor | | string configuration_dir;
|
097e18 | 2009-12-09 | Martin Stjernholm | | int once_mode;
|
8f56cb | 2000-09-30 | Per Hedbor | |
|
58a643 | 1999-12-20 | Martin Nilsson | | #define werror roxen_perror
|
56881b | 1997-08-27 | Henrik Grubbström (Grubba) | |
|
033aab | 2022-08-18 | Henrik Grubbström (Grubba) | | #ifdef DEBUG
#define REPORT_DEBUG(X ...) report_debug(X)
#else
#define REPORT_DEBUG(X ...)
#endif
|
920f06 | 2013-02-05 | Build system | | constant cvs_version="$Id$";
|
2a9898 | 1997-04-19 | Henrik Grubbström (Grubba) | |
int pid = getpid();
|
8ad929 | 2000-03-13 | Martin Nilsson | | Stdio.File stderr = Stdio.File("stderr");
|
2a9898 | 1997-04-19 | Henrik Grubbström (Grubba) | |
|
8f81d8 | 2001-01-03 | Per Hedbor | | #if !constant(uname)
|
51ba6d | 2000-04-12 | Per Hedbor | | #ifdef __NT__
mapping uname()
{
return ([
"machine":"NT",
"release":"unknown",
"sysname":"NT",
"nodename":gethostname(),
"version":"unknown",
]);
}
|
8f81d8 | 2001-01-03 | Per Hedbor | | #else
mapping uname()
{
return ([
"machine":"unknown",
"release":"unknown",
"sysname":"unknown",
"nodename":gethostname(),
"version":"unknown",
]);
}
#endif
|
51ba6d | 2000-04-12 | Per Hedbor | | #endif
|
20bcc7 | 2000-03-13 | Martin Nilsson | | mapping(int:string) pwn=([]);
|
953ca3 | 1997-08-18 | Per Hedbor | | string pw_name(int uid)
|
3611e3 | 1997-04-26 | Per Hedbor | | {
|
c79b26 | 1998-02-05 | Johan Schön | | #if !constant(getpwuid)
return "uid #"+uid;
#else
|
3611e3 | 1997-04-26 | Per Hedbor | | if(pwn[uid]) return pwn[uid];
|
20bcc7 | 2000-03-13 | Martin Nilsson | | return pwn[uid]=([array(string)]getpwuid(uid)||((""+uid)/":"))[0];
|
c79b26 | 1998-02-05 | Johan Schön | | #endif
}
|
ebd050 | 2018-05-14 | Henrik Grubbström (Grubba) | | #if !constant(utf8_string)
protected typedef __attribute__("utf8", string(8bit)) utf8_string;
#endif
|
c79b26 | 1998-02-05 | Johan Schön | | #if !constant(getppid)
|
8f81d8 | 2001-01-03 | Per Hedbor | | int getppid() { return -1; }
|
c79b26 | 1998-02-05 | Johan Schön | | #endif
|
2a9898 | 1997-04-19 | Henrik Grubbström (Grubba) | |
|
d4a3f5 | 2014-05-12 | Henrik Grubbström (Grubba) | | #if constant(syslog)
|
342f4d | 1998-09-12 | Per Hedbor | | #define LOG_CONS (1<<0)
#define LOG_NDELAY (1<<1)
#define LOG_PERROR (1<<2)
#define LOG_PID (1<<3)
#define LOG_AUTH (1<<0)
#define LOG_AUTHPRIV (1<<1)
#define LOG_CRON (1<<2)
#define LOG_DAEMON (1<<3)
#define LOG_KERN (1<<4)
#define LOG_LOCAL (1<<5)
#define LOG_LOCAL1 (1<<6)
#define LOG_LOCAL2 (1<<7)
#define LOG_LOCAL3 (1<<8)
#define LOG_LOCAL4 (1<<9)
#define LOG_LOCAL5 (1<<10)
#define LOG_LOCAL6 (1<<11)
#define LOG_LOCAL7 (1<<12)
#define LOG_LPR (1<<13)
#define LOG_MAIL (1<<14)
#define LOG_NEWS (1<<15)
#define LOG_SYSLOG (1<<16)
#define LOG_USER (1<<17)
#define LOG_UUCP (1<<18)
#define LOG_EMERG (1<<0)
#define LOG_ALERT (1<<1)
#define LOG_CRIT (1<<2)
#define LOG_ERR (1<<3)
#define LOG_WARNING (1<<4)
#define LOG_NOTICE (1<<5)
#define LOG_INFO (1<<6)
#define LOG_DEBUG (1<<7)
int use_syslog, loggingfield;
#endif
|
57a7e6 | 2018-09-12 | Henrik Grubbström (Grubba) | | #if constant(DefaultCompilerEnvironment)
#if (__REAL_MAJOR__ == 8) && (__REAL_MINOR__ == 0) && (__REAL_BUILD__ < 694)
object _disable_threads()
{
object compiler_lock = DefaultCompilerEnvironment->lock();
return predef::_disable_threads();
}
#endif
#endif
|
cefd17 | 2011-12-27 | Martin Stjernholm | |
|
de7659 | 2011-12-27 | Martin Stjernholm | |
|
cefd17 | 2011-12-27 | Martin Stjernholm | | string server_dir =
lambda () {
string cwd = getcwd();
#ifdef __NT__
|
bd2379 | 2012-02-08 | Jonas Wallden | | cwd = replace (cwd, "\\", "/");
|
cefd17 | 2011-12-27 | Martin Stjernholm | | #endif
if (has_suffix (cwd, "/"))
report_warning ("Warning: Server directory is a root dir "
"(or getcwd() misbehaves): %O\n", cwd);
string check_dir (string d) {
while (has_suffix (d, "/"))
d = d[..<2];
#if constant (resolvepath)
if (resolvepath (d) == cwd)
return d;
#else
if (cd (d)) {
if (getcwd() == cwd)
return d;
else
cd (cwd);
}
#endif
return 0;
};
if (string env_pwd = getenv ("PWD"))
if (string res = check_dir (env_pwd))
return res;
if (string res = check_dir (combine_path (__FILE__, "../..")))
return res;
return cwd;
}();
|
6d6bc8 | 2001-06-24 | Martin Nilsson | |
|
09ff05 | 1998-10-03 | Henrik Grubbström (Grubba) | |
|
fb2336 | 2001-12-04 | Martin Stjernholm | | string get_cvs_id(string from)
{
|
f848a2 | 2021-04-20 | Henrik Grubbström (Grubba) | | if (master()->get_cvs_id) return master()->get_cvs_id(from) || "";
|
fb2336 | 2001-12-04 | Martin Stjernholm | | return "";
}
void add_cvs_ids(mixed to)
{
|
d3eaa4 | 2003-01-22 | Henrik Grubbström (Grubba) | | if (arrayp(to) && sizeof(to) >= 2 && !objectp(to[1]) && arrayp(to[1]) ||
objectp(to) && to->is_generic_error)
|
fb2336 | 2001-12-04 | Martin Stjernholm | | to = to[1];
|
d3eaa4 | 2003-01-22 | Henrik Grubbström (Grubba) | | else if (!arrayp(to)) return;
|
fb2336 | 2001-12-04 | Martin Stjernholm | | foreach(to, mixed q)
|
d3eaa4 | 2003-01-22 | Henrik Grubbström (Grubba) | | if(arrayp(q) && sizeof(q) && stringp(q[0])) {
|
fb2336 | 2001-12-04 | Martin Stjernholm | | string id = get_cvs_id(q[0]);
catch (q[0] += id);
}
}
|
9c43e2 | 2010-05-06 | Fredrik Noring | | int num_describe_backtrace = 0;
|
ffebb7 | 2019-10-25 | Karl Gustav Sterneberg | | string describe_backtrace (mixed err, void|int linewidth
#ifdef RUN_SELF_TEST
, void|bool silent
#endif
)
|
fb2336 | 2001-12-04 | Martin Stjernholm | | {
|
9c43e2 | 2010-05-06 | Fredrik Noring | | num_describe_backtrace++;
|
b36cbb | 2010-11-01 | Martin Stjernholm | |
#ifdef RUN_SELF_TEST
|
ffebb7 | 2019-10-25 | Karl Gustav Sterneberg | | if (roxen && !silent)
|
b36cbb | 2010-11-01 | Martin Stjernholm | | foreach (roxen->configurations, object conf)
if (object mod = conf->get_provider ("roxen_test")) {
mod->background_failure();
}
#endif
|
fb2336 | 2001-12-04 | Martin Stjernholm | | add_cvs_ids (err);
return predef::describe_backtrace (err, 999999);
}
|
b5e3b0 | 2010-05-19 | Fredrik Noring | | int co_num_call_out = 0;
int co_num_runs_001s = 0;
int co_num_runs_005s = 0;
int co_num_runs_015s = 0;
int co_num_runs_05s = 0;
int co_num_runs_1s = 0;
int co_num_runs_5s = 0;
int co_num_runs_15s = 0;
int co_acc_time = 0;
int co_acc_cpu_time = 0;
mixed call_out(function f, float|int delay, mixed ... args)
{
return predef::call_out(class (function f) {
int __hash() { return hash_value(f); }
int `==(mixed g) { return f == g; }
string _sprintf() { return sprintf("%O", f); }
mixed `()(mixed ... args)
{
|
7f9f08 | 2010-05-19 | Fredrik Noring | | co_num_call_out++;
mixed err, res;
|
b5e3b0 | 2010-05-19 | Fredrik Noring | | int start_hrtime = gethrtime();
|
fb7e9c | 2010-05-25 | Henrik Grubbström (Grubba) | | float co_vtime = gauge { err = catch { res = f && f(@args); }; };
|
b5e3b0 | 2010-05-19 | Fredrik Noring | | float co_rtime = (gethrtime() - start_hrtime)/1E6;
if (co_rtime > 0.01) co_num_runs_001s++;
if (co_rtime > 0.05) co_num_runs_005s++;
if (co_rtime > 0.15) co_num_runs_015s++;
if (co_rtime > 0.50) co_num_runs_05s++;
if (co_rtime > 1.00) co_num_runs_1s++;
if (co_rtime > 5.00) co_num_runs_5s++;
if (co_rtime > 15.00) co_num_runs_15s++;
co_acc_cpu_time += (int)(1E6*co_vtime);
co_acc_time += (int)(1E6*co_rtime);
if (err) throw(err);
return res;
}
}(f), delay, @args);
}
|
edd857 | 2017-01-19 | Jonas Walldén | |
protected int(2..2147483647) roxen_started = [int(2..2147483647)]time();
protected float roxen_started_flt = time(time());
protected int uptime_row_counter;
|
45fbc5 | 2019-12-11 | Karl Gustav Sterneberg | |
|
78c239 | 2019-12-10 | Karl Gustav Sterneberg | | string format_timestamp()
|
509709 | 1999-08-06 | Per Hedbor | | {
|
edd857 | 2017-01-19 | Jonas Walldén | | string up_str;
if (uptime_row_counter) {
up_str = " ";
} else {
float up = time(roxen_started) - roxen_started_flt;
if (up > 3600) {
up_str = sprintf( "%2dd%2dh%2dm",
(int) up / 86400,
(((int) up / 3600) % 24),
((int) up / 60) % 60);
} else {
up_str = sprintf( "%2dm%4.1fs ", ((int) up / 60) % 60, up % 60);
|
930ddd | 1999-08-06 | Per Hedbor | | }
|
edd857 | 2017-01-19 | Jonas Walldén | | }
uptime_row_counter = (uptime_row_counter + 1) % 5;
mapping l = localtime(time());
|
4f9649 | 2020-01-09 | Eduardo Rodes Pastor | | return sprintf("%4d-%02d-%02d %2d:%02d:%02d %s : ",
|
78c239 | 2019-12-10 | Karl Gustav Sterneberg | | (1900 + l->year), (1 + l->mon), l->mday,
l->hour, l->min, l->sec, up_str);
|
509709 | 1999-08-06 | Per Hedbor | | }
|
0d7947 | 2020-12-14 | Henrik Grubbström (Grubba) | | protected multiset(function(string(8bit):void)) roxen_perror_outputs =
(< stderr->write >);
void register_roxen_perror_output(function(string(8bit):void) fun)
{
roxen_perror_outputs[fun] = 1;
}
void unregister_roxen_perror_output(function(string(8bit):void) fun)
{
roxen_perror_outputs[fun] = 0;
}
|
edd857 | 2017-01-19 | Jonas Walldén | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|
0d7947 | 2020-12-14 | Henrik Grubbström (Grubba) | | protected void low_roxen_perror(string(8bit) data)
|
aaa1cd | 2020-12-14 | Henrik Grubbström (Grubba) | | {
|
0d7947 | 2020-12-14 | Henrik Grubbström (Grubba) | | foreach(roxen_perror_outputs; function(string(8bit):void) fun;) {
mixed err = catch {
fun(data);
};
if (err) {
stderr->write("Roxen perror output handler %O failed:\n"
"%s\n",
fun, describe_backtrace(err));
}
}
|
aaa1cd | 2020-12-14 | Henrik Grubbström (Grubba) | | }
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected int last_was_nl = 1;
|
09ff05 | 1998-10-03 | Henrik Grubbström (Grubba) | |
|
c42377 | 2009-03-24 | Henrik Grubbström (Grubba) | | void roxen_perror(sprintf_format format, sprintf_args ... args)
|
3cbd83 | 1997-04-26 | Per Hedbor | | {
|
58a643 | 1999-12-20 | Martin Nilsson | | if(sizeof(args))
|
4252de | 1999-08-09 | Henrik Grubbström (Grubba) | | format=sprintf(format,@args);
|
d44ce7 | 2020-12-14 | Henrik Grubbström (Grubba) | | format = string_to_utf8(format);
|
c45b2a | 1999-12-09 | Martin Stjernholm | |
|
f353f3 | 1999-12-10 | Martin Stjernholm | |
|
c45b2a | 1999-12-09 | Martin Stjernholm | | int delayed_nl;
if (format == "\b") format = "";
else if (sizeof (format)) {
if (format[0] == '\b') {
if (last_was_nl == -1) last_was_nl = 0;
format = format[1..];
}
if (format[-1] == '\b') {
delayed_nl = 1;
format = format[..sizeof(format)-2];
}
}
|
aaa1cd | 2020-12-14 | Henrik Grubbström (Grubba) | | #if constant(syslog)
if (sizeof(format)) {
syslog_report(format, LOG_DEBUG);
}
#endif
|
4252de | 1999-08-09 | Henrik Grubbström (Grubba) | | if (!last_was_nl && (format != "")) {
int i = search(format, "\n");
if (i == -1) {
|
aaa1cd | 2020-12-14 | Henrik Grubbström (Grubba) | | low_roxen_perror(format);
|
4252de | 1999-08-09 | Henrik Grubbström (Grubba) | | format = "";
|
c45b2a | 1999-12-09 | Martin Stjernholm | | if (delayed_nl) last_was_nl = -1;
|
4252de | 1999-08-09 | Henrik Grubbström (Grubba) | | } else {
|
aaa1cd | 2020-12-14 | Henrik Grubbström (Grubba) | | low_roxen_perror(format[..i]);
|
4252de | 1999-08-09 | Henrik Grubbström (Grubba) | | format = format[i+1..];
last_was_nl = 1;
}
}
|
c45b2a | 1999-12-09 | Martin Stjernholm | | if (sizeof(format)) {
|
509709 | 1999-08-06 | Per Hedbor | |
|
aaa1cd | 2020-12-14 | Henrik Grubbström (Grubba) | | if (last_was_nl == -1) {
format = "\n" + format;
}
|
c45b2a | 1999-12-09 | Martin Stjernholm | | last_was_nl = format[-1] == '\n';
|
4252de | 1999-08-09 | Henrik Grubbström (Grubba) | |
|
eaa799 | 2001-06-30 | Martin Stjernholm | | #ifdef RUN_SELF_TEST
|
aaa1cd | 2020-12-14 | Henrik Grubbström (Grubba) | | low_roxen_perror(format);
|
eaa799 | 2001-06-30 | Martin Stjernholm | | #else
|
c45b2a | 1999-12-09 | Martin Stjernholm | | array(string) a = format/"\n";
int i;
|
4252de | 1999-08-09 | Henrik Grubbström (Grubba) | |
|
27afff | 2015-11-24 | Stefan WallstroÌm | | #ifdef DEBUG_LOG_SHOW_USER
string usr;
catch {
mixed rxml_ctx = all_constants()["_cur_rxml_context"]->get();
if(rxml_ctx)
usr = rxml_ctx->user_get_var("user.username");
};
#endif
|
c45b2a | 1999-12-09 | Martin Stjernholm | | for(i=0; i < sizeof(a)-1; i++) {
|
27afff | 2015-11-24 | Stefan WallstroÌm | | #ifdef DEBUG_LOG_SHOW_USER
if(usr)
a[i] = usr + " : " + a[i];
#endif
|
aaa1cd | 2020-12-14 | Henrik Grubbström (Grubba) | | low_roxen_perror(format_timestamp() + a[i] + "\n");
|
c45b2a | 1999-12-09 | Martin Stjernholm | | }
if (!last_was_nl) {
|
27afff | 2015-11-24 | Stefan WallstroÌm | | #ifdef DEBUG_LOG_SHOW_USER
if(usr)
a[-1] = usr + " : " + a[-1];
#endif
|
aaa1cd | 2020-12-14 | Henrik Grubbström (Grubba) | | low_roxen_perror(format_timestamp() + a[-1]);
|
c45b2a | 1999-12-09 | Martin Stjernholm | | }
|
eaa799 | 2001-06-30 | Martin Stjernholm | | #endif
|
4252de | 1999-08-09 | Henrik Grubbström (Grubba) | | }
|
c45b2a | 1999-12-09 | Martin Stjernholm | |
if (delayed_nl) last_was_nl = -1;
|
528175 | 1997-11-26 | Henrik Grubbström (Grubba) | | }
|
eec980 | 1997-04-01 | Per Hedbor | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|
8ef6ca | 1998-02-14 | Fredrik Noring | | int mkdirhier(string from, int|void mode)
|
eec980 | 1997-04-01 | Per Hedbor | | {
|
8ef6ca | 1998-02-14 | Fredrik Noring | | int r = 1;
|
2e3028 | 2000-10-10 | Martin Stjernholm | | from = roxen_path( from + "x" );
|
20bcc7 | 2000-03-13 | Martin Nilsson | | array(string) f=(from/"/");
string b="";
|
eec980 | 1997-04-01 | Per Hedbor | |
|
e30cf4 | 2000-03-13 | Per Hedbor | |
|
20bcc7 | 2000-03-13 | Martin Nilsson | | foreach(f[0..sizeof(f)-2], string a)
|
eec980 | 1997-04-01 | Per Hedbor | | {
|
9b6223 | 1999-06-21 | Martin Stjernholm | | if (query_num_arg() > 1) {
mkdir(b+a, mode);
|
850eda | 1997-09-06 | Henrik Grubbström (Grubba) | | #if constant(chmod)
|
7e9b45 | 2001-01-14 | Per Hedbor | | Stdio.Stat stat = file_stat (b + a, 1);
|
9b6223 | 1999-06-21 | Martin Stjernholm | | if (stat && stat[0] & ~mode)
|
73c22e | 2002-05-21 | Henrik Grubbström (Grubba) | |
|
6d6bc8 | 2001-06-24 | Martin Nilsson | | catch (chmod (b+a, [int]stat[0] & mode));
|
9b6223 | 1999-06-21 | Martin Stjernholm | | #endif
|
850eda | 1997-09-06 | Henrik Grubbström (Grubba) | | }
|
9b6223 | 1999-06-21 | Martin Stjernholm | | else mkdir(b+a);
|
eec980 | 1997-04-01 | Per Hedbor | | b+=a+"/";
}
|
8ef6ca | 1998-02-14 | Fredrik Noring | | if(!r)
return (file_stat(from)||({0,0}))[1] == -2;
return 1;
|
eec980 | 1997-04-01 | Per Hedbor | | }
|
09ff05 | 1998-10-03 | Henrik Grubbström (Grubba) | |
|
8f81d8 | 2001-01-03 | Per Hedbor | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|
6d6bc8 | 2001-06-24 | Martin Nilsson | | class Roxen {
mixed query(string);
void nwrite(string, int|void, int|void, void|mixed ...);
}
|
19924b | 2001-08-24 | Martin Nilsson | |
|
6d6bc8 | 2001-06-24 | Martin Nilsson | |
Roxen roxen;
|
09ff05 | 1998-10-03 | Henrik Grubbström (Grubba) | |
|
20bcc7 | 2000-03-13 | Martin Nilsson | | function(string, int|void, int|void, void|mixed ...:void) nwrite;
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | |
|
8b3289 | 2003-03-02 | Anders Johansson | |
void early_nwrite(string s, int|void perr, int|void errtype,
object|void mod, object|void conf)
{
report_debug(s);
}
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | |
|
09ff05 | 1998-10-03 | Henrik Grubbström (Grubba) | |
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | |
|
58a643 | 1999-12-20 | Martin Nilsson | | mixed query(string arg)
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | | {
if(!roxen)
error("No roxen object!\n");
|
7ba70c | 2000-07-09 | Per Hedbor | | return roxen->query( arg );
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | | }
|
a6ef1f | 2000-03-28 | Johan Sundström | |
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | | void init_logger()
{
|
d4a3f5 | 2014-05-12 | Henrik Grubbström (Grubba) | | #if constant(syslog)
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | | int res;
use_syslog = !! (query("LogA") == "syslog");
switch(query("LogST"))
{
case "Daemon": res = LOG_DAEMON; break;
|
58a643 | 1999-12-20 | Martin Nilsson | | case "Local 0": res = LOG_LOCAL; break;
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | | case "Local 1": res = LOG_LOCAL1; break;
case "Local 2": res = LOG_LOCAL2; break;
case "Local 3": res = LOG_LOCAL3; break;
case "Local 4": res = LOG_LOCAL4; break;
case "Local 5": res = LOG_LOCAL5; break;
case "Local 6": res = LOG_LOCAL6; break;
case "Local 7": res = LOG_LOCAL7; break;
case "User": res = LOG_USER; break;
}
|
58a643 | 1999-12-20 | Martin Nilsson | |
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | | loggingfield=0;
switch(query("LogWH"))
{
case "All":
loggingfield = loggingfield | LOG_INFO | LOG_NOTICE;
case "Debug":
loggingfield = loggingfield | LOG_DEBUG;
case "Warnings":
loggingfield = loggingfield | LOG_WARNING;
case "Errors":
loggingfield = loggingfield | LOG_ERR;
case "Fatal":
loggingfield = loggingfield | LOG_EMERG;
}
closelog();
|
20bcc7 | 2000-03-13 | Martin Nilsson | | openlog([string]query("LogNA"),
([int]query("LogSP")*LOG_PID)|([int]query("LogCO")*LOG_CONS),
|
58a643 | 1999-12-20 | Martin Nilsson | | res);
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | | #endif
}
|
c42377 | 2009-03-24 | Henrik Grubbström (Grubba) | | void report_debug(sprintf_format message, sprintf_args ... foo)
|
19924b | 2001-08-24 | Martin Nilsson | |
|
2e3860 | 2000-07-14 | Johan Sundström | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | | {
|
58a643 | 1999-12-20 | Martin Nilsson | | if( sizeof( foo ) )
|
23414a | 2000-07-21 | Andreas Lange | | message = sprintf((string)message, @foo );
|
c5e096 | 1999-10-04 | Per Hedbor | | roxen_perror( message );
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | | }
|
e99fd4 | 1999-11-17 | Per Hedbor | |
|
8ad929 | 2000-03-13 | Martin Nilsson | | array(object) find_module_and_conf_for_log( array(array) q )
|
e99fd4 | 1999-11-17 | Per Hedbor | | {
object conf, mod;
|
2dd6c1 | 2000-04-05 | Martin Stjernholm | | for( int i = sizeof (q); i-- > 0; )
|
e99fd4 | 1999-11-17 | Per Hedbor | | {
|
29c5a5 | 2000-03-24 | Per Hedbor | | if(!functionp([function]q[i][2]))
continue;
|
8ad929 | 2000-03-13 | Martin Nilsson | | object o = function_object( [function]q[i][2] );
|
29c5a5 | 2000-03-24 | Per Hedbor | | if(!o)
continue;
|
b69ee7 | 2000-03-09 | Martin Stjernholm | | if( o->is_module ) {
|
37d881 | 2000-02-24 | Per Hedbor | | if( !mod ) mod = o;
|
b69ee7 | 2000-03-09 | Martin Stjernholm | | if (!conf && functionp (mod->my_configuration))
|
8ad929 | 2000-03-13 | Martin Nilsson | | conf = ([function(void:object)]mod->my_configuration)();
|
b69ee7 | 2000-03-09 | Martin Stjernholm | | }
if( o->is_configuration ) {
if( !conf ) conf = o;
}
|
2dd6c1 | 2000-04-05 | Martin Stjernholm | | if( conf )
|
37d881 | 2000-02-24 | Per Hedbor | | break;
|
e99fd4 | 1999-11-17 | Per Hedbor | | }
return ({ mod,conf });
}
|
1d6f41 | 2009-12-20 | Martin Stjernholm | | protected void syslog_report (string message, int level)
{
|
d4a3f5 | 2014-05-12 | Henrik Grubbström (Grubba) | | #if constant(syslog)
|
1d6f41 | 2009-12-20 | Martin Stjernholm | | if(use_syslog && (loggingfield&level))
|
c5b951 | 2009-12-20 | Martin Stjernholm | | foreach(message/"\n", message)
syslog(level, replace(message+"\n", "%", "%%"));
|
1d6f41 | 2009-12-20 | Martin Stjernholm | | #endif
}
|
e99fd4 | 1999-11-17 | Per Hedbor | |
|
4dd337 | 1999-11-23 | Per Hedbor | | #define MC @find_module_and_conf_for_log(backtrace())
|
e99fd4 | 1999-11-17 | Per Hedbor | |
|
c42377 | 2009-03-24 | Henrik Grubbström (Grubba) | | void report_warning(LocaleString|sprintf_format message, sprintf_args ... foo)
|
19924b | 2001-08-24 | Martin Nilsson | |
|
2e3860 | 2000-07-14 | Johan Sundström | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|
c5b951 | 2009-12-20 | Martin Stjernholm | |
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | | {
|
23414a | 2000-07-21 | Andreas Lange | | if( sizeof( foo ) ) message = sprintf((string)message, @foo );
|
6d6bc8 | 2001-06-24 | Martin Nilsson | | nwrite([string]message,0,2,MC);
|
d4a3f5 | 2014-05-12 | Henrik Grubbström (Grubba) | | #if constant(syslog)
|
1d6f41 | 2009-12-20 | Martin Stjernholm | | if (use_syslog) syslog_report (message, LOG_WARNING);
|
ea803c | 2010-01-11 | Jonas Wallden | | #endif
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | | }
|
c42377 | 2009-03-24 | Henrik Grubbström (Grubba) | | void report_notice(LocaleString|sprintf_format message, sprintf_args ... foo)
|
19924b | 2001-08-24 | Martin Nilsson | |
|
2e3860 | 2000-07-14 | Johan Sundström | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|
c5b951 | 2009-12-20 | Martin Stjernholm | |
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | | {
|
23414a | 2000-07-21 | Andreas Lange | | if( sizeof( foo ) ) message = sprintf((string)message, @foo );
|
6d6bc8 | 2001-06-24 | Martin Nilsson | | nwrite([string]message,0,1,MC);
|
d4a3f5 | 2014-05-12 | Henrik Grubbström (Grubba) | | #if constant(syslog)
|
1d6f41 | 2009-12-20 | Martin Stjernholm | | if (use_syslog) syslog_report (message, LOG_NOTICE);
|
ea803c | 2010-01-11 | Jonas Wallden | | #endif
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | | }
|
c42377 | 2009-03-24 | Henrik Grubbström (Grubba) | | void report_error(LocaleString|sprintf_format message, sprintf_args ... foo)
|
19924b | 2001-08-24 | Martin Nilsson | |
|
2e3860 | 2000-07-14 | Johan Sundström | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|
c5b951 | 2009-12-20 | Martin Stjernholm | |
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | | {
|
23414a | 2000-07-21 | Andreas Lange | | if( sizeof( foo ) ) message = sprintf((string)message, @foo );
|
6d6bc8 | 2001-06-24 | Martin Nilsson | | nwrite([string]message,0,3,MC);
|
d4a3f5 | 2014-05-12 | Henrik Grubbström (Grubba) | | #if constant(syslog)
|
1d6f41 | 2009-12-20 | Martin Stjernholm | | if (use_syslog) syslog_report (message, LOG_ERR);
|
ea803c | 2010-01-11 | Jonas Wallden | | #endif
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | | }
|
c42377 | 2009-03-24 | Henrik Grubbström (Grubba) | | void report_fatal(sprintf_format message, sprintf_args ... foo)
|
19924b | 2001-08-24 | Martin Nilsson | |
|
c5b951 | 2009-12-20 | Martin Stjernholm | |
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | | {
|
23414a | 2000-07-21 | Andreas Lange | | if( sizeof( foo ) ) message = sprintf((string)message, @foo );
|
4dd337 | 1999-11-23 | Per Hedbor | | nwrite(message,0,3,MC);
|
d4a3f5 | 2014-05-12 | Henrik Grubbström (Grubba) | | #if constant(syslog)
|
1d6f41 | 2009-12-20 | Martin Stjernholm | | if (use_syslog) syslog_report (message, LOG_EMERG);
|
ea803c | 2010-01-11 | Jonas Wallden | | #endif
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | | }
|
09ff05 | 1998-10-03 | Henrik Grubbström (Grubba) | |
|
c5b951 | 2009-12-20 | Martin Stjernholm | | void report_warning_for (object where,
LocaleString|sprintf_format message,
sprintf_args ... args)
{
if (sizeof (args)) message = sprintf (message, @args);
nwrite (message, 0, 2,
where && where->is_module && where,
where && where->is_configuration && where);
|
d4a3f5 | 2014-05-12 | Henrik Grubbström (Grubba) | | #if constant(syslog)
|
c5b951 | 2009-12-20 | Martin Stjernholm | | if (use_syslog) syslog_report (message, LOG_WARNING);
|
ea803c | 2010-01-11 | Jonas Wallden | | #endif
|
c5b951 | 2009-12-20 | Martin Stjernholm | | }
void report_notice_for (object where,
LocaleString|sprintf_format message,
sprintf_args ... args)
{
if (sizeof (args)) message = sprintf (message, @args);
nwrite (message, 0, 1,
where && where->is_module && where,
where && where->is_configuration && where);
|
d4a3f5 | 2014-05-12 | Henrik Grubbström (Grubba) | | #if constant(syslog)
|
c5b951 | 2009-12-20 | Martin Stjernholm | | if (use_syslog) syslog_report (message, LOG_NOTICE);
|
ea803c | 2010-01-11 | Jonas Wallden | | #endif
|
c5b951 | 2009-12-20 | Martin Stjernholm | | }
void report_error_for (object where,
LocaleString|sprintf_format message,
sprintf_args ... args)
{
if (sizeof (args)) message = sprintf (message, @args);
nwrite (message, 0, 3,
where && where->is_module && where,
where && where->is_configuration && where);
|
d4a3f5 | 2014-05-12 | Henrik Grubbström (Grubba) | | #if constant(syslog)
|
c5b951 | 2009-12-20 | Martin Stjernholm | | if (use_syslog) syslog_report (message, LOG_ERR);
|
ea803c | 2010-01-11 | Jonas Wallden | | #endif
|
c5b951 | 2009-12-20 | Martin Stjernholm | | }
void report_fatal_for (object where,
LocaleString|sprintf_format message,
sprintf_args ... args)
{
if (sizeof (args)) message = sprintf (message, @args);
nwrite (message, 0, 3,
where && where->is_module && where,
where && where->is_configuration && where);
|
d4a3f5 | 2014-05-12 | Henrik Grubbström (Grubba) | | #if constant(syslog)
|
c5b951 | 2009-12-20 | Martin Stjernholm | | if (use_syslog) syslog_report (message, LOG_EMERG);
|
ea803c | 2010-01-11 | Jonas Wallden | | #endif
|
c5b951 | 2009-12-20 | Martin Stjernholm | | }
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected mapping(string:int) sparsely_dont_log = (garb_sparsely_dont_log(), ([]));
|
b00dfe | 2001-02-05 | Martin Stjernholm | |
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected void garb_sparsely_dont_log()
|
b00dfe | 2001-02-05 | Martin Stjernholm | | {
if (sparsely_dont_log && sizeof (sparsely_dont_log)) {
int now = time (1);
|
893cae | 2012-07-02 | Martin Stjernholm | | foreach (sparsely_dont_log; string msg; int ts)
if (ts < now) m_delete (sparsely_dont_log, msg);
|
b00dfe | 2001-02-05 | Martin Stjernholm | | }
|
893cae | 2012-07-02 | Martin Stjernholm | | call_out (garb_sparsely_dont_log, 20*60);
|
b00dfe | 2001-02-05 | Martin Stjernholm | | }
|
c42377 | 2009-03-24 | Henrik Grubbström (Grubba) | | void report_warning_sparsely (LocaleString|sprintf_format message,
sprintf_args ... args)
|
19924b | 2001-08-24 | Martin Nilsson | |
|
b00dfe | 2001-02-05 | Martin Stjernholm | |
{
if( sizeof( args ) ) message = sprintf((string)message, @args );
int now = time (1);
if (sparsely_dont_log[message] >= now) return;
sparsely_dont_log[message] = now + 10*60;
|
6d6bc8 | 2001-06-24 | Martin Nilsson | | nwrite([string]message,0,2,MC);
|
d4a3f5 | 2014-05-12 | Henrik Grubbström (Grubba) | | #if constant(syslog)
|
c9182f | 2009-12-20 | Martin Stjernholm | | if (use_syslog) syslog_report (message, LOG_WARNING);
|
ea803c | 2010-01-11 | Jonas Wallden | | #endif
|
b00dfe | 2001-02-05 | Martin Stjernholm | | }
|
c42377 | 2009-03-24 | Henrik Grubbström (Grubba) | | void report_error_sparsely (LocaleString|sprintf_format message,
sprintf_args ... args)
|
19924b | 2001-08-24 | Martin Nilsson | |
|
b00dfe | 2001-02-05 | Martin Stjernholm | |
{
if( sizeof( args ) ) message = sprintf((string)message, @args );
int now = time (1);
|
893cae | 2012-07-02 | Martin Stjernholm | | if (sparsely_dont_log[message] >= now) return;
sparsely_dont_log[message] = now + 10*60;
|
6d6bc8 | 2001-06-24 | Martin Nilsson | | nwrite([string]message,0,3,MC);
|
d4a3f5 | 2014-05-12 | Henrik Grubbström (Grubba) | | #if constant(syslog)
|
c9182f | 2009-12-20 | Martin Stjernholm | | if (use_syslog) syslog_report (message, LOG_ERR);
|
ea803c | 2010-01-11 | Jonas Wallden | | #endif
|
b00dfe | 2001-02-05 | Martin Stjernholm | | }
|
19924b | 2001-08-24 | Martin Nilsson | |
|
92ced8 | 2011-09-12 | Henrik Grubbström (Grubba) | |
|
533be8 | 2009-02-17 | Martin Stjernholm | |
|
92ced8 | 2011-09-12 | Henrik Grubbström (Grubba) | |
|
533be8 | 2009-02-17 | Martin Stjernholm | | string popen(string|array(string) cmd, void|mapping env,
int|void uid, int|void gid)
|
5e8921 | 1997-02-13 | Per Hedbor | | {
|
3e3bab | 2001-01-19 | Per Hedbor | | Stdio.File f = Stdio.File(), p = f->pipe(Stdio.PROP_IPC);
|
fa13be | 1998-05-28 | Henrik Grubbström (Grubba) | |
|
3e3bab | 2001-01-19 | Per Hedbor | | if(!p) error("Popen failed. (could not create pipe)\n");
|
7e6d46 | 1998-01-20 | Henrik Grubbström (Grubba) | |
|
20bcc7 | 2000-03-13 | Martin Nilsson | | mapping(string:mixed) opts = ([
|
c79b26 | 1998-02-05 | Johan Schön | | "env": (env || getenv()),
|
fa13be | 1998-05-28 | Henrik Grubbström (Grubba) | | "stdout":p,
|
99bf7d | 1998-01-16 | Henrik Grubbström (Grubba) | | ]);
|
22aeb6 | 1998-01-17 | Henrik Grubbström (Grubba) | |
|
3e3bab | 2001-01-19 | Per Hedbor | | if (!getuid())
{
switch(query_num_arg())
{
|
fa13be | 1998-05-28 | Henrik Grubbström (Grubba) | | case 4:
opts->gid = gid;
case 3:
opts->uid = uid;
break;
}
}
|
6e8854 | 1999-02-16 | Per Hedbor | | opts->noinitgroups = 1;
|
533be8 | 2009-02-17 | Martin Stjernholm | | if (stringp (cmd)) {
|
7f8248 | 2001-12-19 | Henrik Grubbström (Grubba) | | #if defined(__NT__) || defined(__amigaos__)
|
533be8 | 2009-02-17 | Martin Stjernholm | | cmd = Process.split_quoted_string(cmd);
|
7f8248 | 2001-12-19 | Henrik Grubbström (Grubba) | | #else /* !__NT||__amigaos__ */
|
533be8 | 2009-02-17 | Martin Stjernholm | | cmd = ({"/bin/sh", "-c", cmd});
|
7f8248 | 2001-12-19 | Henrik Grubbström (Grubba) | | #endif /* __NT__ || __amigaos__ */
|
533be8 | 2009-02-17 | Martin Stjernholm | | }
Process.Process proc = Process.Process (cmd, opts);
|
fa13be | 1998-05-28 | Henrik Grubbström (Grubba) | | p->close();
|
3e3bab | 2001-01-19 | Per Hedbor | | if( proc )
|
b796b5 | 1998-11-18 | Per Hedbor | | {
|
3e3bab | 2001-01-19 | Per Hedbor | | string t = f->read();
|
fa13be | 1998-05-28 | Henrik Grubbström (Grubba) | | f->close();
destruct(f);
|
99bf7d | 1998-01-16 | Henrik Grubbström (Grubba) | | return t;
}
|
fa13be | 1998-05-28 | Henrik Grubbström (Grubba) | | f->close();
destruct(f);
|
99bf7d | 1998-01-16 | Henrik Grubbström (Grubba) | | return 0;
|
5e8921 | 1997-02-13 | Per Hedbor | | }
|
19924b | 2001-08-24 | Martin Nilsson | |
|
3e3bab | 2001-01-19 | Per Hedbor | | Process.Process spawne(string s, array(string) args, mapping|array env,
Stdio.File stdin, Stdio.File stdout, Stdio.File stderr,
void|string wd, void|array(int) uid)
|
5e8921 | 1997-02-13 | Per Hedbor | | {
|
8afc81 | 1998-02-04 | Per Hedbor | | int u, g;
|
58a643 | 1999-12-20 | Martin Nilsson | | if(uid) { u = uid[0]; g = uid[1]; }
|
d4a3f5 | 2014-05-12 | Henrik Grubbström (Grubba) | | #if constant(geteuid)
|
c5e096 | 1999-10-04 | Per Hedbor | | else { u=geteuid(); g=getegid(); }
|
c79b26 | 1998-02-05 | Johan Schön | | #endif
|
92ced8 | 2011-09-12 | Henrik Grubbström (Grubba) | | return Process.Process(({s}) + (args || ({})), ([
|
99bf7d | 1998-01-16 | Henrik Grubbström (Grubba) | | "toggle_uid":1,
"stdin":stdin,
"stdout":stdout,
"stderr":stderr,
"cwd":wd,
|
8afc81 | 1998-02-04 | Per Hedbor | | "env":env,
"uid":u,
"gid":g,
|
99bf7d | 1998-01-16 | Henrik Grubbström (Grubba) | | ]));
|
5e8921 | 1997-02-13 | Per Hedbor | | }
|
19924b | 2001-08-24 | Martin Nilsson | |
|
3e3bab | 2001-01-19 | Per Hedbor | | Process.Process spawn_pike(array(string) args, void|string wd,
Stdio.File|void stdin, Stdio.File|void stdout,
Stdio.File|void stderr)
|
51ff83 | 1997-05-13 | Marcus Comstedt | | {
|
2b01a4 | 2009-01-09 | Martin Stjernholm | | array(string) cmd = ({
|
06c506 | 2000-06-29 | Fredrik Noring | | #ifndef __NT__
|
2b01a4 | 2009-01-09 | Martin Stjernholm | | getcwd()+"/start",
|
06c506 | 2000-06-29 | Fredrik Noring | | #else /* __NT__ */
|
2b01a4 | 2009-01-09 | Martin Stjernholm | | getcwd()+"/../ntstart.exe",
|
06c506 | 2000-06-29 | Fredrik Noring | | #endif /* __NT__ */
|
2b01a4 | 2009-01-09 | Martin Stjernholm | | });
if (wd) cmd += ({"--cd", wd});
cmd += ({"--quiet","--program"}) + args;
|
92ced8 | 2011-09-12 | Henrik Grubbström (Grubba) | | return Process.Process (cmd,
(["toggle_uid":1,
"stdin":stdin,
"stdout":stdout,
"stderr":stderr]));
|
51ff83 | 1997-05-13 | Marcus Comstedt | | }
|
09ff05 | 1998-10-03 | Henrik Grubbström (Grubba) | |
|
fc4039 | 2008-08-15 | Martin Stjernholm | | private object initiate_cache()
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
object cache;
|
82f519 | 1997-03-02 | Per Hedbor | | cache=((program)"base_server/cache")();
|
62b3c4 | 2000-08-12 | Per Hedbor | |
add_constant("http_decode_string", _Roxen.http_decode_string );
|
42c5a0 | 2007-09-06 | Henrik Grubbström (Grubba) | | add_constant("cache_clear_deltas", cache->cache_clear_deltas);
|
425fc6 | 2000-09-21 | Per Hedbor | | add_constant("cache_set", cache->cache_set);
|
b1fca0 | 1996-11-12 | Per Hedbor | | add_constant("cache_lookup", cache->cache_lookup);
|
135318 | 2009-11-12 | Martin Stjernholm | | add_constant("cache_peek", cache->cache_peek);
|
b1fca0 | 1996-11-12 | Per Hedbor | | add_constant("cache_remove", cache->cache_remove);
|
f6d62d | 1997-03-26 | Per Hedbor | | add_constant("cache_expire", cache->cache_expire);
|
c938b3 | 2012-07-10 | Jonas Wallden | | add_constant("cache_expire_by_prefix", cache->cache_expire_by_prefix);
|
425fc6 | 2000-09-21 | Per Hedbor | | add_constant("cache_clear", cache->cache_expire);
|
8f2318 | 2009-12-09 | Martin Stjernholm | | add_constant("cache_entries",cache->cache_entries);
|
425fc6 | 2000-09-21 | Per Hedbor | | add_constant("cache_indices",cache->cache_indices);
|
79c3d7 | 2011-03-15 | Martin Stjernholm | | add_constant("CacheEntry", cache->CacheEntry);
|
4d1c5f | 2001-07-26 | Martin Stjernholm | |
return cache;
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
8ad929 | 2000-03-13 | Martin Nilsson | | class _error_handler {
|
02a63f | 2000-09-05 | Per Hedbor | | void compile_error(string a,int b,string c);
void compile_warning(string a,int b,string c);
|
8ad929 | 2000-03-13 | Martin Nilsson | | }
array(_error_handler) compile_error_handlers = ({});
void push_compile_error_handler( _error_handler q )
|
40dd28 | 1999-11-23 | Per Hedbor | | {
|
6465b9 | 2000-09-27 | Per Hedbor | | if( q->do_not_push )
|
ddb2d9 | 2000-11-13 | Per Hedbor | | {
|
b86de8 | 2000-11-13 | Per Hedbor | | master()->set_inhibit_compile_errors( q );
|
ddb2d9 | 2000-11-13 | Per Hedbor | | compile_error_handlers = ({0})+compile_error_handlers;
}
else
compile_error_handlers = ({q})+compile_error_handlers;
|
40dd28 | 1999-11-23 | Per Hedbor | | }
void pop_compile_error_handler()
{
|
8a5483 | 2004-05-14 | Martin Stjernholm | | if( !compile_error_handlers[0] )
|
ddb2d9 | 2000-11-13 | Per Hedbor | | {
master()->set_inhibit_compile_errors(0);
|
b86de8 | 2000-11-13 | Per Hedbor | | return;
|
ddb2d9 | 2000-11-13 | Per Hedbor | | }
|
40dd28 | 1999-11-23 | Per Hedbor | | compile_error_handlers = compile_error_handlers[1..];
}
class LowErrorContainer
|
256d28 | 1999-11-04 | Henrik Grubbström (Grubba) | | {
string d;
|
17d6d1 | 2000-03-30 | Per Hedbor | | string errors="", warnings="";
|
b86de8 | 2000-11-13 | Per Hedbor | | constant do_not_push = 0;
|
256d28 | 1999-11-04 | Henrik Grubbström (Grubba) | | string get()
{
return errors;
}
|
17d6d1 | 2000-03-30 | Per Hedbor | | string get_warnings()
{
return warnings;
}
void got_error(string file, int line, string err, int|void is_warning)
|
256d28 | 1999-11-04 | Henrik Grubbström (Grubba) | | {
|
cefd17 | 2011-12-27 | Martin Stjernholm | | if (has_prefix (file, d)) file = file[sizeof(d)..];
if (has_prefix (file, server_dir)) file = file[sizeof(server_dir)..];
|
17d6d1 | 2000-03-30 | Per Hedbor | | if( is_warning)
warnings+= sprintf("%s:%s\t%s\n", file, line ? (string) line : "-", err);
else
errors += sprintf("%s:%s\t%s\n", file, line ? (string) line : "-", err);
|
256d28 | 1999-11-04 | Henrik Grubbström (Grubba) | | }
void compile_error(string file, int line, string err)
{
got_error(file, line, "Error: " + err);
}
void compile_warning(string file, int line, string err)
{
|
17d6d1 | 2000-03-30 | Per Hedbor | | got_error(file, line, "Warning: " + err, 1);
|
256d28 | 1999-11-04 | Henrik Grubbström (Grubba) | | }
void create()
{
d = getcwd();
|
40dd28 | 1999-11-23 | Per Hedbor | | if (sizeof(d) && (d[-1] != '/') && (d[-1] != '\\'))
|
256d28 | 1999-11-04 | Henrik Grubbström (Grubba) | | d += "/";
|
40dd28 | 1999-11-23 | Per Hedbor | | }
}
|
19924b | 2001-08-24 | Martin Nilsson | |
|
40dd28 | 1999-11-23 | Per Hedbor | | class ErrorContainer
{
inherit LowErrorContainer;
|
6465b9 | 2000-09-27 | Per Hedbor | | constant do_not_push = 1;
|
40dd28 | 1999-11-23 | Per Hedbor | | void compile_error(string file, int line, string err)
{
if( sizeof(compile_error_handlers) )
|
ddb2d9 | 2000-11-13 | Per Hedbor | | (compile_error_handlers-({0}))->compile_error( file,line, err );
::compile_error(file,line,err);
|
40dd28 | 1999-11-23 | Per Hedbor | | }
void compile_warning(string file, int line, string err)
{
if( sizeof(compile_error_handlers) )
|
ddb2d9 | 2000-11-13 | Per Hedbor | | (compile_error_handlers-({0}))->compile_warning( file,line, err );
::compile_warning(file,line,err);
|
40dd28 | 1999-11-23 | Per Hedbor | | }
|
256d28 | 1999-11-04 | Henrik Grubbström (Grubba) | | }
|
19924b | 2001-08-24 | Martin Nilsson | |
|
a4031a | 1997-09-17 | Henrik Grubbström (Grubba) | | class restricted_cd
{
int locked_pid = getpid();
int `()(string path)
{
if (locked_pid == getpid()) {
|
d67340 | 2002-01-28 | Martin Stjernholm | | error ("Use of cd() is restricted.\n");
|
a4031a | 1997-09-17 | Henrik Grubbström (Grubba) | | }
return cd(path);
}
}
|
09ff05 | 1998-10-03 | Henrik Grubbström (Grubba) | |
|
c79b26 | 1998-02-05 | Johan Schön | | #if !constant(getuid)
int getuid(){ return 17; }
int getgid(){ return 42; }
#endif
|
f0e0e6 | 1998-03-20 | Per Hedbor | |
|
625820 | 2013-03-11 | Henrik Grubbström (Grubba) | | #if constant(Crypto.Password)
constant verify_password = Crypto.Password.verify;
constant crypt_password = Crypto.Password.hash;
#else /* !Crypto.Password */
|
e24055 | 2013-03-08 | Henrik Grubbström (Grubba) | |
int verify_password(string password, string hash)
{
if (hash == "") return 1;
string scheme = "crypt";
sscanf(hash, "{%s}%s", scheme, hash);
switch(lower_case(scheme)) {
case "md5":
case "smd5":
hash = MIME.decode_base64(hash);
password += hash[16..];
hash = hash[..15];
return Crypto.MD5.hash(password) == hash;
case "sha":
case "ssha":
hash = MIME.decode_base64(hash);
password += hash[20..];
hash = hash[..19];
return Crypto.SHA1.hash(password) == hash;
case "crypt":
if ((hash == "") || crypt(password, hash)) return 1;
if (hash[0] != '$') {
if (hash[0] == '_') {
}
return 0;
}
sscanf(hash, "$%s$%s$%s", scheme, string salt, string hash);
int rounds = UNDEFINED;
if (has_prefix(salt, "rounds=")) {
sscanf(salt, "rounds=%d", rounds);
sscanf(hash, "%s$%s", salt, hash);
}
switch(scheme) {
case "1":
return Nettle.crypt_md5(password, salt) == hash;
case "2":
case "2a":
case "2x":
case "2y":
break;
case "3":
break;
#if constant(Crypto.SHA256.crypt_hash)
case "5":
return Crypto.SHA256.crypt_hash(password, salt, rounds) == hash;
#endif
#if constant(Crypto.SHA512.crypt_hash)
case "6":
return Crypto.SHA512.crypt_hash(password, salt, rounds) == hash;
#endif
}
break;
}
return 0;
}
string crypt_password(string password, string|void scheme, int|void rounds)
{
function(string, string, int:string) crypt_hash;
int salt_size = 16;
int default_rounds = 5000;
switch(scheme) {
case UNDEFINED:
#if constant(Crypto.SHA512.crypt_hash)
case "6":
case "$6$":
crypt_hash = Crypto.SHA512.crypt_hash;
scheme = "6";
break;
#endif
#if constant(Crypto.SHA256.crypt_hash)
case "5":
case "$5$":
crypt_hash = Crypto.SHA256.crypt_hash;
scheme = "5";
break;
#endif
#if constant(Crypto.MD5.crypt_hash)
case "1":
case "$1$":
crypt_hash = Crypto.MD5.crypt_hash;
salt_size = 8;
rounds = 1000;
default_rounds = 1000;
scheme = "1";
break;
#endif
case "":
return crypt(password);
default:
error("Unsupported hashing scheme: %O\n", scheme);
}
if (!rounds) rounds = default_rounds;
string salt =
MIME.encode_base64(Crypto.Random.random_string(salt_size))[..salt_size-1];
string hash = crypt_hash(password, salt, rounds);
if (rounds != default_rounds) {
salt = "rounds=" + rounds + "$" + salt;
}
return sprintf("$%s$%s$%s", scheme, salt, hash);
}
|
625820 | 2013-03-11 | Henrik Grubbström (Grubba) | | #endif /* !Crypto.Password */
|
e24055 | 2013-03-08 | Henrik Grubbström (Grubba) | |
|
e41c9d | 2017-04-21 | Henrik Grubbström (Grubba) | | #ifdef THREADS
Thread.Mutex euid_egid_lock = Thread.Mutex();
#endif /* THREADS */
#if constant(System.dumpable)
#define enable_coredumps(X) System.dumpable(X)
#else
#define enable_coredumps(X)
#endif
int privs_level;
protected class Privs
{
#if constant(seteuid)
int saved_uid;
int saved_gid;
int new_uid;
int new_gid;
#define LOGP (roxen->variables && roxen->variables->audit && roxen->variables->audit->query())
#if constant(geteuid) && constant(getegid) && constant(seteuid) && constant(setegid)
#define HAVE_EFFECTIVE_USER
#endif
private string _getcwd()
{
if (catch{return(getcwd());}) {
return("Unknown directory (no x-bit on current directory?)");
}
}
private string dbt(array t)
{
if(!arrayp(t) || (sizeof(t)<2)) return "";
return (((t[0]||"Unknown program")-(_getcwd()+"/"))-"base_server/")+":"+t[1]+"\n";
}
#ifdef THREADS
protected mixed mutex_key;
protected object threads_disabled;
#endif /* THREADS */
int p_level;
void create(string reason, int|string|void uid, int|string|void gid)
{
if(getuid()) return;
#ifdef PRIVS_DEBUG
report_debug(sprintf("Privs(%O, %O, %O)\n"
"privs_level: %O\n",
reason, uid, gid, privs_level));
#endif /* PRIVS_DEBUG */
#ifdef HAVE_EFFECTIVE_USER
array u;
#ifdef THREADS
if (euid_egid_lock) {
if (mixed err = catch { mutex_key = euid_egid_lock->lock(); })
master()->handle_error (err);
}
threads_disabled = _disable_threads();
#endif /* THREADS */
p_level = privs_level++;
saved_uid = geteuid();
saved_gid = getegid();
seteuid(0);
if(stringp(uid) && (replace(uid,"0123456789"/"",({""})*10)==""))
uid = (int)uid;
if(stringp(gid) && (replace(gid, "0123456789"/"", ({"" })*10) == ""))
gid = (int)gid;
if(!stringp(uid))
u = getpwuid(uid);
else
{
u = getpwnam(uid);
if(u)
uid = u[2];
}
if(u && !gid)
gid = u[3];
if(!u)
{
if (uid && (uid != "root"))
{
if (intp(uid) && (uid >= 60000))
{
report_warning(sprintf("Privs: User %d is not in the password database.\n"
"Assuming nobody.\n", uid));
gid = gid || uid;
u = ({ "fake-nobody", "x", uid, gid, "A real nobody", "/", "/sbin/sh" });
} else {
error("Unknown user: "+uid+"\n");
}
} else {
u = ({ "root", "x", 0, gid, "The super-user", "/", "/sbin/sh" });
}
}
if(LOGP)
report_notice(LOC_M(1, "Change to %s(%d):%d privs wanted (%s), from %s"),
(string)u[0], (int)uid, (int)gid,
(string)reason,
(string)dbt(backtrace()[-2]));
if (u[2]) {
#if constant(cleargroups)
if (mixed err = catch { cleargroups(); })
master()->handle_error (err);
#endif /* cleargroups */
#if constant(initgroups)
if (mixed err = catch { initgroups(u[0], u[3]); })
master()->handle_error (err);
#endif
}
gid = gid || getgid();
int err = (int)setegid(new_gid = gid);
if (err < 0) {
report_warning(LOC_M(2, "Privs: WARNING: Failed to set the "
"effective group id to %d!\n"
"Check that your password database is correct "
"for user %s(%d),\n and that your group "
"database is correct.\n"),
gid, (string)u[0], (int)uid);
int gid2 = gid;
#ifdef HPUX_KLUDGE
if (gid >= 60000) {
report_debug("Privs: WARNING: Assuming nobody-group.\n"
"Trying some alternatives...\n");
foreach(({ 60001, 65534, -2 }), gid2) {
report_debug("%d... ", gid2);
if (initgroups(u[0], gid2) >= 0) {
if ((err = setegid(new_gid = gid2)) >= 0) {
report_debug("Success!\n");
break;
}
}
}
}
#endif /* HPUX_KLUDGE */
if (err < 0) {
report_debug("Privs: Failed\n");
error ("Failed to set EGID to %d\n", gid);
}
report_debug("Privs: WARNING: Set egid to %d instead of %d.\n",
gid2, gid);
gid = gid2;
}
if(getgid()!=gid) setgid(gid||getgid());
seteuid(new_uid = uid);
enable_coredumps(1);
#endif /* HAVE_EFFECTIVE_USER */
}
void destroy()
{
if(getuid()) return;
#ifdef PRIVS_DEBUG
report_debug(sprintf("Privs->destroy()\n"
"privs_level: %O\n",
privs_level));
#endif /* PRIVS_DEBUG */
#ifdef HAVE_EFFECTIVE_USER
if (p_level >= privs_level) {
report_error(sprintf("Change back to uid#%d gid#%d from uid#%d gid#%d\n"
"in wrong order! Saved level:%d Current level:%d\n"
"Occurs in:\n%s\n",
saved_uid, saved_gid, new_uid, new_gid,
p_level, privs_level,
describe_backtrace(backtrace())));
return(0);
}
if (p_level != privs_level-1) {
report_error(sprintf("Change back to uid#%d gid#%d from uid#%d gid#%d\n"
"Skips privs level. Saved level:%d Current level:%d\n"
"Occurs in:\n%s\n",
saved_uid, saved_gid, new_uid, new_gid,
p_level, privs_level,
describe_backtrace(backtrace())));
}
privs_level = p_level;
if(LOGP) {
if (mixed err = catch {
array bt = backtrace();
if (sizeof(bt) >= 2) {
report_notice(LOC_M(3,"Change back to uid#%d gid#%d, from %s")+"\n",
saved_uid, saved_gid, dbt(bt[-2]));
} else {
report_notice(LOC_M(4,"Change back to uid#%d gid#%d, "
"from backend")+"\n", saved_uid, saved_gid);
}
})
master()->handle_error (err);
}
#ifdef PRIVS_DEBUG
int uid = geteuid();
if (uid != new_uid) {
report_debug("Privs: UID #%d differs from expected #%d\n"
"%s\n",
uid, new_uid, describe_backtrace(backtrace()));
}
int gid = getegid();
if (gid != new_gid) {
report_debug("Privs: GID #%d differs from expected #%d\n"
"%s\n",
gid, new_gid, describe_backtrace(backtrace()));
}
#endif /* PRIVS_DEBUG */
seteuid(0);
array u = getpwuid(saved_uid);
#if constant(cleargroups)
if (mixed err = catch { cleargroups(); })
master()->handle_error (err);
#endif /* cleargroups */
if(u && (sizeof(u) > 3)) {
if (mixed err = catch { initgroups(u[0], u[3]); })
master()->handle_error (err);
}
setegid(saved_gid);
seteuid(saved_uid);
enable_coredumps(1);
#endif /* HAVE_EFFECTIVE_USER */
}
#else /* constant(seteuid) */
void create(string reason, int|string|void uid, int|string|void gid){}
#endif /* constant(seteuid) */
}
|
8bb2c7 | 2019-02-15 | Henrik Grubbström (Grubba) | | class RoxenConcurrent
{
inherit Concurrent;
class Promise
{
inherit ::this_program;
|
034fd4 | 2019-02-19 | Henrik Grubbström (Grubba) | | private string describe_funcall(Pike.BacktraceFrame frame)
{
string fun;
if (stringp(frame[2])) {
fun = frame[2];
} else {
fun = master()->describe_function(frame[2]);
}
return sprintf("%s(%s)",
fun,
master()->Describer()->
describe_comma_list(frame[3..], 99999));
}
private string describe_initiator()
{
foreach(reverse(backtrace()), Pike.BacktraceFrame frame) {
mixed fun = frame[2];
if (callablep(fun)) {
object o = function_object(fun);
if ((o == this_object()) || (object_program(o) == RoxenConcurrent)) {
continue;
}
}
return describe_funcall(frame);
}
return UNDEFINED;
}
protected string initiator = describe_initiator();
|
8bb2c7 | 2019-02-15 | Henrik Grubbström (Grubba) | | #ifdef THREADS
|
233a92 | 2021-09-23 | Henrik Grubbström (Grubba) | | protected class HandlerBackend(protected object roxen)
|
8bb2c7 | 2019-02-15 | Henrik Grubbström (Grubba) | | {
|
f4f15a | 2019-03-01 | Henrik Grubbström (Grubba) | | array call_out(function co, int t, mixed ... args)
{
if (roxen && !t) {
|
cea01f | 2019-04-17 | Henrik Grubbström (Grubba) | | roxen->low_handle(co, @args);
|
f4f15a | 2019-03-01 | Henrik Grubbström (Grubba) | | return 0;
} else {
|
cea01f | 2019-04-17 | Henrik Grubbström (Grubba) | | return predef::call_out(roxen->low_handle, t, co, @args);
|
f4f15a | 2019-03-01 | Henrik Grubbström (Grubba) | | }
}
void remove_call_out(function|array co)
{
if (!co) return;
predef::remove_call_out(co);
|
8bb2c7 | 2019-02-15 | Henrik Grubbström (Grubba) | | }
}
|
f4f15a | 2019-03-01 | Henrik Grubbström (Grubba) | |
|
233a92 | 2021-09-23 | Henrik Grubbström (Grubba) | | protected Pike.Backend backend = HandlerBackend(roxen);
|
8bb2c7 | 2019-02-15 | Henrik Grubbström (Grubba) | | #endif /* THREADS */
|
034fd4 | 2019-02-19 | Henrik Grubbström (Grubba) | |
protected string _sprintf(int c)
{
if (c == 'O') {
return sprintf("%O(/* %s */)", object_program(this), initiator || "");
}
return UNDEFINED;
}
|
8bb2c7 | 2019-02-15 | Henrik Grubbström (Grubba) | | }
}
|
09ff05 | 1998-10-03 | Henrik Grubbström (Grubba) | |
|
6d6bc8 | 2001-06-24 | Martin Nilsson | | Roxen really_load_roxen()
|
f0e0e6 | 1998-03-20 | Per Hedbor | | {
int start_time = gethrtime();
|
0dd24b | 2003-03-06 | Jonas Wallden | | report_debug("Loading Roxen ... \b");
|
6d6bc8 | 2001-06-24 | Martin Nilsson | | Roxen res;
|
256d28 | 1999-11-04 | Henrik Grubbström (Grubba) | | mixed err = catch {
|
8f81d8 | 2001-01-03 | Per Hedbor | | res = ((program)"base_server/roxen.pike")();
|
256d28 | 1999-11-04 | Henrik Grubbström (Grubba) | | };
|
40e1d6 | 2000-04-13 | Per Hedbor | | if (err)
{
|
56509c | 2001-06-30 | Martin Stjernholm | | report_debug("\bERROR\n");
|
947873 | 2000-03-06 | Martin Stjernholm | | werror (describe_backtrace (err));
|
256d28 | 1999-11-04 | Henrik Grubbström (Grubba) | | throw(err);
}
|
56509c | 2001-06-30 | Martin Stjernholm | | report_debug("\bDone [%.1fms]\n",
|
1d9cfb | 2000-02-14 | Per Hedbor | | (gethrtime()-start_time)/1000.0);
|
256d28 | 1999-11-04 | Henrik Grubbström (Grubba) | |
|
27942e | 1999-09-02 | Per Hedbor | | res->start_time = start_time;
res->boot_time = start_time;
|
4dd337 | 1999-11-23 | Per Hedbor | | nwrite = res->nwrite;
|
d3eaa4 | 2003-01-22 | Henrik Grubbström (Grubba) | |
|
f0e0e6 | 1998-03-20 | Per Hedbor | | return res;
}
|
c79b26 | 1998-02-05 | Johan Schön | |
|
09ff05 | 1998-10-03 | Henrik Grubbström (Grubba) | |
|
139f4c | 1998-03-23 | Henrik Grubbström (Grubba) | | #ifdef TRACE_DESTRUCT
void trace_destruct(mixed x)
|
19924b | 2001-08-24 | Martin Nilsson | |
|
139f4c | 1998-03-23 | Henrik Grubbström (Grubba) | | {
|
58a643 | 1999-12-20 | Martin Nilsson | | report_debug("DESTRUCT(%O)\n%s\n",
x, describe_backtrace(backtrace())):
|
139f4c | 1998-03-23 | Henrik Grubbström (Grubba) | | destruct(x);
}
#endif /* TRACE_DESTRUCT */
|
c348db | 2003-09-15 | Martin Stjernholm | | void trace_exit (int exitcode)
{
catch (report_notice ("Exiting Roxen - exit(%d) called.\n", exitcode));
#ifdef TRACE_EXIT
catch (report_debug (describe_backtrace (backtrace())));
#endif
exit (exitcode);
}
constant real_exit = exit;
|
50b697 | 2001-08-31 | Per Hedbor | | #define DC(X) add_dump_constant( X,nm_resolv(X) )
function add_dump_constant;
mixed nm_resolv(string x )
{
catch {
return new_master->resolv( x );
};
return ([])[0];
};
|
09ff05 | 1998-10-03 | Henrik Grubbström (Grubba) | |
|
b1fca0 | 1996-11-12 | Per Hedbor | | void load_roxen()
{
|
40e1d6 | 2000-04-13 | Per Hedbor | |
|
660eda | 2001-04-09 | Per Hedbor | | #if !constant( callablep )
add_constant( "callablep",
lambda(mixed f){return functionp(f)||programp(f);});
#endif
|
a4031a | 1997-09-17 | Henrik Grubbström (Grubba) | | add_constant("cd", restricted_cd());
|
c348db | 2003-09-15 | Martin Stjernholm | | add_constant ("exit", trace_exit);
|
139f4c | 1998-03-23 | Henrik Grubbström (Grubba) | | #ifdef TRACE_DESTRUCT
add_constant("destruct", trace_destruct);
#endif /* TRACE_DESTRUCT */
|
c79b26 | 1998-02-05 | Johan Schön | | #if !constant(getppid)
add_constant("getppid", getppid);
#endif
#if !constant(getuid)
add_constant("getuid", getuid);
add_constant("getgid", getgid);
#endif
#if !constant(gethostname)
add_constant("gethostname", lambda() { return "localhost"; });
#endif
|
1c98e2 | 1999-10-11 | Martin Stjernholm | |
#ifndef OLD_PARSE_HTML
add_constant("parse_html", parse_html);
add_constant("parse_html_lines", parse_html_lines);
#endif
|
58a643 | 1999-12-20 | Martin Nilsson | |
|
57a7e6 | 2018-09-12 | Henrik Grubbström (Grubba) | | #if constant(DefaultCompilerEnvironment)
#if (__REAL_MAJOR__ == 8) && (__REAL_MINOR__ == 0) && (__REAL_BUILD__ < 694)
add_constant("_disable_threads", _disable_threads);
#endif
#endif
|
8bb2c7 | 2019-02-15 | Henrik Grubbström (Grubba) | | add_constant("Concurrent", RoxenConcurrent());
|
d252c4 | 2019-02-18 | Henrik Grubbström (Grubba) | | add_constant("PikeConcurrent", Concurrent);
|
8bb2c7 | 2019-02-15 | Henrik Grubbström (Grubba) | |
|
50b697 | 2001-08-31 | Per Hedbor | | DC( "Roxen" );
|
f0e0e6 | 1998-03-20 | Per Hedbor | | roxen = really_load_roxen();
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
1c98e2 | 1999-10-11 | Martin Stjernholm | |
#ifndef OLD_PARSE_HTML
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected int|string|array(string) compat_call_tag (
|
624dae | 2000-01-21 | Martin Stjernholm | | Parser.HTML p, string str, mixed... extra)
{
string name = lower_case (p->tag_name());
if (string|function tag = p->m_tags[name])
|
20bcc7 | 2000-03-13 | Martin Nilsson | | if (stringp (tag)) return ({[string]tag});
else return ([function(string,mapping,mixed...:string|array(string))]tag) (name, p->tag_args(), @extra);
|
624dae | 2000-01-21 | Martin Stjernholm | | else if (string|function container = p->m_containers[name])
p->add_container (name, compat_call_container);
return 1;
}
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected int|string|array(string) compat_call_container (
|
624dae | 2000-01-21 | Martin Stjernholm | | Parser.HTML p, mapping(string:string) args, string content, mixed... extra)
{
string name = lower_case (p->tag_name());
if (string|function container = p->m_containers[name])
|
6d6bc8 | 2001-06-24 | Martin Nilsson | | if (stringp (container)) return ({[string]container});
|
624dae | 2000-01-21 | Martin Stjernholm | | else return container (name, args, content, @extra);
else
p->add_container (name, 0);
return 1;
}
|
992083 | 1999-12-07 | Martin Stjernholm | | class ParseHtmlCompat
|
983610 | 1999-11-23 | Per Hedbor | | {
|
992083 | 1999-12-07 | Martin Stjernholm | | inherit Parser.HTML;
|
983610 | 1999-11-23 | Per Hedbor | |
|
992083 | 1999-12-07 | Martin Stjernholm | | mapping(string:string|function) m_tags, m_containers;
|
983610 | 1999-11-23 | Per Hedbor | |
|
992083 | 1999-12-07 | Martin Stjernholm | | void create (mapping(string:string|function) tags,
mapping(string:string|function) containers,
mixed... extra)
|
983610 | 1999-11-23 | Per Hedbor | | {
|
992083 | 1999-12-07 | Martin Stjernholm | | m_tags = tags;
m_containers = containers;
add_containers (mkmapping (indices (m_containers),
|
624dae | 2000-01-21 | Martin Stjernholm | | ({compat_call_container}) * sizeof (m_containers)));
_set_tag_callback (compat_call_tag);
|
992083 | 1999-12-07 | Martin Stjernholm | | set_extra (@extra);
|
b215db | 1999-12-13 | Martin Stjernholm | | case_insensitive_tag (1);
|
992083 | 1999-12-07 | Martin Stjernholm | | lazy_entity_end (1);
|
b215db | 1999-12-13 | Martin Stjernholm | | match_tag (0);
ignore_unknown (1);
|
983610 | 1999-11-23 | Per Hedbor | | }
}
|
6d6bc8 | 2001-06-24 | Martin Nilsson | | string parse_html (string data, mapping(string:function|string) tags,
mapping(string:function|string) containers,
|
992083 | 1999-12-07 | Martin Stjernholm | | mixed... args)
|
983610 | 1999-11-23 | Per Hedbor | | {
|
992083 | 1999-12-07 | Martin Stjernholm | | return ParseHtmlCompat (tags, containers, @args)->finish (data)->read();
|
983610 | 1999-11-23 | Per Hedbor | | }
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected int|string|array(string) compat_call_tag_lines (
|
624dae | 2000-01-21 | Martin Stjernholm | | Parser.HTML p, string str, mixed... extra)
{
string name = lower_case (p->tag_name());
if (string|function tag = p->m_tags[name])
if (stringp (tag)) return ({tag});
else return tag (name, p->tag_args(), p->at_line(), @extra);
else if (string|function container = p->m_containers[name])
p->add_container (name, compat_call_container_lines);
return 1;
}
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected int|string|array(string) compat_call_container_lines (
|
624dae | 2000-01-21 | Martin Stjernholm | | Parser.HTML p, mapping(string:string) args, string content, mixed... extra)
{
string name = lower_case (p->tag_name());
if (string|function container = p->m_containers[name])
|
6d6bc8 | 2001-06-24 | Martin Nilsson | | if (stringp (container)) return ({[string]container});
|
624dae | 2000-01-21 | Martin Stjernholm | | else return container (name, args, content, p->at_line(), @extra);
else
p->add_container (name, 0);
return 1;
}
|
992083 | 1999-12-07 | Martin Stjernholm | | class ParseHtmlLinesCompat
|
983610 | 1999-11-23 | Per Hedbor | | {
|
624dae | 2000-01-21 | Martin Stjernholm | | inherit Parser.HTML;
|
983610 | 1999-11-23 | Per Hedbor | |
|
624dae | 2000-01-21 | Martin Stjernholm | | mapping(string:string|function) m_tags, m_containers;
|
992083 | 1999-12-07 | Martin Stjernholm | |
|
624dae | 2000-01-21 | Martin Stjernholm | | void create (mapping(string:string|function) tags,
mapping(string:string|function) containers,
mixed... extra)
|
983610 | 1999-11-23 | Per Hedbor | | {
|
624dae | 2000-01-21 | Martin Stjernholm | | m_tags = tags;
m_containers = containers;
add_containers (mkmapping (indices (m_containers),
({compat_call_container_lines}) * sizeof (m_containers)));
_set_tag_callback (compat_call_tag_lines);
set_extra (@extra);
case_insensitive_tag (1);
lazy_entity_end (1);
match_tag (0);
ignore_unknown (1);
|
983610 | 1999-11-23 | Per Hedbor | | }
}
|
1c98e2 | 1999-10-11 | Martin Stjernholm | | string parse_html_lines (string data, mapping tags, mapping containers,
mixed... args)
{
|
992083 | 1999-12-07 | Martin Stjernholm | | return ParseHtmlLinesCompat (tags, containers, @args)->finish (data)->read();
|
1c98e2 | 1999-10-11 | Martin Stjernholm | | }
#endif
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected local mapping fd_marks = ([]);
|
19924b | 2001-08-24 | Martin Nilsson | |
|
9eeb5c | 2000-05-22 | Per Hedbor | | mixed mark_fd( int fd, string|void with )
{
if(!with)
return fd_marks[ fd ];
fd_marks[fd] = with;
}
|
1c98e2 | 1999-10-11 | Martin Stjernholm | |
|
09ff05 | 1998-10-03 | Henrik Grubbström (Grubba) | |
|
323569 | 1998-03-26 | Per Hedbor | | #ifdef FD_DEBUG
|
5640d2 | 1998-03-26 | Per Hedbor | | class mf
{
inherit Stdio.File;
|
40a83a | 2004-08-18 | Henrik Grubbström (Grubba) | | mixed open(string what, string mode, int|void perm)
|
5640d2 | 1998-03-26 | Per Hedbor | | {
int res;
|
40a83a | 2004-08-18 | Henrik Grubbström (Grubba) | | res = ::open(what, mode, perm||0666);
|
5640d2 | 1998-03-26 | Per Hedbor | | if(res)
{
|
6a7878 | 2003-10-20 | Martin Stjernholm | | array bt = backtrace();
string file = bt[-2][0];
int line = bt[-2][1];
|
40a83a | 2004-08-18 | Henrik Grubbström (Grubba) | | mark_fd(query_fd(),
sprintf("%s:%d open(%O, %O, 0%03o)",
|
4c0a7e | 2004-08-18 | Henrik Grubbström (Grubba) | | file, line, what, mode, perm||0666));
|
5640d2 | 1998-03-26 | Per Hedbor | | }
return res;
}
void destroy()
{
catch { mark_fd(query_fd(),"CLOSED"); };
|
58a643 | 1999-12-20 | Martin Nilsson | | }
|
5640d2 | 1998-03-26 | Per Hedbor | |
int close(string|void what)
{
destroy();
|
112a25 | 1998-07-17 | Henrik Grubbström (Grubba) | | if (what) {
return ::close(what);
}
return ::close();
|
5640d2 | 1998-03-26 | Per Hedbor | | }
}
#else
constant mf = Stdio.File;
#endif
|
e30cf4 | 2000-03-13 | Per Hedbor | | #include "../etc/include/version.h"
|
6aec6f | 2002-03-15 | Henrik Grubbström (Grubba) | |
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected string release;
protected string dist_version;
|
88edde | 2009-04-20 | Jonas Wallden | | protected string dist_os;
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected int roxen_is_cms;
protected string roxen_product_name;
|
a01b5d | 2013-08-19 | Tobias Liin | | protected string roxen_product_code;
|
6aec6f | 2002-03-15 | Henrik Grubbström (Grubba) | |
|
dd4389 | 2014-09-05 | Henrik Grubbström (Grubba) | | protected string mysql_product_name;
protected string mysql_version;
protected constant mysql_good_versions = ({ "5.5.*", "5.6.*" });
|
d8b81f | 2018-07-06 | Henrik Grubbström (Grubba) | | protected constant mariadb_good_versions = ({ "5.5.*", "10.0.*", "10.1.*", "10.3.*" });
|
dd4389 | 2014-09-05 | Henrik Grubbström (Grubba) | | protected constant mysql_maybe_versions = ({ "5.*", "6.*" });
|
d4a26d | 2016-03-11 | Henrik Grubbström (Grubba) | | protected constant mariadb_maybe_versions = ({ "5.*", "10.*", "11.*" });
|
63c145 | 2018-07-06 | Henrik Grubbström (Grubba) | | protected constant mysql_bad_versions = ({});
protected constant mariadb_bad_versions = ({ "10.2.*" });
|
dd4389 | 2014-09-05 | Henrik Grubbström (Grubba) | |
|
e30cf4 | 2000-03-13 | Per Hedbor | | string roxen_version()
|
19924b | 2001-08-24 | Martin Nilsson | |
|
e30cf4 | 2000-03-13 | Per Hedbor | | {
|
6aec6f | 2002-03-15 | Henrik Grubbström (Grubba) | |
|
bb1fc4 | 2008-06-24 | Martin Stjernholm | | return roxen_ver+"."+roxen_build+(release||roxen_release);
|
e30cf4 | 2000-03-13 | Per Hedbor | | }
|
19924b | 2001-08-24 | Martin Nilsson | |
|
cefd17 | 2011-12-27 | Martin Stjernholm | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|
2cc28b | 2010-01-13 | Jonas Wallden | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|
2cc28b | 2010-01-13 | Jonas Wallden | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|
ae7fb4 | 2006-09-11 | Marcus Wellhardh | |
|
2cc28b | 2010-01-13 | Jonas Wallden | |
|
ae7fb4 | 2006-09-11 | Marcus Wellhardh | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|
2cc28b | 2010-01-13 | Jonas Wallden | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|
2cc28b | 2010-01-13 | Jonas Wallden | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|
e30cf4 | 2000-03-13 | Per Hedbor | | string roxen_path( string filename )
{
|
2cc28b | 2010-01-13 | Jonas Wallden | | filename = replace( filename,
({"$VVARDIR","$LOCALDIR","$LOGFILE","$SERVERDIR"}),
|
4f862f | 2000-03-21 | Martin Nilsson | | ({"$VARDIR/"+roxen_version(),
|
ae7fb4 | 2006-09-11 | Marcus Wellhardh | | getenv ("LOCALDIR") || "../local",
|
2cc28b | 2010-01-13 | Jonas Wallden | | getenv ("LOGFILE") || "$LOGDIR/debug/default.1",
|
cefd17 | 2011-12-27 | Martin Stjernholm | | server_dir }) );
|
7ba70c | 2000-07-09 | Per Hedbor | | if( roxen )
filename = replace( filename,
"$LOGDIR",
[string]roxen->query("logdirprefix") );
|
e30cf4 | 2000-03-13 | Per Hedbor | | else
if( search( filename, "$LOGDIR" ) != -1 )
roxen_perror("Warning: mkdirhier with $LOGDIR before variable is available\n");
|
250a84 | 2000-06-23 | Martin Stjernholm | | filename = replace( filename, "$VARDIR", getenv ("VARDIR") || "../var" );
|
5ddb29 | 2000-08-22 | Per Hedbor | | #ifdef __NT__
while( strlen(filename) && filename[-1] == '/' )
filename = filename[..strlen(filename)-2];
#endif
|
e30cf4 | 2000-03-13 | Per Hedbor | | return filename;
}
int rm( string filename )
{
return predef::rm( roxen_path(filename) );
}
array(string) r_get_dir( string path )
|
2d3cd8 | 2011-12-28 | Martin Stjernholm | |
|
e30cf4 | 2000-03-13 | Per Hedbor | | {
return predef::get_dir( roxen_path( path ) );
}
int mv( string f1, string f2 )
{
return predef::mv( roxen_path(f1), roxen_path( f2 ) );
}
|
2d3cd8 | 2011-12-28 | Martin Stjernholm | | int r_cp( string f1, string f2 )
{
return Stdio.cp( roxen_path(f1), roxen_path( f2 ) );
}
|
7e9b45 | 2001-01-14 | Per Hedbor | | Stdio.Stat file_stat( string filename, int|void slinks )
|
e30cf4 | 2000-03-13 | Per Hedbor | | {
|
b883a7 | 2000-10-17 | Martin Nilsson | | return predef::file_stat( roxen_path(filename), slinks );
|
e30cf4 | 2000-03-13 | Per Hedbor | | }
|
2d3cd8 | 2011-12-28 | Martin Stjernholm | |
int r_is_file (string path)
{
return Stdio.is_file (roxen_path (path));
}
int r_is_dir (string path)
{
return Stdio.is_dir (roxen_path (path));
}
int r_is_link (string path)
{
return Stdio.is_link (roxen_path (path));
}
int r_exist (string path)
{
return Stdio.exist (roxen_path (path));
}
string r_read_bytes (string filename, mixed... args)
{
return Stdio.read_bytes (roxen_path (filename), @args);
}
|
19924b | 2001-08-24 | Martin Nilsson | |
|
45e01b | 2011-12-28 | Martin Stjernholm | |
|
850eda | 1997-09-06 | Henrik Grubbström (Grubba) | | object|void open(string filename, string mode, int|void perm)
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
8ad929 | 2000-03-13 | Martin Nilsson | | #ifdef FD_DEBUG
mf o;
#else
Stdio.File o;
#endif
|
5640d2 | 1998-03-26 | Per Hedbor | | o=mf();
|
e30cf4 | 2000-03-13 | Per Hedbor | | filename = roxen_path( filename );
|
860358 | 1997-09-19 | Henrik Grubbström (Grubba) | | if(!(o->open(filename, mode, perm||0666))) {
|
2bfae4 | 1997-12-04 | Henrik Grubbström (Grubba) | |
if ((< 11, 12, 23, 24, 35 >)[o->errno()]) {
gc();
if(!(o->open(filename, mode, perm||0666))) {
destruct(o);
return;
}
|
002505 | 1997-12-04 | Henrik Grubbström (Grubba) | | } else {
|
2e0899 | 1997-12-04 | Henrik Grubbström (Grubba) | | destruct(o);
|
002505 | 1997-12-04 | Henrik Grubbström (Grubba) | | return;
|
860358 | 1997-09-19 | Henrik Grubbström (Grubba) | | }
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
7ed102 | 1998-01-28 | Henrik Grubbström (Grubba) | |
|
860358 | 1997-09-19 | Henrik Grubbström (Grubba) | | return o;
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | | array(string) default_roxen_font_path =
({ "nfonts/",
#ifdef __NT__
combine_path(replace(getenv("SystemRoot"), "\\", "/"), "fonts/")
#else
@((getenv("RX_FONTPATH") || "")/"," - ({""}))
#endif
});
|
3c55fe | 2013-11-26 | Anders Johansson | | array(string) package_module_path = ({ });
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | |
array(string) package_directories = ({ });
void add_package(string package_dir)
{
|
45e01b | 2011-12-28 | Martin Stjernholm | | string ver = r_read_bytes(combine_path(package_dir, "VERSION"));
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | | if (ver && (ver != "")) {
|
01d660 | 2012-01-03 | Martin Stjernholm | | report_debug("Adding package %s (Version %s).\n",
roxen_path (package_dir), ver - "\n");
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | | } else {
|
01d660 | 2012-01-03 | Martin Stjernholm | | report_debug("Adding package %s.\n",
roxen_path (package_dir));
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | | }
|
d83377 | 2015-07-03 | Henrik Grubbström (Grubba) | | package_directories += ({ package_dir });
|
033aab | 2022-08-18 | Henrik Grubbström (Grubba) | | string real_pkg_dir = lfile_path(package_dir);
|
45e01b | 2011-12-28 | Martin Stjernholm | | string sub_dir = combine_path(real_pkg_dir, "pike-modules");
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | | if (Stdio.is_dir(sub_dir)) {
|
033aab | 2022-08-18 | Henrik Grubbström (Grubba) | | REPORT_DEBUG(" Pike modules: %O\n", sub_dir);
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | | master()->add_module_path(sub_dir);
}
|
45e01b | 2011-12-28 | Martin Stjernholm | | if (Stdio.is_dir(sub_dir = combine_path(real_pkg_dir, "include/"))) {
|
033aab | 2022-08-18 | Henrik Grubbström (Grubba) | | REPORT_DEBUG(" Pike includes: %O\n", sub_dir);
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | | master()->add_include_path(sub_dir);
}
|
d58802 | 2018-05-02 | Karl Gustav Sterneberg | | #ifdef RUN_SELF_TEST
sub_dir = combine_path(real_pkg_dir, "test/pike-modules");
if (Stdio.is_dir(sub_dir)) {
|
033aab | 2022-08-18 | Henrik Grubbström (Grubba) | | REPORT_DEBUG(" Pike modules: %O\n", sub_dir);
|
d58802 | 2018-05-02 | Karl Gustav Sterneberg | | master()->add_module_path(sub_dir);
}
if (Stdio.is_dir(sub_dir = combine_path(real_pkg_dir, "test/include/"))) {
|
033aab | 2022-08-18 | Henrik Grubbström (Grubba) | | REPORT_DEBUG(" Pike includes: %O\n", sub_dir);
|
d58802 | 2018-05-02 | Karl Gustav Sterneberg | | master()->add_include_path(sub_dir);
}
#endif
|
45e01b | 2011-12-28 | Martin Stjernholm | |
|
033aab | 2022-08-18 | Henrik Grubbström (Grubba) | | if (Stdio.is_dir(sub_dir = combine_path(real_pkg_dir, "roxen-modules/"))) {
REPORT_DEBUG(" Roxen modules: %O\n", sub_dir);
package_module_path += ({ sub_dir });
} else {
sub_dir = combine_path(real_pkg_dir, "modules/");
REPORT_DEBUG(" Roxen modules: %O\n", sub_dir);
|
820c70 | 2015-07-07 | Henrik Grubbström (Grubba) | | package_module_path += ({ sub_dir });
|
56c5cd | 2009-03-27 | Henrik Grubbström (Grubba) | | }
|
033aab | 2022-08-18 | Henrik Grubbström (Grubba) | | if (Stdio.is_dir(sub_dir = combine_path(real_pkg_dir, "fonts/"))) {
REPORT_DEBUG(" Fonts: %O\n", sub_dir);
|
d83377 | 2015-07-03 | Henrik Grubbström (Grubba) | | default_roxen_font_path += ({ sub_dir });
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | | }
|
737256 | 2018-02-27 | Karl Gustav Sterneberg | | #ifdef RUN_SELF_TEST
|
033aab | 2022-08-18 | Henrik Grubbström (Grubba) | | if (Stdio.is_dir(sub_dir = combine_path(real_pkg_dir, "test/roxen-modules/"))) {
REPORT_DEBUG(" Roxen modules: %O\n", sub_dir);
package_module_path += ({ sub_dir });
} else if (Stdio.is_dir(sub_dir = combine_path(real_pkg_dir, "test/modules/"))) {
REPORT_DEBUG(" Roxen modules: %O\n", sub_dir);
|
737256 | 2018-02-27 | Karl Gustav Sterneberg | | package_module_path += ({ sub_dir });
}
#endif
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | | }
|
19924b | 2001-08-24 | Martin Nilsson | |
|
e30cf4 | 2000-03-13 | Per Hedbor | | object|void lopen(string filename, string mode, int|void perm)
{
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | | if( filename[0] != '/' ) {
foreach(package_directories, string dir) {
Stdio.File o;
|
ad9ac2 | 2015-07-03 | Henrik Grubbström (Grubba) | | if (o = open(combine_path(roxen_path(dir), filename), mode, perm))
return o;
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | | }
}
|
033aab | 2022-08-18 | Henrik Grubbström (Grubba) | | return open( roxen_path(filename), mode, perm );
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | | }
object(Stdio.Stat) lfile_stat(string filename)
{
if (filename[0] != '/') {
foreach(package_directories, string dir) {
Stdio.Stat res;
|
ad9ac2 | 2015-07-03 | Henrik Grubbström (Grubba) | | if (res = file_stat(combine_path(roxen_path(dir), filename)))
return res;
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | | }
}
|
033aab | 2022-08-18 | Henrik Grubbström (Grubba) | | return file_stat(roxen_path(filename));
|
e30cf4 | 2000-03-13 | Per Hedbor | | }
|
adbc52 | 2011-01-20 | Henrik Grubbström (Grubba) | |
string lfile_path(string filename)
{
if (filename[0] != '/') {
foreach(package_directories, string dir) {
|
ad9ac2 | 2015-07-03 | Henrik Grubbström (Grubba) | | string path = combine_path(roxen_path(dir), filename);
|
adbc52 | 2011-01-20 | Henrik Grubbström (Grubba) | | if (file_stat(path)) return path;
}
}
|
033aab | 2022-08-18 | Henrik Grubbström (Grubba) | | return file_stat(roxen_path(filename)) && roxen_path(filename);
|
adbc52 | 2011-01-20 | Henrik Grubbström (Grubba) | | }
|
22a835 | 2021-11-22 | Henrik Grubbström (Grubba) | | array(string) lget_dir(string path)
{
if (path[0] != '/') {
array(string) res = UNDEFINED;
foreach(package_directories, string dir) {
array(string) paths =
get_dir(combine_path(roxen_path(dir), path));
if (paths) res += paths;
}
if (res) return Array.uniq(res);
}
|
033aab | 2022-08-18 | Henrik Grubbström (Grubba) | | return get_dir(roxen_path(path));
|
22a835 | 2021-11-22 | Henrik Grubbström (Grubba) | | }
|
09ff05 | 1998-10-03 | Henrik Grubbström (Grubba) | |
|
1e3d62 | 1997-02-18 | Niels Möller | | string make_path(string ... from)
|
d3602b | 1997-02-18 | Per Hedbor | | {
|
159041 | 2000-02-16 | Per Hedbor | | return map(from, lambda(string a, string b) {
|
2a9898 | 1997-04-19 | Henrik Grubbström (Grubba) | | return (a[0]=='/')?combine_path("/",a):combine_path(b,a);
|
cefd17 | 2011-12-27 | Martin Stjernholm | | }, server_dir)*":";
|
d3602b | 1997-02-18 | Per Hedbor | | }
|
f68582 | 1997-09-19 | Henrik Grubbström (Grubba) | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|
22c98c | 2001-08-13 | Per Hedbor | | string isodate( int t )
{
mapping lt = localtime(t);
return sprintf( "%d-%02d-%02d", lt->year+1900, lt->mon+1, lt->mday );
}
|
509709 | 1999-08-06 | Per Hedbor | | void write_current_time()
{
|
27942e | 1999-09-02 | Per Hedbor | | if( !roxen )
{
call_out( write_current_time, 10 );
return;
}
|
9a002e | 2000-04-19 | Martin Nilsson | | int t = time(1);
|
8ad929 | 2000-03-13 | Martin Nilsson | | mapping lt = localtime(t);
report_debug("\n** "+sprintf("%02d-%02d-%02d %02d:%02d", lt->year+1900,
lt->mon+1, lt->mday, lt->hour, lt->min)+
|
58a643 | 1999-12-20 | Martin Nilsson | | " pid: "+pid+" ppid: "+getppid()+
|
d4a3f5 | 2014-05-12 | Henrik Grubbström (Grubba) | | #if constant(geteuid)
|
26d796 | 1999-09-25 | Martin Stjernholm | | (geteuid()!=getuid()?" euid: "+pw_name(geteuid()):"")+
#endif
|
58a643 | 1999-12-20 | Martin Nilsson | | " uid: "+pw_name(getuid())+"\n\n");
|
26d796 | 1999-09-25 | Martin Stjernholm | | call_out( write_current_time, 3600 - t % 3600 );
|
509709 | 1999-08-06 | Per Hedbor | | }
|
19924b | 2001-08-24 | Martin Nilsson | |
|
f6ab4a | 2003-01-22 | Henrik Grubbström (Grubba) | |
|
4446d8 | 1999-12-07 | Henrik Grubbström (Grubba) | | void paranoia_throw(mixed err)
{
|
20bcc7 | 2000-03-13 | Martin Nilsson | | if ((arrayp(err) && ((sizeof([array]err) < 2) || !stringp(([array]err)[0]) ||
!arrayp(([array]err)[1]) ||
!(arrayp(([array(array)]err)[1][0])||stringp(([array(array)]err)[1][0])))) ||
(!arrayp(err) && (!objectp(err) || !([object]err)->is_generic_error))) {
|
58a643 | 1999-12-20 | Martin Nilsson | | report_debug(sprintf("Warning: throwing non-error: %O\n"
|
4446d8 | 1999-12-07 | Henrik Grubbström (Grubba) | | "From: %s\n",
err, describe_backtrace(backtrace())));
}
throw(err);
}
|
09ff05 | 1998-10-03 | Henrik Grubbström (Grubba) | |
|
af81b3 | 2000-02-15 | Henrik Grubbström (Grubba) | | int main(int argc, array(string) argv)
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
dd9049 | 2002-01-18 | Martin Nilsson | | Protocols.HTTP;
|
02344e | 2001-06-24 | Per Hedbor | |
|
c74511 | 2014-10-21 | Henrik Grubbström (Grubba) | | #if __VERSION__ < 8.0
|
02344e | 2001-06-24 | Per Hedbor | | report_debug(
#"
------- FATAL -------------------------------------------------
|
c74511 | 2014-10-21 | Henrik Grubbström (Grubba) | | Roxen 6.0 should be run with Pike 8.0 or newer.
|
02344e | 2001-06-24 | Per Hedbor | | ---------------------------------------------------------------
");
|
32d1a0 | 2005-03-10 | Henrik Grubbström (Grubba) | | exit(1);
|
9a86b6 | 2001-06-12 | Per Hedbor | | #endif
|
0716b7 | 2001-06-11 | Per Hedbor | |
|
ebd050 | 2018-05-14 | Henrik Grubbström (Grubba) | | #if !constant(utf8_string)
add_constant("utf8_string", utf8_string);
#endif
|
32d1a0 | 2005-03-10 | Henrik Grubbström (Grubba) | |
|
095253 | 2009-02-12 | Martin Stjernholm | | if (mixed err = catch {
|
67f9f9 | 2005-03-10 | Henrik Grubbström (Grubba) | |
|
8a1956 | 2006-05-31 | Henrik Grubbström (Grubba) | |
|
095253 | 2009-02-12 | Martin Stjernholm | | string interface;
|
8a1956 | 2006-05-31 | Henrik Grubbström (Grubba) | | Stdio.Port p = Stdio.Port();
|
095253 | 2009-02-12 | Martin Stjernholm | | if (p->bind(0, 0, interface = "::1") &&
p->bind(0, 0, interface = "::")) {
|
8a1956 | 2006-05-31 | Henrik Grubbström (Grubba) | | add_constant("__ROXEN_SUPPORTS_IPV6__", 1);
report_debug("Support for IPv6 enabled.\n");
}
|
095253 | 2009-02-12 | Martin Stjernholm | | else
report_debug ("IPv6 support check failed: Could not bind %s: %s\n",
interface, strerror (p->errno()));
|
5b2370 | 2006-05-31 | Henrik Grubbström (Grubba) | | destruct(p);
|
095253 | 2009-02-12 | Martin Stjernholm | | })
report_debug ("IPv6 support check failed: %s",
#ifdef DEBUG
describe_backtrace (err)
#else
describe_error (err)
#endif
);
|
32d1a0 | 2005-03-10 | Henrik Grubbström (Grubba) | |
|
c5b491 | 2000-12-30 | Martin Nilsson | |
|
baa9d5 | 2001-01-27 | Per Hedbor | | array av = copy_value( argv );
|
74e390 | 2000-12-30 | Per Hedbor | | configuration_dir =
|
baa9d5 | 2001-01-27 | Per Hedbor | | Getopt.find_option(av, "d",({"config-dir","configuration-directory" }),
|
74e390 | 2000-12-30 | Per Hedbor | | ({ "ROXEN_CONFIGDIR", "CONFIGURATIONS" }), "../configurations");
|
baa9d5 | 2001-01-27 | Per Hedbor | |
|
74e390 | 2000-12-30 | Per Hedbor | | remove_dumped =
|
92d202 | 2001-08-14 | Henrik Grubbström (Grubba) | | Getopt.find_option(av, "remove-dumped",({"remove-dumped", }), 0 );
|
74e390 | 2000-12-30 | Per Hedbor | |
|
baa9d5 | 2001-01-27 | Per Hedbor | | if( configuration_dir[-1] != '/' ) configuration_dir+="/";
|
6aec6f | 2002-03-15 | Henrik Grubbström (Grubba) | |
if (release = Stdio.read_bytes("RELEASE")) {
release = (replace(release, "\r", "\n")/"\n")[0];
}
|
baa9d5 | 2001-01-27 | Per Hedbor | |
|
5a272a | 2002-05-07 | Jonas Wallden | |
if (dist_version = Stdio.read_bytes("VERSION.DIST"))
dist_version = (replace(dist_version, "\r", "\n") / "\n")[0];
else
|
03f911 | 2002-10-28 | Jonas Wallden | | dist_version = roxen_version();
|
5a272a | 2002-05-07 | Jonas Wallden | |
|
88edde | 2009-04-20 | Jonas Wallden | |
|
fa6442 | 2009-04-30 | Jonas Wallden | | dist_os =
(replace(Stdio.read_bytes("OS") || "src dist", "\r", "\n") / "\n")[0];
|
88edde | 2009-04-20 | Jonas Wallden | |
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | |
|
45e01b | 2011-12-28 | Martin Stjernholm | | add_package("$LOCALDIR");
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | | foreach(package_directories + ({ "." }), string dir) {
dir = combine_path(dir, "packages");
|
6c086f | 2015-03-29 | Henrik Grubbström (Grubba) | | foreach(sort(get_dir(roxen_path(dir)) || ({})), string fname) {
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | | if (fname == "CVS") continue;
fname = combine_path(dir, fname);
|
6c086f | 2015-03-29 | Henrik Grubbström (Grubba) | | if (Stdio.is_dir(roxen_path(fname))) {
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | | add_package(fname);
}
}
}
|
ae395c | 2022-08-16 | Henrik Grubbström (Grubba) | | string dir;
|
436217 | 2022-08-16 | Henrik Grubbström (Grubba) | | while (stringp(dir = Getopt.find_option(av, ({}), ({ "package" }),
|
ae395c | 2022-08-16 | Henrik Grubbström (Grubba) | | UNDEFINED, 1))) {
add_package(dir);
}
|
0dc6f8 | 2022-08-16 | Henrik Grubbström (Grubba) | | #ifdef RUN_SELF_TEST
|
b639a5 | 2022-08-16 | Henrik Grubbström (Grubba) | | foreach(lget_dir("customers") || ({}), string dir) {
|
0dc6f8 | 2022-08-16 | Henrik Grubbström (Grubba) | | dir = combine_path("customers", dir);
if (Stdio.is_dir(roxen_path(dir))) {
add_package(dir);
}
}
#endif
|
56abfd | 2013-03-21 | Henrik Grubbström (Grubba) | | roxen_is_cms = !!lfile_stat("modules/sitebuilder") ||
!!lfile_stat("packages/sitebuilder");
|
cdddcb | 2002-04-08 | Johan Schön | |
|
56abfd | 2013-03-21 | Henrik Grubbström (Grubba) | | if(roxen_is_cms) {
if (lfile_stat("modules/print") || lfile_stat("packages/print")) {
roxen_product_name="Roxen EP";
|
a01b5d | 2013-08-19 | Tobias Liin | | roxen_product_code = "rep";
|
56abfd | 2013-03-21 | Henrik Grubbström (Grubba) | | } else {
roxen_product_name="Roxen CMS";
|
a01b5d | 2013-08-19 | Tobias Liin | | roxen_product_code = "cms";
|
56abfd | 2013-03-21 | Henrik Grubbström (Grubba) | | }
} else {
|
cdddcb | 2002-04-08 | Johan Schön | | roxen_product_name="Roxen WebServer";
|
a01b5d | 2013-08-19 | Tobias Liin | | roxen_product_code = "webserver";
|
56abfd | 2013-03-21 | Henrik Grubbström (Grubba) | | }
|
cdddcb | 2002-04-08 | Johan Schön | |
|
62290c | 2011-09-12 | Henrik Grubbström (Grubba) | | #if defined(ROXEN_USE_FORKD) && constant(Process.set_forkd_default)
report_debug("Enabling use of forkd daemon.\n");
Process.set_forkd_default(1);
#endif
|
baa9d5 | 2001-01-27 | Per Hedbor | |
string defpath =
|
bedb02 | 2001-02-02 | Tomas Nilsson | | #ifdef __NT__
|
a1d2e5 | 2001-11-15 | Tomas Nilsson | |
|
83c5b7 | 2013-02-18 | Henrik Grubbström (Grubba) | | "mysql://%user%@.:" + query_mysql_socket() + "/%db%";
|
bedb02 | 2001-02-02 | Tomas Nilsson | | #else
|
83c5b7 | 2013-02-18 | Henrik Grubbström (Grubba) | | "mysql://%user%@localhost:" + query_mysql_socket() + "/%db%";
|
bedb02 | 2001-02-02 | Tomas Nilsson | | #endif
|
baa9d5 | 2001-01-27 | Per Hedbor | | my_mysql_path =
Getopt.find_option(av, "m",({"mysql-url", }), 0,defpath);
if( my_mysql_path != defpath )
{
werror(
" : ----------------------------------------------------------\n"
|
8a79f8 | 2003-02-05 | Jonas Wallden | | "Notice: Not using the built-in MySQL\n"
"MySQL path is "+my_mysql_path+"\n"
|
baa9d5 | 2001-01-27 | Per Hedbor | | );
mysql_path_is_remote = 1;
}
|
5574b2 | 2002-05-06 | Martin Stjernholm | |
|
ef52c1 | 2018-04-24 | Karl Gustav Sterneberg | | #if constant(MIME.set_boundary_prefix)
string boundary_prefix = Standards.UUID.make_version4()->str();
boundary_prefix = (boundary_prefix / "-") * "";
MIME.set_boundary_prefix(boundary_prefix);
#endif
|
74e390 | 2000-12-30 | Per Hedbor | | nwrite = lambda(mixed ... ){};
|
af81b3 | 2000-02-15 | Henrik Grubbström (Grubba) | | call_out( do_main_wrapper, 0, argc, argv );
|
87d06d | 2000-02-09 | Per Hedbor | |
return -1;
}
|
af81b3 | 2000-02-15 | Henrik Grubbström (Grubba) | |
void do_main_wrapper(int argc, array(string) argv)
{
mixed err = catch {
do_main(argc, argv);
return;
};
catch {
if (err) {
|
e7c2d4 | 2000-04-03 | Per Hedbor | | werror(sprintf("Roxen loader failed:\n"
"%s\n", describe_backtrace(err)));
|
af81b3 | 2000-02-15 | Henrik Grubbström (Grubba) | | }
};
|
c348db | 2003-09-15 | Martin Stjernholm | | trace_exit(1);
|
af81b3 | 2000-02-15 | Henrik Grubbström (Grubba) | | }
|
fb0716 | 2009-02-06 | Jonas Wallden | |
|
400800 | 2009-07-27 | Martin Stjernholm | | protected mapping(string:string) cached_mysql_location;
|
05cbc3 | 2013-02-15 | Henrik Grubbström (Grubba) | |
|
400800 | 2009-07-27 | Martin Stjernholm | |
mapping(string:string) mysql_location()
|
74e390 | 2000-12-30 | Per Hedbor | | {
|
400800 | 2009-07-27 | Martin Stjernholm | | if (cached_mysql_location)
return cached_mysql_location;
|
7dfd2e | 2009-02-06 | Jonas Wallden | | string check_paths(array(string) paths)
{
foreach(paths, string p)
if (file_stat(p))
return p;
return 0;
};
|
74aa18 | 2009-02-12 | Jonas Wallden | |
multiset(string) valid_keys =
|
05cbc3 | 2013-02-15 | Henrik Grubbström (Grubba) | | (< "basedir", "mysqld", "myisamchk", "mysqladmin", "mysqldump",
"mysql_upgrade",
>);
|
7dfd2e | 2009-02-06 | Jonas Wallden | |
|
fb0716 | 2009-02-06 | Jonas Wallden | |
|
7dfd2e | 2009-02-06 | Jonas Wallden | |
mapping res = ([ "basedir" : combine_path(server_dir, "mysql/") ]);
string mysql_loc_file = combine_path(server_dir, "mysql-location.txt");
if (string data = Stdio.read_bytes(mysql_loc_file)) {
data = replace(replace(data, "\r\n", "\n"), "\r", "\n");
foreach(data / "\n", string line) {
line = String.trim_whites((line / "#")[0]);
if (sizeof(line)) {
|
b23a63 | 2009-02-12 | Martin Stjernholm | | sscanf(line, "%[^ \t=]%*[ \t]=%*[ \t]%s", string key, string val);
|
7dfd2e | 2009-02-06 | Jonas Wallden | | if (key && val && sizeof(val)) {
key = lower_case(key);
|
74aa18 | 2009-02-12 | Jonas Wallden | | if (!valid_keys[key]) {
|
7dfd2e | 2009-02-06 | Jonas Wallden | | report_warning("mysql-location.txt: Unknown key '%s'.\n", key);
continue;
}
|
74aa18 | 2009-02-12 | Jonas Wallden | | if (val[0] == '"' || val[0] == '\'')
val = val[1..];
if (sizeof(val))
if (val[-1] == '"' || val[-1] == '\'')
val = val[..sizeof(val) - 2];
|
7dfd2e | 2009-02-06 | Jonas Wallden | | string path = combine_path(server_dir, val);
if (check_paths( ({ path }) )) {
res[key] = path;
} else {
report_warning("mysql-location.txt: "
"Ignoring non-existing path for key '%s': %s\n",
key, path);
}
}
}
}
}
if (res->basedir) {
if (!res->mysqld) {
#ifdef __NT__
string binary = "mysqld-nt.exe";
#else
string binary = "mysqld";
#endif
res->mysqld =
check_paths( ({ combine_path(res->basedir, "libexec", binary),
combine_path(res->basedir, "bin", binary),
combine_path(res->basedir, "sbin", binary) }) );
}
if (!res->myisamchk) {
#ifdef __NT__
string binary = "myisamchk.exe";
#else
string binary = "myisamchk";
#endif
res->myisamchk =
check_paths( ({ combine_path(res->basedir, "libexec", binary),
combine_path(res->basedir, "bin", binary),
combine_path(res->basedir, "sbin", binary) }) );
}
|
7ebd01 | 2009-05-13 | Henrik Grubbström (Grubba) | |
if (!res->mysqldump) {
#ifdef __NT__
string binary = "mysqldump.exe";
#else
string binary = "mysqldump";
#endif
res->mysqldump =
check_paths( ({ combine_path(res->basedir, "libexec", binary),
combine_path(res->basedir, "bin", binary),
combine_path(res->basedir, "sbin", binary) }) );
}
|
05cbc3 | 2013-02-15 | Henrik Grubbström (Grubba) | |
if (!res->mysql_upgrade) {
#ifdef __NT__
string binary = "mysql_upgrade.exe";
#else
string binary = "mysql_upgrade";
#endif
res->mysql_upgrade =
check_paths( ({ combine_path(res->basedir, "libexec", binary),
combine_path(res->basedir, "bin", binary),
combine_path(res->basedir, "sbin", binary) }) );
}
|
7dfd2e | 2009-02-06 | Jonas Wallden | | }
|
400800 | 2009-07-27 | Martin Stjernholm | | return cached_mysql_location = res;
|
74e390 | 2000-12-30 | Per Hedbor | | }
|
400800 | 2009-07-27 | Martin Stjernholm | | mapping(string:string) parse_mysql_location()
{
return mysql_location();
}
|
fb0716 | 2009-02-06 | Jonas Wallden | |
|
cd5f54 | 2005-12-21 | Fredrik Noring | | string query_mysql_data_dir()
{
string old_dir = combine_path(getcwd(), query_configuration_dir(), "_mysql");
string new_dir, datadir = getenv("ROXEN_DATADIR");
if(datadir)
new_dir = combine_path(getcwd(), datadir, "mysql");
if(new_dir && Stdio.exist(new_dir))
return new_dir;
if(Stdio.exist(old_dir))
return old_dir;
if(new_dir)
return new_dir;
return old_dir;
}
|
83c5b7 | 2013-02-18 | Henrik Grubbström (Grubba) | | string query_mysql_socket()
{
#ifdef __NT__
return replace(combine_path(query_mysql_data_dir(), "pipe"), ":", "_");
#else
return combine_path(query_mysql_data_dir(), "socket");
#endif
}
|
eca9da | 2018-07-09 | Henrik Grubbström (Grubba) | | string query_mysql_config_file(string|void datadir)
{
datadir = datadir || query_mysql_data_dir();
return datadir + "/my.cfg";
}
|
a7c75e | 2001-02-01 | Per Hedbor | | string my_mysql_path;
|
74e390 | 2000-12-30 | Per Hedbor | |
string query_configuration_dir()
{
return configuration_dir;
}
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected mapping(string:array(SQLTimeout)) sql_free_list = ([ ]);
protected Thread.Local sql_reuse_in_thread = Thread.Local();
|
a31e39 | 2006-09-18 | Martin Stjernholm | | mapping(string:int) sql_active_list = ([ ]);
|
704582 | 2001-09-03 | Per Hedbor | |
|
a5044b | 2001-09-05 | Henrik Grubbström (Grubba) | | #ifdef DB_DEBUG
|
5d98ea | 2012-01-07 | Martin Stjernholm | | #ifdef OBJ_COUNT_DEBUG
|
a5044b | 2001-09-05 | Henrik Grubbström (Grubba) | | mapping(int:string) my_mysql_last_user = ([]);
|
5d98ea | 2012-01-07 | Martin Stjernholm | | #endif
|
1efb70 | 2006-08-16 | Henrik Grubbström (Grubba) | | multiset(Sql.Sql) all_wrapped_sql_objects = set_weak_flag( (<>), 1 );
|
1f546c | 2001-09-06 | Per Hedbor | | #endif /* DB_DEBUG */
|
abe243 | 2001-09-06 | Per Hedbor | |
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | |
void clear_connect_to_my_mysql_cache( )
{
sql_free_list = ([]);
}
|
f70bb7 | 2006-05-23 | Jonas Wallden | |
mapping(string:int) get_sql_free_list_status()
{
return map(sql_free_list, sizeof);
}
|
f2729a | 2011-05-23 | Martin Stjernholm | | #ifndef DB_CONNECTION_TIMEOUT
#define DB_CONNECTION_TIMEOUT 60
#endif
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected class SQLTimeout(protected Sql.Sql real)
|
6ab352 | 2001-11-08 | Henrik Grubbström (Grubba) | | {
|
f2729a | 2011-05-23 | Martin Stjernholm | | protected int timeout = time(1) + DB_CONNECTION_TIMEOUT;
|
6ab352 | 2001-11-08 | Henrik Grubbström (Grubba) | |
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected int(0..1) `!()
|
6ab352 | 2001-11-08 | Henrik Grubbström (Grubba) | | {
if (timeout < time(1)) {
real = 0;
}
return !real;
}
Sql.Sql get()
{
if (timeout < time(1)) {
real = 0;
}
|
8a2ce4 | 2011-08-29 | Henrik Grubbström (Grubba) | | if (timeout - time(1) < (DB_CONNECTION_TIMEOUT - 10)) {
if (real->ping()) real = 0;
} else {
if (!real->is_open()) real = 0;
}
|
6ab352 | 2001-11-08 | Henrik Grubbström (Grubba) | | Sql.Sql res = real;
real = 0;
return res;
}
}
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | |
|
f1690f | 2012-02-29 | Henrik Grubbström (Grubba) | |
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected class SQLResKey
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | | {
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected Sql.sql_result real;
protected SQLKey key;
|
8c8464 | 2005-09-23 | Martin Stjernholm | |
|
f1690f | 2012-02-29 | Henrik Grubbström (Grubba) | |
|
5d98ea | 2012-01-07 | Martin Stjernholm | | DECLARE_OBJ_COUNT;
|
f1690f | 2012-02-29 | Henrik Grubbström (Grubba) | |
|
5d98ea | 2012-01-07 | Martin Stjernholm | |
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected void create (Sql.sql_result real, SQLKey key)
|
8c8464 | 2005-09-23 | Martin Stjernholm | | {
this_program::real = real;
this_program::key = key;
}
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | |
|
8c8464 | 2005-09-23 | Martin Stjernholm | |
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected int num_rows()
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | | {
return real->num_rows();
}
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected int num_fields()
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | | {
return real->num_fields();
}
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected int eof()
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | | {
return real->eof();
}
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected array(mapping(string:mixed)) fetch_fields()
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | | {
return real->fetch_fields();
}
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected void seek(int skip)
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | | {
real->seek(skip);
}
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected int|array(string|int) fetch_row()
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | | {
return real->fetch_row();
}
|
a2e9b1 | 2014-08-15 | Henrik Grubbström (Grubba) | | protected int|string fetch_json_result()
|
74a97f | 2009-08-26 | Fredrik Noring | | {
return real->fetch_json_result();
}
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | |
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected int(0..1) `!()
|
ca7b41 | 2001-11-07 | Henrik Grubbström (Grubba) | | {
return !real;
}
|
c0a8d9 | 2011-05-23 | Martin Stjernholm | |
class _get_iterator
{
protected int|array(string|int) row = fetch_row();
protected int pos = 0;
int index()
{
return pos;
}
int|array(string|int) value()
{
return row;
}
int(0..1) next()
{
pos++;
return !!(row = fetch_row());
}
this_program `+=(int steps)
{
if(!steps) return this;
if(steps<0) error("Iterator must advance a positive number of steps.\n");
if(steps>1)
{
pos += steps-1;
seek(steps-1);
}
next();
return this;
}
int(0..1) `!()
{
return eof();
}
int _sizeof()
{
return num_fields();
}
}
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected mixed `[]( string what )
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | | {
return `->( what );
}
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected mixed `->(string what )
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | | {
switch( what )
{
|
74a97f | 2009-08-26 | Fredrik Noring | | case "real": return real;
case "num_rows": return num_rows;
case "num_fields": return num_fields;
case "eof": return eof;
case "fetch_fields": return fetch_fields;
case "seek": return seek;
case "fetch_row": return fetch_row;
|
c0a8d9 | 2011-05-23 | Martin Stjernholm | | case "_get_iterator": return _get_iterator;
|
74a97f | 2009-08-26 | Fredrik Noring | | case "fetch_json_result": return fetch_json_result;
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | | }
return real[what];
}
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected string _sprintf(int type)
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | | {
|
5d98ea | 2012-01-07 | Martin Stjernholm | | return sprintf( "SQLResKey(%O)" + OBJ_COUNT, real );
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | | }
|
94d7b0 | 2001-10-15 | Henrik Grubbström (Grubba) | |
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected void destroy()
|
94d7b0 | 2001-10-15 | Henrik Grubbström (Grubba) | | {
|
8c8464 | 2005-09-23 | Martin Stjernholm | | if (key->reuse_in_thread) {
|
39e91c | 2008-02-13 | Martin Stjernholm | |
|
8c8464 | 2005-09-23 | Martin Stjernholm | | mapping(string:Sql.Sql) dbs_for_thread = sql_reuse_in_thread->get();
if (!dbs_for_thread[key->db_name])
dbs_for_thread[key->db_name] = key->real;
}
#if 0
|
94d7b0 | 2001-10-15 | Henrik Grubbström (Grubba) | | werror("Destroying %O\n", this_object());
|
8c8464 | 2005-09-23 | Martin Stjernholm | | #endif
|
94d7b0 | 2001-10-15 | Henrik Grubbström (Grubba) | | }
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | | }
|
f1690f | 2012-02-29 | Henrik Grubbström (Grubba) | |
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected class SQLKey
|
704582 | 2001-09-03 | Per Hedbor | | {
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected Sql.Sql real;
protected string db_name;
|
f39655 | 2022-01-13 | Henrik Grubbström (Grubba) | | protected string real_db_name;
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected int reuse_in_thread;
|
abe243 | 2001-09-06 | Per Hedbor | |
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected int `!( ) { return !real; }
|
8f5705 | 2001-09-06 | Per Hedbor | |
|
036c7b | 2011-05-24 | Martin Stjernholm | | protected void handle_db_error (mixed err)
|
8f5705 | 2001-09-06 | Per Hedbor | | {
|
036c7b | 2011-05-24 | Martin Stjernholm | |
string errmsg = describe_error (err);
if (has_prefix (errmsg, "Mysql.mysql(): Couldn't connect ") ||
|
358196 | 2011-10-07 | Martin Stjernholm | | has_prefix (errmsg, "Mysql.mysql(): Couldn't reconnect ") ||
has_suffix (errmsg, "(MySQL server has gone away)\n")) {
|
8c8464 | 2005-09-23 | Martin Stjernholm | | if (reuse_in_thread) {
mapping(string:Sql.Sql) dbs_for_thread = sql_reuse_in_thread->get();
if (dbs_for_thread[db_name] == real)
m_delete (dbs_for_thread, db_name);
}
|
036c7b | 2011-05-24 | Martin Stjernholm | | real = 0;
|
8c8464 | 2005-09-23 | Martin Stjernholm | | }
|
036c7b | 2011-05-24 | Martin Stjernholm | | throw (err);
}
array(mapping) query( string f, mixed ... args )
{
mixed err = catch {
return real->query( f, @args );
};
handle_db_error (err);
}
Sql.sql_result big_query( string f, mixed ... args )
{
Sql.sql_result o;
if (mixed err = catch (o = real->big_query( f, @args )))
handle_db_error (err);
if (reuse_in_thread) {
mapping(string:Sql.Sql) dbs_for_thread = sql_reuse_in_thread->get();
if (dbs_for_thread[db_name] == real)
m_delete (dbs_for_thread, db_name);
}
return [object(Sql.sql_result)] (object) SQLResKey (o, this);
|
8f5705 | 2001-09-06 | Per Hedbor | | }
|
5d98ea | 2012-01-07 | Martin Stjernholm | |
|
f1690f | 2012-02-29 | Henrik Grubbström (Grubba) | |
|
5d98ea | 2012-01-07 | Martin Stjernholm | | DECLARE_OBJ_COUNT;
|
f1690f | 2012-02-29 | Henrik Grubbström (Grubba) | |
|
a5044b | 2001-09-05 | Henrik Grubbström (Grubba) | | #ifdef DB_DEBUG
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected string bt;
|
abe243 | 2001-09-06 | Per Hedbor | | #endif
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected void create( Sql.Sql real, string db_name, int reuse_in_thread)
|
abe243 | 2001-09-06 | Per Hedbor | | {
|
8c8464 | 2005-09-23 | Martin Stjernholm | | this_program::real = real;
this_program::db_name = db_name;
this_program::reuse_in_thread = reuse_in_thread;
if (reuse_in_thread) {
mapping(string:Sql.Sql) dbs_for_thread = sql_reuse_in_thread->get();
if (!dbs_for_thread) sql_reuse_in_thread->set (dbs_for_thread = ([]));
if (!dbs_for_thread[db_name])
dbs_for_thread[db_name] = real;
}
|
1f546c | 2001-09-06 | Per Hedbor | | #ifdef DB_DEBUG
|
1efb70 | 2006-08-16 | Henrik Grubbström (Grubba) | | if( !real )
|
5c794b | 2001-09-06 | Per Hedbor | | error("Creating SQL with empty real sql\n");
|
a5044b | 2001-09-05 | Henrik Grubbström (Grubba) | |
|
1efb70 | 2006-08-16 | Henrik Grubbström (Grubba) | | foreach( (array)all_wrapped_sql_objects, Sql.Sql sql )
|
5c794b | 2001-09-06 | Per Hedbor | | {
|
1efb70 | 2006-08-16 | Henrik Grubbström (Grubba) | | if( sql )
if( sql == real )
|
8c8464 | 2005-09-23 | Martin Stjernholm | | error("Fatal: This database connection is already used!\n");
|
1efb70 | 2006-08-16 | Henrik Grubbström (Grubba) | | else if( sql->master_sql == real->master_sql )
|
5c794b | 2001-09-06 | Per Hedbor | | error("Fatal: Internal share error: master_sql equal!\n");
}
|
a366a5 | 2001-09-06 | Per Hedbor | |
|
1efb70 | 2006-08-16 | Henrik Grubbström (Grubba) | | all_wrapped_sql_objects[real] = 1;
#if 0
|
5d98ea | 2012-01-07 | Martin Stjernholm | | #ifdef OBJ_COUNT_DEBUG
bt=(my_mysql_last_user[__object_count] = describe_backtrace(backtrace()));
#endif
|
1efb70 | 2006-08-16 | Henrik Grubbström (Grubba) | | #endif
|
abe243 | 2001-09-06 | Per Hedbor | | #endif /* DB_DEBUG */
|
558bf5 | 2022-01-11 | Henrik Grubbström (Grubba) | | real_db_name = real->master_sql->query_db && real->master_sql->query_db();
|
abe243 | 2001-09-06 | Per Hedbor | | }
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected void destroy()
|
704582 | 2001-09-03 | Per Hedbor | | {
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | |
|
1f546c | 2001-09-06 | Per Hedbor | | #ifdef DB_DEBUG
|
1efb70 | 2006-08-16 | Henrik Grubbström (Grubba) | | all_wrapped_sql_objects[real]=0;
|
5c794b | 2001-09-06 | Per Hedbor | | #endif
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | |
|
8c8464 | 2005-09-23 | Martin Stjernholm | | if (reuse_in_thread) {
|
39e91c | 2008-02-13 | Martin Stjernholm | |
|
fc4039 | 2008-08-15 | Martin Stjernholm | | mapping(string:Sql.Sql) dbs_for_thread = sql_reuse_in_thread->get();
|
8c8464 | 2005-09-23 | Martin Stjernholm | | if (dbs_for_thread[db_name] == real) {
m_delete (dbs_for_thread, db_name);
if (!sizeof (dbs_for_thread)) sql_reuse_in_thread->set (0);
}
}
|
036c7b | 2011-05-24 | Martin Stjernholm | | if (!real) return;
|
558bf5 | 2022-01-11 | Henrik Grubbström (Grubba) | | if ((real->master_sql->query_db && real->master_sql->query_db()) !=
real_db_name) {
return;
}
|
33d8e6 | 2001-09-06 | Per Hedbor | | #ifndef NO_DB_REUSE
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | | mixed key;
catch {
key = sq_cache_lock();
};
|
558bf5 | 2022-01-11 | Henrik Grubbström (Grubba) | |
if (real->master_sql->reset) {
real->master_sql->reset();
}
|
d8b9d5 | 2001-09-27 | Henrik Grubbström (Grubba) | |
|
704582 | 2001-09-03 | Per Hedbor | | #ifdef DB_DEBUG
|
5d98ea | 2012-01-07 | Martin Stjernholm | | werror("%O added to free list\n", this );
#ifdef OBJ_COUNT_DEBUG
m_delete(my_mysql_last_user, __object_count);
#endif
|
a7c75e | 2001-02-01 | Per Hedbor | | #endif
|
8c8464 | 2005-09-23 | Martin Stjernholm | | if( !--sql_active_list[db_name] )
m_delete( sql_active_list, db_name );
sql_free_list[ db_name ] = ({ SQLTimeout(real) }) +
(sql_free_list[ db_name ]||({}));
|
704582 | 2001-09-03 | Per Hedbor | | if( `+( 0, @map(values( sql_free_list ),sizeof ) ) > 20 )
|
4f74c8 | 2001-08-09 | Per Hedbor | | {
|
704582 | 2001-09-03 | Per Hedbor | | #ifdef DB_DEBUG
werror("Free list too large. Cleaning.\n" );
#endif
clear_connect_to_my_mysql_cache();
|
4f74c8 | 2001-08-09 | Per Hedbor | | }
|
b56620 | 2001-10-05 | Per Hedbor | | #else
call_out(gc,0);
|
33d8e6 | 2001-09-06 | Per Hedbor | | #endif
|
704582 | 2001-09-03 | Per Hedbor | | }
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected mixed `[]( string what )
|
704582 | 2001-09-03 | Per Hedbor | | {
|
abe243 | 2001-09-06 | Per Hedbor | | return `->( what );
|
704582 | 2001-09-03 | Per Hedbor | | }
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected mixed `->(string what )
|
704582 | 2001-09-03 | Per Hedbor | | {
|
8f5705 | 2001-09-06 | Per Hedbor | | switch( what )
{
|
a366a5 | 2001-09-06 | Per Hedbor | | case "real": return real;
|
8c8464 | 2005-09-23 | Martin Stjernholm | | case "db_name": return db_name;
case "reuse_in_thread": return reuse_in_thread;
|
a366a5 | 2001-09-06 | Per Hedbor | | case "query": return query;
|
8f5705 | 2001-09-06 | Per Hedbor | | case "big_query": return big_query;
}
|
704582 | 2001-09-03 | Per Hedbor | | return real[what];
}
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected string _sprintf(int type)
|
704582 | 2001-09-03 | Per Hedbor | | {
|
c978f1 | 2015-08-03 | Henrik Grubbström (Grubba) | | string display_name = db_name || "";
if (has_suffix(display_name, ":-")) {
display_name = replace(display_name[..<2], ";", ":");
}
array(string) a = display_name/"://";
|
3c8658 | 2015-03-11 | Henrik Grubbström (Grubba) | | string prot = a[0];
string host = a[1..] * "://";
a = host/"@";
if (sizeof(a) > 1) {
host = a[-1];
a = (a[..<1] * "@")/":";
string user = a[0];
if (sizeof(a) > 1) {
display_name = prot + "://" + user + ":CENSORED@" + host;
}
}
return sprintf( "SQLKey(%O, %O)" + OBJ_COUNT, display_name, real );
|
704582 | 2001-09-03 | Per Hedbor | | }
|
4f74c8 | 2001-08-09 | Per Hedbor | | }
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected Thread.Mutex mt = Thread.Mutex();
|
8c8464 | 2005-09-23 | Martin Stjernholm | | Thread.MutexKey sq_cache_lock()
|
16d09e | 2001-09-06 | Per Hedbor | | {
return mt->lock();
}
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected mapping(program:string) default_db_charsets = ([]);
|
a31e39 | 2006-09-18 | Martin Stjernholm | |
|
9f7f66 | 2017-03-14 | Henrik Grubbström (Grubba) | |
|
f919e4 | 2011-05-23 | Martin Stjernholm | | Sql.Sql sq_cache_get( string db_name, void|int reuse_in_thread)
|
3e5319 | 2001-08-10 | Per Hedbor | | {
|
a31e39 | 2006-09-18 | Martin Stjernholm | | Sql.Sql db;
|
9f7f66 | 2017-03-14 | Henrik Grubbström (Grubba) | | Thread.MutexKey key = sq_cache_lock();
|
a31e39 | 2006-09-18 | Martin Stjernholm | |
|
8c8464 | 2005-09-23 | Martin Stjernholm | | if (reuse_in_thread) {
|
fc4039 | 2008-08-15 | Martin Stjernholm | | mapping(string:Sql.Sql) dbs_for_thread = sql_reuse_in_thread->get();
|
a31e39 | 2006-09-18 | Martin Stjernholm | | db = dbs_for_thread && dbs_for_thread[db_name];
|
8c8464 | 2005-09-23 | Martin Stjernholm | | }
|
a31e39 | 2006-09-18 | Martin Stjernholm | | else {
|
9f7f66 | 2017-03-14 | Henrik Grubbström (Grubba) | | while(sizeof(sql_free_list[db_name] || ({})))
|
a31e39 | 2006-09-18 | Martin Stjernholm | | {
|
704582 | 2001-09-03 | Per Hedbor | | #ifdef DB_DEBUG
|
a31e39 | 2006-09-18 | Martin Stjernholm | | werror("%O found in free list\n", db_name );
|
704582 | 2001-09-03 | Per Hedbor | | #endif
|
a31e39 | 2006-09-18 | Martin Stjernholm | | SQLTimeout res = sql_free_list[db_name][0];
if( sizeof( sql_free_list[ db_name ] ) > 1)
sql_free_list[ db_name ] = sql_free_list[db_name][1..];
else
m_delete( sql_free_list, db_name );
|
9f7f66 | 2017-03-14 | Henrik Grubbström (Grubba) | | if (res) {
destruct(key);
if ((db = res->get()) && db->is_open()) {
key = sq_cache_lock();
sql_active_list[db_name]++;
break;
}
key = sq_cache_lock();
|
a31e39 | 2006-09-18 | Martin Stjernholm | | }
|
8c8464 | 2005-09-23 | Martin Stjernholm | | }
|
704582 | 2001-09-03 | Per Hedbor | | }
|
a31e39 | 2006-09-18 | Martin Stjernholm | |
|
f919e4 | 2011-05-23 | Martin Stjernholm | | if (db)
return [object(Sql.Sql)] (object) SQLKey (db, db_name, reuse_in_thread);
return 0;
}
|
68145f | 2011-05-18 | Martin Stjernholm | |
|
f919e4 | 2011-05-23 | Martin Stjernholm | | Sql.Sql fix_connection_charset (Sql.Sql db, string charset)
{
|
956ae9 | 2012-01-09 | Martin Stjernholm | | if (object master_sql = db->master_sql) {
if (mixed err = catch {
if (master_sql->set_charset) {
if (!charset)
charset = default_db_charsets[object_program (master_sql)];
if ((charset == "unicode" || charset == "broken-unicode") &&
master_sql->get_unicode_encode_mode) {
if (!(master_sql->get_unicode_encode_mode() &&
master_sql->get_unicode_decode_mode()))
master_sql->set_charset (charset);
}
|
a31e39 | 2006-09-18 | Martin Stjernholm | |
|
956ae9 | 2012-01-09 | Martin Stjernholm | | else {
if (master_sql->set_unicode_decode_mode &&
master_sql->get_unicode_decode_mode())
master_sql->set_unicode_decode_mode (0);
if (charset != master_sql->get_charset())
master_sql->set_charset (charset);
}
}
})
{
if (db) destruct (db);
throw (err);
|
f919e4 | 2011-05-23 | Martin Stjernholm | | }
|
956ae9 | 2012-01-09 | Martin Stjernholm | | }
|
f919e4 | 2011-05-23 | Martin Stjernholm | |
return db;
|
16d09e | 2001-09-06 | Per Hedbor | | }
|
22d267 | 2008-11-26 | Martin Stjernholm | | #define FIX_CHARSET_FOR_NEW_SQL_CONN(SQLOBJ, CHARSET) do { \
if (object master_sql = SQLOBJ->master_sql) \
if (master_sql->set_charset) { \
if (zero_type (default_db_charsets[object_program (master_sql)])) \
default_db_charsets[object_program (master_sql)] = \
SQLOBJ->get_charset(); \
if (CHARSET) SQLOBJ->set_charset (CHARSET); \
} \
|
a31e39 | 2006-09-18 | Martin Stjernholm | | } while (0)
Sql.Sql sq_cache_set( string db_name, Sql.Sql res,
void|int reuse_in_thread, void|string charset)
|
5197df | 2007-05-03 | Martin Stjernholm | |
|
16d09e | 2001-09-06 | Per Hedbor | | {
if( res )
|
704582 | 2001-09-03 | Per Hedbor | | {
|
22d267 | 2008-11-26 | Martin Stjernholm | | FIX_CHARSET_FOR_NEW_SQL_CONN (res, charset);
|
9f7f66 | 2017-03-14 | Henrik Grubbström (Grubba) | | Thread.MutexKey key = sq_cache_lock();
|
8c8464 | 2005-09-23 | Martin Stjernholm | | sql_active_list[ db_name ]++;
return [object(Sql.Sql)] (object) SQLKey( res, db_name, reuse_in_thread);
|
704582 | 2001-09-03 | Per Hedbor | | }
|
3e5319 | 2001-08-10 | Per Hedbor | | }
|
a366a5 | 2001-09-06 | Per Hedbor | |
|
8c8464 | 2005-09-23 | Martin Stjernholm | | Sql.Sql connect_to_my_mysql( string|int ro, void|string db,
|
a31e39 | 2006-09-18 | Martin Stjernholm | | void|int reuse_in_thread, void|string charset)
|
16d09e | 2001-09-06 | Per Hedbor | | {
|
8c8464 | 2005-09-23 | Martin Stjernholm | | #if 0
|
1f546c | 2001-09-06 | Per Hedbor | | #ifdef DB_DEBUG
|
5c794b | 2001-09-06 | Per Hedbor | | gc();
#endif
|
8c8464 | 2005-09-23 | Martin Stjernholm | | #endif
|
9f7f66 | 2017-03-14 | Henrik Grubbström (Grubba) | | string i = db+":"+(intp(ro)?(ro&&"ro")||"rw":ro);
Sql.Sql res;
|
5aaf5b | 2002-02-06 | Henrik Grubbström (Grubba) | | if (catch {
|
9f7f66 | 2017-03-14 | Henrik Grubbström (Grubba) | | res = sq_cache_get(i, reuse_in_thread);
}) {
|
5aaf5b | 2002-02-06 | Henrik Grubbström (Grubba) | |
|
a31e39 | 2006-09-18 | Martin Stjernholm | |
|
9f7f66 | 2017-03-14 | Henrik Grubbström (Grubba) | |
|
a31e39 | 2006-09-18 | Martin Stjernholm | | Sql.Sql res = low_connect_to_my_mysql(ro, db);
|
22d267 | 2008-11-26 | Martin Stjernholm | | FIX_CHARSET_FOR_NEW_SQL_CONN (res, charset);
|
a31e39 | 2006-09-18 | Martin Stjernholm | | return res;
|
5aaf5b | 2002-02-06 | Henrik Grubbström (Grubba) | | }
|
f919e4 | 2011-05-23 | Martin Stjernholm | | if (res) {
return fix_connection_charset (res, charset);
}
|
93d436 | 2006-07-14 | Henrik Grubbström (Grubba) | | if (res = low_connect_to_my_mysql( ro, db )) {
|
9f7f66 | 2017-03-14 | Henrik Grubbström (Grubba) | | return sq_cache_set(i, res, reuse_in_thread, charset);
|
93d436 | 2006-07-14 | Henrik Grubbström (Grubba) | | }
return 0;
|
16d09e | 2001-09-06 | Per Hedbor | | }
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected mixed low_connect_to_my_mysql( string|int ro, void|string db )
|
4f74c8 | 2001-08-09 | Per Hedbor | | {
object res;
|
a6e1fa | 2001-08-10 | Per Hedbor | | #ifdef DB_DEBUG
werror("Requested %O for %O DB\n", db, ro );
#endif
|
704582 | 2001-09-03 | Per Hedbor | |
|
a7c75e | 2001-02-01 | Per Hedbor | | if( !db )
db = "mysql";
|
6f11ba | 2001-01-08 | Per Hedbor | |
|
c43d0f | 2008-12-20 | Martin Stjernholm | | mixed err = catch
|
74e390 | 2000-12-30 | Per Hedbor | | {
|
baa9d5 | 2001-01-27 | Per Hedbor | | if( intp( ro ) )
ro = ro?"ro":"rw";
|
22c98c | 2001-08-13 | Per Hedbor | | int t = gethrtime();
res = Sql.Sql( replace( my_mysql_path,({"%user%", "%db%" }),
|
8a2ce4 | 2011-08-29 | Henrik Grubbström (Grubba) | | ({ ro, db })),
([ "reconnect":0 ]));
|
1efb70 | 2006-08-16 | Henrik Grubbström (Grubba) | | #ifdef ENABLE_MYSQL_UNICODE_MODE
|
22d267 | 2008-11-26 | Martin Stjernholm | | if (res && res->master_sql && res->master_sql->set_unicode_decode_mode) {
|
222f1b | 2006-08-17 | Henrik Grubbström (Grubba) | |
|
a87a0d | 2006-11-17 | Martin Stjernholm | | mixed err2 = catch {
|
4670e5 | 2006-08-22 | Henrik Grubbström (Grubba) | | res->master_sql->set_unicode_decode_mode(1);
|
1efb70 | 2006-08-16 | Henrik Grubbström (Grubba) | | #ifdef DB_DEBUG
|
4670e5 | 2006-08-22 | Henrik Grubbström (Grubba) | | werror("Unicode decode mode enabled.\n");
|
1efb70 | 2006-08-16 | Henrik Grubbström (Grubba) | | #endif
};
|
a87a0d | 2006-11-17 | Martin Stjernholm | | #ifdef DB_DEBUG
if (err2) werror ("Failed to enable unicode decode mode: %s",
describe_error (err2));
#endif
|
1efb70 | 2006-08-16 | Henrik Grubbström (Grubba) | | }
#endif /* ENABLE_MYSQL_UNICODE_MODE */
|
22c98c | 2001-08-13 | Per Hedbor | | #ifdef DB_DEBUG
werror("Connect took %.2fms\n", (gethrtime()-t)/1000.0 );
#endif
|
704582 | 2001-09-03 | Per Hedbor | | return res;
|
c43d0f | 2008-12-20 | Martin Stjernholm | | };
if( db == "mysql" ||
has_value (describe_error (err), "Access denied"))
throw( err );
if (mixed err_2 = catch {
low_connect_to_my_mysql( 0, "mysql" )
->query( "CREATE DATABASE "+ db );
}) {
report_warning ("Attempt to autocreate database %O failed: %s",
db, describe_error (err_2));
throw (err);
}
|
16d09e | 2001-09-06 | Per Hedbor | | return low_connect_to_my_mysql( ro, db );
|
74e390 | 2000-12-30 | Per Hedbor | | }
|
4f74c8 | 2001-08-09 | Per Hedbor | |
|
fc4039 | 2008-08-15 | Martin Stjernholm | | protected mapping tailf_info = ([]);
protected void do_tailf( int loop, string file )
|
bed50e | 2001-01-21 | Per Hedbor | | {
string mysqlify( string what )
{
|
5dee02 | 2001-08-08 | Per Hedbor | | string res = "";
foreach( (what/"\n"), string line )
|
bed50e | 2001-01-21 | Per Hedbor | | {
|
5dee02 | 2001-08-08 | Per Hedbor | | if( sscanf( line, "%*sAborted connection%*s" ) == 2 )
continue;
|
bed50e | 2001-01-21 | Per Hedbor | | if( line == "" )
return res+"\n";
res += "\n";
|
2698fd | 2002-08-20 | Anders Johansson | | res += "mysql: "+line;
|
bed50e | 2001-01-21 | Per Hedbor | | }
return res;
};
|
5020d4 | 2008-05-09 | Martin Stjernholm | | int os, si;
|
8b3289 | 2003-03-02 | Anders Johansson | | if( tailf_info[file] )
os = tailf_info[file];
|
bed50e | 2001-01-21 | Per Hedbor | | do
{
|
8b3289 | 2003-03-02 | Anders Johansson | | Stdio.Stat s = file_stat( file );
|
2c241c | 2003-03-03 | Anders Johansson | | if(!s) {
os = tailf_info[ file ] = 0;
|
6a1f50 | 2008-02-06 | Fredrik Noring | | sleep(1);
|
2c241c | 2003-03-03 | Anders Johansson | | continue;
}
|
bed50e | 2001-01-21 | Per Hedbor | | si = s[ ST_SIZE ];
|
2c241c | 2003-03-03 | Anders Johansson | | if( zero_type( tailf_info[ file ] ) )
os = tailf_info[ file ] = si;
|
bed50e | 2001-01-21 | Per Hedbor | | if( os != si )
{
|
8b3289 | 2003-03-02 | Anders Johansson | | Stdio.File f = Stdio.File( file, "r" );
|
bed50e | 2001-01-21 | Per Hedbor | | if(!f) return;
if( os < si )
{
f->seek( os );
report_debug( mysqlify( f->read( si - os ) ) );
}
else
report_debug( mysqlify( f->read( si ) ) );
|
8b3289 | 2003-03-02 | Anders Johansson | | os = tailf_info[ file ] = si;
|
bed50e | 2001-01-21 | Per Hedbor | | }
|
510bea | 2001-08-09 | Per Hedbor | | if( loop )
sleep( 1 );
|
bed50e | 2001-01-21 | Per Hedbor | | } while( loop );
}
|
7dfd2e | 2009-02-06 | Jonas Wallden | | protected void low_check_mysql(string myisamchk, string datadir,
|
fc4039 | 2008-08-15 | Martin Stjernholm | | array(string) args, void|Stdio.File errlog)
|
7573ab | 2008-02-06 | Fredrik Noring | | {
array(string) files = ({});
foreach(get_dir(datadir) || ({}), string dir) {
foreach(get_dir(combine_path(datadir, dir)) || ({}), string file)
if(!file || !glob("*.myi", lower_case(file), ))
continue;
else
files += ({ combine_path(datadir, dir, file) });
}
if(!sizeof(files))
return;
|
39e91c | 2008-02-13 | Martin Stjernholm | | Stdio.File devnull
#ifndef __NT__
= Stdio.File( "/dev/null", "w" )
#endif
;
|
7573ab | 2008-02-06 | Fredrik Noring | |
report_debug("Checking MySQL tables with %O...\n", args*" ");
mixed err = catch {
|
a0a3c7 | 2018-07-09 | Henrik Grubbström (Grubba) | | Process.Process(({ myisamchk,
"--defaults-file=" + query_mysql_config_file(datadir),
}) + args + sort(files),
|
92ced8 | 2011-09-12 | Henrik Grubbström (Grubba) | | ([
"stdin":devnull,
"stdout":errlog,
"stderr":errlog
]))->wait();
|
7573ab | 2008-02-06 | Fredrik Noring | | };
if(err)
werror(describe_backtrace(err));
}
|
654e75 | 2019-11-20 | Henrik Grubbström (Grubba) | | Process.Process low_start_mysql( string datadir,
|
1fc86c | 2019-11-20 | Henrik Grubbström (Grubba) | | string uid,
void|int log_queries_to_stdout)
|
825cb9 | 2001-01-31 | Per Hedbor | | {
|
3363a0 | 2007-12-07 | Martin Jonsson | | void rotate_log(string path)
{
rm(path+".5");
for(int i=4; i>0; i--)
mv(path+"."+(string)i, path+"."+(string)(i+1));
};
|
7dfd2e | 2009-02-06 | Jonas Wallden | |
|
400800 | 2009-07-27 | Martin Stjernholm | | mapping mysql_location = this_program::mysql_location();
|
7dfd2e | 2009-02-06 | Jonas Wallden | | if (!mysql_location->mysqld) {
report_debug("\nNo MySQL found in "+ mysql_location->basedir + "!\n");
exit(1);
|
825cb9 | 2001-01-31 | Per Hedbor | | }
|
2ddbde | 2009-02-11 | Jonas Wallden | |
string version_fatal_error = 0;
|
b771de | 2014-09-30 | Henrik Grubbström (Grubba) | | string version = popen(({ mysql_location->mysqld,
"--version", "--no-defaults",
}));
|
2ddbde | 2009-02-11 | Jonas Wallden | | if (!version) {
version_fatal_error =
sprintf("Unable to determine MySQL version with this command:\n\n"
|
b771de | 2014-09-30 | Henrik Grubbström (Grubba) | | " %s --version --no-defaults\n\n",
|
2ddbde | 2009-02-11 | Jonas Wallden | | mysql_location->mysqld);
} else {
|
bffd56 | 2009-02-11 | Jonas Wallden | | string orig_version = version;
|
dd4389 | 2014-09-05 | Henrik Grubbström (Grubba) | | string trailer;
|
533be8 | 2009-02-17 | Martin Stjernholm | | if (has_prefix (version, mysql_location->mysqld))
version = version[sizeof (mysql_location->mysqld)..];
|
dd4389 | 2014-09-05 | Henrik Grubbström (Grubba) | | if (sscanf(lower_case(version), "%*s ver %[0-9.]%s",
mysql_version, trailer) < 2) {
|
2ddbde | 2009-02-11 | Jonas Wallden | | version_fatal_error =
|
62c909 | 2011-11-10 | Martin Stjernholm | | sprintf("Failed to parse MySQL version string - got %q from:\n"
"%O\n\n", version, orig_version);
|
dd4389 | 2014-09-05 | Henrik Grubbström (Grubba) | | #ifndef YES_I_KNOW_WHAT_I_AM_DOING
|
2ddbde | 2009-02-11 | Jonas Wallden | | } else {
|
dd4389 | 2014-09-05 | Henrik Grubbström (Grubba) | | array(string) good_versions = mysql_good_versions;
array(string) maybe_versions = mysql_maybe_versions;
|
63c145 | 2018-07-06 | Henrik Grubbström (Grubba) | | array(string) bad_versions = mysql_bad_versions;
|
dd4389 | 2014-09-05 | Henrik Grubbström (Grubba) | | mysql_product_name = "MySQL";
if (has_prefix(trailer, "-mariadb")) {
mysql_product_name = "MariaDB";
good_versions = mariadb_good_versions;
maybe_versions = mariadb_maybe_versions;
|
63c145 | 2018-07-06 | Henrik Grubbström (Grubba) | | bad_versions = mariadb_bad_versions;
|
dd4389 | 2014-09-05 | Henrik Grubbström (Grubba) | | }
|
2ddbde | 2009-02-11 | Jonas Wallden | |
|
dd4389 | 2014-09-05 | Henrik Grubbström (Grubba) | | if (has_value(glob(good_versions[*], mysql_version), 1)) {
|
2ddbde | 2009-02-11 | Jonas Wallden | |
|
dd4389 | 2014-09-05 | Henrik Grubbström (Grubba) | | } else if (has_value(glob(maybe_versions[*], mysql_version), 1)) {
|
63c145 | 2018-07-06 | Henrik Grubbström (Grubba) | | if (has_value(glob(bad_versions[*], mysql_version), 1)) {
version_fatal_error =
sprintf("This version of %s (%s) is known to not work "
"with Roxen:\n\n"
" %s\n",
mysql_product_name, mysql_version, orig_version);
} else {
|
2ddbde | 2009-02-11 | Jonas Wallden | | #ifdef ALLOW_UNSUPPORTED_MYSQL
|
63c145 | 2018-07-06 | Henrik Grubbström (Grubba) | | report_debug("\nWARNING: Forcing Roxen to run with unsupported "
"%s version (%s).\n",
mysql_product_name, mysql_version);
|
2ddbde | 2009-02-11 | Jonas Wallden | | #else
|
63c145 | 2018-07-06 | Henrik Grubbström (Grubba) | | version_fatal_error =
sprintf("This version of %s (%s) is not officially supported "
"with Roxen.\n"
"If you want to override this restriction, use this "
"option:\n\n"
" -DALLOW_UNSUPPORTED_MYSQL\n\n",
mysql_product_name, mysql_version);
|
2ddbde | 2009-02-11 | Jonas Wallden | | #endif
|
63c145 | 2018-07-06 | Henrik Grubbström (Grubba) | | }
|
2ddbde | 2009-02-11 | Jonas Wallden | | } else {
version_fatal_error =
|
dd4389 | 2014-09-05 | Henrik Grubbström (Grubba) | | sprintf("%s version %s detected:\n\n"
" %s\n", mysql_product_name, mysql_version, orig_version);
|
2ddbde | 2009-02-11 | Jonas Wallden | | }
|
8005a7 | 2016-10-10 | Anders Johansson | | #endif
|
970b02 | 2011-11-10 | Martin Stjernholm | | #ifdef RUN_SELF_TEST
if (version_fatal_error) {
report_debug ("\n%s"
"Continuing anyway in self test mode.\n\n",
version_fatal_error);
version_fatal_error = 0;
}
#endif
|
2ddbde | 2009-02-11 | Jonas Wallden | | }
}
if (version_fatal_error) {
report_debug("\n%s"
"Roxen cannot run unknown/unsupported versions for data\n"
"integrity reasons and will therefore terminate.\n\n",
version_fatal_error);
exit(1);
}
|
706243 | 2009-02-13 | Martin Stjernholm | |
|
825cb9 | 2001-01-31 | Per Hedbor | | string pid_file = datadir + "/mysql_pid";
string err_log = datadir + "/error_log";
|
3363a0 | 2007-12-07 | Martin Jonsson | | string slow_query_log;
if(getenv("LOGFILE"))
slow_query_log = dirname(roxen_path("$LOGFILE")) + "/slow_query_log";
else
slow_query_log = datadir + "/slow_query_log";
|
825cb9 | 2001-01-31 | Per Hedbor | |
|
2ed887 | 2008-02-06 | Martin Jonsson | | slow_query_log = combine_path(getcwd(), slow_query_log);
|
7e7ea8 | 2008-02-06 | Martin Jonsson | |
|
01ff7b | 2002-02-05 | Henrik Grubbström (Grubba) | |
|
6d6bc8 | 2001-06-24 | Martin Nilsson | | array(string) args = ({
|
8edc67 | 2001-07-31 | Per Hedbor | | "--defaults-file="+datadir+"/my.cfg",
|
4e6491 | 2001-11-14 | Tomas Nilsson | | #ifdef __NT__
|
bedb02 | 2001-02-02 | Tomas Nilsson | |
|
a1d2e5 | 2001-11-15 | Tomas Nilsson | | "--socket="+replace(datadir, ":", "_") + "/pipe",
|
a04f24 | 2003-12-12 | Jonas Wallden | | "--enable-named-pipe",
|
bedb02 | 2001-02-02 | Tomas Nilsson | | #else
|
825cb9 | 2001-01-31 | Per Hedbor | | "--socket="+datadir+"/socket",
|
4e6491 | 2001-11-14 | Tomas Nilsson | | "--pid-file="+pid_file,
|
825cb9 | 2001-01-31 | Per Hedbor | | #endif
|
920f06 | 2013-02-05 | Build system | | has_prefix(version, "5.1.")?
"--skip-locking":"--skip-external-locking",
|
1d6a5e | 2002-02-27 | Henrik Grubbström (Grubba) | | "--skip-name-resolve",
|
7dfd2e | 2009-02-06 | Jonas Wallden | | "--basedir=" + mysql_location->basedir,
|
825cb9 | 2001-01-31 | Per Hedbor | | "--datadir="+datadir,
|
6d6bc8 | 2001-06-24 | Martin Nilsson | | });
|
825cb9 | 2001-01-31 | Per Hedbor | |
|
01ff7b | 2002-02-05 | Henrik Grubbström (Grubba) | |
mapping env = getenv();
env->MYSQL_UNIX_PORT = datadir+"/socket";
|
3cd058 | 2002-04-05 | Henrik Grubbström (Grubba) | | if ((int)env->ROXEN_MYSQL_TCP_PORT) {
env->MYSQL_TCP_PORT = env->ROXEN_MYSQL_TCP_PORT;
|
01ff7b | 2002-02-05 | Henrik Grubbström (Grubba) | | args += ({ "--port="+env->MYSQL_TCP_PORT });
if (!env->MYSQL_HOST) {
env->MYSQL_HOST = "127.0.0.1";
}
} else {
args += ({ "--skip-networking" });
env->MYSQL_HOST = "127.0.0.1";
env->MYSQL_TCP_PORT = "0";
}
|
0b2282 | 2014-09-05 | Henrik Grubbström (Grubba) | | string normalized_mysql_version =
map(mysql_version/".",
lambda(string d) {
return ("000" + d)[<2..];
}) * ".";
|
3363a0 | 2007-12-07 | Martin Jonsson | | if(!env->ROXEN_MYSQL_SLOW_QUERY_LOG ||
env->ROXEN_MYSQL_SLOW_QUERY_LOG != "0") {
rotate_log(slow_query_log);
|
0b2282 | 2014-09-05 | Henrik Grubbström (Grubba) | | if (normalized_mysql_version > "005.006.") {
|
ab8e0b | 2014-08-26 | Henrik Grubbström (Grubba) | | args += ({
"--slow-query-log-file="+slow_query_log+".1",
"--slow-query-log",
});
} else {
args += ({ "--log-slow-queries="+slow_query_log+".1" });
}
|
a4d88d | 2007-12-22 | Jonas Wallden | | report_debug("Setting MySQL's slow query log to \"%s.1\"\n", slow_query_log);
|
3363a0 | 2007-12-07 | Martin Jonsson | | }
|
ab8e0b | 2014-08-26 | Henrik Grubbström (Grubba) | | if (log_queries_to_stdout) {
|
0b2282 | 2014-09-05 | Henrik Grubbström (Grubba) | | if (normalized_mysql_version > "005.006.") {
|
ab8e0b | 2014-08-26 | Henrik Grubbström (Grubba) | | args += ({
"--general-log-file=/dev/stdout",
"--general-log",
});
} else {
args += ({"--log=/dev/stdout"});
}
}
|
c5e97b | 2009-06-25 | Martin Stjernholm | |
|
01ff7b | 2002-02-05 | Henrik Grubbström (Grubba) | |
|
328c4d | 2018-07-09 | Henrik Grubbström (Grubba) | | int force = !file_stat( query_mysql_config_file(datadir) );
string cfg_file = (Stdio.read_bytes(query_mysql_config_file(datadir)) ||
|
dab5a0 | 2013-02-14 | Henrik Grubbström (Grubba) | | "[mysqld]\n"
|
f30067 | 2013-12-10 | Henrik Grubbström (Grubba) | | "max_allowed_packet = 128M\n"
|
920f06 | 2013-02-05 | Build system | | "net_buffer_length = 8K\n"
|
89cef9 | 2007-08-27 | Fredrik Noring | | "query-cache-type = 2\n"
"query-cache-size = 32M\n"
|
38a0ec | 2014-09-02 | Henrik Grubbström (Grubba) | | "default-storage-engine = MYISAM\n"
|
1b5e90 | 2014-09-26 | Henrik Grubbström (Grubba) | | "innodb-data-file-path=ibdata1:10M:autoextend\n"
|
e4a443 | 2002-03-22 | Jonas Wallden | | #ifndef UNSAFE_MYSQL
|
9e29fc | 2002-03-15 | Henrik Grubbström (Grubba) | | "local-infile = 0\n"
|
e4a443 | 2002-03-22 | Jonas Wallden | | #endif
|
1d6a5e | 2002-02-27 | Henrik Grubbström (Grubba) | | "skip-name-resolve\n"
|
813965 | 2013-02-18 | Henrik Grubbström (Grubba) | | "character-set-server=latin1\n"
"collation-server=latin1_swedish_ci\n"
|
cae224 | 2004-10-19 | Martin Stjernholm | | "bind-address = "+env->MYSQL_HOST+"\n" +
(uid ? "user = " + uid : "") + "\n");
|
1d6a5e | 2002-02-27 | Henrik Grubbström (Grubba) | |
|
72de91 | 2014-09-26 | Henrik Grubbström (Grubba) | | string normalized_cfg_file = replace(cfg_file, "_", "-");
|
dab5a0 | 2013-02-14 | Henrik Grubbström (Grubba) | |
|
72de91 | 2014-09-26 | Henrik Grubbström (Grubba) | | if (has_value(normalized_cfg_file, "set-variable=") ||
has_value(normalized_cfg_file, "set-variable =")) {
|
328c4d | 2018-07-09 | Henrik Grubbström (Grubba) | | report_debug("Repairing pre Mysql 4.0.2 syntax in %s.\n",
query_mysql_config_file(datadir));
|
dab5a0 | 2013-02-14 | Henrik Grubbström (Grubba) | | cfg_file = replace(cfg_file,
({ "set-variable=",
|
72de91 | 2014-09-26 | Henrik Grubbström (Grubba) | | "set-variable = ", "set-variable =",
"set_variable=",
"set_variable = ", "set_variable =",
}),
({ "", "", "", "", "", "",
}));
|
dab5a0 | 2013-02-14 | Henrik Grubbström (Grubba) | | force = 1;
}
|
1b5e90 | 2014-09-26 | Henrik Grubbström (Grubba) | | if ((normalized_mysql_version > "005.000.") &&
!has_value(normalized_cfg_file, "innodb-data-file-path")) {
array a = cfg_file/"[mysqld]";
if (sizeof(a) > 1) {
|
328c4d | 2018-07-09 | Henrik Grubbström (Grubba) | | report_debug("Adding innodb-data-file-path to %s.\n",
query_mysql_config_file(datadir));
|
1b5e90 | 2014-09-26 | Henrik Grubbström (Grubba) | | int initial = 10;
int bytes = Stdio.file_size(datadir + "/ibdata1");
if (bytes) {
|
c54d66 | 2014-09-26 | Anders Johansson | | initial = ((bytes / (1024 * 1024)) % 8) + 8;
|
1b5e90 | 2014-09-26 | Henrik Grubbström (Grubba) | | if (initial < 10) initial += 8;
}
report_debug("%O\n",
"ibdata1:" + initial + "M:autoextend");
a[1] = "\n"
"innodb-data-file-path=ibdata1:" + initial + "M:autoextend" + a[1];
|
c54d66 | 2014-09-26 | Anders Johansson | | cfg_file = a * "[mysqld]";
|
1b5e90 | 2014-09-26 | Henrik Grubbström (Grubba) | | force = 1;
} else {
|
328c4d | 2018-07-09 | Henrik Grubbström (Grubba) | | report_warning("Mysql configuration file %s lacks\n"
|
1b5e90 | 2014-09-26 | Henrik Grubbström (Grubba) | | "InnoDB data file path entry, "
"and automatic repairer failed.\n",
|
328c4d | 2018-07-09 | Henrik Grubbström (Grubba) | | query_mysql_config_file(datadir));
|
1b5e90 | 2014-09-26 | Henrik Grubbström (Grubba) | | }
}
|
0b2282 | 2014-09-05 | Henrik Grubbström (Grubba) | | if ((normalized_mysql_version > "005.002.") &&
|
72de91 | 2014-09-26 | Henrik Grubbström (Grubba) | | !has_value(normalized_cfg_file, "character-set-server")) {
|
813965 | 2013-02-18 | Henrik Grubbström (Grubba) | |
array a = cfg_file/"[mysqld]";
if (sizeof(a) > 1) {
|
328c4d | 2018-07-09 | Henrik Grubbström (Grubba) | | report_debug("Adding default character set entries to %s.\n",
query_mysql_config_file(datadir));
|
813965 | 2013-02-18 | Henrik Grubbström (Grubba) | | a[1] = "\n"
"character-set-server=latin1\n"
"collation-server=latin1_swedish_ci" + a[1];
cfg_file = a * "[mysqld]";
force = 1;
} else {
|
328c4d | 2018-07-09 | Henrik Grubbström (Grubba) | | report_warning("Mysql configuration file %s lacks\n"
|
813965 | 2013-02-18 | Henrik Grubbström (Grubba) | | "character set entry, and automatic repairer failed.\n",
|
328c4d | 2018-07-09 | Henrik Grubbström (Grubba) | | query_mysql_config_file(datadir));
|
813965 | 2013-02-18 | Henrik Grubbström (Grubba) | | }
|
38a0ec | 2014-09-02 | Henrik Grubbström (Grubba) | | }
|
0b2282 | 2014-09-05 | Henrik Grubbström (Grubba) | | if ((normalized_mysql_version > "005.005.") &&
|
72de91 | 2014-09-26 | Henrik Grubbström (Grubba) | | !has_value(normalized_cfg_file, "default-storage-engine")) {
|
38a0ec | 2014-09-02 | Henrik Grubbström (Grubba) | |
array a = cfg_file/"[mysqld]";
if (sizeof(a) > 1) {
|
328c4d | 2018-07-09 | Henrik Grubbström (Grubba) | | report_debug("Adding default storage engine entry to %s.\n",
query_mysql_config_file(datadir));
|
38a0ec | 2014-09-02 | Henrik Grubbström (Grubba) | | a[1] = "\n"
"default-storage-engine = MYISAM" + a[1];
cfg_file = a * "[mysqld]";
force = 1;
} else {
|
328c4d | 2018-07-09 | Henrik Grubbström (Grubba) | | report_warning("Mysql configuration file %s lacks\n"
|
38a0ec | 2014-09-02 | Henrik Grubbström (Grubba) | | "storage engine entry, and automatic repairer failed.\n",
|
328c4d | 2018-07-09 | Henrik Grubbström (Grubba) | | query_mysql_config_file(datadir));
|
38a0ec | 2014-09-02 | Henrik Grubbström (Grubba) | | }
|
813965 | 2013-02-18 | Henrik Grubbström (Grubba) | | }
|
92b6fc | 2018-03-13 | Henrik Grubbström (Grubba) | | if ((normalized_mysql_version > "010.002.003") &&
!has_value(normalized_cfg_file, "sql_mode")) {
array a = cfg_file/"[mysqld]";
if (sizeof(a) > 1) {
report_debug("Adding sql_mode entry to %s/my.cfg.\n", datadir);
a[1] = "\n"
"sql_mode = NO_ENGINE_SUBSTITUTION" + a[1];
cfg_file = a * "[mysqld]";
force = 1;
} else {
report_warning("Mysql configuration file %s/my.cfg lacks\n"
"sql_mode entry, and automatic repairer failed.\n",
datadir);
}
}
|
813965 | 2013-02-18 | Henrik Grubbström (Grubba) | | #ifdef __NT__
cfg_file = replace(cfg_file, ({ "\r\n", "\n" }), ({ "\r\n", "\r\n" }));
#endif /* __NT__ */
|
dab5a0 | 2013-02-14 | Henrik Grubbström (Grubba) | | if(force)
|
328c4d | 2018-07-09 | Henrik Grubbström (Grubba) | | catch(Stdio.write_file(query_mysql_config_file(datadir), cfg_file));
|
097e18 | 2009-12-09 | Martin Stjernholm | |
Stdio.File errlog = !once_mode && Stdio.File( err_log, "wct" );
|
39e91c | 2008-02-13 | Martin Stjernholm | |
|
7573ab | 2008-02-06 | Fredrik Noring | | string mysql_table_check =
Stdio.read_file(combine_path(query_configuration_dir(),
"_mysql_table_check"));
if(!mysql_table_check)
mysql_table_check = "--force --silent --fast\n"
"--myisam-recover=QUICK,FORCE\n";
sscanf(mysql_table_check, "%s\n%s\n",
string myisamchk_args, string mysqld_extra_args);
|
7dfd2e | 2009-02-06 | Jonas Wallden | | if(myisamchk_args && sizeof(myisamchk_args)) {
if (string myisamchk = mysql_location->myisamchk)
low_check_mysql(myisamchk, datadir, (myisamchk_args / " ") - ({ "" }),
errlog);
else {
report_warning("No myisamchk found in %s. Tables not checked.\n",
mysql_location->basedir);
}
}
|
39e91c | 2008-02-13 | Martin Stjernholm | |
|
7573ab | 2008-02-06 | Fredrik Noring | | if(mysqld_extra_args && sizeof(mysqld_extra_args))
args += (mysqld_extra_args/" ") - ({ "" });
|
7dfd2e | 2009-02-06 | Jonas Wallden | | args = ({ mysql_location->mysqld }) + args;
|
825cb9 | 2001-01-31 | Per Hedbor | |
Stdio.File devnull
#ifndef __NT__
= Stdio.File( "/dev/null", "w" )
#endif
;
|
706243 | 2009-02-13 | Martin Stjernholm | | #ifdef DEBUG
report_debug ("MySQL server command: %s%{\n %s%}\n", args[0], args[1..]);
#else
report_debug ("MySQL server executable: %s\n", args[0]);
#endif
|
29ac05 | 2012-01-18 | Henrik Grubbström (Grubba) | | rm(pid_file);
|
92ced8 | 2011-09-12 | Henrik Grubbström (Grubba) | | Process.Process p = Process.Process( args,
([
"environment":env,
"stdin":devnull,
"stdout":errlog,
"stderr":errlog
]) );
|
4e6491 | 2001-11-14 | Tomas Nilsson | | #ifdef __NT__
if (p)
|
29ac05 | 2012-01-18 | Henrik Grubbström (Grubba) | | Stdio.write_file(pid_file, p->pid() + "\n");
|
4e6491 | 2001-11-14 | Tomas Nilsson | | #endif
|
654e75 | 2019-11-20 | Henrik Grubbström (Grubba) | |
return p;
|
825cb9 | 2001-01-31 | Per Hedbor | | }
|
baa9d5 | 2001-01-27 | Per Hedbor | | int mysql_path_is_remote;
|
c5e97b | 2009-06-25 | Martin Stjernholm | | void start_mysql (void|int log_queries_to_stdout)
|
74e390 | 2000-12-30 | Per Hedbor | | {
|
850c28 | 2001-01-10 | Per Hedbor | | Sql.Sql db;
|
baa9d5 | 2001-01-27 | Per Hedbor | | int st = gethrtime();
|
cd5f54 | 2005-12-21 | Fredrik Noring | | string mysqldir = query_mysql_data_dir();
|
8b3289 | 2003-03-02 | Anders Johansson | | string err_log = mysqldir+"/error_log";
string pid_file = mysqldir+"/mysql_pid";
int do_tailf_threaded = 0;
#ifdef THREADS
if (uname()->sysname != "Linux")
do_tailf_threaded = 1;
#endif
|
baa9d5 | 2001-01-27 | Per Hedbor | | void assure_that_base_tables_exists( )
|
74e390 | 2000-12-30 | Per Hedbor | | {
|
22c98c | 2001-08-13 | Per Hedbor | | if( mixed err = catch( db->query( "SELECT id from local.precompiled_files WHERE id=''" ) ) )
|
74e390 | 2000-12-30 | Per Hedbor | | {
|
22c98c | 2001-08-13 | Per Hedbor | | db->query( "CREATE DATABASE IF NOT EXISTS local" );
connect_to_my_mysql(0,"local")
->query( "CREATE TABLE precompiled_files ("
|
0c0e36 | 2001-01-01 | Martin Nilsson | | "id CHAR(30) NOT NULL PRIMARY KEY, "
"data MEDIUMBLOB NOT NULL, "
"mtime INT UNSIGNED NOT NULL)" );
|
22c98c | 2001-08-13 | Per Hedbor | |
call_out( lambda(){
new_master->resolv("DBManager.is_module_table")
( 0, "local", "precompiled_files",
"Contains binary object code for .pike files. "
"This information is used to shorten the "
"boot time of Roxen by keeping the compiled "
"data instead of recompiling it every time.");
}, 1 );
|
74e390 | 2000-12-30 | Per Hedbor | | }
|
959382 | 2017-10-18 | Henrik Grubbström (Grubba) | |
call_out( lambda(){
new_master->resolv("DBManager.inhibit_backups")
("local", "precompiled_files");
}, 1 );
|
74e390 | 2000-12-30 | Per Hedbor | | if( remove_dumped )
{
|
0c0e36 | 2001-01-01 | Martin Nilsson | | report_notice("Removing precompiled files\n");
|
b00dfe | 2001-02-05 | Martin Stjernholm | | if (mixed err = catch
|
523851 | 2001-01-22 | Per Hedbor | | {
|
22c98c | 2001-08-13 | Per Hedbor | | db->query( "DELETE FROM local.precompiled_files" );
|
92e622 | 2001-09-04 | Per Hedbor | | db->query( "DELETE FROM local.compiled_formats" );
|
4491d7 | 2002-09-17 | Martin Stjernholm | |
db->query( "DELETE FROM local.modules" );
|
b00dfe | 2001-02-05 | Martin Stjernholm | | }) {
#ifdef MYSQL_CONNECT_DEBUG
werror ("Error removing dumped files: %s", describe_error (err));
#endif
}
|
74e390 | 2000-12-30 | Per Hedbor | | }
};
|
baa9d5 | 2001-01-27 | Per Hedbor | | void connected_ok(int was)
{
string version = db->query( "SELECT VERSION() AS v" )[0]->v;
|
56509c | 2001-06-30 | Martin Stjernholm | | report_debug("\b%s %s [%.1fms]\n",
|
baa9d5 | 2001-01-27 | Per Hedbor | | (was?"Was running":"Done"),
version, (gethrtime()-st)/1000.0);
if( (float)version < 3.23 )
|
8a79f8 | 2003-02-05 | Jonas Wallden | | report_debug( "Warning: This is a very old MySQL. "
|
f0c991 | 2004-04-26 | Henrik Grubbström (Grubba) | | "Please use 3.23.* or later.\n");
|
baa9d5 | 2001-01-27 | Per Hedbor | |
|
d08409 | 2006-08-21 | Henrik Grubbström (Grubba) | | if ((float)version > 4.0) {
add_constant("ROXEN_MYSQL_SUPPORTS_UNICODE", 1);
}
|
097e18 | 2009-12-09 | Martin Stjernholm | | if( !do_tailf_threaded && !once_mode ) do_tailf(0, err_log );
|
baa9d5 | 2001-01-27 | Per Hedbor | | assure_that_base_tables_exists();
};
|
2c241c | 2003-03-03 | Anders Johansson | | void start_tailf()
{
if( do_tailf_threaded ) {
thread_create( do_tailf, 1, err_log );
sleep(0.1);
|
e1f814 | 2015-04-28 | Jonas Walldén | | } else {
|
2c241c | 2003-03-03 | Anders Johansson | | do_tailf(0, err_log );
void do_do_tailf( )
{
call_out( do_do_tailf, 1 );
do_tailf( 0, err_log );
};
call_out( do_do_tailf, 0 );
}
};
|
8a79f8 | 2003-02-05 | Jonas Wallden | | report_debug( "Starting MySQL ... \b");
|
baa9d5 | 2001-01-27 | Per Hedbor | |
|
b00dfe | 2001-02-05 | Martin Stjernholm | | if( mixed err = catch( db = connect_to_my_mysql( 0, "mysql" ) ) ) {
#ifdef MYSQL_CONNECT_DEBUG
|
8a79f8 | 2003-02-05 | Jonas Wallden | | werror ("Error connecting to local MySQL: %s", describe_error (err));
|
b00dfe | 2001-02-05 | Martin Stjernholm | | #endif
}
else {
|
097e18 | 2009-12-09 | Martin Stjernholm | | if (!once_mode) start_tailf();
|
74e390 | 2000-12-30 | Per Hedbor | | connected_ok(1);
return;
}
|
baa9d5 | 2001-01-27 | Per Hedbor | | if( mysql_path_is_remote )
{
report_debug( "******************** FATAL ******************\n"
|
8a79f8 | 2003-02-05 | Jonas Wallden | | "Cannot connect to the specified MySQL server\n"
|
baa9d5 | 2001-01-27 | Per Hedbor | | " Aborting\n"
"******************** FATAL ******************\n" );
exit(1);
}
|
786a22 | 2012-01-19 | Henrik Grubbström (Grubba) | | mkdirhier( mysqldir+"/mysql/" );
|
29ac05 | 2012-01-18 | Henrik Grubbström (Grubba) | | #ifndef __NT__
if (!Stdio.exist(pid_file)) sleep(0.1);
if (Stdio.exist(pid_file)) {
int pid;
int prev_pid = -1;
int cnt;
for (cnt = 0; cnt < 600; cnt++) {
pid = pid ||
(int)String.trim_all_whites(Stdio.read_bytes(pid_file)||"");
if (pid) {
if (!kill(pid, 0) && errno() == System.ESRCH) {
|
0be647 | 2012-01-18 | Henrik Grubbström (Grubba) | | if (prev_pid == pid) {
rm(pid_file);
}
|
29ac05 | 2012-01-18 | Henrik Grubbström (Grubba) | | prev_pid = pid;
pid = 0;
cnt = 0;
sleep(0.1);
continue;
}
} else if (prev_pid) {
prev_pid = 0;
sleep(0.1);
continue;
} else {
break;
}
report_debug("Retrying to connect to local MySQL (pid: %d).\n", pid);
if( mixed err = catch( db = connect_to_my_mysql( 0, "mysql" ) ) ) {
#ifdef MYSQL_CONNECT_DEBUG
werror ("Error connecting to local MySQL: %s", describe_error (err));
#endif
}
else {
if (!once_mode) start_tailf();
connected_ok(1);
return;
}
sleep(0.1);
}
if (pid && (cnt >= 600)) {
report_error("Process %d is claiming to be MySQLd (pid file: %O),\n"
"but doesn't answer to connection attempts.\n",
pid, pid_file);
exit(1);
}
|
786a22 | 2012-01-19 | Henrik Grubbström (Grubba) | | }
|
29ac05 | 2012-01-18 | Henrik Grubbström (Grubba) | | #endif
Stdio.write_file(pid_file, getpid()+"\n");
|
8b3289 | 2003-03-02 | Anders Johansson | | rm( err_log );
|
087029 | 2009-12-10 | Martin Stjernholm | | if (!once_mode) start_tailf();
|
baa9d5 | 2001-01-27 | Per Hedbor | |
|
10732c | 2001-01-10 | Per Hedbor | | if( !file_stat( mysqldir+"/mysql/user.MYD" ) ||
!file_stat( mysqldir+"/mysql/host.MYD" ) ||
!file_stat( mysqldir+"/mysql/db.MYD" ) )
|
74e390 | 2000-12-30 | Per Hedbor | | {
|
710753 | 2001-01-31 | Per Hedbor | | #ifdef DEBUG
|
8a79f8 | 2003-02-05 | Jonas Wallden | | report_debug("MySQL data directory does not exist -- copying template\n");
|
710753 | 2001-01-31 | Per Hedbor | | #endif
|
73c22e | 2002-05-21 | Henrik Grubbström (Grubba) | | if (!file_stat(mysqldir)) {
#ifdef DEBUG
report_debug("Creating directory %O\n", mysqldir);
#endif /* DEBUG */
mkdirhier(combine_path(mysqldir, "../"));
mkdir(mysqldir, 0750);
}
|
15e5c2 | 2001-01-22 | Per Hedbor | | Filesystem.System tar = Filesystem.Tar( "etc/mysql-template.tar" );
|
74e390 | 2000-12-30 | Per Hedbor | | foreach( tar->get_dir( "mysql" ), string f )
{
|
710753 | 2001-01-31 | Per Hedbor | | #ifdef DEBUG
|
74e390 | 2000-12-30 | Per Hedbor | | report_debug("copying "+f+" ... ");
|
710753 | 2001-01-31 | Per Hedbor | | #endif
|
74e390 | 2000-12-30 | Per Hedbor | | Stdio.File to = Stdio.File( mysqldir+f, "wct" );
Stdio.File from = tar->open( f, "r" );
to->write( from->read() );
|
710753 | 2001-01-31 | Per Hedbor | | #ifdef DEBUG
|
74e390 | 2000-12-30 | Per Hedbor | | report_debug("\n");
|
710753 | 2001-01-31 | Per Hedbor | | #endif
|
74e390 | 2000-12-30 | Per Hedbor | | }
}
|
bed50e | 2001-01-21 | Per Hedbor | |
|
654e75 | 2019-11-20 | Henrik Grubbström (Grubba) | | Process.Process mysqld =
low_start_mysql( mysqldir,
|
baa9d5 | 2001-01-27 | Per Hedbor | | #if constant(getpwuid)
|
1fc86c | 2019-11-20 | Henrik Grubbström (Grubba) | | (getpwuid(getuid()) || ({0}))[ 0 ],
|
825cb9 | 2001-01-31 | Per Hedbor | | #else /* Ignored by the start_mysql script */
|
1fc86c | 2019-11-20 | Henrik Grubbström (Grubba) | | 0,
|
baa9d5 | 2001-01-27 | Per Hedbor | | #endif
|
1fc86c | 2019-11-20 | Henrik Grubbström (Grubba) | | log_queries_to_stdout);
|
bed50e | 2001-01-21 | Per Hedbor | |
|
74e390 | 2000-12-30 | Per Hedbor | | int repeat;
while( 1 )
{
|
654e75 | 2019-11-20 | Henrik Grubbström (Grubba) | | if (!mysqld || (mysqld->status() == 2)) {
int ret = mysqld->wait();
werror("\nMySQL failed to start with error code %O. Aborting.\n", ret);
exit(1);
}
|
510bea | 2001-08-09 | Per Hedbor | | sleep( 0.1 );
|
11694b | 2019-11-20 | Henrik Grubbström (Grubba) | |
if( repeat++ > 600 )
|
74e390 | 2000-12-30 | Per Hedbor | | {
|
097e18 | 2009-12-09 | Martin Stjernholm | | if( !do_tailf_threaded && !once_mode ) do_tailf(0, err_log );
|
8a79f8 | 2003-02-05 | Jonas Wallden | | report_fatal("\nFailed to start MySQL. Aborting\n");
|
74e390 | 2000-12-30 | Per Hedbor | | exit(1);
}
|
b00dfe | 2001-02-05 | Martin Stjernholm | | if( mixed err = catch( db = connect_to_my_mysql( 0, "mysql" ) ) ) {
#ifdef MYSQL_CONNECT_DEBUG
|
8a79f8 | 2003-02-05 | Jonas Wallden | | werror ("Error connecting to local MySQL: %s", describe_error (err));
|
b00dfe | 2001-02-05 | Martin Stjernholm | | #endif
}
|
bd3550 | 2006-08-23 | Anders Johansson | | else if (db)
|
510bea | 2001-08-09 | Per Hedbor | | {
|
74e390 | 2000-12-30 | Per Hedbor | | connected_ok(0);
return;
}
}
}
|
c42377 | 2009-03-24 | Henrik Grubbström (Grubba) | | int low_dump( string file, program|void p )
|
8f81d8 | 2001-01-03 | Per Hedbor | | {
|
2cff13 | 2008-08-08 | Martin Stjernholm | | #ifdef ENABLE_DUMPING
|
8f81d8 | 2001-01-03 | Per Hedbor | | if( file[0] != '/' )
|
cefd17 | 2011-12-27 | Martin Stjernholm | | file = server_dir +"/"+ file;
|
8f81d8 | 2001-01-03 | Per Hedbor | | #ifdef __NT__
file = normalize_path( file );
#endif
if(!p)
p = new_master->programs[ replace(file, "//", "/" ) ];
#ifdef __NT__
if( !p )
{
if( sscanf( file, "%*s:/%s", file ) )
{
file = "/"+file;
p = new_master->programs[ replace(file, "//", "/" ) ];
}
}
#endif
array q;
#ifdef MUCHU_DUMP_DEBUG
# define DUMP_DEBUG
#endif
if(!p)
{
#ifdef DUMP_DEBUG
werror(file+" not loaded, and thus cannot be dumped.\n");
#endif
return 0;
}
if( new_master->has_set_on_load[ file ] == 1 )
{
|
3bcf39 | 2001-02-23 | Per Hedbor | | m_delete( new_master->has_set_on_load, file );
|
8f81d8 | 2001-01-03 | Per Hedbor | | if( q = catch( new_master->dump_program( file, p ) ) )
{
#ifdef DUMP_DEBUG
|
080af7 | 2001-03-29 | Per Hedbor | | report_debug("** Cannot encode "+file+": "+describe_error(q)+"\n");
|
8f81d8 | 2001-01-03 | Per Hedbor | | #else
array parts = replace(file, "//", "/") / "/";
if (sizeof(parts) > 3) parts = parts[sizeof(parts)-3..];
report_debug("Notice: Dumping failed for " + parts*"/"+" (not a bug)\n");
#endif
return -1;
}
#ifdef DUMP_DEBUG
werror( file+" dumped successfully\n" );
#endif
return 1;
}
#ifdef MUCHO_DUMP_DEBUG
werror(file+" already dumped (and up to date)\n");
#endif
|
2cff13 | 2008-08-08 | Martin Stjernholm | | #endif // ENABLE_DUMPING
|
8f81d8 | 2001-01-03 | Per Hedbor | | return 0;
}
|
c42377 | 2009-03-24 | Henrik Grubbström (Grubba) | | int dump( string file, program|void p )
{
int res = low_dump(file, p);
return res;
}
|
3e3bab | 2001-01-19 | Per Hedbor | | object(Stdio.Stat)|array(int) da_Stat_type;
|
79ca87 | 2000-11-24 | Per Hedbor | | LocaleString da_String_type;
|
bd5255 | 2018-09-14 | Jonas Walldén | | function orig_predef_describe_bt = predef::describe_backtrace;
|
af81b3 | 2000-02-15 | Henrik Grubbström (Grubba) | | void do_main( int argc, array(string) argv )
|
87d06d | 2000-02-09 | Per Hedbor | | {
|
8ad929 | 2000-03-13 | Martin Nilsson | | array(string) hider = argv;
|
7339a0 | 2000-02-10 | Per Hedbor | | argv = 0;
|
097e18 | 2009-12-09 | Martin Stjernholm | | catch (once_mode = (int)Getopt.find_option(hider + ({}), "o", "once"));
|
8a869b | 2003-09-15 | Martin Stjernholm | | #ifdef GC_TRACE
|
bdc5ae | 2009-11-20 | Martin Stjernholm | | trace (GC_TRACE, "gc");
|
8a869b | 2003-09-15 | Martin Stjernholm | | #endif
|
8b3289 | 2003-03-02 | Anders Johansson | | nwrite = early_nwrite;
|
8f81d8 | 2001-01-03 | Per Hedbor | | add_constant( "connect_to_my_mysql", connect_to_my_mysql );
|
4f74c8 | 2001-08-09 | Per Hedbor | | add_constant( "clear_connect_to_my_mysql_cache",
clear_connect_to_my_mysql_cache );
|
e1f814 | 2015-04-28 | Jonas Walldén | |
#if !constant(thread_create)
report_debug(#"
------ FATAL ----------------------------------------------------
Roxen requires Pike with thread support.
-----------------------------------------------------------------
");
exit(-1);
#endif
|
ed3d53 | 2000-10-30 | Per Hedbor | | #ifdef SECURITY
#if !constant(__builtin.security.Creds)
|
84fff7 | 2014-08-29 | Henrik Grubbström (Grubba) | | report_debug(#"
|
ed3d53 | 2000-10-30 | Per Hedbor | | ------ FATAL ----------------------------------------------------
SECURITY defined (the internal security system in roxen), but
the pike binary has not been compiled --with-security. This makes
it impossible for roxen to have any internal security at all.
-----------------------------------------------------------------
|
84fff7 | 2014-08-29 | Henrik Grubbström (Grubba) | |
|
ed3d53 | 2000-10-30 | Per Hedbor | | ");
exit(-1);
#endif
#endif
|
1768d3 | 2000-03-09 | Per Hedbor | | if( (-1&0xffffffff) < 0 )
{
|
84fff7 | 2014-08-29 | Henrik Grubbström (Grubba) | | report_debug(#"
|
234e79 | 2000-09-23 | Henrik Grubbström (Grubba) | | ------- WARNING -----------------------------------------------
|
f0c991 | 2004-04-26 | Henrik Grubbström (Grubba) | | Roxen requires bignum support in Pike since version 2.4.
|
8a79f8 | 2003-02-05 | Jonas Wallden | | Please recompile Pike with gmp / bignum support to run Roxen.
|
1768d3 | 2000-03-09 | Per Hedbor | |
|
8a79f8 | 2003-02-05 | Jonas Wallden | | It might still be possible to start Roxen, but the
functionality will be affected, and stange errors might occur.
|
234e79 | 2000-09-23 | Henrik Grubbström (Grubba) | | ---------------------------------------------------------------
|
1768d3 | 2000-03-09 | Per Hedbor | |
|
84fff7 | 2014-08-29 | Henrik Grubbström (Grubba) | |
|
1768d3 | 2000-03-09 | Per Hedbor | | ");
}
|
23c642 | 1999-11-29 | Per Hedbor | | #ifdef NOT_INSTALLED
|
84fff7 | 2014-08-29 | Henrik Grubbström (Grubba) | | report_debug(#"
|
ae46e9 | 2000-09-23 | Per Hedbor | | ------- WARNING -----------------------------------------------
|
8a79f8 | 2003-02-05 | Jonas Wallden | | You are running with an un-installed Pike binary.
|
23c642 | 1999-11-29 | Per Hedbor | |
|
58a643 | 1999-12-20 | Martin Nilsson | | Please note that this is unsupported, and might stop working at
|
23c642 | 1999-11-29 | Per Hedbor | | any time, since some things are done differently in uninstalled
|
8a79f8 | 2003-02-05 | Jonas Wallden | | Pikes, as an example the module search paths are different, and
|
23c642 | 1999-11-29 | Per Hedbor | | some environment variables are ignored.
|
ae46e9 | 2000-09-23 | Per Hedbor | | ---------------------------------------------------------------
|
23c642 | 1999-11-29 | Per Hedbor | |
|
84fff7 | 2014-08-29 | Henrik Grubbström (Grubba) | |
|
23c642 | 1999-11-29 | Per Hedbor | | ");
#endif
|
c74511 | 2014-10-21 | Henrik Grubbström (Grubba) | | #if __VERSION__ < 8.0
|
84fff7 | 2014-08-29 | Henrik Grubbström (Grubba) | | report_debug(#"
|
23c642 | 1999-11-29 | Per Hedbor | |
|
58a643 | 1999-12-20 | Martin Nilsson | | ******************************************************
|
c74511 | 2014-10-21 | Henrik Grubbström (Grubba) | | Roxen " + roxen_ver + #" requires Pike 8.0 or newer.
|
234e79 | 2000-09-23 | Henrik Grubbström (Grubba) | | Please install a newer version of Pike.
|
58a643 | 1999-12-20 | Martin Nilsson | | ******************************************************
|
23c642 | 1999-11-29 | Per Hedbor | |
");
|
af81b3 | 2000-02-15 | Henrik Grubbström (Grubba) | | _exit(0);
|
c74511 | 2014-10-21 | Henrik Grubbström (Grubba) | | #endif /* __VERSION__ < 8.0 */
|
1dc04b | 2001-08-24 | Martin Stjernholm | |
#if !constant (Mysql.mysql)
report_debug (#"
******************************************************
|
f0c991 | 2004-04-26 | Henrik Grubbström (Grubba) | | Roxen requires MySQL support in Pike since version 2.4.
|
1dc04b | 2001-08-24 | Martin Stjernholm | | Your Pike has been compiled without support for MySQL.
Please install MySQL client libraries and reconfigure
|
b23a63 | 2009-02-12 | Martin Stjernholm | | and rebuild Pike from source.
|
1dc04b | 2001-08-24 | Martin Stjernholm | | ******************************************************
");
_exit(0);
#endif // !constant (Mysql.mysql)
|
23c642 | 1999-11-29 | Per Hedbor | |
|
e2468a | 2012-11-14 | Stefan Wallström | | #if !constant (Regexp.PCRE)
report_debug (#"
******************************************
|
fb4690 | 2021-11-03 | Henrik Grubbström (Grubba) | | Roxen requires Regexp.PCRE support in Pike.
|
e2468a | 2012-11-14 | Stefan Wallström | | ******************************************
");
_exit(0);
#endif // !constant (Regexp.PCRE)
|
fb4690 | 2021-11-03 | Henrik Grubbström (Grubba) | | #if !constant (Crypto.SHA256)
report_debug (#"
********************************************
Roxen requires Crypto.SHA256 support in Pike.
Please check that you have Nettle installed.
********************************************
");
_exit(0);
#endif // !constant (Crypto.SHA256)
#if !constant (Crypto.AES.GCM)
report_debug (#"
*********************************************
Roxen requires Crypto.AES.GCM support in Pike.
Please check that your Nettle is version 2.2
or later.
*********************************************
");
_exit(0);
#endif // !constant (Crypto.AES.GCM)
#if !constant (Crypto.ECC.Curve)
report_debug (#"
***********************************************
Roxen requires Crypto.ECC.Curve support in Pike.
Please check that your Nettle is version 2.7 or
later, and has been compiled with a supported
version of Gmp.
***********************************************
");
_exit(0);
#endif // !constant (Crypto.ECC.Curve)
|
e2468a | 2012-11-14 | Stefan Wallström | |
|
d5c852 | 2016-06-29 | Henrik Grubbström (Grubba) | | string s;
if (!catch(s = _Roxen->make_http_headers((["a\r\n":"b\r\n"]), 1)) &&
(sizeof(s/"\r\n") > 2)) {
|
16bb3e | 2005-10-28 | Henrik Grubbström (Grubba) | | add_constant("HAVE_OLD__Roxen_make_http_headers", 1);
report_debug(#"
------- WARNING -----------------------------------------------
Old or broken _Roxen.make_http_headers() detected.
|
81d0e7 | 2016-07-01 | Henrik Grubbström (Grubba) | | Roxen 6.0 prefers Pike 8.0.270 or later.
|
16bb3e | 2005-10-28 | Henrik Grubbström (Grubba) | | Roxen will still work, but at lower performance.
Please install a newer version of Pike.
---------------------------------------------------------------
");
}
|
99da85 | 2005-11-14 | Henrik Grubbström (Grubba) | | Stdio.Stat stat = file_stat("etc/include/version.h");
if (stat && (stat->mtime > time())) {
report_debug(#"
------- WARNING -----------------------------------------------
System time is incorrect.
System time: %s
Check time: %s
This may cause unreliable operation. Please set
the correct system time.
---------------------------------------------------------------
", ctime(stat->mtime), ctime(time(1)));
}
|
af81b3 | 2000-02-15 | Henrik Grubbström (Grubba) | | int start_time = gethrtime();
|
1e3d62 | 1997-02-18 | Niels Möller | | string path = make_path("base_server", "etc/include", ".");
|
930ddd | 1999-08-06 | Per Hedbor | | last_was_nl = 1;
|
4f8bbe | 2003-03-25 | Jonas Wallden | | mapping un = uname();
string hostinfo =
(un->sysname || "") + " " + (un->release || "") +
(un->machine ? (" (" + un->machine + ")") : "");
|
99da85 | 2005-11-14 | Henrik Grubbström (Grubba) | | string pike_ver = version();
if ((__REAL_MAJOR__ != __MAJOR__) ||
(__REAL_MINOR__ != __MINOR__)) {
pike_ver += sprintf(" (in Pike %d.%d compat mode)",
__MAJOR__, __MINOR__);
}
|
4f8bbe | 2003-03-25 | Jonas Wallden | | report_debug("-" * 65 + "\n"
|
99da85 | 2005-11-14 | Henrik Grubbström (Grubba) | | "Pike version: " + pike_ver + "\n"
|
4f8bbe | 2003-03-25 | Jonas Wallden | | "Product version: " + roxen_product_name + " " + roxen_version() + "\n"
"Operating system: " + hostinfo + "\n");
|
1e3d62 | 1997-02-18 | Niels Möller | | master()->putenv("PIKE_INCLUDE_PATH", path);
|
f6250b | 1998-03-28 | Henrik Grubbström (Grubba) | | foreach(path/":", string p) {
add_include_path(p);
|
b796b5 | 1998-11-18 | Per Hedbor | | add_program_path(p);
|
f6250b | 1998-03-28 | Henrik Grubbström (Grubba) | | }
|
8cb783 | 1999-03-27 | Henrik Grubbström (Grubba) | |
|
07e2cc | 2001-12-04 | Martin Stjernholm | | add_constant ("get_cvs_id", get_cvs_id);
add_constant ("add_cvs_ids", add_cvs_ids);
add_constant ("describe_backtrace", describe_backtrace);
|
b5e3b0 | 2010-05-19 | Fredrik Noring | | add_constant ("call_out", call_out);
|
07e2cc | 2001-12-04 | Martin Stjernholm | |
|
4446d8 | 1999-12-07 | Henrik Grubbström (Grubba) | | #ifdef INTERNAL_ERROR_DEBUG
add_constant("throw", paranoia_throw);
#endif /* INTERNAL_ERROR_DEBUG */
|
9eeb5c | 2000-05-22 | Per Hedbor | | add_constant( "mark_fd", mark_fd );
|
22c98c | 2001-08-13 | Per Hedbor | | add_constant( "isodate", isodate );
|
9eeb5c | 2000-05-22 | Per Hedbor | |
|
79ca87 | 2000-11-24 | Per Hedbor | | add_constant( "LocaleString", typeof(da_String_type) );
|
3e3bab | 2001-01-19 | Per Hedbor | | add_constant( "Stat", typeof(da_Stat_type) );
|
79ca87 | 2000-11-24 | Per Hedbor | |
|
af81b3 | 2000-02-15 | Henrik Grubbström (Grubba) | | mixed err;
|
8f81d8 | 2001-01-03 | Per Hedbor | | add_constant("open", open);
add_constant("roxen_path", roxen_path);
|
e30cf4 | 2000-03-13 | Per Hedbor | | add_constant("roxen_version", roxen_version);
|
5a272a | 2002-05-07 | Jonas Wallden | | add_constant("roxen_dist_version", dist_version);
|
88edde | 2009-04-20 | Jonas Wallden | | add_constant("roxen_dist_os", dist_os);
|
93963e | 2002-03-19 | Martin Stjernholm | | add_constant("roxen_release", release || roxen_release);
|
cdddcb | 2002-04-08 | Johan Schön | | add_constant("roxen_is_cms", roxen_is_cms);
add_constant("roxen_product_name", roxen_product_name);
|
a01b5d | 2013-08-19 | Tobias Liin | | add_constant("roxen_product_code", roxen_product_code);
|
8f81d8 | 2001-01-03 | Per Hedbor | | add_constant("lopen", lopen);
|
b395ab | 2008-02-05 | Henrik Grubbström (Grubba) | | add_constant("lfile_stat", lfile_stat);
|
adbc52 | 2011-01-20 | Henrik Grubbström (Grubba) | | add_constant("lfile_path", lfile_path);
|
22a835 | 2021-11-22 | Henrik Grubbström (Grubba) | | add_constant("lget_dir", lget_dir);
|
e30cf4 | 2000-03-13 | Per Hedbor | | add_constant("report_notice", report_notice);
|
8f81d8 | 2001-01-03 | Per Hedbor | | add_constant("report_debug", report_debug);
add_constant("report_warning",report_warning);
add_constant("report_error", report_error);
add_constant("report_fatal", report_fatal);
|
c5b951 | 2009-12-20 | Martin Stjernholm | | add_constant("report_notice_for", report_notice_for);
add_constant("report_warning_for", report_warning_for);
add_constant("report_error_for", report_error_for);
add_constant("report_fatal_for", report_fatal_for);
|
8daece | 2001-02-05 | Martin Stjernholm | | add_constant("report_warning_sparsely", report_warning_sparsely);
add_constant("report_error_sparsely", report_error_sparsely);
|
8f81d8 | 2001-01-03 | Per Hedbor | | add_constant("werror", roxen_perror);
|
d67340 | 2002-01-28 | Martin Stjernholm | | add_constant("perror", roxen_perror);
|
8f81d8 | 2001-01-03 | Per Hedbor | | add_constant("roxen_perror", roxen_perror);
|
0d7947 | 2020-12-14 | Henrik Grubbström (Grubba) | | add_constant("register_roxen_perror_output",
register_roxen_perror_output);
add_constant("unregister_roxen_perror_output",
unregister_roxen_perror_output);
|
8f81d8 | 2001-01-03 | Per Hedbor | | add_constant("roxenp", lambda() { return roxen; });
add_constant("ST_MTIME", ST_MTIME );
add_constant("ST_CTIME", ST_CTIME );
add_constant("ST_SIZE", ST_SIZE );
add_constant("mkdirhier", mkdirhier );
#if !constant(uname)
|
51ba6d | 2000-04-12 | Per Hedbor | | add_constant( "uname", uname );
|
8f81d8 | 2001-01-03 | Per Hedbor | | #endif
#ifdef __NT__
|
51ba6d | 2000-04-12 | Per Hedbor | | add_constant( "getuid", lambda(){ return 0; } );
add_constant( "getgid", lambda(){ return 0; } );
add_constant( "geteuid", lambda(){ return 0; } );
add_constant( "getegid", lambda(){ return 0; } );
#endif
|
8f81d8 | 2001-01-03 | Per Hedbor | | add_constant("r_rm", rm);
add_constant("r_mv", mv);
|
2d3cd8 | 2011-12-28 | Martin Stjernholm | | add_constant("r_cp", r_cp);
|
8f81d8 | 2001-01-03 | Per Hedbor | | add_constant("r_get_dir", r_get_dir);
add_constant("r_file_stat", file_stat);
|
2d3cd8 | 2011-12-28 | Martin Stjernholm | | add_constant("r_is_file", r_is_file);
add_constant("r_is_dir", r_is_dir);
add_constant("r_is_link", r_is_link);
add_constant("r_exist", r_exist);
add_constant("r_read_bytes", r_read_bytes);
|
8f81d8 | 2001-01-03 | Per Hedbor | | add_constant("roxenloader", this_object());
add_constant("ErrorContainer", ErrorContainer);
|
e41c9d | 2017-04-21 | Henrik Grubbström (Grubba) | | #ifdef THREADS
add_constant("euid_egid_lock", euid_egid_lock);
#endif
#ifndef __NT__
if(!getuid())
add_constant("Privs", Privs);
else
#endif /* !__NT__ */
add_constant("Privs", class {
void create(string reason, int|string|void uid, int|string|void gid) {}
});
|
3c6d94 | 2001-06-25 | Martin Stjernholm | | add_constant("_cur_rxml_context", Thread.Local());
|
846a91 | 2017-09-29 | Henrik Grubbström (Grubba) | | int mysql_only_mode =
(int)Getopt.find_option(hider, "mysql-only", ({ "mysql-only" }));
if (mysql_only_mode) {
once_mode = 1;
}
|
c5e97b | 2009-06-25 | Martin Stjernholm | | if (has_value (hider, "--mysql-log-queries")) {
hider -= ({"--mysql-log-queries"});
argc = sizeof (hider);
start_mysql (1);
}
else
start_mysql (0);
|
74e390 | 2000-12-30 | Per Hedbor | |
|
846a91 | 2017-09-29 | Henrik Grubbström (Grubba) | | if (mysql_only_mode) {
exit(0);
}
|
af81b3 | 2000-02-15 | Henrik Grubbström (Grubba) | | if (err = catch {
|
342c0f | 2001-09-03 | Marcus Comstedt | | if(master()->relocate_module) add_constant("PIKE_MODULE_RELOC", 1);
|
8ad929 | 2000-03-13 | Martin Nilsson | | replace_master(new_master=[object(__builtin.__master)](((program)"etc/roxen_master.pike")()));
|
af81b3 | 2000-02-15 | Henrik Grubbström (Grubba) | | }) {
|
ed3d53 | 2000-10-30 | Per Hedbor | | werror("Initialization of Roxen's master failed:\n"
"%s\n", describe_backtrace(err));
|
af81b3 | 2000-02-15 | Henrik Grubbström (Grubba) | | exit(1);
}
|
5e8921 | 1997-02-13 | Per Hedbor | |
|
6ba1c0 | 2010-05-06 | Henrik Grubbström (Grubba) | |
add_constant ("describe_backtrace", describe_backtrace);
|
8f81d8 | 2001-01-03 | Per Hedbor | |
|
5c27a2 | 2000-09-23 | Per Hedbor | | #if constant( Gz.inflate )
|
6465b9 | 2000-09-27 | Per Hedbor | | add_constant("grbz",lambda(string d){return Gz.inflate()->inflate(d);});
|
5c27a2 | 2000-09-23 | Per Hedbor | | #else
|
6465b9 | 2000-09-27 | Per Hedbor | | add_constant("grbz",lambda(string d){return d;});
|
84fff7 | 2014-08-29 | Henrik Grubbström (Grubba) | | report_debug(#"
|
b7c64a | 2000-09-23 | Per Hedbor | | ------- WARNING -----------------------------------------
The Gz (zlib) module is not available.
The default builtin font will not be available.
To get zlib support, install zlib from
ftp://ftp.freesoftware.com/pub/infozip/zlib/zlib.html
and recompile pike, after removing the file 'config.cache'
----------------------------------------------------------
|
84fff7 | 2014-08-29 | Henrik Grubbström (Grubba) | |
|
b7c64a | 2000-09-23 | Per Hedbor | | ");
|
5c27a2 | 2000-09-23 | Per Hedbor | | #endif
|
e3ad9c | 1997-04-11 | Peter Bortas | | add_constant("spawne",spawne);
|
51ff83 | 1997-05-13 | Marcus Comstedt | | add_constant("spawn_pike",spawn_pike);
|
e3ad9c | 1997-04-11 | Peter Bortas | | add_constant("popen",popen);
|
8c26b7 | 1998-07-13 | Henrik Grubbström (Grubba) | | add_constant("roxen_popen",popen);
|
b1fca0 | 1996-11-12 | Per Hedbor | | add_constant("init_logger", init_logger);
|
19924b | 2001-08-24 | Martin Nilsson | | add_constant("capitalize", String.capitalize);
|
40dd28 | 1999-11-23 | Per Hedbor | |
|
68e2e2 | 2000-02-02 | Martin Stjernholm | |
#if constant (Image.TTF)
if (sizeof (indices (Image.TTF)))
|
61c0ef | 2000-02-16 | Per Hedbor | | {
|
68e2e2 | 2000-02-02 | Martin Stjernholm | | add_constant ("has_Image_TTF", 1);
|
61c0ef | 2000-02-16 | Per Hedbor | | add_constant( "Image.TTF", Image.TTF );
|
425fc6 | 2000-09-21 | Per Hedbor | |
add_constant("__rbf", "font_handlers/rbf" );
|
39ba6c | 2004-06-24 | Henrik Grubbström (Grubba) | | } else
#endif
{
|
d6216d | 2001-05-07 | Per Hedbor | | #if constant(Image.FreeType.Face)
|
39ba6c | 2004-06-24 | Henrik Grubbström (Grubba) | |
add_constant("__rbf", "font_handlers/rbf" );
|
5c27a2 | 2000-09-23 | Per Hedbor | | #else
|
84fff7 | 2014-08-29 | Henrik Grubbström (Grubba) | | report_debug(#"
|
b7c64a | 2000-09-23 | Per Hedbor | | ------- WARNING ----------------------------------------------
|
f0c991 | 2004-04-26 | Henrik Grubbström (Grubba) | | Neither the Image.TTF nor the Image.FreeType module is available.
True Type fonts and the default font will not be available.
To get True Type support, download a Freetype package from
|
b7c64a | 2000-09-23 | Per Hedbor | |
|
f0c991 | 2004-04-26 | Henrik Grubbström (Grubba) | | http://freetype.sourceforge.net/download.html
|
b7c64a | 2000-09-23 | Per Hedbor | |
|
5c27a2 | 2000-09-23 | Per Hedbor | | Install it, and then remove config.cache in pike and recompile.
If this was a binary release of Roxen, there should be no need
|
b7c64a | 2000-09-23 | Per Hedbor | | to recompile the pike binary, since the one included should
already have the FreeType interface module, installing the
library should be enough.
--------------------------------------------------------------
|
84fff7 | 2014-08-29 | Henrik Grubbström (Grubba) | |
|
b7c64a | 2000-09-23 | Per Hedbor | | " );
|
d6216d | 2001-05-07 | Per Hedbor | | #endif
|
39ba6c | 2004-06-24 | Henrik Grubbström (Grubba) | | }
|
4d36bb | 2000-01-25 | Per Hedbor | |
|
7339a0 | 2000-02-10 | Per Hedbor | | if( search( hider, "--long-error-file-names" ) != -1 )
|
1e9e09 | 1999-12-21 | Per Hedbor | | {
|
7339a0 | 2000-02-10 | Per Hedbor | | hider -= ({ "--long-error-file-names" });
argc = sizeof(hider);
|
1e9e09 | 1999-12-21 | Per Hedbor | | new_master->putenv("LONG_PIKE_ERRORS", "yup");
}
|
c676b1 | 2015-04-21 | Henrik Grubbström (Grubba) | | array(string) patches = get_dir("patches");
if (patches && sizeof(patches)) {
report_debug("Installed patches:\n");
foreach(sort(patches), string patch) {
report_debug(" %s\n", patch);
}
report_debug("\n");
}
|
1d9cfb | 2000-02-14 | Per Hedbor | |
|
8a79f8 | 2003-02-05 | Jonas Wallden | | report_debug("Loading Pike modules ... \b");
|
159041 | 2000-02-16 | Per Hedbor | |
|
50b697 | 2001-08-31 | Per Hedbor | | add_dump_constant = new_master->add_dump_constant;
|
159041 | 2000-02-16 | Per Hedbor | | int t = gethrtime();
|
080af7 | 2001-03-29 | Per Hedbor | |
|
a366a5 | 2001-09-06 | Per Hedbor | | DC("Thread.Thread"); DC("Thread.Local");
DC("Thread.Mutex"); DC("Thread.MutexKey");
DC("Thread.Condition"); DC("thread_create");
DC( "Thread.Queue" );
|
b56620 | 2001-10-05 | Per Hedbor | | DC("Sql"); DC("Sql.mysql");
|
5574b2 | 2002-05-06 | Martin Stjernholm | | DC ("String.Buffer");
|
b56620 | 2001-10-05 | Per Hedbor | |
|
94d7b0 | 2001-10-15 | Henrik Grubbström (Grubba) | | #if constant(Oracle.oracle)
|
b56620 | 2001-10-05 | Per Hedbor | | DC("Sql.oracle");
#endif
|
94d7b0 | 2001-10-15 | Henrik Grubbström (Grubba) | | #if constant(Odbc.odbc)
|
b56620 | 2001-10-05 | Per Hedbor | | DC("Sql.odbc");
#endif
|
5860ed | 2001-09-06 | Per Hedbor | |
|
0b6ae0 | 2001-09-06 | Jonas Wallden | | DC( "_Roxen.HeaderParser" );
|
a366a5 | 2001-09-06 | Per Hedbor | | DC( "Protocols.HTTP" ); DC( "Protocols.HTTP.Query" );
|
59c6ff | 2001-08-09 | Per Hedbor | |
|
a366a5 | 2001-09-06 | Per Hedbor | | DC( "Calendar.ISO" ); DC( "Calendar.ISO.Second" );
|
59c6ff | 2001-08-09 | Per Hedbor | |
|
080af7 | 2001-03-29 | Per Hedbor | | DC( "Stdio.Stat" );
|
e7c2d4 | 2000-04-03 | Per Hedbor | |
|
080af7 | 2001-03-29 | Per Hedbor | | DC( "Regexp" );
|
1d9cfb | 2000-02-14 | Per Hedbor | |
|
080af7 | 2001-03-29 | Per Hedbor | | DC( "Pipe.pipe" );
|
1d9cfb | 2000-02-14 | Per Hedbor | |
|
080af7 | 2001-03-29 | Per Hedbor | |
foreach( ({ "ANY", "XCF", "PSD", "PNG", "BMP", "TGA", "PCX",
"XBM", "XPM", "TIFF", "ILBM", "PS", "PVR", "GIF",
"JPEG", "XWD", "PNM", "RAS", "DSI", "TIM", "HRZ",
"AVS", "WBF", "WBMP", "XFace" }),
string x )
DC("Image."+x);
|
a366a5 | 2001-09-06 | Per Hedbor | | DC( "Image.Image" ); DC( "Image.Font" ); DC( "Image.Colortable" );
DC( "Image.Layer" ); DC( "Image.lay" ); DC( "Image.Color" );
DC( "Image.Color.Color" );DC("Image._PSD" ); DC("Image._XCF" );
|
5574b2 | 2002-05-06 | Martin Stjernholm | | DC ("Image.Color.black");
|
a366a5 | 2001-09-06 | Per Hedbor | | DC( "Image._XPM" ); DC( "Image" );
if( DC("Image.GIF.encode") )
DC( "Image.GIF.encode_trans" );
|
080af7 | 2001-03-29 | Per Hedbor | |
DC( "Stdio.File" ); DC( "Stdio.UDP" ); DC( "Stdio.Port" );
DC( "Stdio.read_bytes" ); DC( "Stdio.read_file" );
DC( "Stdio.write_file" );
|
50b697 | 2001-08-31 | Per Hedbor | |
|
080af7 | 2001-03-29 | Per Hedbor | | DC( "Stdio.sendfile" );
DC( "Stdio.stderr" ); DC( "Stdio.stdin" ); DC( "Stdio.stdout" );
DC( "Parser.HTML" );
|
e554ad | 2015-06-17 | Henrik Grubbström (Grubba) | | if( DC("SSL.File" ) )
|
080af7 | 2001-03-29 | Per Hedbor | | {
DC( "SSL.context" );
DC( "Tools.PEM.pem_msg" );
|
fc4039 | 2008-08-15 | Martin Stjernholm | | DC( "Crypto.Random.random_string" );
|
080af7 | 2001-03-29 | Per Hedbor | | DC( "Standards.PKCS.RSA.parse_private_key");
|
fc4039 | 2008-08-15 | Martin Stjernholm | | DC( "Crypto.RSA" );
|
080af7 | 2001-03-29 | Per Hedbor | | DC( "Tools.X509.decode_certificate" );
DC( "Standards.PKCS.DSA.parse_private_key" );
DC( "SSL.cipher.dh_parameters" );
}
if( DC( "HTTPLoop.prog" ) )
DC( "HTTPLoop.Loop" );
if( DC( "Image.FreeType" ) )
DC( "Image.FreeType.Face" );
DC( "Process.create_process" );
|
a366a5 | 2001-09-06 | Per Hedbor | | DC( "MIME.Message" ); DC( "MIME.encode_base64" );
|
080af7 | 2001-03-29 | Per Hedbor | | DC( "MIME.decode_base64" );
|
50aa16 | 2015-04-28 | Jonas Walldén | | DC( "Locale" );
DC( "Charset" );
|
080af7 | 2001-03-29 | Per Hedbor | |
|
56509c | 2001-06-30 | Martin Stjernholm | | report_debug("\bDone [%.1fms]\n", (gethrtime()-t)/1000.0);
|
1d9cfb | 2000-02-14 | Per Hedbor | |
|
159041 | 2000-02-16 | Per Hedbor | | add_constant( "hsv_to_rgb", nm_resolv("Colors.hsv_to_rgb") );
add_constant( "rgb_to_hsv", nm_resolv("Colors.rgb_to_hsv") );
add_constant( "parse_color", nm_resolv("Colors.parse_color") );
add_constant( "color_name", nm_resolv("Colors.color_name") );
add_constant( "colors", nm_resolv("Colors") );
|
7ba70c | 2000-07-09 | Per Hedbor | |
|
e24055 | 2013-03-08 | Henrik Grubbström (Grubba) | | add_constant("verify_password", verify_password);
add_constant("crypt_password", crypt_password);
|
c42377 | 2009-03-24 | Henrik Grubbström (Grubba) | |
|
080af7 | 2001-03-29 | Per Hedbor | |
object prototypes = (object)"base_server/prototypes.pike";
dump( "base_server/prototypes.pike", object_program( prototypes ) );
|
8cedaa | 2004-05-07 | Martin Stjernholm | | foreach (indices (prototypes), string id)
if (!prototypes->ignore_identifiers[id])
add_constant (id, prototypes[id]);
|
c42377 | 2009-03-24 | Henrik Grubbström (Grubba) | |
|
c2d7aa | 2004-04-13 | Martin Stjernholm | | prototypes->Roxen = master()->resolv ("Roxen");
|
c42377 | 2009-03-24 | Henrik Grubbström (Grubba) | |
|
c2d7aa | 2004-04-13 | Martin Stjernholm | |
|
c42377 | 2009-03-24 | Henrik Grubbström (Grubba) | |
|
4d1c5f | 2001-07-26 | Martin Stjernholm | | object cache = initiate_cache();
|
c42377 | 2009-03-24 | Henrik Grubbström (Grubba) | |
|
b1fca0 | 1996-11-12 | Per Hedbor | | load_roxen();
|
5574b2 | 2002-05-06 | Martin Stjernholm | |
|
7339a0 | 2000-02-10 | Per Hedbor | | int retval = roxen->main(argc,hider);
|
4d1c5f | 2001-07-26 | Martin Stjernholm | | cache->init_call_outs();
|
159041 | 2000-02-16 | Per Hedbor | | report_debug("-- Total boot time %2.1f seconds ---------------------------\n",
|
f0e0e6 | 1998-03-20 | Per Hedbor | | (gethrtime()-start_time)/1000000.0);
|
26d796 | 1999-09-25 | Martin Stjernholm | | write_current_time();
|
87d06d | 2000-02-09 | Per Hedbor | | if( retval > -1 )
|
c348db | 2003-09-15 | Martin Stjernholm | | trace_exit( retval );
|
87d06d | 2000-02-09 | Per Hedbor | | return;
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
6533f2 | 2001-08-23 | Martin Nilsson | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|
2d3cd8 | 2011-12-28 | Martin Stjernholm | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|
2d3cd8 | 2011-12-28 | Martin Stjernholm | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|
2d3cd8 | 2011-12-28 | Martin Stjernholm | |
|
19924b | 2001-08-24 | Martin Nilsson | |
|