wholenumber_t rexx_add_queue( RexxMethodContext *context, // the call context RexxStringObject queue_line, /* line to add */ int order ) /* queuing order */ { char buffer = 0; // buffer for an empty string CONSTRXSTRING rx_string; // rxstring to push RexxReturnCode rc; // queue return code if (queue_line == NULLOBJECT) /* no line given? */ { // just use a null string value MAKERXSTRING(rx_string, &buffer, 0); } else { MAKERXSTRING(rx_string, context->StringData(queue_line), context->StringLength(queue_line)); } /* get the queue name */ RexxObjectPtr queue_name = context->GetObjectVariable("NAMED_QUEUE"); /* move the line to the queue */ rc = RexxAddQueue(context->ObjectToStringValue(queue_name), &rx_string, order); if (rc != 0) /* stream error? */ { context->RaiseException1(Rexx_Error_System_service_service, context->NewStringFromAsciiz("SYSTEM QUEUE")); } return rc; /* return the result */ }
static void push ( char * pushstr, /* String to be pushed onto queue */ long lOp) /* 0 = FIFO, 1 = LIFO */ { CONSTRXSTRING rxstr; rxstr.strptr = pushstr; rxstr.strlength = strlen(pushstr); RexxAddQueue("SESSION", &rxstr, (size_t)lOp); return; }
int main (int argc, char **argv) { // our invocation information InstanceInfo instanceInfo; // fill in the structure for the invocation buildInfo(&instanceInfo, argc, argv); // this can be done using either RexxCreateInterpreter or RexxStart if (instanceInfo.callType == InstanceInfo::INSTANCE) { // go invoke this invokeProgram(&instanceInfo); } else { invokeRexxStart(&instanceInfo); } // if no error, then push the return result on to the queue if (instanceInfo.rc == 0) { CONSTRXSTRING result; MAKERXSTRING(result, instanceInfo.returnResult, strlen(instanceInfo.returnResult)); RexxAddQueue("TESTQUEUE", &result, RXQUEUE_LIFO); } else { CONSTRXSTRING result; char errorResult[50]; sprintf(errorResult, "%d %d", instanceInfo.rc, instanceInfo.code); MAKERXSTRING(result, errorResult, strlen(errorResult)); RexxAddQueue("TESTQUEUE", &result, RXQUEUE_LIFO); } return (int)instanceInfo.rc; // return the error indicator }