XTA: API Reference for C language

lixa_iface.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2019, Christian Ferrari <tiian@users.sourceforge.net>
3  * All rights reserved.
4  *
5  * This file is part of LIXA.
6  *
7  * LIXA is free software: you can redistribute this file and/or modify
8  * it under the terms of the GNU Lesser General Public License version 2.1 as
9  * published by the Free Software Foundation.
10  *
11  * LIXA is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with LIXA. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef LIXA_IFACE_H
20 # define LIXA_IFACE_H
21 
22 
23 
24 #include "xa.h"
25 #include "xta_iface.h"
26 
27 
28 
29 /* save old LIXA_TRACE_MODULE and set a new value */
30 #ifdef LIXA_TRACE_MODULE
31 # define LIXA_TRACE_MODULE_SAVE LIXA_TRACE_MODULE
32 # undef LIXA_TRACE_MODULE
33 #else
34 # undef LIXA_TRACE_MODULE_SAVE
35 #endif /* LIXA_TRACE_MODULE */
36 #define LIXA_TRACE_MODULE LIXA_TRACE_MOD_CLIENT_CONFIG
37 
38 
39 
43 #define LIXA_IFACE_STD 0
44 
47 #define LIXA_IFACE_XTA 1
48 
49 
50 
51 /*
52  * This type is a declaration only statement: the real type is defined inside
53  * XA Resource header file. Here we just need to store a pointer to
54  * a XA Resource inside LIXA interface.
55  */
57 
58 
59 
64 typedef struct lixa_iface_s {
72  int type;
73  union {
77  struct xa_switch_t *std;
81  const struct xta_iface_s *xta;
82  };
87 } lixa_iface_t;
88 
89 
90 
91 #ifdef __cplusplus
92 extern "C" {
93 #endif /* __cplusplus */
94 
95 
96 
101  void lixa_iface_reset(lixa_iface_t *iface);
102 
103 
104 
110  void lixa_iface_set_std(lixa_iface_t *iface, struct xa_switch_t *std);
111 
112 
113 
121  void lixa_iface_set_xta(lixa_iface_t *iface, const struct xta_iface_s *xta,
122  xta_xa_resource_t *context);
123 
124 
125 
131  static inline long lixa_iface_get_flags(const lixa_iface_t *iface) {
132  if (LIXA_IFACE_STD == iface->type)
133  return iface->std->flags;
134  else
135  return iface->xta->flags;
136  }
137 
138 
139 
145  static inline const char *lixa_iface_get_name(const lixa_iface_t *iface) {
146  if (LIXA_IFACE_STD == iface->type)
147  return iface->std->name;
148  else
149  return iface->xta->name;
150  }
151 
152 
153 
163  static inline int lixa_iface_xa_open(lixa_iface_t *iface, char *info,
164  int rmid, long flags) {
165  if (LIXA_IFACE_STD == iface->type)
166  return iface->std->xa_open_entry(info, rmid, flags);
167  else
168  return iface->xta->xa_open_entry(iface->context, info,
169  rmid, flags);
170  }
171 
172 
173 
183  static inline int lixa_iface_xa_close(lixa_iface_t *iface, char *info,
184  int rmid, long flags) {
185  if (LIXA_IFACE_STD == iface->type)
186  return iface->std->xa_close_entry(info, rmid, flags);
187  else
188  return iface->xta->xa_close_entry(iface->context, info,
189  rmid, flags);
190  }
191 
192 
193 
203  static inline int lixa_iface_xa_start(lixa_iface_t *iface, const XID *xid,
204  int rmid, long flags) {
205  if (LIXA_IFACE_STD == iface->type)
206  return iface->std->xa_start_entry((XID *)xid, rmid, flags);
207  else
208  return iface->xta->xa_start_entry(iface->context, xid,
209  rmid, flags);
210  }
211 
212 
213 
223  static inline int lixa_iface_xa_commit(lixa_iface_t *iface,
224  const XID *xid, int rmid, long flags) {
225  if (LIXA_IFACE_STD == iface->type)
226  return iface->std->xa_commit_entry((XID *)xid,rmid,flags);
227  else
228  return iface->xta->xa_commit_entry(
229  iface->context, xid, rmid, flags);
230  }
231 
232 
233 
243  static inline int lixa_iface_xa_rollback(lixa_iface_t *iface,
244  const XID *xid, int rmid,
245  long flags) {
246  if (LIXA_IFACE_STD == iface->type)
247  return iface->std->xa_rollback_entry((XID *)xid, rmid, flags);
248  else
249  return iface->xta->xa_rollback_entry(
250  iface->context, xid, rmid, flags);
251  }
252 
253 
254 
267  static inline int lixa_iface_xa_recover(lixa_iface_t *iface,
268  XID *xids, long count,
269  int rmid, long flags) {
270  if (LIXA_IFACE_STD == iface->type)
271  return iface->std->xa_recover_entry(
272  (XID *)xids,count,rmid,flags);
273  else
274  return iface->xta->xa_recover_entry(
275  iface->context,xids,count,rmid,flags);
276  }
277 
278 
279 
289  static inline int lixa_iface_xa_forget(lixa_iface_t *iface,
290  const XID *xid, int rmid, long flags) {
291  if (LIXA_IFACE_STD == iface->type)
292  return iface->std->xa_forget_entry((XID *)xid, rmid, flags);
293  else
294  return iface->xta->xa_forget_entry(
295  iface->context, xid, rmid, flags);
296  }
297 
298 
299 
309  static inline int lixa_iface_xa_end(lixa_iface_t *iface,
310  const XID *xid, int rmid, long flags) {
311  if (LIXA_IFACE_STD == iface->type)
312  return iface->std->xa_end_entry((XID *)xid, rmid, flags);
313  else
314  return iface->xta->xa_end_entry(iface->context, xid, rmid, flags);
315  }
316 
317 
318 
328  static inline int lixa_iface_xa_prepare(lixa_iface_t *iface,
329  const XID *xid, int rmid, long flags) {
330  if (LIXA_IFACE_STD == iface->type)
331  return iface->std->xa_prepare_entry((XID *)xid, rmid, flags);
332  else
333  return iface->xta->xa_prepare_entry(
334  iface->context, xid, rmid, flags);
335  }
336 
337 
338 
339 #ifdef __cplusplus
340 }
341 #endif /* __cplusplus */
342 
343 
344 
345 /* restore old value of LIXA_TRACE_MODULE */
346 #ifdef LIXA_TRACE_MODULE_SAVE
347 # undef LIXA_TRACE_MODULE
348 # define LIXA_TRACE_MODULE LIXA_TRACE_MODULE_SAVE
349 # undef LIXA_TRACE_MODULE_SAVE
350 #endif /* LIXA_TRACE_MODULE_SAVE */
351 
352 
353 
354 #endif /* LIXA_IFACE_H */
static const char * lixa_iface_get_name(const lixa_iface_t *iface)
Definition: lixa_iface.h:145
int(* xa_prepare_entry)(const XID *, int, long)
Definition: xa.h:110
int(* xa_prepare_entry)(xta_xa_resource_t *, const XID *, int, long)
Definition: xta_iface.h:70
int(* xa_end_entry)(const XID *, int, long)
Definition: xa.h:102
static int lixa_iface_xa_end(lixa_iface_t *iface, const XID *xid, int rmid, long flags)
Definition: lixa_iface.h:309
void lixa_iface_set_std(lixa_iface_t *iface, struct xa_switch_t *std)
xta_xa_resource_t * context
Definition: lixa_iface.h:86
int(* xa_recover_entry)(xta_xa_resource_t *, XID *xids, long, int, long)
Definition: xta_iface.h:78
static int lixa_iface_xa_start(lixa_iface_t *iface, const XID *xid, int rmid, long flags)
Definition: lixa_iface.h:203
int(* xa_commit_entry)(const XID *, int, long)
Definition: xa.h:114
#define LIXA_IFACE_STD
Definition: lixa_iface.h:43
static int lixa_iface_xa_rollback(lixa_iface_t *iface, const XID *xid, int rmid, long flags)
Definition: lixa_iface.h:243
int(* xa_close_entry)(xta_xa_resource_t *, char *, int, long)
Definition: xta_iface.h:54
int(* xa_rollback_entry)(xta_xa_resource_t *, const XID *, int, long)
Definition: xta_iface.h:66
Definition: xa.h:73
int(* xa_open_entry)(char *, int, long)
Definition: xa.h:90
struct lixa_iface_s lixa_iface_t
void lixa_iface_reset(lixa_iface_t *iface)
int(* xa_forget_entry)(const XID *, int, long)
Definition: xa.h:122
int(* xa_close_entry)(char *, int, long)
Definition: xa.h:94
long flags
Definition: xa.h:82
void lixa_iface_set_xta(lixa_iface_t *iface, const struct xta_iface_s *xta, xta_xa_resource_t *context)
static int lixa_iface_xa_recover(lixa_iface_t *iface, XID *xids, long count, int rmid, long flags)
Definition: lixa_iface.h:267
Definition: xa.h:28
long flags
Definition: xta_iface.h:42
static int lixa_iface_xa_commit(lixa_iface_t *iface, const XID *xid, int rmid, long flags)
Definition: lixa_iface.h:223
static int lixa_iface_xa_close(lixa_iface_t *iface, char *info, int rmid, long flags)
Definition: lixa_iface.h:183
int(* xa_start_entry)(xta_xa_resource_t *, const XID *, int, long)
Definition: xta_iface.h:58
int(* xa_start_entry)(const XID *, int, long)
Definition: xa.h:98
int(* xa_open_entry)(xta_xa_resource_t *, char *, int, long)
Definition: xta_iface.h:50
static int lixa_iface_xa_prepare(lixa_iface_t *iface, const XID *xid, int rmid, long flags)
Definition: lixa_iface.h:328
const struct xta_iface_s * xta
Definition: lixa_iface.h:81
struct xa_switch_t * std
Definition: lixa_iface.h:77
static int lixa_iface_xa_open(lixa_iface_t *iface, char *info, int rmid, long flags)
Definition: lixa_iface.h:163
int(* xa_rollback_entry)(const XID *, int, long)
Definition: xa.h:106
int(* xa_forget_entry)(xta_xa_resource_t *, const XID *, int, long)
Definition: xta_iface.h:82
char name[RMNAMESZ]
Definition: xta_iface.h:38
static int lixa_iface_xa_forget(lixa_iface_t *iface, const XID *xid, int rmid, long flags)
Definition: lixa_iface.h:289
int(* xa_recover_entry)(XID *, long, int, long)
Definition: xa.h:118
int(* xa_end_entry)(xta_xa_resource_t *, const XID *, int, long)
Definition: xta_iface.h:62
char name[RMNAMESZ]
Definition: xa.h:78
static long lixa_iface_get_flags(const lixa_iface_t *iface)
Definition: lixa_iface.h:131
int(* xa_commit_entry)(xta_xa_resource_t *, const XID *, int, long)
Definition: xta_iface.h:74

Copyright © 2009-2019, Christian Ferrari tiian@users.sourceforge.net http://www.tiian.org/