/********************************************************************/ /* */ /* CHKCCSID : CCSID 検査 */ /* */ /* Office Quattro Co,.Ltd 2014/04/28 15:55:28 created */ /* */ /* CRTBNDC QUATTRO/CHKCCSID R610SRC/QCSRC2 */ /* TERASPACE(*YES *TSIFC) STGMDL(*TERASPACE) */ /* */ /********************************************************************/ #pragma comment(COPYRIGHT, "(C) CopyRight \ Office Quattro.Corp. 2014- All right reserved. Users Restricted \ Rights - Use, duplication or disclosure restricted by Office Quattro \ Corp. Licenced Materials-Property of Office Quattro.") #include #include #include #include /* triml */ #include #include #include "asnet.src/h(QUSRSPLA)" /* V5R2M0-V6R1M0 共通 */ #include #include /* QtqValidateCCSID */ #include #include #include #define TRUE 0 #define FALSE -1 #define UNKNOWN -2 #define MAX_HEAP_SIZE 16711600 /* 高速ヒープ・サイズ 16MB*/ #define TERA_HEAP_SIZE 214748324 /* 高速ヒープ・サイズ 2GB */ #define MAX_USRSPACE 16776704 #define JAPAN 1399 #define CHINA 935 #define HONGKONG 937 #define KOREA 933 #define USA 37 volatile _INTRPT_Hndlr_Parms_T ca; typedef struct { int BYTESPRO; int BYTESAVL; char MSGID[7]; char RESRVD; char EXCPDATA[132]; } ERRSTRUCTURE; /* Define the error return structure */ ERRSTRUCTURE errcode;/* Error Code Structure for RCVMSG */ typedef struct { char NM[10]; char LIB[10]; } QNAME; /* Define the qualified name */ QNAME inname; /* Qualified user space name */ char os400[6]; /* OS/400 バージョン */ /*************************************************************/ /* 内 部 使 用  関  数 */ /*************************************************************/ void GetParam(int argc, char *argv[]); void INZSR(void); int getSpoolattr(char* splf, char* jobinfo, int splno); char* getLanguage(int ccsid); /*************************************************************/ /* IMPORT  関  数 */ /*************************************************************/ /*************************************************************/ /* IMPORT  変  数 */ /*************************************************************/ /*************************************************************/ /* 外 部 呼 出 し  関  数 */ /*************************************************************/ /*************************************************************/ /* グ ロ ー バ ル 変 数 */ /*************************************************************/ /*------( 受取りパラメータ値 )----------*/ char SPLF[11], JOBINFO[27], MSGID[8], MSG[133], MSGDTA[133]; int SPLNO; /*------( 受取りパラメータ値 )----------*/ char job[11], user[11], jobnbr[7], LANG[14]; int get_ccsid, Spooled_File_Size, job_ccsid, txt_ccsid; char DBCS_SOSI[10], WHY[48]; typedef struct { Qus_SPLA0200_t spla0200; char Options[20]; } Qsp_SPLA0200_t; Qsp_SPLA0200_t splinfo; long spl_size; /* スプール・バッファー・サイズ */ char* spool_buf; int chk_table[4], CCSID_of_Job; char Dev_File_Lib[11], Dev_File_Name[11]; /********************************************************************/ /* m a i n --- main module of this pgm */ /* */ /* 1. SPLF */ /* 2. JONINFO */ /* 3. SPLNO */ /* 4. MSGID */ /* 5. MSG */ /* 6. MSGDTA */ /* */ /*------------------------------------------------------------------*/ int main(int argc, char *argv[]){ int ccsid, rc; #pragma exception_handler(MONMSG, ca, 0, _C2_MH_ESCAPE, \ _CTLA_HANDLE) GetParam(argc, argv); /*[ パラメータの取得 ]*/ INZSR(); /*[ 初期設定 ]*/ if((ccsid = getSpoolattr(SPLF, JOBINFO, SPLNO)) == FALSE){/* 実行 JOB */ memcpy(argv[4], MSGID, 7); memcpy(argv[5], MSG, 132); memcpy(argv[6], MSGDTA, 132); exit(-1); }/* 実行 JOB */ if(ccsid == UNKNOWN){/* 装置 */ printf("[%d] ccsid is UNKNOW\n", __LINE__); getchar(); }/* 装置 */ exit(0); MONMSG: #pragma disable_handler exit(0); } /*************************************/ void GetParam(int argc, char *argv[]) /*************************************/ { memcpy(SPLF, argv[1], 10); SPLF[10] = 0x00; memcpy(JOBINFO, argv[2], 26); JOBINFO[26] = 0x00; sscanf(JOBINFO, "%10s%10s%6s", job, user, jobnbr); memcpy(&SPLNO, argv[3], 4); } /****************/ void INZSR(void) /****************/ { errcode.BYTESPRO = 160; errcode.BYTESAVL = 0; memset(MSG, ' ', sizeof(MSG)); } /*******************************************************/ int getSpoolattr(char* splf, char* jobinfo, int splno) /*******************************************************/ { Qdc_DEVD0600_t devd0600; int msg_data_len, len, iCode_Page, iGrph_Char_Set, bIGC = FALSE, esr, ccsid int CSCPL[4], su = 2, sel = 0; int default_ccsid; char jobID[16], splID[16], DEVD[11], Code_Page[11], Grph_Char_Set[11]; char JOBCCSID_For_CHRID[2]; typedef struct { short int status; short int reason; char reserved[8]; } FB; FB fb; printf("* getSpoolattr\n"); memset(&splinfo, 0, sizeof(Qsp_SPLA0200_t)); memset(jobID, ' ', sizeof(jobID)); memset(splID, ' ', sizeof(splID)); QUSRSPLA((char*)&splinfo, sizeof(Qus_SPLA0200_t), "SPLA0200", jobinfo, jobID, splID, splf, splno, (char*)&errcode); if(errcode.BYTESAVL != 0){/* APIERR */ memcpy(MSGID, errcode.MSGID, 7); memset(MSGDTA, 0, sizeof(MSGDTA)); msg_data_len = errcode.BYTESAVL; memcpy(MSGDTA, errcode.EXCPDATA, msg_data_len); return FALSE; }/* APIERR */ memcpy(Code_Page, splinfo.spla0200.Code_Page, 10); Code_Page[10] = 0x00; printf("[%d] Code_Page = [%s]\n", __LINE__, Code_Page); memcpy(Grph_Char_Set, splinfo.spla0200.Grph_Char_Set, 10); Grph_Char_Set[10] = 0x00; printf("[%d] Grph_Char_Set=[%s]\n", __LINE__, Grph_Char_Set); ccsid = splinfo.spla0200.CCSID; printf("[%d] ccsid = %d\n", __LINE__, ccsid); memcpy(JOBCCSID_For_CHRID, splinfo.spla0200.JOBCCSID_For_CHRID, 1); printf("[%d] JOBCCSID_For_CHRID = 0x%02x\n", __LINE__, JOBCCSID_For_CHRID); if(strncmp(Code_Page, "*DEVD", 5) == 0){/*DEVD*/ memcpy(DEVD, splinfo.spla0200.Job_Name, 10); DEVD[10] = 0x00; QDCRDEVD(&devd0600, sizeof(devd0600), "DEVD0600", DEVD, (char*)&errcode); if(errcode.BYTESAVL != 0){/* APIERR */ memcpy(MSGID, errcode.MSGID, 7); memset(MSGDTA, 0, sizeof(MSGDTA)); msg_data_len = errcode.BYTESAVL; memcpy(MSGDTA, errcode.EXCPDATA, msg_data_len); return FALSE; }/* APIERR */ iCode_Page = devd0600.Char_ID_Code_Page; iGrph_Char_Set = devd0600.Char_ID_Graphic_Char_Set; printf("language ID = %10.10s\n", devd0600.DBCS_Feature_Language_ID); printf("Last code point = %10.10s\n", devd0600.DBCS_Feature_Last_Code_Point printf("Matrix Size = %10.10s\n", devd0600.DBCS_Feature_Matrix_Size); if(strncmp(devd0600.Keyboard_Language_Type, "JKB", 3) == 0 || /*Japan*/ strncmp(devd0600.Keyboard_Language_Type, "KOB", 3) == 0 || /* Korea */ strncmp(devd0600.Keyboard_Language_Type, "RCB", 3) == 0 || /* CHS */ strncmp(devd0600.Keyboard_Language_Type, "TAB", 3) == 0 || /* CHT */ strncmp(devd0600.Keyboard_Language_Type, "THB", 3) == 0){/* 漢字 */ bIGC = TRUE; }/* 漢字 */ else bIGC = FALSE; if(devd0600.DBCS_Feature_RAM_Size > 0) bIGC = TRUE; else bIGC = FALSE; getchar(); }/*DEVD*/ else{/* その他 */ iCode_Page = atoi(Code_Page); iGrph_Char_Set = atoi(Grph_Char_Set); }/* その他 */ if(strncmp(splinfo.spla0200.DBCS_Data, "*YES", 4) == 0) bIGC = 0x1301; else bIGC = 0x1100; CCSID_of_Job = splinfo.spla0200.CCSID_of_Job; printf("[%d] iGrph_Char_Set = %d\n", __LINE__, iGrph_Char_Set); printf("[%d] iCode_Page = %d\n", __LINE__, iCode_Page); printf("[%d] bIGC = %d\n", __LINE__, bIGC); printf("[%d] CCSID_of_Job = %d\n", __LINE__, CCSID_of_Job); /*( CCSID の取得 )*/ memset(&fb, 0, sizeof(FB)); CSCPL[0] = iGrph_Char_Set; CSCPL[1] = iCode_Page; CSCPL[2] = 370; CSCPL[3] = 300; QTQSCSP(&CSCPL, &su, &bIGC, &ccsid, &esr, (void*)&fb); printf("[%d] QTQSCSP ccsid=%d\n", __LINE__, ccsid); printf("[%d] QTQSCSP status=%d, reason=%d\n", __LINE__, fb.status, fb.reason) getchar(); QTQGRDC(&ccsid, &bIGC, &sel, &default_ccsid, &fb); printf("[%d] QTQGRDC ccsid=%d\n", __LINE__, default_ccsid); printf("[%d] QTQGRDC status=%d, reason=%d\n", __LINE__, fb.status, fb.reason) getchar(); return ccsid; return UNKNOWN; } /***************************/ char* getLanguage(int ccsid) /***************************/ { char LANG[14]; switch(ccsid){/*switch*/ case 5026: case 5035: case 1399: case 290: case 300: case 301: case 897: case 930: case 932: case 942: case 1027: case 1041: case 4396: case 57345: strcpy(LANG, " 日本語 "); break; case 37: strcpy(LANG, " 英語 "); break; case 935: case 836: case 837: case 903: case 928: case 936: case 946: case 1042: case 1115: case 1380: case 1381: strcpy(LANG, " 中国簡体字 "); break; case 937: case 835: case 904: case 927: case 938: case 948: case 950: case 1043: case 1114: case 28709: strcpy(LANG, " 中国繁体字 "); break; case 833: case 834: case 891: case 926: case 933: case 934: case 944: case 949: case 951: case 1040: case 1088: strcpy(LANG, " 韓国語 "); break; default: strcpy(LANG, " 不明 "); break; }/*switch*/ return LANG; }