UPNP_MSEARCH_HANDLE_ITEM* UPNP_MSEARCH_HANDLE_ITEM_Create(UPNP_SERVER_HANDLE handle) { UPNP_MSEARCH_HANDLE_ITEM* item = NULL; UPNP_SSDP_HANDLE_ITEM* srvHandle = NULL; int ret = 0; if( handle == NULL ){ return NULL; } srvHandle = (UPNP_SSDP_HANDLE_ITEM*)handle; item = (UPNP_MSEARCH_HANDLE_ITEM*)malloc(sizeof(UPNP_MSEARCH_HANDLE_ITEM)); if( item != NULL ){ item->msearchCallBack = srvHandle->msearchCallBack; item->msearchCallBackParam = srvHandle->msearchCallBackParam; item->lockHandle = MP_LOCK_CreateHandle(); item->msearchThread = NULL; item->msearchStopFlag = 0; item->resultList = SORT_LIST_CreateHandle(0, SORT_LIST_COMPDEF_strcmp, NULL, UPNP_SSDP_SOCKET_ITEM_Delete); } return item; }
//ハンドルの作成 //戻り値:ハンドル、エラー時NULL UPNP_SERVER_HANDLE UPNP_SERVER_CreateHandle( UPNP_SSDP_CALLBACK ssdpCallBack, //[IN]SSDPのNotify通知用コールバック void* ssdpCallBackParam, //[IN]SSDPのNotify通知用コールバック呼出時に入れるパラメーター UPNP_MSEARCH_REQUEST_CALLBACK msearchCallBack, //[IN]SSDPのM-SEARCHリクエスト通知用コールバック void* msearchCallBackParam //[IN]SSDPのM-SEARCHリクエスト通知用コールバック呼出時に入れるパラメーター ) { UPNP_SSDP_HANDLE_ITEM* item = NULL; #ifdef _WIN32 WSADATA wsaData; #endif item = (UPNP_SSDP_HANDLE_ITEM*)malloc(sizeof(UPNP_SSDP_HANDLE_ITEM)); if( item != NULL ){ item->ssdpCallBack = ssdpCallBack; item->ssdpCallBackParam = ssdpCallBackParam; item->msearchCallBack = msearchCallBack; item->msearchCallBackParam = msearchCallBackParam; item->lockHandle = MP_LOCK_CreateHandle(); item->ssdpSrvThread = NULL; item->ssdpSrvStopFlag = 0; item->notifySendThread = NULL; item->notifySendStopFlag = 0; item->ssdpSockList = SORT_LIST_CreateHandle(1, SORT_LIST_COMPDEF_strcmp, NULL, UPNP_SSDP_SOCKET_ITEM_Delete); item->recvThreadList = SORT_LIST_CreateHandle(1, SORT_LIST_COMPDEF_strcmp, NULL, UPNP_SSDP_RECV_PARAM_Delete); item->notifyDeviceList = SORT_LIST_CreateHandle(0, SORT_LIST_COMPDEF_strcmp, NULL, UPNP_SSDP_NOTIFY_DEVICE_INFO_Delete); #ifdef _WIN32 CoInitialize(NULL); ZeroMemory(&wsaData, sizeof(wsaData)); WSAStartup(MAKEWORD(2, 2), &wsaData); #endif } return (void*)item; }