MudOSa4DGD/
MudOSa4DGD/bin/
MudOSa4DGD/data/
MudOSa4DGD/doc/
MudOSa4DGD/doc/driver/
MudOSa4DGD/doc/efun/bitstrings/
MudOSa4DGD/doc/efun/command/
MudOSa4DGD/doc/efun/communication/
MudOSa4DGD/doc/efun/heart_beat/
MudOSa4DGD/doc/efun/interactive/
MudOSa4DGD/doc/efun/inventory/
MudOSa4DGD/doc/efun/living/
MudOSa4DGD/doc/efun/mappings/
MudOSa4DGD/doc/efun/strings/
MudOSa4DGD/doc/efun/uid/
MudOSa4DGD/doc/funs/
MudOSa4DGD/doc/language/
MudOSa4DGD/mudlib/dgd/doc/
MudOSa4DGD/mudlib/dgd/lib/include/dgd/
MudOSa4DGD/mudlib/dgd/lib/std/
MudOSa4DGD/mudlib/dgd/lib/sys/
MudOSa4DGD/mudlib/dgd/log/
MudOSa4DGD/mudlib/log/
MudOSa4DGD/mudlib/std/include/
MudOSa4DGD/mudlib/std/obj/
/*
 * user_id.c
 *
 * Identify all objects with the users that creates/controls them
 *
 * (C) Frank Schmidt, Jesus@NorseMUD
 *
 */

/* user id and effective user id */
private static string __uid, __euid;


/* get uid and euid of this_object() */
nomask string __getuid() { return __uid; }
nomask string __geteuid() { return __euid; }

/* set uid of this_object() */
nomask int __setuid(string id) {
  /* only let us do this for export_uid-style */
  if (AUTO_PRIV() && __euid == 0) {
    __uid = id;
    return 1;
  }
  return 0;
}

/* set euid of this_object() */
nomask int __seteuid(string id) {
  string file;
  file=object_name(this_object());
  /* check if we are allowed to set this euid */
  if ((id == DRIVER_UID && 
       /* allow DGD-objects to get driver euid */
       (file == USER || file == GLOBAL || file == DRIVER)) ||
      (file == master() || /* prevent recursion in master object */
       /* check master for valid euid */
       call_other(master(), __VALID_SETEUID_FUNC, this_object(), id))) {
    __euid = id;
    return 1;
  }
  return 0;
}


/* define "efun" for getuid(ob) and geteuid(ob) */
static varargs string getuid(object ob) {
  if (!ob) return __uid;
  return ob->__getuid();
}


static varargs string geteuid(object ob) {
  if (!ob) return __euid;
  return ob->__geteuid();
}


#ifdef MUDOS_EXPORT_UID

/* export euid from this_object() to uid of ob */
static varargs int export_uid(object ob) {
  if (!ob) return __setuid(euid);
  return ob->__setuid(euid);
}

#endif


/* be able to change euid also */
static varargs int seteuid(mixed var1, mixed var2) {
  if (!objectp(var1)) return __seteuid(var1);
  return var1->__seteuid(var2);
}


#ifndef MUDOS_CREATOR
# ifndef creator

/* creator returns the uid */
static varargs string creator(object ob) {
  return getuid(ob);
}

# endif
#endif