ホーム › Networking.Ldap › ber_init
ber_init
関数berval値からBER要素を初期化して作成する。
シグネチャ
// WLDAP32.dll
#include <windows.h>
BerElement* ber_init(
LDAP_BERVAL* pBerVal
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pBerVal | LDAP_BERVAL* | inout | 初期化に用いるBERエンコード済みデータ(berval)。内容を複製しBerElementを生成する。 |
戻り値の型: BerElement*
各言語での呼び出し定義
// WLDAP32.dll
#include <windows.h>
BerElement* ber_init(
LDAP_BERVAL* pBerVal
);[DllImport("WLDAP32.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ber_init(
IntPtr pBerVal // LDAP_BERVAL* in/out
);<DllImport("WLDAP32.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ber_init(
pBerVal As IntPtr ' LDAP_BERVAL* in/out
) As IntPtr
End Function' pBerVal : LDAP_BERVAL* in/out
Declare PtrSafe Function ber_init Lib "wldap32" ( _
ByVal pBerVal As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ber_init = ctypes.cdll.wldap32.ber_init
ber_init.restype = ctypes.c_void_p
ber_init.argtypes = [
ctypes.c_void_p, # pBerVal : LDAP_BERVAL* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WLDAP32.dll')
ber_init = Fiddle::Function.new(
lib['ber_init'],
[
Fiddle::TYPE_VOIDP, # pBerVal : LDAP_BERVAL* in/out
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)#[link(name = "wldap32")]
extern "C" {
fn ber_init(
pBerVal: *mut LDAP_BERVAL // LDAP_BERVAL* in/out
) -> *mut BerElement;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WLDAP32.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ber_init(IntPtr pBerVal);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WLDAP32_ber_init' -Namespace Win32 -PassThru
# $api::ber_init(pBerVal)#uselib "WLDAP32.dll"
#func global ber_init "ber_init" sptr
; ber_init varptr(pBerVal) ; 戻り値は stat
; pBerVal : LDAP_BERVAL* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WLDAP32.dll" #cfunc global ber_init "ber_init" var ; res = ber_init(pBerVal) ; pBerVal : LDAP_BERVAL* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WLDAP32.dll" #cfunc global ber_init "ber_init" sptr ; res = ber_init(varptr(pBerVal)) ; pBerVal : LDAP_BERVAL* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BerElement* ber_init(LDAP_BERVAL* pBerVal) #uselib "WLDAP32.dll" #cfunc global ber_init "ber_init" var ; res = ber_init(pBerVal) ; pBerVal : LDAP_BERVAL* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BerElement* ber_init(LDAP_BERVAL* pBerVal) #uselib "WLDAP32.dll" #cfunc global ber_init "ber_init" intptr ; res = ber_init(varptr(pBerVal)) ; pBerVal : LDAP_BERVAL* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
procber_init = wldap32.NewProc("ber_init")
)
// pBerVal (LDAP_BERVAL* in/out)
r1, _, err := procber_init.Call(
uintptr(pBerVal),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BerElement*function ber_init(
pBerVal: Pointer // LDAP_BERVAL* in/out
): Pointer; cdecl;
external 'WLDAP32.dll' name 'ber_init';result := DllCall("WLDAP32\ber_init"
, "Ptr", pBerVal ; LDAP_BERVAL* in/out
, "Cdecl Ptr") ; return: BerElement*●ber_init(pBerVal) = DLL("WLDAP32.dll", "void* ber_init(void*)")
# 呼び出し: ber_init(pBerVal)
# pBerVal : LDAP_BERVAL* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。const std = @import("std");
extern "wldap32" fn ber_init(
pBerVal: [*c]LDAP_BERVAL // LDAP_BERVAL* in/out
) callconv(.c) [*c]BerElement;proc ber_init(
pBerVal: ptr LDAP_BERVAL # LDAP_BERVAL* in/out
): ptr BerElement {.importc: "ber_init", cdecl, dynlib: "WLDAP32.dll".}pragma(lib, "wldap32");
extern(C)
BerElement* ber_init(
LDAP_BERVAL* pBerVal // LDAP_BERVAL* in/out
);ccall((:ber_init, "WLDAP32.dll"), Ptr{BerElement},
(Ptr{LDAP_BERVAL},),
pBerVal)
# pBerVal : LDAP_BERVAL* in/out -> Ptr{LDAP_BERVAL}local ffi = require("ffi")
ffi.cdef[[
void* ber_init(
void* pBerVal);
]]
local wldap32 = ffi.load("wldap32")
-- wldap32.ber_init(pBerVal)
-- pBerVal : LDAP_BERVAL* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WLDAP32.dll');
const ber_init = lib.func('__cdecl', 'ber_init', 'void *', ['void *']);
// ber_init(pBerVal)
// pBerVal : LDAP_BERVAL* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WLDAP32.dll", {
ber_init: { parameters: ["pointer"], result: "pointer" },
});
// lib.symbols.ber_init(pBerVal)
// pBerVal : LDAP_BERVAL* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* ber_init(
void* pBerVal);
C, "WLDAP32.dll");
// $ffi->ber_init(pBerVal);
// pBerVal : LDAP_BERVAL* 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);
Pointer ber_init(
Pointer pBerVal // LDAP_BERVAL* in/out
);
}@[Link("wldap32")]
lib LibWLDAP32
fun ber_init = ber_init(
pBerVal : LDAP_BERVAL* # LDAP_BERVAL* in/out
) : BerElement*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ber_initNative = Pointer<Void> Function(Pointer<Void>);
typedef ber_initDart = Pointer<Void> Function(Pointer<Void>);
final ber_init = DynamicLibrary.open('WLDAP32.dll')
.lookupFunction<ber_initNative, ber_initDart>('ber_init');
// pBerVal : LDAP_BERVAL* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ber_init(
pBerVal: Pointer // LDAP_BERVAL* in/out
): Pointer; cdecl;
external 'WLDAP32.dll' name 'ber_init';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ber_init"
c_ber_init :: Ptr () -> IO (Ptr ())
-- pBerVal : LDAP_BERVAL* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ber_init =
foreign "ber_init"
((ptr void) @-> returning (ptr void))
(* pBerVal : LDAP_BERVAL* 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 ("ber_init" ber-init :convention :cdecl) :pointer
(p-ber-val :pointer)) ; LDAP_BERVAL* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ber_init = Win32::API::More->new('WLDAP32',
'LPVOID ber_init(LPVOID pBerVal)');
# my $ret = $ber_init->Call($pBerVal);
# pBerVal : LDAP_BERVAL* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。