[DGD] some klib code error?
Lee Jia
bobolijia at gmail.com
Wed Oct 24 15:35:59 CEST 2007
kernel\lib\wiztool.c
----------------------------------------
static object compile_object(string path, string source...)
{
int kernel;
path = driver->normalize_path(path, directory, owner);
kernel = sscanf(path, "/kernel/%*s");
if ((sizeof(source) != 0 && kernel) ||
!access(owner, path,
((sscanf(path, "%*s" + INHERITABLE_SUBDIR) != 0 ||
!driver->creator(path)) && sizeof(source) == 0 && !kernel) ?
READ_ACCESS : WRITE_ACCESS)) {
message(path + ": Permission denied.\n");
return nil;
}
return (sizeof(source) != 0) ?
::compile_object(path, source...) : ::compile_object(path);
}
================================================
auto.c
---------------------------------------
static object compile_object(string path, string source...)
{
string oname, uid;
object driver, rsrcd, obj;
int *rsrc, lib, kernel, new, stack, ticks;
CHECKARG(path, 1, "compile_object");
if (!this_object()) {
error("Permission denied");
}
/*
* check access
*/
oname = object_name(this_object());
driver = ::find_object(DRIVER);
path = driver->normalize_path(path, oname + "/..", creator);
lib = sscanf(path, "%*s" + INHERITABLE_SUBDIR);
kernel = sscanf(path, "/kernel/%*s");
uid = driver->creator(path);
if ((sizeof(source) != 0 && kernel) ||
(creator != "System" &&
!::find_object(ACCESSD)->access(oname, path,
((lib || !uid) &&
sizeof(source) == 0 && !kernel) ?
READ_ACCESS : WRITE_ACCESS))) {
error("Access denied");
}
/*
* check resource usage
*/
rsrcd = ::find_object(RSRCD);
rsrc = rsrcd->rsrc_get(uid, "objects");
if (rsrc[RSRC_USAGE] >= rsrc[RSRC_MAX] && rsrc[RSRC_MAX] >= 0) {
error("Too many objects");
}
/*
* do the compiling
*/
new = !::find_object(path);
stack = ::status()[ST_STACKDEPTH];
ticks = ::status()[ST_TICKS];
rlimits (-1; -1) {
catch {
if (new && !lib) {
if ((stack >= 0 &&
stack - 2 < rsrcd->rsrc_get(uid,
"create stack")[RSRC_MAX]) ||
(ticks >= 0 &&
ticks < rsrcd->rsrc_get(uid, "create ticks")[RSRC_MAX])) {
error("Insufficient stack or ticks to create object");
}
}
driver->compiling(path);
if (sizeof(source) != 0) {
obj = ::compile_object(path, source...);
} else {
obj = ::compile_object(path);
}
if (new) {
rsrcd->rsrc_incr(uid, "objects", nil, 1, TRUE);
}
if (lib) {
driver->compile_lib(path, uid, source...);
} else {
driver->compile(obj, uid, source...);
}
} : {
driver->compile_failed(path, uid);
rlimits (stack; ticks) {
error(TLSVAR2);
}
}
}
if (new && !lib) {
call_other(obj, "???"); /* initialize & register */
}
return (lib) ? nil : obj;
}
-----------------------------------------------
I think it is not "source" but "source...",right?
More information about the DGD
mailing list