0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
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 <ndebug.h>
0042
0043 void TEST31_1ST (TPSVCINFO *p_svc)
0044 {
0045 int ret=EXSUCCEED;
0046 UBFH *p_ub = (UBFH *)p_svc->data;
0047
0048 if (EXSUCCEED!=tplogsetreqfile((char **)&p_ub, NULL, NULL))
0049 {
0050 NDRX_LOG(log_error, "TESTERROR: Failed to set request file! :%s", tpstrerror(tperrno));
0051 EXFAIL_OUT(ret);
0052 }
0053
0054
0055 tplogprintubf(log_debug, "TEST31_1ST request buffer", p_ub);
0056
0057 tplog(log_warn, "Hello from TEST31_1ST!");
0058
0059
0060 out:
0061
0062 if (EXSUCCEED==ret)
0063 {
0064 tplog(log_warn, "Request ok, forwarding to 2ND service");
0065 tplogclosereqfile();
0066 tpforward( "TEST31_2ND",
0067 (char *)p_ub,
0068 0L,
0069 0L);
0070 }
0071 else
0072 {
0073 tplog(log_warn, "Request FAIL, returning...");
0074 tplogclosereqfile();
0075 tpreturn(TPFAIL,
0076 0L,
0077 (char *)p_ub,
0078 0L,
0079 0L);
0080 }
0081 }
0082
0083
0084
0085
0086
0087 void SETREQFILE(TPSVCINFO *p_svc)
0088 {
0089 int ret = EXSUCCEED;
0090 UBFH *p_ub = (UBFH *)p_svc->data;
0091 char filename[256];
0092 static int req_no = 0;
0093
0094 req_no++;
0095
0096 sprintf(filename, "./logs/request_%d.log", req_no);
0097
0098
0099 if (NULL==(p_ub = (UBFH *)tprealloc((char *)p_ub, 4000)))
0100 {
0101 NDRX_LOG(log_error, "TESTERROR: realloc failed: %s",
0102 filename, tpstrerror(tperrno));
0103 EXFAIL_OUT(ret);
0104 }
0105
0106 if (EXSUCCEED!=tplogsetreqfile((char **)&p_ub, filename, NULL))
0107 {
0108 NDRX_LOG(log_error, "TESTERROR: Failed to set request file to [%s]:%s",
0109 filename, tpstrerror(tperrno));
0110 EXFAIL_OUT(ret);
0111 }
0112
0113 tplog(log_debug, "Hello from SETREQFILE!");
0114
0115 tplogclosereqfile();
0116
0117 tplog(log_debug, "SETREQFILE closed req file - logging in main");
0118
0119 out:
0120 tpreturn( ret==EXSUCCEED?TPSUCCESS:TPFAIL,
0121 0L,
0122 (char *)p_ub,
0123 0L,
0124 0L);
0125 }
0126
0127
0128
0129
0130 int NDRX_INTEGRA(tpsvrinit)(int argc, char **argv)
0131 {
0132 NDRX_LOG(log_debug, "tpsvrinit called");
0133
0134
0135 if (EXSUCCEED!=tplogconfig(LOG_FACILITY_NDRX|LOG_FACILITY_UBF|LOG_FACILITY_TP,
0136 EXFAIL, "file=./1sv.log tp=5 ndrx=5 ubf=0", "1SRV", NULL))
0137 {
0138 NDRX_LOG(log_error, "TESTERROR: Failed to configure logger!");
0139 }
0140
0141 if (EXSUCCEED!=tpadvertise("TEST31_1ST", TEST31_1ST))
0142 {
0143 NDRX_LOG(log_error, "TESTERROR: Failed to initialize TEST31_1ST (first)!");
0144 }
0145 else if (EXSUCCEED!=tpadvertise("SETREQFILE", SETREQFILE))
0146 {
0147 NDRX_LOG(log_error, "TESTERROR: Failed to initialize SETREQFILE!");
0148 }
0149
0150
0151 return EXSUCCEED;
0152 }
0153
0154
0155
0156
0157 void NDRX_INTEGRA(tpsvrdone)(void)
0158 {
0159 NDRX_LOG(log_debug, "tpsvrdone called");
0160 }
0161
0162