dsI/bin/
dsI/extra/creremote/
dsI/extra/mingw/
dsI/extra/wolfpaw/
dsI/fluffos-2.7-ds2.018/
dsI/fluffos-2.7-ds2.018/ChangeLog.old/
dsI/fluffos-2.7-ds2.018/Win32/
dsI/fluffos-2.7-ds2.018/compat/
dsI/fluffos-2.7-ds2.018/compat/simuls/
dsI/fluffos-2.7-ds2.018/testsuite/
dsI/fluffos-2.7-ds2.018/testsuite/clone/
dsI/fluffos-2.7-ds2.018/testsuite/command/
dsI/fluffos-2.7-ds2.018/testsuite/data/
dsI/fluffos-2.7-ds2.018/testsuite/etc/
dsI/fluffos-2.7-ds2.018/testsuite/include/
dsI/fluffos-2.7-ds2.018/testsuite/inherit/
dsI/fluffos-2.7-ds2.018/testsuite/inherit/master/
dsI/fluffos-2.7-ds2.018/testsuite/log/
dsI/fluffos-2.7-ds2.018/testsuite/single/
dsI/fluffos-2.7-ds2.018/testsuite/single/tests/compiler/
dsI/fluffos-2.7-ds2.018/testsuite/single/tests/efuns/
dsI/fluffos-2.7-ds2.018/testsuite/single/tests/operators/
dsI/fluffos-2.7-ds2.018/testsuite/u/
dsI/fluffos-2.7-ds2.018/tmp/
dsI/lib/cfg/
dsI/lib/cmds/common/
dsI/lib/cmds/creators/include/
dsI/lib/cmds/creators/include/SCCS/
dsI/lib/daemon/services/
dsI/lib/doc/
dsI/lib/domains/Ylsrim/
dsI/lib/domains/Ylsrim/adm/
dsI/lib/domains/Ylsrim/armour/
dsI/lib/domains/Ylsrim/broken/
dsI/lib/domains/Ylsrim/fish/
dsI/lib/domains/Ylsrim/meal/
dsI/lib/domains/Ylsrim/npc/
dsI/lib/domains/Ylsrim/virtual/
dsI/lib/domains/Ylsrim/weapon/
dsI/lib/domains/default/creator/
dsI/lib/domains/default/etc/
dsI/lib/domains/default/room/
dsI/lib/lib/comp/
dsI/lib/lib/lvs/
dsI/lib/lib/user/
dsI/lib/lib/virtual/
dsI/lib/obj/
dsI/lib/obj/include/
dsI/lib/realms/
dsI/lib/save/kills/a/
dsI/lib/save/kills/b/
dsI/lib/save/kills/f/
dsI/lib/save/kills/m/
dsI/lib/save/kills/q/
dsI/lib/save/kills/r/
dsI/lib/secure/cfg/
dsI/lib/secure/cfg/classes/
dsI/lib/secure/cfg/races/SCCS/
dsI/lib/secure/cmds/creators/include/
dsI/lib/secure/cmds/players/
dsI/lib/secure/cmds/players/include/
dsI/lib/secure/daemon/include/
dsI/lib/secure/lib/
dsI/lib/secure/lib/include/
dsI/lib/secure/lib/net/
dsI/lib/secure/lib/net/include/
dsI/lib/secure/lib/std/
dsI/lib/secure/obj/
dsI/lib/secure/obj/include/
dsI/lib/secure/save/
dsI/lib/spells/
dsI/lib/verbs/admins/include/
dsI/lib/verbs/common/
dsI/lib/verbs/common/include/
dsI/lib/verbs/creators/
dsI/lib/verbs/creators/include/
dsI/lib/verbs/players/include/SCCS/
dsI/lib/verbs/rooms/
dsI/lib/verbs/rooms/include/
dsI/lib/www/
dsI/v22.2b14/
dsI/win32/
/*    /secure/cmds/creator/call.c
 *    from the Foundation II LPC Library
 *    allows you to call functions in objects ad hoc
 *    created by Descartes of Borg 950430
 */

#include <privs.h>
#include <lib.h>

inherit LIB_DAEMON;

mixed cmd(string args) {
    mixed *arg_arr;
    string *all_args;
    function f;
    object target;
    mixed val;
    string arg_targ, arg_func, err, this_arg;
    int i, maxi;

    if(!member_group(previous_object(), PRIV_SECURE)) {
      log_file("adm/call", query_privs(previous_object())
        +" ("+ctime(time())+"): call "+args+"\n");
    }
    if( !args || args == "" ) return "Call ob->func(arg1, arg2)\n";
    if( sscanf(args, "%s->%s(%s", arg_targ, arg_func, args) != 3 )
      return "Call ob->func(arg1, arg2)\n";
    args = trim(args);
    if( args != ")" ) args = args[0..<2];
    else args = "";
    if( !(target = to_object(arg_targ)) )
      return "Cannot identify any object as \"" + arg_targ + "\".";
    if( !function_exists(arg_func, target) )
      return "The function " + arg_func +"() is not in " +
	identify(target) + "\n";
    f = (: call_other, target, arg_func :);
    if( args == "" ) {
	err = catch(val = evaluate(f));
	if( err) {
	    message("error", identify(target) + " -> " + arg_func + "()",
		    this_player());
	    message("error", "Error in execution: " + err, this_player());
	    return 1;
	}
	else {
	    message("system", identify(target) + " -> " + arg_func + "() = " +
		    identify(val), this_player());
	    return 1;
	}
    }
    arg_arr = convert_string("({"+args+"})");
    err = catch(val = call_other(target, ({ arg_func }) + arg_arr));
    args = identify(target) + " -> " + arg_func + "( ";
    for(i = 0, maxi = sizeof(arg_arr); i<maxi; i++) {
	args += identify(arg_arr[i]);
	if( i < maxi - 1 ) args += ", ";
    }
    if( err ) {
	message("error", args + ")", this_player());
	message("error", "Error in execution: " + err, this_player());
	return 1;
    }
    args += " ) = " + identify(val);
    message("system", args, this_player());
    return 1;
}

void help() {
    message("help", "Syntax: <call [object]->[function](([args]))>\n\n"
	    "Examples:\n\tcall me->GetName()\n"
	    "\tcall \"/realms/descartes/workroom\"->GetProperty(\"light\")\n\n"
	    "Allows you to call any function in any object with any set of "
	    "arguments from the command line.  The syntax is identical to "
	    "that you would use inside LPC code, except that you can refer "
	    "to objects by their names or by pronouns in addition to the "
	    "usual manners.\n\n"
	    "See also: eval, gauge", this_player());
}