GFINGER_.C
LIB3/NET/UDP/GFINGER_.C · 2.0 KB
From the archive nm4dos.zip
Download the archive « Back to the archive contents
#include "udp.h"
/*
* Finger a wiz on another mud.
*/
void send_gfinger_q( string mud, string wiz )
{
mapping minfo;
if( mud == MUD_NAME )
return;
minfo = NAMESERVER_CD->query_mud_info( mud );
if( !minfo )
return;
NAMESERVER_CD->send_udp( minfo[ "HOSTADDRESS" ], minfo[ "PORTUDP" ],
"@@@" + UDP_GFINGER_Q +
"||NAME:" + MUD_NAME +
"||PORTUDP:" + NAMESERVER_CD->query_my_port() +
"||PLAYER:" + wiz +
"||ASKWIZ:" + this_player()->query_name() +
"@@@\n" );
} /* send_gtell() */
void incoming_request( mapping info )
{
string finger, *bits;
int i;
if( info[ "NAME" ] && info[ "PORTUDP" ] )
{
if( info[ "NAME" ] == MUD_NAME )
return;
if( !NAMESERVER_CD->query_mud_info( info[ "NAME" ] ) )
PING_Q->send_ping_q( info[ "HOSTADDRESS" ], info[ "PORTUDP" ] );
finger = "/secure/finger"->finger_info( lower_case( info[ "PLAYER" ] ) );
if( !finger )
finger = "I am most dreadfully sorry, but " + info[ "PLAYER" ] +
"has not visited here yet. Try again later :)\n";
bits = explode( finger, "\n" );
finger = "";
for( i = 0; i < sizeof( bits ); i++ )
{
if( strlen( finger ) + strlen( bits[ i ] ) > 256 )
{
NAMESERVER_CD->send_udp( info[ "HOSTADDRESS" ], info[ "PORTUDP" ],
"@@@" + UDP_GFINGER_A +
"||NAME:" + MUD_NAME +
"||PORTUDP:" + NAMESERVER_CD->query_my_port() +
"||ASKWIZ:" + info[ "ASKWIZ" ] +
"||MSG:" + finger +
"@@@\n" );
finger = "";
}
finger += bits[ i ] + "\n";
}
if( strlen( finger ) )
NAMESERVER_CD->send_udp( info[ "HOSTADDRESS" ], info[ "PORTUDP" ],
"@@@" + UDP_GFINGER_A +
"||NAME:" + MUD_NAME +
"||PORTUDP:" + NAMESERVER_CD->query_my_port() +
"||ASKWIZ:" + info[ "ASKWIZ" ] +
"||MSG:" + finger +
"@@@\n" );
}
} /* incoming_request() */
void create()
{
seteuid( getuid() );
}
void dest_me()
{
destruct( this_object() );
}