An existing function must be wrapped in order to be described by a FUNC Object. The wrapping consists of:
pSgeWorkCallData
structure and passing it to the wrapped function.
pSgeWorkCallData
structure.
If the DSQLDIR environment variable is not set, Sapphire/Web will look in the project's directory.
FUNC,FUNC,object_name,Uwhere
object_name
U
pSgeWorkCallData
structure that gets passed to it. The prototype fora FUNC object function is as follows:
int function(pSgeWorkCallData p)
/* Unknown number of Arguments */
size = SaReqGetNumArgs(p);
for(i = 0; i < size; i++) {
value = SaReqGetNArg(p, i); /* value of Nth argument */
name = SaReqGetNArgName(p, i); /* name of Nth argument */
printf("%s=%s\n", name, value); /* print out argument */
}
...
/* Known Argument List of Filename and Filesize */
char *fname;
int size;
fname = SaReqGetArgByName(p, "Filename");
size = atoi(SaReqGetArgByName(p, "Filesize"));
...
char results[2][5];
int i, j, status;
status = my_func(results);
for(i = 0; i < 2; i++) {
for(j = 0; j < 5; j++) {
SaReqAppendString(p, results[i][j]);
}
}
SaReqSetGroupCount(p, 1); /* number of groups is 1 */
SaReqAppendRowCount(p, 2); /* number of rows returned */
SaReqAppendColCount(p, 5); /* number of columns per row */
/* These do not need to be set, but are a way of sending other information back to the Object Binding code. */
SaReqSetErrorCode(p, 0); /* no error */
SaReqSetReturnCode(p, status); /* return status of my_func*/
SaReqSetAffectedRowCount(p, 2); /* set affected rows */