home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / xa.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  8KB  |  170 lines

  1. /* -----------------------------------------------------------------
  2.  * Microsoft Distributed Transaction Coordinator
  3.  * Microsoft Corporation, 1995.
  4.  *
  5.  * File : xa.h 
  6.  * 
  7.  * Contents : This file is derived from xa.h as it appears in 
  8.  * "Distributed Transaction Processing: The XA Specification", 
  9.  * November 93, X/Open Company Limited.
  10.  *
  11.  */
  12.  
  13. /*
  14.  * Start of xa.h header
  15.  *
  16.  * Define a symbol to prevent multiple inclusion of this header file
  17.  */
  18.  
  19. #ifndef XA_H
  20. #define XA_H
  21. /*
  22.  * Transaction branch identification: XID and NULLXID:
  23.  */
  24. #define XIDDATASIZE        128            /* size in bytes */
  25. #define MAXGTRIDSIZE    64          /* maximum size in bytes of gtrid */
  26. #define MAXBQUALSIZE    64          /* maximum size in bytes of bqual */
  27.  
  28. #ifndef _XID_T_DEFINED
  29. #define _XID_T_DEFINED
  30. struct xid_t
  31. {
  32.     long formatID;                    /* format identifier */
  33.     long gtrid_length;                /* value not to exceed 64 */
  34.     long bqual_length;                /* value not to exceed 64 */
  35.     char data[XIDDATASIZE];
  36. };
  37. #endif
  38.  
  39. typedef struct xid_t XID;
  40. /*
  41.  * A value of -1 in formatID means that the XID is null.
  42.  */
  43. /*
  44.  * Declarations of routines by which RMs call TMs:
  45.  */
  46. #ifdef _TMPROTOTYPES
  47. extern int __cdecl ax_reg(int, XID *, long);
  48. extern int __cdecl ax_unreg(int, long);
  49. #else /* ifndef _TMPROTOTYPES */
  50. extern int __cdecl ax_reg();
  51. extern int __cdecl ax_unreg();
  52. #endif /* ifndef _TMPROTOTYPES */
  53. /*
  54.  * XA Switch Data Structure
  55.  */
  56. #define RMNAMESZ    32                                    /* length of resource manager name, */
  57.                                                         /* including the null terminator */
  58. #define MAXINFOSIZE 256                                    /* maximum size in bytes of xa_info strings, */
  59.                                                         /* including the null terminator */
  60.  
  61. #ifndef _XA_SWITCH_T_DEFINED
  62. #define _XA_SWITCH_T_DEFINED
  63. struct xa_switch_t
  64. {
  65.   char name[RMNAMESZ];                                    /* name of resource manager */
  66.   long flags;                                            /* resource manager specific options */
  67.   long version;                                            /* must be 0 */
  68.   int (__cdecl *xa_open_entry)(char *, int, long);        /* xa_open function pointer */
  69.   int (__cdecl *xa_close_entry)(char *, int, long);        /* xa_close function pointer*/
  70.   int (__cdecl *xa_start_entry)(XID *, int, long);        /* xa_start function pointer */
  71.   int (__cdecl *xa_end_entry)(XID *, int, long);        /* xa_end function pointer */
  72.   int (__cdecl *xa_rollback_entry)(XID *, int, long);    /* xa_rollback function pointer */
  73.   int (__cdecl *xa_prepare_entry)(XID *, int, long);    /* xa_prepare function pointer */
  74.   int (__cdecl *xa_commit_entry)(XID *, int, long);        /* xa_commit function pointer */
  75.   int (__cdecl *xa_recover_entry)(XID *, long, int, long);
  76.                                                         /* xa_recover function pointer*/
  77.   int (__cdecl *xa_forget_entry)(XID *, int, long);        /* xa_forget function pointer */
  78.   int (__cdecl *xa_complete_entry)(int *, int *, int, long);
  79.                                                         /* xa_complete function pointer */
  80. };
  81.  
  82. typedef struct xa_switch_t xa_switch_t;
  83. #endif
  84.  
  85. /*
  86.  * Flag definitions for the RM switch
  87.  */
  88. #define TMNOFLAGS        0x00000000L                        /* no resource manager features selected */
  89. #define TMREGISTER        0x00000001L                        /* resource manager dynamically registers */
  90. #define TMNOMIGRATE        0x00000002L                        /* resource manager does not support association migration */
  91. #define TMUSEASYNC        0x00000004L                        /* resource manager supports asynchronous operations */
  92. /*
  93.  * Flag definitions for xa_ and ax_ routines
  94.  */
  95. /* use TMNOFLAGS, defined above, when not specifying other flags */
  96. #define TMASYNC            0x80000000L                        /* perform routine asynchronously */
  97. #define TMONEPHASE        0x40000000L                        /* caller is using one-phase commit optimisation */
  98. #define TMFAIL            0x20000000L                        /* dissociates caller and marks transaction branch rollback-only */
  99. #define TMNOWAIT        0x10000000L                        /* return if blocking condition exists */
  100. #define TMRESUME        0x08000000L                        /* caller is resuming association with suspended transaction branch */
  101. #define TMSUCCESS        0x04000000L                        /* dissociate caller from transaction branch */
  102. #define TMSUSPEND        0x02000000L                        /* caller is suspending, not ending, association */
  103. #define TMSTARTRSCAN    0x01000000L                        /* start a recovery scan */
  104. #define TMENDRSCAN        0x00800000L                        /* end a recovery scan */
  105. #define TMMULTIPLE        0x00400000L                        /* wait for any asynchronous operation */
  106. #define TMJOIN            0x00200000L                        /* caller is joining existing transaction branch */
  107. #define TMMIGRATE        0x00100000L                        /* caller intends to perform migration */
  108. /*
  109.  * ax_() return codes (transaction manager reports to resource manager)
  110.  */
  111. #define TM_JOIN            2                                /* caller is joining existing transaction branch */
  112. #define TM_RESUME        1                                /* caller is resuming association with suspended transaction branch */
  113. #define TM_OK            0                                /* normal execution */
  114. #define TMER_TMERR        (-1)                            /* an error occurred in the transaction manager */
  115. #define TMER_INVAL        (-2)                            /* invalid arguments were given */
  116. #define TMER_PROTO        (-3)                            /* routine invoked in an improper context */
  117. /*
  118.  * xa_() return codes (resource manager reports to transaction manager)
  119.  */
  120. #define XA_RBBASE        100                                /* The inclusive lower bound of the rollback codes */
  121. #define XA_RBROLLBACK    XA_RBBASE                        /* The rollback was caused by an unspecified reason */
  122. #define XA_RBCOMMFAIL    XA_RBBASE+1                        /* The rollback was caused by a communication failure */
  123. #define XA_RBDEADLOCK    XA_RBBASE+2                        /* A deadlock was detected */
  124. #define XA_RBINTEGRITY    XA_RBBASE+3                        /* A condition that violates the integrity of the resources was detected */
  125. #define XA_RBOTHER        XA_RBBASE+4                        /* The resource manager rolled back the transaction branch for a reason not on this list */
  126. #define XA_RBPROTO        XA_RBBASE+5                        /* A protocol error occurred in the resource manager */
  127. #define XA_RBTIMEOUT    XA_RBBASE+6                        /* A transaction branch took too long */
  128. #define XA_RBTRANSIENT    XA_RBBASE+7                        /* May retry the transaction branch */
  129. #define XA_RBEND        XA_RBTRANSIENT                    /* The inclusive upper bound of the rollback codes */
  130.  
  131. #define XA_NOMIGRATE    9                                /* resumption must occur where suspension occurred */
  132. #define XA_HEURHAZ        8                                /* the transaction branch may have been heuristically completed */
  133. #define XA_HEURCOM        7                                /* the transaction branch has been heuristically committed */
  134. #define XA_HEURRB        6                                /* the transaction branch has been heuristically rolled back */
  135. #define XA_HEURMIX        5                                /* the transaction branch has been heuristically committed and rolled back */
  136. #define XA_RETRY        4                                /* routine returned with no effect and may be re-issued */
  137. #define XA_RDONLY        3                                /* the transaction branch was read-only and has been committed */
  138. #define XA_OK            0                                /* normal execution */
  139. #define XAER_ASYNC        (-2)                            /* asynchronous operation already outstanding */
  140. #define XAER_RMERR        (-3)                            /* a resource manager error occurred in the transaction branch */
  141. #define XAER_NOTA        (-4)                            /* the XID is not valid */
  142. #define XAER_INVAL        (-5)                            /* invalid arguments were given */
  143. #define XAER_PROTO        (-6)                            /* routine invoked in an improper context */
  144. #define XAER_RMFAIL        (-7)                            /* resource manager unavailable */
  145. #define XAER_DUPID        (-8)                            /* the XID already exists */
  146. #define XAER_OUTSIDE    (-9)                            /* resource manager doing work outside */
  147.                                                         /* global transaction */
  148. /*
  149.  * XA entry point type definitions:
  150.  */
  151.  
  152. typedef int (__cdecl *XA_OPEN_EPT)(char *, int, long);    /* xa_open entry point */
  153. typedef int (__cdecl *XA_CLOSE_EPT)(char *, int, long);    /* xa_close entry point*/
  154. typedef int (__cdecl *XA_START_EPT)(XID *, int, long);    /* xa_start entry point */
  155. typedef int (__cdecl *XA_END_EPT)(XID *, int, long);    /* xa_end entry point */
  156. typedef int (__cdecl *XA_ROLLBACK_EPT)(XID *, int, long);
  157.                                                         /* xa_rollback entry point */
  158. typedef int (__cdecl *XA_PREPARE_EPT)(XID *, int, long);/* xa_prepare entry point */
  159. typedef int (__cdecl *XA_COMMIT_EPT)(XID *, int, long);    /* xa_commit entry point */
  160. typedef int (__cdecl *XA_RECOVER_EPT)(XID *, long, int, long);
  161.                                                         /* xa_recover entry point*/
  162. typedef int (__cdecl *XA_FORGET_EPT)(XID *, int, long);    /* xa_forget entry point */
  163. typedef int (__cdecl *XA_COMPLETE_EPT)(int *, int *, int, long);
  164.                                                         /* xa_complete entry point */
  165.  
  166. #endif /* ifndef XA_H */
  167. /*
  168.  * End of xa.h header
  169.  */
  170.