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/
/*    /cmds/player/mudlist.c
 *    from the Dead Souls LPC Library
 *    gives information about muds
 *    created by Descartes of Borg 950623
 */

#include <lib.h>
#include <daemons.h>

inherit LIB_DAEMON;

mixed cmd(string str) {
    mixed *info;
    string *list;
    mapping borg;
    string mud;

    if( str && str != "" && strlen(str) > 3 ) {
	mapping tmp;
	string opt, tmpstr;

	tmp = (mapping)INTERMUD_D->GetMudList();
	if( str[0] != '-' ) str = "-n " + str;
	opt = str[1..1];
	str = str[3..];
	borg = ([]);
	foreach(mud, info in tmp) {
	    int x, y, z;

	    switch(opt) {
		case "m":
		  x = 5;
		  break;
                case "d":
		  x = 7;
		  break;
		case "n":
		  x = 0;
		  break;
	    }
	    tmpstr = (x ? info[x] : mud);
	    z = strlen(str = replace_string(lower_case(str), " ", ""));
	    y = strlen(tmpstr = replace_string(lower_case(tmpstr), " ", ""));
	    if( str == tmpstr ) {
		borg = ([ mud : info ]);
		break;
	    }
	    else if( y > z && tmpstr[0..z-1] == str && info[0] == -1 ) 
	      borg[mud] = info;
	}
    }
    else {
	borg = ([ ]);
	foreach( mud, info in (mapping)INTERMUD_D->GetMudList() )
	  if( info[0] == -1 ) borg[mud] = info;
    }
    if( !sizeof(borg) ) {
	message("system", "No MUDs match your query.", this_player());
	return 1;
    }
    else if( sizeof(borg) == 1 ) {
	string msg, svc;
	int val, comma = 0;

	mud = keys(borg)[0];
	msg = "\nDetailed information on %^GREEN%^" + mud + "%^RESET%^:\n";
	msg += sprintf("MUD Type: %:-6s Server: %:-20s Library: %s\n",
		       borg[mud][8], borg[mud][7], borg[mud][5]);
	msg += "Status: " + borg[mud][9] + "\nAdmin email: " +
	  borg[mud][10] + "\n";
	msg += "Services: ";
	foreach(svc, val in borg[mud][11]) {
	    if( val == 1 ) {
		if( comma ) msg += ", " + svc;
		else {
		    msg += svc;
		    comma = 1;
		}
	    }
	}
	msg += "\nHost: " + borg[mud][1] + "\n";
	msg += "Telnet port: " + borg[mud][2] + "\n";
	if( borg[mud][11]["amcp"] )
	  msg += "AMCP version: " + borg[mud][11]["amcp"] + "\n";
	if( borg[mud][11]["http"] ) 
	  msg += "HTTP port (World Wide Web): " + borg[mud][11]["http"]+"\n";
	if( borg[mud][11]["ftp"] ) 
	  msg += "FTP port (File Transfer): " + borg[mud][11]["ftp"] + "\n";
	if( borg[mud][11]["rcp"] )
	  msg += "RCP port (Remote Creator): " + borg[mud][11]["rcp"] + "\n";
	message("info", msg, this_player());
	return 1;
    }
    list = ({});
    foreach(mud, info in borg)
      list += ({ sprintf("%:-15s %:-6s %:-15s %:-18s %s %d",
			 mud, info[8], info[7], info[5], info[1], info[2]) });
    list = sort_array(list, 1);
    list = ({ mud_name() + " recognizes " + consolidate(sizeof(borg), "a mud")+
		" matching your query: ", "" }) + list;
    this_player()->eventPage(list);
    return 1;
}

int alphabet(string a, string b) {
    if((a = lower_case(a)) == (b = lower_case(b))) return 0;
    else if(a > b) return 1;
    else return -1;
}

void help() {
    message("help", "Syntax: <mudlist>\n"
	    "        <mudlist -dmn [arg]>\n\n"
	    "Without any arguments, it gives a full listing of all muds "
	    "with which this mud is capable of communication through "
	    "tell, mail, finger, rwho, and other intermud services.  "
	    "With arguments, <mudlist> requires one and only one option "
	    "which must be one of the following:\n"
	    "\t-d [driver]: List only muds using the named driver\n"
	    "\t-m [mudlib]: List only muds using the named mudlib\n"
	    "\t-n [mudname]: List only the muds with the name given\n\n"
	    "Note that the argument need not be complete, for example:\n"
	    "\t mudlist -n idea\n"
	    "will list IdeaExchange as well as any other mud whose name "
	    "begins with the string \"idea\".\n\n"
	    "See also: finger, mail, rwho, tell", this_player());
}