Перевод ODS API mssql2000 на Delphi (написание extended stored procedures)
Автор: Wicked
{ **** UBPFD *********** by delphibase.endimus.com ****
>> перевод ODS API mssql2000 на Delphi (написание extended stored procedures)
перевод (как я понял, один из многих) заголовочных файлов
ODS API mssql2000 на object pascal.... для успешной работы необходима opends60.dll...
выполнен с помощью утилиты c2p, её комментарии я оставил...
часть функций, помеченные как устаревшие, не были переведены...
имхо перевод не лишен недостатков, поэтому используйте as is...
добавлю, что у меня всё работает... :)
Зависимости: windows
Автор: wicked, wilk@ua.fm, ICQ:92356239, Тернополь
Copyright: (1) Microsoft (srv.h), (2) Oleg Bulychov, (3) wicked aka Andy Wilk
Дата: 15 ноября 2002 г.
***************************************************** }
{*********************************}
{ Generated by c2pas32 v0.9b }
{ (c) 2001 Oleg Bulychov }
{ Gladiators Software }
{ http://www.astonshell.com/ }
{*********************************}
{(c) 2002 corrections by andy wilk }
unit srv_h;
interface
uses windows;
//------------------------------------------------------------
// Open Data Services header file: srv.h
// Copyright (c) 1989, 1990, 1991, 1997 by Microsoft Corp.
//
// Avoid double inclusion
// ODS uses pack(4) on all CPU types
{$A+ }
// define model
//dll name
const
opends_dll = 'opends60.dll';
//------------------------------------------------------------
// Formats of data types
type
DBBOOL = boolean;
DBBYTE = byte;
DBTINYINT = byte;
DBSMALLINT = smallint;
DBUSMALLINT = word;
DBINT = integer;
DBCHAR = char;
pDBCHAR = ^DBCHAR;
DBBINARY = byte;
DBBIT = byte;
DBFLT8 = double;
pinteger = ^integer;
USHORT = word;
srv_datetime = record // Format for SRVDATETIME
dtdays: integer; // number of days since 1/1/1900
dttime: UINT; // number 300th second since mid
end;
DBDATETIME = srv_datetime;
srv_money = record // Format for SRVMONEY
mnyhigh: integer;
mnylow: UINT;
end;
DBMONEY = srv_money;
DBFLT4 = single;
DBMONEY4 = integer;
dbdatetime4 = record // Format for SRVDATETIM4
numdays: word; // number of days since 1/1/1900
nummins: word; // number of minutes sicne midnight
end;
DBDATETIM4 = dbdatetime4;
const
MAXNUMERICLEN = 16;
type
dbnumeric = record // Format for SRVNUMERIC,SRVNUMERICN,SRVDECIMAL,SRVDECIMALN
precision: BYTE;
scale: BYTE;
sign: BYTE;
val: array[0..Pred(MAXNUMERICLEN)] of BYTE;
end;
//DBNUMERIC = dbnumeric;
DBDECIMAL = DBNUMERIC;
//------------------------------------------------------------
// Constants used by APIs
// Type Tokens
const
SRV_TDS_NULL = {!!!a type cast? =>} {BYTE(} $1F;
SRV_TDS_TEXT = {!!!a type cast? =>} {BYTE(} $23;
SRV_TDS_GUID = {!!!a type cast? =>} {BYTE(} $24;
SRV_TDS_VARBINARY = {!!!a type cast? =>} {BYTE(} $25;
SRV_TDS_INTN = {!!!a type cast? =>} {BYTE(} $26;
SRV_TDS_VARCHAR = {!!!a type cast? =>} {BYTE(} $27;
SRV_TDS_BINARY = {!!!a type cast? =>} {BYTE(} $2D;
SRV_TDS_IMAGE = {!!!a type cast? =>} {BYTE(} $22;
SRV_TDS_CHAR = {!!!a type cast? =>} {BYTE(} $2F;
SRV_TDS_INT1 = {!!!a type cast? =>} {BYTE(} $30;
SRV_TDS_BIT = {!!!a type cast? =>} {BYTE(} $32;
SRV_TDS_INT2 = {!!!a type cast? =>} {BYTE(} $34;
SRV_TDS_DECIMAL = {!!!a type cast? =>} {BYTE(} $37;
SRV_TDS_INT4 = {!!!a type cast? =>} {BYTE(} $38;
SRV_TDS_DATETIM4 = {!!!a type cast? =>} {BYTE(} $3A;
SRV_TDS_FLT4 = {!!!a type cast? =>} {BYTE(} $3B;
SRV_TDS_MONEY = {!!!a type cast? =>} {BYTE(} $3C;
SRV_TDS_DATETIME = {!!!a type cast? =>} {BYTE(} $3D;
SRV_TDS_FLT8 = {!!!a type cast? =>} {BYTE(} $3E;
SRV_TDS_NUMERIC = {!!!a type cast? =>} {BYTE(} $3F;
SRV_TDS_SSVARIANT = {!!!a type cast? =>} {BYTE(} $62;
SRV_TDS_NTEXT = {!!!a type cast? =>} {BYTE(} $63;
SRV_TDS_BITN = {!!!a type cast? =>} {BYTE(} $68;
SRV_TDS_DECIMALN = {!!!a type cast? =>} {BYTE(} $6A;
SRV_TDS_NUMERICN = {!!!a type cast? =>} {BYTE(} $6C;
SRV_TDS_FLTN = {!!!a type cast? =>} {BYTE(} $6D;
SRV_TDS_MONEYN = {!!!a type cast? =>} {BYTE(} $6E;
SRV_TDS_DATETIMN = {!!!a type cast? =>} {BYTE(} $6F;
SRV_TDS_MONEY4 = {!!!a type cast? =>} {BYTE(} $7A;
SRV_TDS_INT8 = {!!!a type cast? =>} {BYTE(} $7F;
SRV_TDS_BIGVARBINARY = {!!!a type cast? =>} {BYTE(} $A5;
SRV_TDS_BIGVARCHAR = {!!!a type cast? =>} {BYTE(} $A7;
SRV_TDS_BIGBINARY = {!!!a type cast? =>} {BYTE(} $AD;
SRV_TDS_BIGCHAR = {!!!a type cast? =>} {BYTE(} $AF;
SRV_TDS_NVARCHAR = {!!!a type cast? =>} {BYTE(} $E7;
SRV_TDS_NCHAR = {!!!a type cast? =>} {BYTE(} $EF;
// Datatypes
// Also: values of symbol parameter to srv_symbol when type = SRV_DATATYPE
SRVNULL = SRV_TDS_NULL;
SRVTEXT = SRV_TDS_TEXT;
SRVGUID = SRV_TDS_GUID;
SRVVARBINARY = SRV_TDS_VARBINARY;
SRVINTN = SRV_TDS_INTN;
SRVVARCHAR = SRV_TDS_VARCHAR;
SRVBINARY = SRV_TDS_BINARY;
SRVIMAGE = SRV_TDS_IMAGE;
SRVCHAR = SRV_TDS_CHAR;
SRVINT1 = SRV_TDS_INT1;
SRVBIT = SRV_TDS_BIT;
SRVINT2 = SRV_TDS_INT2;
SRVDECIMAL = SRV_TDS_DECIMAL;
SRVINT4 = SRV_TDS_INT4;
SRVDATETIM4 = SRV_TDS_DATETIM4;
SRVFLT4 = SRV_TDS_FLT4;
SRVMONEY = SRV_TDS_MONEY;
SRVDATETIME = SRV_TDS_DATETIME;
SRVFLT8 = SRV_TDS_FLT8;
SRVNUMERIC = SRV_TDS_NUMERIC;
SRVSSVARIANT = SRV_TDS_SSVARIANT;
SRVNTEXT = SRV_TDS_NTEXT;
SRVBITN = SRV_TDS_BITN;
SRVDECIMALN = SRV_TDS_DECIMALN;
SRVNUMERICN = SRV_TDS_NUMERICN;
SRVFLTN = SRV_TDS_FLTN;
SRVMONEYN = SRV_TDS_MONEYN;
SRVDATETIMN = SRV_TDS_DATETIMN;
SRVMONEY4 = SRV_TDS_MONEY4;
SRVINT8 = SRV_TDS_INT8;
SRVBIGVARBINARY = SRV_TDS_BIGVARBINARY;
SRVBIGVARCHAR = SRV_TDS_BIGVARCHAR;
SRVBIGBINARY = SRV_TDS_BIGBINARY;
SRVBIGCHAR = SRV_TDS_BIGCHAR;
SRVNVARCHAR = SRV_TDS_NVARCHAR;
SRVNCHAR = SRV_TDS_NCHAR;
// values for srv_symbol type parameter
SRV_ERROR = 0;
SRV_DONE = 1;
SRV_DATATYPE = 2;
SRV_EVENT = 4;
// values for srv_symbol symbol parameter, when type = SRV_ERROR
SRV_ENO_OS_ERR = 0;
SRV_INFO = 1;
SRV_FATAL_PROCESS = 10;
SRV_FATAL_SERVER = 19;
// Types of server events
// Also: values for srv_symbol symbol parameter, when type = SRV_EVENT
SRV_CONTINUE = 0;
SRV_LANGUAGE = 1;
SRV_CONNECT = 2;
SRV_RPC = 3;
SRV_RESTART = 4;
SRV_DISCONNECT = 5;
SRV_ATTENTION = 6;
SRV_SLEEP = 7;
SRV_START = 8;
SRV_STOP = 9;
SRV_EXIT = 10;
SRV_CANCEL = 11;
SRV_SETUP = 12;
SRV_CLOSE = 13;
SRV_PRACK = 14;
SRV_PRERROR = 15;
SRV_ATTENTION_ACK = 16;
SRV_CONNECT_V7 = 16;
// TDS type for TDS 7 clients. Overloaded with SRV_ATTENTION_ACK
SRV_SKIP = 17;
SRV_TRANSMGR = 18;
SRV_PRELOGIN = 19;
SRV_OLEDB = 20;
SRV_INTERNAL_HANDLER = 99;
SRV_PROGRAMMER_DEFINED = 100;
// values for srv_sfield field parameter
SRV_SERVERNAME = 0;
SRV_VERSION = 6;
// Length to indicate string is null terminated
SRV_NULLTERM = -1;
// values of msgtype parameter to srv_sendmsg
SRV_MSG_INFO = 1;
SRV_MSG_ERROR = 2;
// values of status parameter to srv_senddone
// Also: values for symbol parameters to srv_symbol when type = SRV_DONE
SRV_DONE_FINAL = {!!!a type cast? =>} {USHORT(} $0000;
SRV_DONE_MORE = {!!!a type cast? =>} {USHORT(} $0001;
SRV_DONE_ERROR = {!!!a type cast? =>} {USHORT(} $0002;
SRV_DONE_COUNT = {!!!a type cast? =>} {USHORT(} $0010;
SRV_DONE_RPC_IN_BATCH = {!!!a type cast? =>} {USHORT(} $0080;
// return values of srv_paramstatus
SRV_PARAMRETURN = $0001;
SRV_PARAMDEFAULT = $0002;
SRV_PARAMSORTORDER = $0004;
// This is sent by clients in RPC, unset in processRPC
// return values of srv_rpcoptions
SRV_RECOMPILE = $0001;
SRV_NOMETADATA = $0002;
// values of field parameter to srv_pfield
//#define SRV_LANGUAGE 1 already defined above
//#define SRV_EVENT 4 already defined above
SRV_SPID = 10;
SRV_NETSPID = 11;
SRV_TYPE = 12;
SRV_STATUS = 13;
SRV_RMTSERVER = 14;
SRV_HOST = 15;
SRV_USER = 16;
SRV_PWD = 17;
SRV_CPID = 18;
SRV_APPLNAME = 19;
SRV_TDS = 20;
SRV_CLIB = 21;
SRV_LIBVERS = 22;
SRV_ROWSENT = 23;
SRV_BCPFLAG = 24;
SRV_NATLANG = 25;
SRV_PIPEHANDLE = 26;
SRV_NETWORK_MODULE = 27;
SRV_NETWORK_VERSION = 28;
SRV_NETWORK_CONNECTION = 29;
SRV_LSECURE = 30;
SRV_SAXP = 31;
SRV_UNICODE_USER = 33;
SRV_UNICODE_PWD = 35;
SRV_SPROC_CODEPAGE = 36;
SRV_MSGLCID = 37;
SRV_INSTANCENAME = 38;
SRV_HASHPWD = 39;
// return value of SRV_TDSVERSION macro
SRV_TDS_NONE = 0;
SRV_TDS_2_0 = 1;
SRV_TDS_3_4 = 2;
SRV_TDS_4_2 = 3;
SRV_TDS_6_0 = 4;
SRV_TDS_7_0 = 5;
// Return values from APIs
type
SRVRETCODE = integer; // SUCCEED or FAIL
//{$ifndef ODBCVER}
RETCODE = integer;
//{$endif}
//{$if !defined( SUCCEED )}
const
_SUCCEED = 1; // Successful return value
//{$endif}
//{$if !defined( FAIL )}
_FAIL = 0; // Unsuccessful return value
//{$endif}
SRV_DUPLICATE_HANDLER = 2; // additional return value for srv_pre/post_handle
//------------------------------------------------
//PreDeclare structures
//
type
srv_server = record
end;
pSRV_SERVER = ^srv_server;
srv_config = record
end;
pSRV_CONFIG = ^srv_config;
srv_proc = record
end;
pSRV_PROC = ^srv_proc;
//------------------------------------------------
//------------------------------------------------
// ODS MACROs & APIs
// Describing and sending a result set
function srv_describe(srvproc: pSRV_PROC;
colnumber: integer;
column_name: pchar;
namelen: integer;
desttype: integer;
destlen: integer;
srctype: integer;
srclen: integer;
srcdata: pointer): integer; cdecl; external opends_dll name 'srv_describe';
function srv_setutype(srvproc: pSRV_PROC; column: integer; usertype: integer):
integer; cdecl; external opends_dll name 'srv_setutype';
function srv_setcoldata(srvproc: pSRV_PROC; column: integer; data: pinteger):
integer; cdecl; external opends_dll name 'srv_setcoldata';
function srv_setcollen(srvproc: pSRV_PROC; column: integer; len: integer):
integer; cdecl; external opends_dll name 'srv_setcollen';
function srv_sendrow(srvproc: pSRV_PROC): integer; cdecl; external opends_dll
name 'srv_sendrow';
function srv_senddone(srvproc: pSRV_PROC; status: USHORT; curcmd: USHORT; count:
integer): integer; cdecl; external opends_dll name 'srv_senddone';
// Dealing with Extended Procedure parameters
function srv_rpcparams(srvproc: pSRV_PROC): integer; cdecl; external opends_dll
name 'srv_rpcparams';
function srv_paraminfo(srvproc: pSRV_PROC;
n: integer;
var pbType: integer;
var pcbMaxLen: integer;
var pcbActualLen: integer;
pbData: pointer;
var pfNull: byte): integer; cdecl; external opends_dll name 'srv_paraminfo';
function srv_paramsetoutput(srvproc: pSRV_PROC;
n: integer;
pbData: pointer;
cbLen: integer;
fNull: boolean): integer; cdecl; external opends_dll name
'srv_paramsetoutput';
//procedure srv_paramdata{!!!3 unknown typedef}; cdecl; external opends_dll name 'srv_paramdata';
//function srv_paramlen{!!!3 unknown typedef}: integer; cdecl; external opends_dll name 'srv_paramlen';
//function srv_parammaxlen{!!!3 unknown typedef}: integer; cdecl; external opends_dll name 'srv_parammaxlen';
//function srv_paramtype{!!!3 unknown typedef}: integer; cdecl; external opends_dll name 'srv_paramtype';
//function srv_paramset{!!!3 unknown typedef}: integer; cdecl; external opends_dll name 'srv_paramset';
function srv_paramname(srvproc: pSRV_PROC;
n: integer;
len: integer): pchar; cdecl; external opends_dll name 'srv_paramname';
function srv_paramnumber(srvproc: pSRV_PROC;
name: pchar;
namelen: integer): integer; cdecl; external opends_dll name 'srv_paramnumber';
//--------------------------------------------------------------
//--------------------------------------------------------------
// The rest of these APIs are still supported, in SQL Server 7.0,
// but may not be supported after SQL Server 7.0
// MACROs
//function SRV_GETSERVER(a: integer): integer; {<= !!!6 unknown macro}
//function SRV_GOT_ATTENTION(a: integer): integer; {<= !!!6 unknown macro}
//function SRV_TDSVERSION(a: integer): integer; {<= !!!6 unknown macro}
//function srv_getserver(srvproc: pSRV_PROC): pSRV_SERVER; cdecl; external opends_dll name 'srv_getserver';
//function srv_got_attention(srvproc: pSRV_PROC): boolean; cdecl; external opends_dll name 'srv_got_attention';
// Memory
//function srv_alloc(ulSize: integer): pointer; cdecl; external opends_dll name 'srv_alloc';
//function srv_bmove(from: pinteger; to: pinteger; count: integer): integer; cdecl; external opends_dll name 'srv_bmove';
//function srv_bzero(location: pinteger; count: integer): integer; cdecl; external opends_dll name 'srv_bzero';
//function srv_free(ptr: pinteger): integer; cdecl; external opends_dll name 'srv_free';
function srv_convert(srvproc: pSRV_PROC;
srctype: integer;
src: pointer;
srclen: DBINT;
desttype: integer;
dest: pointer;
destlen: DBINT): integer; cdecl; external opends_dll name 'srv_convert';
function srv_getuserdata(srvproc: pSRV_PROC): pointer; cdecl; external opends_dll
name 'srv_getuserdata';
function srv_getbindtoken(srvproc: pSRV_PROC; token_buf: pchar): integer; cdecl;
external opends_dll name 'srv_getbindtoken';
//function srv_getdtcxact(srvproc: pSRV_PROC; {!!!3 unknown typedef}): integer; cdecl; external opends_dll name 'srv_getdtcxact';
type
EventHandler = function(p: pointer): integer;
//function srv_impersonate_client(srvproc: pSRV_PROC): integer; cdecl; external opends_dll name 'srv_impersonate_client';
//function srv_langcpy(srvproc: pSRV_PROC; start: integer; nbytes: integer; buffer: pchar): integer; cdecl; external opends_dll name 'srv_langcpy';
//function srv_langlen(srvproc: pSRV_PROC): integer; cdecl; external opends_dll name 'srv_langlen';
//function srv_langptr(srvproc: pSRV_PROC): pointer; cdecl; external opends_dll name 'srv_langptr';
//function srv_log(server: pSRV_SERVER; datestamp: BOOL; msg: pchar; msglen: integer): integer; cdecl; external opends_dll name 'srv_log';
function srv_paramstatus(srvproc: pSRV_PROC;
n: integer): integer; cdecl; external opends_dll name 'srv_paramstatus';
function srv_pfieldex(srvproc: pSRV_PROC; field: integer; len: pinteger):
pointer; cdecl; external opends_dll name 'srv_pfieldex';
function srv_pfield(srvproc: pSRV_PROC; field: integer; len: pinteger): pchar;
cdecl; external opends_dll name 'srv_pfield';
function srv_returnval(srvproc: pSRV_PROC; valuename: pchar; len: integer;
status: BYTE; _type: integer; maxlen: integer; datalen: integer; value:
pinteger): integer; cdecl; external opends_dll name 'srv_returnval';
function srv_revert_to_self(srvproc: pSRV_PROC): integer; cdecl; external
opends_dll name 'srv_revert_to_self';
function srv_rpcdb(srvproc: pSRV_PROC; len: pinteger): pchar; cdecl; external
opends_dll name 'srv_rpcdb';
function srv_rpcname(srvproc: pSRV_PROC; len: pinteger): pchar; cdecl; external
opends_dll name 'srv_rpcname';
function srv_rpcnumber(srvproc: pSRV_PROC): integer; cdecl; external opends_dll
name 'srv_rpcnumber';
function srv_rpcoptions(srvproc: pSRV_PROC): USHORT; cdecl; external opends_dll
name 'srv_rpcoptions';
function srv_rpcowner(srvproc: pSRV_PROC; len: pinteger): pchar; cdecl; external
opends_dll name 'srv_rpcowner';
// message text
function srv_wsendmsg(srvproc: pSRV_PROC;
msgnum: integer;
msgclass: BYTE;
msg: pwidestring;
msglen: integer): integer; cdecl; external opends_dll name 'srv_wsendmsg';
function srv_sendmsg(srvproc: pSRV_PROC;
msgtype: integer;
msgnum: integer;
msgclass: BYTE;
state: BYTE;
rpcname: pchar;
rpcnamelen: integer;
linenum: USHORT;
msg: pchar;
msglen: integer): integer; cdecl; external opends_dll name 'srv_sendmsg';
function srv_sendstatus(srvproc: pSRV_PROC; status: integer): integer; cdecl;
external opends_dll name 'srv_sendstatus';
function srv_setuserdata(srvproc: pSRV_PROC; _ptr: pointer): integer; cdecl;
external opends_dll name 'srv_setuserdata';
function srv_sfield(server: pSRV_SERVER; field: integer; len: pinteger): pchar;
cdecl; external opends_dll name 'srv_sfield';
function srv_symbol(_type: integer; symbol: integer; len: pinteger): pchar;
cdecl; external opends_dll name 'srv_symbol';
function srv_tdsversion(srvproc: pSRV_PROC): integer; cdecl; external opends_dll
name 'srv_tdsversion';
function srv_willconvert(srctype: integer; desttype: integer): BOOL; cdecl;
external opends_dll name 'srv_willconvert';
function srv_terminatethread(srvproc: pSRV_PROC): integer; cdecl; external
opends_dll name 'srv_terminatethread';
function srv_sendstatistics(srvproc: pSRV_PROC): integer; cdecl; external
opends_dll name 'srv_sendstatistics';
function srv_clearstatistics(srvproc: pSRV_PROC): integer; cdecl; external
opends_dll name 'srv_clearstatistics';
function srv_message_handler(srvproc: pSRV_PROC;
errornum: integer;
severity: BYTE;
state: BYTE;
oserrnum: integer;
errtext: pchar;
errtextlen: integer;
oserrtext: pchar;
oserrtextlen: integer): integer; cdecl; external opends_dll name
'srv_message_handler';
function srv_pre_handle(server: pSRV_SERVER; srvproc: pSRV_PROC; event: integer;
handler: EventHandler; remove: boolean): integer; cdecl; external opends_dll
name
'srv_pre_handle';
function srv_post_handle(server: pSRV_SERVER; srvproc: pSRV_PROC; event:
integer; handler: EventHandler; remove: boolean): integer; cdecl; external
opends_dll name 'srv_post_handle';
function srv_IgnoreAnsiToOem(srvproc: pSRV_PROC; bTF: boolean): integer; cdecl;
external opends_dll name 'srv_IgnoreAnsiToOem';
{!!!1 => pragma pack()}
const
SS_MAJOR_VERSION = 7;
SS_MINOR_VERSION = 0;
SS_LEVEL_VERSION = 0;
SS_MINIMUM_VERSION = '7.00.00.0000';
ODS_VERSION = ((SS_MAJOR_VERSION shl 24) or (SS_MINOR_VERSION shl 16));
//_ODS_SRV_H_
//////////////////////////////////////////////////////////////////
// Suggested implementation of __GetXpVersion
//
//__declspec(dllexport) ULONG __GetXpVersion()
// {
// return ODS_VERSION;
// }
//////////////////////////////////////////////////////////////////
implementation
end.
|