IPC_RETURN_TYPE _IPC_subscribe (const char *msgName, const char *hndName, HANDLER_TYPE handler, void *clientData, int autoUnmarshall) { HND_KEY_TYPE hndKey; HND_PTR hnd; if (!msgName || strlen(msgName) == 0) { RETURN_ERROR(IPC_Null_Argument); } else if (!X_IPC_CONNECTED()) { RETURN_ERROR(IPC_Not_Connected); } else { x_ipcRegisterHandler(msgName, hndName, handler); /* Set the client data */ hndKey.num = 0; hndKey.str = hndName; LOCK_CM_MUTEX; hnd = GET_HANDLER(&hndKey); UNLOCK_CM_MUTEX; hnd->autoUnmarshall = autoUnmarshall; if (hnd->isRegistered && hnd->clientData != NO_CLIENT_DATA) { X_IPC_MOD_WARNING1("Resetting client data for handler %s\n", hndName); } hnd->isRegistered = TRUE; hnd->clientData = clientData; return IPC_OK; } }
void _x_ipcWatchVar(const char *varName, const char *format, X_IPC_HND_FN watchFn) { #ifdef UNUSED_PRAGMA #pragma unused(format) #endif char *watchMsgName; watchMsgName = (char *)x_ipcMalloc(1+strlen(varName)+strlen(VAR_WATCH_PREFIX)); strcpy(watchMsgName,VAR_WATCH_PREFIX); strcat(watchMsgName,varName); /* Check to see if already registered */ LOCK_CM_MUTEX; HND_KEY_TYPE hndKey; hndKey.num = 0; hndKey.str = watchMsgName; HND_PTR watchMsgHnd = GET_HANDLER(&hndKey); UNLOCK_CM_MUTEX; if (watchMsgHnd == NULL || watchMsgHnd->msg == NULL) { /* Register the tap messages and handler */ x_ipcRegisterHandler(watchMsgName,watchMsgName,watchFn); x_ipcLimitPendingMessages(watchMsgName, GET_M_GLOBAL(modNameGlobal), 1); } x_ipcFree(watchMsgName); }
void _x_ipcRegisterHandler(const char *msgName, const char *hndName, X_IPC_HND_FN hndProc) { x_ipcRegisterHandler(msgName, hndName, hndProc); }