r3419 - trunk/libmnetutil/source
erik at minisip.org
erik at minisip.org
Thu Sep 6 17:31:26 CEST 2007
Author: erik
Date: 2007-09-06 17:31:25 +0200 (Thu, 06 Sep 2007)
New Revision: 3419
Modified:
trunk/libmnetutil/source/LdapUrl.cxx
Log:
libmnetutil:
- Compile fix for machines without openldap (and without --enable-ldap on
libmnetutil).
Modified: trunk/libmnetutil/source/LdapUrl.cxx
===================================================================
--- trunk/libmnetutil/source/LdapUrl.cxx 2007-09-06 12:14:37 UTC (rev 3418)
+++ trunk/libmnetutil/source/LdapUrl.cxx 2007-09-06 15:31:25 UTC (rev 3419)
@@ -35,8 +35,12 @@
#endif
LdapUrl::LdapUrl(std::string url) {
+#ifdef ENABLE_LDAP
clear(); // Reset URL parts to default values
setUrl(url); // Parse supplied URL
+#else
+ throw LdapException("LDAP support not enabled");
+#endif
}
LdapUrl::LdapUrl() {
@@ -44,6 +48,7 @@
}
void LdapUrl::clear() {
+#ifdef ENABLE_LDAP
host = "";
port = LDAP_PORT;
filter = "(objectClass=*)";
@@ -52,6 +57,9 @@
validUrl = false;
attributes = std::vector<std::string>();
extensions = std::vector<LdapUrlExtension>();
+#else
+ throw LdapException("LDAP support not enabled");
+#endif
}
bool LdapUrl::isValid() const {
@@ -59,7 +67,7 @@
}
std::string LdapUrl::getString() const {
-
+#ifdef ENABLE_LDAP
// Start off with the schema and host name
std::string url("ldap://");
url += host;
@@ -109,6 +117,9 @@
}
return url;
+#else
+ throw LdapException("LDAP support not enabled");
+#endif
}
bool LdapUrl::isUnreservedChar(char in) const {
char* alphabetUnreserved = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";
@@ -129,6 +140,7 @@
}
void LdapUrl::setUrl(const std::string url) {
+#ifdef ENABLE_LDAP
std::string::size_type lastPos = 0, pos = 0, posTemp = 0;
if (strCaseCmp(url.substr(0, 7).c_str(), "ldap://") == 0) {
@@ -204,9 +216,10 @@
} else {
validUrl = false;
}
+#endif
}
void LdapUrl::printDebug() {
-
+#ifdef ENABLE_LDAP
std::cerr << " VALID? " << (validUrl ? "yes" : "NO") << std::endl;
std::cerr << " Host: [" << host << "]" << std::endl;
@@ -226,6 +239,9 @@
std::cerr << " DN: [" << dn << "]" << std::endl;
std::cerr << " Scope: [" << (scope == LDAP_SCOPE_BASE ? "base" : (scope == LDAP_SCOPE_ONELEVEL ? "one" : "sub")) << "]" << std::endl;
+#else
+ throw LdapException("LDAP support not enabled");
+#endif
}
bool LdapUrl::hasCriticalExtension() const {
@@ -288,6 +304,7 @@
res += binToHex(reinterpret_cast<const unsigned char*>(&in), sizeof(in));
return res;
}
+
char LdapUrl::decodeChar(const std::string in) const {
if (in.length() == 3) {
return (charToNum(in[1]) << 4) + (charToNum(in[2]));
@@ -318,6 +335,7 @@
}
return res;
}
+
std::string LdapUrl::percentDecode(const std::string & in) const {
std::string res;
for (size_t i=0; i < in.length(); i++) {
@@ -329,3 +347,4 @@
}
return res;
}
+
More information about the Minisip-devel
mailing list