The following is a sample subcommand handler:
Sample subcommand handler
ULONG Edit_Commands(
PRXSTRING Command, /* Command string passed from the caller */
PUSHORT Flags, /* pointer to short for return of flags */
PRXSTRING Retstr) /* pointer to RXSTRING for RC return */
{
LONG command_id; /* command to process */
LONG rc; /* return code */
PSZ scan_pointer; /* current command scan */
PSZ target; /* general editor target */
scan_pointer = command->strptr; /* point to the command */
/* resolve command */
command_id = resolve_command(&scan_pointer);
switch (command_id) { /* process based on command */
case LOCATE: /* locate command */
/* validate rest of command */
if (rc = get_target(&scan_pointer, &target)) {
*Flags = RXSUBCOM_ERROR; /* raise an error condition */
break; /* return to REXX */
}
rc = locate(target); /* look target in the file */
*Flags = RXSUBCOM_OK; /* not found is not an error */
break; /* go finish up */
.
.
.
default: /* unknown command */
rc = 1; /* return code for unknown */
*Flags = RXSUBCOM_FAILURE; /* this is a command failure */
break;
}
sprintf(Retstr->strptr, "%d", rc); /* format return code string */
/* and set the correct length */
Retstr->strlength = strlen(Retstr->strptr);
return 0; /* processing completed */
}