/*    /secure/cmds/player/chfn.c
 *    from the Foundation II LPC Library
 *    just when you thought you were safe from lisp
 *    created by Descartes of Borg 950517
 */
#include <lib.h>
inherit LIB_DAEMON;
mixed cmd(string args) {
    function f;
    string rname;
    message("system", "Changing user information for " +
	    (string)previous_object()->GetCapName() + ": ", previous_object());
    rname = (string)previous_object()->GetRealName();
    message("prompt", "Real name [" + rname + "] ", previous_object());
    f = function(string str, string old, object ob) {
	function g;
	if( !str || str == "" ) str = old;
	if( str != old ) {
	    ob->SetRealName(str);
	    message("system", "Real name changed to " + str, ob);
	}
	else message("system", "Real name unchanged.", ob);
	str = (string)ob->GetEmail();
	message("prompt", "Email [" + str + "] ", ob);
	g = function(string str, string old, object ob) {
	    if( !str || str == "" ) str = old;
	    if( str != old ) {
		string a, b;
		if( sscanf(str, "%s@%s", a, b) != 2 ) {
		    message("system", "Invalid email.", ob);
		    return;
		}
		ob->SetEmail(str);
		message("system", "Email changed to " + str, ob);
	    }
	    else message("system", "Email unchanged.", ob);
	};
	input_to(g, str, ob);
    };
    input_to(f, rname, previous_object());
    return 1;
}
void help() {
    message("help", "Syntax: <chfn>\n\n"
	    "Allows you to change your real life information.\n\n"
	    "See also: passwd", this_player());
}