11.1 General Utilities
void SaveMessageAndMakeCode(GetMsgCodeStruct *params, long PSYXid);
This utility should be called in response to a
pGetMsgCodemessage (see "1.4 Standard Messages") when the PSYX wishes to accept any string message and read the string when it is called to execute the message.
paramsshould be the message data pointer passed in for the
PSYXidshould be the name of the PSYX that received the message.
SaveMessageAndMakeCode()will generate a unqiue message id and fill in the
GetMsgCodeStructappropriately. Later, when the PSYX receives a message it does not recognize, it should call
int LoadMessageString(long msg, long id, char *buffer);
This utility should be called by a PSYX that has used
SaveMessageAndMakeCode()when it receieves an unrecognized message. If
TRUE, then the message code was one generated by
SaveMessageAndMakeCode()and buffer is filled in with the original string message. (Buffer should be at least 256 bytes long).
FALSE, then the PSYX should return
FALSE, indicating to the PSYX manager that the message was not understood.
struct CodeFuncPair *CreateFunctionTable(long firstID, ...);
This utility can be used to build a message table. The parameters should be an alternating list of message IDs and function pointers; the function pointer following an ID is the message handler for that message. The list must be terminated with a 0, following the last function pointer.
CreateFunctionTable()returns a pointer that can be the reply to a
pGetFuncTablemessage. This table must be freed before the PSYX is purged using
Free()(capital "F") in response to a
pDeinitializemessage. The table should never be freed before the
Generated with CERN WebMaker