#include #include #include "../include/swserv-plugins.h" /* * SWServ Plugin hail notify. * * This function is called whenever a hail or com message is sent * from one object to another or from one object to any other * object (general hail or general com message). * * The obj_num is the object that send the hail or com message. * * The tobj_num is the object that the hail or com message was * sent to. If this is a general hail or general com message then * this value is -1. * * The channel specifies the channel that this hail or com message * was sent on. * * The message specifies the com message. If this value is NULL * then this is to be considered a hail instead of a com message. */ SWPLUGIN_HAIL_NOTIFY_FUNCRTN SWPLUGIN_HAIL_NOTIFY_FUNC( int con_num, int obj_num, int tobj_num, int channel, const char *message, SWServContext *ctx ) { xsw_object_struct *obj = SWServObjectGetPointer(ctx, obj_num), *tobj = SWServObjectGetPointer(ctx, tobj_num); /* If the message is not NULL then it implies this is a com * message, otherwise this is a hail */ if(message != NULL) { if((obj != NULL) && (tobj != NULL)) { printf( "`%s' sent a message to `%s' on com channel %.2f: `%s'\n", obj->name, tobj->name, (float)channel / 100.0f, message ); } else if(obj != NULL) { printf( "`%s' sent a general message on com channel %.2f: `%s'\n", obj->name, (float)channel / 100.0f, message ); } } else { if((obj != NULL) && (tobj != NULL)) { printf( "`%s' hailed `%s' on com channel %.2f.\n", obj->name, tobj->name, (float)channel / 100.0f ); } else if(obj != NULL) { printf( "`%s' sent a general hail on com channel %.2f.\n", obj->name, (float)channel / 100.0f ); } } } /* * SWServ Plugin initialize. */ SWPLUGIN_INIT_FUNCRTN SWPLUGIN_INIT_FUNC(SWPLUGIN_INIT_FUNCINPUT) { return(0); } /* * SWServ Plugin manage. */ SWPLUGIN_MANAGE_FUNCRTN SWPLUGIN_MANAGE_FUNC(SWPLUGIN_MANAGE_FUNCINPUT) { return(0); } /* * SWServ Plugin shutdown. */ SWPLUGIN_SHUTDOWN_FUNCRTN SWPLUGIN_SHUTDOWN_FUNC(SWPLUGIN_SHUTDOWN_FUNCINPUT) { return; }