Specifications of the user exit program

In the user exit program the following functions must be called without exception.

  • Initial processing function

  • Main function

  • End processing function

(1) Initial processing function

The function performs the initial processing.

a) Syntax

In Windows:

int __stdcall ed_userexit_init( short *dtlerrno )

In UNIX:

int ed_userexit_init( short *dtlerrno )

b) Parameters

short *dtlerrno

: stores the detailed code when the initial processing fails.

= Remarks =

dtlerrno (detailed code) is output within the error message of the error code 093. The user can specify a detailed code of their choice in order to identify the location where the error occurs.

c) Return values

0

: normal termination

-1

: abnormal termination

= Remarks =

Make sure to perform the initial processing even if it does not include any actual processing.

(2) Main processing function

Based on the input data and its field name or field number, this function creates output data.

a) Syntax

In Windows:

int __stdcall ed_userexit_main(USER_EXITINFO *user_exitinfo, char **outbuf, int *outsize, short *dtlerrno, void *ptr1, void *ptr2)

In UNIX:

int  ed_userexit_main(USER_EXITINFO *user_exitinfo, char **outbuf, int *outsize, short *dtlerrno, void *ptr1, void *ptr2)

b) Parameters

USER_EXITINFO *user_exitinfo

: Retains the input data stored in struct.

char **outbuf

: stores the output data.

int *outsize

: stores the output data size.

short *dtlerrno

: stores the detailed code when the main

void *ptr1

: A pointer used internally.

void *ptr2

: A pointer used internally.

c) Return values

0

: normal termination

-1

: abnormal termination

Note
  • Make sure that outbuf in the ed_userexit_main function is two bytes larger than the data size. In addition, initialize the buffer with NULL.

  • DataMagic releases the buffer, do not release it from the user side.

  • Two-byte codes from a user exit program are not converted on output.

    However, note that such code is not converted to the kanji encoding specified for the output file.

  • If you are using a user exit program to output a value for a variable, the kanji code type on the input side must be used to specify the value in the user exit program.

= Remarks =

dtlerrno (detailed code) is output within the error message of the error code 094. The user can specify a detailed code of their choice in order to identify the location where the error occurs.

(3) End processing function

The end processing function releases the buffer used in the user exit program and performs other tasks. Make sure to perform the end processing even if it does not include any actual processing.

a) Syntax

In Windows:

void __stdcall ed_userexit_end()

In UNIX:

void ed_userexit_end()

b) Parameters

None

c) Return values

None

(4) USER_EXITINFO struct

 struct  user_exitinfo{ 
int whereno;…  :extraction condition number
int outfileno;…  :output number charoutitemname[255+1];…  output field name
int  outitemno;…  :output field number
char  outitemtype;… :definition field type
int  outitemsize;…  :definition field size
char  outitemfig;…  :digits after decimal point of the definition
} USER_EXITINFO;

= Remarks =

If there is no corresponding data, 0 is stored in the int type and the char type.

(5) Input file data acquisition function 1 (can be used in the main processing)

This function obtains the data corresponding to the field number from the input data.

a) Syntax

In Windows:

int __stdcall ed_getindata_itemno(void *ptr1, void *ptr2, int itemno, char **getbuf, int *getsize)

In UNIX:

int ed_getindata_itemno( void *ptr1, void *ptr2, int itemno, char **getbuf, int *getsize)

b) Parameters

void *ptr1

: A pointer used internally

void *ptr2

: A pointer used internally

int itemno

: Specifies the field number of the input data you want to obtain.

char **getbuf

: Stores the obtained data.

int *getsize

: Stores the size of the obtained data.

c) Return values

0

: Obtained successfully

-1

: Failed to obtain

= Remarks =

Make sure to pass the same pointers via the arguments ptr1 and ptr2 above as those passed for receiving values via ptr1 and ptr2 in ed_userexit_main.

Note
  • Allocate, within the API, the buffer of the obtained data (**getbuf). After the API is used, it is necessary to release the area by using the ed_free() function.

  • If the input format is XML, this function cannot be used.

(6) Input file data acquisition function 2 (can be used in the main processing)

This function obtains the data corresponding to the field name from the input data.

a) Syntax

In Windows:

int __stdcall ed_getindata_itemname(void *ptr1, void *ptr2, char *itemname, char **getbuf, int *getsize)

In UNIX:

int ed_getindata_itemname(void *ptr1, void *ptr2, char *itemname, char **getbuf, int *getsize)

b) Parameters

void *ptr1

: A pointer used internally

void *ptr2

: A pointer used internally

char *itemname

: Specifies the field name of the input data you want to obtain.

char **getbuf

: Stores the obtained data.

int *getsize

: Stores the size of the obtained data.

c) Return values

0

: Obtained successfully

-1

: Failed to obtain

= Remarks =

Make sure to pass the same pointers via the arguments ptr1 and ptr2 above as those passed for receiving values via ptr1 and ptr2 in ed_userexit_main.

Note

Allocate, within the API, the buffer of the obtained data (**getbuf). After the API is used, it is necessary to release the area by using the ed_free() function.

(7) Function for obtaining variable data (Can be used for main processing)

This function obtains the data corresponding to the variable name.

a) Syntax

In Windows:

int __stdcall ed_getindata_var(void *ptr1, void *ptr2, char *itemname, char **getbuf, int *getsize) 

In UNIX:

int ed_getindata_var(void *ptr1, void *ptr2, char *itemname, char **getbuf, int *getsize)

b) Parameters

void *ptr1

: Pointer to be used internally

void *ptr2

: Pointer to be used internally

char *itemname

: Specifies the name of the variable to be obtained

char **getbuf

: Stores the obtained data

int *getsize

: Stores the size of the obtained data

c) Return values

0

: Data is obtained successfully

-1

: Data could not be obtained

= Remarks =

Make sure to pass the same pointers via the arguments ptr1 and ptr2 above as those passed for receiving values via ptr1 and ptr2 in ed_userexit_main.

Note

The buffer for the obtained data (**getbuf) is allocated in the API. After the API is used, the ed_free() function must be used to release the area.

(8) Matching file data acquisition function (can be used in the main processing)

This function obtains the data corresponding to the field number from the data specified by the matching number.

a) Syntax

In Windows:

int __stdcall ed_getindata_itemno_matchno(void *ptr1, void *ptr2, int matchno, int itemno, char **getbuf, int *getsize)

In UNIX:

int ed_getindata_itemno_matchno(void *ptr1, void *ptr2, int matchno, int itemno, char **getbuf, int *getsize)

b) Parameters

void *ptr1

: A pointer used internally.

void *ptr2

: A pointer used internally.

int matchno

: Specifies the matching number that you want to obtain.

int itemno

: Specifies the field number of the input data you want to obtain.

char **getbuf

: Stores the obtained data.

int *getsize

: Stores the size of the obtained data.

c) Return values

0

: Obtained successfully

-1

: Failed to obtain

= Remarks =

Make sure to pass the same pointers via the arguments ptr1 and ptr2 above as those passed for receiving values via ptr1 and ptr2 in ed_userexit_main.

Note

Allocate, within the API, the buffer of the obtained data (**getbuf). After the API is used, it is necessary to release the area by using the ed_free() function.

(9) Memory acquisition function (can be used in the main processing)

This function allocates memory of the specified data size.

a) Syntax

In Windows:

void* __stdcall ed_malloc(size_t size)

In UNIX:

void* ed_malloc(size_t size)

b) Parameters

size_t size

: Specifies the size of the data to be obtained

c) Return values

Not NULL

: Obtained pointer

NULL

: Failed to obtain

(10) Memory release function (can be used in the main processing)

This function releases the memory specified with the argument.

a) Syntax

In Windows:

void __stdcall ed_free(void *ptr)

In UNIX:

void ed_free(void *ptr)

b) Parameters

void *ptr

specifies the pointer to release.

c) Return values

None