ホーム › Networking.Ldap › ldap_compare_ext_sW
ldap_compare_ext_sW
関数コントロール付きで属性値を同期的に比較する拡張版(Unicode版)。
シグネチャ
// WLDAP32.dll (Unicode / -W)
#include <windows.h>
DWORD ldap_compare_ext_sW(
LDAP* ld,
LPCWSTR dn,
LPCWSTR Attr,
LPCWSTR Value, // optional
LDAP_BERVAL* Data, // optional
LDAPControlW** ServerControls,
LDAPControlW** ClientControls
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ld | LDAP* | inout | 比較操作を行う対象のLDAPセッションハンドル。 |
| dn | LPCWSTR | in | 比較対象エントリの識別名(DN、Unicode)。 |
| Attr | LPCWSTR | in | 比較する属性名(Unicode)。エントリ内の対象属性を指す。 |
| Value | LPCWSTR | inoptional | 属性と照合する文字列値(Unicode)。Dataを使う場合はNULLとする。 |
| Data | LDAP_BERVAL* | inoptional | バイナリ値で比較する場合のLDAP_BERVAL構造体へのポインタ。文字列比較時はNULL。 |
| ServerControls | LDAPControlW** | inout | サーバー側コントロールの配列(LDAPControlW*の配列)。不要ならNULL。 |
| ClientControls | LDAPControlW** | inout | クライアント側コントロールの配列(LDAPControlW*の配列)。不要ならNULL。 |
戻り値の型: DWORD
各言語での呼び出し定義
// WLDAP32.dll (Unicode / -W)
#include <windows.h>
DWORD ldap_compare_ext_sW(
LDAP* ld,
LPCWSTR dn,
LPCWSTR Attr,
LPCWSTR Value, // optional
LDAP_BERVAL* Data, // optional
LDAPControlW** ServerControls,
LDAPControlW** ClientControls
);[DllImport("WLDAP32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern uint ldap_compare_ext_sW(
IntPtr ld, // LDAP* in/out
[MarshalAs(UnmanagedType.LPWStr)] string dn, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string Attr, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string Value, // LPCWSTR optional
IntPtr Data, // LDAP_BERVAL* optional
IntPtr ServerControls, // LDAPControlW** in/out
IntPtr ClientControls // LDAPControlW** in/out
);<DllImport("WLDAP32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ldap_compare_ext_sW(
ld As IntPtr, ' LDAP* in/out
<MarshalAs(UnmanagedType.LPWStr)> dn As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> Attr As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> Value As String, ' LPCWSTR optional
Data As IntPtr, ' LDAP_BERVAL* optional
ServerControls As IntPtr, ' LDAPControlW** in/out
ClientControls As IntPtr ' LDAPControlW** in/out
) As UInteger
End Function' ld : LDAP* in/out
' dn : LPCWSTR
' Attr : LPCWSTR
' Value : LPCWSTR optional
' Data : LDAP_BERVAL* optional
' ServerControls : LDAPControlW** in/out
' ClientControls : LDAPControlW** in/out
Declare PtrSafe Function ldap_compare_ext_sW Lib "wldap32" ( _
ByVal ld As LongPtr, _
ByVal dn As LongPtr, _
ByVal Attr As LongPtr, _
ByVal Value As LongPtr, _
ByVal Data As LongPtr, _
ByVal ServerControls As LongPtr, _
ByVal ClientControls As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ldap_compare_ext_sW = ctypes.cdll.wldap32.ldap_compare_ext_sW
ldap_compare_ext_sW.restype = wintypes.DWORD
ldap_compare_ext_sW.argtypes = [
ctypes.c_void_p, # ld : LDAP* in/out
wintypes.LPCWSTR, # dn : LPCWSTR
wintypes.LPCWSTR, # Attr : LPCWSTR
wintypes.LPCWSTR, # Value : LPCWSTR optional
ctypes.c_void_p, # Data : LDAP_BERVAL* optional
ctypes.c_void_p, # ServerControls : LDAPControlW** in/out
ctypes.c_void_p, # ClientControls : LDAPControlW** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WLDAP32.dll')
ldap_compare_ext_sW = Fiddle::Function.new(
lib['ldap_compare_ext_sW'],
[
Fiddle::TYPE_VOIDP, # ld : LDAP* in/out
Fiddle::TYPE_VOIDP, # dn : LPCWSTR
Fiddle::TYPE_VOIDP, # Attr : LPCWSTR
Fiddle::TYPE_VOIDP, # Value : LPCWSTR optional
Fiddle::TYPE_VOIDP, # Data : LDAP_BERVAL* optional
Fiddle::TYPE_VOIDP, # ServerControls : LDAPControlW** in/out
Fiddle::TYPE_VOIDP, # ClientControls : LDAPControlW** in/out
],
-Fiddle::TYPE_INT, Fiddle::Function::CDECL)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "wldap32")]
extern "C" {
fn ldap_compare_ext_sW(
ld: *mut LDAP, // LDAP* in/out
dn: *const u16, // LPCWSTR
Attr: *const u16, // LPCWSTR
Value: *const u16, // LPCWSTR optional
Data: *mut LDAP_BERVAL, // LDAP_BERVAL* optional
ServerControls: *mut *mut LDAPControlW, // LDAPControlW** in/out
ClientControls: *mut *mut LDAPControlW // LDAPControlW** in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WLDAP32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ldap_compare_ext_sW(IntPtr ld, [MarshalAs(UnmanagedType.LPWStr)] string dn, [MarshalAs(UnmanagedType.LPWStr)] string Attr, [MarshalAs(UnmanagedType.LPWStr)] string Value, IntPtr Data, IntPtr ServerControls, IntPtr ClientControls);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WLDAP32_ldap_compare_ext_sW' -Namespace Win32 -PassThru
# $api::ldap_compare_ext_sW(ld, dn, Attr, Value, Data, ServerControls, ClientControls)#uselib "WLDAP32.dll"
#func global ldap_compare_ext_sW "ldap_compare_ext_sW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; ldap_compare_ext_sW varptr(ld), dn, Attr, Value, varptr(Data), varptr(ServerControls), varptr(ClientControls) ; 戻り値は stat
; ld : LDAP* in/out -> "wptr"
; dn : LPCWSTR -> "wptr"
; Attr : LPCWSTR -> "wptr"
; Value : LPCWSTR optional -> "wptr"
; Data : LDAP_BERVAL* optional -> "wptr"
; ServerControls : LDAPControlW** in/out -> "wptr"
; ClientControls : LDAPControlW** in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WLDAP32.dll" #cfunc global ldap_compare_ext_sW "ldap_compare_ext_sW" var, wstr, wstr, wstr, var, var, var ; res = ldap_compare_ext_sW(ld, dn, Attr, Value, Data, ServerControls, ClientControls) ; ld : LDAP* in/out -> "var" ; dn : LPCWSTR -> "wstr" ; Attr : LPCWSTR -> "wstr" ; Value : LPCWSTR optional -> "wstr" ; Data : LDAP_BERVAL* optional -> "var" ; ServerControls : LDAPControlW** in/out -> "var" ; ClientControls : LDAPControlW** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WLDAP32.dll" #cfunc global ldap_compare_ext_sW "ldap_compare_ext_sW" sptr, wstr, wstr, wstr, sptr, sptr, sptr ; res = ldap_compare_ext_sW(varptr(ld), dn, Attr, Value, varptr(Data), varptr(ServerControls), varptr(ClientControls)) ; ld : LDAP* in/out -> "sptr" ; dn : LPCWSTR -> "wstr" ; Attr : LPCWSTR -> "wstr" ; Value : LPCWSTR optional -> "wstr" ; Data : LDAP_BERVAL* optional -> "sptr" ; ServerControls : LDAPControlW** in/out -> "sptr" ; ClientControls : LDAPControlW** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD ldap_compare_ext_sW(LDAP* ld, LPCWSTR dn, LPCWSTR Attr, LPCWSTR Value, LDAP_BERVAL* Data, LDAPControlW** ServerControls, LDAPControlW** ClientControls) #uselib "WLDAP32.dll" #cfunc global ldap_compare_ext_sW "ldap_compare_ext_sW" var, wstr, wstr, wstr, var, var, var ; res = ldap_compare_ext_sW(ld, dn, Attr, Value, Data, ServerControls, ClientControls) ; ld : LDAP* in/out -> "var" ; dn : LPCWSTR -> "wstr" ; Attr : LPCWSTR -> "wstr" ; Value : LPCWSTR optional -> "wstr" ; Data : LDAP_BERVAL* optional -> "var" ; ServerControls : LDAPControlW** in/out -> "var" ; ClientControls : LDAPControlW** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD ldap_compare_ext_sW(LDAP* ld, LPCWSTR dn, LPCWSTR Attr, LPCWSTR Value, LDAP_BERVAL* Data, LDAPControlW** ServerControls, LDAPControlW** ClientControls) #uselib "WLDAP32.dll" #cfunc global ldap_compare_ext_sW "ldap_compare_ext_sW" intptr, wstr, wstr, wstr, intptr, intptr, intptr ; res = ldap_compare_ext_sW(varptr(ld), dn, Attr, Value, varptr(Data), varptr(ServerControls), varptr(ClientControls)) ; ld : LDAP* in/out -> "intptr" ; dn : LPCWSTR -> "wstr" ; Attr : LPCWSTR -> "wstr" ; Value : LPCWSTR optional -> "wstr" ; Data : LDAP_BERVAL* optional -> "intptr" ; ServerControls : LDAPControlW** in/out -> "intptr" ; ClientControls : LDAPControlW** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
procldap_compare_ext_sW = wldap32.NewProc("ldap_compare_ext_sW")
)
// ld (LDAP* in/out), dn (LPCWSTR), Attr (LPCWSTR), Value (LPCWSTR optional), Data (LDAP_BERVAL* optional), ServerControls (LDAPControlW** in/out), ClientControls (LDAPControlW** in/out)
r1, _, err := procldap_compare_ext_sW.Call(
uintptr(ld),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(dn))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Attr))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Value))),
uintptr(Data),
uintptr(ServerControls),
uintptr(ClientControls),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction ldap_compare_ext_sW(
ld: Pointer; // LDAP* in/out
dn: PWideChar; // LPCWSTR
Attr: PWideChar; // LPCWSTR
Value: PWideChar; // LPCWSTR optional
Data: Pointer; // LDAP_BERVAL* optional
ServerControls: Pointer; // LDAPControlW** in/out
ClientControls: Pointer // LDAPControlW** in/out
): DWORD; cdecl;
external 'WLDAP32.dll' name 'ldap_compare_ext_sW';result := DllCall("WLDAP32\ldap_compare_ext_sW"
, "Ptr", ld ; LDAP* in/out
, "WStr", dn ; LPCWSTR
, "WStr", Attr ; LPCWSTR
, "WStr", Value ; LPCWSTR optional
, "Ptr", Data ; LDAP_BERVAL* optional
, "Ptr", ServerControls ; LDAPControlW** in/out
, "Ptr", ClientControls ; LDAPControlW** in/out
, "Cdecl UInt") ; return: DWORD●ldap_compare_ext_sW(ld, dn, Attr, Value, Data, ServerControls, ClientControls) = DLL("WLDAP32.dll", "dword ldap_compare_ext_sW(void*, char*, char*, char*, void*, void*, void*)")
# 呼び出し: ldap_compare_ext_sW(ld, dn, Attr, Value, Data, ServerControls, ClientControls)
# ld : LDAP* in/out -> "void*"
# dn : LPCWSTR -> "char*"
# Attr : LPCWSTR -> "char*"
# Value : LPCWSTR optional -> "char*"
# Data : LDAP_BERVAL* optional -> "void*"
# ServerControls : LDAPControlW** in/out -> "void*"
# ClientControls : LDAPControlW** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。const std = @import("std");
extern "wldap32" fn ldap_compare_ext_sW(
ld: [*c]LDAP, // LDAP* in/out
dn: [*c]const u16, // LPCWSTR
Attr: [*c]const u16, // LPCWSTR
Value: [*c]const u16, // LPCWSTR optional
Data: [*c]LDAP_BERVAL, // LDAP_BERVAL* optional
ServerControls: [*c][*c]LDAPControlW, // LDAPControlW** in/out
ClientControls: [*c][*c]LDAPControlW // LDAPControlW** in/out
) callconv(.c) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc ldap_compare_ext_sW(
ld: ptr LDAP, # LDAP* in/out
dn: WideCString, # LPCWSTR
Attr: WideCString, # LPCWSTR
Value: WideCString, # LPCWSTR optional
Data: ptr LDAP_BERVAL, # LDAP_BERVAL* optional
ServerControls: ptr LDAPControlW, # LDAPControlW** in/out
ClientControls: ptr LDAPControlW # LDAPControlW** in/out
): uint32 {.importc: "ldap_compare_ext_sW", cdecl, dynlib: "WLDAP32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "wldap32");
extern(C)
uint ldap_compare_ext_sW(
LDAP* ld, // LDAP* in/out
const(wchar)* dn, // LPCWSTR
const(wchar)* Attr, // LPCWSTR
const(wchar)* Value, // LPCWSTR optional
LDAP_BERVAL* Data, // LDAP_BERVAL* optional
LDAPControlW** ServerControls, // LDAPControlW** in/out
LDAPControlW** ClientControls // LDAPControlW** in/out
);ccall((:ldap_compare_ext_sW, "WLDAP32.dll"), UInt32,
(Ptr{LDAP}, Cwstring, Cwstring, Cwstring, Ptr{LDAP_BERVAL}, Ptr{LDAPControlW}, Ptr{LDAPControlW}),
ld, dn, Attr, Value, Data, ServerControls, ClientControls)
# ld : LDAP* in/out -> Ptr{LDAP}
# dn : LPCWSTR -> Cwstring
# Attr : LPCWSTR -> Cwstring
# Value : LPCWSTR optional -> Cwstring
# Data : LDAP_BERVAL* optional -> Ptr{LDAP_BERVAL}
# ServerControls : LDAPControlW** in/out -> Ptr{LDAPControlW}
# ClientControls : LDAPControlW** in/out -> Ptr{LDAPControlW}
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
uint32_t ldap_compare_ext_sW(
void* ld,
const uint16_t* dn,
const uint16_t* Attr,
const uint16_t* Value,
void* Data,
void* ServerControls,
void* ClientControls);
]]
local wldap32 = ffi.load("wldap32")
-- wldap32.ldap_compare_ext_sW(ld, dn, Attr, Value, Data, ServerControls, ClientControls)
-- ld : LDAP* in/out
-- dn : LPCWSTR
-- Attr : LPCWSTR
-- Value : LPCWSTR optional
-- Data : LDAP_BERVAL* optional
-- ServerControls : LDAPControlW** in/out
-- ClientControls : LDAPControlW** in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('WLDAP32.dll');
const ldap_compare_ext_sW = lib.func('__cdecl', 'ldap_compare_ext_sW', 'uint32_t', ['void *', 'str16', 'str16', 'str16', 'void *', 'void *', 'void *']);
// ldap_compare_ext_sW(ld, dn, Attr, Value, Data, ServerControls, ClientControls)
// ld : LDAP* in/out -> 'void *'
// dn : LPCWSTR -> 'str16'
// Attr : LPCWSTR -> 'str16'
// Value : LPCWSTR optional -> 'str16'
// Data : LDAP_BERVAL* optional -> 'void *'
// ServerControls : LDAPControlW** in/out -> 'void *'
// ClientControls : LDAPControlW** in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WLDAP32.dll", {
ldap_compare_ext_sW: { parameters: ["pointer", "buffer", "buffer", "buffer", "pointer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.ldap_compare_ext_sW(ld, dn, Attr, Value, Data, ServerControls, ClientControls)
// ld : LDAP* in/out -> "pointer"
// dn : LPCWSTR -> "buffer"
// Attr : LPCWSTR -> "buffer"
// Value : LPCWSTR optional -> "buffer"
// Data : LDAP_BERVAL* optional -> "pointer"
// ServerControls : LDAPControlW** in/out -> "pointer"
// ClientControls : LDAPControlW** in/out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t ldap_compare_ext_sW(
void* ld,
const uint16_t* dn,
const uint16_t* Attr,
const uint16_t* Value,
void* Data,
void* ServerControls,
void* ClientControls);
C, "WLDAP32.dll");
// $ffi->ldap_compare_ext_sW(ld, dn, Attr, Value, Data, ServerControls, ClientControls);
// ld : LDAP* in/out
// dn : LPCWSTR
// Attr : LPCWSTR
// Value : LPCWSTR optional
// Data : LDAP_BERVAL* optional
// ServerControls : LDAPControlW** in/out
// ClientControls : LDAPControlW** in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Wldap32 extends Library {
Wldap32 INSTANCE = Native.load("wldap32", Wldap32.class, W32APIOptions.UNICODE_OPTIONS);
int ldap_compare_ext_sW(
Pointer ld, // LDAP* in/out
WString dn, // LPCWSTR
WString Attr, // LPCWSTR
WString Value, // LPCWSTR optional
Pointer Data, // LDAP_BERVAL* optional
Pointer ServerControls, // LDAPControlW** in/out
Pointer ClientControls // LDAPControlW** in/out
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("wldap32")]
lib LibWLDAP32
fun ldap_compare_ext_sW = ldap_compare_ext_sW(
ld : LDAP*, # LDAP* in/out
dn : UInt16*, # LPCWSTR
Attr : UInt16*, # LPCWSTR
Value : UInt16*, # LPCWSTR optional
Data : LDAP_BERVAL*, # LDAP_BERVAL* optional
ServerControls : LDAPControlW**, # LDAPControlW** in/out
ClientControls : LDAPControlW** # LDAPControlW** in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ldap_compare_ext_sWNative = Uint32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef ldap_compare_ext_sWDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final ldap_compare_ext_sW = DynamicLibrary.open('WLDAP32.dll')
.lookupFunction<ldap_compare_ext_sWNative, ldap_compare_ext_sWDart>('ldap_compare_ext_sW');
// ld : LDAP* in/out -> Pointer<Void>
// dn : LPCWSTR -> Pointer<Utf16>
// Attr : LPCWSTR -> Pointer<Utf16>
// Value : LPCWSTR optional -> Pointer<Utf16>
// Data : LDAP_BERVAL* optional -> Pointer<Void>
// ServerControls : LDAPControlW** in/out -> Pointer<Void>
// ClientControls : LDAPControlW** in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ldap_compare_ext_sW(
ld: Pointer; // LDAP* in/out
dn: PWideChar; // LPCWSTR
Attr: PWideChar; // LPCWSTR
Value: PWideChar; // LPCWSTR optional
Data: Pointer; // LDAP_BERVAL* optional
ServerControls: Pointer; // LDAPControlW** in/out
ClientControls: Pointer // LDAPControlW** in/out
): DWORD; cdecl;
external 'WLDAP32.dll' name 'ldap_compare_ext_sW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ldap_compare_ext_sW"
c_ldap_compare_ext_sW :: Ptr () -> CWString -> CWString -> CWString -> Ptr () -> Ptr () -> Ptr () -> IO Word32
-- ld : LDAP* in/out -> Ptr ()
-- dn : LPCWSTR -> CWString
-- Attr : LPCWSTR -> CWString
-- Value : LPCWSTR optional -> CWString
-- Data : LDAP_BERVAL* optional -> Ptr ()
-- ServerControls : LDAPControlW** in/out -> Ptr ()
-- ClientControls : LDAPControlW** in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ldap_compare_ext_sw =
foreign "ldap_compare_ext_sW"
((ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning uint32_t)
(* ld : LDAP* in/out -> (ptr void) *)
(* dn : LPCWSTR -> (ptr uint16_t) *)
(* Attr : LPCWSTR -> (ptr uint16_t) *)
(* Value : LPCWSTR optional -> (ptr uint16_t) *)
(* Data : LDAP_BERVAL* optional -> (ptr void) *)
(* ServerControls : LDAPControlW** in/out -> (ptr void) *)
(* ClientControls : LDAPControlW** in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wldap32 (t "WLDAP32.dll"))
(cffi:use-foreign-library wldap32)
(cffi:defcfun ("ldap_compare_ext_sW" ldap-compare-ext-s-w :convention :cdecl) :uint32
(ld :pointer) ; LDAP* in/out
(dn (:string :encoding :utf-16le)) ; LPCWSTR
(attr (:string :encoding :utf-16le)) ; LPCWSTR
(value (:string :encoding :utf-16le)) ; LPCWSTR optional
(data :pointer) ; LDAP_BERVAL* optional
(server-controls :pointer) ; LDAPControlW** in/out
(client-controls :pointer)) ; LDAPControlW** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ldap_compare_ext_sW = Win32::API::More->new('WLDAP32',
'DWORD ldap_compare_ext_sW(LPVOID ld, LPCWSTR dn, LPCWSTR Attr, LPCWSTR Value, LPVOID Data, LPVOID ServerControls, LPVOID ClientControls)');
# my $ret = $ldap_compare_ext_sW->Call($ld, $dn, $Attr, $Value, $Data, $ServerControls, $ClientControls);
# ld : LDAP* in/out -> LPVOID
# dn : LPCWSTR -> LPCWSTR
# Attr : LPCWSTR -> LPCWSTR
# Value : LPCWSTR optional -> LPCWSTR
# Data : LDAP_BERVAL* optional -> LPVOID
# ServerControls : LDAPControlW** in/out -> LPVOID
# ClientControls : LDAPControlW** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f ldap_compare_ext_sA (ANSI版) — コントロール付きで属性値を同期的に比較する拡張版(ANSI版)。