/
atmisv38.c
133 lines (111 loc) · 3.66 KB
/
atmisv38.c
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
129
130
131
132
133
/**
* @brief TP Notify testing...
*
* @file atmisv38.c
*/
/* -----------------------------------------------------------------------------
* Enduro/X Middleware Platform for Distributed Transaction Processing
* Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
* Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
* This software is released under one of the following licenses:
* AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
* See LICENSE file for full text.
* -----------------------------------------------------------------------------
* AGPL license:
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License, version 3 as published
* by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
* for more details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* -----------------------------------------------------------------------------
* A commercial use license is available from Mavimax, Ltd
* contact@mavimax.com
* -----------------------------------------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <ndebug.h>
#include <atmi.h>
#include <ndrstandard.h>
#include <ubf.h>
#include <test.fd.h>
#include <ubfutil.h>
void SVC38 (TPSVCINFO *p_svc)
{
int ret=EXSUCCEED;
char tmp[20];
char nodeid[5];
UBFH *p_ub = (UBFH *)p_svc->data;
ndrx_debug_dump_UBF(log_error, "SVC38 got request", p_ub);
if (EXSUCCEED!=Bget(p_ub, T_STRING_FLD, 0, tmp, NULL))
{
NDRX_LOG(log_error, "TESTERROR: Failed to get T_STRING_FLD!");
EXFAIL_OUT(ret);
}
snprintf(nodeid, sizeof(nodeid), "%02ld", tpgetnodeid());
/* put the reply nodeid */
tmp[2]=nodeid[0];
tmp[3]=nodeid[1];
/* Change the buffer & send notif */
tmp[0]='B';
tmp[1]='B';
if (EXSUCCEED!=Bchg(p_ub, T_STRING_FLD, 0, tmp, 0))
{
NDRX_LOG(log_error, "TESTERROR: Failed to setup T_STRING_FLD!");
EXFAIL_OUT(ret);
}
/* OK we shall send notification to client, b */
if (EXSUCCEED!=tpnotify(&p_svc->cltid, (char *)p_ub, 0L, 0L))
{
NDRX_LOG(log_error, "TESTERROR: failed to tpnotify()!");
EXFAIL_OUT(ret);
}
/* Set to CC */
tmp[0]='C';
tmp[1]='C';
if (EXSUCCEED!=Bchg(p_ub, T_STRING_FLD, 0, tmp, 0))
{
NDRX_LOG(log_error, "TESTERROR: Failed to setup T_STRING_FLD!");
EXFAIL_OUT(ret);
}
out:
tpreturn( ret==EXSUCCEED?TPSUCCESS:TPFAIL,
0L,
(char *)p_ub,
0L,
0L);
}
/*
* Do initialization
*/
int NDRX_INTEGRA(tpsvrinit)(int argc, char **argv)
{
int ret = EXSUCCEED;
char svcnm[MAXTIDENT+1];
NDRX_LOG(log_debug, "tpsvrinit called");
snprintf(svcnm, sizeof(svcnm), "SVC38_%02ld", tpgetnodeid());
/* Advertise our local service... */
if (EXSUCCEED!=tpadvertise(svcnm, SVC38))
{
NDRX_LOG(log_error, "TESTERROR: Failed to initialize [%s]!", svcnm);
ret=EXFAIL;
}
return ret;
}
/**
* Do de-initialization
*/
void NDRX_INTEGRA(tpsvrdone)(void)
{
NDRX_LOG(log_debug, "tpsvrdone called");
}
/* vim: set ts=4 sw=4 et smartindent: */