UXMLAttribute* UXMLElement::getAttribute(const UString& attributeName) { U_TRACE(0, "UXMLElement::getAttribute(%.*S)", U_STRING_TO_TRACE(attributeName)) uint32_t n = numAttributes(); if (n) { UXMLAttribute* entry; UString szAccessor, szNamespace; splitNamespaceAndName(attributeName, szNamespace, szAccessor); for (uint32_t i = 0; i < n; ++i) { entry = attributeAt(i); if ((entry->getAccessor() == attributeName) && (szNamespace.empty() || (entry->getNamespaceName() == szNamespace))) { // We found the attribute U_RETURN_POINTER(entry, UXMLAttribute); } } } U_RETURN_POINTER(0, UXMLAttribute); }
xmlNodePtr UXML2Document::findNode(const xmlNodePtr parent, const xmlChar* name, const xmlChar* ns) { U_TRACE(0, "UXML2Document::findNode(%p,%S,%S)", parent, name, ns) U_INTERNAL_ASSERT_POINTER(name) xmlNodePtr ret; xmlNodePtr cur = parent; while (cur) { if (cur->type == XML_ELEMENT_NODE && UXML2Node(cur).checkNodeName(name, ns)) { U_RETURN_POINTER(cur, xmlNode); } if (cur->children) { ret = findNode(cur->children, name, ns); if (ret) U_RETURN_POINTER(ret, xmlNode); } cur = cur->next; } U_RETURN_POINTER(0, xmlNode); }
X509_REQ* UPKCS10::readPKCS10(const UString& x, const char* format) { U_TRACE(1, "UPKCS10::readPKCS10(%.*S,%S)", U_STRING_TO_TRACE(x), format) BIO* in; UString tmp = x; X509_REQ* _request = 0; if (format == 0) format = (x.isBinary() ? "DER" : "PEM"); if (U_STREQ(format, "PEM") && U_STRNCMP(x.data(), "-----BEGIN CERTIFICATE REQUEST-----")) { unsigned length = x.size(); UString buffer(length); if (UBase64::decode(x.data(), length, buffer) == false) goto next; tmp = buffer; format = "DER"; } next: in = (BIO*) U_SYSCALL(BIO_new_mem_buf, "%p,%d", U_STRING_TO_PARAM(tmp)); _request = (X509_REQ*) (U_STREQ(format, "PEM") ? U_SYSCALL(PEM_read_bio_X509_REQ, "%p,%p,%p,%p", in, 0, 0, 0) : U_SYSCALL(d2i_X509_REQ_bio, "%p,%p", in, 0)); (void) U_SYSCALL(BIO_free, "%p", in); U_RETURN_POINTER(_request, X509_REQ); }
UIOCallback* UTranformInputURI::find(const char* uri) { U_TRACE(0, "UTranformInputURI::find(%S)", uri) U_INTERNAL_ASSERT_POINTER(allIOCallbacks) UIOCallback* callbacks; for (uint32_t i = 0, n = allIOCallbacks->size(); i < n; ++i) { callbacks = (*allIOCallbacks)[i]; if (callbacks->matchcallback(uri)) U_RETURN_POINTER(callbacks, UIOCallback); } U_RETURN_POINTER(U_NULLPTR, UIOCallback); }
URPCMethod* URPCObject::find(const UString& methodName) { U_TRACE(0, "URPCObject::find(%V)", methodName.rep) URPCMethod* method; uint32_t n = methodList.size(); // Iterate over the list of methods of the object for (uint32_t i = 0; i < n; ++i) { method = methodList[i]; if (methodName == method->getMethodName()) U_RETURN_POINTER(method, URPCMethod); } U_RETURN_POINTER(0, URPCMethod); }
UStringRep* UObjectIO::create() { U_TRACE(0, "UObjectIO::create()") UObjectIO::output(); UStringRep* rep = U_NEW(UStringRep(buffer_output, buffer_output_len)); U_INTERNAL_PRINT("rep = %.*S", U_STRING_TO_TRACE(*rep)) U_RETURN_POINTER(rep, UStringRep); }
xmlNodePtr UXML2Document::findChild(const xmlNodePtr parent, const xmlChar* name, const xmlChar* ns) { U_TRACE(0, "UXML2Document::findChild(%p,%S,%S)", parent, name, ns) U_INTERNAL_ASSERT_POINTER(name) U_INTERNAL_ASSERT_POINTER(parent) xmlNodePtr cur = parent->children; while (cur) { if (cur->type == XML_ELEMENT_NODE && UXML2Node(cur).checkNodeName(name, ns)) { U_RETURN_POINTER(cur, xmlNode); } cur = cur->next; } U_RETURN_POINTER(U_NULLPTR, xmlNode); }
xmlNodePtr UXML2Document::findParent(const xmlNodePtr cur, const xmlChar* name, const xmlChar* ns) { U_TRACE(0, "UXML2Document::findParent(%p,%S,%S)", cur, name, ns) U_INTERNAL_ASSERT_POINTER(cur) U_INTERNAL_ASSERT_POINTER(name) xmlNodePtr ret; if (cur->type == XML_ELEMENT_NODE && UXML2Node(cur).checkNodeName(name, ns)) { U_RETURN_POINTER(cur, xmlNode); } if (cur->parent) { ret = findParent(cur->parent, name, ns); if (ret) U_RETURN_POINTER(ret, xmlNode); } U_RETURN_POINTER(0, xmlNode); }
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); }