Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

531 lines
16 KiB

  1. //------------------------------------------------------------
  2. // Open Data Services header file: srv.h
  3. // Copyright (c) 1989 - 1999 by Microsoft Corp.
  4. //
  5. // Avoid double inclusion
  6. #ifndef _ODS_SRV_H_
  7. #define _ODS_SRV_H_
  8. #include "windows.h"
  9. // ODS uses pack(4) on all CPU types
  10. #pragma pack(4)
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. // define model
  15. #if !defined( FAR )
  16. #define FAR far
  17. #endif
  18. //------------------------------------------------------------
  19. // Formats of data types
  20. #if !defined(DBTYPEDEFS) // Do not conflict with DBLIB definitions
  21. #if !defined(MAXNUMERICLEN) // Do not conflict with ODBC definitions
  22. #define DBTYPEDEFS
  23. typedef unsigned char DBBOOL;
  24. typedef unsigned char DBBYTE;
  25. typedef unsigned char DBTINYINT;
  26. typedef short DBSMALLINT;
  27. typedef unsigned short DBUSMALLINT;
  28. typedef long DBINT;
  29. typedef char DBCHAR;
  30. typedef unsigned char DBBINARY;
  31. typedef unsigned char DBBIT;
  32. typedef double DBFLT8;
  33. typedef struct srv_datetime
  34. { // Format for SRVDATETIME
  35. long dtdays; // number of days since 1/1/1900
  36. unsigned long dttime; // number 300th second since mid
  37. } DBDATETIME;
  38. typedef struct srv_money
  39. { // Format for SRVMONEY
  40. long mnyhigh;
  41. unsigned long mnylow;
  42. } DBMONEY;
  43. typedef float DBFLT4;
  44. typedef long DBMONEY4;
  45. typedef struct dbdatetime4
  46. { // Format for SRVDATETIM4
  47. unsigned short numdays; // number of days since 1/1/1900
  48. unsigned short nummins; // number of minutes sicne midnight
  49. } DBDATETIM4;
  50. #define MAXNUMERICLEN 16
  51. typedef struct dbnumeric
  52. { // Format for SRVNUMERIC,SRVNUMERICN,SRVDECIMAL,SRVDECIMALN
  53. BYTE precision;
  54. BYTE scale;
  55. BYTE sign;
  56. BYTE val[MAXNUMERICLEN];
  57. } DBNUMERIC;
  58. typedef DBNUMERIC DBDECIMAL;
  59. #endif // #if !defined(MAXNUMERICLEN)
  60. #endif // #if !defined( DBTYPEDEFS )
  61. //------------------------------------------------------------
  62. // Constants used by APIs
  63. // Type Tokens
  64. #define SRV_TDS_NULL (BYTE) 0x1f
  65. #define SRV_TDS_TEXT (BYTE) 0x23
  66. #define SRV_TDS_GUID (BYTE) 0x24
  67. #define SRV_TDS_VARBINARY (BYTE) 0x25
  68. #define SRV_TDS_INTN (BYTE) 0x26
  69. #define SRV_TDS_VARCHAR (BYTE) 0x27
  70. #define SRV_TDS_BINARY (BYTE) 0x2d
  71. #define SRV_TDS_IMAGE (BYTE) 0x22
  72. #define SRV_TDS_CHAR (BYTE) 0x2f
  73. #define SRV_TDS_INT1 (BYTE) 0x30
  74. #define SRV_TDS_BIT (BYTE) 0x32
  75. #define SRV_TDS_INT2 (BYTE) 0x34
  76. #define SRV_TDS_DECIMAL (BYTE) 0x37
  77. #define SRV_TDS_INT4 (BYTE) 0x38
  78. #define SRV_TDS_DATETIM4 (BYTE) 0x3a
  79. #define SRV_TDS_FLT4 (BYTE) 0x3b
  80. #define SRV_TDS_MONEY (BYTE) 0x3c
  81. #define SRV_TDS_DATETIME (BYTE) 0x3d
  82. #define SRV_TDS_FLT8 (BYTE) 0x3e
  83. #define SRV_TDS_NUMERIC (BYTE) 0x3f
  84. #define SRV_TDS_NTEXT (BYTE) 0x63
  85. #define SRV_TDS_BITN (BYTE) 0x68
  86. #define SRV_TDS_DECIMALN (BYTE) 0x6a
  87. #define SRV_TDS_NUMERICN (BYTE) 0x6c
  88. #define SRV_TDS_FLTN (BYTE) 0x6d
  89. #define SRV_TDS_MONEYN (BYTE) 0x6e
  90. #define SRV_TDS_DATETIMN (BYTE) 0x6f
  91. #define SRV_TDS_MONEY4 (BYTE) 0x7a
  92. #define SRV_TDS_BIGVARBINARY (BYTE) 0xA5
  93. #define SRV_TDS_BIGVARCHAR (BYTE) 0xA7
  94. #define SRV_TDS_BIGBINARY (BYTE) 0xAD
  95. #define SRV_TDS_BIGCHAR (BYTE) 0xAF
  96. #define SRV_TDS_NVARCHAR (BYTE) 0xe7
  97. #define SRV_TDS_NCHAR (BYTE) 0xef
  98. // Datatypes
  99. // Also: values of symbol parameter to srv_symbol when type = SRV_DATATYPE
  100. #define SRVNULL SRV_TDS_NULL
  101. #define SRVTEXT SRV_TDS_TEXT
  102. #define SRVGUID SRV_TDS_GUID
  103. #define SRVVARBINARY SRV_TDS_VARBINARY
  104. #define SRVINTN SRV_TDS_INTN
  105. #define SRVVARCHAR SRV_TDS_VARCHAR
  106. #define SRVBINARY SRV_TDS_BINARY
  107. #define SRVIMAGE SRV_TDS_IMAGE
  108. #define SRVCHAR SRV_TDS_CHAR
  109. #define SRVINT1 SRV_TDS_INT1
  110. #define SRVBIT SRV_TDS_BIT
  111. #define SRVINT2 SRV_TDS_INT2
  112. #define SRVDECIMAL SRV_TDS_DECIMAL
  113. #define SRVINT4 SRV_TDS_INT4
  114. #define SRVDATETIM4 SRV_TDS_DATETIM4
  115. #define SRVFLT4 SRV_TDS_FLT4
  116. #define SRVMONEY SRV_TDS_MONEY
  117. #define SRVDATETIME SRV_TDS_DATETIME
  118. #define SRVFLT8 SRV_TDS_FLT8
  119. #define SRVNUMERIC SRV_TDS_NUMERIC
  120. #define SRVNTEXT SRV_TDS_NTEXT
  121. #define SRVBITN SRV_TDS_BITN
  122. #define SRVDECIMALN SRV_TDS_DECIMALN
  123. #define SRVNUMERICN SRV_TDS_NUMERICN
  124. #define SRVFLTN SRV_TDS_FLTN
  125. #define SRVMONEYN SRV_TDS_MONEYN
  126. #define SRVDATETIMN SRV_TDS_DATETIMN
  127. #define SRVMONEY4 SRV_TDS_MONEY4
  128. #define SRVBIGVARBINARY SRV_TDS_BIGVARBINARY
  129. #define SRVBIGVARCHAR SRV_TDS_BIGVARCHAR
  130. #define SRVBIGBINARY SRV_TDS_BIGBINARY
  131. #define SRVBIGCHAR SRV_TDS_BIGCHAR
  132. #define SRVNVARCHAR SRV_TDS_NVARCHAR
  133. #define SRVNCHAR SRV_TDS_NCHAR
  134. // values for srv_symbol type parameter
  135. #define SRV_ERROR 0
  136. #define SRV_DONE 1
  137. #define SRV_DATATYPE 2
  138. #define SRV_EVENT 4
  139. // values for srv_symbol symbol parameter, when type = SRV_ERROR
  140. #define SRV_ENO_OS_ERR 0
  141. #define SRV_INFO 1
  142. #define SRV_FATAL_PROCESS 10
  143. #define SRV_FATAL_SERVER 19
  144. // Types of server events
  145. // Also: values for srv_symbol symbol parameter, when type = SRV_EVENT
  146. #define SRV_CONTINUE 0
  147. #define SRV_LANGUAGE 1
  148. #define SRV_CONNECT 2
  149. #define SRV_RPC 3
  150. #define SRV_RESTART 4
  151. #define SRV_DISCONNECT 5
  152. #define SRV_ATTENTION 6
  153. #define SRV_SLEEP 7
  154. #define SRV_START 8
  155. #define SRV_STOP 9
  156. #define SRV_EXIT 10
  157. #define SRV_CANCEL 11
  158. #define SRV_SETUP 12
  159. #define SRV_CLOSE 13
  160. #define SRV_PRACK 14
  161. #define SRV_PRERROR 15
  162. #define SRV_ATTENTION_ACK 16
  163. #define SRV_CONNECT_V7 16 // TDS type for TDS 7 clients. Overloaded with SRV_ATTENTION_ACK
  164. #define SRV_SKIP 17
  165. #define SRV_TRANSMGR 18
  166. #define SRV_OLEDB 20
  167. #define SRV_INTERNAL_HANDLER 99
  168. #define SRV_PROGRAMMER_DEFINED 100
  169. // values for srv_config option parameter
  170. #define SRV_CONNECTIONS 1
  171. #define SRV_LOGFILE 2
  172. #define SRV_STACKSIZE 3
  173. #define SRV_REMOTE_ACCESS 7
  174. #define SRV_REMOTE_CONNECTIONS 9
  175. #define SRV_MAX_PACKETS 10
  176. #define SRV_MAXWORKINGTHREADS 11
  177. #define SRV_MINWORKINGTHREADS 12
  178. #define SRV_THREADTIMEOUT 13
  179. #define SRV_MAX_PACKETSIZE 17
  180. #define SRV_THREADPRIORITY 18
  181. #define SRV_ANSI_CODEPAGE 19
  182. #define SRV_DEFAULT_PACKETSIZE 26
  183. #define SRV_PASSTHROUGH 27
  184. // vlaues for srv_config value parameter when option = SRV_THREADPRIORITY
  185. #define SRV_PRIORITY_LOW THREAD_PRIORITY_LOWEST
  186. #define SRV_PRIORITY_NORMAL THREAD_PRIORITY_NORMAL
  187. #define SRV_PRIORITY_HIGH THREAD_PRIORITY_HIGHEST
  188. #define SRV_PRIORITY_CRITICAL THREAD_PRIORITY_TIME_CRITICAL
  189. // values for srv_sfield field parameter
  190. #define SRV_SERVERNAME 0
  191. #define SRV_VERSION 6
  192. // Length to indicate string is null terminated
  193. #define SRV_NULLTERM -1
  194. // values of msgtype parameter to srv_sendmsg
  195. #define SRV_MSG_INFO 1
  196. #define SRV_MSG_ERROR 2
  197. // values of status parameter to srv_senddone
  198. // Also: values for symbol parameters to srv_symbol when type = SRV_DONE
  199. #define SRV_DONE_FINAL (USHORT) 0x0000
  200. #define SRV_DONE_MORE (USHORT) 0x0001
  201. #define SRV_DONE_ERROR (USHORT) 0x0002
  202. #define SRV_DONE_COUNT (USHORT) 0x0010
  203. #define SRV_DONE_RPC_IN_BATCH (USHORT) 0x0080
  204. // return values of srv_paramstatus
  205. #define SRV_PARAMRETURN 0x0001
  206. #define SRV_PARAMDEFAULT 0x0002
  207. // return values of srv_rpcoptions
  208. #define SRV_RECOMPILE 0x0001
  209. #define SRV_NOMETADATA 0x0002
  210. // values of field parameter to srv_pfield
  211. //#define SRV_LANGUAGE 1 already defined above
  212. //#define SRV_EVENT 4 already defined above
  213. #define SRV_SPID 10
  214. #define SRV_NETSPID 11
  215. #define SRV_TYPE 12
  216. #define SRV_STATUS 13
  217. #define SRV_RMTSERVER 14
  218. #define SRV_HOST 15
  219. #define SRV_USER 16
  220. #define SRV_PWD 17
  221. #define SRV_CPID 18
  222. #define SRV_APPLNAME 19
  223. #define SRV_TDS 20
  224. #define SRV_CLIB 21
  225. #define SRV_LIBVERS 22
  226. #define SRV_ROWSENT 23
  227. #define SRV_BCPFLAG 24
  228. #define SRV_NATLANG 25
  229. #define SRV_PIPEHANDLE 26
  230. #define SRV_NETWORK_MODULE 27
  231. #define SRV_NETWORK_VERSION 28
  232. #define SRV_NETWORK_CONNECTION 29
  233. #define SRV_LSECURE 30
  234. #define SRV_SAXP 31
  235. #define SRV_UNICODE_USER 33
  236. #define SRV_UNICODE_PWD 35
  237. #define SRV_SPROC_CODEPAGE 36
  238. // return value of SRV_TDSVERSION macro
  239. #define SRV_TDS_NONE 0
  240. #define SRV_TDS_2_0 1
  241. #define SRV_TDS_3_4 2
  242. #define SRV_TDS_4_2 3
  243. #define SRV_TDS_6_0 4
  244. #define SRV_TDS_7_0 5
  245. // Return values from APIs
  246. typedef int SRVRETCODE; // SUCCEED or FAIL
  247. #ifndef ODBCVER
  248. typedef int RETCODE;
  249. #endif
  250. #if !defined( SUCCEED )
  251. #define SUCCEED 1 // Successful return value
  252. #endif
  253. #if !defined( FAIL )
  254. #define FAIL 0 // Unsuccessful return value
  255. #endif
  256. #define SRV_DUPLICATE_HANDLER 2 // additional return value for srv_pre/post_handle
  257. //------------------------------------------------
  258. //PreDeclare structures
  259. //
  260. struct srv_server;
  261. typedef struct srv_server SRV_SERVER;
  262. struct srv_config;
  263. typedef struct srv_config SRV_CONFIG;
  264. struct srv_proc;
  265. typedef struct srv_proc SRV_PROC;
  266. //------------------------------------------------
  267. //------------------------------------------------
  268. // ODS MACROs & APIs
  269. // Describing and sending a result set
  270. int srv_describe(SRV_PROC*,int,char*,int,long int,long int,long int,long int,void*);
  271. int srv_setutype(SRV_PROC* srvproc,int column,long int usertype);
  272. int srv_setcoldata(SRV_PROC* srvproc,int column,void* data);
  273. int srv_setcollen( SRV_PROC* srvproc,int column,int len);
  274. int srv_sendrow(SRV_PROC* srvproc );
  275. int srv_senddone(SRV_PROC* srvproc,USHORT status,USHORT curcmd,long int count);
  276. // Dealing with Extended Procedure parameters
  277. int srv_rpcparams(SRV_PROC*);
  278. int srv_paraminfo(SRV_PROC*,int,BYTE*,ULONG*,ULONG*,BYTE*,BOOL*);
  279. int srv_paramsetoutput(SRV_PROC*,int,BYTE*,ULONG,BOOL);
  280. void* srv_paramdata(SRV_PROC*,int);
  281. int srv_paramlen(SRV_PROC*,int);
  282. int srv_parammaxlen(SRV_PROC*,int);
  283. int srv_paramtype(SRV_PROC*,int);
  284. int srv_paramset(SRV_PROC*,int,void*,int);
  285. char* srv_paramname(SRV_PROC*,int,int*);
  286. int srv_paramnumber(SRV_PROC*,char*,int);
  287. //--------------------------------------------------------------
  288. //--------------------------------------------------------------
  289. // The rest of these APIs are still supported, in SQL Server 7.0,
  290. // but may not be supported after SQL Server 7.0
  291. // MACROs
  292. #define SRV_GETCONFIG(a) srv_getconfig ( a )
  293. #define SRV_GETSERVER(a) srv_getserver ( a )
  294. #define SRV_GOT_ATTENTION(a) srv_got_attention ( a )
  295. #define SRV_EVENTDATA(a) srv_eventdata ( a )
  296. #define SRV_IODEAD(a) srv_iodead ( a )
  297. #define SRV_TDSVERSION(a) srv_tdsversion ( a )
  298. SRV_CONFIG* srv_getconfig( SRV_SERVER * server );
  299. SRV_SERVER* srv_getserver( SRV_PROC * srvproc );
  300. BOOL srv_got_attention( SRV_PROC * srvproc );
  301. void* srv_eventdata( SRV_PROC * srvproc );
  302. // Memory
  303. void* srv_alloc(long int ulSize);
  304. int srv_bmove(void* from,void* to,long int count);
  305. int srv_bzero( void * location,long int count);
  306. int srv_free( void * ptr );
  307. int srv_config( SRV_CONFIG * config,long int option,char* value,int valuelen);
  308. SRV_CONFIG * srv_config_alloc( void );
  309. int srv_convert(SRV_PROC*,int,void*,long int,int,void*,long int);
  310. int (* srv_errhandle(int (* handler)(SRV_SERVER * server,
  311. SRV_PROC * srvproc,
  312. int srverror,
  313. BYTE severity,
  314. BYTE state,
  315. int oserrnum,
  316. char * errtext,
  317. int errtextlen,
  318. char * oserrtext,
  319. int oserrtextlen)))
  320. ( SRV_SERVER * server,
  321. SRV_PROC * srvproc,
  322. int srverror,
  323. BYTE severity,
  324. BYTE state,
  325. int oserrnum,
  326. char * errtext,
  327. int errtextlen,
  328. char * oserrtext,
  329. int oserrtextlen );
  330. int srv_event(SRV_PROC * srvproc,int event,BYTE* data);
  331. void* srv_getuserdata( SRV_PROC * srvproc );
  332. int srv_getbindtoken(SRV_PROC * srvproc,char* token_buf);
  333. int srv_getdtcxact(SRV_PROC * srvproc,void ** ppv);
  334. typedef int (* EventHandler)(void*);
  335. EventHandler srv_handle(SRV_SERVER*,long int,EventHandler);
  336. int srv_impersonate_client( SRV_PROC * srvproc );
  337. SRV_SERVER* srv_init( SRV_CONFIG * config,
  338. char * connectname,
  339. int namelen );
  340. BOOL srv_iodead( SRV_PROC * srvproc );
  341. long srv_langcpy(SRV_PROC * srvproc,long start,long nbytes,char* buffer);
  342. long srv_langlen( SRV_PROC * srvproc );
  343. void* srv_langptr( SRV_PROC *srvproc );
  344. int
  345. srv_log( SRV_SERVER * server,
  346. BOOL datestamp,
  347. char * msg,
  348. int msglen );
  349. int srv_paramstatus(SRV_PROC*,int);
  350. char* srv_pfield( SRV_PROC * srvproc,int field,int * len );
  351. int srv_returnval( SRV_PROC * srvproc,
  352. char * valuename,
  353. int len,
  354. BYTE status,
  355. long int type,
  356. long int maxlen,
  357. long int datalen,
  358. void * value );
  359. int srv_revert_to_self( SRV_PROC * srvproc );
  360. char* srv_rpcdb(SRV_PROC* srvproc,int* len );
  361. char* srv_rpcname(SRV_PROC * srvproc,int* len );
  362. int srv_rpcnumber( SRV_PROC * srvproc );
  363. USHORT srv_rpcoptions( SRV_PROC * srvproc );
  364. char* srv_rpcowner( SRV_PROC * srvproc,int * len );
  365. int srv_run( SRV_SERVER * server );
  366. int
  367. srv_sendmsg( SRV_PROC * srvproc,
  368. int msgtype,
  369. long int msgnum,
  370. BYTE msgclass,
  371. BYTE state,
  372. char * rpcname,
  373. int rpcnamelen,
  374. USHORT linenum,
  375. char * message,
  376. int msglen );
  377. int
  378. srv_ansi_sendmsg( SRV_PROC * srvproc,
  379. int msgtype,
  380. long int msgnum,
  381. BYTE msgclass,
  382. BYTE state,
  383. char * rpcname,
  384. int rpcnamelen,
  385. USHORT linenum,
  386. char * message,
  387. int msglen );
  388. int srv_sendstatus( SRV_PROC * srvproc,long int status );
  389. int srv_setuserdata(SRV_PROC* srvproc,void* ptr);
  390. char* srv_sfield( SRV_SERVER * server,int field,int* len);
  391. char* srv_symbol(int type,int symbol,int* len);
  392. int srv_tdsversion(SRV_PROC* srvproc);
  393. int srv_writebuf(SRV_PROC* srvproc, void* ptr, WORD count);
  394. BOOL srv_willconvert(int srctype,int desttype );
  395. void srv_ackattention( SRV_PROC * srvproc );
  396. int srv_terminatethread( SRV_PROC * srvproc );
  397. int srv_sendstatistics( SRV_PROC * srvproc );
  398. int srv_clearstatistics( SRV_PROC * srvproc );
  399. int srv_setevent( SRV_SERVER * server, int event);
  400. int srv_message_handler( SRV_PROC * srvproc,
  401. int errornum,
  402. BYTE severity,
  403. BYTE state,
  404. int oserrnum,
  405. char * errtext,
  406. int errtextlen,
  407. char * oserrtext,
  408. int oserrtextlen );
  409. int srv_pre_handle( SRV_SERVER * server,
  410. SRV_PROC * srvproc,
  411. long int event,
  412. EventHandler handler,
  413. BOOL remove );
  414. int srv_post_handle( SRV_SERVER * server,
  415. SRV_PROC * srvproc,
  416. long int event,
  417. EventHandler handler,
  418. BOOL remove );
  419. int srv_post_completion_queue( SRV_PROC * srvproc,
  420. char * inbuf,
  421. int inbuflen );
  422. int srv_IgnoreAnsiToOem( SRV_PROC * srvproc,BOOL bTF);
  423. #ifdef __cplusplus
  424. }
  425. #endif
  426. #pragma pack()
  427. #define SS_MAJOR_VERSION 7
  428. #define SS_MINOR_VERSION 00
  429. #define SS_LEVEL_VERSION 0000
  430. #define SS_MINIMUM_VERSION "7.00.00.0000"
  431. #define ODS_VERSION ((SS_MAJOR_VERSION << 24) | (SS_MINOR_VERSION << 16))
  432. #endif //_ODS_SRV_H_
  433. //////////////////////////////////////////////////////////////////
  434. // Suggested implementation of __GetXpVersion
  435. //
  436. //__declspec(dllexport) ULONG __GetXpVersion()
  437. // {
  438. // return ODS_VERSION;
  439. // }
  440. //////////////////////////////////////////////////////////////////