static mUpnpXmlNode *mupnp_control_action_response_createresponsenode(mUpnpAction *action) { mUpnpXmlNode *actionNameResNode; char nodeName[MUPNP_ACTOINNAME_LEN_MAX + sizeof(MUPNP_SOAP_METHODNS) + sizeof(MUPNP_SOAP_DELIM) + sizeof(MUPNP_SOAP_RESPONSE) + 1]; char attrName[sizeof(MUPNP_SOAP_ATTRIBUTE_XMLNS) + sizeof(MUPNP_SOAP_DELIM) + sizeof(MUPNP_SOAP_METHODNS) + 1]; const char *actionName; mUpnpXmlNode *serviceNode; mUpnpService *service; mUpnpArgumentList *argList; mUpnpArgument *arg; mUpnpXmlNode *argNode; mupnp_log_debug_l4("Entering...\n"); actionNameResNode = mupnp_xml_node_new(); /* action name */ actionName = mupnp_action_getname(action); mupnp_strcpy(nodeName, MUPNP_SOAP_METHODNS); mupnp_strcat(nodeName, MUPNP_SOAP_DELIM); mupnp_strncat(nodeName, actionName, MUPNP_ACTOINNAME_LEN_MAX); mupnp_strcat(nodeName, MUPNP_SOAP_RESPONSE); mupnp_xml_node_setname(actionNameResNode, nodeName); /* service attribute */ serviceNode = mupnp_service_getservicenode(mupnp_action_getservice(action)); if (serviceNode != NULL) { service = mupnp_service_new(); mupnp_service_setservicenode(service, serviceNode); mupnp_strcpy(attrName, MUPNP_SOAP_ATTRIBUTE_XMLNS); mupnp_strcat(attrName, MUPNP_SOAP_DELIM); mupnp_strcat(attrName, MUPNP_SOAP_METHODNS); mupnp_xml_node_setattribute(actionNameResNode, attrName, mupnp_service_getservicetype(service)); mupnp_service_delete(service); } /* arguments */ argList = mupnp_action_getargumentlist(action); for (arg = mupnp_argumentlist_gets(argList); arg != NULL; arg = mupnp_argument_next(arg)) { if (mupnp_argument_isoutdirection(arg) == false) continue; argNode = mupnp_xml_node_new(); mupnp_xml_node_setname(argNode, mupnp_argument_getname(arg)); mupnp_xml_node_setvalue(argNode, mupnp_argument_getvalue(arg)); mupnp_xml_node_addchildnode(actionNameResNode, argNode); } return actionNameResNode; mupnp_log_debug_l4("Leaving...\n"); }
void mupnp_net_setinterface(const char* ifaddr) { mupnp_log_debug_l4("Entering...\n"); mupnp_strcpy(InterfaceAddress, ifaddr); IsInterfaceAddressInitialized = true; mupnp_log_debug_l4("Leaving...\n"); }
const char *mupnp_http_getservername(char *buf, size_t bufSize) { #if defined(WIN32) && !defined(ITRON) OSVERSIONINFO verInfo; mupnp_strcpy(buf, "Platform 1.0"); ZeroMemory(&verInfo, sizeof(OSVERSIONINFO)); verInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (GetVersionEx(&verInfo)) { #if defined(HAVE_SNPRINTF) snprintf(buf, bufSize, "Windows %d.%d", verInfo.dwMajorVersion, verInfo.dwMinorVersion); #else sprintf(buf, "Windows %d.%d", verInfo.dwMajorVersion, verInfo.dwMinorVersion); #endif } #elif defined(BTRON) T_VER verInfo; mupnp_strcpy(buf, "Platform 1.0"); if (get_ver(&verInfo) == 0) { #if defined(HAVE_SNPRINTF) snprintf(buf, bufSize, "BTRON %hd", verInfo.spver); #else sprintf(buf, "BTRON %hd", verInfo.spver); #endif } #elif defined(ITRON) mupnp_strcpy(buf, "uITRON 4.0"); #elif defined(TENGINE) mupnp_strcpy(buf, "T-Engine 1.0"); #elif defined(HAVE_UNAME) || defined(TARGET_OS_MAC) || defined(TARGET_OS_IPHONE) struct utsname unameBuf; mupnp_strcpy(buf, "Platform 1.0"); if (uname(&unameBuf) == 0) { #if defined(HAVE_SNPRINTF) snprintf(buf, bufSize, "%s %s", unameBuf.sysname, unameBuf.release); #else sprintf(buf, "%s %s", unameBuf.sysname, unameBuf.release); #endif } #else mupnp_strcpy(buf, "Platform 1.0"); #endif mupnp_log_debug_l4("Entering...\n"); return buf; mupnp_log_debug_l4("Leaving...\n"); }