#include #include #include #include #include #include #include #include #include #include #include /* triml */ #define TRUE 0 #define FALSE -1 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 */ ERRSTRUCTURE errcd53; typedef struct { Qmh_Rtvm_RTVM0100_t rtvm0100; char msg[512]; } ERRMSG; ERRMSG err_msg; /*************************************************************/ /* 外 部 呼 出 し  関  数 */ /*************************************************************/ #pragma map(QSYGETPH53, "QSYS/QSYGETPH") #pragma linkage(QSYGETPH53, OS) void QSYGETPH53(char user[10], char* password, char PRFHND[12], ERRSTRUCTURE* errcode, int passlen, int passCCSID); /*************************************************************/ /* グ ロ ー バ ル 変 数 */ /*************************************************************/ char os400[6]; /* OS/400 バージョン */ char PRFHND[13]; char CURHND[13]; /* QTMHHTTP 仮想ログイン・ハンドル */ void main(void){ int len, pos, passlen, passCCSID = 65535, msglen, msgdtalen; char user[11], passwrd[49], msgid[8], msg[513], msgdta[133], errmsg[1024]; char msgtxt[132], ref[133]; char* ptr; _DTAA_NAME_T dtaname = {"QSS1MRI ", "QGPL "}; printf("** TESTGETPH:QSYGETPH のテスト **\n"); getchar(); printf("* ユーザー名を入力してください。 \n"); scanf("%10s", user); while(strlen(user) < 10) strcat(user, " "); printf("* パスワードを入力してください。 \n"); scanf("%10s", passwrd); passlen = strlen(passwrd); printf("user = [%s], passwrd = [%s]\n", user, passwrd); QXXRTVDA(dtaname, 1, 6, os400); errcd53.BYTESPRO = 160; errcd53.BYTESAVL = 0; memset(PRFHND, 0, sizeof(PRFHND)); if(strncmp(os400, "V5R3M0", 6) >= 0){/*V5R3M0*/ pos = triml(passwrd, ' '); if(pos > 0) passwrd[pos] = 0x00; passlen = strlen(passwrd); passCCSID = 65535; QSYGETPH53(user, passwrd, PRFHND, &errcd53, passlen, passCCSID); }/*V5R3M0*/ else{/*CISC-V5R2M0*/ QSYGETPH(user, passwrd, PRFHND, &errcd53); }/*CISC-V5R2M0*/ if(errcd53.BYTESAVL != 0){/* APIERR */ memcpy(msgid, errcd53.MSGID, 7); msgid[7] = 0x00; memcpy(msgdta, errcd53.EXCPDATA, 100); msgdta[100] = 0x00; len = triml(msgdta, ' '); if(len > 0) msgdta[len] = 0x00; msgdtalen = strlen(msgdta); msglen = sizeof(ERRMSG); QMHRTVM(&err_msg, msglen, "RTVM0100", msgid, "QCPFMSG *LIBL ", msgdta, msgdtalen, "*YES ", "*YES ", &errcode); memcpy(msg, err_msg.msg, 512); msg[512] = 0x00; len = triml(msg, ' '); if(len > 0) msg[len] = 0x00; strcpy(msgtxt, msg); ptr = strstr(msgtxt, "&N"); if(ptr != NULL){ pos = (int)(ptr - msgtxt); msgtxt[pos] = 0x00; } sprintf(ref, "LOGIN: USER=%s PASSWRD=%s", user, passwrd); printf("[%d] %s\n", msgid, msgtxt); getchar(); return; }/* APIERR */ /*[ 指定したユーザー・プロフィールで JOB を開始する。 ]*/ QWTSETP(PRFHND); printf(" ユーザー %s で仮想ユーザー環境を開始しました。 \n", user); getchar(); getchar(); system("DSPJOB OPTION(*STSA)"); QSYRLSPH(PRFHND); printf(" ログオフしました。 \n"); getchar(); }