XTA: API Reference for C language

lixa_config.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_CONFIG_H
20 # define LIXA_CONFIG_H
21 
22 
23 
24 #include <config.h>
25 
26 
27 
28 #ifdef HAVE_LIBXML_TREE_H
29 # include <libxml/tree.h>
30 #endif
31 #ifdef HAVE_LIBXML_PARSER_H
32 # include <libxml/parser.h>
33 #endif
34 #ifdef HAVE_NETINET_IN_H
35 # include <netinet/in.h>
36 #endif
37 #ifdef HAVE_GLIB_H
38 # include <glib.h>
39 #endif
40 #ifdef HAVE_STRING_H
41 # include <string.h>
42 #endif
43 
44 
45 
46 #include "lixa_inst_conf.h"
47 
48 
49 
50 /* save old LIXA_TRACE_MODULE and set a new value */
51 #ifdef LIXA_TRACE_MODULE
52 # define LIXA_TRACE_MODULE_SAVE LIXA_TRACE_MODULE
53 # undef LIXA_TRACE_MODULE
54 #endif /* LIXA_TRACE_MODULE */
55 #define LIXA_TRACE_MODULE LIXA_TRACE_MOD_COMMON_CONFIG
56 
57 
58 
62 #define MD5_DIGEST_LENGTH 16
63 
64 
65 
69 #define LIXA_JOB_SOURCE_IP_LEN 15
70 
71 
72 
76 #define LIXA_JOB_RAW_LEN (MD5_DIGEST_LENGTH * 2 + 1 + \
77  LIXA_JOB_SOURCE_IP_LEN + 1)
78 
79 
80 
84 extern const char *LIXA_NULL_STRING;
85 
89 extern const xmlChar *LIXA_XML_CONFIG_LISTENER;
90 
94 extern const xmlChar *LIXA_XML_CONFIG_CLIENT;
95 
99 extern const xmlChar *LIXA_XML_CONFIG_CLIENT_CONNECTION_TIMEOUT;
100 
104 extern const xmlChar *LIXA_XML_CONFIG_SERVER;
105 
109 extern const xmlChar *LIXA_XML_CONFIG_SERVER_PID;
110 
114 extern const xmlChar *LIXA_XML_CONFIG_SERVER_MIN_EST;
115 
119 extern const xmlChar *LIXA_XML_CONFIG_SERVER_MAX_EST;
120 
124 extern const xmlChar *LIXA_XML_CONFIG_DOMAIN_PROPERTY;
125 
129 extern const xmlChar *LIXA_XML_CONFIG_ADDRESS_PROPERTY;
130 
134 extern const xmlChar *LIXA_XML_CONFIG_PORT_PROPERTY;
135 
139 extern const xmlChar *LIXA_XML_CONFIG_DOMAIN_AF_INET_VALUE;
140 
144 extern const xmlChar *LIXA_XML_CONFIG_MANAGER;
145 
149 extern const xmlChar *LIXA_XML_CONFIG_MANAGER_STATUS;
150 
154 extern const xmlChar *LIXA_XML_CONFIG_STTSRV;
155 
159 extern const xmlChar *LIXA_XML_CONFIG_STTSRVS;
160 
164 extern const xmlChar *LIXA_XML_CONFIG_RSRMGR;
165 
169 extern const xmlChar *LIXA_XML_CONFIG_RSRMGRS;
170 
174 extern const xmlChar *LIXA_XML_CONFIG_PROFILE_PROPERTY;
175 
179 extern const xmlChar *LIXA_XML_CONFIG_PROFILE;
180 
184 extern const xmlChar *LIXA_XML_CONFIG_PROFILES;
185 
189 extern const xmlChar *LIXA_XML_CONFIG_NAME_PROPERTY;
190 
194 extern const xmlChar *LIXA_XML_CONFIG_SWITCH_FILE_PROPERTY;
195 
199 extern const xmlChar *LIXA_XML_CONFIG_XA_CLOSE_INFO_PROPERTY;
200 
204 extern const xmlChar *LIXA_XML_CONFIG_XA_OPEN_INFO_PROPERTY;
205 
206 
207 
215 typedef char md5_digest_hex_t[MD5_DIGEST_LENGTH * 2 + 1];
216 
217 
218 
223 union lixa_job_u {
224  struct {
226  char separator;
229  } fields;
231 };
232 
237 typedef union lixa_job_u lixa_job_t;
238 
239 
240 
241 #ifdef __cplusplus
242 extern "C" {
243 #endif /* __cplusplus */
244 
245 
246 
253  int lixa_config_retrieve_domain(xmlNode *cur_node, int *domain);
254 
255 
256 
263  int lixa_config_retrieve_port(xmlNode *cur_node, in_port_t *port);
264 
265 
266 
276  int lixa_config_retrieve_generic_long(xmlNode *cur_node,
277  const xmlChar *property,
278  long *value);
279 
280 
281 
290  int lixa_config_digest(int fd, const char *profile,
291  md5_digest_hex_t digest);
292 
293 
294 
299  static inline void lixa_job_reset(lixa_job_t *job) {
300  memset(job->raw, ' ', LIXA_JOB_RAW_LEN - 1);
301  job->raw[LIXA_JOB_RAW_LEN - 1] = '\0'; }
302 
303 
304 
311  static inline const char *lixa_job_get_raw(const lixa_job_t *job) {
312  return job->raw; }
313 
314 
315 
323  int lixa_job_set_raw(lixa_job_t *job, const char *raw_job);
324 
325 
326 
333  static inline void lixa_job_set_config_digest(
334  lixa_job_t *job, const char *config_digest) {
335  strncpy(job->fields.config_digest, config_digest,
336  MD5_DIGEST_LENGTH * 2);
337  job->fields.terminator = '\0';
338  }
339 
340 
341 
348  int lixa_job_set_source_ip(lixa_job_t *job, int fd);
349 
350 
351 
352 #ifdef __cplusplus
353 }
354 #endif /* __cplusplus */
355 
356 
357 
358 /* restore old value of LIXA_TRACE_MODULE */
359 #ifdef LIXA_TRACE_MODULE_SAVE
360 # undef LIXA_TRACE_MODULE
361 # define LIXA_TRACE_MODULE LIXA_TRACE_MODULE_SAVE
362 # undef LIXA_TRACE_MODULE_SAVE
363 #endif /* LIXA_TRACE_MODULE_SAVE */
364 
365 
366 
367 #endif /* LIXA_CONFIG_H */
const xmlChar * LIXA_XML_CONFIG_MANAGER_STATUS
const xmlChar * LIXA_XML_CONFIG_STTSRV
const xmlChar * LIXA_XML_CONFIG_DOMAIN_PROPERTY
const xmlChar * LIXA_XML_CONFIG_CLIENT
const xmlChar * LIXA_XML_CONFIG_LISTENER
const xmlChar * LIXA_XML_CONFIG_RSRMGR
const xmlChar * LIXA_XML_CONFIG_XA_CLOSE_INFO_PROPERTY
int lixa_config_retrieve_port(xmlNode *cur_node, in_port_t *port)
int lixa_job_set_raw(lixa_job_t *job, const char *raw_job)
const xmlChar * LIXA_XML_CONFIG_MANAGER
static const char * lixa_job_get_raw(const lixa_job_t *job)
Definition: lixa_config.h:311
const xmlChar * LIXA_XML_CONFIG_SERVER_MAX_EST
const xmlChar * LIXA_XML_CONFIG_SERVER
static void lixa_job_set_config_digest(lixa_job_t *job, const char *config_digest)
Definition: lixa_config.h:333
const xmlChar * LIXA_XML_CONFIG_PROFILE_PROPERTY
int lixa_config_retrieve_domain(xmlNode *cur_node, int *domain)
char md5_digest_hex_t[MD5_DIGEST_LENGTH *2+1]
Definition: lixa_config.h:215
const char * LIXA_NULL_STRING
const xmlChar * LIXA_XML_CONFIG_STTSRVS
int lixa_config_digest(int fd, const char *profile, md5_digest_hex_t digest)
const xmlChar * LIXA_XML_CONFIG_SERVER_MIN_EST
const xmlChar * LIXA_XML_CONFIG_SWITCH_FILE_PROPERTY
const xmlChar * LIXA_XML_CONFIG_CLIENT_CONNECTION_TIMEOUT
char separator
Definition: lixa_config.h:226
char terminator
Definition: lixa_config.h:228
int lixa_job_set_source_ip(lixa_job_t *job, int fd)
char config_digest[MD5_DIGEST_LENGTH *2]
Definition: lixa_config.h:225
static void lixa_job_reset(lixa_job_t *job)
Definition: lixa_config.h:299
const xmlChar * LIXA_XML_CONFIG_PORT_PROPERTY
const xmlChar * LIXA_XML_CONFIG_PROFILES
const xmlChar * LIXA_XML_CONFIG_SERVER_PID
const xmlChar * LIXA_XML_CONFIG_PROFILE
const xmlChar * LIXA_XML_CONFIG_ADDRESS_PROPERTY
#define LIXA_JOB_SOURCE_IP_LEN
Definition: lixa_config.h:69
#define MD5_DIGEST_LENGTH
Definition: lixa_config.h:62
char source_ip[LIXA_JOB_SOURCE_IP_LEN]
Definition: lixa_config.h:227
int lixa_config_retrieve_generic_long(xmlNode *cur_node, const xmlChar *property, long *value)
const xmlChar * LIXA_XML_CONFIG_XA_OPEN_INFO_PROPERTY
const xmlChar * LIXA_XML_CONFIG_NAME_PROPERTY
char raw[LIXA_JOB_RAW_LEN]
Definition: lixa_config.h:230
const xmlChar * LIXA_XML_CONFIG_RSRMGRS
guint8 md5_digest_t[MD5_DIGEST_LENGTH]
Definition: lixa_config.h:211
#define LIXA_JOB_RAW_LEN
Definition: lixa_config.h:76
struct lixa_job_u::@10 fields
const xmlChar * LIXA_XML_CONFIG_DOMAIN_AF_INET_VALUE

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