/************************************************************************ * Function : configure_urlbase * * Parameters : * INOUT IXML_Document *doc ; IXML Description document * IN const struct sockaddr_in* serverAddr ; socket address object * providing the IP address and port information * IN const char* alias ; string containing the alias * IN time_t last_modified ; time when the XML document was * downloaded * OUT char docURL[LINE_SIZE] ; buffer to hold the URL of the * document. * INOUT IXML_Document *doc:dom document whose urlbase is to be modified * IN const struct sockaddr_in* serverAddr : ip address and port of * the miniserver * IN const char* alias : a name to be used for the temp; e.g.:"foo.xml" * IN time_t last_modified : time * OUT char docURL[LINE_SIZE] : document URL * * Description : Configure the full URL for the description document. * Create the URL document and add alias, description information. * The doc is added to the web server to be served using the given * alias. * * Return : int ; * UPNP_E_SUCCESS - On Success * UPNP_E_OUTOF_MEMORY - Default Error * * Note : ************************************************************************/ int configure_urlbase( INOUT IXML_Document * doc, IN const struct sockaddr_in *serverAddr, IN const char *alias, IN time_t last_modified, OUT char docURL[LINE_SIZE] ) { char *root_path = NULL; char *new_alias = NULL; char *xml_str = NULL; int err_code; char ipaddr_port[LINE_SIZE]; err_code = UPNP_E_OUTOF_MEMORY; // default error // get IP address and port addrToString( serverAddr, ipaddr_port ); // config url-base in 'doc' err_code = config_description_doc( doc, ipaddr_port, &root_path ); if( err_code != UPNP_E_SUCCESS ) { goto error_handler; } // calc alias err_code = calc_alias( alias, root_path, &new_alias ); if( err_code != UPNP_E_SUCCESS ) { goto error_handler; } // calc full url for desc doc err_code = calc_descURL( ipaddr_port, new_alias, docURL ); if( err_code != UPNP_E_SUCCESS ) { goto error_handler; } // xml doc to str xml_str = ixmlPrintDocument( doc ); if( xml_str == NULL ) { goto error_handler; } UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, "desc url: %s\n", docURL ); UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, "doc = %s\n", xml_str ); // store in web server err_code = web_server_set_alias( new_alias, xml_str, strlen( xml_str ), last_modified ); error_handler: free( root_path ); free( new_alias ); if( err_code != UPNP_E_SUCCESS ) { ixmlFreeDOMString( xml_str ); } return err_code; }
void _profileHelper(void *left, const char *middle, void *right) { // some scratch space, in case addrToString needs it. avoids needless malloc churn char leftScratch[16]; char rightScratch[16]; char msg[256]; if (gFunctionTraceEnabled && gLogDestination != kLogToUndefined) { snprintf(msg, sizeof(msg), "%.*s %s() %s %s()", gCallDepth, leader, addrToString(left, leftScratch), middle, addrToString(right, rightScratch)); gLogString(kLogDebug, msg); } }
void Client::getMACAddress(void) { bool macIsSet = false; IP_ADAPTER_INFO AdapterInfo[16]; DWORD dwBufLen = sizeof(AdapterInfo); DWORD dwStatus = GetAdaptersInfo(AdapterInfo, &dwBufLen); if (dwStatus == ERROR_SUCCESS) { PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; while (pAdapterInfo && !macIsSet) { if (isValidMac(pAdapterInfo)) { m_MAC = addrToString(pAdapterInfo->Address); macIsSet = true; } pAdapterInfo = pAdapterInfo->Next; } } }