2 * Copyright (c) 2001 by Sun Microsystems, Inc.
6 #pragma ident "%Z%%M% %I% %E% SMI"
15 #if !defined( MACOS ) && !defined( DOS )
16 #include <sys/types.h>
17 #include <sys/socket.h>
24 int ldap_create_page_control(LDAP
*ld
, unsigned int pagesize
, struct berval
*cookie
, char isCritical
, LDAPControl
**output
)
29 if (NULL
== ld
|| NULL
== output
)
30 return (LDAP_PARAM_ERROR
);
32 if ((ber
= ber_alloc_t(LBER_USE_DER
)) == NULLBER
){
33 return (LDAP_NO_MEMORY
);
36 if (ber_printf(ber
, "{io}", pagesize
,
37 (cookie
&& cookie
->bv_val
) ? cookie
->bv_val
: "",
38 (cookie
&& cookie
->bv_val
) ? cookie
->bv_len
: 0)
41 return (LDAP_ENCODING_ERROR
);
44 rc
= nsldapi_build_control(LDAP_CONTROL_SIMPLE_PAGE
, ber
, 1, isCritical
,
51 int ldap_parse_page_control(LDAP
*ld
, LDAPControl
**controls
, unsigned int *totalcount
, struct berval
**cookie
)
55 LDAPControl
*listCtrlp
;
57 for (i
= 0; controls
[i
] != NULL
; i
++){
58 if (strcmp(controls
[i
]->ldctl_oid
, "1.2.840.113556.1.4.319") == 0) {
59 listCtrlp
= controls
[i
];
60 if ((theBer
= ber_init(&listCtrlp
->ldctl_value
)) == NULLBER
){
61 return (LDAP_NO_MEMORY
);
63 if ((rc
= ber_scanf(theBer
, "{iO}", totalcount
, cookie
)) == LBER_ERROR
){
65 return (LDAP_DECODING_ERROR
);
68 return (LDAP_SUCCESS
);
71 return (LDAP_CONTROL_NOT_FOUND
);