diff options
author | stevel@tonic-gate <none@none> | 2005-06-14 00:00:00 -0700 |
---|---|---|
committer | stevel@tonic-gate <none@none> | 2005-06-14 00:00:00 -0700 |
commit | 7c478bd95313f5f23a4c958a745db2134aa03244 (patch) | |
tree | c871e58545497667cbb4b0a4f2daf204743e1fe7 /usr/src/lib/libldap4/common/extensions.c | |
download | illumos-joyent-7c478bd95313f5f23a4c958a745db2134aa03244.tar.gz |
OpenSolaris Launch
Diffstat (limited to 'usr/src/lib/libldap4/common/extensions.c')
-rw-r--r-- | usr/src/lib/libldap4/common/extensions.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/usr/src/lib/libldap4/common/extensions.c b/usr/src/lib/libldap4/common/extensions.c new file mode 100644 index 0000000000..c04bed0e26 --- /dev/null +++ b/usr/src/lib/libldap4/common/extensions.c @@ -0,0 +1,79 @@ +/* + * + * Copyright %G% Sun Microsystems, Inc. + * All Rights Reserved + * + * + * Comments: + * + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <stdio.h> +#include <string.h> + +#ifdef MACOS +#include "macos.h" +#endif /* MACOS */ + +#if !defined( MACOS ) && !defined( DOS ) +#include <sys/types.h> +#include <sys/socket.h> +#endif + +#include "lber.h" +#include "ldap.h" +#include "ldap-private.h" +#include "ldap-int.h" + +int ldap_create_page_control(LDAP *ld, unsigned int pagesize, struct berval *cookie, char isCritical, LDAPControl **output) +{ + BerElement *ber; + int rc; + + if (NULL == ld || NULL == output) + return (LDAP_PARAM_ERROR); + + if ((ber = ber_alloc_t(LBER_USE_DER)) == NULLBER){ + return (LDAP_NO_MEMORY); + } + + if (ber_printf(ber, "{io}", pagesize, + (cookie && cookie->bv_val) ? cookie->bv_val : "", + (cookie && cookie->bv_val) ? cookie->bv_len : 0) + == LBER_ERROR) { + ber_free(ber, 1); + return (LDAP_ENCODING_ERROR); + } + + rc = ldap_build_control(LDAP_CONTROL_SIMPLE_PAGE, ber, 1, isCritical, + output); + + ld->ld_errno = rc; + return (rc); +} + +int ldap_parse_page_control(LDAP *ld, LDAPControl **controls, unsigned int *totalcount, struct berval **cookie) +{ + int i, rc; + BerElement *theBer; + LDAPControl *listCtrlp; + + for (i = 0; controls[i] != NULL; i++){ + if (strcmp(controls[i]->ldctl_oid, "1.2.840.113556.1.4.319") == 0) { + listCtrlp = controls[i]; + if ((theBer = ber_init(&listCtrlp->ldctl_value)) == NULLBER){ + return (LDAP_NO_MEMORY); + } + if ((rc = ber_scanf(theBer, "{iO}", totalcount, cookie)) == LBER_ERROR){ + ber_free(theBer, 1); + return (LDAP_DECODING_ERROR); + } + ber_free(theBer, 1); + return (LDAP_SUCCESS); + } + } + return (LDAP_CONTROL_NOT_FOUND); +} + |