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 <sys_unix.h>
0038 #include <atmi.h>
0039 #include <ndrstandard.h>
0040 #include <ubf.h>
0041 #include <test.fd.h>
0042 #include <string.h>
0043 #include <unistd.h>
0044 #include "test72.h"
0045 
0046 
0047 
0048 
0049 
0050 
0051 
0052 exprivate long M_count = 0; 
0053 
0054 
0055 exprivate long M_count2 = 0;
0056 exprivate NDRX_SPIN_LOCKDECL(M_count_lock);
0057 
0058 
0059 
0060 
0061 
0062 void TESTSV (TPSVCINFO *p_svc)
0063 {
0064     int ret=EXSUCCEED;
0065     UBFH *p_ub = (UBFH *)p_svc->data;
0066 
0067     NDRX_LOG(log_debug, "%s got call", __func__);
0068     
0069     p_ub = (UBFH *)tprealloc((char *)p_ub, 1024);
0070 
0071     if (EXFAIL==Bchg(p_ub, T_LONG_FLD, 0, (char *)&M_count, 0))
0072     {
0073         NDRX_LOG(log_error, "TESTERROR: Failed to get T_LONG_FLD: %s", 
0074                  Bstrerror(Berror));
0075         ret=EXFAIL;
0076         goto out;
0077     }
0078     NDRX_SPIN_LOCK_V(M_count_lock);
0079     M_count++;
0080     NDRX_SPIN_UNLOCK_V(M_count_lock);
0081     
0082     
0083 out:
0084     tpreturn(  ret==EXSUCCEED?TPSUCCESS:TPFAIL,
0085                 0L,
0086                 (char *)p_ub,
0087                 0L,
0088                 0L);
0089 }
0090 
0091 
0092 
0093 
0094 void TESTSVB (TPSVCINFO *p_svc)
0095 {
0096     int ret=EXSUCCEED;
0097     UBFH *p_ub = (UBFH *)p_svc->data;
0098 
0099     NDRX_LOG(log_debug, "%s got call", __func__);
0100     
0101     p_ub = (UBFH *)tprealloc((char *)p_ub, 1024);
0102 
0103     if (EXFAIL==Bchg(p_ub, T_LONG_FLD, 0, (char *)&M_count2, 0))
0104     {
0105         NDRX_LOG(log_error, "TESTERROR: Failed to get T_LONG_FLD: %s", 
0106                  Bstrerror(Berror));
0107         ret=EXFAIL;
0108         goto out;
0109     }
0110     NDRX_SPIN_LOCK_V(M_count_lock);
0111     M_count2++;
0112     NDRX_SPIN_UNLOCK_V(M_count_lock);
0113     
0114     
0115 out:
0116     tpreturn(  ret==EXSUCCEED?TPSUCCESS:TPFAIL,
0117                 0L,
0118                 (char *)p_ub,
0119                 0L,
0120                 0L);
0121 }
0122 
0123 
0124 
0125 
0126 void GETINFOS (TPSVCINFO *p_svc)
0127 {
0128     int ret=EXSUCCEED;
0129     long cnt;
0130     UBFH *p_ub = (UBFH *)p_svc->data;
0131 
0132     NDRX_LOG(log_debug, "%s got call", __func__);
0133     
0134     p_ub = (UBFH *)tprealloc((char *)p_ub, 1024);
0135     
0136     NDRX_SPIN_LOCK_V(M_count_lock);
0137     cnt = M_count;
0138     NDRX_SPIN_UNLOCK_V(M_count_lock);
0139     
0140 
0141     if (EXFAIL==Bchg(p_ub, T_LONG_FLD, 0, (char *)&cnt, 0))
0142     {
0143         NDRX_LOG(log_error, "TESTERROR: Failed to get T_LONG_FLD: %s", 
0144                  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 
0159 
0160 void GETINFOSB (TPSVCINFO *p_svc)
0161 {
0162     int ret=EXSUCCEED;
0163     long cnt;
0164     UBFH *p_ub = (UBFH *)p_svc->data;
0165 
0166     NDRX_LOG(log_debug, "%s got call", __func__);
0167     
0168     p_ub = (UBFH *)tprealloc((char *)p_ub, 1024);
0169     
0170     NDRX_SPIN_LOCK_V(M_count_lock);
0171     cnt = M_count2;
0172     NDRX_SPIN_UNLOCK_V(M_count_lock);
0173     
0174 
0175     if (EXFAIL==Bchg(p_ub, T_LONG_FLD, 0, (char *)&cnt, 0))
0176     {
0177         NDRX_LOG(log_error, "TESTERROR: Failed to get T_LONG_FLD: %s", 
0178                  Bstrerror(Berror));
0179         ret=EXFAIL;
0180         goto out;
0181     }
0182     
0183 out:
0184     tpreturn(  ret==EXSUCCEED?TPSUCCESS:TPFAIL,
0185                 0L,
0186                 (char *)p_ub,
0187                 0L,
0188                 0L);
0189 }
0190 
0191 
0192 
0193 
0194 int NDRX_INTEGRA(tpsvrinit)(int argc, char **argv)
0195 {
0196     int ret = EXSUCCEED;
0197     NDRX_LOG(log_debug, "tpsvrinit called");
0198 
0199     NDRX_SPIN_INIT_V(M_count_lock);
0200     
0201     if (EXSUCCEED!=tpadvertise("TESTSV", TESTSV))
0202     {
0203         NDRX_LOG(log_error, "Failed to initialise TESTSV!");
0204         EXFAIL_OUT(ret);
0205     }
0206     
0207     if (EXSUCCEED!=tpadvertise("GETINFOS", GETINFOS))
0208     {
0209         NDRX_LOG(log_error, "Failed to initialise GETINFOS!");
0210         EXFAIL_OUT(ret);
0211     }
0212     
0213     if (EXSUCCEED!=tpadvertise("TESTSVB", TESTSVB))
0214     {
0215         NDRX_LOG(log_error, "Failed to initialise TESTSVB!");
0216         EXFAIL_OUT(ret);
0217     }
0218     
0219     if (EXSUCCEED!=tpadvertise("GETINFOSB", GETINFOSB))
0220     {
0221         NDRX_LOG(log_error, "Failed to initialise GETINFOSB!");
0222         EXFAIL_OUT(ret);
0223     }
0224     
0225 out:
0226     return ret;
0227 }
0228 
0229 
0230 
0231 
0232 void NDRX_INTEGRA(tpsvrdone)(void)
0233 {
0234     NDRX_LOG(log_debug, "tpsvrdone called");
0235 }
0236 
0237