⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ldap_sort.3

📁 开放源码的ldap系统
💻 3
字号:
.TH LDAP_SORT 3 "22 September 1998" "OpenLDAP LDVERSION".\" $OpenLDAP: pkg/ldap/doc/man/man3/ldap_sort.3,v 1.3.8.1 2000/06/13 17:57:12 kurt Exp $.\" Copyright 1998-2000 The OpenLDAP Foundation All Rights Reserved..\" Copying restrictions apply.  See COPYRIGHT/LICENSE..SH NAMEldap_sort_entries, ldap_sort_values, ldap_sort_strcasecmp \- LDAP sorting routines.SH SYNOPSIS.nf.ft B#include <ldap.h>.LP.ft Bldap_sort_entries(ld, chain, attr, cmp).ftLDAP *ld;LDAPMessage **chain;char *attr;int (*cmp)();.LP.ft Bldap_sort_values(ld, vals, cmp).ftLDAP *ld;char **vals;int (*cmp)();.LP.ft Bldap_sort_strcasecmp(a, b).ftchar *a;char *b;.SH DESCRIPTIONThese routines are used to sort lists of entries and values retrievedfrom an LDAP server..B ldap_sort_entries()is used to sort a chainof entries retrieved from an LDAP search call either by DN or by somearbitrary attribute in the entries.  It takes \fIld\fP, the LDAPstructure, which is only used for error reporting, \fIchain\fP, thelist of entries as returned by.BR ldap_search_s (3)or.BR ldap_result (3).\fIattr\fP is the attribute to use as a key in the sortor NULL to sort by DN, and \fIcmp\fP is the comparison function to usewhen comparing values (or individual DN components if sorting by DN).In this case, \fIcmp\fP should be a function taking two single valuesof the \fIattr\fP to sort by, and returning a value less than zero,equal to zero, or greater than zero, depending on whether the firstargument is less than, equal to, or greater than the second argument.The convention is the same as used by.BR qsort (3),which is called to do the actual sorting..LP.B ldap_sort_values()is used to sort an array of values from an entry,as returned by.BR ldap_get_values (3).It takes the LDAP connectionstructure \fIld\fP, the array of valuesto sort \fIvals\fP, and \fIcmp\fP, the comparisonfunction to use during the sort.Note that \fIcmp\fP will be passed a pointer to each element in the\fIvals\fP array, so if you pass the normal char ** for this parameter,\fIcmp\fP should take two char **'s as arguments (i.e., you cannotpass \fIstrcasecmp\fP or its friends for \fIcmp\fP).  You can, however,pass the function.B ldap_sort_strcasecmp()for this purpose..LPFor example:.LP.nf.ft tt	LDAP *ld;	LDAPMessage *res;	/* ... call to ldap_search_s(), fill in res, retrieve sn attr ... */	/* now sort the entries on surname attribute */	if ( ldap_sort_entries( ld, &res, "sn", ldap_sort_strcasecmp ) != 0 )		ldap_perror( ld, "ldap_sort_entries" );.ft.fi.SH NOTES.LPThe.B ldap_sort_entries()routine applies the comparison function toeach value of the attribute in the array as returned by a call to.BR ldap_get_values (3),until a mismatch is found.This works fine for single-valued attributes, butmay produce unexpected results for multi-valued attributes.When sorting by DN, the comparison function isapplied to an exploded version of the DN, without types.The return values for all of these functions are declared in the<ldap.h> header file.  Some routines may dynamically allocate memory.Callers are responsible for freeing such memory using the supplieddeallocation routines..SH SEE ALSO.BR ldap (3),.BR ldap_search (3),.BR ldap_result (3),.BR qsort (3).SH ACKNOWLEDGEMENTS.B	OpenLDAPis developed and maintained by The OpenLDAP Project (http://www.openldap.org/)..B	OpenLDAPis derived from University of Michigan LDAP 3.3 Release.  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -