/* Copyright 1989, 1990 by James Aspnes, David Applegate, and Bennet Yee */ /* See the file COPYING for distribution information */ #include "db.h" datum flag_set(datum x, datum flag) { struct object *o; return ((o = object(x)) != 0 && (o->flags & flag) != 0); } datum controls(datum x, datum thing) { struct object *o; struct object *t; if(x == thing) { return 1; } else if((t = object(thing)) == 0 || oflag_set(t, F_ADMIN) || (o = object(x)) == 0) { return 0; } else { return (oflag_set(o, F_WIZARD) || (o->owner == t->owner && !oflag_set(t, F_WIZARD))); } } /* datum can_read(datum x, datum thing) { return flag_set(thing, F_PUBLIC) || controls(x, thing); } */ /* returns 1 if a is an ancestor of x */ datum is_ancestor(datum x, datum a) { for(;;) { if(x == a) return 1; if(x == NOTHING) return 0; x = safe_get(x, parent); } }