Back to home page

Enduro/X

 
 

    


0001 /**
0002  * @brief DDR functionality tests - server
0003  *
0004  * @file atmisv84.c
0005  */
0006 /* -----------------------------------------------------------------------------
0007  * Enduro/X Middleware Platform for Distributed Transaction Processing
0008  * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0009  * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0010  * This software is released under one of the following licenses:
0011  * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0012  * See LICENSE file for full text.
0013  * -----------------------------------------------------------------------------
0014  * AGPL license:
0015  * 
0016  * This program is free software; you can redistribute it and/or modify it under
0017  * the terms of the GNU Affero General Public License, version 3 as published
0018  * by the Free Software Foundation;
0019  *
0020  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0021  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0022  * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0023  * for more details.
0024  *
0025  * You should have received a copy of the GNU Affero General Public License along 
0026  * with this program; if not, write to the Free Software Foundation, Inc., 
0027  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0028  *
0029  * -----------------------------------------------------------------------------
0030  * A commercial use license is available from Mavimax, Ltd
0031  * contact@mavimax.com
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 #include <unistd.h>
0043 #include "test84.h"
0044 #include "exsha1.h"
0045 
0046 /*---------------------------Externs------------------------------------*/
0047 /*---------------------------Macros-------------------------------------*/
0048 /*---------------------------Enums--------------------------------------*/
0049 /*---------------------------Typedefs-----------------------------------*/
0050 /*---------------------------Globals------------------------------------*/
0051 /*---------------------------Statics------------------------------------*/
0052 /*---------------------------Prototypes---------------------------------*/
0053 
0054 /**
0055  * Standard service entry
0056  */
0057 void TESTSV (TPSVCINFO *p_svc)
0058 {
0059     int ret=EXSUCCEED;
0060     UBFH *p_ub = (UBFH *)p_svc->data;
0061     
0062     if (NULL==p_ub)
0063     {
0064         /* it's OK */
0065         goto out;
0066     }
0067     
0068     /* ensure the size */
0069     if (NULL==(p_ub = (UBFH *)tprealloc((char *)p_ub, 1024)))
0070     {
0071         NDRX_LOG(log_error, "Failed to realloc: %s", tpstrerror(tperrno));
0072         EXFAIL_OUT(ret);
0073     }
0074 
0075     NDRX_LOG(log_debug, "%s got call", __func__);
0076     
0077     /* Just print the buffer */
0078     Bprint(p_ub);
0079     
0080     if (EXFAIL==Bchg(p_ub, T_STRING_FLD, 0, p_svc->name, 0))
0081     {
0082         NDRX_LOG(log_error, "TESTERROR: Failed to set T_STRING_FLD to [%s]: %s", 
0083                  p_svc->name, Bstrerror(Berror));
0084         ret=EXFAIL;
0085         goto out;
0086     }
0087     
0088 out:
0089     tpreturn(  ret==EXSUCCEED?TPSUCCESS:TPFAIL,
0090                 0L,
0091                 (char *)p_ub,
0092                 0L,
0093                 0L);
0094 }
0095 
0096 
0097 void DYNSV(TPSVCINFO *p_svc)
0098 {
0099     tpreturn(  TPSUCCESS,
0100                 0L,
0101                 (char *)p_svc->data,
0102                 0L,
0103                 0L);
0104 }
0105 
0106 void DYNADV(TPSVCINFO *p_svc)
0107 {
0108     UBFH *p_ub = (UBFH *)p_svc->data;
0109     int ret = EXSUCCEED;
0110     char svcnm[XATMI_SERVICE_NAME_LENGTH+1];
0111     BFLDLEN len;
0112     
0113     len = sizeof(svcnm);
0114     
0115     if (EXFAIL==Bget(p_ub, T_STRING_2_FLD, 0, svcnm, &len))
0116     {
0117         NDRX_LOG(log_error, "TESTERROR: Failed to get T_STRING_2_FLD: %s", Bstrerror(Berror));
0118         ret=EXFAIL;
0119         goto out;
0120     }
0121     
0122     if (0==strcmp(p_svc->name, "DADV"))
0123     {
0124         if (EXSUCCEED!=tpadvertise(svcnm, DYNSV))
0125         {
0126             NDRX_LOG(log_error, "Failed to advertise: %s", tpstrerror(tperrno));
0127             ret=EXFAIL;
0128             goto out;
0129         }
0130     }
0131     else if (0==strcmp(p_svc->name, "DUNA"))
0132     {
0133         if (EXSUCCEED!=tpunadvertise(svcnm))
0134         {
0135             NDRX_LOG(log_error, "Failed to unadvertise: %s", tpstrerror(tperrno));
0136             ret=EXFAIL;
0137             goto out;
0138         }
0139     }
0140     
0141     if (EXFAIL==Bchg(p_ub, T_STRING_FLD, 0, p_svc->name, 0))
0142     {
0143         NDRX_LOG(log_error, "TESTERROR: Failed to set T_STRING_FLD to [%s]: %s", 
0144                  p_svc->name, Bstrerror(Berror));
0145         ret=EXFAIL;
0146         goto out;
0147     }
0148     
0149 out:
0150     tpreturn(  ret==EXSUCCEED?TPSUCCESS:TPFAIL,
0151                 0L,
0152                 (char *)p_ub,
0153                 0L,
0154                 0L);
0155 }
0156 
0157 /**
0158  * Forward service
0159  * @param p_svc
0160  */
0161 void FWDSV (TPSVCINFO *p_svc)
0162 {
0163     tpforward("TESTSV", p_svc->data, p_svc->len, 0);
0164 }
0165 
0166 /**
0167  * Do initialisation
0168  */
0169 int NDRX_INTEGRA(tpsvrinit)(int argc, char **argv)
0170 {
0171     int ret = EXSUCCEED;
0172     NDRX_LOG(log_debug, "tpsvrinit called");
0173 
0174     if (EXSUCCEED!=tpadvertise("TESTSV", TESTSV))
0175     {
0176         NDRX_LOG(log_error, "Failed to initialise TESTSV!");
0177         EXFAIL_OUT(ret);
0178     }
0179     
0180     if (EXSUCCEED!=tpadvertise("FWDSV", FWDSV))
0181     {
0182         NDRX_LOG(log_error, "Failed to initialise FWDSV!");
0183         EXFAIL_OUT(ret);
0184     }
0185     
0186     /* Check that "UNASV" is not present by psc */
0187     if (EXSUCCEED!=tpadvertise("UNASV", TESTSV))
0188     {
0189         NDRX_LOG(log_error, "Failed to initialise FWDSV!");
0190         EXFAIL_OUT(ret);
0191     }
0192     
0193     if (EXSUCCEED!=tpadvertise("DYNADV", DYNADV))
0194     {
0195         NDRX_LOG(log_error, "Failed to initialise DYNADV!");
0196         EXFAIL_OUT(ret);
0197     }
0198     
0199     if (EXSUCCEED!=tpunadvertise("UNASV"))
0200     {
0201         NDRX_LOG(log_error, "TESTERROR: failed to unadvertise!");
0202         EXFAIL_OUT(ret);
0203     }
0204     
0205     
0206 out:
0207     return ret;
0208 }
0209 
0210 /**
0211  * Do de-initialisation
0212  */
0213 void NDRX_INTEGRA(tpsvrdone)(void)
0214 {
0215     NDRX_LOG(log_debug, "tpsvrdone called");
0216 }
0217 
0218 /* vim: set ts=4 sw=4 et smartindent: */