result_t XmlElement::set_id(exlib::string newVal) { if (newVal.empty()) return removeAttribute("id"); return setAttribute("id", newVal); }
result_t os_base::time(exlib::string tmString, date_t& retVal) { if (tmString.empty()) retVal.now(); else retVal.parse(tmString); return 0; }
result_t XmlElement::set_className(exlib::string newVal) { if (m_isXml) return CALL_E_INVALID_CALL; if (newVal.empty()) return removeAttribute("class"); return setAttribute("class", newVal); }
result_t XmlElement::lookupNamespaceURI(exlib::string prefix, exlib::string& retVal) { if (globalNamespaceURI(prefix, retVal)) return 0; result_t hr = m_attrs->lookupNamespaceURI(prefix, retVal); if (hr < 0) return hr; if (hr != CALL_RETURN_NULL) return retVal.empty() ? CALL_RETURN_NULL : 0; return XmlNodeImpl::lookupNamespaceURI(prefix, retVal); }
result_t MongoCollection::runCommand(exlib::string cmd, exlib::string cmd1, exlib::string arg, v8::Local<v8::Object>& retVal) { obj_ptr<MongoDB> db(m_db); if (!db) return CHECK_ERROR(CALL_E_INVALID_CALL); bson bbq; bson_init(&bbq); bson_append_string(&bbq, cmd.c_str(), m_name.c_str()); if (!cmd1.empty()) bson_append_string(&bbq, cmd1.c_str(), arg.c_str()); bson_finish(&bbq); return db->bsonHandler(&bbq, retVal); }
void XmlElement::fix_prefix(exlib::string namespaceURI, exlib::string& prefix) { exlib::string _namespaceURI; int32_t i; if (!prefix.empty() && lookupNamespaceURI(prefix, _namespaceURI) == CALL_RETURN_NULL) setAttributeNS("http://www.w3.org/2000/xmlns/", ("xmlns:" + prefix), namespaceURI); else if (_namespaceURI != namespaceURI) { char buf[64]; for (i = 0; i < 65536; i++) { sprintf(buf, "a%d", i); if (lookupNamespaceURI(buf, _namespaceURI) == CALL_RETURN_NULL) { prefix = buf; setAttributeNS("http://www.w3.org/2000/xmlns/", ("xmlns:" + prefix), namespaceURI); return; } } } }
result_t X509Cert::get_type(exlib::string &retVal) { mbedtls_x509_crt *crt = get_crt(); if (!crt) return CHECK_ERROR(CALL_E_INVALID_CALL); int32_t cert_type = crt->ns_cert_type; int32_t i; for (i = 0; i < (int32_t)ARRAYSIZE(g_types); i ++) { if (cert_type & g_types[i].id) { if (!retVal.empty()) retVal.append(", ", 2); retVal.append(g_types[i].name); } } return 0; }
result_t fs_base::clearZipFS(exlib::string fname) { if (fname.empty()) { s_cachelock.lock(); s_cache.clear(); s_cachelock.unlock(); } else { std::list<obj_ptr<cache_node>>::iterator it; exlib::string safe_name; path_base::normalize(fname, safe_name); s_cachelock.lock(); for (it = s_cache.begin(); it != s_cache.end(); ++it) if ((*it)->m_name == safe_name) { s_cache.erase(it); break; } s_cachelock.unlock(); } return 0; }