string parameters are passed in a CS_STRING_HOLDER structure. binary parameters are passed in a CS_BINARY_HOLDER structure. These structures are defined in jagpublic.h as follows:
typedef struct _cs_longchar_holder { CS_LONGCHAR *value; CS_INT length; } CS_STRING_HOLDER; typedef struct _cs_longbinary_holder { CS_LONGBINARY *value; CS_INT length; } CS_BINARY_HOLDER; #define CS_LONGCHAR_HOLDER CS_STRING_HOLDER #define CS_LONGBINARY_HOLDER CS_BINARY_HOLDER
To allow backward compatibility with code that was written for EAServer version 1.1, you can use CS_LONGCHAR_HOLDER in place of CS_STRING_HOLDER, and CS_LONGBINARY_HOLDER in place of CS_BINARY_HOLDER.
On input, the value field contains the input value and the length field specifies the input length. For output, you can set a new value and length in the structure as follows:
If the output value is longer than the input length, you must reallocate memory for the value and reset the value and length fields. Use the JagFree and JagAlloc routines as shown in the example below.
If the output value is not longer than the input length, you can copy the output value directly into the buffer addressed by the input value pointer and reset the length field.
The following example calls the JagFree and JagAlloc routines to reallocate a larger value buffer:
JagFree(myholder->value); myholder->value = JagAlloc(new_length); if (myholder->value == NULL) { JagLog(JAG_TRUE, “Out of memory!\n”); return CS_FAIL; } memcpy(myholder->value, new_value, new_length); myholder->length = new_length;