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 <string.h>
0035 #include <stdio.h>
0036 #include <stdint.h>
0037 #include <stdlib.h>
0038 #include <memory.h>
0039 #include <errno.h>
0040 #include <dlfcn.h>
0041
0042 #include <ndrstandard.h>
0043 #include <ndebug.h>
0044 #include <ndrxdcmn.h>
0045 #include <userlog.h>
0046 #include <ubf.h>
0047 #include <ubfutil.h>
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 expublic int atmi_cvt_c_to_ubf(ubf_c_map_t *map, void *c_struct, UBFH *p_ub, long *rules)
0063 {
0064 int ret = EXSUCCEED;
0065
0066 while (BBADFLDID!=map->fld)
0067 {
0068 if (*rules & UBFUTIL_EXPORT)
0069 {
0070 char *data_ptr = (char *)(c_struct+map->offset);
0071
0072 if (BFLD_INT==map->ftype)
0073 {
0074 long l;
0075 int *i = (int *)data_ptr;
0076
0077 l = *i;
0078
0079 if (EXSUCCEED!=CBchg(p_ub, map->fld, map->occ, (char *)&l, map->buf_size,
0080 BFLD_LONG))
0081 {
0082 int be = Berror;
0083 NDRX_LOG(log_error, "Failed to install mapped long "
0084 "field %d:[%s] to UBF buffer: %s",
0085 Bfname(map->fld), Bstrerror(be));
0086 EXFAIL_OUT(ret);
0087 }
0088 }
0089 else if (EXSUCCEED!=CBchg(p_ub, map->fld, map->occ, data_ptr, map->buf_size,
0090 map->ftype))
0091 {
0092 int be = Berror;
0093 NDRX_LOG(log_error, "Failed to install field %d:[%s] to UBF buffer: %s",
0094 Bfname(map->fld), Bstrerror(be));
0095 EXFAIL_OUT(ret);
0096 }
0097 }
0098 rules++;
0099 map++;
0100 }
0101 out:
0102 return ret;
0103 }
0104
0105
0106
0107
0108
0109
0110
0111
0112 expublic int atmi_cvt_ubf_to_c(ubf_c_map_t *map, UBFH *p_ub, void *c_struct, long *rules)
0113 {
0114 int ret = EXSUCCEED;
0115 BFLDLEN len;
0116 while (BBADFLDID!=map->fld)
0117 {
0118 if (*rules & UBFUTIL_EXPORT)
0119 {
0120 char *data_ptr = (char *)(c_struct+map->offset);
0121 len = map->buf_size;
0122
0123 if (BFLD_INT==map->ftype)
0124 {
0125 long l;
0126 int *i = (int *)data_ptr;
0127 if (EXSUCCEED!=CBget(p_ub, map->fld, map->occ, (char *)&l, 0, BFLD_LONG))
0128 {
0129 int be = Berror;
0130 NDRX_LOG(log_error, "Failed to get mapped in field %d:[%s"
0131 "] from UBF buffer: %s",
0132 map->fld, Bfname(map->fld), Bstrerror(be));
0133
0134 if (*rules & UBFUTIL_OPTIONAL)
0135 {
0136 NDRX_LOG(log_warn, "Field %d:[%s] is optional - continue");
0137 }
0138 else
0139 {
0140 EXFAIL_OUT(ret);
0141 }
0142 }
0143 else
0144 {
0145 *i = (int)l;
0146 }
0147 }
0148 else if (EXSUCCEED!=CBget(p_ub, map->fld, map->occ, data_ptr, &len, map->ftype))
0149 {
0150 int be = Berror;
0151 NDRX_LOG(log_error, "Failed to get field %d:[%s] from UBF buffer: %s",
0152 map->fld, Bfname(map->fld), Bstrerror(be));
0153
0154 if (*rules & UBFUTIL_OPTIONAL)
0155 {
0156 NDRX_LOG(log_warn, "Field %d:[%s] is optional - continue");
0157 }
0158 else
0159 {
0160 EXFAIL_OUT(ret);
0161 }
0162 }
0163 }
0164 rules++;
0165 map++;
0166 }
0167
0168 out:
0169 return ret;
0170 }
0171