#include #include #include #include #include #include #define TRUE 0 #define FALSE -1 #define ID_LEN 16 typedef struct { char job[10]; char user[10]; char jobnbr[6]; } JOBINFO; JOBINFO jobinfo; typedef struct { int BYTESPRO; int BYTESAVL; char MSGID[7]; char RESRVD; char EXCPDATA[100]; } ERRSTRUCTURE; /* Define the error return structure */ ERRSTRUCTURE errcode;/* Error Code Structure for RCVMSG */ /*************************************************************/ /* 内 部 使 用  関  数 */ /*************************************************************/ void GetParam(int argc, char *argv[]); void INZSR(void); void ApiError(char* place, int stmno, ERRSTRUCTURE* errcode, char* pgm); /*************************************************************/ /* グ ロ ー バ ル 変 数 */ /*************************************************************/ char job[11], user[11], jobnbr[7], outq[11], outqlib[11], date[8]; char type[2], prtdev[11], langid[4], cntryid[3], ccsid[6]; char dftccsid[6], cymddate[9], sbmmsgq[11], sbmmsgqlib[11]; char jobid[ID_LEN], ascnbr[7], m_ccsid[6]; decimal(5, 0) dftCCSID, CCSID; int main(int argc, char *argv[]){ Qwc_JOBI0300_t jobi0300; Qwc_JOBI0400_t jobi0400; char jobid[16]; GetParam(argc, argv); /*[ パラメータの取得 ]*/ INZSR(); /*[ 初期設定 ]*/ memset(jobid, ' ', sizeof(jobid)); QUSRJOBI(&jobi0300, sizeof(Qwc_JOBI0300_t), "JOBI0300", &jobinfo, jobid, &errcode); if(errcode.BYTESAVL != 0){/* APIERR */ ApiError("QUSRJOBI", __LINE__, &errcode, "VT5250"); exit(-1); }/* APIERR */ memcpy(jobid, jobi0300.Int_Job_ID, 16); memcpy(outq, jobi0300.Outq_Name, 10); outq[10] = 0x00; memcpy(outqlib, jobi0300.Outq_Lib, 10); outqlib[10] = 0x00; memcpy(date, jobi0300.Job_Date, 7); date[7] = 0x00; memcpy(prtdev, jobi0300.Prt_Dev_Name, 10); prtdev[10] = 0x00; memcpy(sbmmsgq, jobi0300.Subm_Msgq_Name, 10); sbmmsgq[10] = 0x00; memcpy(sbmmsgqlib, jobi0300.Subm_Msgq_Lib, 10); sbmmsgqlib[10] = 0x00; memcpy(cymddate, jobi0300.Date_Put_On_Jobq, 8); cymddate[8] = 0x00; memset(&jobinfo, ' ', sizeof(jobinfo)); memcpy(jobinfo.job, "*INT ", 10); QUSRJOBI(&jobi0400, sizeof(Qwc_JOBI0400_t), "JOBI0400", &jobinfo, jobid, &errcode); if(errcode.BYTESAVL != 0){/* APIERR */ ApiError("QUSRJOBI", __LINE__, &errcode, "VT5250"); exit(-1); }/* APIERR */ memcpy(langid, jobi0400.Language_ID, 3); langid[3] = 0x00; memcpy(cntryid, jobi0400.Country_ID, 2); cntryid[2] = 0x00; if(jobi0400.Job_Type[0] == 'B') strcpy(type, "0"); else strcpy(type, "1"); sprintf(ccsid, "%05d", jobi0400.Coded_Char_Set_ID); CCSID = (decimal(5, 0))jobi0400.Coded_Char_Set_ID; sprintf(dftccsid, "%05d", jobi0400.Default_Coded_Char_Set_Id); dftCCSID = (decimal(5, 0))jobi0400.Default_Coded_Char_Set_Id; strcpy(argv[1], job); strcpy(argv[2], user); strcpy(argv[3], jobnbr); strcpy(argv[4], outq); strcpy(argv[5], outqlib); strcpy(argv[6], date); strcpy(argv[7], type); strcpy(argv[8], prtdev); strcpy(argv[9], langid); strcpy(argv[10], cntryid); memcpy(argv[11], &CCSID, 3); memcpy(argv[12], &dftCCSID, 3); strcpy(argv[13], cymddate); strcpy(argv[14], sbmmsgq); strcpy(argv[15], sbmmsgqlib); return; } /*************************************/ void GetParam(int argc, char *argv[]) /*************************************/ { memcpy(job, argv[1], 10); job[10] = 0x00; memcpy(user, argv[2], 10); user[10] = 0x00; memcpy(jobnbr, argv[3], 6); jobnbr[6] = 0x00; } /****************/ void INZSR(void) /****************/ { errcode.BYTESPRO = sizeof(errcode); errcode.BYTESAVL = 0; } /*********************************************************************/ void ApiError(char* place, int stmno, ERRSTRUCTURE* errcode, char* pgm) /*********************************************************************/ { char msgid[8], msgf[11], msgflib[11], msgdta[101], Message[512]; int msglen, msgdtalen, pos, strpos = FALSE; char* ptr; typedef struct { Qmh_Rtvm_RTVM0100_t rtvm0100; char msg[512]; } ERRMSG; ERRMSG errmsg; memcpy(msgid, errcode->MSGID, 7); msgid[7] = 0x00; if(msgid[0] == 0x00 || msgid[0] == ' '){/*msgid なし */ perror("APIERROR"); printf(" at %s, STMNO=%d\n", place, stmno); getchar(); return; }/*msgid なし */ memcpy(msgdta, errcode->EXCPDATA, 100); msgdta[100] = 0x00; msglen = sizeof(ERRMSG); msgdtalen = strlen(msgdta); memset(&errmsg, 0, sizeof(ERRMSG)); QMHRTVM(&errmsg, msglen, "RTVM0100", msgid, "QCPFMSG *LIBL ", msgdta, msgdtalen, "*YES ", "*YES ", errcode); memset(Message, 0, sizeof(Message)); memcpy(Message, errmsg.msg, 512); ptr = strstr(Message, "&N"); while(ptr != NULL){/*while*/ pos = (int)(ptr - Message); if(strpos == FALSE) strpos = pos; Message[pos] = 0x15; pos ++; Message[pos] = ' '; ptr = strstr(&Message[pos], "&N"); }/*while*/ if(strpos != FALSE) Message[strpos] = 0x00; printf("PGM-%s:APIERR %s-%s\n", pgm, msgid, Message); printf(" AT %s, STMNO=%d\n", place, stmno); printf(" MSGDTA =%s\n", msgdta); }