bool USOAPParser::parse(const UString& msg) { U_TRACE(0, "USOAPParser::parse(%.*S)", U_STRING_TO_TRACE(msg)) initParser(); if (UXMLParser::parse(msg)) { // If we succeeded, get the name of the method being called. This of course assumes only // one method in the body, and that there are no objects outside of the serialization root. // This method will need an override if this assumption is invalid U_INTERNAL_ASSERT_POINTER(body) method = body->childAt(0); envelope.methodName = method->elem()->getAccessorName(); // load the parameters for the method to execute UString param; for (uint32_t i = 0, num_arguments = method->numChild(); i < num_arguments; ++i) { param = method->childAt(i)->elem()->getValue(); // check if parameter optional if (param) envelope.arg->push_back(param); } U_RETURN(true); } U_RETURN(false); }
uint32_t UXML2Document::getElement(UString& element, uint32_t pos, const char* tag, uint32_t tag_len) { U_TRACE(0, "UXML2Document::getElement(%V,%u,%.*S,%u)", element.rep, pos, tag_len, tag, tag_len) U_INTERNAL_ASSERT_POINTER(tag) uint32_t start = data.find(tag, pos, tag_len); if (start == U_NOT_FOUND || data.c_char(start-1) != '<') { U_RETURN(U_NOT_FOUND); } uint32_t end = data.find(tag, start + tag_len, tag_len); if (end == U_NOT_FOUND || data.c_char(end-1) != '/' || data.c_char(end-2) != '<') { U_RETURN(U_NOT_FOUND); } element = data.substr(start - 1, end + tag_len - start + 2); end += tag_len; U_RETURN(end); }
bool UDirWalk::setDirectory(const char* dir, const char* _filter, uint32_t _filter_len) { U_TRACE(0, "UDirWalk::setDirectory(%S,%.*S,%u", dir, _filter_len, _filter, _filter_len) pthis->pathlen = u__strlen(dir, __PRETTY_FUNCTION__); dir = u_getPathRelativ(dir, &(pthis->pathlen)); U_INTERNAL_ASSERT_MAJOR(pthis->pathlen, 0) if (UFile::access(dir) == false) { pthis->pathlen = 0; U_RETURN(false); } U__MEMCPY(pthis->pathname, dir, pthis->pathlen); pthis->pathname[pthis->pathlen] = '\0'; if (_filter_len) { filter = _filter; filter_len = _filter_len; u_pfn_flags = 0; u_pfn_match = u_dosmatch_with_OR; } U_RETURN(true); }
bool UDirWalk::setDirectory(const UString& dir, const char* _filter, uint32_t _filter_len) { U_TRACE(0, "UDirWalk::setDirectory(%.*S,%.*S,%u)", U_STRING_TO_TRACE(dir), _filter_len, _filter, _filter_len) pthis->pathlen = dir.size(); const char* pdir = u_getPathRelativ(dir.data(), &(pthis->pathlen)); U_INTERNAL_ASSERT_MAJOR(pthis->pathlen, 0) U_MEMCPY(pthis->pathname, pdir, pthis->pathlen); pthis->pathname[pthis->pathlen] = '\0'; if (UFile::access(pthis->pathname) == false) { pthis->pathlen = 0; U_RETURN(false); } setFilter(_filter, _filter_len); U_RETURN(true); }
bool URDBServer::open(const UString& pathdb, uint32_t log_size) { U_TRACE(0, "URDBServer::open(%V,%u)", pathdb.rep, log_size) URDBClientImage::rdb = rdb; if (rdb->open(pathdb, log_size)) U_RETURN(true); U_RETURN(false); }
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* UDynamic::operator[](const char* _sym) { U_TRACE(0, "UDynamic::operator[](%S)", _sym) U_CHECK_MEMORY U_INTERNAL_ASSERT_POINTER(handle) #if defined(_MSWINDOWS_) addr = (void*) ::GetProcAddress(handle, _sym); #else addr = U_SYSCALL(dlsym, "%p,%S", handle, _sym); #endif if (addr == 0) { # if defined(_MSWINDOWS_) err = "symbol missing"; # else err = ::dlerror(); # endif U_WARNING("UDynamic::operator[](%S) failed: %.*S", _sym, 256, err); } U_RETURN(addr); }
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) { UClient_Base::response.snprintf("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); }
bool UTranformInclC14N::execute(UString& data) { U_TRACE(0, "UTranformInclC14N::execute(%.*S)", U_STRING_TO_TRACE(data)) data = UXML2Document::xmlC14N(data); U_RETURN(true); }
bool UTranformBase64::execute(UString& data) { U_TRACE(0, "UTranformBase64::execute(%.*S)", U_STRING_TO_TRACE(data)) UString buffer(data.size()); UBase64::decode(data, buffer); if (buffer) { data = buffer; U_RETURN(true); } U_RETURN(false); }
bool UBase64::decodeUrl(const char* s, uint32_t n, UString& buffer) { U_TRACE(0, "UBase64::decodeUrl(%.*S,%u,%.*S)", n, s, n, U_STRING_TO_TRACE(buffer)) uint32_t pos = u_base64url_decode(s, n, (unsigned char*)buffer.data()); buffer.size_adjust(pos); U_INTERNAL_DUMP("u_base64_errors = %u buffer(%u) = %#.*S", u_base64_errors, buffer.size(), U_STRING_TO_TRACE(buffer)) if (pos > 0 && u_base64_errors == 0) { U_RETURN(true); } U_RETURN(false); }
bool UDynamic::load(const char* pathname) { U_TRACE(0, "UDynamic::load(%S)", pathname) U_CHECK_MEMORY U_INTERNAL_ASSERT_EQUALS(handle, 0) #ifdef _MSWINDOWS_ handle = ::LoadLibrary(pathname); #else /** * -------------------------------------------------------------------- * Perform lazy binding * -------------------------------------------------------------------- * Only resolve symbols as the code that references them is executed. * If the symbol is never referenced, then it is never resolved. * Lazy binding is only performed for function references; references * to variables are always immediately bound when the library is loaded * -------------------------------------------------------------------- */ handle = U_SYSCALL(dlopen, "%S,%d", pathname, RTLD_LAZY); // RTLD_NOW #endif if (handle == 0) { # if defined(_MSWINDOWS_) err = "load failed"; # else err = ::dlerror(); # endif U_WARNING("UDynamic::load(%S) failed: %.*S", pathname, 256, err); U_RETURN(false); } #ifndef _MSWINDOWS_ (void) ::dlerror(); /* Clear any existing error */ #endif U_RETURN(true); }
U_NO_EXPORT int UTDB::_print(TDB_CONTEXT* tdb, TDB_DATA key, TDB_DATA dbuf, void* ptr) { U_TRACE(0, "UTDB::_print(%p,%J,%J,%p)", tdb, key, dbuf, ptr) U_INTERNAL_ASSERT_POINTER(ptr) ((UString*)ptr)->printKeyValue((const char*)key.dptr, key.dsize, (const char*)dbuf.dptr, dbuf.dsize); U_RETURN(0); // A non-zero return value from fn() indicates that the traversal should stop }
static VALUE URUBY_io_rewind(VALUE obj, VALUE args) { U_TRACE(0, "URUBY_io_rewind(%llu,%llu)", obj, args) post_readline_pos = UClientImage_Base::body->data(); post_readline_watermark = post_readline_pos + UClientImage_Base::body->size(); U_INTERNAL_DUMP("post_readline_pos = %p post_readline_watermark = %p", post_readline_pos, post_readline_watermark) U_RETURN(Qnil); }
int UProxyPlugIn::handlerConfig(UFileConfig& cfg) { U_TRACE(0, "UProxyPlugIn::handlerConfig(%p)", &cfg) vservice = U_NEW(UVector<UModProxyService*>); vmsg_error = U_NEW(UVector<UString>); UModProxyService::loadConfig(cfg, *vservice, vmsg_error); U_RETURN(U_PLUGIN_HANDLER_GO_ON); }
U_NO_EXPORT int UTDB::_getKeys(TDB_CONTEXT* tdb, TDB_DATA key, TDB_DATA dbuf, void* ptr) { U_TRACE(0, "UTDB::_getKeys(%p,%J,%J,%p)", tdb, key, dbuf, ptr) U_INTERNAL_ASSERT_POINTER(ptr) UString str((void*)key.dptr, key.dsize); ((UVector<UString>*)ptr)->push(str); U_RETURN(0); // A non-zero return value from fn() indicates that the traversal should stop }
bool UTranformSha256::execute(UString& data) { U_TRACE(0, "UTranformSha256::execute(%.*S)", U_STRING_TO_TRACE(data)) UString ObjectDigestValue(200U); UServices::generateDigest(U_HASH_SHA256, 0, data, ObjectDigestValue, true); data = ObjectDigestValue; U_RETURN(true); }
bool UTranformXPointer::setExpr(const char* expr, int nodeSetType, xmlNodePtr node) { U_TRACE(0, "UTranformXPointer::setExpr(%S,%d,%p)", expr, nodeSetType, node) UBaseTransform::hereNode = node; UXPathData* data; U_NEW(UXPathData, data, UXPathData(UXPathData::XPOINTER, nodeSetType, expr)); if (data->registerNamespaces(node)) { dataList.push(data); U_RETURN(true); } U_DELETE(data) U_RETURN(false); }
int UHttpPlugIn::handlerRead() { U_TRACE_NO_PARAM(0, "UHttpPlugIn::handlerRead()") #if defined(HAVE_SYS_INOTIFY_H) && defined(U_HTTP_INOTIFY_SUPPORT) U_INTERNAL_ASSERT_POINTER(UHTTP::cache_file) UHTTP::in_READ(); #endif U_RETURN(U_NOTIFIER_OK); }
static VALUE URUBY_io_new(VALUE _class) { U_TRACE(0, "URUBY_io_new(%llu)", _class) VALUE self = Data_Wrap_Struct(_class, U_NULLPTR, U_NULLPTR, U_NULLPTR); U_INTERNAL_DUMP("self = %llu", self) U_SYSCALL_VOID(rb_obj_call_init, "%llu,%d,%p", self, 0, U_NULLPTR); U_RETURN(self); }
virtual int handlerTime() { U_TRACE(0, "MyAlarm1::handlerTime()") // return value: // --------------- // -1 - normal // 0 - monitoring // --------------- U_RETURN(-1); }
bool UEscape::decode(const char* s, uint32_t n, UString& buffer) { U_TRACE(0, "UEscape::decode(%.*S,%u,%.*S)", n, s, n, U_STRING_TO_TRACE(buffer)) uint32_t pos = u_escape_decode(s, n, (unsigned char*)buffer.data()); buffer.size_adjust(pos); bool result = (pos > 0); U_RETURN(result); }
bool UMagic::init(int flags) { U_TRACE(1, "UMagic::init(%d)", flags) U_INTERNAL_ASSERT_EQUALS(magic, U_NULLPTR) magic = (magic_t) U_SYSCALL(magic_open, "%d", flags); bool ok = (magic && U_SYSCALL(magic_load, "%p,%S", magic, U_NULLPTR) != -1); U_DUMP("ok = %b status = %.*S", ok, 512, getError()) U_RETURN(ok); }
static bool reportEntry(const UString& elem) { U_TRACE(5, "Application::reportEntry(%.*S)", U_STRING_TO_TRACE(elem)) UString tmp(U_CAPACITY); UXMLEscape::encode(elem, tmp); (void) sprintf(buffer, form, U_STRING_TO_TRACE(tmp)); std::cout << buffer; U_RETURN(false); }
bool UProcess::fork() { U_TRACE(1, "UProcess::fork()") U_CHECK_MEMORY _pid = U_FORK(); if (child()) u_setPid(); running = (_pid != -1); U_RETURN(running); }
virtual int handlerTime() { U_TRACE(0+256, "MyAlarm1::handlerTime()") // return value: // --------------- // -1 - normal // 0 - monitoring // --------------- cout.write(buffer, u__snprintf(buffer, sizeof(buffer), "MyAlarm1::handlerTime() u_now = %1D expire = %#1D\n", UEventTime::expire())); U_RETURN(-1); }
bool URPCClient_Base::readResponse(USocket* sk, UString& buffer, UString& response) { U_TRACE(0, "URPCClient_Base::readResponse(%p,%V,%V)", sk, buffer.rep, response.rep) uint32_t rstart = 0; // NB: we force for U_SUBSTR_INC_REF case (string can be referenced more)... buffer.setEmptyForce(); response.setEmptyForce(); if (URPC::readTokenString(sk, U_NULLPTR, buffer, rstart, response)) { // NB: we force for U_SUBSTR_INC_REF case (string can be referenced more)... buffer.size_adjust_force(U_TOKEN_NM); } U_INTERNAL_DUMP("buffer = %V response = %V", buffer.rep, response.rep) if (buffer) U_RETURN(true); U_RETURN(false); }
bool UProcess::fork() { U_TRACE_NO_PARAM(1, "UProcess::fork()") U_CHECK_MEMORY _pid = U_FORK(); if (child()) u_setPid(); running = (_pid != -1); U_INTERNAL_DUMP("%P running = %b", running) U_RETURN(running); }
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 UCDB::open(bool brdonly) { U_TRACE(0, "UCDB::open(%b)", brdonly) nrecord = start_hash_table_slot = 0; if (UFile::isOpen() || UFile::open(brdonly ? O_RDONLY : O_CREAT | O_RDWR)) { UFile::readSize(); if (UFile::st_size) { (void) UFile::memmap(PROT_READ | (brdonly ? 0 : PROT_WRITE)); if (UFile::map == MAP_FAILED) { data.dptr = 0; hp = &hp_buf; hr = &hr_buf; slot = &slot_buf; (void) UFile::pread(&start_hash_table_slot, sizeof(uint32_t), 0); } else { UFile::close(); start_hash_table_slot = *(uint32_t*)UFile::map; } nrecord = (UFile::st_size - start_hash_table_slot) / sizeof(cdb_hash_table_slot); } U_INTERNAL_DUMP("nrecord = %u", nrecord) # ifdef DEBUG if (UFile::st_size) checkForAllEntry(); # endif U_RETURN(true); }