📄 misc.c
字号:
{
PWCHAR ret = NULL;
#ifdef HAVE_LDAP
char *retU;
TRACE( "(%p, %p, %p)\n", ld, entry, ptr );
if (!ld || !entry) return NULL;
retU = ldap_first_attribute( ld, entry, ptr );
ret = strUtoW( retU );
ldap_memfree( retU );
#endif
return ret;
}
/***********************************************************************
* ldap_first_entry (WLDAP32.@)
*
* Get the first entry from a result message.
*
* PARAMS
* ld [I] Pointer to an LDAP context.
* res [I] Search result message.
*
* RETURNS
* Success: The first entry.
* Failure: NULL
*
* NOTES
* The returned entry will be freed when the message is freed.
*/
WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_first_entry( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res )
{
#ifdef HAVE_LDAP
TRACE( "(%p, %p)\n", ld, res );
if (!ld || !res) return NULL;
return ldap_first_entry( ld, res );
#else
return NULL;
#endif
}
/***********************************************************************
* ldap_first_reference (WLDAP32.@)
*
* Get the first reference from a result message.
*
* PARAMS
* ld [I] Pointer to an LDAP context.
* res [I] Search result message.
*
* RETURNS
* Success: The first reference.
* Failure: NULL
*/
WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_first_reference( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res )
{
#ifdef HAVE_LDAP_FIRST_REFERENCE
TRACE( "(%p, %p)\n", ld, res );
if (!ld) return NULL;
return ldap_first_reference( ld, res );
#else
return NULL;
#endif
}
/***********************************************************************
* ldap_memfreeA (WLDAP32.@)
*
* See ldap_memfreeW.
*/
void CDECL ldap_memfreeA( PCHAR block )
{
TRACE( "(%p)\n", block );
strfreeA( block );
}
/***********************************************************************
* ldap_memfreeW (WLDAP32.@)
*
* Free a block of memory.
*
* PARAMS
* block [I] Pointer to memory block to be freed.
*/
void CDECL ldap_memfreeW( PWCHAR block )
{
TRACE( "(%p)\n", block );
strfreeW( block );
}
/***********************************************************************
* ldap_msgfree (WLDAP32.@)
*
* Free a message.
*
* PARAMS
* res [I] Message to be freed.
*/
ULONG CDECL WLDAP32_ldap_msgfree( WLDAP32_LDAPMessage *res )
{
ULONG ret = LDAP_SUCCESS;
#ifdef HAVE_LDAP
TRACE( "(%p)\n", res );
ldap_msgfree( res );
#endif
return ret;
}
/***********************************************************************
* ldap_next_attributeA (WLDAP32.@)
*
* See ldap_next_attributeW.
*/
PCHAR CDECL ldap_next_attributeA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry,
WLDAP32_BerElement *ptr )
{
PCHAR ret = NULL;
#ifdef HAVE_LDAP
WCHAR *retW;
TRACE( "(%p, %p, %p)\n", ld, entry, ptr );
if (!ld || !entry || !ptr) return NULL;
retW = ldap_next_attributeW( ld, entry, ptr );
ret = strWtoA( retW );
ldap_memfreeW( retW );
#endif
return ret;
}
/***********************************************************************
* ldap_next_attributeW (WLDAP32.@)
*
* Get the next attribute for a given entry.
*
* PARAMS
* ld [I] Pointer to an LDAP context.
* entry [I] Entry to retrieve attribute for.
* ptr [I/O] Position pointer.
*
* RETURNS
* Success: The name of the next attribute.
* Failure: NULL
*
* NOTES
* Free the returned string after each iteration with ldap_memfree.
* When done iterating and when ptr != NULL, call ber_free( ptr, 0 ).
*/
PWCHAR CDECL ldap_next_attributeW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry,
WLDAP32_BerElement *ptr )
{
PWCHAR ret = NULL;
#ifdef HAVE_LDAP
char *retU;
TRACE( "(%p, %p, %p)\n", ld, entry, ptr );
if (!ld || !entry || !ptr) return NULL;
retU = ldap_next_attribute( ld, entry, ptr );
ret = strUtoW( retU );
ldap_memfree( retU );
#endif
return ret;
}
/***********************************************************************
* ldap_next_entry (WLDAP32.@)
*
* Get the next entry from a result message.
*
* PARAMS
* ld [I] Pointer to an LDAP context.
* entry [I] Entry returned by a previous call.
*
* RETURNS
* Success: The next entry.
* Failure: NULL
*
* NOTES
* The returned entry will be freed when the message is freed.
*/
WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_next_entry( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
{
#ifdef HAVE_LDAP
TRACE( "(%p, %p)\n", ld, entry );
if (!ld || !entry) return NULL;
return ldap_next_entry( ld, entry );
#else
return NULL;
#endif
}
/***********************************************************************
* ldap_next_reference (WLDAP32.@)
*
* Get the next reference from a result message.
*
* PARAMS
* ld [I] Pointer to an LDAP context.
* entry [I] Entry returned by a previous call.
*
* RETURNS
* Success: The next reference.
* Failure: NULL
*
* NOTES
* The returned entry will be freed when the message is freed.
*/
WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_next_reference( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
{
#ifdef HAVE_LDAP_NEXT_REFERENCE
TRACE( "(%p, %p)\n", ld, entry );
if (!ld || !entry) return NULL;
return ldap_next_reference( ld, entry );
#else
return NULL;
#endif
}
/***********************************************************************
* ldap_result (WLDAP32.@)
*
* Get the result of an asynchronous operation.
*
* PARAMS
* ld [I] Pointer to an LDAP context.
* msgid [I] Message ID of the operation.
* all [I] How many results should be returned?
* timeout [I] How long to wait for the results?
* res [O] Result message for the operation.
*
* RETURNS
* Success: One of the following values:
*
* LDAP_RES_ADD
* LDAP_RES_BIND
* LDAP_RES_COMPARE
* LDAP_RES_DELETE
* LDAP_RES_EXTENDED
* LDAP_RES_MODIFY
* LDAP_RES_MODRDN
* LDAP_RES_REFERRAL
* LDAP_RES_SEARCH_ENTRY
* LDAP_RES_SEARCH_RESULT
*
* Failure: ~0UL
*
* This function returns 0 when the timeout has expired.
*
* NOTES
* A NULL timeout pointer causes the function to block waiting
* for results to arrive. A timeout value of 0 causes the function
* to immediately return any available results. Free returned results
* with ldap_msgfree.
*/
ULONG CDECL WLDAP32_ldap_result( WLDAP32_LDAP *ld, ULONG msgid, ULONG all,
struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
{
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
TRACE( "(%p, 0x%08x, 0x%08x, %p, %p)\n", ld, msgid, all, timeout, res );
if (!ld || !res || msgid == ~0UL) return ~0UL;
ret = ldap_result( ld, msgid, all, (struct timeval *)timeout, res );
#endif
return ret;
}
/***********************************************************************
* LdapUnicodeToUTF8 (WLDAP32.@)
*
* Convert a wide character string to a UTF8 string.
*
* PARAMS
* src [I] Wide character string to convert.
* srclen [I] Size of string to convert, in characters.
* dst [O] Pointer to a buffer that receives the converted string.
* dstlen [I] Size of the destination buffer in characters.
*
* RETURNS
* The number of characters written into the destination buffer.
*
* NOTES
* Set dstlen to zero to ask for the required buffer size.
*/
int CDECL LdapUnicodeToUTF8( LPCWSTR src, int srclen, LPSTR dst, int dstlen )
{
return WideCharToMultiByte( CP_UTF8, 0, src, srclen, dst, dstlen, NULL, NULL );
}
/***********************************************************************
* LdapUTF8ToUnicode (WLDAP32.@)
*
* Convert a UTF8 string to a wide character string.
*
* PARAMS
* src [I] UTF8 string to convert.
* srclen [I] Size of string to convert, in characters.
* dst [O] Pointer to a buffer that receives the converted string.
* dstlen [I] Size of the destination buffer in characters.
*
* RETURNS
* The number of characters written into the destination buffer.
*
* NOTES
* Set dstlen to zero to ask for the required buffer size.
*/
int CDECL LdapUTF8ToUnicode( LPCSTR src, int srclen, LPWSTR dst, int dstlen )
{
return MultiByteToWideChar( CP_UTF8, 0, src, srclen, dst, dstlen );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -