📄 winber.pas
字号:
{******************************************************************}
{ }
{ Borland Delphi Runtime Library }
{ Basic Encoding Rules interface unit }
{ }
{ Portions created by Microsoft are }
{ Copyright (C) 1995-1999 Microsoft Corporation. }
{ All Rights Reserved. }
{ }
{ The original file is: winber.h, released June 2000. }
{ The original Pascal code is: WinBer.pas, released December 2000 }
{ The initial developer of the Pascal code is Marcel van Brakel }
{ (brakelm@bart.nl). }
{ }
{ Portions created by Marcel van Brakel are }
{ Copyright (C) 1999 Marcel van Brakel. }
{ }
{ Obtained through: }
{ Joint Endeavour of Delphi Innovators (Project JEDI) }
{ }
{ You may retrieve the latest version of this file at the Project }
{ JEDI home page, located at http://delphi-jedi.org }
{ }
{ The contents of this file are used with permission, subject to }
{ the Mozilla Public License Version 1.1 (the "License"); you may }
{ not use this file except in compliance with the License. You may }
{ obtain a copy of the License at }
{ http://www.mozilla.org/MPL/MPL-1.1.html }
{ }
{ Software distributed under the License is distributed on an }
{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
{ implied. See the License for the specific language governing }
{ rights and limitations under the License. }
{ }
{******************************************************************}
unit WinBer;
{$WEAKPACKAGEUNIT}
{$HPPEMIT ''}
{$HPPEMIT '#include "WinBer.h"'}
{$HPPEMIT ''}
{$I WINDEFINES.INC}
interface
uses
WinLDAP, WinType;
const
LBER_ERROR = DWORD($ffffffff);
{$EXTERNALSYM LBER_ERROR}
LBER_DEFAULT = DWORD($ffffffff);
{$EXTERNALSYM LBER_DEFAULT}
//
// This constructs a new BerElement structure containing a copy of the
// data in the supplied berval structure.
//
function ber_init(pBerVal: PBerVal): PBerElement; cdecl;
{$EXTERNALSYM ber_init}
//
// This frees a BerElement which is returned from ber_alloc_t()
// or ber_init(). The second argument - fbuf should always be set
// to 1.
//
//
procedure ber_free(pBerElement: PBerElement; fbuf: Integer); cdecl;
{$EXTERNALSYM ber_free}
//
// Frees a BERVAL structure. Applications should not call
// this API to free BERVAL structures which they themselves
// have allocated
//
procedure ber_bvfree(pBerVal: PBerVal); cdecl;
{$EXTERNALSYM ber_bvfree}
//
// Frees an array of BERVAL structures.
//
procedure ber_bvecfree(pBerVal: PBerVal); cdecl;
{$EXTERNALSYM ber_bvecfree}
//
// Returns a copy of a the supplied berval structure
//
function ber_bvdup(pBerVal: PBerVal): PBerVal; cdecl;
{$EXTERNALSYM ber_bvdup}
//
// Constructs and returns a BerElement structure. The options field
// contains a bitwise-or of options which are to be used when generating
// the encoding of the BerElement
//
// The LBER_USE_DER options should always be specified.
//
function ber_alloc_t(options: Integer): PBerElement; cdecl;
{$EXTERNALSYM ber_alloc_t}
//
// This skips over the current tag and returns the tag of the next
// element in the supplied BerElement. The lenght of this element is
// stored in the pLen argument.
//
// LBER_DEFAULT is returned if there is no further data to be read
// else the tag of the next element is returned.
//
// The difference between ber_skip_tag() and ber_peek_tag() is that the
// state pointer is advanced past the first tag+lenght and is pointed to
// the value part of the next element
//
function ber_skip_tag(pBerElement: PBerElement; var pLen: ULONG): ULONG; cdecl;
{$EXTERNALSYM ber_skip_tag}
//
// This returns the tag of the next element to be parsed in the
// supplied BerElement. The length of this element is stored in the
// pLen argument.
//
// LBER_DEFAULT is returned if there is no further data to be read
// else the tag of the next element is returned.
//
function ber_peek_tag(pBerElement: PBerElement; var pLen: ULONG): ULONG; cdecl;
{$EXTERNALSYM ber_peek_tag}
//
// This returns the tag and length of the first element in a SET, SET OF
// or SEQUENCE OF data value.
//
// LBER_DEFAULT is returned if the constructed value is empty else, the tag
// is returned. It also returns an opaque cookie which has to be passed to
// subsequent invocations of ber_next_element().
//
function ber_first_element(pBerElement: PBerElement; var pLen: ULONG; var ppOpaque: PChar): ULONG; cdecl;
{$EXTERNALSYM ber_first_element}
//
// This positions the state at the start of the next element in the
// constructed type.
//
// LBER_DEFAULT is returned if the constructed value is empty else, the tag
// is returned.
//
function ber_next_element(pBerElement: PBerElement; var pLen: ULONG; opaque: PChar): ULONG; cdecl;
{$EXTERNALSYM ber_next_element}
//
// This allocates a BerVal structure whose contents are taken from the
// supplied BerElement structure.
//
// The return values are 0 on success and -1 on error.
//
function ber_flatten(pBerElement: PBerElement; var pBerVal: PBerVal): Integer; cdecl;
{$EXTERNALSYM ber_flatten}
//
// This is similar to sprintf(). One important difference
// is that state information is maintained in the BerElement so that multiple
// calls can be made to ber_printf() to append to the end of the BerElement.
//
// The function returns -1 if there is an error during encoding.
//
//function ber_printf(pBerElement: PBerElement; fmt: PChar; ... } ): Integer; cdecl;
//{$EXTERNALSYM ber_printf}
//function ber_scanf(pBerElement: PBerElement; fmt: PChar; ... } ): ULONG; cdecl;
//{$EXTERNALSYM ber_scanf}
implementation
const
winberapi = 'wldap32.dll';
function ber_init; external winberapi name 'ber_init';
procedure ber_free; external winberapi name 'ber_free';
procedure ber_bvfree; external winberapi name 'ber_bvfree';
procedure ber_bvecfree; external winberapi name 'ber_bvecfree';
function ber_bvdup; external winberapi name 'ber_bvdup';
function ber_alloc_t; external winberapi name 'ber_alloc_t';
function ber_skip_tag; external winberapi name 'ber_skip_tag';
function ber_peek_tag; external winberapi name 'ber_peek_tag';
function ber_first_element; external winberapi name 'ber_first_element';
function ber_next_element; external winberapi name 'ber_next_element';
function ber_flatten; external winberapi name 'ber_flatten';
//function ber_printf; external winberapi name 'ber_printf';
//function ber_scanf; external winberapi name 'ber_scanf';
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -