-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcfg_dump.c
More file actions
128 lines (99 loc) · 4 KB
/
cfg_dump.c
File metadata and controls
128 lines (99 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* cfg_dump.c - Example code dumping UM objects' configuration.
* See https://github.com/UltraMessaging/cfg_dump */
/*
Copyright (c) 2022-2023 Informatica Corporation
Permission is granted to licensees to use or alter this software for any
purpose, including commercial applications, according to the terms laid
out in the Software License Agreement.
This source code example is provided by Informatica for educational
and evaluation purposes only.
THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES
EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF
NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE
UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES,
BE LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR
INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE
TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF
THE LIKELIHOOD OF SUCH DAMAGES.
*/
#include <stdio.h>
#include <string.h>
#if ! defined(_WIN32)
#include <stdlib.h>
#include <unistd.h>
#endif
#include "lbm/lbm.h"
/* Simple error handler. */
#define E(lbm_funct_call_) do { \
int e_ = (lbm_funct_call_); \
if (e_ == LBM_FAILURE) { \
fprintf(stderr, "ERROR (%s:%d): %s failed: '%s'\n", __FILE__, __LINE__, #lbm_funct_call_, lbm_errmsg()); \
exit(1); \
} \
} while (0) /* E */
/* UM callback for receiver events, including received messages. */
int my_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd)
{
return 0;
}
void print_opts(lbm_config_option_t *rcv_opts, int num_opts, char *header)
{
int i;
printf("%s\n", header);
for (i = 0; i < num_opts; i++) {
printf(" %s %s %s\n", rcv_opts[i].type, rcv_opts[i].oname, rcv_opts[i].val);
}
} /* print_opts */
void print_context(lbm_context_t *ctx, char *header)
{
int num_opts = lbm_context_attr_option_size();
lbm_config_option_t *opts = (lbm_config_option_t *)malloc(sizeof(lbm_config_option_t) * num_opts);
E(lbm_context_dump(ctx, &num_opts, opts));
print_opts(opts, num_opts, header);
free(opts);
} /* print_context */
void print_rcv(lbm_rcv_t *rcv, char *header)
{
int num_opts = lbm_rcv_topic_attr_option_size();
lbm_config_option_t *opts = (lbm_config_option_t *)malloc(sizeof(lbm_config_option_t) * num_opts);
E(lbm_rcv_topic_dump(rcv, &num_opts, opts));
print_opts(opts, num_opts, header);
free(opts);
} /* print_rcv */
void print_src(lbm_src_t *src, char *header)
{
int num_opts = lbm_src_topic_attr_option_size();
lbm_config_option_t *opts = (lbm_config_option_t *)malloc(sizeof(lbm_config_option_t) * num_opts);
E(lbm_src_topic_dump(src, &num_opts, opts));
print_opts(opts, num_opts, header);
free(opts);
} /* print_src */
void print_ssrc(lbm_ssrc_t *ssrc, char *header)
{
int num_opts = lbm_src_topic_attr_option_size(); /* Smart src uses the regular "src" API. */
lbm_config_option_t *opts = (lbm_config_option_t *)malloc(sizeof(lbm_config_option_t) * num_opts);
E(lbm_ssrc_topic_dump(ssrc, &num_opts, opts));
print_opts(opts, num_opts, header);
free(opts);
} /* print_ssrc */
int main(int argc, char **argv)
{
lbm_context_t *my_ctx;
lbm_topic_t *topic_obj;
lbm_rcv_t *my_rcv;
lbm_src_t *my_src;
lbm_ssrc_t *my_ssrc;
E(lbm_config("cfg_dump.cfg"));
E(lbm_context_create(&my_ctx, NULL, NULL, NULL));
print_context(my_ctx, "Context");
E(lbm_rcv_topic_lookup(&topic_obj, my_ctx, "MyTopic", NULL));
E(lbm_rcv_create(&my_rcv, my_ctx, topic_obj, my_rcv_cb, NULL, NULL));
print_rcv(my_rcv, "Receiver MyTopic");
E(lbm_src_topic_alloc(&topic_obj, my_ctx, "MyTopic", NULL));
E(lbm_src_create(&my_src, my_ctx, topic_obj, NULL, NULL, NULL));
print_src(my_src, "Source MyTopic");
E(lbm_src_topic_alloc(&topic_obj, my_ctx, "MySmartTopic", NULL));
E(lbm_ssrc_create(&my_ssrc, my_ctx, topic_obj, NULL, NULL, NULL));
print_ssrc(my_ssrc, "SmartSource MySmartTopic");
} /* main */