foundation2_fluffos_v1/
foundation2_fluffos_v1/bin/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/ChangeLog.old/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/Win32/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/compat/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/compat/simuls/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/include/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/clone/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/command/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/data/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/etc/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/include/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/inherit/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/inherit/master/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/log/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/single/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/single/tests/compiler/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/single/tests/efuns/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/single/tests/operators/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/u/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/tmp/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/windows/
foundation2_fluffos_v1/lib/cfg/
foundation2_fluffos_v1/lib/cmds/adm/
foundation2_fluffos_v1/lib/daemon/save/
foundation2_fluffos_v1/lib/daemon/services/
foundation2_fluffos_v1/lib/daemon/soul/
foundation2_fluffos_v1/lib/doc/build/
foundation2_fluffos_v1/lib/doc/classes/
foundation2_fluffos_v1/lib/doc/driver/
foundation2_fluffos_v1/lib/doc/driver/applies/
foundation2_fluffos_v1/lib/doc/driver/applies/interactive/
foundation2_fluffos_v1/lib/doc/driver/concepts/
foundation2_fluffos_v1/lib/doc/driver/driver/
foundation2_fluffos_v1/lib/doc/driver/efuns/arrays/
foundation2_fluffos_v1/lib/doc/driver/efuns/buffers/
foundation2_fluffos_v1/lib/doc/driver/efuns/calls/
foundation2_fluffos_v1/lib/doc/driver/efuns/compile/
foundation2_fluffos_v1/lib/doc/driver/efuns/filesystem/
foundation2_fluffos_v1/lib/doc/driver/efuns/floats/
foundation2_fluffos_v1/lib/doc/driver/efuns/functions/
foundation2_fluffos_v1/lib/doc/driver/efuns/general/
foundation2_fluffos_v1/lib/doc/driver/efuns/mappings/
foundation2_fluffos_v1/lib/doc/driver/efuns/numbers/
foundation2_fluffos_v1/lib/doc/driver/efuns/parsing/
foundation2_fluffos_v1/lib/doc/driver/lpc/constructs/
foundation2_fluffos_v1/lib/doc/driver/lpc/types/
foundation2_fluffos_v1/lib/doc/driver/platforms/
foundation2_fluffos_v1/lib/doc/efun/
foundation2_fluffos_v1/lib/doc/etc/
foundation2_fluffos_v1/lib/doc/faq/
foundation2_fluffos_v1/lib/doc/help/creator/
foundation2_fluffos_v1/lib/doc/help/player/
foundation2_fluffos_v1/lib/doc/lpc/basic/
foundation2_fluffos_v1/lib/doc/lpc/data_types/
foundation2_fluffos_v1/lib/doc/lpc/etc/
foundation2_fluffos_v1/lib/doc/lpc/intermediate/
foundation2_fluffos_v1/lib/doc/lpc/types/
foundation2_fluffos_v1/lib/doc/mudlib/
foundation2_fluffos_v1/lib/doc/mudlib/Features/
foundation2_fluffos_v1/lib/domains/Examples/armour/
foundation2_fluffos_v1/lib/domains/Examples/etc/
foundation2_fluffos_v1/lib/domains/Examples/npc/
foundation2_fluffos_v1/lib/domains/Examples/room/
foundation2_fluffos_v1/lib/domains/Examples/virtual/
foundation2_fluffos_v1/lib/domains/Examples/virtual/exaA/
foundation2_fluffos_v1/lib/domains/Examples/virtual/exaB/
foundation2_fluffos_v1/lib/domains/Examples/weapon/
foundation2_fluffos_v1/lib/domains/School/doc/
foundation2_fluffos_v1/lib/domains/School/room/
foundation2_fluffos_v1/lib/domains/School/room/Classes/
foundation2_fluffos_v1/lib/domains/School/room/Offices/
foundation2_fluffos_v1/lib/domains/Standard/
foundation2_fluffos_v1/lib/domains/Standard/pools/
foundation2_fluffos_v1/lib/domains/Standard/std/
foundation2_fluffos_v1/lib/domains/Standard/xtra/
foundation2_fluffos_v1/lib/include/
foundation2_fluffos_v1/lib/lib/obj/
foundation2_fluffos_v1/lib/news/
foundation2_fluffos_v1/lib/save/
foundation2_fluffos_v1/lib/secure/cfg/
foundation2_fluffos_v1/lib/secure/cmds/player/
foundation2_fluffos_v1/lib/secure/lib/
foundation2_fluffos_v1/old/
foundation2_fluffos_v1/win32/
/*    /cmds/player/mudlist.c
 *    from the Nightmare IV 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 %:-19s %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()->more(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());
}