Feature #257

Implemented tpexport() and tpimport() functions

Added by Madars Vitolins 7 months ago. Updated 28 days ago.

Status:NewStart date:12/07/2017
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-

Description

tpexport() and tpimport() shall be implemented. The common storage format could be JSON string.

History

#1 Updated by Madars Vitolins 7 months ago

Also needs support for tpenvelope().

#2 Updated by Madars Vitolins 7 months ago

Example formats:

{
    buftype:"STRING|CARRAY|UBF|VIEW",
        /* sub-type only for views */
    subtype:"view1",
    version:"1.0",
    /* for string */
    data: "test string" 
    /* for carray, base64*/
    data: "dGVzdCBzdHJpbmcNCg==" 
    /* for UBF, for internals see ubf2exjson.c */
    data:
    {
        FIELD1:"VAL",
        FIELD2:"VAL" 
    }
    /* For view, internals: view2exjson.c */
    data:
    {
        transaction:
        {
            view1:{
                field1:"hello",
                field2:"world" 
            }
        }
    }

}

#3 Updated by Madars Vitolins 28 days ago

The core of the function shall be: tpexportex() and tpimportex() which takes additional argument:

struct ndrx_expbufctl
{
    char buftype[XATMI_TYPE_LEN+1];
    short buftype_ind;

    char subtype[XATMI_SUBTYPE_LEN+1];
    short subtype_ind;

    char version[MAXTIDENT+1];
    short version_ind;

    char svcnm[XATMI_SERVICE_NAME_LENGTH+1];
    short svcnm_ind;

    int rval;
    short rval_ind;

   long rcode;
   short rcode_ind;

   int tperror;
   short tperror_ind;

   char tpstrerror[MAX_TP_ERROR_LEN+1];
   short tpstrerror_ind;
};
typedef struct ndrx_expbufctl_t ndrx_expbufctl;

int tpexportex(ndrx_expbufctl_t *ctl, char *ibuf, long ilen, char *ostr, long *olen,  long flags)

int tpimportex(ndrx_expbufctl_t *ctl, char *istr, long ilen, char **obuf, long *olen,  long flags)

In case of "tpexportex", if any indicator is set in the ctl structure, then export it as is. For buffer type and sub-type, if fields are set, that should be cross checked with real buffer type provided by tptypes, if does not compare, then reject with TPEINVAL and corresponding message.

For tpimportex, read all header data as is and put the any field found in the ctl data and set the indicator. tpimportex shall perform memset 0 on ctl struct.

Header data should be as follows:

{
    buftype:"STRING|CARRAY|UBF|VIEW",
        /* sub-type only for views */
    subtype:"view1",
    version:"1.0",
    svcnm:"HELLOSVC",
    irval:0,
    rcode:123,
    tperror:6,
    tpstrerror:"No service entry" 
}

Also available in: Atom PDF