Back to home page

Enduro/X

 
 

    


0001 /**
0002  * @brief UBF field type convertion functions
0003  *
0004  * @file cf.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 
0035 /*---------------------------Includes-----------------------------------*/
0036 #include <string.h>
0037 #include <stdio.h>
0038 #include <stdlib.h>
0039 #include <memory.h>
0040 
0041 #include <ubf.h>
0042 #include <ubf_int.h>    /* Internal headers for UBF... */
0043 #include <fdatatype.h>
0044 #include <ferror.h>
0045 #include <fieldtable.h>
0046 #include <ndrstandard.h>
0047 #include <ndebug.h>
0048 #include "cf.h"
0049 
0050 /*---------------------------Externs------------------------------------*/
0051 /*---------------------------Macros-------------------------------------*/
0052 #define CARR_TEMP_BUF \
0053         char tmp[CF_TEMP_BUF_MAX]; \
0054         int cpy_len = in_len > CF_TEMP_BUF_MAX?CF_TEMP_BUF_MAX: in_len;\
0055         UBF_LOG(log_debug, "[%10.10s]", input_buf);\
0056         memcpy(tmp, input_buf, cpy_len); \
0057         tmp[cpy_len] = EXEOS
0058 
0059 /*
0060  * This generally checks fixed data type lengths, i.e. if converting out
0061  * then if specified shorter that standard data type, then rejected!
0062  */
0063 #define CHECK_OUTPUT_BUF_SIZE \
0064     if (CNV_DIR_OUT==cnv_dir && NULL!=out_len)\
0065     {\
0066         if (to->size > *out_len)\
0067         {\
0068             ndrx_Bset_error_fmt(BNOSPACE, "data size: %d specified :%d", to->size, *out_len);\
0069             return NULL; \
0070         }\
0071     }
0072 
0073 /*
0074  * This converts simple data type to string
0075  */
0076 #define CONV_TO_STRING(X, C) \
0077     if (CNV_DIR_OUT==cnv_dir && NULL!=out_len)\
0078     {\
0079         char tmp[CF_TEMP_BUF_MAX];\
0080         snprintf(tmp, sizeof(tmp), X, (C)*ptr);\
0081         len = strlen(tmp)+1; /* Including EOS! */\
0082         if (*out_len<len)\
0083         {\
0084             ndrx_Bset_error_fmt(BNOSPACE, "data size: %d specified: %d", len, *out_len);\
0085             return NULL;\
0086         }\
0087         else\
0088         {\
0089             strcpy(output_buf, tmp);\
0090         }\
0091     }\
0092     else\
0093     {\
0094         /* In case if converting in, we have space for trailing EOS! */\
0095         if (NULL!=out_len) /* In case if we really need it! */\
0096         {\
0097             snprintf(output_buf, *out_len, X, (C)*ptr);\
0098             len = strlen(output_buf)+1;\
0099         }\
0100         else\
0101             sprintf(output_buf, X, (C)*ptr);\
0102     }\
0103     if (NULL!=out_len)\
0104         *out_len = len;\
0105 
0106 /*
0107  * Convert simple data type to character array
0108  * This is the same as above, but strncpy used instead of strcpy!
0109  */
0110 #define CONV_TO_CARRAY(X, C)\
0111 if (CNV_DIR_OUT==cnv_dir)\
0112     {\
0113         char tmp[CF_TEMP_BUF_MAX];\
0114         snprintf(tmp, sizeof(tmp), X, (C)*ptr);\
0115         len = strlen(tmp); /* NOT Including EOS! */\
0116         if (NULL!=out_len && *out_len < len)\
0117         {\
0118             ndrx_Bset_error_fmt(BNOSPACE, "data size: %d specified: %d", len, *out_len);\
0119             return NULL;\
0120         }\
0121         else\
0122         {\
0123             NDRX_STRNCPY(output_buf, tmp, len);\
0124         }\
0125     }\
0126     else\
0127     {\
0128         /* In case if converting in, we have space for trailing EOS! */\
0129         if (NULL!=out_len) /* In case if we really need it! */\
0130         {\
0131             snprintf(output_buf, *out_len, X, (C)*ptr);\
0132             len = strlen(output_buf);\
0133         }\
0134         else\
0135         {\
0136             sprintf(output_buf, X, (C)*ptr);\
0137         }\
0138     }\
0139     if (NULL!=out_len)\
0140         *out_len = len;
0141 
0142 /*---------------------------Enums--------------------------------------*/
0143 /*---------------------------Typedefs-----------------------------------*/
0144 /*---------------------------Globals------------------------------------*/
0145 /*---------------------------Statics------------------------------------*/
0146 /*---------------------------Prototypes---------------------------------*/
0147 
0148 /* Functions from short to something */
0149 exprivate char * conv_short_long(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0150 exprivate char * conv_short_char(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0151 exprivate char * conv_short_float(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0152 exprivate char * conv_short_double(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0153 exprivate char * conv_short_string(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0154 exprivate char * conv_short_carr(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0155 exprivate char * conv_short_int(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0156 exprivate char * conv_short_ptr(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0157 
0158 /* Functions from long to something */
0159 exprivate char * conv_long_short(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0160 exprivate char * conv_long_char(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0161 exprivate char * conv_long_float(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0162 exprivate char * conv_long_double(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0163 exprivate char * conv_long_string(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0164 exprivate char * conv_long_carr(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0165 exprivate char * conv_long_int(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0166 exprivate char * conv_long_ptr(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0167 
0168 /* Functions from char to something */
0169 exprivate char * conv_char_short(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0170 exprivate char * conv_char_long(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0171 exprivate char * conv_char_float(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0172 exprivate char * conv_char_double(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0173 exprivate char * conv_char_string(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0174 exprivate char * conv_char_carr(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0175 exprivate char * conv_char_int(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0176 exprivate char * conv_char_ptr(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0177 
0178 /* Functions from float to something */
0179 exprivate char * conv_float_short(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0180 exprivate char * conv_float_long(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0181 exprivate char * conv_float_char(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0182 exprivate char * conv_float_double(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0183 exprivate char * conv_float_string(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0184 exprivate char * conv_float_carr(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0185 exprivate char * conv_float_int(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0186 exprivate char * conv_float_ptr(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0187 
0188 /* Functions from double to something */
0189 exprivate char * conv_double_short(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0190 exprivate char * conv_double_long(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0191 exprivate char * conv_double_char(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0192 exprivate char * conv_double_float(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0193 exprivate char * conv_double_string(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0194 exprivate char * conv_double_carr(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0195 exprivate char * conv_double_int(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0196 exprivate char * conv_double_ptr(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0197 
0198 /* Functions from string to something */
0199 exprivate char * conv_string_short(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0200 exprivate char * conv_string_long(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0201 exprivate char * conv_string_char(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0202 exprivate char * conv_string_float(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0203 exprivate char * conv_string_double(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0204 exprivate char * conv_string_carr(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0205 exprivate char * conv_string_int(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0206 exprivate char * conv_string_ptr(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0207 
0208 exprivate char * conv_carr_short(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0209 exprivate char * conv_carr_long(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0210 exprivate char * conv_carr_char(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0211 exprivate char * conv_carr_float(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0212 exprivate char * conv_carr_double(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0213 exprivate char * conv_carr_string(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0214 exprivate char * conv_carr_int(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0215 exprivate char * conv_carr_ptr(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0216 
0217 /* Int type operations */
0218 exprivate char * conv_int_short(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0219 exprivate char * conv_int_long(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0220 exprivate char * conv_int_char(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0221 exprivate char * conv_int_float(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0222 exprivate char * conv_int_double(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0223 exprivate char * conv_int_string(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0224 exprivate char * conv_int_carr(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0225 exprivate char * conv_int_ptr(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0226 
0227 /* ptr type operations */
0228 exprivate char * conv_ptr_short(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0229 exprivate char * conv_ptr_long(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0230 exprivate char * conv_ptr_char(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0231 exprivate char * conv_ptr_float(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0232 exprivate char * conv_ptr_double(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0233 exprivate char * conv_ptr_string(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0234 exprivate char * conv_ptr_carr(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0235 exprivate char * conv_ptr_int(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0236 
0237 /* Special conversation parts */
0238 exprivate char * conv_same(struct conv_type *t, int cnv_dir, char *input_buf, int in_len, char *output_buf , int *out_len);
0239 
0240 
0241 expublic conv_type_t G_conv_fn_short[] =
0242 {
0243     {BFLD_SHORT, BFLD_SHORT, conv_same},
0244     {BFLD_SHORT, BFLD_LONG, conv_short_long},
0245     {BFLD_SHORT, BFLD_CHAR, conv_short_char},
0246     {BFLD_SHORT, BFLD_FLOAT, conv_short_float},
0247     {BFLD_SHORT, BFLD_DOUBLE, conv_short_double},
0248     {BFLD_SHORT, BFLD_STRING, conv_short_string},
0249     {BFLD_SHORT, BFLD_CARRAY, conv_short_carr},
0250     {BFLD_SHORT, BFLD_INT, conv_short_int},
0251     {BFLD_SHORT, BFLD_RFU0, NULL},
0252     {BFLD_SHORT, BFLD_PTR, conv_short_ptr}
0253 };
0254 expublic conv_type_t G_conv_fn_long[] =
0255 {
0256     {BFLD_LONG, BFLD_SHORT, conv_long_short},
0257     {BFLD_LONG, BFLD_LONG, conv_same},
0258     {BFLD_LONG, BFLD_CHAR, conv_long_char},
0259     {BFLD_LONG, BFLD_FLOAT, conv_long_float},
0260     {BFLD_LONG, BFLD_DOUBLE, conv_long_double},
0261     {BFLD_LONG, BFLD_STRING, conv_long_string},
0262     {BFLD_LONG, BFLD_CARRAY, conv_long_carr},
0263     {BFLD_LONG, BFLD_INT, conv_long_int},
0264     {BFLD_LONG, BFLD_RFU0, NULL},
0265     {BFLD_LONG, BFLD_PTR, conv_long_ptr}
0266 };
0267 
0268 expublic conv_type_t G_conv_fn_char[] =
0269 {
0270 
0271     {BFLD_CHAR, BFLD_SHORT, conv_char_short},
0272     {BFLD_CHAR, BFLD_LONG, conv_char_long},
0273     {BFLD_CHAR, BFLD_CHAR, conv_same},
0274     {BFLD_CHAR, BFLD_FLOAT, conv_char_float},
0275     {BFLD_CHAR, BFLD_DOUBLE, conv_char_double},
0276     {BFLD_CHAR, BFLD_STRING, conv_char_string},
0277     {BFLD_CHAR, BFLD_CARRAY, conv_char_carr},
0278     {BFLD_CHAR, BFLD_INT, conv_char_int},
0279     {BFLD_CHAR, BFLD_RFU0, NULL},
0280     {BFLD_CHAR, BFLD_PTR, conv_char_ptr}
0281 };
0282 
0283 expublic conv_type_t G_conv_fn_float[] =
0284 {
0285     {BFLD_FLOAT, BFLD_SHORT, conv_float_short},
0286     {BFLD_FLOAT, BFLD_LONG, conv_float_long},
0287     {BFLD_FLOAT, BFLD_CHAR, conv_float_char},
0288     {BFLD_FLOAT, BFLD_FLOAT, conv_same},
0289     {BFLD_FLOAT, BFLD_DOUBLE, conv_float_double},
0290     {BFLD_FLOAT, BFLD_STRING, conv_float_string},
0291     {BFLD_FLOAT, BFLD_CARRAY, conv_float_carr},
0292     {BFLD_FLOAT, BFLD_INT, conv_float_int},
0293     {BFLD_FLOAT, BFLD_RFU0, NULL},
0294     {BFLD_FLOAT, BFLD_PTR, conv_float_ptr}
0295 };
0296 
0297 expublic conv_type_t G_conv_fn_double[] =
0298 {
0299     {BFLD_DOUBLE, BFLD_SHORT, conv_double_short},
0300     {BFLD_DOUBLE, BFLD_LONG, conv_double_long},
0301     {BFLD_DOUBLE, BFLD_CHAR, conv_double_char},
0302     {BFLD_DOUBLE, BFLD_FLOAT, conv_double_float},
0303     {BFLD_DOUBLE, BFLD_DOUBLE, conv_same},
0304     {BFLD_DOUBLE, BFLD_STRING, conv_double_string},
0305     {BFLD_DOUBLE, BFLD_CARRAY, conv_double_carr},
0306     {BFLD_DOUBLE, BFLD_INT, conv_double_int},
0307     {BFLD_DOUBLE, BFLD_RFU0, NULL},
0308     {BFLD_DOUBLE, BFLD_PTR, conv_double_ptr}
0309 };
0310 
0311 expublic conv_type_t G_conv_fn_string[] =
0312 {
0313     {BFLD_STRING, BFLD_SHORT, conv_string_short},
0314     {BFLD_STRING, BFLD_LONG, conv_string_long},
0315     {BFLD_STRING, BFLD_CHAR, conv_string_char},
0316     {BFLD_STRING, BFLD_FLOAT, conv_string_float},
0317     {BFLD_STRING, BFLD_DOUBLE, conv_string_double},
0318     {BFLD_STRING, BFLD_STRING, conv_same},
0319     {BFLD_STRING, BFLD_CARRAY, conv_string_carr},
0320     {BFLD_STRING, BFLD_INT, conv_string_int},
0321     {BFLD_STRING, BFLD_RFU0, NULL},
0322     {BFLD_STRING, BFLD_PTR, conv_string_ptr}
0323 };
0324 
0325 expublic conv_type_t G_conv_fn_carr[] =
0326 {
0327     {BFLD_CARRAY, BFLD_SHORT, conv_carr_short},
0328     {BFLD_CARRAY, BFLD_LONG, conv_carr_long},
0329     {BFLD_CARRAY, BFLD_CHAR, conv_carr_char},
0330     {BFLD_CARRAY, BFLD_FLOAT, conv_carr_float},
0331     {BFLD_CARRAY, BFLD_DOUBLE, conv_carr_double},
0332     {BFLD_CARRAY, BFLD_STRING, conv_carr_string},
0333     {BFLD_CARRAY, BFLD_CARRAY, conv_same},
0334     {BFLD_CARRAY, BFLD_INT, conv_carr_int},
0335     {BFLD_CARRAY, BFLD_RFU0, NULL},
0336     {BFLD_CARRAY, BFLD_PTR, conv_carr_ptr}
0337 };
0338 
0339 expublic conv_type_t G_conv_fn_int[] =
0340 {
0341     {BFLD_INT, BFLD_SHORT, conv_int_short},
0342     {BFLD_INT, BFLD_LONG, conv_int_long},
0343     {BFLD_INT, BFLD_CHAR, conv_int_char},
0344     {BFLD_INT, BFLD_FLOAT, conv_int_float},
0345     {BFLD_INT, BFLD_DOUBLE, conv_int_double},
0346     {BFLD_INT, BFLD_STRING, conv_int_string},
0347     {BFLD_INT, BFLD_CARRAY, conv_int_carr},
0348     {BFLD_INT, BFLD_INT, conv_same},
0349     {BFLD_INT, BFLD_RFU0, NULL},
0350     {BFLD_INT, BFLD_PTR, conv_int_ptr}
0351 };
0352 
0353 expublic conv_type_t G_conv_fn_ptr[] =
0354 {
0355     {BFLD_PTR, BFLD_SHORT, conv_ptr_short},
0356     {BFLD_PTR, BFLD_LONG, conv_ptr_long},
0357     {BFLD_PTR, BFLD_CHAR, conv_ptr_char},
0358     {BFLD_PTR, BFLD_FLOAT, conv_ptr_float},
0359     {BFLD_PTR, BFLD_DOUBLE, conv_ptr_double},
0360     {BFLD_PTR, BFLD_STRING, conv_ptr_string},
0361     {BFLD_PTR, BFLD_CARRAY, conv_ptr_carr},
0362     {BFLD_PTR, BFLD_INT, conv_ptr_carr},
0363     {BFLD_PTR, BFLD_RFU0, NULL},
0364     {BFLD_PTR, BFLD_PTR, conv_same},
0365 };
0366 
0367 /**
0368  * Get conversation buffer to use
0369  * @param in_from_type from data type
0370  * @param in_to_type to data type
0371  * @param in_temp_buf static temp buffer
0372  * @param in_data data buffer (pointer to data)
0373  * @param in_len input data length used for carray
0374  * @param out_alloc_buf pointer to dynamically allocated buffer
0375  * @param mode - see CB_MODE_*
0376  * @param extra_len - extra len to allocate for buffer (usable only in CB_MODE_ALLOC mode)
0377  * @return
0378  */
0379 expublic char * ndrx_ubf_get_cbuf(int in_from_type, int in_to_type,
0380                         char *in_temp_buf, char *in_data, int in_len,
0381                         char **out_alloc_buf,
0382                         int *alloc_size,
0383                         int mode,
0384                         int extra_len)
0385 {
0386     char *ret=NULL;
0387     dtype_ext1_t *dtype_ext1 = &G_dtype_ext1_map[in_to_type];
0388     dtype_str_t *dtype = &G_dtype_str_map[in_to_type];
0389 
0390     /*
0391      * We allocated extra +1 for EOS,  no matter of fact is it needed or not.
0392      * for simplicity.
0393      */
0394     /* Fixes Bgetalloc() 05/05/2016 mvitolin */
0395     if ((BFLD_CARRAY==in_from_type || BFLD_STRING==in_from_type) &&
0396             (BFLD_CARRAY==in_to_type || BFLD_STRING==in_to_type))
0397     {
0398         UBF_LOG(log_debug, "Conv: carray/string->carray/string - allocating buf, "
0399                                         "size: %d", in_len+1);
0400 
0401         if (CB_MODE_DEFAULT==mode)
0402         {
0403             /* 18/04/2013, seems fails on RPI.
0404              * Fix the issue with invalid len for strings passed in.
0405              */
0406             if (BFLD_STRING==in_from_type)
0407             {
0408                 in_len = strlen(in_data);
0409             }
0410             /* if target is string, then we need extra */
0411             if (NULL==(*out_alloc_buf = NDRX_MALLOC(in_len+1)))
0412             {
0413                 ndrx_Bset_error(BMALLOC);
0414                 return NULL; /* <<<< RETURN!!! */
0415             }
0416             ret=*out_alloc_buf;
0417             /* Set the output size! */
0418             *alloc_size=in_len+1;
0419         }
0420         else if (CB_MODE_TEMPSPACE==mode)
0421         {
0422             /* Using temporary buffer space */
0423             if (NULL==(ret = dtype_ext1->p_tbuf(dtype_ext1, in_len+1)))
0424             {
0425                 return NULL; /* <<<< RETURN!!! */
0426             }
0427             /* Set the output size! */
0428             *alloc_size=in_len+1;
0429         }
0430         else if (CB_MODE_ALLOC==mode)
0431         {
0432             int tmp_len = in_len+1+extra_len;
0433             /* Using temporary buffer space */
0434             if (NULL==(ret = dtype_ext1->p_talloc(dtype_ext1, &tmp_len)))
0435             {
0436                 return NULL; /* <<<< RETURN!!! */
0437             }
0438             /* Set the output size! */
0439             *alloc_size=tmp_len;
0440             *out_alloc_buf=ret;
0441         }
0442     }
0443     else
0444     {
0445         UBF_LOG(log_debug, "Conv: using temp buf mode: %d", mode);
0446         if (CB_MODE_DEFAULT==mode)
0447         {
0448             /* Not sure do we need to return alloc_size here? */
0449             ret=in_temp_buf;
0450             *alloc_size=CF_TEMP_BUF_MAX;
0451         }
0452         else if (CB_MODE_TEMPSPACE==mode)
0453         {
0454             /* Using temporary buffer space */
0455             if (NULL==(ret = dtype_ext1->p_tbuf(dtype_ext1, CF_TEMP_BUF_MAX)))
0456             {
0457                 return NULL; /* <<<< RETURN!!! */
0458             }
0459             /* Set the output size! */
0460             /* Bug #544 - previously was  dtype->size which could be 0 */
0461             *alloc_size=CF_TEMP_BUF_MAX;
0462         }
0463         else if (CB_MODE_ALLOC==mode)
0464         {
0465             int tmp_len;
0466             
0467             /* Using temporary buffer space -> in case of PTR/UBF/VIEW use
0468              * originally estimated size. There is no other use there excep
0469              * Bgetalloc()
0470              */
0471             if (BFLD_UBF==in_from_type || BFLD_VIEW==in_from_type)
0472             {
0473                 tmp_len = in_len+extra_len;
0474             }
0475             else
0476             {
0477                 tmp_len = CF_TEMP_BUF_MAX+extra_len;
0478             }
0479             
0480             if (NULL==(ret = dtype_ext1->p_talloc(dtype_ext1, &tmp_len)))
0481             {
0482                 return NULL; /* <<<< RETURN!!! */
0483             }
0484             /* Set the output size! */
0485             *alloc_size=tmp_len;
0486             *out_alloc_buf=ret;
0487         }
0488     }
0489     
0490     return ret;
0491 }
0492 
0493 /**
0494  * Convert data types,
0495  * @param t
0496  * @param ibuf
0497  * @param ilen
0498  * @param olen
0499  * @return
0500  */
0501 expublic char * ndrx_ubf_convert(int from_type, int cnv_dir, char *input_buf, int in_len,
0502                         int to_type, char *output_buf , int *out_len)
0503 {
0504     conv_type_t* conv_tab = NULL;
0505     conv_type_t *conv_entry = NULL;
0506     char *ret=NULL;
0507 
0508     switch (from_type)
0509     {
0510         case BFLD_SHORT:
0511             conv_tab = (conv_type_t*)&G_conv_fn_short;
0512             break;
0513         case BFLD_LONG:
0514             conv_tab = (conv_type_t*)&G_conv_fn_long;
0515             break;
0516         case BFLD_CHAR:
0517             conv_tab = (conv_type_t*)&G_conv_fn_char;
0518             break;
0519         case BFLD_FLOAT:
0520             conv_tab = (conv_type_t*)&G_conv_fn_float;
0521             break;
0522         case BFLD_DOUBLE:
0523             conv_tab = (conv_type_t*)&G_conv_fn_double;
0524             break;
0525         case BFLD_STRING:
0526             conv_tab = (conv_type_t*)&G_conv_fn_string;
0527             break;
0528         case BFLD_CARRAY:
0529             conv_tab = (conv_type_t*)&G_conv_fn_carr;
0530             break;
0531     case BFLD_INT:
0532             conv_tab = (conv_type_t*)&G_conv_fn_int;
0533             break;
0534         case BFLD_PTR:
0535             conv_tab = (conv_type_t*)&G_conv_fn_ptr;
0536             break;
0537         default:
0538             /* ERR - invalid type */
0539             ret=NULL;
0540             ndrx_Bset_error_fmt(BTYPERR, "Bad from type %d", from_type);
0541             break;
0542     }
0543 
0544     if (NULL!=conv_tab)
0545     {
0546         UBF_LOG(log_debug, "Converting from %d to %d",
0547                                         from_type, to_type);
0548         conv_entry = &conv_tab[to_type];
0549         ret=conv_entry->conv_fn(conv_entry, cnv_dir, input_buf, in_len, output_buf, out_len);
0550     }
0551 
0552     return ret;
0553 }
0554 
0555 /**
0556  * Returns the same data, but copied into different buffer.
0557  * Does buffer length check.
0558  */
0559 exprivate char * conv_same(struct conv_type *t, int cnv_dir, char *input_buf, 
0560               int in_len, char *output_buf , int *out_len)
0561 {
0562     dtype_str_t *dtype = &G_dtype_str_map[t->to_type];
0563     int real_data;
0564     int size = dtype->p_get_data_size(dtype, input_buf, in_len, &real_data);
0565     
0566     /* Check buffer sizes */
0567 
0568     if (NULL!=out_len && real_data > *out_len)
0569     {
0570         ndrx_Bset_error_fmt(BNOSPACE, "data size: %d specified :%d", 
0571                 real_data, *out_len);
0572         return NULL;
0573     }
0574 
0575     if (NULL!=out_len)
0576         *out_len = real_data;
0577 
0578     /* Copy off the buffer data */
0579     memcpy(output_buf, input_buf, real_data);
0580 
0581     return output_buf;
0582 }
0583 
0584 /********************************* SHORT ***************************************/
0585 exprivate char * conv_short_long(struct conv_type *t, int cnv_dir, char *input_buf, 
0586                 int in_len, char *output_buf , int *out_len)
0587 {
0588     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0589     short *ptr = (short *)input_buf;
0590     long *l = (long *)output_buf;
0591 
0592     /* Check the data type lengths */
0593     CHECK_OUTPUT_BUF_SIZE;
0594 
0595     if (NULL!=out_len)
0596         *out_len = to->size;
0597 
0598     *l = (long)*ptr;
0599 
0600     return output_buf;
0601 }
0602 
0603 exprivate char * conv_short_char(struct conv_type *t, int cnv_dir, char *input_buf, 
0604                 int in_len, char *output_buf , int *out_len)
0605 {
0606     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0607     short *ptr = (short *)input_buf;
0608     unsigned char *c = (unsigned char *)output_buf;
0609 
0610     /* Check the data type lengths */
0611     CHECK_OUTPUT_BUF_SIZE;
0612 
0613     if (NULL!=out_len)
0614         *out_len = to->size;
0615 
0616     *c = (char) *ptr;
0617 
0618     return output_buf;
0619 }
0620 
0621 exprivate char * conv_short_float(struct conv_type *t, int cnv_dir, char *input_buf, 
0622                  int in_len, char *output_buf , int *out_len)
0623 {
0624     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0625     short *ptr = (short *)input_buf;
0626     float *f = (float *)output_buf;
0627 
0628     /* Check the data type lengths */
0629     CHECK_OUTPUT_BUF_SIZE;
0630 
0631     if (NULL!=out_len)
0632         *out_len = to->size;
0633 
0634     *f = (float) *ptr;
0635 
0636     return output_buf;
0637 }
0638 
0639 exprivate char * conv_short_double(struct conv_type *t, int cnv_dir, char *input_buf, 
0640                   int in_len, char *output_buf , int *out_len)
0641 {
0642     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0643     short *ptr = (short *)input_buf;
0644     double *d = (double *)output_buf;
0645 
0646     /* Check the data type len for output */
0647     CHECK_OUTPUT_BUF_SIZE;
0648 
0649     if (NULL!=out_len)
0650         *out_len = to->size;
0651 
0652     *d = (double) *ptr;
0653 
0654     return output_buf;
0655 }
0656 
0657 exprivate char * conv_short_string(struct conv_type *t, int cnv_dir, char *input_buf, 
0658                   int in_len, char *output_buf , int *out_len)
0659 {
0660     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0661     short *ptr = (short *)input_buf;
0662     int len;
0663 
0664     CONV_TO_STRING("%hd", short);
0665 
0666     return output_buf;
0667 }
0668 
0669 exprivate char * conv_short_carr(struct conv_type *t, int cnv_dir, char *input_buf, 
0670                 int in_len, char *output_buf , int *out_len)
0671 {
0672     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0673     short *ptr = (short *)input_buf;
0674     int len;
0675 
0676     CONV_TO_CARRAY("%hd", short);
0677 
0678     return output_buf;
0679 }
0680 
0681 exprivate char * conv_short_int(struct conv_type *t, int cnv_dir, char *input_buf, 
0682                 int in_len, char *output_buf , int *out_len)
0683 {
0684     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0685     short *ptr = (short *)input_buf;
0686     int *l = (int *)output_buf;
0687 
0688     /* Check the data type lengths */
0689     CHECK_OUTPUT_BUF_SIZE;
0690 
0691     if (NULL!=out_len)
0692         *out_len = to->size;
0693 
0694     *l = (int)*ptr;
0695 
0696     return output_buf;
0697 }
0698 
0699 exprivate char * conv_short_ptr(struct conv_type *t, int cnv_dir, char *input_buf, 
0700                 int in_len, char *output_buf , int *out_len)
0701 {
0702     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0703     short *ptr = (short *)input_buf;
0704     void** p = (void **)output_buf;
0705 
0706     /* Check the data type lengths */
0707     CHECK_OUTPUT_BUF_SIZE;
0708 
0709     if (NULL!=out_len)
0710         *out_len = to->size;
0711 
0712     *p = (void*)(ndrx_longptr_t)*ptr;
0713 
0714     return output_buf;
0715 }
0716 
0717 /********************************* LONG ****************************************/
0718 exprivate char * conv_long_short(struct conv_type *t, int cnv_dir, char *input_buf, 
0719                 int in_len, char *output_buf , int *out_len)
0720 {
0721     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0722     long *ptr = (long *)input_buf;
0723     short *l = (short *)output_buf;
0724 
0725     /* Check the data type len for output */
0726     CHECK_OUTPUT_BUF_SIZE;
0727 
0728     if (NULL!=out_len)
0729         *out_len = to->size;
0730 
0731     *l = (short)*ptr;
0732 
0733     return output_buf;
0734 }
0735 
0736 exprivate char * conv_long_char(struct conv_type *t, int cnv_dir, char *input_buf, 
0737                    int in_len, char *output_buf , int *out_len)
0738 {
0739     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0740     long *ptr = (long *)input_buf;
0741     unsigned char *c = (unsigned char *)output_buf;
0742 
0743     /* Check the data type len for output */
0744     CHECK_OUTPUT_BUF_SIZE;
0745 
0746     if (NULL!=out_len)
0747         *out_len = to->size;
0748 
0749     *c = (char) *ptr;
0750 
0751     return output_buf;
0752 }
0753 
0754 exprivate char * conv_long_float(struct conv_type *t, int cnv_dir, char *input_buf, 
0755                 int in_len, char *output_buf , int *out_len)
0756 {
0757     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0758     long *ptr = (long *)input_buf;
0759     float *f = (float *)output_buf;
0760 
0761     /* Check the data type len for output */
0762     CHECK_OUTPUT_BUF_SIZE;
0763 
0764     if (NULL!=out_len)
0765         *out_len = to->size;
0766 
0767     *f = (float) *ptr;
0768 
0769     return output_buf;
0770 }
0771 
0772 exprivate char * conv_long_double(struct conv_type *t, int cnv_dir, char *input_buf, 
0773                  int in_len, char *output_buf , int *out_len)
0774 {
0775     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0776     long *ptr = (long *)input_buf;
0777     double *d = (double *)output_buf;
0778 
0779     /* Check the data type len for output */
0780     CHECK_OUTPUT_BUF_SIZE;
0781 
0782     if (NULL!=out_len)
0783         *out_len = to->size;
0784 
0785     *d = (double) *ptr;
0786 
0787     return output_buf;
0788 }
0789 
0790 exprivate char * conv_long_string(struct conv_type *t, int cnv_dir, char *input_buf, 
0791                  int in_len, char *output_buf , int *out_len)
0792 {
0793     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0794     long *ptr = (long *)input_buf;
0795     int len;
0796 
0797     CONV_TO_STRING("%ld", long);
0798 
0799     return output_buf;
0800 }
0801 
0802 exprivate char * conv_long_carr(struct conv_type *t, int cnv_dir, char *input_buf, 
0803                    int in_len, char *output_buf , int *out_len)
0804 {
0805     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0806     long *ptr = (long *)input_buf;
0807     long len;
0808     
0809     CONV_TO_CARRAY("%ld", long);
0810 
0811     return output_buf;
0812 }
0813 
0814 exprivate char * conv_long_int(struct conv_type *t, int cnv_dir, char *input_buf, 
0815                 int in_len, char *output_buf , int *out_len)
0816 {
0817     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0818     long *ptr = (long *)input_buf;
0819     int *i = (int *)output_buf;
0820 
0821     /* Check the data type len for output */
0822     CHECK_OUTPUT_BUF_SIZE;
0823 
0824     if (NULL!=out_len)
0825         *out_len = to->size;
0826 
0827     *i = (int)*ptr;
0828 
0829     return output_buf;
0830 }
0831 
0832 exprivate char * conv_long_ptr(struct conv_type *t, int cnv_dir, char *input_buf, 
0833                 int in_len, char *output_buf , int *out_len)
0834 {
0835     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0836     long *ptr = (long *)input_buf;
0837     void **p = (void **)output_buf;
0838 
0839     /* Check the data type len for output */
0840     CHECK_OUTPUT_BUF_SIZE;
0841 
0842     if (NULL!=out_len)
0843         *out_len = to->size;
0844 
0845     *p = (void *)(ndrx_longptr_t)*ptr;
0846 
0847     return output_buf;
0848 }
0849 
0850 
0851 /********************************* BFLD_CHAR ***********************************/
0852 exprivate char * conv_char_short(struct conv_type *t, int cnv_dir, char *input_buf, 
0853                 int in_len, char *output_buf , int *out_len)
0854 {
0855     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0856     unsigned char *ptr = (unsigned char *)input_buf;
0857     short *l = (short *)output_buf;
0858 
0859     CHECK_OUTPUT_BUF_SIZE;
0860 
0861     if (NULL!=out_len)
0862         *out_len = to->size;
0863 
0864     *l = (short)*ptr;
0865 
0866     return output_buf;
0867 }
0868 
0869 exprivate char * conv_char_long(struct conv_type *t, int cnv_dir, char *input_buf, 
0870                    int in_len, char *output_buf , int *out_len)
0871 {
0872     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0873     unsigned char *ptr = (unsigned char *)input_buf;
0874     long *l = (long *)output_buf;
0875 
0876     CHECK_OUTPUT_BUF_SIZE;
0877 
0878     if (NULL!=out_len)
0879         *out_len = to->size;
0880 
0881     *l = (long) *ptr;
0882 
0883     return output_buf;
0884 }
0885 
0886 exprivate char * conv_char_float(struct conv_type *t, int cnv_dir, char *input_buf, 
0887                 int in_len, char *output_buf , int *out_len)
0888 {
0889     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0890     unsigned char *ptr = (unsigned char *)input_buf;
0891     float *f = (float *)output_buf;
0892 
0893     CHECK_OUTPUT_BUF_SIZE;
0894 
0895     if (NULL!=out_len)
0896         *out_len = to->size;
0897 
0898     *f = (float) *ptr;
0899 
0900     return output_buf;
0901 }
0902 
0903 exprivate char * conv_char_double(struct conv_type *t, int cnv_dir, char *input_buf, 
0904                  int in_len, char *output_buf , int *out_len)
0905 {
0906     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0907     unsigned char *ptr = (unsigned char *)input_buf;
0908     double *d = (double *)output_buf;
0909 
0910     CHECK_OUTPUT_BUF_SIZE;
0911 
0912     if (NULL!=out_len)
0913         *out_len = to->size;
0914 
0915     *d = (double) *ptr;
0916 
0917     return output_buf;
0918 }
0919 
0920 exprivate char * conv_char_string(struct conv_type *t, int cnv_dir, char *input_buf, 
0921                  int in_len, char *output_buf , int *out_len)
0922 {
0923     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0924     unsigned char *ptr = (unsigned char *)input_buf;
0925     int len;
0926 
0927     if (CNV_DIR_OUT==cnv_dir && NULL!=out_len &&  *out_len<2)
0928     {
0929         ndrx_Bset_error_fmt(BNOSPACE, "data size: 2 specified :%d", len, *out_len);
0930         return NULL; /* <<< RETURN */
0931     }
0932     else
0933     {
0934         output_buf[0] = ptr[0];
0935         output_buf[1] = EXEOS;
0936 
0937         if (NULL!=out_len)
0938             *out_len = 2;
0939 
0940     }
0941 
0942     return output_buf;
0943 }
0944 
0945 exprivate char * conv_char_carr(struct conv_type *t, int cnv_dir, char *input_buf, 
0946                    int in_len, char *output_buf , int *out_len)
0947 {
0948     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0949     unsigned char *ptr = (unsigned char *)input_buf;
0950     int len;
0951     
0952     if (CNV_DIR_OUT==cnv_dir && NULL!=out_len &&  *out_len<1)
0953     {
0954         ndrx_Bset_error_fmt(BNOSPACE, "data size: 1 specified :%d", len, *out_len);
0955         return NULL; /* <<< RETURN */
0956     }
0957     else
0958     {
0959         if (NULL!=out_len)
0960             *out_len = 1;
0961         output_buf[0] = ptr[0];
0962     }
0963 
0964     return output_buf;
0965 }
0966 
0967 exprivate char * conv_char_int(struct conv_type *t, int cnv_dir, char *input_buf, 
0968                    int in_len, char *output_buf , int *out_len)
0969 {
0970     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0971     unsigned char *ptr = (unsigned char *)input_buf;
0972     int *i = (int *)output_buf;
0973 
0974     CHECK_OUTPUT_BUF_SIZE;
0975 
0976     if (NULL!=out_len)
0977         *out_len = to->size;
0978 
0979     *i = (int) *ptr;
0980 
0981     return output_buf;
0982 }
0983 
0984 exprivate char * conv_char_ptr(struct conv_type *t, int cnv_dir, char *input_buf, 
0985                    int in_len, char *output_buf , int *out_len)
0986 {
0987     dtype_str_t *to = &G_dtype_str_map[t->to_type];
0988     unsigned char *ptr = (unsigned char *)input_buf;
0989     void **p = (void **)output_buf;
0990 
0991     CHECK_OUTPUT_BUF_SIZE;
0992 
0993     if (NULL!=out_len)
0994         *out_len = to->size;
0995 
0996     *p = (void *)(ndrx_longptr_t) *ptr;
0997 
0998     return output_buf;
0999 }
1000 
1001 /********************************* BFLD_FLOAT ***********************************/
1002 exprivate char * conv_float_short(struct conv_type *t, int cnv_dir, char *input_buf, 
1003                  int in_len, char *output_buf , int *out_len)
1004 {
1005     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1006     float *ptr = (float *)input_buf;
1007     short *l = (short *)output_buf;
1008 
1009     CHECK_OUTPUT_BUF_SIZE;
1010 
1011     if (NULL!=out_len)
1012         *out_len = to->size;
1013 
1014     *l = (short)*ptr;
1015 
1016     return output_buf;
1017 }
1018 
1019 exprivate char * conv_float_char(struct conv_type *t, int cnv_dir, char *input_buf, 
1020                 int in_len, char *output_buf , int *out_len)
1021 {
1022     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1023     float *ptr = (float *)input_buf;
1024     unsigned char *c = (unsigned char *)output_buf;
1025 
1026     CHECK_OUTPUT_BUF_SIZE;
1027 
1028     if (NULL!=out_len)
1029         *out_len = to->size;
1030 
1031     
1032     *c = (short) *ptr;
1033 
1034     return output_buf;
1035 }
1036 
1037 exprivate char * conv_float_double(struct conv_type *t, int cnv_dir, char *input_buf, 
1038                   int in_len, char *output_buf , int *out_len)
1039 {
1040     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1041     float *ptr = (float *)input_buf;
1042     double *d = (double *)output_buf;
1043 
1044     CHECK_OUTPUT_BUF_SIZE;
1045 
1046     if (NULL!=out_len)
1047         *out_len = to->size;
1048 
1049     *d = (double) *ptr;
1050 
1051     return output_buf;
1052 }
1053 
1054 exprivate char * conv_float_long(struct conv_type *t, int cnv_dir, char *input_buf, 
1055                 int in_len, char *output_buf , int *out_len)
1056 {
1057     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1058     float *ptr = (float *)input_buf;
1059     long *d = (long *)output_buf;
1060 
1061     CHECK_OUTPUT_BUF_SIZE;
1062 
1063     if (NULL!=out_len)
1064         *out_len = to->size;
1065 
1066     *d = (long) *ptr;
1067 
1068     return output_buf;
1069 }
1070 
1071 exprivate char * conv_float_string(struct conv_type *t, int cnv_dir, char *input_buf, 
1072                   int in_len, char *output_buf , int *out_len)
1073 {
1074     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1075     float *ptr = (float *)input_buf;
1076     int len;
1077     char fmt[]="%.0lf";
1078     fmt[2]+=FLOAT_RESOLUTION;
1079 
1080     CONV_TO_STRING(fmt, float);
1081 
1082     return output_buf;
1083 }
1084 
1085 exprivate char * conv_float_carr(struct conv_type *t, int cnv_dir, char *input_buf, 
1086                 int in_len, char *output_buf , int *out_len)
1087 {
1088     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1089     float *ptr = (float *)input_buf;
1090     int len;
1091     char fmt[]="%.0lf";
1092     fmt[2]+=FLOAT_RESOLUTION;
1093     
1094     CONV_TO_CARRAY(fmt, float);
1095 
1096     return output_buf;
1097 }
1098 
1099 exprivate char * conv_float_int(struct conv_type *t, int cnv_dir, char *input_buf, 
1100                  int in_len, char *output_buf , int *out_len)
1101 {
1102     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1103     float *ptr = (float *)input_buf;
1104     int *i = (int *)output_buf;
1105 
1106     CHECK_OUTPUT_BUF_SIZE;
1107 
1108     if (NULL!=out_len)
1109         *out_len = to->size;
1110 
1111     *i = (int)*ptr;
1112 
1113     return output_buf;
1114 }
1115 
1116 exprivate char * conv_float_ptr(struct conv_type *t, int cnv_dir, char *input_buf, 
1117                  int in_len, char *output_buf , int *out_len)
1118 {
1119     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1120     float *ptr = (float *)input_buf;
1121     void **p = (void **)output_buf;
1122 
1123     CHECK_OUTPUT_BUF_SIZE;
1124 
1125     if (NULL!=out_len)
1126         *out_len = to->size;
1127 
1128     *p = (void*)(ndrx_longptr_t)*ptr;
1129 
1130     return output_buf;
1131 }
1132 
1133 /********************************* BFLD_DOUBLE ***********************************/
1134 exprivate char * conv_double_short(struct conv_type *t, int cnv_dir, char *input_buf, 
1135                   int in_len, char *output_buf , int *out_len)
1136 {
1137     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1138     double *ptr = (double *)input_buf;
1139     short *l = (short *)output_buf;
1140 
1141 
1142     CHECK_OUTPUT_BUF_SIZE;
1143 
1144     if (NULL!=out_len)
1145         *out_len = to->size;
1146 
1147     *l = (short)*ptr;
1148 
1149     return output_buf;
1150 }
1151 
1152 exprivate char * conv_double_char(struct conv_type *t, int cnv_dir, char *input_buf, 
1153                  int in_len, char *output_buf , int *out_len)
1154 {
1155     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1156     double *ptr = (double *)input_buf;
1157     unsigned char *c = (unsigned char *)output_buf;
1158 
1159     CHECK_OUTPUT_BUF_SIZE;
1160 
1161     if (NULL!=out_len)
1162         *out_len = to->size;
1163 
1164     *c = (char) *ptr;
1165 
1166     return output_buf;
1167 }
1168 
1169 exprivate char * conv_double_float(struct conv_type *t, int cnv_dir, char *input_buf, 
1170                   int in_len, char *output_buf , int *out_len)
1171 {
1172     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1173     double *ptr = (double *)input_buf;
1174     float *f = (float *)output_buf;
1175 
1176     CHECK_OUTPUT_BUF_SIZE;
1177 
1178     if (NULL!=out_len)
1179         *out_len = to->size;
1180 
1181     *f = (float) *ptr;
1182 
1183     return output_buf;
1184 }
1185 
1186 exprivate char * conv_double_long(struct conv_type *t, int cnv_dir, char *input_buf, 
1187                  int in_len, char *output_buf , int *out_len)
1188 {
1189     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1190     double *ptr = (double *)input_buf;
1191     long *d = (long *)output_buf;
1192 
1193     CHECK_OUTPUT_BUF_SIZE;
1194 
1195     if (NULL!=out_len)
1196         *out_len = to->size;
1197 
1198     *d = (long) *ptr;
1199 
1200     return output_buf;
1201 }
1202 
1203 exprivate char * conv_double_string(struct conv_type *t, int cnv_dir, char *input_buf, 
1204                    int in_len, char *output_buf , int *out_len)
1205 {
1206     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1207     double *ptr = (double *)input_buf;
1208     int len;
1209     char fmt[]="%.0lf";
1210     fmt[2]+=DOUBLE_RESOLUTION;
1211 
1212     CONV_TO_STRING(fmt, double);
1213 
1214     return output_buf;
1215 }
1216 
1217 exprivate char * conv_double_carr(struct conv_type *t, int cnv_dir, char *input_buf, 
1218                  int in_len, char *output_buf , int *out_len)
1219 {
1220     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1221     double *ptr = (double *)input_buf;
1222     int len;
1223     char fmt[]="%.0lf";
1224     fmt[2]+=DOUBLE_RESOLUTION;
1225     
1226     CONV_TO_CARRAY(fmt, double);
1227 
1228     return output_buf;
1229 }
1230 
1231 exprivate char * conv_double_int(struct conv_type *t, int cnv_dir, char *input_buf, 
1232                   int in_len, char *output_buf , int *out_len)
1233 {
1234     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1235     double *ptr = (double *)input_buf;
1236     int *i = (int *)output_buf;
1237 
1238 
1239     CHECK_OUTPUT_BUF_SIZE;
1240 
1241     if (NULL!=out_len)
1242         *out_len = to->size;
1243 
1244     *i = (int)*ptr;
1245 
1246     return output_buf;
1247 }
1248 
1249 exprivate char * conv_double_ptr(struct conv_type *t, int cnv_dir, char *input_buf, 
1250                   int in_len, char *output_buf , int *out_len)
1251 {
1252     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1253     double *ptr = (double *)input_buf;
1254     void **p = (void **)output_buf;
1255 
1256 
1257     CHECK_OUTPUT_BUF_SIZE;
1258 
1259     if (NULL!=out_len)
1260         *out_len = to->size;
1261 
1262     *p = (void *)(ndrx_longptr_t)*ptr;
1263 
1264     return output_buf;
1265 }
1266 
1267 
1268 /********************************* BFLD_STRING ***********************************/
1269 exprivate char * conv_string_short(struct conv_type *t, int cnv_dir, char *input_buf, 
1270                   int in_len, char *output_buf , int *out_len)
1271 {
1272     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1273     char *ptr = (char *)input_buf;
1274     short *s = (short *)output_buf;
1275 
1276     CHECK_OUTPUT_BUF_SIZE;
1277 
1278     if (NULL!=out_len)
1279         *out_len = to->size;
1280 
1281     *s = atoi(ptr); /* Bug #210 */
1282 
1283     return output_buf;
1284 }
1285 
1286 exprivate char * conv_string_char(struct conv_type *t, int cnv_dir, char *input_buf, 
1287                  int in_len, char *output_buf , int *out_len)
1288 {
1289     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1290     char *ptr = (char *)input_buf;
1291     unsigned char *c = (unsigned char *)output_buf;
1292 
1293     CHECK_OUTPUT_BUF_SIZE;
1294 
1295     if (NULL!=out_len)
1296         *out_len = to->size;
1297 
1298      *c = ptr[0];
1299 
1300     return output_buf;
1301 }
1302 
1303 exprivate char * conv_string_float(struct conv_type *t, int cnv_dir, char *input_buf, 
1304                   int in_len, char *output_buf , int *out_len)
1305 {
1306     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1307     char *ptr = (char *)input_buf;
1308     float *f = (float *)output_buf;
1309 
1310     CHECK_OUTPUT_BUF_SIZE;
1311 
1312     if (NULL!=out_len)
1313         *out_len = to->size;
1314 
1315     *f = atof(ptr);
1316 
1317     return output_buf;
1318 }
1319 
1320 exprivate char * conv_string_long(struct conv_type *t, int cnv_dir, char *input_buf, 
1321                  int in_len, char *output_buf , int *out_len)
1322 {
1323     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1324     char *ptr = (char *)input_buf;
1325     long *d = (long *)output_buf;
1326 
1327     CHECK_OUTPUT_BUF_SIZE;
1328 
1329     if (NULL!=out_len)
1330         *out_len = to->size;
1331 
1332     *d = atol(ptr);
1333 
1334     return output_buf;
1335 }
1336 
1337 exprivate char * conv_string_double(struct conv_type *t, int cnv_dir, char *input_buf, 
1338                    int in_len, char *output_buf , int *out_len)
1339 {
1340     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1341     char *ptr = (char *)input_buf;
1342     double *d = (double *)output_buf;
1343 
1344     CHECK_OUTPUT_BUF_SIZE;
1345 
1346     if (NULL!=out_len)
1347         *out_len = to->size;
1348 
1349     *d = atof(ptr);
1350 
1351     return output_buf;
1352 }
1353 
1354 exprivate char * conv_string_carr(struct conv_type *t, int cnv_dir, char *input_buf, 
1355                  int in_len, char *output_buf , int *out_len)
1356 {
1357     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1358     int input_strlen = strlen(input_buf);
1359 
1360     /* Check output size! Check only outgoing conv. Because
1361      * on incoming dest buffer should be fine!*/
1362     if (CNV_DIR_OUT==cnv_dir && NULL!=out_len && *out_len > 0 && *out_len < input_strlen)
1363     {
1364         ndrx_Bset_error_fmt(BNOSPACE, "data size: %d specified :%d", input_strlen, *out_len);
1365         return NULL; /*<<<< RETURN!*/
1366     }
1367 
1368     NDRX_STRNCPY(output_buf, input_buf, input_strlen);
1369 
1370     if (NULL!=out_len)
1371         *out_len = input_strlen;
1372 
1373     return output_buf;
1374 }
1375 
1376 exprivate char * conv_string_int(struct conv_type *t, int cnv_dir, char *input_buf, 
1377                   int in_len, char *output_buf , int *out_len)
1378 {
1379     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1380     char *ptr = (char *)input_buf;
1381     int *i = (int *)output_buf;
1382 
1383     CHECK_OUTPUT_BUF_SIZE;
1384 
1385     if (NULL!=out_len)
1386         *out_len = to->size;
1387 
1388     *i = atoi(ptr);
1389 
1390     return output_buf;
1391 }
1392 
1393 exprivate char * conv_string_ptr(struct conv_type *t, int cnv_dir, char *input_buf, 
1394                   int in_len, char *output_buf , int *out_len)
1395 {
1396     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1397     char *ptr = (char *)input_buf;
1398     void **p = (void **)output_buf;
1399 
1400     CHECK_OUTPUT_BUF_SIZE;
1401 
1402     if (NULL!=out_len)
1403         *out_len = to->size;
1404     
1405     if (0!=strncmp(ptr, "0x", 2))
1406     {
1407         /* set to 0 if format not matching */
1408         *((ndrx_longptr_t *)p) = 0;
1409     }
1410     else
1411     {
1412         /* LP64 */
1413         sscanf (ptr, "0x" NDRX_LONGPTR_HEX, (ndrx_longptr_t *)p);
1414     }
1415     
1416     return output_buf;
1417 }
1418 
1419 /********************************* BFLD_CARRAY ***********************************/
1420 exprivate char * conv_carr_short(struct conv_type *t, int cnv_dir, char *input_buf,
1421                 int in_len, char *output_buf , int *out_len)
1422 {
1423     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1424     char *ptr = (char *)input_buf;
1425     short *s = (short *)output_buf;
1426     CARR_TEMP_BUF;
1427     
1428     CHECK_OUTPUT_BUF_SIZE;
1429 
1430     if (NULL!=out_len)
1431         *out_len = to->size;
1432 
1433     *s = atoi(tmp); /* Bug #210 */
1434 
1435     return output_buf;
1436 }
1437 
1438 exprivate char * conv_carr_char(struct conv_type *t, int cnv_dir, char *input_buf, 
1439                    int in_len, char *output_buf , int *out_len)
1440 {
1441     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1442     char *ptr = (char *)input_buf;
1443     unsigned char *c = (unsigned char *)output_buf;
1444     CHECK_OUTPUT_BUF_SIZE;
1445 
1446     if (NULL!=out_len)
1447         *out_len = to->size;
1448 
1449      *c = ptr[0];
1450 
1451     return output_buf;
1452 }
1453 
1454 exprivate char * conv_carr_float(struct conv_type *t, int cnv_dir, char *input_buf, 
1455                 int in_len, char *output_buf , int *out_len)
1456 {
1457     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1458     float *f = (float *)output_buf;
1459     CARR_TEMP_BUF;
1460     CHECK_OUTPUT_BUF_SIZE;
1461     
1462     if (NULL!=out_len)
1463         *out_len = to->size;
1464 
1465     *f = atof(tmp);
1466 
1467     return output_buf;
1468 }
1469 
1470 exprivate char * conv_carr_long(struct conv_type *t, int cnv_dir, char *input_buf, 
1471                    int in_len, char *output_buf , int *out_len)
1472 {
1473     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1474     char *ptr = (char *)input_buf;
1475     long *d = (long *)output_buf;
1476     CARR_TEMP_BUF;
1477     CHECK_OUTPUT_BUF_SIZE;
1478     
1479     if (NULL!=out_len)
1480         *out_len = to->size;
1481 
1482     *d = atol(tmp);
1483 
1484     return output_buf;
1485 }
1486 
1487 exprivate char * conv_carr_double(struct conv_type *t, int cnv_dir, char *input_buf, 
1488                  int in_len, char *output_buf , int *out_len)
1489 {
1490     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1491     char *ptr = (char *)input_buf;
1492     double *d = (double *)output_buf;
1493     CARR_TEMP_BUF;
1494     CHECK_OUTPUT_BUF_SIZE;
1495     
1496     if (NULL!=out_len)
1497         *out_len = to->size;
1498 
1499     *d = atof(tmp);
1500 
1501     return output_buf;
1502 }
1503 
1504 exprivate char * conv_carr_string(struct conv_type *t, int cnv_dir, char *input_buf, 
1505                  int in_len, char *output_buf , int *out_len)
1506 {
1507     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1508     int input_carrlen = in_len;
1509 
1510     /* Check output size! */
1511      /* Now we include EOS */
1512     if (CNV_DIR_OUT==cnv_dir && NULL!=out_len && *out_len > 0 && *out_len < input_carrlen+1)
1513     {
1514         ndrx_Bset_error_fmt(BNOSPACE, "data size: %d specified :%d", input_carrlen+1, *out_len);
1515         return NULL; /*<<<< RETURN!*/
1516     }
1517 
1518     NDRX_STRNCPY_SRC(output_buf, input_buf, input_carrlen);
1519     output_buf[input_carrlen] = EXEOS;
1520     
1521     if (NULL!=out_len)
1522         *out_len = strlen(output_buf)+1; /* We have to count in EOS! */
1523 
1524     return output_buf;
1525 }
1526 
1527 exprivate char * conv_carr_int(struct conv_type *t, int cnv_dir, char *input_buf,
1528                 int in_len, char *output_buf , int *out_len)
1529 {
1530     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1531     char *ptr = (char *)input_buf;
1532     int *s = (int *)output_buf;
1533     CARR_TEMP_BUF;
1534     
1535     CHECK_OUTPUT_BUF_SIZE;
1536 
1537     if (NULL!=out_len)
1538         *out_len = to->size;
1539 
1540     *s = atoi(tmp);
1541 
1542     return output_buf;
1543 }
1544 
1545 exprivate char * conv_carr_ptr(struct conv_type *t, int cnv_dir, char *input_buf,
1546                 int in_len, char *output_buf , int *out_len)
1547 {
1548     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1549     char *ptr = (char *)input_buf;
1550     void **p = (void **)output_buf;
1551     CARR_TEMP_BUF;
1552     
1553     CHECK_OUTPUT_BUF_SIZE;
1554 
1555     if (NULL!=out_len)
1556         *out_len = to->size;
1557     
1558     if (0!=strncmp(tmp, "0x", 2))
1559     {
1560         /* set to 0 if format not matching */
1561         *((ndrx_longptr_t *)p) = 0;
1562     }
1563     else
1564     {
1565         /* LP64 */
1566         sscanf(tmp, "0x" NDRX_LONGPTR_HEX, (ndrx_longptr_t*)p);
1567     }
1568 
1569 
1570     return output_buf;
1571 }
1572 
1573 
1574 /********************************* BFLD_INT ***********************************/
1575 
1576 exprivate char * conv_int_short(struct conv_type *t, int cnv_dir, char *input_buf, 
1577                 int in_len, char *output_buf , int *out_len)
1578 {
1579     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1580     int *ptr = (int *)input_buf;
1581     short *l = (short *)output_buf;
1582 
1583     /* Check the data type lengths */
1584     CHECK_OUTPUT_BUF_SIZE;
1585 
1586     if (NULL!=out_len)
1587         *out_len = to->size;
1588 
1589     *l = (short)*ptr;
1590 
1591     return output_buf;
1592 }
1593 
1594 exprivate char * conv_int_long(struct conv_type *t, int cnv_dir, char *input_buf, 
1595                 int in_len, char *output_buf , int *out_len)
1596 {
1597     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1598     int *ptr = (int *)input_buf;
1599     long *l = (long *)output_buf;
1600 
1601     /* Check the data type lengths */
1602     CHECK_OUTPUT_BUF_SIZE;
1603 
1604     if (NULL!=out_len)
1605         *out_len = to->size;
1606 
1607     *l = (long)*ptr;
1608 
1609     return output_buf;
1610 }
1611 
1612 exprivate char * conv_int_char(struct conv_type *t, int cnv_dir, char *input_buf, 
1613                 int in_len, char *output_buf , int *out_len)
1614 {
1615     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1616     int *ptr = (int *)input_buf;
1617     unsigned char *c = (unsigned char *)output_buf;
1618 
1619     /* Check the data type lengths */
1620     CHECK_OUTPUT_BUF_SIZE;
1621 
1622     if (NULL!=out_len)
1623         *out_len = to->size;
1624 
1625     *c = (char) *ptr;
1626 
1627     return output_buf;
1628 }
1629 
1630 exprivate char * conv_int_float(struct conv_type *t, int cnv_dir, char *input_buf, 
1631                  int in_len, char *output_buf , int *out_len)
1632 {
1633     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1634     int *ptr = (int *)input_buf;
1635     float *f = (float *)output_buf;
1636 
1637     /* Check the data type lengths */
1638     CHECK_OUTPUT_BUF_SIZE;
1639 
1640     if (NULL!=out_len)
1641         *out_len = to->size;
1642 
1643     *f = (float) *ptr;
1644 
1645     return output_buf;
1646 }
1647 
1648 exprivate char * conv_int_double(struct conv_type *t, int cnv_dir, char *input_buf, 
1649                   int in_len, char *output_buf , int *out_len)
1650 {
1651     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1652     int *ptr = (int *)input_buf;
1653     double *d = (double *)output_buf;
1654 
1655     /* Check the data type len for output */
1656     CHECK_OUTPUT_BUF_SIZE;
1657 
1658     if (NULL!=out_len)
1659         *out_len = to->size;
1660 
1661     *d = (double) *ptr;
1662 
1663     return output_buf;
1664 }
1665 
1666 exprivate char * conv_int_string(struct conv_type *t, int cnv_dir, char *input_buf, 
1667                   int in_len, char *output_buf , int *out_len)
1668 {
1669     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1670     int *ptr = (int *)input_buf;
1671     int len;
1672 
1673     CONV_TO_STRING("%d", int);
1674 
1675     return output_buf;
1676 }
1677 
1678 exprivate char * conv_int_carr(struct conv_type *t, int cnv_dir, char *input_buf, 
1679                 int in_len, char *output_buf , int *out_len)
1680 {
1681     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1682     int *ptr = (int *)input_buf;
1683     int len;
1684 
1685     CONV_TO_CARRAY("%d", int);
1686 
1687     return output_buf;
1688 }
1689 
1690 exprivate char * conv_int_ptr(struct conv_type *t, int cnv_dir, char *input_buf, 
1691                 int in_len, char *output_buf , int *out_len)
1692 {
1693     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1694     int *ptr = (int *)input_buf;
1695     void **p = (void *)output_buf;
1696 
1697     /* Check the data type lengths */
1698     CHECK_OUTPUT_BUF_SIZE;
1699 
1700     if (NULL!=out_len)
1701         *out_len = to->size;
1702 
1703     *p = (void *)(ndrx_longptr_t)*ptr;
1704 
1705     return output_buf;
1706 }
1707 
1708 /********************************* BFLD_PTR ***********************************/
1709 
1710 
1711 exprivate char * conv_ptr_short(struct conv_type *t, int cnv_dir, char *input_buf, 
1712                 int in_len, char *output_buf , int *out_len)
1713 {
1714     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1715     void **ptr = (void *)input_buf;
1716     short *s = (short *)output_buf;
1717 
1718     /* Check the data type lengths */
1719     CHECK_OUTPUT_BUF_SIZE;
1720 
1721     if (NULL!=out_len)
1722         *out_len = to->size;
1723 
1724     *s = (short)(ndrx_longptr_t)*ptr;
1725 
1726     return output_buf;
1727 }
1728 
1729 exprivate char * conv_ptr_long(struct conv_type *t, int cnv_dir, char *input_buf, 
1730                 int in_len, char *output_buf , int *out_len)
1731 {
1732     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1733     ndrx_longptr_t **ptr = (ndrx_longptr_t **)input_buf;
1734     long *l = (long *)output_buf;
1735 
1736     /* Check the data type lengths */
1737     CHECK_OUTPUT_BUF_SIZE;
1738 
1739     if (NULL!=out_len)
1740         *out_len = to->size;
1741 
1742     *l = (long)*ptr;
1743 
1744     return output_buf;
1745 }
1746 
1747 exprivate char * conv_ptr_char(struct conv_type *t, int cnv_dir, char *input_buf, 
1748                 int in_len, char *output_buf , int *out_len)
1749 {
1750     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1751     void **ptr = (void **)input_buf;
1752     unsigned char *c = (unsigned char *)output_buf;
1753 
1754     /* Check the data type lengths */
1755     CHECK_OUTPUT_BUF_SIZE;
1756 
1757     if (NULL!=out_len)
1758         *out_len = to->size;
1759 
1760     *c = (char)(ndrx_longptr_t)*ptr;
1761 
1762     return output_buf;
1763 }
1764 
1765 exprivate char * conv_ptr_float(struct conv_type *t, int cnv_dir, char *input_buf, 
1766                  int in_len, char *output_buf , int *out_len)
1767 {
1768     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1769     void **ptr = (void **)input_buf;
1770     float *f = (float *)output_buf;
1771 
1772     /* Check the data type lengths */
1773     CHECK_OUTPUT_BUF_SIZE;
1774 
1775     if (NULL!=out_len)
1776         *out_len = to->size;
1777 
1778     *f = (float)(ndrx_longptr_t) *ptr;
1779 
1780     return output_buf;
1781 }
1782 
1783 exprivate char * conv_ptr_double(struct conv_type *t, int cnv_dir, char *input_buf, 
1784                   int in_len, char *output_buf , int *out_len)
1785 {
1786     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1787     void **ptr = (void **)input_buf;
1788     double *d = (double *)output_buf;
1789 
1790     /* Check the data type len for output */
1791     CHECK_OUTPUT_BUF_SIZE;
1792 
1793     if (NULL!=out_len)
1794         *out_len = to->size;
1795 
1796     *d = (double)(ndrx_longptr_t)*ptr;
1797 
1798     return output_buf;
1799 }
1800 
1801 exprivate char * conv_ptr_string(struct conv_type *t, int cnv_dir, char *input_buf, 
1802                   int in_len, char *output_buf , int *out_len)
1803 {
1804     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1805     void **ptr = (void **)input_buf;
1806     int len;
1807 
1808     /* assume working on LP64 */
1809     CONV_TO_STRING("0x" NDRX_LONGPTR_HEX, ndrx_longptr_t);
1810 
1811     return output_buf;
1812 }
1813 
1814 exprivate char * conv_ptr_carr(struct conv_type *t, int cnv_dir, char *input_buf, 
1815                 int in_len, char *output_buf , int *out_len)
1816 {
1817     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1818     void **ptr = (void **)input_buf;
1819     int len;
1820 
1821     /* assume working on LP64 */
1822     CONV_TO_CARRAY("0x" NDRX_LONGPTR_HEX, ndrx_longptr_t);
1823 
1824     return output_buf;
1825 }
1826 
1827 exprivate char * conv_ptr_int(struct conv_type *t, int cnv_dir, char *input_buf, 
1828                 int in_len, char *output_buf , int *out_len)
1829 {
1830     dtype_str_t *to = &G_dtype_str_map[t->to_type];
1831     void **ptr = (void **)input_buf;
1832     int *i = (int *)output_buf;
1833 
1834     /* Check the data type lengths */
1835     CHECK_OUTPUT_BUF_SIZE;
1836 
1837     if (NULL!=out_len)
1838         *out_len = to->size;
1839 
1840     *i = (int)(ndrx_longptr_t)*ptr;
1841 
1842     return output_buf;
1843 }
1844 
1845 /* vim: set ts=4 sw=4 et smartindent: */