0001 TPEXPORT(3)
0002 ===========
0003 :doctype: manpage
0004
0005
0006 NAME
0007 ----
0008 tpexport - export UBF|VIEW|STRING|CARRAY|JSON type buffer into the JSON formatted text buffer
0009
0010
0011 SYNOPSIS
0012 --------
0013 #include <atmi.h>
0014
0015 int tpexport(char *'ibuf', long 'ilen', char *'ostr', long *'olen', long 'flags');
0016
0017 For XATMI client link with '-latmiclt -latmi -lview -lnstd -lpthread -lrt -lm'
0018
0019 For XATMI server link with '-latmisrv|-latmisrvnomain|-latmisrvinteg -latmi -lview -lnstd -lpthread -lrt -lm'
0020
0021 DESCRIPTION
0022 -----------
0023 Function converts typed buffer to JSON formatted text buffer.
0024
0025 'ibuf' is XATMI buffer which will be exported to JSON formatted text buffer.
0026 'ilen' is used for buffer types such *CARRAY*, where buffer length is not
0027 described by type.
0028 'ostr' exported output JSON formatted text buffer. If *TPEX_STRING* flag is set,
0029 then JSON buffer will be converted to base64.
0030 'olen' define maximum size for 'ostr'
0031
0032 Function supports exporting of sub buffers for *UBF*. The *PTR*, *VIEW* and *UBF*
0033 sub-fields are supported in export. Also empty *UBF* and *VIEW* data types are
0034 handled as empty JSON objects. See examples bellow.
0035
0036 *JSON tags in the exported file:*
0037
0038 - *buftype* - which type of buffer exported (STRING, UBF, VIEW, CARRAY, JSON)
0039
0040 - *version* - exported version of JSON text buffer
0041
0042 - *subtype* - contains name of VIEW buffer, used only for exported VIEWs
0043
0044 - *data* - contains JSON formatted data
0045
0046
0047 EXAMPLES
0048 --------
0049
0050 For example following UBF buffer
0051
0052 --------------------------------------------------------------------------------
0053 T_SHORT_FLD 1765
0054 T_LONG_FLD 3333111
0055 T_LONG_FLD 2
0056 T_CHAR_FLD A
0057 T_FLOAT_FLD 1.00000
0058 T_DOUBLE_FLD 1111.220000
0059 T_DOUBLE_FLD 333.000000
0060 T_DOUBLE_FLD 444.000000
0061 T_STRING_FLD HELLO WORLD
0062 T_CARRAY_FLD \00\01\02\03HELLO BINARY\04\05\00
0063 --------------------------------------------------------------------------------
0064
0065 Will be exported to following JSON
0066
0067 --------------------------------------------------------------------------------
0068 {
0069 "buftype":"UBF",
0070 "version":1,
0071 "data":
0072 {
0073 "T_SHORT_FLD:1765,
0074 "T_LONG_FLD":[3333111,2],
0075 "T_CHAR_FLD":"A",
0076 "T_FLOAT_FLD":1,
0077 "T_DOUBLE_FLD":[1111.220000,333,444],
0078 "T_STRING_FLD":"HELLO WORLD",
0079 "T_CARRAY_FLD":"AAECA0hFTExPIEJJTkFSWQQFAA=="
0080 }
0081 }
0082 --------------------------------------------------------------------------------
0083
0084 For example following VIEW
0085
0086 --------------------------------------------------------------------------------
0087 VIEW MYVIEW56
0088 #type cname fbname count flag size null
0089 short tshort1 - 1 - - -
0090 long tlong1 - 1 - - -
0091 char tchar1 - 1 - - -
0092 float tfloat1 - 1 - - -
0093 double tdouble1 - 1 - - -
0094 string tstring1 - 1 - 15 -
0095 carray tcarray1 - 1 - 10 -
0096 END
0097 --------------------------------------------------------------------------------
0098
0099 Will be exported into following JSON
0100
0101 --------------------------------------------------------------------------------
0102 {
0103 "buftype":"VIEW",
0104 "version":1,
0105 "subtype":"MYVIEW56",
0106 "data":
0107 {
0108 "MYVIEW56\":
0109 {
0110 "tshort1":1,
0111 "tlong1":2,
0112 "tchar1":"A",
0113 "tfloat1":1,
0114 "tdouble1":21,
0115 "tstring1":"ABC",
0116 "tcarray1":"SEVMTE8AAAAAAA=="
0117 }
0118 }
0119 }
0120 --------------------------------------------------------------------------------
0121
0122 For example following text buffer
0123
0124 --------------------------------------------------------------------------------
0125 HELLO WORLD
0126 --------------------------------------------------------------------------------
0127
0128 Will be imported into following JSON
0129
0130 --------------------------------------------------------------------------------
0131 {
0132 "buftype":"STRING",
0133 "version":1,
0134 "data":"HELLO WORLD"
0135 }
0136 --------------------------------------------------------------------------------
0137
0138
0139 For example following CARRAY buffer
0140
0141 --------------------------------------------------------------------------------
0142 0000 48 45 4c 4c 4f 20 57 4f 52 4c 44 20 43 41 52 52 HELLO WORLD CARR
0143 0010 41 59 AY
0144 --------------------------------------------------------------------------------
0145
0146 Will be imported into following JSON
0147
0148 --------------------------------------------------------------------------------
0149 {
0150 "buftype":"CARRAY",
0151 "version":1,
0152 "data":"SEVMTE8gV09STEQgQ0FSUkFZ"
0153 }
0154 --------------------------------------------------------------------------------
0155
0156
0157 For example following JSON buffer
0158
0159 --------------------------------------------------------------------------------
0160 {
0161 "T_SHORT_FLD":1765,
0162 "T_LONG_FLD":[3333111,2],
0163 "T_CHAR_FLD":"A",
0164 "T_FLOAT_FLD":1,
0165 "T_DOUBLE_FLD":[1111.220000,333,444],
0166 "T_STRING_FLD":"HELLO WORLD",
0167 "T_CARRAY_FLD":"AAECA0hFTExPIEJJTkFSWQQFAA=="
0168 }
0169 --------------------------------------------------------------------------------
0170
0171 Will be imported into following JSON
0172
0173 --------------------------------------------------------------------------------
0174 {
0175 "buftype":"JSON",
0176 "version":1,
0177 "data":
0178 {"T_SHORT_FLD":1765,
0179 "T_LONG_FLD":[3333111,2],
0180 "T_CHAR_FLD":"A",
0181 "T_FLOAT_FLD":1,
0182 "T_DOUBLE_FLD":[1111.220000,333,444],
0183 "T_STRING_FLD":"HELLO WORLD",
0184 "T_CARRAY_FLD":"AAECA0hFTExPIEJJTkFSWQQFAA=="}
0185 }
0186 --------------------------------------------------------------------------------
0187
0188 String type data such as string VIEW fields, UBF *BFLD_STRING* fields or *STRING* buffers
0189 must correspond to *UTF-8* encoding.
0190
0191 Following UBF buffer (with sub-buffers):
0192
0193 --------------------------------------------------------------------------------
0194 T_SHORT_FLD 55
0195 T_PTR_FLD 0x619000003280
0196 T_PTR_2_FLD 0x61900000be80
0197 T_PTR_2_FLD 0x619000002d80
0198 T_UBF_FLD
0199 T_STRING_FLD HELLO WORLD INNER
0200 T_UBF_2_FLD
0201 T_STRING_FLD HELLO WORLD INNER 1
0202 T_UBF_2_FLD
0203 T_STRING_FLD HELLO WORLD INNER 2
0204 T_UBF_2_FLD
0205 T_VIEW_FLD MYVIEW56
0206 tshort1 1
0207 tlong1 2
0208 tchar1 A
0209 tfloat1 1.00000
0210 tdouble1 21.000000
0211 tstring1 ABC
0212 tcarray1 HELLO\00\00\00\00\00
0213 T_VIEW_2_FLD MYVIEW56
0214 tshort1 1
0215 tlong1 2
0216 tchar1 A
0217 tfloat1 1.00000
0218 tdouble1 21.000000
0219 tstring1 ABC_2
0220 tcarray1 HELLO\00\00\00\00\00
0221 T_VIEW_2_FLD
0222 T_VIEW_2_FLD MYVIEW56
0223 tshort1 1
0224 tlong1 2
0225 tchar1 A
0226 tfloat1 1.00000
0227 tdouble1 21.000000
0228 tstring1 ABC_3
0229 tcarray1 HELLO\00\00\00\00\00
0230 --------------------------------------------------------------------------------
0231
0232 would be exported as:
0233
0234 --------------------------------------------------------------------------------
0235 {
0236 "buftype":"UBF",
0237 "version":1,
0238 "data":{
0239 "T_SHORT_FLD":55,
0240 "T_UBF_FLD":{
0241 "T_STRING_FLD":"HELLO WORLD INNER"
0242 },
0243 "T_UBF_2_FLD":[
0244 {
0245 "T_STRING_FLD":"HELLO WORLD INNER 1"
0246 },
0247 {
0248 "T_STRING_FLD":"HELLO WORLD INNER 2"
0249 },
0250 {
0251
0252 }
0253 ],
0254 "T_VIEW_FLD":{
0255 "MYVIEW56":{
0256 "tshort1":1,
0257 "tlong1":2,
0258 "tchar1":"A",
0259 "tfloat1":1,
0260 "tdouble1":21,
0261 "tstring1":"ABC",
0262 "tcarray1":"SEVMTE8AAAAAAA=="
0263 }
0264 },
0265 "T_VIEW_2_FLD":[
0266 {
0267 "MYVIEW56":{
0268 "tshort1":1,
0269 "tlong1":2,
0270 "tchar1":"A",
0271 "tfloat1":1,
0272 "tdouble1":21,
0273 "tstring1":"ABC_2",
0274 "tcarray1":"SEVMTE8AAAAAAA=="
0275 }
0276 },
0277 {
0278 "":{
0279
0280 }
0281 },
0282 {
0283 "MYVIEW56":{
0284 "tshort1":1,
0285 "tlong1":2,
0286 "tchar1":"A",
0287 "tfloat1":1,
0288 "tdouble1":21,
0289 "tstring1":"ABC_3",
0290 "tcarray1":"SEVMTE8AAAAAAA=="
0291 }
0292 }
0293 ],
0294 "T_PTR_FLD":{
0295 "buftype":"UBF",
0296 "version":1,
0297 "data":{
0298 "T_SHORT_FLD":1765,
0299 "T_LONG_FLD":[
0300 115,
0301 2
0302 ],
0303 "T_CHAR_FLD":"A",
0304 "T_FLOAT_FLD":1,
0305 "T_DOUBLE_FLD":[
0306 1111.220000,
0307 333,
0308 444
0309 ],
0310 "T_STRING_FLD":"HELLO WORLD",
0311 "T_CARRAY_FLD":"AAECA0hFTExPIEJJTkFSWQQFAA=="
0312 }
0313 },
0314 "T_PTR_2_FLD":[
0315 {
0316 "buftype":"UBF",
0317 "version":1,
0318 "data":{
0319 "T_SHORT_FLD":1765,
0320 "T_LONG_FLD":[
0321 1111,
0322 2
0323 ],
0324 "T_CHAR_FLD":"A",
0325 "T_FLOAT_FLD":1,
0326 "T_DOUBLE_FLD":[
0327 1111.220000,
0328 333,
0329 444
0330 ],
0331 "T_STRING_FLD":"HELLO WORLD 22",
0332 "T_CARRAY_FLD":"AAECA0hFTExPIEJJTkFSWQQFAA=="
0333 }
0334 },
0335 {
0336 "buftype":"UBF",
0337 "version":1,
0338 "data":{
0339 "T_SHORT_FLD":1765,
0340 "T_LONG_FLD":[
0341 4444,
0342 2
0343 ],
0344 "T_CHAR_FLD":"A",
0345 "T_FLOAT_FLD":1,
0346 "T_DOUBLE_FLD":[
0347 1111.220000,
0348 333,
0349 444
0350 ],
0351 "T_STRING_FLD":"HELLO WORLD 44",
0352 "T_CARRAY_FLD":"AAECA0hFTExPIEJJTkFSWQQFAA=="
0353 }
0354 }
0355 ]
0356 }
0357 }
0358 --------------------------------------------------------------------------------
0359
0360 RETURN VALUE
0361 ------------
0362 On success, *tpexport()* return 0; on error, -1 is returned,
0363 with *tperrno* set to indicate the error.
0364
0365 ERRORS
0366 ------
0367 Note that tpstrerror() returns generic error message plus custom message with
0368 debug info from last function call.
0369
0370
0371 *TPEINVAL* Invalid JSON or invalid base64 encoding, 'ibuf' is NULL or 'ostr' is NULL.
0372
0373 *TPEOTYPE* Invalid type specified to function. VIEW sub-type not found or
0374 environment is not configured.
0375
0376 *TPESYSTEM* System failure occurred during serving. See logs i.e. user log, or
0377 debugs for more info. Strings does not correspond to *UTF-8* format.
0378
0379 *TPEOS* System failure occurred during serving. See logs i.e. user log, or
0380 debugs for more info. In case of insufficient memory this error will be
0381 generated too.
0382
0383
0384 EXAMPLE
0385 -------
0386 Sample code see under:
0387
0388 - *atmitest/test056_tpimpexp/atmiclt56_ubf.c* - import UBF buffer
0389
0390 - *atmitest/test056_tpimpexp/atmiclt56_view.c* - import VIEW buffer
0391
0392 - *atmitest/test056_tpimpexp/atmiclt56_carray.c* - import CARRAY buffer
0393
0394 - *atmitest/test056_tpimpexp/atmiclt56_json.c* - import JSON buffer
0395
0396 - *atmitest/test056_tpimpexp/atmiclt56_string.c* - import STRING buffer
0397
0398 BUGS
0399 ----
0400 Report bugs to support@mavimax.com
0401
0402 SEE ALSO
0403 --------
0404 *tpimport(3)*
0405
0406 COPYING
0407 -------
0408 (C) Mavimax, Ltd