hkvTextureFileToDataFormatMapping::hkvTextureFileToDataFormatMapping() { hkvTextureDataFormat rawFormats[] = { HKV_TEXTURE_DATA_FORMAT_A4R4G4B4, HKV_TEXTURE_DATA_FORMAT_A1R5G5B5, HKV_TEXTURE_DATA_FORMAT_R5G6B5, HKV_TEXTURE_DATA_FORMAT_A8R8G8B8, HKV_TEXTURE_DATA_FORMAT_X8R8G8B8, HKV_TEXTURE_DATA_FORMAT_R8G8B8 }; addMappings(HKV_TEXTURE_FILE_FORMAT_DDS, rawFormats); addMappings(HKV_TEXTURE_FILE_FORMAT_RGBA, rawFormats); addMappings(HKV_TEXTURE_FILE_FORMAT_GTX, rawFormats); addMapping(HKV_TEXTURE_FILE_FORMAT_RGBA, HKV_TEXTURE_DATA_FORMAT_R4G4B4A4_GL); hkvTextureDataFormat bcFormats[] = { HKV_TEXTURE_DATA_FORMAT_DXT1, HKV_TEXTURE_DATA_FORMAT_DXT3, HKV_TEXTURE_DATA_FORMAT_DXT5, }; addMappings(HKV_TEXTURE_FILE_FORMAT_DDS, bcFormats); addMappings(HKV_TEXTURE_FILE_FORMAT_GTX, bcFormats); hkvTextureDataFormat pvrFormats[] = { HKV_TEXTURE_DATA_FORMAT_PVRTC2, HKV_TEXTURE_DATA_FORMAT_PVRTC4, }; addMappings(HKV_TEXTURE_FILE_FORMAT_PVR, pvrFormats); hkvTextureDataFormat etcFormats[] = { HKV_TEXTURE_DATA_FORMAT_ETC1, }; addMappings(HKV_TEXTURE_FILE_FORMAT_ETC, etcFormats); }
hkvPlatformToTextureDataFormatMapping::hkvPlatformToTextureDataFormatMapping() : hkReferencedObject(), hkSingleton(), hkvPlatformToTextureDataFormatMappingBase() { hkvTextureDataFormat rawFormats[] = { HKV_TEXTURE_DATA_FORMAT_A4R4G4B4, HKV_TEXTURE_DATA_FORMAT_A1R5G5B5, HKV_TEXTURE_DATA_FORMAT_R5G6B5, HKV_TEXTURE_DATA_FORMAT_A8R8G8B8, HKV_TEXTURE_DATA_FORMAT_X8R8G8B8, HKV_TEXTURE_DATA_FORMAT_R8G8B8 }; addMappings(HKV_TARGET_PLATFORM_DX9, rawFormats); addMappings(HKV_TARGET_PLATFORM_DX11, rawFormats); addMappings(HKV_TARGET_PLATFORM_XBOX360, rawFormats); addMappings(HKV_TARGET_PLATFORM_PS3, rawFormats); addMappings(HKV_TARGET_PLATFORM_PSVITA, rawFormats); addMappings(HKV_TARGET_PLATFORM_IOS, rawFormats); addMappings(HKV_TARGET_PLATFORM_ANDROID, rawFormats); addMappings(HKV_TARGET_PLATFORM_TIZEN, rawFormats); addMappings(HKV_TARGET_PLATFORM_WIIU, rawFormats); addMapping(HKV_TARGET_PLATFORM_ANDROID, HKV_TEXTURE_DATA_FORMAT_R4G4B4A4_GL); addMapping(HKV_TARGET_PLATFORM_IOS, HKV_TEXTURE_DATA_FORMAT_R4G4B4A4_GL); addMapping(HKV_TARGET_PLATFORM_TIZEN, HKV_TEXTURE_DATA_FORMAT_R4G4B4A4_GL); hkvTextureDataFormat bcFormats[] = { HKV_TEXTURE_DATA_FORMAT_DXT1, HKV_TEXTURE_DATA_FORMAT_DXT3, HKV_TEXTURE_DATA_FORMAT_DXT5, }; addMappings(HKV_TARGET_PLATFORM_DX9, bcFormats); addMappings(HKV_TARGET_PLATFORM_DX11, bcFormats); addMappings(HKV_TARGET_PLATFORM_XBOX360, bcFormats); addMappings(HKV_TARGET_PLATFORM_PS3, bcFormats); addMappings(HKV_TARGET_PLATFORM_PSVITA, bcFormats); addMappings(HKV_TARGET_PLATFORM_WIIU, bcFormats); hkvTextureDataFormat pvrFormats[] = { HKV_TEXTURE_DATA_FORMAT_PVRTC2, HKV_TEXTURE_DATA_FORMAT_PVRTC4, }; addMappings(HKV_TARGET_PLATFORM_IOS, pvrFormats); addMappings(HKV_TARGET_PLATFORM_ANDROID, pvrFormats); addMappings(HKV_TARGET_PLATFORM_TIZEN, pvrFormats); hkvTextureDataFormat etcFormats[] = { HKV_TEXTURE_DATA_FORMAT_ETC1, }; addMappings(HKV_TARGET_PLATFORM_ANDROID, etcFormats); addMappings(HKV_TARGET_PLATFORM_TIZEN, etcFormats); }
void SipRedirectorGateway::processForm(const HttpRequestContext& requestContext, const HttpMessage& request, HttpMessage*& response) { UtlString string_get("get"); UtlString string_set("set"); UtlString string_prefix("prefix"); UtlString string_destination("destination"); OsSysLog::add(FAC_SIP, PRI_DEBUG, "%s::processForm entered", mLogName.data()); UtlString* user; // Process the request. // Get the body of the request. const HttpBody* request_body = request.getBody(); OsSysLog::add(FAC_SIP, PRI_DEBUG, "%s::processForm A *** request body is '%s'", mLogName.data(), request_body->getBytes()); // Get the values from the form. if (request_body->isMultipart()) { // Extract the values from the form data. UtlHashMap values; int c = request_body->getMultipartCount(); for (int i = 0; i < c; i++) { UtlString* name = new UtlString; if (request_body->getMultipart(i)->getPartHeaderValue("name", *name)) { const char* v; int l; request_body->getMultipartBytes(i, &v, &l); // Strip leading and trailing whitespace from values. UtlString* value = new UtlString(v, l); value->strip(UtlString::both); OsSysLog::add(FAC_SIP, PRI_CRIT, "%s::processForm " "form value '%s' = '%s'", mLogName.data(), name->data(), value->data()); // 'name' and 'value' are now owned by 'values'. values.insertKeyAndValue(name, value); } else { // 'name' is not owned by 'values' and we have to delete it. delete name; } } if (values.findValue(&string_get)) { // This is a "get gateway" request. // Insert the HTML into the response. HttpBody* response_body = new HttpBody(form, -1, CONTENT_TYPE_TEXT_HTML); response->setBody(response_body); } else if (values.findValue(&string_set)) { // This is a "set gateway" request. // Validate the routing prefix. UtlString* prefix = dynamic_cast <UtlString*> (values.findValue(&string_prefix)); if (prefixIsValid(*prefix)) { // Validate the destination. UtlString* destination = dynamic_cast <UtlString*> (values.findValue(&string_destination)); if (destination_is_valid(destination)) { OsSysLog::add(FAC_SIP, PRI_CRIT, "%s::processForm " "add mapping '%s' -> '%s'", mLogName.data(), prefix->data(), destination->data()); mMapLock.acquire(); // Insert the mapping. mMapUserToContacts.insertKeyAndValue(prefix, destination); mMapContactsToUser.insertKeyAndValue(destination, prefix); mMapLock.release(); writeMappings(); } } // Insert the HTML into the response. HttpBody* response_body = new HttpBody(form, -1, CONTENT_TYPE_TEXT_HTML); response->setBody(response_body); } else { // Incomprehensible request. // Insert the HTML into the response. HttpBody* response_body = new HttpBody(form, -1, CONTENT_TYPE_TEXT_HTML); response->setBody(response_body); } } else { // Incomprehensible request. // Insert the default HTML into the response. HttpBody* response_body = new HttpBody(form, -1, CONTENT_TYPE_TEXT_HTML); response->setBody(response_body); } #if 0 #if 0 // This is quite a chore, because getMultipartBytes gets the entire // multipart section, including the trailing delimiter, rather than just // the body, which is what we need. const char* value; int length; request_body->getMultipartBytes(0, &value, &length); #if 0 OsSysLog::add(FAC_SIP, PRI_DEBUG, "%s::processForm A *** seeing '%.*s'", mLogName.data(), length, value); #endif // Advance 'value' over the first \r\n\r\n, which ends the headers. const char* s = strstr(value, "\r\n\r\n"); if (s) { s += 4; // Allow for length of \r\n\r\n. length -= s - value; value = s; } OsSysLog::add(FAC_SIP, PRI_DEBUG, "%s::processForm B *** seeing '%.*s'", mLogName.data(), length, value); #if 0 // Search backward for the last \r, excepting the one in the second-to-last // position, which marks the end of the contents. if (length >= 3) { for (s = value + length - 3; !(s == value || *s == '\r'); s--) { /* empty */ } length = s - value; } OsSysLog::add(FAC_SIP, PRI_DEBUG, "%s::processForm seeing '%.*s'", mLogName.data(), length, value); #endif // Add the mappings. const char* error_msg; int error_location; UtlBoolean success = addMappings(value, length, user, error_msg, error_location); // Construct the response. response = new HttpMessage(); // Send 200 OK reply. response->setResponseFirstHeaderLine(HTTP_PROTOCOL_VERSION, HTTP_OK_CODE, HTTP_OK_TEXT); // Construct the HTML. char buffer1[100]; #if 0 OsSysLog::add(FAC_SIP, PRI_DEBUG, "%s::processForm *** domain '%s'", mLogName.data(), Gatewayredirector->mDomainName.data()); #endif if (success) { OsSysLog::add(FAC_SIP, PRI_DEBUG, "%s::processForm success user '%s'", mLogName.data(), user->data()); sprintf(buffer1, "<code>sip:<font size=\"+1\">%s</font>@%s:65070</code> redirects to:<br />", user->data(), Gatewayredirector->mDomainName.data()); } else { OsSysLog::add(FAC_SIP, PRI_DEBUG, "%s::processForm failure error_msg '%s', error_location %d", mLogName.data(), error_msg, error_location); strcpy(buffer1, "<i>Error:</i>"); } // Transcribe the input value into buffer2. char buffer2[FORM_SIZE]; char* p; int i; if (success) { // An impossible location. error_location = -1; } for (p = buffer2, i = 0; ; i++) { // If this is the error location, insert the error message. if (i == error_location) { *p++ = '!'; *p++ = '-'; *p++ = '-'; strcpy(p, error_msg); p += strlen(error_msg); *p++ = '-'; *p++ = '-'; *p++ = '!'; } // Test for ending the loop after testing to insert the error message, // because the error message may be after the last character. if (i >= length) { break; } switch (value[i]) { case '<': *p++ = '&'; *p++ = 'l'; *p++ = 't'; *p++ = ';'; break; case '>': *p++ = '&'; *p++ = 'g'; *p++ = 't'; *p++ = ';'; break; case '&': *p++ = '&'; *p++ = 'a'; *p++ = 'm'; *p++ = 'p'; *p++ = ';'; break; default: *p++ = value[i]; break; } } *p++ = '\0'; #endif #endif }