home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Internet Business Development Kit / PRODUCT_CD.iso / sqlsvr / ptk / mips / srvstruc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-01  |  26.2 KB  |  784 lines

  1. //
  2. // Structure related defines
  3. //
  4.  
  5. #define SRV_SERVBSIZE(a)                            \
  6.             ((WORD)(a->srvio.packetsize) > (WORD)0  \
  7.             ? (WORD)(a->srvio.packetsize)           \
  8.             : (WORD)512)
  9.  
  10. #define SRV_DEFAULT_SERVBSIZE   512
  11. #define MAX_NETLIBS             16      // Maximum server side net-libs
  12. #define SRV_SERVNETFUNCS    11
  13.  
  14. #ifdef BRIDGE
  15.   #define SRV_CLIENTNETFUNCS    12
  16. #endif
  17.  
  18. typedef long (CDECL *LGFARPROC)();
  19.  
  20. typedef struct srv_handler {
  21.     
  22.   struct srv_handler * previous;
  23.   struct srv_handler * next;
  24.   struct srv_handler * last;
  25.   int (* handler)(void *);
  26.  
  27. } SRV_HANDLER;
  28.  
  29. typedef struct srv_pevents {        
  30.      SRV_HANDLER * srv_attention;
  31.      SRV_HANDLER * srv_connect;
  32.      SRV_HANDLER * srv_disconnect;
  33.      SRV_HANDLER * srv_rpc;
  34.      SRV_HANDLER * srv_language;
  35.      SRV_HANDLER * srv_start;
  36.      SRV_HANDLER * srv_stop;
  37.      SRV_HANDLER * srv_sleep;
  38.      SRV_HANDLER * srv_restart;
  39.      SRV_HANDLER * srv_transmgr;
  40.      SRV_HANDLER * srv_oledb;
  41. } SRV_PEVENTS;
  42.  
  43. typedef struct srv_events {
  44.     int (*srv_hndl_attention)(void *);  // ( SRV_PROC   * )
  45.     int (*srv_hndl_connect)(void *);    // ( SRV_PROC   * )
  46.     int (*srv_hndl_disconnect)(void *); // ( SRV_PROC   * )
  47.     int (*srv_hndl_restart)(void *);    // ( SRV_SERVER * )
  48.     int (*srv_hndl_rpc)(void *);        // ( SRV_PROC   * )
  49.     int (*srv_hndl_sleep)(void *);      // ( SRV_SERVER * )
  50.     int (*srv_hndl_language)(void *);   // ( SRV_PROC   * )
  51.     int (*srv_hndl_start)(void *);      // ( SRV_SERVER * )
  52.     int (*srv_hndl_stop)(void *);    // ( SRV_SERVER * )
  53.     int (*srv_hndl_attention_ack)(void *);  // ( SRV_PROC * )
  54.     int (*srv_hndl_transmgr)(void *);    // ( SRV_PROC * )
  55.     int (*srv_hndl_insertexec)(void *);    // ( SRV_PROC * )
  56.     int (*srv_hndl_oledb)(void *);    // ( SRV_PROC * )
  57. } SRV_EVENTS;
  58.  
  59. typedef struct srv_subchannel {
  60.     struct srv_proc * srvproc;
  61.    HANDLE threadHDL;
  62.    THREAD threadID;
  63.     HANDLE ss_handle;
  64.     HANDLE cs_handle;
  65.     HANDLE hEvent;
  66.     BOOL status;
  67.     struct srv_proc * site_srvproc;
  68.     DWORD index;
  69.     struct srv_proc ** master_list;
  70. } SRV_SUBCHANNEL;
  71.  
  72. //
  73. // define structures
  74. //
  75.  
  76. typedef struct translation_info
  77. {
  78.     BOOL flag;                      // data translation flag
  79.     void (*int2)(short*);           // 2-byte integer swap function
  80.     void (*int4)(long*);            // 4-byte integer swap function
  81.     void (*recvflt)(float*);        // receive 8-byte float translation function
  82.     void (*sendflt)(float*);        // send 8-byte float translation function
  83.     void (*recvflt4)(float*);       // receive 4-byte float translation function
  84.     void (*sendflt4)(float*);       // send 4-byte float translation function
  85.     void (*recvchar)(char *, int);  // ASCII translation function
  86.     void (*sendchar)(char *, int);  // ASCII translation function
  87.     void (*twoint4)(char *);        // 2 4-byte integer swap function
  88.     void (*twoint2)(char *);        // 2 2-byte interger swap function
  89. } TRANSLATION_INFO;
  90.  
  91.  
  92. typedef struct srv_params
  93. {
  94.     struct srv_server    * server;
  95.     struct srv_proc      * srvproc;
  96.     struct srv_queuehead * queuehead;
  97.     struct srv_comport     * comport;
  98.     THREAD                 threadID;
  99.     HANDLE                 threadHDL;
  100. } SRV_PARAMS;
  101.  
  102. #if defined( _MSSQLRISC_)
  103.   #pragma pack(2)
  104. #endif
  105.  
  106. //  SRV_LOGIN
  107. //     The (TDS 4.0) login record received from the server client at login time.
  108. //
  109.  
  110. typedef struct srv_loginrec {
  111.     BYTE lhostname[SRV_MAXNAME];    // name of host or generic
  112.     BYTE lhostnlen;         // length of lhostname
  113.     BYTE lusername[SRV_MAXNAME];    // name of user
  114.     BYTE lusernlen;         // length of lusername
  115.     BYTE lpw[SRV_MAXNAME];  // password (plaintext)
  116.     BYTE lpwnlen;           // length of lpw
  117.     BYTE lhostproc[SRV_HOSTIDLEN];     // host process identification
  118.     BYTE lunused[SRV_MAXNAME-SRV_HOSTIDLEN - 6];     // unused
  119.     BYTE lapptype [6];        // Application specific.
  120.     BYTE lhplen;            // length of host process id
  121.     BYTE lint2;             // type of int2 on this host
  122.     BYTE lint4;             // type of int4 on this host
  123.     BYTE lchar;             // type of char
  124.     BYTE lflt;              // type of float
  125.     BYTE ldate;             // type of datetime
  126.     BYTE lusedb;            // notify on exec of use db cmd
  127.     BYTE ldmpld;            // disallow use of dump/load and bulk insert
  128.     BYTE linterface;        // SQL interface type
  129.     BYTE ltype;             // type of network connection
  130.     BYTE spare[7];          // NOTE: Apparently used by System-10
  131.     BYTE lappname[SRV_MAXNAME]; // application name
  132.     BYTE lappnlen;          // length of appl name
  133.     BYTE lservname[SRV_MAXNAME];    // name of server
  134.     BYTE lservnlen;         // length of lservname
  135.     BYTE lrempw[0xff];      // passwords for remote servers
  136.     BYTE lrempwlen;         // length of lrempw
  137.     BYTE ltds[4];           // tds version
  138.     BYTE lprogname[DBPROGNLEN]; // client program name
  139.     BYTE lprognlen;         // length of client program name
  140.     BYTE lprogvers[4];      // client program version
  141.     BYTE lnoshort;          // NEW: auto convert of short datatypes
  142.     BYTE lflt4;             // NEW: type of flt4 on this host
  143.     BYTE ldate4;            // NEW: type of date4 on this host
  144.     BYTE llanguage[SRV_MAXNAME];    // NEW: initial language
  145.     BYTE llanglen;          // NEW: length of language
  146.     BYTE lsetlang;          // NEW: notify on language change
  147.     short slhier;           // NEW: security label hierarchy
  148.     BYTE slcomp[8];         // NEW: security components
  149.     short slspare;          // NEW: security label spare
  150.     BYTE slrole;            // NEW: security login role
  151.     BYTE lcharset[SRV_MAXNAME]; // character set name (unused)
  152.     BYTE lcharsetlen;       // length of character set (unused)
  153.     BYTE lsetcharset;       // notify on character set change (unused)
  154.     BYTE lpacketsize[SRV_PKTLEN]; // length of TDS packets
  155.     BYTE lpacketsizelen;    // length of lpacketsize
  156.     BYTE ldummy[3];         // NEW: pad to longword
  157.  
  158. } SRV_LOGINREC;
  159.  
  160. //
  161. //  SRV_LOGIN_OLDTDS
  162. //     The login record received from "old" TDS 2.0 or 3.4 server clients.
  163. //     The format is basically the same as 4.0, it is just shorter (no server
  164. //     name or password, etc appended at the end).
  165. //
  166. typedef struct srv_login_oldtds {
  167.     BYTE lhostname[SRV_MAXNAME];    // name of host or generic
  168.     BYTE lhostnlen;         // length of lhostname
  169.     BYTE lusername[SRV_MAXNAME];    // name of user
  170.     BYTE lusernlen;         // length of lusername
  171.     BYTE lpw[SRV_MAXNAME];  // password (plaintext)
  172.     BYTE lpwnlen;           // length of lpw
  173.     BYTE lhostproc[SRV_MAXNAME];    // host process identification
  174.     BYTE lhplen;            // length of host process id
  175.     BYTE lint2;             // type of int2 on this host
  176.     BYTE lint4;             // type of int4 on this host
  177.     BYTE lchar;             // type of char
  178.     BYTE lflt;              // type of float
  179.     BYTE ldate;             // type of datetime
  180.     BYTE lusedb;            // notify on exec of use db cmd
  181.     BYTE ldmpld;            // disallow use of dump/load and bulk insert
  182.     BYTE linterface;        // SQL interface type
  183.     BYTE spare[8];          // spare fields
  184.     BYTE lappname[SRV_MAXNAME]; // application name
  185.     BYTE lappnlen;          // length of appl name
  186.     BYTE ldummy;         // pad length to even boundary
  187.  
  188. } SRV_LOGIN_OLDTDS;
  189. #if defined( _MSSQLRISC_)
  190.   #pragma pack()
  191. #endif
  192.  
  193. // Define structure for ODS statistics
  194.  
  195. typedef struct srv_stats {
  196.     int NumReads;
  197.     int NumWrites;
  198. } SRV_STATS;
  199.  
  200.  
  201.  
  202. // Define list elements used in queuing
  203. // network request.
  204.  
  205. typedef struct srv_queuehead {
  206.     struct srv_queuehead * Flink;
  207.     struct srv_queuehead * Blink;
  208.     struct srv_listhead  * ListHead;
  209. } SRV_QUEUEHEAD, *PSRV_QUEUEHEAD;
  210.  
  211.  
  212. typedef struct srv_listhead {
  213.     struct srv_listentry * Flink;
  214.     struct srv_listentry * Blink;
  215.     int    NumListEntries;
  216.     int    NumReadRequest;
  217.     int    MaxQueueLength;
  218.     long   ListLock;
  219.     HANDLE ListEvent;
  220. } SRV_LISTHEAD, *PSRV_LISTHEAD;
  221.  
  222. typedef struct srv_listentry {
  223.     struct srv_listentry * Flink;
  224.     struct srv_listentry * Blink;
  225.     struct srv_proc      * pSrvProc;
  226. } SRV_LISTENTRY, *PSRV_LISTENTRY;
  227.  
  228. // Define routines to manage list entries.
  229.  
  230. //
  231. //  VOID
  232. //  InitializeListHead(
  233. //  PSRV_LISTENTRY ListHead
  234. //      );
  235. //
  236.  
  237. #define InitializeListHead(TYPE, ListHead) (\
  238.     (ListHead)->Flink = (ListHead)->Blink = (TYPE)(ListHead))
  239.  
  240. //
  241. //  BOOLEAN
  242. //  IsListEmpty(
  243. //  PSRV_LISTENTRY ListHead
  244. //      );
  245. //
  246.  
  247. #define IsListEmpty(ListHead) (\
  248.     ( ((ListHead)->Flink == (ListHead)) ? TRUE : FALSE ) )
  249.  
  250. //
  251. //  SRV_LISTENTRY
  252. //  RemoveHeadList(
  253. //  TYPE,
  254. //  TYPE ListHead
  255. //      );
  256. //
  257.  
  258. #define RemoveHeadList(TYPE,ListHead) \
  259.     (TYPE)(ListHead)->Flink;\
  260.     {\
  261.     TYPE FirstEntry;\
  262.         FirstEntry = (ListHead)->Flink;\
  263.     FirstEntry->Flink->Blink = (TYPE)(ListHead);\
  264.         (ListHead)->Flink = FirstEntry->Flink;\
  265.     }
  266.  
  267. //
  268. //  VOID
  269. //  RemoveEntryList(
  270. //  PSRV_LISTENTRY Entry
  271. //      );
  272. //
  273.  
  274. #define RemoveEntryList(Entry) {\
  275.     PSRV_LISTENTRY _EX_Entry;\
  276.         _EX_Entry = (Entry);\
  277.         _EX_Entry->Blink->Flink = _EX_Entry->Flink;\
  278.         _EX_Entry->Flink->Blink = _EX_Entry->Blink;\
  279.     }
  280.  
  281. //
  282. //  VOID
  283. //  InsertTailList(
  284. //  PSRV_LISTHEAD  ListHead,
  285. //  PSRV_LISTENTRY Entry
  286. //      );
  287. //
  288.  
  289. #define InsertTailList(ListHead,Entry) \
  290.     (Entry)->Flink = (ListHead);\
  291.     (Entry)->Blink = (ListHead)->Blink;\
  292.     (ListHead)->Blink->Flink = (Entry);\
  293.     (ListHead)->Blink = (Entry);\
  294.     InterlockedIncrement(&(ListHead)->NumListEntries);
  295.  
  296. //
  297. //  VOID
  298. //  InsertHeadList(
  299. //  PSRV_LISTHEAD  ListHead,
  300. //  PSRV_LISTENTRY Entry
  301. //      );
  302. //
  303.  
  304. #define InsertHeadList(ListHead,Entry) \
  305.     (Entry)->Flink = (ListHead)->Flink;\
  306.     (Entry)->Blink = (ListHead);\
  307.     (ListHead)->Flink->Blink = (Entry);\
  308.     (ListHead)->Flink = (Entry);\
  309.     InterlockedIncrement(&(ListHead)->NumListEntries);
  310.  
  311. //
  312. //  VOID
  313. //  InsertHeadQueue(
  314. //  PSRV_QUEUEHEAD  ListHead,
  315. //  PSRV_QUEUEHEAD  Entry
  316. //      );
  317. //
  318.  
  319. #define InsertHeadQueue(ListHead,Entry) \
  320.     (Entry)->Flink = (ListHead)->Flink;\
  321.     (Entry)->Blink = (ListHead);\
  322.     (ListHead)->Flink->Blink = (Entry);\
  323.     (ListHead)->Flink = (Entry);
  324.  
  325. //
  326. //  VOID
  327. //  InsertTailQueue(
  328. //  PSRV_QUEUEHEAD  ListHead,
  329. //  PSRV_QUEUEHEAD  Entry
  330. //      );
  331. //
  332.  
  333. #define InsertTailQueue(ListHead,Entry) \
  334.     (Entry)->Flink = (ListHead);\
  335.     (Entry)->Blink = (ListHead)->Blink;\
  336.     (ListHead)->Blink->Flink = (Entry);\
  337.     (ListHead)->Blink = (Entry);
  338.  
  339. //
  340. //  VOID
  341. //  RemoveEntryQueue(
  342. //  PSRV_QUEUEHEAD Entry
  343. //      );
  344. //
  345.  
  346. #define RemoveEntryQueue(Entry) {\
  347.     PSRV_QUEUEHEAD _EX_Entry;\
  348.         _EX_Entry = (Entry);\
  349.         _EX_Entry->Blink->Flink = _EX_Entry->Flink;\
  350.         _EX_Entry->Flink->Blink = _EX_Entry->Blink;\
  351.     }
  352.  
  353.  
  354. // Configuration structure.
  355.  
  356. typedef struct srv_config {
  357.     unsigned  connections;          // maximum allowed client connections
  358.     unsigned  stacksize;            // stack size of new threads created
  359.     BOOL      log_file_open;        // flag indicating log file open
  360.     HANDLE    log_handle;           // handle of openned log file
  361.     char      log_file_name[SRV_MAXFILENAME];    // name of log file
  362.     BOOL      print_recv;           // dump reads to screen
  363.     BOOL      print_send;           // dump sends to screen
  364.     BOOL      remote_access;        // flag indicating remote server access
  365.     unsigned  max_remote_sites;     // simultaneous remote sites accessing
  366.     unsigned  max_remote_connections;   // maximum allowed in/out remote connections
  367.     WORD      numConnectsPerThread; // Number of connections to monitor per network thread
  368.     WORD      MaxWorkingThreads;    // Max number of working threads
  369.     WORD      MinWorkingThreads;    // Min Number of working threads
  370.     WORD      ConcurrentThreads;    // Min Number of working threads
  371.     DWORD     WorkingThreadTimeout; // Time to wait before exiting when idle
  372.     unsigned  max_packets;          // maximum number of network packets buffered
  373.     //
  374.     // Multi Server Side Net-Library support
  375.     //
  376.     WORD      numNetLibs;
  377.     WORD      spare;
  378.     LGFARPROC SSNetLibs[MAX_NETLIBS][SRV_SERVNETFUNCS];         // NetLib Function ptrs
  379.     HANDLE    SSModules[MAX_NETLIBS];                           // NetLib Module handles
  380.     char      connect_names[MAX_NETLIBS][SRV_MAXFILENAME];      // NetLib connection names
  381.     char      connect_dlls[MAX_NETLIBS][SRV_MAXFILENAME];       // NetLib names
  382.     char      connect_versions[MAX_NETLIBS][SRV_MAXFILENAME];   // NetLib versions
  383.     char      server_name[SRV_MAXFILENAME]; // Server name
  384.     BOOL      local_only;           // flag indicating local access only
  385.     BOOL      unpack_rpc;           // flag indicating if RPCs should be unpacked
  386.     unsigned  max_packetsize;       // maximum network packet size
  387.     unsigned  dflt_packetsize;        // The default packet size.
  388.  
  389.     int       ThreadPriority;  // Priority of thread in class.
  390.     BOOL ansi;    // flag indicating if ANSI codepage is used
  391.     BYTE      tdsversion[4];
  392.     BYTE      progversion[4];
  393.     DWORD     threadaffinity;            // thread affinity option
  394. #ifdef BRIDGE
  395.     HANDLE      CSModule;                       // Client NetLib Module handle
  396.     LGFARPROC   CSNetLib[SRV_CLIENTNETFUNCS];   // NetLib Function ptrs
  397.     char        client_name[SRV_MAXFILENAME];   // Client side name
  398.     BOOL        bAuditConnects;                 // flag indicating if connects should be logged
  399. #endif
  400. } SRV_CONFIG;
  401.  
  402. //
  403. //  SRV_TDSHDR
  404. //  The first 8 bytes of each network packet constitute the packet
  405. //  header.
  406. //
  407. typedef struct srv_tdshdr {
  408.     BYTE        type;       // io packet type
  409.     BYTE        status;     // io packet status
  410.     DBUSMALLINT length;     // io packet length
  411.     DBUSMALLINT channel;    // io packet subchannel
  412.     BYTE        packet;     // io packet number
  413.     BYTE        window;     // io packet window size
  414.  
  415. } SRV_TDSHDR;
  416.  
  417. //  SRV_INPUTBUF
  418. //  This structure maintains the read information when
  419. //  pre-reading packets.
  420. //
  421.  
  422. typedef struct srv_inputbuf {
  423.     BYTE * pBuffer;
  424.     DWORD  ioStatus;
  425.     DWORD  ioRecvCnt;
  426.     struct srv_inputbuf * pNext;
  427. } SRV_INPUTBUF;
  428.  
  429. // SRV_COMPORT_QUEUE
  430. // Queue entry for completion port requests.
  431. //
  432. typedef struct srv_comport_queue
  433. {
  434.     struct srv_comport_queue*    Flink;
  435.     struct srv_comport_queue*    Blink;
  436. } SRV_COMPORT_QUEUE;
  437.  
  438. // SRV_COMPORT_BUF
  439. //    Description of a buffer passed through the srv_post_completion_queue
  440. //  entry point. These buffers are typically posted by the server to
  441. //    perform work on a worker thread that can't be handled by the currently
  442. //    executing thread.
  443. //
  444. typedef struct srv_comportbuf 
  445. {
  446.     SRV_COMPORT_QUEUE    queue;
  447.  
  448.     // Overlapped structure passed through srv_post_completion_queue
  449.     // overlapped.Offset contains the address of this structure such that
  450.     // 
  451.     OVERLAPPED    overlapped;
  452.     DWORD        message_size;
  453.     BYTE        message [1];
  454. } SRV_COMPORT_BUF;
  455.  
  456. // WARNING! There is code that assumes it can get to the "last" input
  457. // buffer by looking at the current->pNext buffer. (i.e. It assumes
  458. // SRV_NUMINPUTBUFS == 2).
  459. //
  460. #define SRV_NUMINPUTBUFS 2
  461.  
  462. //
  463. //  SRV_IO
  464. //  This is the data structure used for reading and writing client
  465. //  connection data for a particular server task.
  466. //
  467. typedef struct srv_io {
  468.     void * server_ep;       // server side endpoint
  469. #ifdef BRIDGE
  470.     void * client_ep;       // client side endpoint
  471.     BOOL       fCSerror;        // flag indicate client-side error
  472. #endif
  473.     HANDLE      cs_sub_handle;  // client-side subchannel local handle
  474.     BYTE  * outbuff;        // send: start of send buffer
  475.     BYTE  * p_outbuff;      // send: next place in buffer
  476.     WORD        n_outbuff;      // send: room left in send buffer
  477.     BYTE  * inbuff;         // recv: start of read buffer
  478.     BYTE  * p_inbuff;       // recv: next place in buffer
  479.     WORD        n_inbuff;       // recv: room left in read buffer
  480.     int         SQLspanned;     // flag indicating that the SQL command
  481.                                 //  has spanned more that 1 network buffer.
  482.     int cbflag;                      // flag indicating that a client buffer is
  483.                                 //  available.
  484.     DBUSMALLINT channel;        // io packet subchannel
  485.     BYTE        packet;         // io packet number
  486.     BYTE        window;         // io packet window size
  487.     HANDLE      ioEvent;        // io event handle
  488.     OVERLAPPED  ioOverlapped;   // io overlapped structure.
  489.     SRV_INPUTBUF * pNextInBuf;  // current io input buffer index
  490.     SRV_INPUTBUF   ioInputBuffers[SRV_NUMINPUTBUFS]; // io input buffers
  491.     HANDLE      ss_sub_handle;  // server-side subchannel local handle
  492.     WORD packetsize;        // TDS packet size
  493. } SRV_IO;
  494.  
  495. //
  496. //  SRV_COLDESC: column description array (used by srv_describe & srv_sendrow)
  497. //
  498. typedef struct srv_coldesc {
  499.     unsigned long otype;        // output data type
  500.     unsigned long olen;         // length
  501.     unsigned long itype;        // input data type
  502.     unsigned long ilen;         // length
  503.     BYTE    *data;        // data buffer address
  504.     DBINT    user_type;        // user-defined data type
  505.     BYTE     precision;     // precision
  506.     BYTE     scale;        // scale
  507. } SRV_COLDESC;
  508.  
  509. //
  510. //  SRV_RPCp: RPC parameter information
  511. //
  512. typedef struct srv_rpcp {
  513.     BYTE          len;          // length of RPC parameter name
  514.     BYTE    * rpc_name;     // pointer to the RPC parameter name
  515.     BYTE          status;       // return status, 1 = passed by reference
  516.     unsigned long user_type;    // User-defined data type
  517.     BYTE          type;         // data type
  518.     unsigned long maxlen;       // maximum possible data length
  519.     unsigned long actual_len;   // actual data length
  520.     void    * value;        // the actual data
  521. } SRV_RPCp;
  522.  
  523. typedef struct srv_comport {
  524.     HANDLE hdl;
  525.     DWORD  cpu;
  526. } SRV_COMPORT;
  527.  
  528. //
  529. //  SRV_PROC:   This is the main connection structure
  530. //
  531. typedef struct srv_proc {
  532.     WORD         tdsversion;    // version of tds detected from client
  533.                                 //   0x3400 = 3.4, 0x4000 = 4.0
  534.     WORD         status;        // status of this SRV_PROC
  535.     SRV_IO       srvio;         // I/O structure of srvproc
  536.     SRV_LOGINREC login;         // login record received from the client
  537.     void   * langbuff;      // pointer to language buffer
  538.     unsigned long langlen;       // length of language buffer
  539.     unsigned int event;         // event variable
  540.     void   * server;        // pointer to associated SRV_SERVER structure
  541.     char   * threadstack;   // stack pointer of event thread stack
  542.     THREAD       threadID;      // thead ID associated with this SRV_PROC
  543.     HANDLE       threadHDL;     // thread handle for resume and suspend
  544.     HANDLE       iowakeup;      // event handle to wait on for overlapped io
  545.                                 // and more. Passed on to SQL Server and netlibs.
  546.     HANDLE       exited;        // semaphore indicating that thread
  547.                                 //  associated with this SRV_PROC has exited
  548.     DBINT        rowsent;       // # of rows sent to client
  549.     SRV_COLDESC * coldescp; // pointer to column description array
  550.     DBUSMALLINT  coldescno;     // count of column descriptions
  551.     BYTE   * colnamep;      // pointer to column name list
  552.     WORD         colnamelen;    // length of column name list
  553.     void  * userdata;      // pointer to user's private data area
  554.     void   * event_data;    // pointer to event data area
  555.  
  556.     BYTE         serverlen;     // length of server name
  557.     BYTE   * servername;    // name of server
  558.     //
  559.     //  RPC info
  560.     //
  561.     BYTE         rpc_active;        // flag indicating active RPC (TRUE=active)
  562.     BYTE         rpc_server_len;    // length of RPC server name
  563.     BYTE   * rpc_server;        // name of RPC server
  564.     BYTE         rpc_database_len;  // length of RPC database name
  565.     BYTE   * rpc_database;      // name of RPC database
  566.     BYTE         rpc_owner_len;     // length of RPC owner name
  567.     BYTE   * rpc_owner;         // name of RPC owner
  568.     BYTE         rpc_proc_len;      // length of RPC or stored procecedure name
  569.     BYTE   * rpc_proc_name;     // name of RPC or stored procedure
  570.     unsigned int rpc_proc_number;   // number of RPC "procedure_name;number"
  571.     unsigned int rpc_linenumber;    // line number batch error occurred on.
  572.     unsigned short rpc_options;     // recompile option flag (bit 0)
  573.     unsigned short rpc_num_params;  // number of RPC parameters
  574.     SRV_RPCp * * rpc_params;// array of pointers to each RPC paramater
  575.     //
  576.     // Return information for non-remote procedure call client command.
  577.     // This information is provided by the function srv_returnval().
  578.     // flag indicating active non-RPC values (TRUE = active)
  579.     BYTE         non_rpc_active;
  580.     // number of non-RPC parameters
  581.     //
  582.     unsigned short non_rpc_num_params;
  583.  
  584.     // array of pointers to each non-RPC paramater
  585.     //
  586.     SRV_RPCp * * non_rpc_params;
  587.     //
  588.     // temporary work buffer
  589.     //
  590.     char         temp_buffer[100];
  591.  
  592.      // array of subchannel structures
  593.      //
  594.     SRV_SUBCHANNEL * (*subprocs);
  595.  
  596.     // Data Translation information
  597.     //
  598.     TRANSLATION_INFO     translation_info;
  599.     struct srv_listentry IOListEntry;
  600.     struct srv_listentry CommandListEntry;
  601.     PSRV_LISTHEAD        pNetListHead;
  602.     BOOL                 bNewPacket;
  603.     long       StatusCrit;     // critical section to check attentions
  604.     void           * serverdata;    // private data area used ONLY by SQL Server
  605.     SRV_SUBCHANNEL * subchannel;
  606.  
  607.     // Pre && Post Handler pointers
  608.     SRV_PEVENTS * pre_events;
  609.     SRV_PEVENTS * post_events;
  610.  
  611.     // current position in language buffer used by processRPC
  612.     // 
  613.     void * p_langbuff;    
  614.  
  615.     BOOL    fSecureLogin;
  616.  
  617.     // Set by the server when making an outbound call to an XP.
  618.     //
  619.     BOOL    fInExtendedProc;
  620.  
  621.     // If TRUE indicates the current buffer is from
  622.     // srv_post_completion_queue and the buffer should be
  623.     // deallocated when the current work is completed.  If
  624.     // FALSE the current buffer came from the network and a
  625.     // new read should be posted on the net.
  626.     //
  627.     unsigned    fLocalPost:1;
  628.  
  629.     // If TRUE an XP associated with this srvproc made a call back into
  630.     // the server on a bound connection. This flag is used to allow the
  631.     // calling session to wait for logout processing of the XP to complete
  632.     //
  633.     unsigned    fMadeBoundCall:1;
  634.  
  635.     // Filler to align after flags above.
  636.     //
  637.     unsigned    uFill1:30;
  638.  
  639.     // List of requests posted using srv_post_completion_queue. Entries are
  640.     // dynamically allocated inside srv_post_completion_queue and enqueued
  641.     // in netIOCompletionRoutine. After the request has been processed the
  642.     // entry is removed from this queue and deallocated.
  643.     //
  644.     // NOTE: Must hold SRV_PROC spinlock while altering queue.
  645.     //
  646.     SRV_COMPORT_QUEUE    comport_queue;
  647. } SRV_PROC;
  648.  
  649. typedef struct srv_control {
  650.     unsigned int status;            // status of process
  651.     unsigned int connects;          // current number of connections
  652.     SRV_PROC * (* srvprocs);// array of SRV_PROC connection structures
  653.     // semaphore indicating that the connects counter is being accessed or
  654.     // modified
  655.     //
  656.     HANDLE connects_sem;
  657.     //
  658.     //
  659.     // semaphore indicating that thread has started
  660.     //
  661.     HANDLE start_sem;
  662.     //
  663.     // semaphore indicating that some event has occurred
  664.     //
  665.     HANDLE event_sem;
  666.     //
  667.     // semaphore indicating that log file is being written to
  668.     //
  669.     HANDLE log_sem;
  670.     // shutdown critical section
  671.     //
  672.     long ShutDownCrit;
  673.  
  674.     // Network list critical section
  675.     //
  676.     long NetQueueCrit;
  677.  
  678.     // Thread Pool critical section
  679.     //
  680.     long ThreadPoolCrit;
  681.  
  682.     // print screen critical section
  683.     //
  684.     long ScrnPrnt;
  685.  
  686.      unsigned int remote_sites;     // current number of remote sites connected
  687.      unsigned int remote_connects;  // current number of in/out remote connections
  688.      // semaphore indicating that the remote sites counter is being accessed or
  689.      // modified
  690.      //
  691.     HANDLE remote_sites_sem;
  692.  
  693.      // semaphore indicating that the remote connections counter is being accessed or
  694.      // modified
  695.      //
  696.     HANDLE remote_connects_sem;
  697.  
  698.     HANDLE pre_post_sem;
  699.  
  700.     //
  701.     // network request queue list
  702.     //
  703.     SRV_QUEUEHEAD netQueueList;
  704.     int           numNetQueueEntries;
  705.     int           maxNetQueueEntries;
  706.  
  707.     //
  708.     // command queue list
  709.     //
  710.  
  711.     PSRV_LISTHEAD CommandQueueHead;
  712.  
  713.     // Server statistics.
  714.     //
  715.     SRV_STATS   Stats;
  716.  
  717.     DWORD * pSharedCounter;
  718.  
  719.     HANDLE srvproc_mutex;
  720.  
  721.     DWORD  dwWorkingThreadCnt;
  722.     DWORD  maxWorkingThreadCnt;
  723.  
  724.     SRV_COMPORT *comport;
  725.     BYTE   num_comports;
  726.  
  727.     BYTE   ProcessorCnt;
  728.  
  729. } SRV_CONTROL;
  730.  
  731. typedef struct srv_server {
  732.     LGFARPROC  SSNetLib[SRV_SERVNETFUNCS];  // Server Side NetLib functions
  733.     HANDLE     SSModule;                    // Server Side DLL
  734.     DWORD      ep_size;
  735.     void * listen_ep;
  736. #ifdef BRIDGE
  737.     LGFARPROC CSNetLib[SRV_CLIENTNETFUNCS]; // Client Side NetLib functions
  738.     HANDLE    CSModule;                     // Client Side DLL
  739.     char      client_name[SRV_MAXFILENAME];
  740. #endif
  741.     THREAD net_threadID;        // thead ID of client network event thread
  742.     HANDLE net_threadHDL;       // thread handle for resume and suspend
  743.  
  744.     //
  745.     // connection information
  746.     //
  747.     char connect_name[SRV_MAXFILENAME];
  748.     char connect_dll[SRV_MAXFILENAME];
  749.     char connect_version[SRV_MAXFILENAME];
  750.  
  751.     //
  752.     // temporary work buffer
  753.     //
  754.     char temp_buffer[100];
  755.     //
  756.     // server configuration information
  757.     //
  758.     SRV_CONFIG config;
  759.     // server control information
  760.     //
  761.     SRV_CONTROL * control;
  762.  
  763.     // define the event handlers
  764.     //
  765.     SRV_EVENTS * events;
  766.  
  767.     // Pre && Post Handler pointers
  768.     SRV_PEVENTS * pre_events;
  769.     SRV_PEVENTS * post_events;
  770.  
  771. } SRV_SERVER;
  772.  
  773. // Private structure used to export server entry points as ODS callbacks
  774. // for SQLServer use only.
  775. //
  776. typedef struct ods_callbacks
  777. {
  778.     int (*sql_getbindtoken) (void*, char*);
  779.     void (*sql_getdtcxact) (void*, void**);
  780.  
  781.     // Place new callbacks at the end of the structure.
  782.  
  783. } ODS_CALLBACKS;
  784.