Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christopher Ng
OpenLDAP
Commits
2d39f617
Commit
2d39f617
authored
26 years ago
by
Kurt Zeilenga
Browse files
Options
Downloads
Patches
Plain Diff
Add LDAP_OPT_API_FEATURE_INFO to obtain feature info (ie: version)
at runtime.
parent
811cfab9
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/ldap.h
+10
-0
10 additions, 0 deletions
include/ldap.h
libraries/libldap/apitest.c
+11
-0
11 additions, 0 deletions
libraries/libldap/apitest.c
libraries/libldap/options.c
+39
-13
39 additions, 13 deletions
libraries/libldap/options.c
with
60 additions
and
13 deletions
include/ldap.h
+
10
−
0
View file @
2d39f617
...
...
@@ -51,6 +51,13 @@ LDAP_BEGIN_DECL
/* #define LDAP_API_OPERATION_SESSION_SAFE 1 */
#endif
#define LDAP_API_FEATURE_INFO 1
typedef
struct
ldap_apifeature_info
{
char
*
ldapaif_name
;
/* matches LDAP_API_FEATURE_... less the prefix */
int
ldapaif_version
;
/* matches the value LDAP_API_FEATURE_... */
}
LDAPAPIFeatureInfo
;
#define LDAP_PORT 389
#define LDAP_ROOT_DSE ""
...
...
@@ -81,6 +88,9 @@ LDAP_BEGIN_DECL
#define LDAP_OPT_ERROR_NUMBER 0x0031
#define LDAP_OPT_ERROR_STRING 0x0032
/* LDAP_OPTions under IETF discussion */
#define LDAP_OPT_API_FEATURE_INFO 0x0100
/* not defined by current draft */
/* for LDAPv2 compatibility */
#define LDAP_OPT_DNS 0x1001
/* use DN & DNS */
...
...
This diff is collapsed.
Click to expand it.
libraries/libldap/apitest.c
+
11
−
0
View file @
2d39f617
...
...
@@ -80,8 +80,19 @@ main(int argc, char **argv)
for
(
i
=
0
;
api
.
ldapai_extensions
[
i
]
!=
NULL
;
i
++
)
/* empty */
;
printf
(
" Extensions: %d
\n
"
,
i
);
for
(
i
=
0
;
api
.
ldapai_extensions
[
i
]
!=
NULL
;
i
++
)
{
#ifndef LDAP_API_FEATURE_INFO
printf
(
" %s
\n
"
,
api
.
ldapai_extensions
[
i
]);
#else
LDAPAPIFeatureInfo
fi
;
fi
.
ldapaif_name
=
api
.
ldapai_extensions
[
i
];
fi
.
ldapaif_version
=
0
;
ldap_get_option
(
NULL
,
LDAP_OPT_API_FEATURE_INFO
,
&
fi
);
printf
(
" %s (%d)
\n
"
,
api
.
ldapai_extensions
[
i
],
fi
.
ldapaif_version
);
#endif
}
}
...
...
This diff is collapsed.
Click to expand it.
libraries/libldap/options.c
+
39
−
13
View file @
2d39f617
...
...
@@ -8,30 +8,33 @@
#include
"ldap-int.h"
static
const
char
*
features
[]
=
{
static
const
LDAPAPIFeatureInfo
features
[]
=
{
#ifdef LDAP_API_FEATURE_INFO
{
"INFO"
,
LDAP_API_FEATURE_INFO
},
#endif
#ifdef LDAP_API_FEATURE_THREAD_SAFE
"THREAD_SAFE"
,
{
"THREAD_SAFE"
,
LDAP_API_FEATURE_THREAD_SAFE
},
#endif
#ifdef LDAP_API_FEATURE_SESSION_THREAD_SAFE
"SESSION_THREAD_SAFE"
,
{
"SESSION_THREAD_SAFE"
,
LDAP_API_FEATURE_SESSION_THREAD_SAFE
},
#endif
#ifdef LDAP_API_FEATURE_OPERATION_THREAD_SAFE
"OPERATION_THREAD_SAFE"
,
{
"OPERATION_THREAD_SAFE"
,
LDAP_API_FEATURE_OPERATION_THREAD_SAFE
},
#endif
#ifdef LDAP_API_FEATURE_X_OPENLDAP_REEENTRANT
"X_OPENLDAP_REENTRANT"
,
{
"X_OPENLDAP_REENTRANT"
,
LDAP_API_FEATURE_X_OPENLDAP_REENTRANT
},
#endif
#if defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE ) && \
defined( LDAP_THREAD_SAFE )
"X_OPENLDAP_THREAD_SAFE"
,
{
"X_OPENLDAP_THREAD_SAFE"
,
LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
},
#endif
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
"X_OPENLDAP_V2_DNS"
,
{
"X_OPENLDAP_V2_DNS"
,
LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
},
#endif
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
"X_OPENLDAP_V2_REFERRALS"
,
{
"X_OPENLDAP_V2_REFERRALS"
,
LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
},
#endif
NULL
{
NULL
,
0
}
};
int
...
...
@@ -75,15 +78,17 @@ ldap_get_option(
info
->
ldapai_api_version
=
LDAP_API_VERSION
;
info
->
ldapai_api_version
=
LDAP_API_VERSION
;
info
->
ldapai_protocol_version
=
LDAP_VERSION_MAX
;
if
(
features
[
0
]
==
NULL
)
{
if
(
features
[
0
].
ldapaif_name
==
NULL
)
{
info
->
ldapai_extensions
=
NULL
;
}
else
{
int
i
;
info
->
ldapai_extensions
=
malloc
(
sizeof
(
features
));
info
->
ldapai_extensions
=
malloc
(
sizeof
(
char
*
)
*
sizeof
(
features
)
/
sizeof
(
LDAPAPIFeatureInfo
));
for
(
i
=
0
;
features
[
i
]
!=
NULL
;
i
++
)
{
for
(
i
=
0
;
features
[
i
]
.
ldapaif_name
!=
NULL
;
i
++
)
{
info
->
ldapai_extensions
[
i
]
=
ldap_strdup
(
features
[
i
]);
ldap_strdup
(
features
[
i
]
.
ldapaif_name
);
}
info
->
ldapai_extensions
[
i
]
=
NULL
;
...
...
@@ -178,6 +183,23 @@ ldap_get_option(
}
break
;
case
LDAP_OPT_API_FEATURE_INFO
:
{
LDAPAPIFeatureInfo
*
info
=
(
LDAPAPIFeatureInfo
*
)
outvalue
;
int
i
;
if
(
info
==
NULL
)
return
-
1
;
if
(
info
->
ldapaif_name
==
NULL
)
return
-
1
;
for
(
i
=
0
;
features
[
i
].
ldapaif_name
!=
NULL
;
i
++
)
{
if
(
!
strcmp
(
info
->
ldapaif_name
,
features
[
i
].
ldapaif_name
))
{
info
->
ldapaif_version
=
features
[
i
].
ldapaif_version
;
return
0
;
}
}
}
break
;
case
LDAP_OPT_DEBUG_LEVEL
:
*
(
int
*
)
outvalue
=
lo
->
ldo_debug
;
break
;
...
...
@@ -325,6 +347,10 @@ ldap_set_option(
ld
->
ld_error
=
err
;
}
return
0
;
case
LDAP_OPT_API_FEATURE_INFO
:
/* read-only */
break
;
case
LDAP_OPT_DEBUG_LEVEL
:
lo
->
ldo_debug
=
*
(
int
*
)
invalue
;
return
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment