Back to home page

Enduro/X

 
 

    


0001 /**
0002  *
0003  * @file atmisv4_2ND.c
0004  */
0005 /* -----------------------------------------------------------------------------
0006  * Enduro/X Middleware Platform for Distributed Transaction Processing
0007  * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0008  * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0009  * This software is released under one of the following licenses:
0010  * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0011  * See LICENSE file for full text.
0012  * -----------------------------------------------------------------------------
0013  * AGPL license:
0014  *
0015  * This program is free software; you can redistribute it and/or modify it under
0016  * the terms of the GNU Affero General Public License, version 3 as published
0017  * by the Free Software Foundation;
0018  *
0019  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0020  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0021  * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0022  * for more details.
0023  *
0024  * You should have received a copy of the GNU Affero General Public License along 
0025  * with this program; if not, write to the Free Software Foundation, Inc.,
0026  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0027  *
0028  * -----------------------------------------------------------------------------
0029  * A commercial use license is available from Mavimax, Ltd
0030  * contact@mavimax.com
0031  * -----------------------------------------------------------------------------
0032  */
0033 
0034 #include <stdio.h>
0035 #include <stdlib.h>
0036 #include <ndebug.h>
0037 #include <atmi.h>
0038 #include <ndrstandard.h>
0039 #include <ubf.h>
0040 #include <test.fd.h>
0041 #include <string.h>
0042 
0043 void TEST4_2ND (TPSVCINFO *p_svc)
0044 {
0045     int ret=EXSUCCEED;
0046 
0047     static double d = 11.66;
0048 
0049     UBFH *p_ub = (UBFH *)p_svc->data;
0050 
0051     NDRX_LOG(log_debug, "TESTSVFN got call");
0052 
0053     /* Just print the buffer */
0054     Bprint(p_ub);
0055     if (NULL==(p_ub = (UBFH *)tprealloc((char *)p_ub, 4096))) /* allocate some stuff for more data to put in  */
0056     {
0057         ret=EXFAIL;
0058         goto out;
0059     }
0060 
0061     d+=1;
0062 
0063     if (EXFAIL==Badd(p_ub, T_DOUBLE_2_FLD, (char *)&d, 0))
0064     {
0065         ret=EXFAIL;
0066         goto out;
0067     }
0068 
0069 out:
0070     tpreturn(  ret==EXSUCCEED?TPSUCCESS:TPFAIL,
0071                 0L,
0072                 (char *)p_ub,
0073                 0L,
0074                 0L);
0075 }
0076 
0077 /*
0078  * Do initialization
0079  */
0080 int NDRX_INTEGRA(tpsvrinit)(int argc, char **argv)
0081 {
0082     int ret=EXSUCCEED;
0083     TPEVCTL evctl;
0084 
0085     NDRX_LOG(log_debug, "tpsvrinit called");
0086     memset(&evctl, 0, sizeof(evctl));
0087 
0088     if (EXSUCCEED!=tpadvertise("TEST4_2ND", TEST4_2ND))
0089     {
0090         NDRX_LOG(log_error, "Failed to initialize TEST2_2ND (first)!");
0091         ret=EXFAIL;
0092         goto out;
0093     }
0094     else if (EXSUCCEED!=tpadvertise("TEST4_2ND_AL", TEST4_2ND))
0095     {
0096         NDRX_LOG(log_error, "Failed to initialize TEST4_2ND_AL (alias)!");
0097         ret=EXFAIL;
0098         goto out;
0099     }
0100 
0101 
0102     NDRX_STRCPY_SAFE(evctl.name1, "TEST4_2ND");
0103     evctl.flags|=TPEVSERVICE;
0104     /* Subscribe to event server */
0105     if (EXFAIL==tpsubscribe("EV..TEST", "1==1 && T_DOUBLE_FLD==5", &evctl, 0L))
0106     {
0107         NDRX_LOG(log_error, "Failed to subscribe TEST4_1ST "
0108                                         "to EV..TEST event failed");
0109         ret=EXFAIL;
0110     }
0111     
0112 out:
0113     return ret;
0114 }
0115 
0116 /**
0117  * Do de-initialization
0118  */
0119 void NDRX_INTEGRA(tpsvrdone)(void)
0120 {
0121     NDRX_LOG(log_debug, "tpsvrdone called");
0122 }
0123 
0124 /* vim: set ts=4 sw=4 et smartindent: */