int U_EXPORT main (int argc, char* argv[], char* env[]) { U_ULIB_INIT(argv); U_TRACE(5,"main(%d)",argc) u_init_ulib_hostname(); u_init_ulib_username(); ULog y(U_STRING_FROM_CONSTANT("$PWD/test_log.log"), 1024, "tmp"); y.setPrefix(U_CONSTANT_TO_PARAM(U_SERVER_LOG_PREFIX)); uint32_t i, n = (argc > 1 ? u_atoi(argv[1]) : 10); for (i = 0; i < n; ++i) { y.log(U_CONSTANT_TO_PARAM("message %6d - %H %U %w"), i+1); y.msync(); } cout << "ok" << '\n'; }
static void usp_init_updates() { U_TRACE(5, "::usp_init_updates()") psql_updates = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("hello_world"))); pstmt1 = U_NEW(UOrmStatement(*psql_updates, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?"))); pstmt2 = U_NEW(UOrmStatement(*psql_updates, U_CONSTANT_TO_PARAM("UPDATE World SET randomNumber = ? WHERE id = ?"))); if (pstmt1 == 0 || pstmt2 == 0) { U_ERROR("usp_init_updates(): we cound't connect to db, exiting..."); } pworld_updates = U_NEW(World); pvworld_updates = U_NEW(UVector<World*>(500)); pstmt1->use( pworld_updates->id); pstmt1->into(pworld_updates->randomNumber); pstmt2->use( pworld_updates->randomNumber, pworld_updates->id); #ifndef AS_cpoll_cppsp_DO pvalue = U_NEW(UValue(ARRAY_VALUE)); #endif }
UString USOAPParser::processMessage(const UString& msg, URPCObject& object, bool& bContainsFault) { U_TRACE(0, "USOAPParser::processMessage(%V,%p,%p,%b)", msg.rep, &object, &bContainsFault) U_INTERNAL_ASSERT(msg) UString retval; clearData(); if (U_STRING_FIND(msg, 0, "http://schemas.xmlsoap.org/soap/envelope/") != U_NOT_FOUND) { zero(); bContainsFault = true; (void) retval.assign(U_CONSTANT_TO_PARAM("<?xml version=\"1.0\" ?>" "<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\">" "<env:Header>" "<env:Upgrade>" "<env:SupportedEnvelope qname=\"ns1:Envelope\" xmlns:ns1=\"http://www.w3.org/2003/05/soap-envelope\"/>" "</env:Upgrade>" "</env:Header>" "<env:Body>" "<env:Fault>" "<faultcode>env:VersionMismatch</faultcode>" "<faultstring>Version Mismatch</faultstring>" "</env:Fault>" "</env:Body>" "</env:Envelope>")); } else if (parse(msg)) { U_ASSERT_EQUALS(envelope.methodName.equal(U_CONSTANT_TO_PARAM("Fault")), false) retval = object.processMessage(envelope, bContainsFault); } else { int line = ::XML_GetCurrentLineNumber(m_parser), coln = ::XML_GetCurrentColumnNumber(m_parser); object.setFailed(); URPCMethod::pFault->getFaultReason() = UXMLParser::getErrorMessage(); U_INTERNAL_DUMP("UXMLParser: %V (%d,%d) ", URPCMethod::pFault->getFaultReason().rep, line, coln) URPCMethod::pFault->setDetail("The fault occurred near position (line: %d col: %d) within the message", line, coln); bContainsFault = true; retval = URPCMethod::encoder->encodeFault(URPCMethod::pFault); } U_RETURN_STRING(retval); }
bool UTwilioClient::sendRequest(int method, const char* path, uint32_t path_len, const UString& data) { U_TRACE(0, "UTwilioClient::sendRequest(%d,%.*S,%u,%V)", method, path_len, path, path_len, data.rep) U_INTERNAL_ASSERT_POINTER(client) uri.snprintf(U_CONSTANT_TO_PARAM(TWILIO_API_URL "/" TWILIO_API_VERSION "/Accounts/%.*s/%.*s"), U_STRING_TO_TRACE(client->user), path_len, path); if (method == 4) // DELETE { // send DELETE(4) request to server and get response if (client->sendRequest(4, U_NULLPTR, 0, U_NULLPTR, 0, U_STRING_TO_PARAM(uri))) U_RETURN(true); } else if (method == 3) // PUT { UFile file(data); // upload file to server and get response if (client->upload(uri, file, U_NULLPTR, 0, 3)) U_RETURN(true); } else { UVector<UString> name_value; if (name_value.split(data)) { if (method == 0) // GET { Url url(uri); if (url.setQuery(name_value)) { UString x = url.get(); // send GET(0) request to server and get response if (client->sendRequest(0, U_NULLPTR, 0, U_NULLPTR, 0, U_STRING_TO_PARAM(x))) U_RETURN(true); } } else if (method == 2) // POST { UString body = Url::getQueryBody(name_value); // send POST(2) request to server and get response if (client->sendRequest(2, U_CONSTANT_TO_PARAM("application/x-www-form-urlencoded"), U_STRING_TO_PARAM(body), U_STRING_TO_PARAM(uri))) U_RETURN(true); } } } U_RETURN(false); }
void HttpLocation::stringify(UString& field) { U_TRACE(5, "HttpLocation::stringify(%.*S)", U_STRING_TO_TRACE(field)) field += name; field.append(U_CONSTANT_TO_PARAM(": ")); field += url; field.append(U_CONSTANT_TO_PARAM("\r\n")); U_INTERNAL_DUMP("field = %.*S", U_STRING_TO_TRACE(field)) }
void URPCObject::readFileMethod(UFileConfig& file_method) { // U_TRACE(0, "URPCObject::readFileMethod(%p)", &file_method) // problem with sanitize address UString method_name, method_ns, response_type; while (file_method.loadSection(0,0)) { method_ns = file_method.at(U_CONSTANT_TO_PARAM("NAMESPACE")); method_name = file_method.at(U_CONSTANT_TO_PARAM("METHOD_NAME")); response_type = file_method.at(U_CONSTANT_TO_PARAM("RESPONSE_TYPE")); int rtype = (response_type.equal(U_CONSTANT_TO_PARAM("success_or_failure")) ? success_or_failure : response_type.equal(U_CONSTANT_TO_PARAM("stdin_success_or_failure")) ? stdin_success_or_failure : response_type.equal(U_CONSTANT_TO_PARAM("standard_output")) ? standard_output : response_type.equal(U_CONSTANT_TO_PARAM("stdin_standard_output")) ? stdin_standard_output : response_type.equal(U_CONSTANT_TO_PARAM("standard_output_binary")) ? standard_output_binary : stdin_standard_output_binary); UCommand* command = UCommand::loadConfigCommand(&file_method); // Adds an object method to the list of method the object can call. Take ownership of the memory insertGenericMethod(method_name, method_ns, command, rtype); file_method.table.clear(); } U_ASSERT(methodList.size()) }
void HttpRequestHeader::stringify(UString& field) { U_TRACE(5, "HttpRequestHeader::stringify(%.*S)", U_STRING_TO_TRACE(field)) field += method; field.append(U_CONSTANT_TO_PARAM(" ")); field += url; field.append(U_CONSTANT_TO_PARAM(" ")); field += httpver; field.append(U_CONSTANT_TO_PARAM("\r\n")); HttpHeader::stringify(field); U_INTERNAL_DUMP("field = %.*S", U_STRING_TO_TRACE(field)) }
static void usp_init_fortunes() { U_TRACE(5, "::usp_init_fortunes()") psql_fortune = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("fortune"))); pstmt_fortune = U_NEW(UOrmStatement(*psql_fortune, U_CONSTANT_TO_PARAM("SELECT id, message FROM Fortune"))); if (pstmt_fortune == 0) U_ERROR("usp_init_fortunes(): we cound't connect to db, exiting..."); pfortune = U_NEW(Fortune); pvfortune = U_NEW(UVector<Fortune*>); pmessage = U_NEW(U_STRING_FROM_CONSTANT("Additional fortune added at request time.")); pstmt_fortune->into(*pfortune); }
void HttpResponseHeader::stringify(UString& field) { U_TRACE(5, "HttpResponseHeader::stringify(%.*S)", U_STRING_TO_TRACE(field)) field += httpver; field.append(U_CONSTANT_TO_PARAM(" ")); field += status; field.append(U_CONSTANT_TO_PARAM(" ")); field += reason; field.append(U_CONSTANT_TO_PARAM("\r\n")); HttpHeader::stringify(field); U_INTERNAL_DUMP("field = %.*S", U_STRING_TO_TRACE(field)) }
UString USOAPEncoder::encodeMethod(URPCMethod& method, const UString& nsName) // namespace qualified element information { U_TRACE(0, "USOAPEncoder::encodeMethod(%p,%V)", &method, nsName.rep) method.encode(); // Encode the method by virtual method... if (method.hasFailed()) U_RETURN_STRING(encodedValue); uint32_t num_arg = arg.size(); if (num_arg > 1) encodedValue = arg.join(0, 0); else if (num_arg == 1) encodedValue = arg[0]; else encodedValue.setEmpty(); UString methodName = method.getMethodName(), headerContents = method.getHeaderContent(); if (bIsResponse) (void) methodName.append(U_CONSTANT_TO_PARAM("Response")); buffer.setBuffer(400U + (nsName.size() * 4) + (methodName.size() * 2) + encodedValue.size() + headerContents.size()); buffer.snprintf("<?xml version='1.0' ?>" "<env:Envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" "<env:Header>%v</env:Header>" "<env:Body>" "<%v:%v env:encodingStyle=\"http://www.w3.org/2003/05/soap-encoding\" xmlns:%v=\"%v\">%v</%v:%v>" "</env:Body>" "</env:Envelope>", headerContents.rep, nsName.rep, methodName.rep, nsName.rep, nsName.rep, encodedValue.rep, nsName.rep, methodName.rep); U_RETURN_STRING(buffer); }
HttpBaWwwAuthenticate::HttpBaWwwAuthenticate(const char* name_, unsigned name_len, const char* value_, unsigned value_len) { U_TRACE_REGISTER_OBJECT(5, HttpBaWwwAuthenticate, "%.*S,%u,%.*S,%u", name_len, name_, name_len, value_len, value_, value_len) U_INTERNAL_ASSERT(memcmp(name_, U_CONSTANT_TO_PARAM("WWW-Authenticate")) == 0) U_INTERNAL_ASSERT(memcmp(value_, U_CONSTANT_TO_PARAM(" Basic realm")) == 0) name.assign(name_, name_len); UVector<UString> vec; buffer.assign(value_, value_len); (void) U_VEC_SPLIT(vec, buffer, "="); realm = vec[2]; }
void URPCFault::encode(UString& response) { U_TRACE(0, "URPCFault::encode(%V)", response.rep) UString code = getFaultCode(); response.setBuffer(100U + code.size() + faultReason.size() + detail.size()); response.snprintf(U_CONSTANT_TO_PARAM("%v: %v%s%v"), code.rep, faultReason.rep, (detail.empty() ? "" : " - "), detail.rep); }
int main(int argc, char *argv[]) { U_ULIB_INIT(argv); U_TRACE(5,"main(%d)",argc) UTwilioClient tc(U_STRING_FROM_CONSTANT("SID"), U_STRING_FROM_CONSTANT("TOKEN")); bool ok = tc.getCompletedCalls(); U_INTERNAL_ASSERT(ok) ok = tc.makeCall(U_CONSTANT_TO_PARAM("xxx-xxx-xxxx"), U_CONSTANT_TO_PARAM("xxx-xxx-xxxx"), U_CONSTANT_TO_PARAM("http://xxxx")); U_INTERNAL_ASSERT(ok) ok = tc.sendSMS(U_CONSTANT_TO_PARAM("xxx-xxx-xxxx"), U_CONSTANT_TO_PARAM("xxx-xxx-xxxx"), U_CONSTANT_TO_PARAM("\"Hello, how are you?\"")); U_INTERNAL_ASSERT(ok) }
void HttpBaWwwAuthenticate::stringify(UString& field) { U_TRACE(5, "HttpBaWwwAuthenticate::stringify(%.*S)", U_STRING_TO_TRACE(field)) field += name; field.append(U_CONSTANT_TO_PARAM(": Basic realm=")); bool quoted = (realm[0] == '"'); if (quoted == false) field += '"'; field += realm; if (quoted == false) field += '"'; field.append(U_CONSTANT_TO_PARAM("\r\n")); U_INTERNAL_DUMP("field = %.*S", U_STRING_TO_TRACE(field)) }
UString URPCFault::getFaultCode() { U_TRACE_NO_PARAM(0, "URPCFault::getFaultCode()") UString retval; /* SOAP: * ---------------------------------------------------------------------------------------------------- * VersionMismatch: The faulting node found an invalid element information item instead of the expected * Envelope element information item. The namespace, local name or both did not match * the Envelope element information item required by this recommendation. * * MustUnderstand: An immediate child element information item of the SOAP Header element information * item targeted at the faulting node that was not understood by the faulting node * contained a SOAP mustUnderstand attribute information item with a value of "true". * * DataEncodingUnknown: A SOAP header block or SOAP body child element information item targeted at the * faulting SOAP node is scoped with a data encoding that the faulting node does not support. * * Sender: The message was incorrectly formed or did not contain the appropriate information in order to * succeed. For example, the message could lack the proper authentication or payment information. * It is generally an indication that the message is not to be resent without change. * * Receiver: The message could not be processed for reasons attributable to the processing of the message * rather than to the contents of the message itself. For example, processing could include * communicating with an upstream SOAP node, which did not respond. The message could succeed * if resent at a later point in time * ---------------------------------------------------------------------------------------------------- */ switch (faultCode) { case Sender: (void) retval.assign(U_CONSTANT_TO_PARAM("Client")); break; case Receiver: (void) retval.assign(U_CONSTANT_TO_PARAM("Server")); break; case MustUnderstand: (void) retval.assign(U_CONSTANT_TO_PARAM("MustUnderstand")); break; case VersionMismatch: (void) retval.assign(U_CONSTANT_TO_PARAM("VersionMismatch")); break; case DataEncodingUnknown: (void) retval.assign(U_CONSTANT_TO_PARAM("DataEncodingUnknown")); break; } U_RETURN_STRING(retval); }
int U_EXPORT main (int argc, char* argv[]) { U_ULIB_INIT(argv); U_TRACE(5,"main(%d)",argc) U_ASSERT_EQUALS( UServices::dosMatchWithOR(U_CONSTANT_TO_PARAM("www.sito1.com"), U_CONSTANT_TO_PARAM("SSI|benchmark|www.sito1.com|www.sito2.com"), FNM_INVERT), false) UString buffer(2000); u_base64_max_columns = 72; UBase64::encode(U_CONSTANT_TO_PARAM(TESTOA), buffer); U_INTERNAL_DUMP("buffer = %#.*S", U_STRING_TO_TRACE(buffer)) U_ASSERT( buffer == U_STRING_FROM_CONSTANT(TESTOB) ) UBase64::decode( U_CONSTANT_TO_PARAM(TESTOB), buffer); U_ASSERT( buffer == U_STRING_FROM_CONSTANT(TESTOA) ) UString cmd, result1, result2; int fd_stderr = U_SYSCALL(open, "%S,%d", "err/services.err", O_WRONLY); cmd = U_STRING_FROM_CONSTANT("ls test_services.cpp"); result1 = UCommand::outputCommand(cmd); // U_ASSERT( result1 == U_STRING_FROM_CONSTANT("test_services.cpp\n") ) buffer = UServices::getUUID(); U_INTERNAL_DUMP("buffer = %#.*S", U_STRING_TO_TRACE(buffer)) cmd = U_STRING_FROM_CONSTANT("cat test_services.cpp"); result2 = UCommand::outputCommand(cmd, 0, -1, fd_stderr); U_ASSERT( result2.empty() == false ) cout.write(result2.data(), result2.size()); }
int main(int argc, char* argv[]) { unsigned char encoded[1024]; char* reply = get_reply(); (void) u_xml_encode(argv[1], strlen(argv[1]), encoded); (void) u__snprintf(reply, get_reply_capacity(), U_CONSTANT_TO_PARAM("<h1>Hello %s</h1>"), encoded); return 200; }
HttpLocation::HttpLocation(const char* name_, unsigned name_len, const char* value_, unsigned value_len) { U_TRACE_REGISTER_OBJECT(5, HttpLocation, "%.*S,%u,%.*S,%u", name_len, name_, name_len, value_len, value_, value_len) U_INTERNAL_ASSERT(memcmp(name_, U_CONSTANT_TO_PARAM("Location")) == 0) name.assign(name_, name_len); trim(value_, value_len); url.assign(value_, value_len); U_INTERNAL_DUMP("url = %.*S", U_STRING_TO_TRACE(url)) }
UString UMagic::getType(const char* buffer, uint32_t buffer_len) { U_TRACE(1, "UMagic::getType(%.*S,%u)", buffer_len, buffer, buffer_len) U_INTERNAL_ASSERT_POINTER(magic) UString str; const char* result = (const char*) U_SYSCALL(magic_buffer, "%p,%p,%u", magic, buffer, buffer_len); if (result) (void) str.assign(result); else (void) str.assign(U_CONSTANT_TO_PARAM("application/octet-stream")); U_RETURN_STRING(str); }
void setXAdESReference() { U_TRACE(5, "Application::setXAdESReference()") // SIGNED PROPERTIES UString signingCertificate(U_CAPACITY); // Compute the digest of the signer certificate UString DigestValue(U_CAPACITY); UServices::generateDigest(alg, 0, X509Certificate, DigestValue, true); signingCertificate.snprintf(U_CONSTANT_TO_PARAM(U_XADES_CERTIFICATE_TEMPLATE), U_STRING_TO_TRACE(digest_algorithm), U_STRING_TO_TRACE(DigestValue), U_STRING_TO_TRACE(X509IssuerName), X509SerialNumber); UString signingTime(100U); if (signing_time) { UString dateTime = UTimeDate::strftime(U_CONSTANT_TO_PARAM("%Y-%m-%dT%H:%M:%SZ"), u_now->tv_sec); signingTime.snprintf(U_CONSTANT_TO_PARAM(U_XADES_SIGNING_TIME_TEMPLATE), U_STRING_TO_TRACE(dateTime)); } UString roleTemplate(U_CAPACITY); if (claimed_role.empty() == false) roleTemplate.snprintf(U_CONSTANT_TO_PARAM(U_XADES_SIGNER_ROLE_TEMPLATE), U_STRING_TO_TRACE(claimed_role)); (void) signedProperties.reserve(U_CONSTANT_SIZE(U_XADES_SIGNED_PROPERTIES_TEMPLATE) + 8192U + signingTime.size()); signedProperties.snprintf(U_CONSTANT_TO_PARAM(U_XADES_SIGNED_PROPERTIES_TEMPLATE), U_STRING_TO_TRACE(signingTime), U_STRING_TO_TRACE(signingCertificate), U_STRING_TO_TRACE(production_place_city), U_STRING_TO_TRACE(production_place_state_or_province), U_STRING_TO_TRACE(production_place_postal_code), U_STRING_TO_TRACE(production_place_country_name), U_STRING_TO_TRACE(roleTemplate), U_STRING_TO_TRACE(DataObjectFormat)); to_digest = UXML2Document::xmlC14N(signedProperties); UString signedPropertiesDigestValue(200U); UServices::generateDigest(alg, 0, to_digest, signedPropertiesDigestValue, true); (void) XAdESReference.reserve(U_CONSTANT_SIZE(U_XADES_REFERENCE_TEMPLATE) + signedPropertiesDigestValue.size()); XAdESReference.snprintf(U_CONSTANT_TO_PARAM(U_XADES_REFERENCE_TEMPLATE), U_STRING_TO_TRACE(digest_algorithm), U_STRING_TO_TRACE(signedPropertiesDigestValue)); }
UString USOAPEncoder::encodeMethod(URPCMethod& method, const UString& nsName) // namespace qualified element information { U_TRACE(0, "USOAPEncoder::encodeMethod(%p,%.*S)", &method, U_STRING_TO_TRACE(nsName)) method.encode(); // Encode the method by virtual method... if (method.hasFailed()) U_RETURN_STRING(encodedValue); uint32_t num_arg = arg.size(); if (num_arg > 1) encodedValue = arg.join(0, 0); else if (num_arg == 1) encodedValue = arg[0]; else encodedValue.setEmpty(); UString methodName = method.getMethodName(), headerContents = method.getHeaderContent(); if (bIsResponse) (void) methodName.append(U_CONSTANT_TO_PARAM("Response")); uint32_t sz_nsName = nsName.size(), sz_methodName = methodName.size(), sz_encodedValue = encodedValue.size(), sz_headerContents = headerContents.size(); const char* ptr_nsName = nsName.data(); const char* ptr_methodName = methodName.data(); const char* ptr_encodedValue = encodedValue.data(); const char* ptr_headerContents = headerContents.data(); buffer.setBuffer(400U + (sz_nsName * 4) + (sz_methodName * 2) + sz_encodedValue + sz_headerContents); buffer.snprintf("<?xml version='1.0' ?>" "<env:Envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" "<env:Header>%.*s</env:Header>" "<env:Body>" "<%.*s:%.*s env:encodingStyle=\"http://www.w3.org/2003/05/soap-encoding\" xmlns:%.*s=\"%.*s\">%.*s</%.*s:%.*s>" "</env:Body>" "</env:Envelope>", sz_headerContents, ptr_headerContents, sz_nsName, ptr_nsName, sz_methodName, ptr_methodName, sz_nsName, ptr_nsName, sz_nsName, ptr_nsName, sz_encodedValue, ptr_encodedValue, sz_nsName, ptr_nsName, sz_methodName, ptr_methodName); U_RETURN_STRING(buffer); }
UString UHttpClient_Base::getBasicAuthorizationHeader() { U_TRACE_NO_PARAM(0, "UHttpClient_Base::getBasicAuthorizationHeader()") UString headerValue(300U), tmp(100U), data(100U); // --------------------------------------------------------------------------------------------------------------------------- // According to RFC 2617 HTTP Authentication: Basic and Digest Access Authentication // --------------------------------------------------------------------------------------------------------------------------- // For "Basic" authentication, the user and password are concatentated with a colon separator before being encoded in base64. // According to RFC 2068 (HTTP/1.1) the Username and Password are defined as TEXT productions and are therefore supposed to be // encoded in ISO-8859-1 before being Base64-encoded // --------------------------------------------------------------------------------------------------------------------------- tmp.snprintf(U_CONSTANT_TO_PARAM("%v:%v"), user.rep, password.rep); UBase64::encode(tmp, data); // Authorization: Basic cy5jYXNhenphOnN0ZWZhbm8x headerValue.snprintf(U_CONSTANT_TO_PARAM("Basic %v"), data.rep); U_RETURN_STRING(headerValue); }
X509* UCertificate::readX509(const UString& x, const char* format) { U_TRACE(1, "UCertificate::readX509(%V,%S)", x.rep, format) BIO* in; X509* _x509 = 0; UString tmp = x; if (format == 0) format = (x.isBinary() ? "DER" : "PEM"); if (strncmp(format, U_CONSTANT_TO_PARAM("PEM")) == 0 && strncmp(x.data(), U_CONSTANT_TO_PARAM("-----BEGIN CERTIFICATE-----")) != 0) { unsigned length = x.size(); UString buffer(length); UBase64::decode(x.data(), length, buffer); if (buffer && u_base64_errors == 0) { tmp = buffer; format = "DER"; } } in = (BIO*) U_SYSCALL(BIO_new_mem_buf, "%p,%d", U_STRING_TO_PARAM(tmp)); _x509 = (X509*) (strncmp(format, U_CONSTANT_TO_PARAM("PEM")) == 0 ? U_SYSCALL(PEM_read_bio_X509, "%p,%p,%p,%p", in, 0, 0, 0) : U_SYSCALL(d2i_X509_bio, "%p,%p", in, 0)); (void) U_SYSCALL(BIO_free, "%p", in); U_RETURN_POINTER(_x509, X509); }
int UEchoPlugIn::handlerRequest() { U_TRACE(0, "UEchoPlugIn::handlerRequest()") #ifdef U_RESPONSE_FOR_TEST UClientImage_Base::wbuffer->assign(U_CONSTANT_TO_PARAM(U_RESPONSE_FOR_TEST)); #else *UClientImage_Base::wbuffer = *UClientImage_Base::request; #endif UClientImage_Base::body->clear(); UHTTP::endRequestProcessing(); U_RETURN(U_PLUGIN_HANDLER_FINISHED); }
bool UREDISClient_Base::connect(const char* phost, unsigned int _port) { U_TRACE(0, "UREDISClient_Base::connect(%S,%u)", phost, _port) UString host; if (phost) (void) host.assign(phost); else { const char* env_redis_host = (const char*) U_SYSCALL(getenv, "%S", "REDIS_HOST"); if (env_redis_host == 0) { (void) UClient_Base::response.replace(U_CONSTANT_TO_PARAM("connection disabled")); U_RETURN(false); } (void) host.assign(env_redis_host, u__strlen(env_redis_host, __PRETTY_FUNCTION__)); const char* env_redis_port = (const char*) U_SYSCALL(getenv, "%S", "REDIS_PORT"); if (env_redis_port) _port = atoi(env_redis_port); } if (UClient_Base::setHostPort(host, _port) && UClient_Base::connect()) { UClient_Base::iovcnt = 4; UClient_Base::iov[1].iov_base = UClient_Base::iov[4].iov_base = (caddr_t)" "; UClient_Base::iov[1].iov_len = UClient_Base::iov[4].iov_len = 1; UClient_Base::iov[3].iov_base = UClient_Base::iov[5].iov_base = (caddr_t)U_CRLF; UClient_Base::iov[3].iov_len = UClient_Base::iov[5].iov_len = 2; U_DUMP("getRedisVersion() = %V", getRedisVersion().rep) U_RETURN(true); } U_RETURN(false); }
int main(int argc, char* argv[]) { u_init_ulib(argv); U_INTERNAL_TRACE("main(%d,%p)", argc, argv) if (argc == 1) do_cipher(argv[1], U_ENCRYPT); else if (argc == 2 && memcmp(argv[1], U_CONSTANT_TO_PARAM("-d")) == 0) do_cipher(argv[2], U_DECRYPT); else { fprintf(stderr, "%s", usage); exit(1); } return 0; }
int main(int argc, char** argv) { u_init_ulib(argv); U_INTERNAL_TRACE("main(%d,%p)", argc, argv) U_INTERNAL_PRINT("argv[0] = %s\nargv[1] = %s", argv[0], argv[1]) if (argc == 2) u_do_cipher(argv[1], U_ENCRYPT); else if (argc == 3 && memcmp(argv[1], U_CONSTANT_TO_PARAM("-d")) == 0) u_do_cipher(argv[2], U_DECRYPT); else { fprintf(stderr, "%s", usage); exit(1); } return 0; }
UString getOptionValue(const char* param, const char* tag) { U_TRACE(5, "Application::getOptionValue(%S,%S)", param, tag) UString result; if (param && *param) result = param; else { UString tmp(100U); U_INTERNAL_DUMP("xades_c = %b", xades_c) tmp.snprintf(U_CONSTANT_TO_PARAM("XAdES-%s.%s"), (xades_c ? "C" : "BES"), tag); result = cfg[tmp]; } U_RETURN_STRING(result); }
UString URPCObject::processMessage(URPCEnvelope& envelope, bool& bContainsFault) { U_TRACE(0, "URPCObject::processMessage(%p,%p)", &envelope, &bContainsFault) U_INTERNAL_ASSERT_POINTER(URPCMethod::encoder) UString retval; // Iterate over the list of methods URPCMethod* method = find(envelope.getMethodName()); if (method == 0) { // Return object not found error. This would be a Client fault setFailed(); URPCMethod::pFault->setFaultReason(U_CONSTANT_TO_PARAM("The requested method does not exist on this server")); bContainsFault = true; retval = URPCMethod::encoder->encodeFault(URPCMethod::pFault); } else { UString ns = envelope.getNsName(); U_INTERNAL_DUMP("envelope.nsName = %V", ns.rep) // check the name of namespace qualified element information (gSOAP) if (ns.empty()) ns = method->getNamespaces(); if (ns.empty()) ns = *UString::str_ns; bContainsFault = (method->execute(envelope) == false); retval = URPCMethod::encoder->encodeMethodResponse(*method, ns); } U_RETURN_STRING(retval); }
U_EXPORT ostream& operator<<(ostream& os, const UXMLElement& e) { U_TRACE(0+256, "UXMLElement::operator<<(%p,%p)", &os, &e) // encode the element name os.put('<'); if (e.namespaceName) { os << e.namespaceName; os.put(':'); } os << e.accessorName; os.put(' '); // encode the element's attributes os << e.attributeContainer; // terminate the element declaration os.put(' '); os.put('>'); if (e.value) { (void) os.write(U_CONSTANT_TO_PARAM(" VALUE = ")); char buffer[4096]; uint32_t len = u_escape_encode((const unsigned char*)U_STRING_TO_PARAM(e.value), buffer, sizeof(buffer), false); (void) os.write(buffer, len); } return os; }