reply.c

./lib/secure/udp_cmd_/reply.c · 1022 B

From the archive h7v3.0a.tar.gz

Download the archive   « Back to the archive contents

#include <udp.h>

#ifdef ZEBEDEE
#include <defs.h>
#elif !defined(DATE)
#define DATE	ctime(time())[4..15]
#endif

void udp_reply(mapping data) {
    if (data[RECIPIENT]) {
	object ob;
	string err;

	/* If recipient is a player name, pass the message to them. */
	if (ob = find_player(data[RECIPIENT])) {
	    tell_object(ob, "\n" + data[DATA]);
	    return;
	}
	// Otherwise send it to udp_reply() in the recipient.
	// Note: We must send a copy as it may be changed by the recipient.
	//       We must never alter the mapping passed to us by the inetd.
	if (err = catch(data[RECIPIENT]->udp_reply(copy_mapping(data))))
	    log_file(LOG_FILE, DATE + ": Error in file: " +
	    data[RECIPIENT] + "\n" + err + "\n");
	return;
    }
    switch(data[REQUEST]) {
	case "ping":
	    /* Ignore system ping replies. */
	    return;
	default:
	    /* Log replies to the system. (ie. No RECIPIENT) */
	    if (data[DATA])
		log_file(LOG_FILE, DATE + ": Reply from " + data[NAME] +
		"\n" + data[DATA] + "\n");
	    return;
    }
}

Site Stats

Snippets: 1791
Codebases: 571