| Code: 
							
								
								
								| 
    #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <recio.h>
#include <qwvrcstk.h>
 typedef _Packed struct API_Error {
  int       bytesProvided;
  int       bytesAvail;
  char      exceptionID[7];
  char      reserved[1];
  char      exception[128];
} API_Error_t;
  _RFILE            *qsysprtFp;
 static int  ckQSHELL( void );
 */
int main (int argc, char *argv[])
{
  qsysprtFp = _Ropen("QSYSPRT", "wr");
   if (ckQSHELL()) {
    _Rwrite(qsysprtFp, "YES", 3);
  } else {
    _Rwrite(qsysprtFp, "NO", 2);
  }
   if (qsysprtFp != NULL) {
    _Rclose(qsysprtFp);
  }
  return;
}
 *  Return 1 if we're running in QSHELL; 0 otherwise.
 */
int  ckQSHELL( void )
{
  int                 retc = 0;
  int                 alcSize;
  int                 eX;
  char               *cRCSTKp;
  Qwv_RCSTK_Entry_t  *RCSTKp;
  char               *cCSTK0100p;
  Qwv_CSTK0100_t     *CSTK0100p;
  Qwv_CSTK0100_t      CSTK0100;
  Qwc_JIDF0100_t      JIDF0100;
  API_Error_t         locAPI_Err;
   memset(&locAPI_Err, 0, sizeof(locAPI_Err));
  locAPI_Err.bytesProvided = sizeof(locAPI_Err);
  memset(&JIDF0100, ' ', sizeof(JIDF0100));
  memset(&JIDF0100.Reserved, 0, sizeof(JIDF0100.Reserved));
  memset(&JIDF0100.Thread_Id, 0, sizeof(JIDF0100.Thread_Id));
  JIDF0100.Job_Name[0]  = '*';                   
  JIDF0100.Thread_Indicator = 1;                 
   
   QWVRCSTK(&CSTK0100,
           sizeof(CSTK0100),
           "CSTK0100",
           &JIDF0100,
           "JIDF0100",
           &locAPI_Err);
   alcSize = CSTK0100.Bytes_Available;
  cCSTK0100p = malloc(alcSize);
  CSTK0100p = (Qwv_CSTK0100_t *) cCSTK0100p;
   
   QWVRCSTK(cCSTK0100p,
           alcSize,
           "CSTK0100",
           &JIDF0100,
           "JIDF0100",
           &locAPI_Err);
   cRCSTKp = cCSTK0100p + CSTK0100p->Entry_Offset;
  RCSTKp = (Qwv_RCSTK_Entry_t *) cRCSTKp;
   
   for (eX = 0; eX < CSTK0100p->Entry_Returned; eX++) {
     
     if (0 == memcmp(RCSTKp->Program_Library, "QSHELL ", 7)) {
      retc = 1;
      break;
    }
    cRCSTKp = cRCSTKp + RCSTKp->Entry_Length;
    RCSTKp = (Qwv_RCSTK_Entry_t *) cRCSTKp;
  }
  if (cCSTK0100p != NULL) {
    free(cCSTK0100p);
    cCSTK0100p = NULL;
  }
  return retc;
}
  |  |