call_other.c

MudOSa4DGD/mudlib/dgd/lib/sys/kfun/call_other.c · 1.9 KB

From the archive MudOSa4DGD-30.06.98.tar.gz

Download the archive   « Back to the archive contents

/*
 * call_other.c
 *
 * possibly override call_other to emulate MudOS some
 *
 * (C) Frank Schmidt, Jesus@NorseMUD
 *
 */


/* call another object failing all DRIVER_PRIV and AUTO_PRIV checks */
static varargs mixed __call_other(mixed var1, mixed var2, mixed args...) {
  return ::call_other(var1, var2, args...);
}


/* call any local function, may be static (driver objects only) */
nomask varargs mixed __call_local(string func, mixed args...) {
  if (DRIVER_PRIV()) {
    return ::call_other(this_object(), func, args...);
  }
  else
    illegal();
}



/* THIS DEFINE IS NOT RECOMMENDED DUE TO PERFORMANCE CONCERNS! */
#ifdef MUDOS_CALL_OTHER_ARRAY

/* call a function in another object, may be an array of objects */
static varargs mixed call_other(mixed var1, mixed var2, mixed args...) {
  if (!arrayp(var1)) {
    /* EXTRA BUT NEEDED DRIVER SECURITY / CPU HOGGER */
    if (!IS_DRIVER_SOURCE(previous_program())) {
      string file;
      if (objectp(var1)) file = object_name(var1);
      else file = var1;
      if (IS_DRIVER_SOURCE(file)) {
	/* illegal: non-DriverLib object calling DriverLib object */
	error("Illegal call_other()!");
	return 0;
      }
    }
    return ::call_other(var1, var2, args...);
  }
  else {
    int sz;
    if ((sz=::sizeof(var1)) > 0) {
      int i;
      mixed *rets;
      for (rets = allocate(sz); i < sz; ++i) {
	mixed ob;
	if (ob=var1[i]) {
	  /* EXTRA BUT NEEDED DRIVER SECURITY / CPU HOGGER */
	  if (!IS_DRIVER_SOURCE(previous_program())) {
	    string file;
	    if (objectp(ob)) file = object_name(ob);
	    else file = ob;
	    if (IS_DRIVER_SOURCE(file)) {
	      /* illegal: non-DriverLib object calling DriverLib object */
	      error("Illegal call_other()!");
	      return 0;
	    }
	  }
	  rets[i] = ::call_other(ob, var2, args...);
	}
      }
      /* return array of returned values */
      return rets;
    }
    else
      return ({ });
  }
}

#endif

Site Stats

Snippets: 1791
Codebases: 571