Win32 API 日本語リファレンス
ホームGlobalization › utrace_vformat

utrace_vformat

関数
可変引数リストからICUトレース出力を整形する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

// icuuc.dll
#include <windows.h>

INT utrace_vformat(
    LPSTR outBuf,
    INT capacity,
    INT indent,
    LPCSTR fmt,
    CHAR* args
);

パラメーター

名前方向説明
outBufLPSTRin整形結果を受け取る出力バッファ。
capacityINTinoutBufの容量(バイト)。
indentINTin出力に付加するインデント量。
fmtLPCSTRinICUトレース書式指定文字列。
argsCHAR*inout書式に渡す可変引数リスト(va_list相当)へのポインタ。

戻り値の型: INT

各言語での呼び出し定義

// icuuc.dll
#include <windows.h>

INT utrace_vformat(
    LPSTR outBuf,
    INT capacity,
    INT indent,
    LPCSTR fmt,
    CHAR* args
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int utrace_vformat(
    [MarshalAs(UnmanagedType.LPStr)] string outBuf,   // LPSTR
    int capacity,   // INT
    int indent,   // INT
    [MarshalAs(UnmanagedType.LPStr)] string fmt,   // LPCSTR
    IntPtr args   // CHAR* in/out
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function utrace_vformat(
    <MarshalAs(UnmanagedType.LPStr)> outBuf As String,   ' LPSTR
    capacity As Integer,   ' INT
    indent As Integer,   ' INT
    <MarshalAs(UnmanagedType.LPStr)> fmt As String,   ' LPCSTR
    args As IntPtr   ' CHAR* in/out
) As Integer
End Function
' outBuf : LPSTR
' capacity : INT
' indent : INT
' fmt : LPCSTR
' args : CHAR* in/out
Declare PtrSafe Function utrace_vformat Lib "icuuc" ( _
    ByVal outBuf As String, _
    ByVal capacity As Long, _
    ByVal indent As Long, _
    ByVal fmt As String, _
    ByVal args As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

utrace_vformat = ctypes.cdll.icuuc.utrace_vformat
utrace_vformat.restype = ctypes.c_int
utrace_vformat.argtypes = [
    wintypes.LPCSTR,  # outBuf : LPSTR
    ctypes.c_int,  # capacity : INT
    ctypes.c_int,  # indent : INT
    wintypes.LPCSTR,  # fmt : LPCSTR
    ctypes.POINTER(ctypes.c_byte),  # args : CHAR* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
utrace_vformat = Fiddle::Function.new(
  lib['utrace_vformat'],
  [
    Fiddle::TYPE_VOIDP,  # outBuf : LPSTR
    Fiddle::TYPE_INT,  # capacity : INT
    Fiddle::TYPE_INT,  # indent : INT
    Fiddle::TYPE_VOIDP,  # fmt : LPCSTR
    Fiddle::TYPE_VOIDP,  # args : CHAR* in/out
  ],
  Fiddle::TYPE_INT, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn utrace_vformat(
        outBuf: *mut u8,  // LPSTR
        capacity: i32,  // INT
        indent: i32,  // INT
        fmt: *const u8,  // LPCSTR
        args: *mut i8  // CHAR* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int utrace_vformat([MarshalAs(UnmanagedType.LPStr)] string outBuf, int capacity, int indent, [MarshalAs(UnmanagedType.LPStr)] string fmt, IntPtr args);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_utrace_vformat' -Namespace Win32 -PassThru
# $api::utrace_vformat(outBuf, capacity, indent, fmt, args)
#uselib "icuuc.dll"
#func global utrace_vformat "utrace_vformat" sptr, sptr, sptr, sptr, sptr
; utrace_vformat outBuf, capacity, indent, fmt, varptr(args)   ; 戻り値は stat
; outBuf : LPSTR -> "sptr"
; capacity : INT -> "sptr"
; indent : INT -> "sptr"
; fmt : LPCSTR -> "sptr"
; args : CHAR* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuuc.dll"
#cfunc global utrace_vformat "utrace_vformat" str, int, int, str, var
; res = utrace_vformat(outBuf, capacity, indent, fmt, args)
; outBuf : LPSTR -> "str"
; capacity : INT -> "int"
; indent : INT -> "int"
; fmt : LPCSTR -> "str"
; args : CHAR* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT utrace_vformat(LPSTR outBuf, INT capacity, INT indent, LPCSTR fmt, CHAR* args)
#uselib "icuuc.dll"
#cfunc global utrace_vformat "utrace_vformat" str, int, int, str, var
; res = utrace_vformat(outBuf, capacity, indent, fmt, args)
; outBuf : LPSTR -> "str"
; capacity : INT -> "int"
; indent : INT -> "int"
; fmt : LPCSTR -> "str"
; args : CHAR* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procutrace_vformat = icuuc.NewProc("utrace_vformat")
)

// outBuf (LPSTR), capacity (INT), indent (INT), fmt (LPCSTR), args (CHAR* in/out)
r1, _, err := procutrace_vformat.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(outBuf))),
	uintptr(capacity),
	uintptr(indent),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(fmt))),
	uintptr(args),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function utrace_vformat(
  outBuf: PAnsiChar;   // LPSTR
  capacity: Integer;   // INT
  indent: Integer;   // INT
  fmt: PAnsiChar;   // LPCSTR
  args: Pointer   // CHAR* in/out
): Integer; cdecl;
  external 'icuuc.dll' name 'utrace_vformat';
result := DllCall("icuuc\utrace_vformat"
    , "AStr", outBuf   ; LPSTR
    , "Int", capacity   ; INT
    , "Int", indent   ; INT
    , "AStr", fmt   ; LPCSTR
    , "Ptr", args   ; CHAR* in/out
    , "Cdecl Int")   ; return: INT
●utrace_vformat(outBuf, capacity, indent, fmt, args) = DLL("icuuc.dll", "int utrace_vformat(char*, int, int, char*, void*)")
# 呼び出し: utrace_vformat(outBuf, capacity, indent, fmt, args)
# outBuf : LPSTR -> "char*"
# capacity : INT -> "int"
# indent : INT -> "int"
# fmt : LPCSTR -> "char*"
# args : CHAR* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。
const std = @import("std");

extern "icuuc" fn utrace_vformat(
    outBuf: [*c]const u8, // LPSTR
    capacity: i32, // INT
    indent: i32, // INT
    fmt: [*c]const u8, // LPCSTR
    args: [*c]i8 // CHAR* in/out
) callconv(.c) i32;
proc utrace_vformat(
    outBuf: cstring,  # LPSTR
    capacity: int32,  # INT
    indent: int32,  # INT
    fmt: cstring,  # LPCSTR
    args: ptr int8  # CHAR* in/out
): int32 {.importc: "utrace_vformat", cdecl, dynlib: "icuuc.dll".}
pragma(lib, "icuuc");
extern(C)
int utrace_vformat(
    const(char)* outBuf,   // LPSTR
    int capacity,   // INT
    int indent,   // INT
    const(char)* fmt,   // LPCSTR
    byte* args   // CHAR* in/out
);
ccall((:utrace_vformat, "icuuc.dll"), Int32,
      (Cstring, Int32, Int32, Cstring, Ptr{Int8}),
      outBuf, capacity, indent, fmt, args)
# outBuf : LPSTR -> Cstring
# capacity : INT -> Int32
# indent : INT -> Int32
# fmt : LPCSTR -> Cstring
# args : CHAR* in/out -> Ptr{Int8}
local ffi = require("ffi")
ffi.cdef[[
int32_t utrace_vformat(
    const char* outBuf,
    int32_t capacity,
    int32_t indent,
    const char* fmt,
    int8_t* args);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.utrace_vformat(outBuf, capacity, indent, fmt, args)
-- outBuf : LPSTR
-- capacity : INT
-- indent : INT
-- fmt : LPCSTR
-- args : CHAR* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const utrace_vformat = lib.func('__cdecl', 'utrace_vformat', 'int32_t', ['str', 'int32_t', 'int32_t', 'str', 'int8_t *']);
// utrace_vformat(outBuf, capacity, indent, fmt, args)
// outBuf : LPSTR -> 'str'
// capacity : INT -> 'int32_t'
// indent : INT -> 'int32_t'
// fmt : LPCSTR -> 'str'
// args : CHAR* in/out -> 'int8_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("icuuc.dll", {
  utrace_vformat: { parameters: ["buffer", "i32", "i32", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.utrace_vformat(outBuf, capacity, indent, fmt, args)
// outBuf : LPSTR -> "buffer"
// capacity : INT -> "i32"
// indent : INT -> "i32"
// fmt : LPCSTR -> "buffer"
// args : CHAR* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t utrace_vformat(
    const char* outBuf,
    int32_t capacity,
    int32_t indent,
    const char* fmt,
    int8_t* args);
C, "icuuc.dll");
// $ffi->utrace_vformat(outBuf, capacity, indent, fmt, args);
// outBuf : LPSTR
// capacity : INT
// indent : INT
// fmt : LPCSTR
// args : CHAR* 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 Icuuc extends Library {
    Icuuc INSTANCE = Native.load("icuuc", Icuuc.class);
    int utrace_vformat(
        String outBuf,   // LPSTR
        int capacity,   // INT
        int indent,   // INT
        String fmt,   // LPCSTR
        byte[] args   // CHAR* in/out
    );
}
@[Link("icuuc")]
lib Libicuuc
  fun utrace_vformat = utrace_vformat(
    outBuf : UInt8*,   # LPSTR
    capacity : Int32,   # INT
    indent : Int32,   # INT
    fmt : UInt8*,   # LPCSTR
    args : Int8*   # CHAR* in/out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef utrace_vformatNative = Int32 Function(Pointer<Utf8>, Int32, Int32, Pointer<Utf8>, Pointer<Int8>);
typedef utrace_vformatDart = int Function(Pointer<Utf8>, int, int, Pointer<Utf8>, Pointer<Int8>);
final utrace_vformat = DynamicLibrary.open('icuuc.dll')
    .lookupFunction<utrace_vformatNative, utrace_vformatDart>('utrace_vformat');
// outBuf : LPSTR -> Pointer<Utf8>
// capacity : INT -> Int32
// indent : INT -> Int32
// fmt : LPCSTR -> Pointer<Utf8>
// args : CHAR* in/out -> Pointer<Int8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function utrace_vformat(
  outBuf: PAnsiChar;   // LPSTR
  capacity: Integer;   // INT
  indent: Integer;   // INT
  fmt: PAnsiChar;   // LPCSTR
  args: Pointer   // CHAR* in/out
): Integer; cdecl;
  external 'icuuc.dll' name 'utrace_vformat';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "utrace_vformat"
  c_utrace_vformat :: CString -> Int32 -> Int32 -> CString -> Ptr Int8 -> IO Int32
-- outBuf : LPSTR -> CString
-- capacity : INT -> Int32
-- indent : INT -> Int32
-- fmt : LPCSTR -> CString
-- args : CHAR* in/out -> Ptr Int8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let utrace_vformat =
  foreign "utrace_vformat"
    (string @-> int32_t @-> int32_t @-> string @-> (ptr int8_t) @-> returning int32_t)
(* outBuf : LPSTR -> string *)
(* capacity : INT -> int32_t *)
(* indent : INT -> int32_t *)
(* fmt : LPCSTR -> string *)
(* args : CHAR* in/out -> (ptr int8_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)

(cffi:defcfun ("utrace_vformat" utrace-vformat :convention :cdecl) :int32
  (out-buf :string)   ; LPSTR
  (capacity :int32)   ; INT
  (indent :int32)   ; INT
  (fmt :string)   ; LPCSTR
  (args :pointer))   ; CHAR* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $utrace_vformat = Win32::API::More->new('icuuc',
    'int utrace_vformat(LPCSTR outBuf, int capacity, int indent, LPCSTR fmt, LPVOID args)');
# my $ret = $utrace_vformat->Call($outBuf, $capacity, $indent, $fmt, $args);
# outBuf : LPSTR -> LPCSTR
# capacity : INT -> int
# indent : INT -> int
# fmt : LPCSTR -> LPCSTR
# args : CHAR* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。