Difference between revisions of "CQDFRTVFD"
(fix the #NEXT logic) |
(fix #NEXT Logic) |
||
Line 604: | Line 604: | ||
DISPINFOC1 | DISPINFOC1 | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | /* Function: This program uses the QDFRTVFD API to return the */ | ||
+ | /* structure of a display file. */ | ||
+ | |||
+ | |||
+ | #include <stdio.h> | ||
+ | #include <stdlib.h> | ||
+ | #include <string.h> | ||
+ | #include "QSYSINC/H/QUSEC" | ||
+ | #include "QSYSINC/H/QDFRTVFD" | ||
+ | |||
+ | #include <mispace.h> | ||
+ | #include <pointer.h> | ||
+ | #include <mispcobj.h> | ||
+ | #include <except.h> | ||
+ | #include <qtes.h> | ||
+ | |||
+ | |||
/* Link up the Create User Space API */ | /* Link up the Create User Space API */ | ||
#pragma linkage(CreateUserSpace,OS) | #pragma linkage(CreateUserSpace,OS) | ||
#pragma map(CreateUserSpace,"QUSCRTUS") | #pragma map(CreateUserSpace,"QUSCRTUS") | ||
− | + | ||
void CreateUserSpace(char[20], | void CreateUserSpace(char[20], | ||
char[10], | char[10], | ||
Line 635: | Line 636: | ||
_TE_ERROR_CODE_T * | _TE_ERROR_CODE_T * | ||
); | ); | ||
− | + | ||
/* Link up the Delete User Space API */ | /* Link up the Delete User Space API */ | ||
#pragma linkage(DeleteUserSpace,OS) | #pragma linkage(DeleteUserSpace,OS) | ||
Line 642: | Line 643: | ||
_TE_ERROR_CODE_T * | _TE_ERROR_CODE_T * | ||
); | ); | ||
− | + | ||
/* Link up the Retrieve Pointer to User Space API */ | /* Link up the Retrieve Pointer to User Space API */ | ||
#pragma linkage(RetrievePointerToUserSpace,OS) | #pragma linkage(RetrievePointerToUserSpace,OS) | ||
Line 650: | Line 651: | ||
_TE_ERROR_CODE_T * | _TE_ERROR_CODE_T * | ||
); | ); | ||
− | + | ||
− | + | ||
− | #define EQ == | + | #define EQ == |
− | + | ||
− | #define fail() do { printf("\nLine %d FAILED in file %s", \ | + | #define fail() do { printf("\nLine %d FAILED in file %s", \ |
− | __LINE__,__FILE__); \ | + | __LINE__,__FILE__); \ |
− | } while(0) | + | } while(0) |
− | + | ||
/* Pointers to structures required to be used by this program. */ | /* Pointers to structures required to be used by this program. */ | ||
− | QDFFBASE_t *p_QDFFBASE; | + | QDFFBASE_t *p_QDFFBASE; |
− | QDFFINFO_t *p_QDFFINFO; | + | QDFFINFO_t *p_QDFFINFO; |
− | QDFARFTE_t *p_QDFARFTE; | + | QDFARFTE_t *p_QDFARFTE; |
− | QDFFRINF_t *p_QDFFRINF; | + | QDFFRINF_t *p_QDFFRINF; |
− | QDFFDPDD_t *p_QDFFDPDD; | + | QDFFDPDD_t *p_QDFFDPDD; |
− | QDFFRDPD_t *p_QDFFRDPD; | + | QDFFRDPD_t *p_QDFFRDPD; |
− | QDFWFLEI_t *p_QDFWFLEI; | + | QDFWFLEI_t *p_QDFWFLEI; |
− | QDFFNTBL_t *p_QDFFNTBL; | + | QDFFNTBL_t *p_QDFFNTBL; |
− | QDFWRCDI_t *p_QDFWRCDI; | + | QDFWRCDI_t *p_QDFWRCDI; |
− | QDFWFLDI_t *p_QDFWFLDI; | + | QDFWFLDI_t *p_QDFWFLDI; |
− | QDFFSFCR_t *p_QDFFSFCR; | + | QDFFSFCR_t *p_QDFFSFCR; |
− | QDFFSFHR_t *p_QDFFSFHR; | + | QDFFSFHR_t *p_QDFFSFHR; |
− | QDFFSCRA_t *p_QDFFSCRA; | + | QDFFSCRA_t *p_QDFFSCRA; |
− | QDFFFITB_t *p_QDFFFITB; | + | QDFFFITB_t *p_QDFFFITB; |
− | QDFFFINF_t *p_QDFFFINF; | + | QDFFFINF_t *p_QDFFFINF; |
− | QDFFFCON_t *p_QDFFFCON; | + | QDFFFCON_t *p_QDFFFCON; |
− | QDFFFDPD_t *p_QDFFFDPD; | + | QDFFFDPD_t *p_QDFFFDPD; |
− | QDFFFNAM_t *p_QDFFFNAM; | + | QDFFFNAM_t *p_QDFFFNAM; |
− | QDFFFDIC_t *p_QDFFFDIC; | + | QDFFFDIC_t *p_QDFFFDIC; |
− | QDFFXFDP_t *p_QDFFXFDP; | + | QDFFXFDP_t *p_QDFFXFDP; |
− | QDFFRCTB_t *p_QDFFRCTB; | + | QDFFRCTB_t *p_QDFFRCTB; |
− | QDFFRCTE_t *p_QDFFRCTE; | + | QDFFRCTE_t *p_QDFFRCTE; |
− | QDFFNTB_t *p_QDFFNTB; | + | QDFFNTB_t *p_QDFFNTB; |
− | QDFFCOSA_t *p_QDFFCOSA; | + | QDFFCOSA_t *p_QDFFCOSA; |
− | QDFFCCOA_t *p_QDFFCCOA; | + | QDFFCCOA_t *p_QDFFCCOA; |
− | QDFKMFDK_t *p_QDFKMFDK; | + | QDFKMFDK_t *p_QDFKMFDK; |
− | QDFKDFT_t *p_QDFKDFT; | + | QDFKDFT_t *p_QDFKDFT; |
− | QDFKEDTR_t *p_QDFKEDTR; | + | QDFKEDTR_t *p_QDFKEDTR; |
− | QDFKDFPM_t *p_QDFKDFPM; | + | QDFKDFPM_t *p_QDFKDFPM; |
− | + | ||
− | + | ||
/* Global variables */ | /* Global variables */ | ||
char *p_iLib; | char *p_iLib; | ||
Line 695: | Line 696: | ||
char *p_iRecord; | char *p_iRecord; | ||
char *p_iField; | char *p_iField; | ||
− | + | int *p_iNumFld; | |
− | |||
char *p_iFunc; | char *p_iFunc; | ||
− | + | ||
− | /* returned data */ | + | /* returned data */ |
typedef struct FieldData { | typedef struct FieldData { | ||
char RecordName[10]; | char RecordName[10]; | ||
Line 711: | Line 711: | ||
int FldDec; | int FldDec; | ||
int EndDta; | int EndDta; | ||
+ | int NumFld; | ||
} FieldData_t; | } FieldData_t; | ||
− | + | ||
− | FieldData_t *p_FieldData; | + | FieldData_t *p_FieldData; |
− | FieldData_t *Odata; | + | FieldData_t *Odata; |
− | + | ||
typedef struct inputArguments | typedef struct inputArguments | ||
{ | { | ||
Line 723: | Line 724: | ||
char *iRecord; | char *iRecord; | ||
char *iField; | char *iField; | ||
− | + | int *iFld; | |
− | |||
char *iFunc; | char *iFunc; | ||
FieldData_t *iOdata; | FieldData_t *iOdata; | ||
} main_args_t; | } main_args_t; | ||
− | + | ||
int RtvApiDta (void); | int RtvApiDta (void); | ||
int ProcessRec (void); | int ProcessRec (void); | ||
Line 736: | Line 736: | ||
int ProcessCat23(void); | int ProcessCat23(void); | ||
int ProcessCat24(void); | int ProcessCat24(void); | ||
− | + | ||
int RecIndex; | int RecIndex; | ||
− | + | ||
/* Area into which the QDFRTVFD returns the requested data.*/ | /* Area into which the QDFRTVFD returns the requested data.*/ | ||
− | + | ||
char *pBuffer; | char *pBuffer; | ||
_TE_ERROR_CODE_T errorCode; | _TE_ERROR_CODE_T errorCode; | ||
− | + | ||
− | + | ||
char FileName[20] = " "; | char FileName[20] = " "; | ||
char Format[8]; | char Format[8]; | ||
int EndFlds = 0; | int EndFlds = 0; | ||
− | + | ||
/* 4 bytes WDFFRETN Length of the returned data. */ | /* 4 bytes WDFFRETN Length of the returned data. */ | ||
/* 4 bytes WDFFSIZE Size of the display file description */ | /* 4 bytes WDFFSIZE Size of the display file description */ | ||
Line 756: | Line 756: | ||
int ReturnSiz; | int ReturnSiz; | ||
} RtvSizeInfo_t; | } RtvSizeInfo_t; | ||
− | + | ||
− | + | ||
− | + | ||
/* ######################################################## */ | /* ######################################################## */ | ||
− | int main(int argc, main_args_t *main_args) | + | int main(int argc, main_args_t *main_args) |
− | { | + | { |
− | + | ||
char Funct[10] = " "; | char Funct[10] = " "; | ||
− | + | ||
p_iFile = main_args->iFile; | p_iFile = main_args->iFile; | ||
p_iLib = main_args->iLib; | p_iLib = main_args->iLib; | ||
p_iRecord = main_args->iRecord; | p_iRecord = main_args->iRecord; | ||
p_iField = main_args->iField; | p_iField = main_args->iField; | ||
− | + | p_iNumFld = main_args->iFld; | |
− | |||
p_iFunc = main_args->iFunc; | p_iFunc = main_args->iFunc; | ||
Odata = main_args->iOdata; | Odata = main_args->iOdata; | ||
− | + | ||
− | + | ||
− | + | ||
/* On First pass get the API data */ | /* On First pass get the API data */ | ||
memmove(Funct,p_iFunc, strlen(p_iFunc)); | memmove(Funct,p_iFunc, strlen(p_iFunc)); | ||
Line 781: | Line 780: | ||
RtvApiDta(); | RtvApiDta(); | ||
}; | }; | ||
− | + | ||
if (!memcmp(Funct, "#NEXT", 5)) { | if (!memcmp(Funct, "#NEXT", 5)) { | ||
/*! call RetrievePointerToUserSpace - Retrieve Pointer to User Space */ | /*! call RetrievePointerToUserSpace - Retrieve Pointer to User Space */ | ||
Line 789: | Line 788: | ||
&errorCode); | &errorCode); | ||
} | } | ||
− | + | ||
ProcessRec(); | ProcessRec(); | ||
− | + | ||
− | + | ||
/* free(ReturnVar); */ | /* free(ReturnVar); */ | ||
− | } | + | } |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
/* ######################################### */ | /* ######################################### */ | ||
− | + | ||
RtvApiDta() { | RtvApiDta() { | ||
− | + | ||
RtvSizeInfo_t *RtvSize; | RtvSizeInfo_t *RtvSize; | ||
int API_Len; | int API_Len; | ||
− | + | ||
Qus_EC_t Error_Code = {0}; | Qus_EC_t Error_Code = {0}; | ||
− | + | ||
− | + | ||
/* Define the API format requested and the display file to access */ | /* Define the API format requested and the display file to access */ | ||
memcpy(Format,"DSPF0100",8); | memcpy(Format,"DSPF0100",8); | ||
Line 814: | Line 813: | ||
memmove(FileName,p_iFile, strlen(p_iFile)); | memmove(FileName,p_iFile, strlen(p_iFile)); | ||
memmove(FileName + 10 ,p_iLib, strlen(p_iLib )); | memmove(FileName + 10 ,p_iLib, strlen(p_iLib )); | ||
− | + | ||
/* Invoke the API. to get the size needed */ | /* Invoke the API. to get the size needed */ | ||
RtvSize = malloc(8); | RtvSize = malloc(8); | ||
Line 828: | Line 827: | ||
API_Len = RtvSize->ReturnSiz; | API_Len = RtvSize->ReturnSiz; | ||
free(RtvSize); | free(RtvSize); | ||
− | + | ||
CreateUserSpace("RTVFDUSPC QTEMP ", | CreateUserSpace("RTVFDUSPC QTEMP ", | ||
"USRSPC ", | "USRSPC ", | ||
Line 838: | Line 837: | ||
&errorCode | &errorCode | ||
); | ); | ||
− | + | ||
/*! call RetrievePointerToUserSpace - Retrieve Pointer to User Space */ | /*! call RetrievePointerToUserSpace - Retrieve Pointer to User Space */ | ||
/*!! (pass: Name and library of user space, pointer variable */ | /*!! (pass: Name and library of user space, pointer variable */ | ||
Line 847: | Line 846: | ||
&pBuffer, | &pBuffer, | ||
&errorCode); | &errorCode); | ||
− | + | ||
QDFRTVFD (pBuffer, | QDFRTVFD (pBuffer, | ||
API_Len, | API_Len, | ||
Line 859: | Line 858: | ||
} | } | ||
} | } | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
/* ######################################### */ | /* ######################################### */ | ||
int ProcessRec() { | int ProcessRec() { | ||
− | + | ||
int NumRecs; | int NumRecs; | ||
int i; | int i; | ||
Line 878: | Line 877: | ||
p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWFLEI + p_QDFWFLEI->WDFWXLEN); | p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWFLEI + p_QDFWFLEI->WDFWXLEN); | ||
p_QDFFNTBL = (QDFFNTBL_t *)((char *) p_QDFWFLEI + p_QDFWFLEI->WDFWNTBO); | p_QDFFNTBL = (QDFFNTBL_t *)((char *) p_QDFWFLEI + p_QDFWFLEI->WDFWNTBO); | ||
− | + | ||
/* here is the place to retreive File Keywords */ | /* here is the place to retreive File Keywords */ | ||
− | + | ||
NumRecs = p_QDFFBASE->WDFFRCS; | NumRecs = p_QDFFBASE->WDFFRCS; | ||
− | + | ||
for (i=0; i< NumRecs ; ++i) { | for (i=0; i< NumRecs ; ++i) { | ||
− | + | ||
/* Bump ptr to next record structure */ | /* Bump ptr to next record structure */ | ||
if (i != 0) | if (i != 0) | ||
{p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWNXTR); | {p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWNXTR); | ||
p_QDFARFTE = (QDFARFTE_t *)((char *) p_QDFARFTE + sizeof(QDFARFTE_t)); } | p_QDFARFTE = (QDFARFTE_t *)((char *) p_QDFARFTE + sizeof(QDFARFTE_t)); } | ||
− | + | ||
memcpy(Odata->RecordName, | memcpy(Odata->RecordName, | ||
p_QDFARFTE->WDFARFNM,sizeof(p_QDFARFTE->WDFARFNM)); | p_QDFARFTE->WDFARFNM,sizeof(p_QDFARFTE->WDFARFNM)); | ||
− | + | ||
if (i EQ NumRecs - 1) { | if (i EQ NumRecs - 1) { | ||
EndFlds = 1; | EndFlds = 1; | ||
} | } | ||
− | + | ||
ProcessField(&GotIt); | ProcessField(&GotIt); | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
− | + | ||
− | } | + | } |
− | + | ||
/* ######################################### */ | /* ######################################### */ | ||
− | + | ||
int ProcessField(int *GotIt) { | int ProcessField(int *GotIt) { | ||
− | + | ||
int SflCtl; | int SflCtl; | ||
int SizeIdx; | int SizeIdx; | ||
Line 917: | Line 916: | ||
char X01 = 0x01 ; | char X01 = 0x01 ; | ||
char Functn[10] = " "; | char Functn[10] = " "; | ||
− | + | ||
+ | NumFlds = 0; | ||
+ | |||
/* record header */ | /* record header */ | ||
p_QDFFRINF = (QDFFRINF_t *)((char *) p_QDFFINFO + p_QDFARFTE->WDFARFOF); | p_QDFFRINF = (QDFFRINF_t *)((char *) p_QDFFINFO + p_QDFARFTE->WDFARFOF); | ||
Line 933: | Line 934: | ||
p_QDFFSFHR = (QDFFSFHR_t *)((char *) p_QDFFSFCR + sizeof(QDFFSFCR_t)); | p_QDFFSFHR = (QDFFSFHR_t *)((char *) p_QDFFSFCR + sizeof(QDFFSFCR_t)); | ||
} | } | ||
− | + | ||
for (SizeIdx=0; SizeIdx<p_QDFFBASE->WDFFSCR ; ++SizeIdx) { | for (SizeIdx=0; SizeIdx<p_QDFFBASE->WDFFSCR ; ++SizeIdx) { | ||
p_QDFFSCRA = (QDFFSCRA_t *)((char *) p_QDFFBASE + sizeof(QDFFBASE_t) | p_QDFFSCRA = (QDFFSCRA_t *)((char *) p_QDFFBASE + sizeof(QDFFBASE_t) | ||
Line 945: | Line 946: | ||
/* used. */ | /* used. */ | ||
p_QDFFRCTB = (QDFFRCTB_t *)((char *) p_QDFFRINF + p_QDFFRDPD->WDFFDRCO); | p_QDFFRCTB = (QDFFRCTB_t *)((char *) p_QDFFRINF + p_QDFFRDPD->WDFFDRCO); | ||
− | + | ||
/******** HERE include code for Record Keywords ********/ | /******** HERE include code for Record Keywords ********/ | ||
− | + | ||
/* PROCESS THE RECORDS FIELDS */ | /* PROCESS THE RECORDS FIELDS */ | ||
/* Find where used section */ | /* Find where used section */ | ||
− | + | ||
p_QDFWFLDI = (QDFWFLDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWRLEN); | p_QDFWFLDI = (QDFWFLDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWRLEN); | ||
p_QDFFFITB = (QDFFFITB_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFOFIT | p_QDFFFITB = (QDFFFITB_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFOFIT | ||
+ ( p_QDFWFLDI->WDFWRRDX -1) * sizeof(QDFFFITB_t)); | + ( p_QDFWFLDI->WDFWRRDX -1) * sizeof(QDFFFITB_t)); | ||
− | + | ||
− | + | ||
for (FldIdx=0; FldIdx < p_QDFFRINF->WDFFFLD; ++FldIdx) { | for (FldIdx=0; FldIdx < p_QDFFRINF->WDFFFLD; ++FldIdx) { | ||
− | + | ||
/* Field Header */ | /* Field Header */ | ||
p_QDFFFINF = (QDFFFINF_t *)((char *) p_QDFFRINF + p_QDFFFITB->WDFFFOFS); | p_QDFFFINF = (QDFFFINF_t *)((char *) p_QDFFRINF + p_QDFFFITB->WDFFFOFS); | ||
− | + | ||
if (p_QDFFFINF->WDFFFIOA EQ 0x01) { | if (p_QDFFFINF->WDFFFIOA EQ 0x01) { | ||
/* constant */ | /* constant */ | ||
Line 974: | Line 975: | ||
/* Field Extension */ | /* Field Extension */ | ||
p_QDFFXFDP = (QDFFXFDP_t *)((char *) p_QDFFFINF + p_QDFFFDPD->WDFFXFDO); | p_QDFFXFDP = (QDFFXFDP_t *)((char *) p_QDFFFINF + p_QDFFFDPD->WDFFXFDO); | ||
− | + | ||
/* Row Column */ | /* Row Column */ | ||
p_QDFFRCTB = (QDFFRCTB_t *)((char *) p_QDFFRINF + p_QDFFRDPD->WDFFDRCO | p_QDFFRCTB = (QDFFRCTB_t *)((char *) p_QDFFRINF + p_QDFFRDPD->WDFFDRCO | ||
+ (p_QDFWFLDI->WDFWRRDX - 1) *2); | + (p_QDFWFLDI->WDFWRRDX - 1) *2); | ||
p_QDFFRCTE = (QDFFRCTE_t *)((char *) p_QDFFRCTB + sizeof(QDFFRCTB_t)); | p_QDFFRCTE = (QDFFRCTE_t *)((char *) p_QDFFRCTB + sizeof(QDFFRCTB_t)); | ||
− | + | ||
*Odata->ROW = p_QDFFRCTE->WDFFSROW; | *Odata->ROW = p_QDFFRCTE->WDFFSROW; | ||
*Odata->COL = p_QDFFRCTE->WDFFSCOL; | *Odata->COL = p_QDFFRCTE->WDFFSCOL; | ||
− | + | ||
/* here can extract data time flags */ | /* here can extract data time flags */ | ||
− | + | ||
/* CONSTANTS */ | /* CONSTANTS */ | ||
if (p_QDFFFINF->WDFFFIOA EQ 0x01) { | if (p_QDFFFINF->WDFFFIOA EQ 0x01) { | ||
/* constant */ | /* constant */ | ||
ProcessCons(); | ProcessCons(); | ||
− | + | ||
} | } | ||
else { | else { | ||
/* Field Name */ | /* Field Name */ | ||
− | + | ||
p_QDFFNTB = (QDFFNTB_t *)((char *) p_QDFFNTBL + sizeof(QDFFNTBL_t) | p_QDFFNTB = (QDFFNTB_t *)((char *) p_QDFFNTBL + sizeof(QDFFNTBL_t) | ||
+ 10 * (p_QDFWFLDI->WDFWNMEI -1) ); | + 10 * (p_QDFWFLDI->WDFWNMEI -1) ); | ||
− | + | ||
− | + | ||
/*Field attribute. */ | /*Field attribute. */ | ||
/*X'01' indicates Constant (see structure QDFFFCON, Constant Field */ | /*X'01' indicates Constant (see structure QDFFFCON, Constant Field */ | ||
Line 1,007: | Line 1,008: | ||
/*X'07' indicates Program to System (P) */ | /*X'07' indicates Program to System (P) */ | ||
*Odata->FldIO = p_QDFFFINF->WDFFFIOA; | *Odata->FldIO = p_QDFFFINF->WDFFFIOA; | ||
− | + | ||
/* Keyboard shift and data type. */ | /* Keyboard shift and data type. */ | ||
/* X'00' indicates Alpha shift/character (A), */ | /* X'00' indicates Alpha shift/character (A), */ | ||
− | + | ||
− | + | ||
*Odata->FldAtr = p_QDFFFNAM->WDFFKBDT; | *Odata->FldAtr = p_QDFFFNAM->WDFFKBDT; | ||
memcpy(Odata->FldNam, | memcpy(Odata->FldNam, | ||
Line 1,019: | Line 1,020: | ||
Odata->FldDec = p_QDFFFNAM->WDFFDEC; | Odata->FldDec = p_QDFFFNAM->WDFFDEC; | ||
} | } | ||
− | + | ||
/*********** HERE include code for Field KEYWORDS **********/ | /*********** HERE include code for Field KEYWORDS **********/ | ||
if (FldIdx < p_QDFFRINF->WDFFFLD -1) { | if (FldIdx < p_QDFFRINF->WDFFFLD -1) { | ||
Line 1,026: | Line 1,027: | ||
+ ( p_QDFWFLDI->WDFWRRDX -1) * sizeof(QDFFFITB_t)); | + ( p_QDFWFLDI->WDFWRRDX -1) * sizeof(QDFFFITB_t)); | ||
} | } | ||
− | + | ||
NumFlds += 1; | NumFlds += 1; | ||
− | + | ||
+ | Odata->NumFld = NumFlds; | ||
Odata->EndDta = 0; | Odata->EndDta = 0; | ||
− | + | ||
/* End ofthe Fields */ | /* End ofthe Fields */ | ||
if ((EndFlds EQ 1) && (FldIdx EQ p_QDFFRINF->WDFFFLD -1) ) { | if ((EndFlds EQ 1) && (FldIdx EQ p_QDFFRINF->WDFFFLD -1) ) { | ||
Line 1,038: | Line 1,040: | ||
&errorCode); | &errorCode); | ||
}; | }; | ||
− | + | ||
/* Return the requested Field */ | /* Return the requested Field */ | ||
memmove(Functn,p_iFunc, strlen(p_iFunc)); | memmove(Functn,p_iFunc, strlen(p_iFunc)); | ||
− | + | ||
if (!memcmp(Functn , "#FIRST", 6)) { | if (!memcmp(Functn , "#FIRST", 6)) { | ||
*GotIt = 1; | *GotIt = 1; | ||
}; | }; | ||
− | + | ||
if (*GotIt) { | if (*GotIt) { | ||
*GotIt = 0; | *GotIt = 0; | ||
exit(0); | exit(0); | ||
}; | }; | ||
− | + | ||
/* We know we are about to get the NEXT record when we have */ | /* We know we are about to get the NEXT record when we have */ | ||
/* found the record just before */ | /* found the record just before */ | ||
+ | if (!memcmp(Functn , "#NEXT" , 5) && | ||
+ | !memcmp(p_iRecord, Odata->RecordName, 10) && | ||
+ | !memcmp(p_iField, Odata->FldNam, 10 ) && | ||
+ | (*p_iNumFld EQ NumFlds)) | ||
+ | *GotIt = 1; | ||
+ | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | + | ||
− | } | + | } |
− | + | ||
/* ######################################### */ | /* ######################################### */ | ||
− | + | ||
int ProcessCons() { | int ProcessCons() { | ||
/*------------------------------------------------*/ | /*------------------------------------------------*/ | ||
Line 1,074: | Line 1,075: | ||
/* for a constant field (text on the screen.) */ | /* for a constant field (text on the screen.) */ | ||
/*------------------------------------------------*/ | /*------------------------------------------------*/ | ||
− | + | ||
int cc; | int cc; | ||
− | + | ||
if (p_QDFFFDPD->WDFFFDOC > 0) { | if (p_QDFFFDPD->WDFFFDOC > 0) { | ||
− | + | ||
/* p_QDFFRINF = (QDFFRINF_t *)((char *) p_QDFFINFO + p_QDFFFINF );*/ | /* p_QDFFRINF = (QDFFRINF_t *)((char *) p_QDFFINFO + p_QDFFFINF );*/ | ||
/* p_QDFFRINF = p_QDFFINFO + QDFARFTE.WDFARFOF */ | /* p_QDFFRINF = p_QDFFINFO + QDFARFTE.WDFARFOF */ | ||
− | + | ||
p_QDFFCOSA = (QDFFCOSA_t *) ((char *) p_QDFFFINF + | p_QDFFCOSA = (QDFFCOSA_t *) ((char *) p_QDFFFINF + | ||
p_QDFFFDPD->WDFFFDOC); | p_QDFFFDPD->WDFFFDOC); | ||
cc = 0; | cc = 0; | ||
for (cc=0; cc<=p_QDFFCOSA->WDFFCCT -1 ; ++cc) { | for (cc=0; cc<=p_QDFFCOSA->WDFFCCT -1 ; ++cc) { | ||
− | + | ||
p_QDFFCCOA = (QDFFCCOA_t *)((char *) p_QDFFCOSA + | p_QDFFCCOA = (QDFFCCOA_t *)((char *) p_QDFFCOSA + | ||
sizeof(QDFFCOSA_t) + sizeof(QDFFCCOA_t) * cc); | sizeof(QDFFCOSA_t) + sizeof(QDFFCCOA_t) * cc); | ||
− | + | ||
− | + | ||
if (p_QDFFCCOA->WDFFCAID EQ 0x22) { | if (p_QDFFCCOA->WDFFCAID EQ 0x22) { | ||
p_QDFKMFDK = (QDFKMFDK_t *)((char *) p_QDFFFINF + | p_QDFKMFDK = (QDFKMFDK_t *)((char *) p_QDFFFINF + | ||
Line 1,096: | Line 1,097: | ||
ProcessCat22(); | ProcessCat22(); | ||
} | } | ||
− | + | ||
− | + | ||
if (p_QDFFCCOA->WDFFCAID EQ 0x23) { | if (p_QDFFCCOA->WDFFCAID EQ 0x23) { | ||
p_QDFKDFT = (QDFKDFT_t *)((char *) p_QDFFFINF + | p_QDFKDFT = (QDFKDFT_t *)((char *) p_QDFFFINF + | ||
Line 1,103: | Line 1,104: | ||
ProcessCat23(); | ProcessCat23(); | ||
} | } | ||
− | + | ||
− | + | ||
if (p_QDFFCCOA->WDFFCAID EQ 0x24) { | if (p_QDFFCCOA->WDFFCAID EQ 0x24) { | ||
p_QDFKEDTR = (QDFKEDTR_t *)((char *) p_QDFFFINF + | p_QDFKEDTR = (QDFKEDTR_t *)((char *) p_QDFFFINF + | ||
Line 1,110: | Line 1,111: | ||
ProcessCat24(); | ProcessCat24(); | ||
} | } | ||
− | + | ||
} | } | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
− | + | ||
− | + | ||
− | } | + | } |
− | + | ||
/* ######################################### */ | /* ######################################### */ | ||
− | + | ||
int ProcessCat22() { | int ProcessCat22() { | ||
/*-----------------------------------------------*/ | /*-----------------------------------------------*/ | ||
Line 1,129: | Line 1,130: | ||
/*-----------------------------------------------*/ | /*-----------------------------------------------*/ | ||
} | } | ||
− | + | ||
/* ######################################### */ | /* ######################################### */ | ||
− | + | ||
int ProcessCat23() { | int ProcessCat23() { | ||
/*------------------------------------------------*/ | /*------------------------------------------------*/ | ||
Line 1,137: | Line 1,138: | ||
/* category 23 (DFT, MSGCON, DFTVAL, HTML) */ | /* category 23 (DFT, MSGCON, DFTVAL, HTML) */ | ||
/*------------------------------------------------*/ | /*------------------------------------------------*/ | ||
− | typedef _Packed struct KwdData { | + | typedef _Packed struct KwdData { |
char Temp[3000]; | char Temp[3000]; | ||
} KwdData_t; | } KwdData_t; | ||
− | + | ||
KwdData_t *p_KwdData; | KwdData_t *p_KwdData; | ||
int ck; | int ck; | ||
− | + | ||
for (ck=1; ck <= p_QDFKDFT->WDFKDFS ; ++ck) { | for (ck=1; ck <= p_QDFKDFT->WDFKDFS ; ++ck) { | ||
− | + | ||
if (ck EQ 1 ) { | if (ck EQ 1 ) { | ||
p_QDFKDFPM = (QDFKDFPM_t *)((char *) p_QDFKDFT + sizeof(QDFKDFT_t)); } | p_QDFKDFPM = (QDFKDFPM_t *)((char *) p_QDFKDFT + sizeof(QDFKDFT_t)); } | ||
else | else | ||
{p_QDFKDFPM = (QDFKDFPM_t *)((char *) p_QDFKDFPM + sizeof(QDFKDFPM_t)); } | {p_QDFKDFPM = (QDFKDFPM_t *)((char *) p_QDFKDFPM + sizeof(QDFKDFPM_t)); } | ||
− | + | ||
if (p_QDFKDFPM->WDFKDFID EQ 0x01) { | if (p_QDFKDFPM->WDFKDFID EQ 0x01) { | ||
− | + | ||
memcpy(Odata->FldNam," ",10); | memcpy(Odata->FldNam," ",10); | ||
− | + | ||
Odata->FldPlen = p_QDFKDFPM->WDFKDFLN; | Odata->FldPlen = p_QDFKDFPM->WDFKDFLN; | ||
*Odata->FldIO = p_QDFFFINF->WDFFFIOA; | *Odata->FldIO = p_QDFFFINF->WDFFFIOA; | ||
p_KwdData = (KwdData_t *) ((char *) p_QDFKDFPM + sizeof(QDFKDFPM_t) ); | p_KwdData = (KwdData_t *) ((char *) p_QDFKDFPM + sizeof(QDFKDFPM_t) ); | ||
+ | memset(Odata->FldCom, ' ',3000); | ||
memcpy(Odata->FldCom, | memcpy(Odata->FldCom, | ||
p_KwdData->Temp, p_QDFKDFPM->WDFKDFLN); | p_KwdData->Temp, p_QDFKDFPM->WDFKDFLN); | ||
− | + | ||
} | } | ||
− | + | ||
} | } | ||
− | + | ||
− | + | ||
} | } | ||
− | + | ||
/* ######################################### */ | /* ######################################### */ | ||
− | + | ||
int ProcessCat24() { | int ProcessCat24() { | ||
/*-----------------------------------------------*/ | /*-----------------------------------------------*/ | ||
Line 1,175: | Line 1,177: | ||
/* category 24 (Date, Time) */ | /* category 24 (Date, Time) */ | ||
/*-----------------------------------------------*/ | /*-----------------------------------------------*/ | ||
+ | memcpy(Odata->FldNam," ",10); | ||
+ | memset(Odata->FldCom, ' ',3000); | ||
} | } | ||
− | + | ||
− | + | ||
− | |||
− | |||
RTVFLD1 | RTVFLD1 | ||
+ | |||
h Option(*NODEBUGIO) DFTACTGRP(*NO) | h Option(*NODEBUGIO) DFTACTGRP(*NO) | ||
− | + | ||
D RTVFLD1 PR | D RTVFLD1 PR | ||
D 10A | D 10A | ||
D 10A | D 10A | ||
− | + | ||
D RTVFLD1 PI | D RTVFLD1 PI | ||
D iLib 10A | D iLib 10A | ||
D iFile 10A | D iFile 10A | ||
− | + | ||
D DISPINFOC1 PR ExtPgm('DISPINFOC1') | D DISPINFOC1 PR ExtPgm('DISPINFOC1') | ||
D Lib 10A const | D Lib 10A const | ||
Line 1,196: | Line 1,199: | ||
D oRecord 10A const | D oRecord 10A const | ||
D oField 10A const | D oField 10A const | ||
− | D | + | D oFld 10I 0 const |
− | |||
D Func 10A const | D Func 10A const | ||
D Fdata like(RTVDATA) | D Fdata like(RTVDATA) | ||
Line 1,212: | Line 1,214: | ||
D FldDec 10I 0 | D FldDec 10I 0 | ||
D EndDta 10I 0 | D EndDta 10I 0 | ||
− | + | D NumFld 10I 0 | |
+ | |||
D oRecordName 10A | D oRecordName 10A | ||
D oFldNam 10A | D oFldNam 10A | ||
− | D | + | D oFld 10I 0 |
− | + | ||
− | |||
/free | /free | ||
− | + | ||
*INLR = *ON; | *INLR = *ON; | ||
− | + | ||
− | DISPINFOC1( iLib : iFile : ' ': ' ' : | + | DISPINFOC1( iLib : iFile : ' ': ' ' : 0 : |
'#FIRST' : RTVDATA ); | '#FIRST' : RTVDATA ); | ||
− | + | ||
DOW (EndDta = 0); | DOW (EndDta = 0); | ||
− | + | ||
oRecordName = RecordName ; | oRecordName = RecordName ; | ||
oFldNam = FldNam ; | oFldNam = FldNam ; | ||
− | + | oFld = NumFld ; | |
− | + | ||
− | |||
// To get the next record the previous fields info is also passed | // To get the next record the previous fields info is also passed | ||
DISPINFOC1(iLib : iFile : | DISPINFOC1(iLib : iFile : | ||
oRecordName : | oRecordName : | ||
oFldNam : | oFldNam : | ||
− | + | oFld : | |
− | |||
'#NEXT ' : RTVDATA ); | '#NEXT ' : RTVDATA ); | ||
− | + | ||
ENDDO; | ENDDO; | ||
− | + | ||
/end-free | /end-free | ||
− | + | ||
+ | |||
Line 1,249: | Line 1,250: | ||
[[#top]] | [[#top]] | ||
+ | |||
===DISPINFOC2 Version with C Module === | ===DISPINFOC2 Version with C Module === | ||
Revision as of 06:58, 30 September 2014
Contents
Introduction
C version of the RPG prpgram DSPINFO. This program works differently to the RPG version. I coded it to return only one field or constant at a time. So to see all the fields in a DSPF it needs to loop.
DISPINFOC is coded quite inefficiently but it still works quite fast. It retreives the API data for every time it is called then iterates though all the fields. I coded it this way so as to hide the API retreival within DISPINFOC.
The 2 versions below are more efficient.
I did not include any of the logic to retreive FILE, RECORD, or FIELD attributes. Also there is no logic for any other caterories (eg Date/Time) other than Cat 23 (Conatants)
DISPINFOC
/* Function: This program uses the QDFRTVFD API to return the */ /* structure of a display file. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "QSYSINC/H/QUSEC" #include "QSYSINC/H/QDFRTVFD" #define EQ == #define fail() do { printf("\nLine %d FAILED in file %s", \ __LINE__,__FILE__); \ } while(0) /* Pointers to structures required to be used by this program. */ QDFFBASE_t *p_QDFFBASE; QDFFINFO_t *p_QDFFINFO; QDFARFTE_t *p_QDFARFTE; QDFFRINF_t *p_QDFFRINF; QDFFDPDD_t *p_QDFFDPDD; QDFFRDPD_t *p_QDFFRDPD; QDFWFLEI_t *p_QDFWFLEI; QDFFNTBL_t *p_QDFFNTBL; QDFWRCDI_t *p_QDFWRCDI; QDFWFLDI_t *p_QDFWFLDI; QDFFSFCR_t *p_QDFFSFCR; QDFFSFHR_t *p_QDFFSFHR; QDFFSCRA_t *p_QDFFSCRA; QDFFFITB_t *p_QDFFFITB; QDFFFINF_t *p_QDFFFINF; QDFFFCON_t *p_QDFFFCON; QDFFFDPD_t *p_QDFFFDPD; QDFFFNAM_t *p_QDFFFNAM; QDFFFDIC_t *p_QDFFFDIC; QDFFXFDP_t *p_QDFFXFDP; QDFFRCTB_t *p_QDFFRCTB; QDFFRCTE_t *p_QDFFRCTE; QDFFNTB_t *p_QDFFNTB; QDFFCOSA_t *p_QDFFCOSA; QDFFCCOA_t *p_QDFFCCOA; QDFKMFDK_t *p_QDFKMFDK; QDFKDFT_t *p_QDFKDFT; QDFKEDTR_t *p_QDFKEDTR; QDFKDFPM_t *p_QDFKDFPM; /* Global variables */ char *p_iLib; char *p_iFile; char *p_iRecord; char *p_iField; int *p_iNumFld; char *p_iFunc; /* returned data */ typedef struct FieldData { char RecordName[10]; char ROW[1]; char COL[1]; char FldIO[1]; char FldAtr[1]; char FldNam[10]; char FldCom[3000]; int FldPlen; int FldDec; int EndDta; int NumFld; } FieldData_t; FieldData_t *p_FieldData; FieldData_t *Odata; typedef struct inputArguments { char *pgmname; char *iLib; char *iFile; char *iRecord; char *iField; int *iFld; char *iFunc; FieldData_t *iOdata; } main_args_t; int ProcessRec (void); int ProcessField (int *); int ProcessCons(void); int ProcessCat22(void); int ProcessCat23(void); int ProcessCat24(void); int RecIndex; /* Area into which the QDFRTVFD returns the requested data.*/ char *ReturnVar; char FileName[20] = " "; char Format[8]; int EndFlds = 0; /* 4 bytes WDFFRETN Length of the returned data. */ /* 4 bytes WDFFSIZE Size of the display file description */ typedef struct RtvSizeInfo { int ReturnLen; int ReturnSiz; } RtvSizeInfo_t; /* ######################################################## */ int main(int argc, main_args_t *main_args) { RtvSizeInfo_t *RtvSize; Qus_EC_t Error_Code = {0}; int API_Len; p_iFile = main_args->iFile; p_iLib = main_args->iLib; p_iRecord = main_args->iRecord; p_iField = main_args->iField; p_iNumFld = main_args->iFld; p_iFunc = main_args->iFunc; Odata = main_args->iOdata; /* Define the API format requested and the display file to access */ memcpy(Format,"DSPF0100",8); /* Point to your DSPF */ memmove(FileName,p_iFile, strlen(p_iFile)); memmove(FileName + 10 ,p_iLib, strlen(p_iLib )); /* Invoke the API. */ RtvSize = malloc(8); QDFRTVFD (RtvSize, 8, Format, FileName, &Error_Code); if ( Error_Code.Bytes_Available != 0 ) { fail(); exit (1); } API_Len = RtvSize->ReturnSiz; free(RtvSize); ReturnVar = malloc(API_Len); QDFRTVFD (ReturnVar, API_Len, Format, FileName, &Error_Code); if ( Error_Code.Bytes_Available != 0 ) { fail(); printf( "\nExcId: %s" , Error_Code.Exception_Id ); exit (1); } ProcessRec(); free(ReturnVar); } /* ######################################### */ int ProcessRec() { int NumRecs; int i; int GotIt = 0; /* Access returned structures. The base structure starts at */ /* the begining of the returned space. */ p_QDFFBASE = (QDFFBASE_t *)ReturnVar; p_QDFFINFO = (QDFFINFO_t *)((char *) p_QDFFBASE + p_QDFFBASE->WDFFINOF); p_QDFARFTE = (QDFARFTE_t *)((char *) p_QDFFINFO + p_QDFFINFO->WDFFDFLO); p_QDFWFLEI = (QDFWFLEI_t *)((char *) p_QDFFINFO + p_QDFFINFO->WDFFWUOF); p_QDFFDPDD = (QDFFDPDD_t *)((char *) p_QDFFINFO + p_QDFFINFO->WDFFXDOF); p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWFLEI + p_QDFWFLEI->WDFWXLEN); p_QDFFNTBL = (QDFFNTBL_t *)((char *) p_QDFWFLEI + p_QDFWFLEI->WDFWNTBO); /* here is the place to retreive File Keywords */ NumRecs = p_QDFFBASE->WDFFRCS; for (i=0; i< NumRecs ; ++i) { /* Bump ptr to next record structure */ if (i != 0) {p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWNXTR); p_QDFARFTE = (QDFARFTE_t *)((char *) p_QDFARFTE + sizeof(QDFARFTE_t)); } memcpy(Odata->RecordName, p_QDFARFTE->WDFARFNM,sizeof(p_QDFARFTE->WDFARFNM)); if (i EQ NumRecs - 1) { EndFlds = 1; } ProcessField(&GotIt); } } /* ######################################### */ int ProcessField(int *GotIt) { int SflCtl; int SizeIdx; int FldIdx; int NumFlds; char ScrnSize[1]; char Attrib[1]; char X01 = 0x01 ; char Functn[10] = " "; NumFlds = 0; /* record header */ p_QDFFRINF = (QDFFRINF_t *)((char *) p_QDFFINFO + p_QDFARFTE->WDFARFOF); /* record dev dept */ p_QDFFRDPD = (QDFFRDPD_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFRAOF); /* SFLCTL */ /* 12 C BIN(31) WDFFRFLG Miscellaneous record contents. */ /* 12 C 0 BIT(1) WDFFUDDS If on, USRDFN keyword is specified. */ /* 12 C 1 BIT(1) WDFFSFL If on, SFL keyword is specified (next rec*/ /* 12 C 2 BIT(1) WDFFSFLC If on, SFLCTL keyword is specified (p*/ SflCtl = 0; if (p_QDFFRINF->WDFFRFLG.WDFFSFLC) { SflCtl = 1; p_QDFFSFCR = (QDFFSFCR_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFRAOF); p_QDFFSFHR = (QDFFSFHR_t *)((char *) p_QDFFSFCR + sizeof(QDFFSFCR_t)); } for (SizeIdx=0; SizeIdx<p_QDFFBASE->WDFFSCR ; ++SizeIdx) { p_QDFFSCRA = (QDFFSCRA_t *)((char *) p_QDFFBASE + sizeof(QDFFBASE_t) + sizeof(QDFFSCRA_t) * SizeIdx ) ; *ScrnSize = p_QDFFSCRA->WDFFSCIA ; } /* Find RowColumn table. Note: this is the first row/col table */ /* so this code only works for the PRIMARY DISPLAY SIZE. */ /* See QDFFRDPD.WDFFDRCO field description for finding the */ /* correct QDFFRCTB structure if more than one screen size is */ /* used. */ p_QDFFRCTB = (QDFFRCTB_t *)((char *) p_QDFFRINF + p_QDFFRDPD->WDFFDRCO); /******** HERE include code for Record Keywords ********/ /* PROCESS THE RECORDS FIELDS */ /* Find where used section */ p_QDFWFLDI = (QDFWFLDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWRLEN); p_QDFFFITB = (QDFFFITB_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFOFIT + ( p_QDFWFLDI->WDFWRRDX -1) * sizeof(QDFFFITB_t)); for (FldIdx=0; FldIdx < p_QDFFRINF->WDFFFLD; ++FldIdx) { /* Field Header */ p_QDFFFINF = (QDFFFINF_t *)((char *) p_QDFFRINF + p_QDFFFITB->WDFFFOFS); if (p_QDFFFINF->WDFFFIOA EQ 0x01) { /* constant */ p_QDFFFCON = (QDFFFCON_t *)((char *) p_QDFFFINF + sizeof(QDFFFINF_t)); p_QDFFFDPD = (QDFFFDPD_t *)((char *) p_QDFFFINF + p_QDFFFCON->WDFFFAOC); } else { /* variable */ p_QDFFFNAM = (QDFFFNAM_t *)((char *) p_QDFFFINF + sizeof(QDFFFINF_t)); p_QDFFFDPD = (QDFFFDPD_t *)((char *) p_QDFFFINF + p_QDFFFNAM->WDFFFAOF); p_QDFFFDIC = (QDFFFDIC_t *)((char *) p_QDFFFDPD + sizeof(QDFFFDPD_t)); } /* Field Extension */ p_QDFFXFDP = (QDFFXFDP_t *)((char *) p_QDFFFINF + p_QDFFFDPD->WDFFXFDO); /* Row Column */ p_QDFFRCTB = (QDFFRCTB_t *)((char *) p_QDFFRINF + p_QDFFRDPD->WDFFDRCO + (p_QDFWFLDI->WDFWRRDX - 1) *2); p_QDFFRCTE = (QDFFRCTE_t *)((char *) p_QDFFRCTB + sizeof(QDFFRCTB_t)); *Odata->ROW = p_QDFFRCTE->WDFFSROW; *Odata->COL = p_QDFFRCTE->WDFFSCOL; /* here can extract data time flags */ /* CONSTANTS */ if (p_QDFFFINF->WDFFFIOA EQ 0x01) { /* constant */ ProcessCons(); } else { /* Field Name */ p_QDFFNTB = (QDFFNTB_t *)((char *) p_QDFFNTBL + sizeof(QDFFNTBL_t) + 10 * (p_QDFWFLDI->WDFWNMEI -1) ); /*Field attribute. */ /*X'01' indicates Constant (see structure QDFFFCON, Constant Field */ /*X'02' indicates Output (O), */ /*X'03' indicates Message (M), h (B), */ /*X'04' indicates Input (I), (P) */ /*X'05' indicates Both (B), */ /*X'06' indicates Hidden (H), and */ /*X'07' indicates Program to System (P) */ *Odata->FldIO = p_QDFFFINF->WDFFFIOA; /* Keyboard shift and data type. */ /* X'00' indicates Alpha shift/character (A), */ *Odata->FldAtr = p_QDFFFNAM->WDFFKBDT; memcpy(Odata->FldNam, p_QDFFNTB->WDFFNAM,sizeof(p_QDFFNTB->WDFFNAM)); memset(Odata->FldCom, ' ',3000); Odata->FldPlen = p_QDFFFNAM->WDFFPLEN; Odata->FldDec = p_QDFFFNAM->WDFFDEC; } /*********** HERE include code for Field KEYWORDS **********/ if (FldIdx < p_QDFFRINF->WDFFFLD -1) { p_QDFWFLDI = (QDFWFLDI_t *)((char *) p_QDFWFLDI + p_QDFWFLDI->WDFWFLDL); p_QDFFFITB = (QDFFFITB_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFOFIT + ( p_QDFWFLDI->WDFWRRDX -1) * sizeof(QDFFFITB_t)); } NumFlds += 1; Odata->NumFld = NumFlds; Odata->EndDta = 0; /* End ofthe Fields */ if ((EndFlds EQ 1) && (FldIdx EQ p_QDFFRINF->WDFFFLD -1) ) { Odata->EndDta = 1; *GotIt = 1; }; /* Return the requested Field */ memmove(Functn,p_iFunc, strlen(p_iFunc)); if (!memcmp(Functn , "#FIRST", 6)) { *GotIt = 1; }; if (*GotIt) { *GotIt = 0; free(ReturnVar); exit(0); }; /* We know we are about to get the NEXT record when we have */ /* found the record just before */ if (!memcmp(Functn , "#NEXT" , 5) && !memcmp(p_iRecord, Odata->RecordName, 10) && !memcmp(p_iField, Odata->FldNam, 10 ) && (*p_iNumFld EQ NumFlds)) *GotIt = 1; } } /* ######################################### */ int ProcessCons() { /*------------------------------------------------*/ /* This loops through all keyword categories */ /* for a constant field (text on the screen.) */ /*------------------------------------------------*/ int cc; if (p_QDFFFDPD->WDFFFDOC > 0) { /* p_QDFFRINF = (QDFFRINF_t *)((char *) p_QDFFINFO + p_QDFFFINF );*/ /* p_QDFFRINF = p_QDFFINFO + QDFARFTE.WDFARFOF */ p_QDFFCOSA = (QDFFCOSA_t *) ((char *) p_QDFFFINF + p_QDFFFDPD->WDFFFDOC); cc = 0; for (cc=0; cc<=p_QDFFCOSA->WDFFCCT -1 ; ++cc) { p_QDFFCCOA = (QDFFCCOA_t *)((char *) p_QDFFCOSA + sizeof(QDFFCOSA_t) + sizeof(QDFFCCOA_t) * cc); if (p_QDFFCCOA->WDFFCAID EQ 0x22) { p_QDFKMFDK = (QDFKMFDK_t *)((char *) p_QDFFFINF + p_QDFFCCOA->WDFFCAOF); ProcessCat22(); } if (p_QDFFCCOA->WDFFCAID EQ 0x23) { p_QDFKDFT = (QDFKDFT_t *)((char *) p_QDFFFINF + p_QDFFCCOA->WDFFCAOF); ProcessCat23(); } if (p_QDFFCCOA->WDFFCAID EQ 0x24) { p_QDFKEDTR = (QDFKEDTR_t *)((char *) p_QDFFFINF + p_QDFFCCOA->WDFFCAOF); ProcessCat24(); } } } } /* ######################################### */ int ProcessCat22() { /*-----------------------------------------------*/ /* This loops through all keywords that fall into*/ /* category 22 */ /*-----------------------------------------------*/ } /* ######################################### */ int ProcessCat23() { /*------------------------------------------------*/ /* This loops through all keywords that fall into */ /* category 23 (DFT, MSGCON, DFTVAL, HTML) */ /*------------------------------------------------*/ typedef _Packed struct KwdData { char Temp[3000]; } KwdData_t; KwdData_t *p_KwdData; int ck; for (ck=1; ck <= p_QDFKDFT->WDFKDFS ; ++ck) { if (ck EQ 1 ) { p_QDFKDFPM = (QDFKDFPM_t *)((char *) p_QDFKDFT + sizeof(QDFKDFT_t)); } else {p_QDFKDFPM = (QDFKDFPM_t *)((char *) p_QDFKDFPM + sizeof(QDFKDFPM_t)); } if (p_QDFKDFPM->WDFKDFID EQ 0x01) { memcpy(Odata->FldNam," ",10); Odata->FldPlen = p_QDFKDFPM->WDFKDFLN; *Odata->FldIO = p_QDFFFINF->WDFFFIOA; p_KwdData = (KwdData_t *) ((char *) p_QDFKDFPM + sizeof(QDFKDFPM_t) ); memset(Odata->FldCom, ' ',3000); memcpy(Odata->FldCom, p_KwdData->Temp, p_QDFKDFPM->WDFKDFLN); } } } /* ######################################### */ int ProcessCat24() { /*-----------------------------------------------*/ /* This loops through all keywords that fall into*/ /* category 24 (Date, Time) */ /*-----------------------------------------------*/ memcpy(Odata->FldNam," ",10); memset(Odata->FldCom, ' ',3000); }
RTVFLD (RPG code DISPINFOC driver)
RPG Driver program for DISPINFOC This program is coded to loop to invoke DISPINFOC for one field at a time.
It needs to pass a parameter (#FIRST | #NEXT) to tell DISPINFOC what to do.
h Option(*NODEBUGIO) DFTACTGRP(*NO) D RTVFLD PR D 10A D 10A D RTVFLD PI D iLib 10A D iFile 10A D DISPINFOC PR ExtPgm('DISPINFOC') D Lib 10A const D File 10A const D oRecord 10A const D oField 10A const D oFld 10I 0 const D Func 10A const D Fdata like(RTVDATA) // returned data D RTVDATA DS D RecordName 10A D ROW 1A D COL 1A D FldIO 1A D FldAtr 1A D FldNam 10A D FldCom 3000A D FLdPlen 10I 0 D FldDec 10I 0 D EndDta 10I 0 D NumFld 10I 0 D oRecordName 10A D oFldNam 10A D oFld 10I 0 /free *INLR = *ON; DISPINFOC( iLib : iFile : ' ': ' ' : 0 : '#FIRST' : RTVDATA ); DOW (EndDta = 0); oRecordName = RecordName ; oFldNam = FldNam ; oFld = NumFld ; // To get the next record the previous fields info is also passed DISPINFOC(iLib : iFile : oRecordName : oFldNam : oFld : '#NEXT ' : RTVDATA ); ENDDO; /end-free
DISPINFOC1 Version with User Space
/* Function: This program uses the QDFRTVFD API to return the */ /* structure of a display file. */ DISPINFOC1 /* Function: This program uses the QDFRTVFD API to return the */ /* structure of a display file. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "QSYSINC/H/QUSEC" #include "QSYSINC/H/QDFRTVFD" #include <mispace.h> #include <pointer.h> #include <mispcobj.h> #include <except.h> #include <qtes.h> /* Link up the Create User Space API */ #pragma linkage(CreateUserSpace,OS) #pragma map(CreateUserSpace,"QUSCRTUS") void CreateUserSpace(char[20], char[10], long int, char, char[10], char[50], char[10], _TE_ERROR_CODE_T * ); /* Link up the Delete User Space API */ #pragma linkage(DeleteUserSpace,OS) #pragma map(DeleteUserSpace,"QUSDLTUS") void DeleteUserSpace(char[20], _TE_ERROR_CODE_T * ); /* Link up the Retrieve Pointer to User Space API */ #pragma linkage(RetrievePointerToUserSpace,OS) #pragma map(RetrievePointerToUserSpace,"QUSPTRUS") void RetrievePointerToUserSpace(char[20], char **, _TE_ERROR_CODE_T * ); #define EQ == #define fail() do { printf("\nLine %d FAILED in file %s", \ __LINE__,__FILE__); \ } while(0) /* Pointers to structures required to be used by this program. */ QDFFBASE_t *p_QDFFBASE; QDFFINFO_t *p_QDFFINFO; QDFARFTE_t *p_QDFARFTE; QDFFRINF_t *p_QDFFRINF; QDFFDPDD_t *p_QDFFDPDD; QDFFRDPD_t *p_QDFFRDPD; QDFWFLEI_t *p_QDFWFLEI; QDFFNTBL_t *p_QDFFNTBL; QDFWRCDI_t *p_QDFWRCDI; QDFWFLDI_t *p_QDFWFLDI; QDFFSFCR_t *p_QDFFSFCR; QDFFSFHR_t *p_QDFFSFHR; QDFFSCRA_t *p_QDFFSCRA; QDFFFITB_t *p_QDFFFITB; QDFFFINF_t *p_QDFFFINF; QDFFFCON_t *p_QDFFFCON; QDFFFDPD_t *p_QDFFFDPD; QDFFFNAM_t *p_QDFFFNAM; QDFFFDIC_t *p_QDFFFDIC; QDFFXFDP_t *p_QDFFXFDP; QDFFRCTB_t *p_QDFFRCTB; QDFFRCTE_t *p_QDFFRCTE; QDFFNTB_t *p_QDFFNTB; QDFFCOSA_t *p_QDFFCOSA; QDFFCCOA_t *p_QDFFCCOA; QDFKMFDK_t *p_QDFKMFDK; QDFKDFT_t *p_QDFKDFT; QDFKEDTR_t *p_QDFKEDTR; QDFKDFPM_t *p_QDFKDFPM; /* Global variables */ char *p_iLib; char *p_iFile; char *p_iRecord; char *p_iField; int *p_iNumFld; char *p_iFunc; /* returned data */ typedef struct FieldData { char RecordName[10]; char ROW[1]; char COL[1]; char FldIO[1]; char FldAtr[1]; char FldNam[10]; char FldCom[3000]; int FldPlen; int FldDec; int EndDta; int NumFld; } FieldData_t; FieldData_t *p_FieldData; FieldData_t *Odata; typedef struct inputArguments { char *pgmname; char *iLib; char *iFile; char *iRecord; char *iField; int *iFld; char *iFunc; FieldData_t *iOdata; } main_args_t; int RtvApiDta (void); int ProcessRec (void); int ProcessField (int *); int ProcessCons(void); int ProcessCat22(void); int ProcessCat23(void); int ProcessCat24(void); int RecIndex; /* Area into which the QDFRTVFD returns the requested data.*/ char *pBuffer; _TE_ERROR_CODE_T errorCode; char FileName[20] = " "; char Format[8]; int EndFlds = 0; /* 4 bytes WDFFRETN Length of the returned data. */ /* 4 bytes WDFFSIZE Size of the display file description */ typedef struct RtvSizeInfo { int ReturnLen; int ReturnSiz; } RtvSizeInfo_t; /* ######################################################## */ int main(int argc, main_args_t *main_args) { char Funct[10] = " "; p_iFile = main_args->iFile; p_iLib = main_args->iLib; p_iRecord = main_args->iRecord; p_iField = main_args->iField; p_iNumFld = main_args->iFld; p_iFunc = main_args->iFunc; Odata = main_args->iOdata; /* On First pass get the API data */ memmove(Funct,p_iFunc, strlen(p_iFunc)); if (!memcmp(Funct, "#FIRST", 6)) { RtvApiDta(); }; if (!memcmp(Funct, "#NEXT", 5)) { /*! call RetrievePointerToUserSpace - Retrieve Pointer to User Space */ errorCode.BytesProvided = 0; RetrievePointerToUserSpace("RTVFDUSPC QTEMP ", &pBuffer, &errorCode); } ProcessRec(); /* free(ReturnVar); */ } /* ######################################### */ RtvApiDta() { RtvSizeInfo_t *RtvSize; int API_Len; Qus_EC_t Error_Code = {0}; /* Define the API format requested and the display file to access */ memcpy(Format,"DSPF0100",8); /* Point to your DSPF */ memmove(FileName,p_iFile, strlen(p_iFile)); memmove(FileName + 10 ,p_iLib, strlen(p_iLib )); /* Invoke the API. to get the size needed */ RtvSize = malloc(8); QDFRTVFD (RtvSize, 8, Format, FileName, &Error_Code); if ( Error_Code.Bytes_Available != 0 ) { fail(); exit (1); } API_Len = RtvSize->ReturnSiz; free(RtvSize); CreateUserSpace("RTVFDUSPC QTEMP ", "USRSPC ", API_Len, 0, "*ALL ", " ", "*YES ", &errorCode ); /*! call RetrievePointerToUserSpace - Retrieve Pointer to User Space */ /*!! (pass: Name and library of user space, pointer variable */ /*!! return: nothing (pointer variable is left pointing to start*/ /*!! of user space) */ errorCode.BytesProvided = 0; RetrievePointerToUserSpace("RTVFDUSPC QTEMP ", &pBuffer, &errorCode); QDFRTVFD (pBuffer, API_Len, Format, FileName, &Error_Code); if ( Error_Code.Bytes_Available != 0 ) { fail(); printf( "\nExcId: %s" , Error_Code.Exception_Id ); exit (1); } } /* ######################################### */ int ProcessRec() { int NumRecs; int i; int GotIt = 0; /* Access returned structures. The base structure starts at */ /* the begining of the returned space. */ p_QDFFBASE = (QDFFBASE_t *)pBuffer; p_QDFFINFO = (QDFFINFO_t *)((char *) p_QDFFBASE + p_QDFFBASE->WDFFINOF); p_QDFARFTE = (QDFARFTE_t *)((char *) p_QDFFINFO + p_QDFFINFO->WDFFDFLO); p_QDFWFLEI = (QDFWFLEI_t *)((char *) p_QDFFINFO + p_QDFFINFO->WDFFWUOF); p_QDFFDPDD = (QDFFDPDD_t *)((char *) p_QDFFINFO + p_QDFFINFO->WDFFXDOF); p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWFLEI + p_QDFWFLEI->WDFWXLEN); p_QDFFNTBL = (QDFFNTBL_t *)((char *) p_QDFWFLEI + p_QDFWFLEI->WDFWNTBO); /* here is the place to retreive File Keywords */ NumRecs = p_QDFFBASE->WDFFRCS; for (i=0; i< NumRecs ; ++i) { /* Bump ptr to next record structure */ if (i != 0) {p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWNXTR); p_QDFARFTE = (QDFARFTE_t *)((char *) p_QDFARFTE + sizeof(QDFARFTE_t)); } memcpy(Odata->RecordName, p_QDFARFTE->WDFARFNM,sizeof(p_QDFARFTE->WDFARFNM)); if (i EQ NumRecs - 1) { EndFlds = 1; } ProcessField(&GotIt); } } /* ######################################### */ int ProcessField(int *GotIt) { int SflCtl; int SizeIdx; int FldIdx; int NumFlds; char ScrnSize[1]; char Attrib[1]; char X01 = 0x01 ; char Functn[10] = " "; NumFlds = 0; /* record header */ p_QDFFRINF = (QDFFRINF_t *)((char *) p_QDFFINFO + p_QDFARFTE->WDFARFOF); /* record dev dept */ p_QDFFRDPD = (QDFFRDPD_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFRAOF); /* SFLCTL */ /* 12 C BIN(31) WDFFRFLG Miscellaneous record contents. */ /* 12 C 0 BIT(1) WDFFUDDS If on, USRDFN keyword is specified. */ /* 12 C 1 BIT(1) WDFFSFL If on, SFL keyword is specified (next rec*/ /* 12 C 2 BIT(1) WDFFSFLC If on, SFLCTL keyword is specified (p*/ SflCtl = 0; if (p_QDFFRINF->WDFFRFLG.WDFFSFLC) { SflCtl = 1; p_QDFFSFCR = (QDFFSFCR_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFRAOF); p_QDFFSFHR = (QDFFSFHR_t *)((char *) p_QDFFSFCR + sizeof(QDFFSFCR_t)); } for (SizeIdx=0; SizeIdx<p_QDFFBASE->WDFFSCR ; ++SizeIdx) { p_QDFFSCRA = (QDFFSCRA_t *)((char *) p_QDFFBASE + sizeof(QDFFBASE_t) + sizeof(QDFFSCRA_t) * SizeIdx ) ; *ScrnSize = p_QDFFSCRA->WDFFSCIA ; } /* Find RowColumn table. Note: this is the first row/col table */ /* so this code only works for the PRIMARY DISPLAY SIZE. */ /* See QDFFRDPD.WDFFDRCO field description for finding the */ /* correct QDFFRCTB structure if more than one screen size is */ /* used. */ p_QDFFRCTB = (QDFFRCTB_t *)((char *) p_QDFFRINF + p_QDFFRDPD->WDFFDRCO); /******** HERE include code for Record Keywords ********/ /* PROCESS THE RECORDS FIELDS */ /* Find where used section */ p_QDFWFLDI = (QDFWFLDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWRLEN); p_QDFFFITB = (QDFFFITB_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFOFIT + ( p_QDFWFLDI->WDFWRRDX -1) * sizeof(QDFFFITB_t)); for (FldIdx=0; FldIdx < p_QDFFRINF->WDFFFLD; ++FldIdx) { /* Field Header */ p_QDFFFINF = (QDFFFINF_t *)((char *) p_QDFFRINF + p_QDFFFITB->WDFFFOFS); if (p_QDFFFINF->WDFFFIOA EQ 0x01) { /* constant */ p_QDFFFCON = (QDFFFCON_t *)((char *) p_QDFFFINF + sizeof(QDFFFINF_t)); p_QDFFFDPD = (QDFFFDPD_t *)((char *) p_QDFFFINF + p_QDFFFCON->WDFFFAOC); } else { /* variable */ p_QDFFFNAM = (QDFFFNAM_t *)((char *) p_QDFFFINF + sizeof(QDFFFINF_t)); p_QDFFFDPD = (QDFFFDPD_t *)((char *) p_QDFFFINF + p_QDFFFNAM->WDFFFAOF); p_QDFFFDIC = (QDFFFDIC_t *)((char *) p_QDFFFDPD + sizeof(QDFFFDPD_t)); } /* Field Extension */ p_QDFFXFDP = (QDFFXFDP_t *)((char *) p_QDFFFINF + p_QDFFFDPD->WDFFXFDO); /* Row Column */ p_QDFFRCTB = (QDFFRCTB_t *)((char *) p_QDFFRINF + p_QDFFRDPD->WDFFDRCO + (p_QDFWFLDI->WDFWRRDX - 1) *2); p_QDFFRCTE = (QDFFRCTE_t *)((char *) p_QDFFRCTB + sizeof(QDFFRCTB_t)); *Odata->ROW = p_QDFFRCTE->WDFFSROW; *Odata->COL = p_QDFFRCTE->WDFFSCOL; /* here can extract data time flags */ /* CONSTANTS */ if (p_QDFFFINF->WDFFFIOA EQ 0x01) { /* constant */ ProcessCons(); } else { /* Field Name */ p_QDFFNTB = (QDFFNTB_t *)((char *) p_QDFFNTBL + sizeof(QDFFNTBL_t) + 10 * (p_QDFWFLDI->WDFWNMEI -1) ); /*Field attribute. */ /*X'01' indicates Constant (see structure QDFFFCON, Constant Field */ /*X'02' indicates Output (O), */ /*X'03' indicates Message (M), h (B), */ /*X'04' indicates Input (I), (P) */ /*X'05' indicates Both (B), */ /*X'06' indicates Hidden (H), and */ /*X'07' indicates Program to System (P) */ *Odata->FldIO = p_QDFFFINF->WDFFFIOA; /* Keyboard shift and data type. */ /* X'00' indicates Alpha shift/character (A), */ *Odata->FldAtr = p_QDFFFNAM->WDFFKBDT; memcpy(Odata->FldNam, p_QDFFNTB->WDFFNAM,sizeof(p_QDFFNTB->WDFFNAM)); memset(Odata->FldCom,' ',3000); Odata->FldPlen = p_QDFFFNAM->WDFFPLEN; Odata->FldDec = p_QDFFFNAM->WDFFDEC; } /*********** HERE include code for Field KEYWORDS **********/ if (FldIdx < p_QDFFRINF->WDFFFLD -1) { p_QDFWFLDI = (QDFWFLDI_t *)((char *) p_QDFWFLDI + p_QDFWFLDI->WDFWFLDL); p_QDFFFITB = (QDFFFITB_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFOFIT + ( p_QDFWFLDI->WDFWRRDX -1) * sizeof(QDFFFITB_t)); } NumFlds += 1; Odata->NumFld = NumFlds; Odata->EndDta = 0; /* End ofthe Fields */ if ((EndFlds EQ 1) && (FldIdx EQ p_QDFFRINF->WDFFFLD -1) ) { Odata->EndDta = 1; *GotIt = 1; DeleteUserSpace("RTVFDUSPC QTEMP ", &errorCode); }; /* Return the requested Field */ memmove(Functn,p_iFunc, strlen(p_iFunc)); if (!memcmp(Functn , "#FIRST", 6)) { *GotIt = 1; }; if (*GotIt) { *GotIt = 0; exit(0); }; /* We know we are about to get the NEXT record when we have */ /* found the record just before */ if (!memcmp(Functn , "#NEXT" , 5) && !memcmp(p_iRecord, Odata->RecordName, 10) && !memcmp(p_iField, Odata->FldNam, 10 ) && (*p_iNumFld EQ NumFlds)) *GotIt = 1; } } /* ######################################### */ int ProcessCons() { /*------------------------------------------------*/ /* This loops through all keyword categories */ /* for a constant field (text on the screen.) */ /*------------------------------------------------*/ int cc; if (p_QDFFFDPD->WDFFFDOC > 0) { /* p_QDFFRINF = (QDFFRINF_t *)((char *) p_QDFFINFO + p_QDFFFINF );*/ /* p_QDFFRINF = p_QDFFINFO + QDFARFTE.WDFARFOF */ p_QDFFCOSA = (QDFFCOSA_t *) ((char *) p_QDFFFINF + p_QDFFFDPD->WDFFFDOC); cc = 0; for (cc=0; cc<=p_QDFFCOSA->WDFFCCT -1 ; ++cc) { p_QDFFCCOA = (QDFFCCOA_t *)((char *) p_QDFFCOSA + sizeof(QDFFCOSA_t) + sizeof(QDFFCCOA_t) * cc); if (p_QDFFCCOA->WDFFCAID EQ 0x22) { p_QDFKMFDK = (QDFKMFDK_t *)((char *) p_QDFFFINF + p_QDFFCCOA->WDFFCAOF); ProcessCat22(); } if (p_QDFFCCOA->WDFFCAID EQ 0x23) { p_QDFKDFT = (QDFKDFT_t *)((char *) p_QDFFFINF + p_QDFFCCOA->WDFFCAOF); ProcessCat23(); } if (p_QDFFCCOA->WDFFCAID EQ 0x24) { p_QDFKEDTR = (QDFKEDTR_t *)((char *) p_QDFFFINF + p_QDFFCCOA->WDFFCAOF); ProcessCat24(); } } } } /* ######################################### */ int ProcessCat22() { /*-----------------------------------------------*/ /* This loops through all keywords that fall into*/ /* category 22 */ /*-----------------------------------------------*/ } /* ######################################### */ int ProcessCat23() { /*------------------------------------------------*/ /* This loops through all keywords that fall into */ /* category 23 (DFT, MSGCON, DFTVAL, HTML) */ /*------------------------------------------------*/ typedef _Packed struct KwdData { char Temp[3000]; } KwdData_t; KwdData_t *p_KwdData; int ck; for (ck=1; ck <= p_QDFKDFT->WDFKDFS ; ++ck) { if (ck EQ 1 ) { p_QDFKDFPM = (QDFKDFPM_t *)((char *) p_QDFKDFT + sizeof(QDFKDFT_t)); } else {p_QDFKDFPM = (QDFKDFPM_t *)((char *) p_QDFKDFPM + sizeof(QDFKDFPM_t)); } if (p_QDFKDFPM->WDFKDFID EQ 0x01) { memcpy(Odata->FldNam," ",10); Odata->FldPlen = p_QDFKDFPM->WDFKDFLN; *Odata->FldIO = p_QDFFFINF->WDFFFIOA; p_KwdData = (KwdData_t *) ((char *) p_QDFKDFPM + sizeof(QDFKDFPM_t) ); memset(Odata->FldCom, ' ',3000); memcpy(Odata->FldCom, p_KwdData->Temp, p_QDFKDFPM->WDFKDFLN); } } } /* ######################################### */ int ProcessCat24() { /*-----------------------------------------------*/ /* This loops through all keywords that fall into*/ /* category 24 (Date, Time) */ /*-----------------------------------------------*/ memcpy(Odata->FldNam," ",10); memset(Odata->FldCom, ' ',3000); } RTVFLD1 h Option(*NODEBUGIO) DFTACTGRP(*NO) D RTVFLD1 PR D 10A D 10A D RTVFLD1 PI D iLib 10A D iFile 10A D DISPINFOC1 PR ExtPgm('DISPINFOC1') D Lib 10A const D File 10A const D oRecord 10A const D oField 10A const D oFld 10I 0 const D Func 10A const D Fdata like(RTVDATA) // returned data D RTVDATA DS D RecordName 10A D ROW 1A D COL 1A D FldIO 1A D FldAtr 1A D FldNam 10A D FldCom 3000A D FLdPlen 10I 0 D FldDec 10I 0 D EndDta 10I 0 D NumFld 10I 0 D oRecordName 10A D oFldNam 10A D oFld 10I 0 /free *INLR = *ON; DISPINFOC1( iLib : iFile : ' ': ' ' : 0 : '#FIRST' : RTVDATA ); DOW (EndDta = 0); oRecordName = RecordName ; oFldNam = FldNam ; oFld = NumFld ; // To get the next record the previous fields info is also passed DISPINFOC1(iLib : iFile : oRecordName : oFldNam : oFld : '#NEXT ' : RTVDATA ); ENDDO; /end-free
DISPINFOC2 Version with C Module
I needed to drive this fron a CLLE (code is below) because I need a RCLACTGRP DISPINFO2.
Reason is I did a return from the C module, rather than an exit.
DISPINFOC2 /* Function: This module uses the QDFRTVFD API to return the */ /* structure of a display file. */ /* CRTCMOD MODULE(urlib/DISPINFOC2) SRCFILE(urlib/C) SRCMBR(DISPINFOC2) */ /* REPLACE(*yes) */ /* bind into your program with */ /* CRTPGM PGM(urlib/RTVFLD2) */ /* MODULE(urlib/RTVFLD2 urlib/DISPINFOC2) */ /* ACTGRP(DISPINFO2) */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "QSYSINC/H/QUSEC" #include "QSYSINC/H/QDFRTVFD" #define EQ == #define fail() do { printf("\nLine %d FAILED in file %s", \ __LINE__,__FILE__); \ } while(0) /* Pointers to structures required to be used by this program. */ QDFFBASE_t *p_QDFFBASE; QDFFINFO_t *p_QDFFINFO; QDFARFTE_t *p_QDFARFTE; QDFFRINF_t *p_QDFFRINF; QDFFDPDD_t *p_QDFFDPDD; QDFFRDPD_t *p_QDFFRDPD; QDFWFLEI_t *p_QDFWFLEI; QDFFNTBL_t *p_QDFFNTBL; QDFWRCDI_t *p_QDFWRCDI; QDFWFLDI_t *p_QDFWFLDI; QDFFSFCR_t *p_QDFFSFCR; QDFFSFHR_t *p_QDFFSFHR; QDFFSCRA_t *p_QDFFSCRA; QDFFFITB_t *p_QDFFFITB; QDFFFINF_t *p_QDFFFINF; QDFFFCON_t *p_QDFFFCON; QDFFFDPD_t *p_QDFFFDPD; QDFFFNAM_t *p_QDFFFNAM; QDFFFDIC_t *p_QDFFFDIC; QDFFXFDP_t *p_QDFFXFDP; QDFFRCTB_t *p_QDFFRCTB; QDFFRCTE_t *p_QDFFRCTE; QDFFNTB_t *p_QDFFNTB; QDFFCOSA_t *p_QDFFCOSA; QDFFCCOA_t *p_QDFFCCOA; QDFKMFDK_t *p_QDFKMFDK; QDFKDFT_t *p_QDFKDFT; QDFKEDTR_t *p_QDFKEDTR; QDFKDFPM_t *p_QDFKDFPM; /* Global variables */ char *p_iLib; char *p_iFile; char *p_iRecord; char *p_iField; char *p_iRow; char *p_iCol; char *p_iFunc; /* returned data */ typedef struct FieldData { char RecordName[10]; char ROW[1]; char COL[1]; char FldIO[1]; char FldAtr[1]; char FldNam[10]; char FldCom[3000]; int FldPlen; int FldDec; int EndDta; } FieldData_t; FieldData_t *p_FieldData; FieldData_t *Odata; int RtvApiDta (void); int ProcessRec (void); int ProcessField (int *); int ProcessCons(void); int ProcessCat22(void); int ProcessCat23(void); int ProcessCat24(void); int RecIndex; char *ReturnVar; char FileName[20] = " "; char Format[8]; int EndFlds = 0; /* 4 bytes WDFFRETN Length of the returned data. */ /* 4 bytes WDFFSIZE Size of the display file description */ typedef struct RtvSizeInfo { int ReturnLen; int ReturnSiz; } RtvSizeInfo_t; /* ######################################################## */ int DISPINFOC2 ( char *p_pLib , char *p_pFile , char *p_pRecord , char *p_pField , char *p_pRow , char *p_pCol , char *p_pFunc , FieldData_t *pOdata) { char Funct[10] = " "; p_iLib = p_pLib; p_iFile = p_pFile; p_iRecord = p_pRecord; p_iField = p_pField; p_iRow = p_pRow; p_iCol = p_pCol; p_iFunc = p_pFunc; Odata = pOdata; /* On First pass get the API data */ memmove(Funct,p_iFunc, strlen(p_iFunc)); if (!memcmp(Funct, "#FIRST", 6)) { RtvApiDta(); }; ProcessRec(); } /* ######################################### */ RtvApiDta() { RtvSizeInfo_t *RtvSize; int API_Len; Qus_EC_t Error_Code = {0}; /* Define the API format requested and the display file to access */ memcpy(Format,"DSPF0100",8); /* Point to your DSPF */ memmove(FileName,p_iFile, strlen(p_iFile)); memmove(FileName + 10 ,p_iLib, strlen(p_iLib )); /* Invoke the API. to get the size needed */ RtvSize = malloc(8); QDFRTVFD (RtvSize, 8, Format, FileName, &Error_Code); if ( Error_Code.Bytes_Available != 0 ) { fail(); exit (1); } API_Len = RtvSize->ReturnSiz; free(RtvSize); ReturnVar = malloc(API_Len); QDFRTVFD (ReturnVar, API_Len, Format, FileName, &Error_Code); if ( Error_Code.Bytes_Available != 0 ) { fail(); printf( "\nExcId: %s" , Error_Code.Exception_Id ); exit (1); } } /* ######################################### */ int ProcessRec() { int NumRecs; int i; int GotIt = 0; /* Access returned structures. The base structure starts at */ /* the begining of the returned space. */ p_QDFFBASE = (QDFFBASE_t *)ReturnVar; p_QDFFINFO = (QDFFINFO_t *)((char *) p_QDFFBASE + p_QDFFBASE->WDFFINOF); p_QDFARFTE = (QDFARFTE_t *)((char *) p_QDFFINFO + p_QDFFINFO->WDFFDFLO); p_QDFWFLEI = (QDFWFLEI_t *)((char *) p_QDFFINFO + p_QDFFINFO->WDFFWUOF); p_QDFFDPDD = (QDFFDPDD_t *)((char *) p_QDFFINFO + p_QDFFINFO->WDFFXDOF); p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWFLEI + p_QDFWFLEI->WDFWXLEN); p_QDFFNTBL = (QDFFNTBL_t *)((char *) p_QDFWFLEI + p_QDFWFLEI->WDFWNTBO); /* here is the place to retreive File Keywords */ NumRecs = p_QDFFBASE->WDFFRCS; for (i=0; i< NumRecs ; ++i) { /* Bump ptr to next record structure */ if (i != 0) {p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWNXTR); p_QDFARFTE = (QDFARFTE_t *)((char *) p_QDFARFTE + sizeof(QDFARFTE_t)); } memcpy(Odata->RecordName, p_QDFARFTE->WDFARFNM,sizeof(p_QDFARFTE->WDFARFNM)); if (i EQ NumRecs - 1) { EndFlds = 1; } ProcessField(&GotIt); if (GotIt EQ 1) { return(0); }; } } /* ######################################### */ int ProcessField(int *GotIt) { int SflCtl; int SizeIdx; int FldIdx; int NumFlds; char ScrnSize[1]; char Attrib[1]; char X01 = 0x01 ; char Functn[10] = " "; /* record header */ p_QDFFRINF = (QDFFRINF_t *)((char *) p_QDFFINFO + p_QDFARFTE->WDFARFOF); /* record dev dept */ p_QDFFRDPD = (QDFFRDPD_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFRAOF); /* SFLCTL */ /* 12 C BIN(31) WDFFRFLG Miscellaneous record contents. */ /* 12 C 0 BIT(1) WDFFUDDS If on, USRDFN keyword is specified. */ /* 12 C 1 BIT(1) WDFFSFL If on, SFL keyword is specified (next rec*/ /* 12 C 2 BIT(1) WDFFSFLC If on, SFLCTL keyword is specified (p*/ SflCtl = 0; if (p_QDFFRINF->WDFFRFLG.WDFFSFLC) { SflCtl = 1; p_QDFFSFCR = (QDFFSFCR_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFRAOF); p_QDFFSFHR = (QDFFSFHR_t *)((char *) p_QDFFSFCR + sizeof(QDFFSFCR_t)); } for (SizeIdx=0; SizeIdx<p_QDFFBASE->WDFFSCR ; ++SizeIdx) { p_QDFFSCRA = (QDFFSCRA_t *)((char *) p_QDFFBASE + sizeof(QDFFBASE_t) + sizeof(QDFFSCRA_t) * SizeIdx ) ; *ScrnSize = p_QDFFSCRA->WDFFSCIA ; } /* Find RowColumn table. Note: this is the first row/col table */ /* so this code only works for the PRIMARY DISPLAY SIZE. */ /* See QDFFRDPD.WDFFDRCO field description for finding the */ /* correct QDFFRCTB structure if more than one screen size is */ /* used. */ p_QDFFRCTB = (QDFFRCTB_t *)((char *) p_QDFFRINF + p_QDFFRDPD->WDFFDRCO); /******** HERE include code for Record Keywords ********/ /* PROCESS THE RECORDS FIELDS */ /* Find where used section */ p_QDFWFLDI = (QDFWFLDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWRLEN); p_QDFFFITB = (QDFFFITB_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFOFIT + ( p_QDFWFLDI->WDFWRRDX -1) * sizeof(QDFFFITB_t)); for (FldIdx=0; FldIdx < p_QDFFRINF->WDFFFLD; ++FldIdx) { /* Field Header */ p_QDFFFINF = (QDFFFINF_t *)((char *) p_QDFFRINF + p_QDFFFITB->WDFFFOFS); if (p_QDFFFINF->WDFFFIOA EQ 0x01) { /* constant */ p_QDFFFCON = (QDFFFCON_t *)((char *) p_QDFFFINF + sizeof(QDFFFINF_t)); p_QDFFFDPD = (QDFFFDPD_t *)((char *) p_QDFFFINF + p_QDFFFCON->WDFFFAOC); } else { /* variable */ p_QDFFFNAM = (QDFFFNAM_t *)((char *) p_QDFFFINF + sizeof(QDFFFINF_t)); p_QDFFFDPD = (QDFFFDPD_t *)((char *) p_QDFFFINF + p_QDFFFNAM->WDFFFAOF); p_QDFFFDIC = (QDFFFDIC_t *)((char *) p_QDFFFDPD + sizeof(QDFFFDPD_t)); } /* Field Extension */ p_QDFFXFDP = (QDFFXFDP_t *)((char *) p_QDFFFINF + p_QDFFFDPD->WDFFXFDO); /* Row Column */ p_QDFFRCTB = (QDFFRCTB_t *)((char *) p_QDFFRINF + p_QDFFRDPD->WDFFDRCO + (p_QDFWFLDI->WDFWRRDX - 1) *2); p_QDFFRCTE = (QDFFRCTE_t *)((char *) p_QDFFRCTB + sizeof(QDFFRCTB_t)); *Odata->ROW = p_QDFFRCTE->WDFFSROW; *Odata->COL = p_QDFFRCTE->WDFFSCOL; /* here can extract data time flags */ /* CONSTANTS */ if (p_QDFFFINF->WDFFFIOA EQ 0x01) { /* constant */ ProcessCons(); } else { /* Field Name */ p_QDFFNTB = (QDFFNTB_t *)((char *) p_QDFFNTBL + sizeof(QDFFNTBL_t) + 10 * (p_QDFWFLDI->WDFWNMEI -1) ); /*Field attribute. */ /*X'01' indicates Constant (see structure QDFFFCON, Constant Field */ /*X'02' indicates Output (O), */ /*X'03' indicates Message (M), h (B), */ /*X'04' indicates Input (I), (P) */ /*X'05' indicates Both (B), */ /*X'06' indicates Hidden (H), and */ /*X'07' indicates Program to System (P) */ *Odata->FldIO = p_QDFFFINF->WDFFFIOA; /* Keyboard shift and data type. */ /* X'00' indicates Alpha shift/character (A), */ *Odata->FldAtr = p_QDFFFNAM->WDFFKBDT; memcpy(Odata->FldNam, p_QDFFNTB->WDFFNAM,sizeof(p_QDFFNTB->WDFFNAM)); memset(Odata->FldCom, ' ',3000); Odata->FldPlen = p_QDFFFNAM->WDFFPLEN; Odata->FldDec = p_QDFFFNAM->WDFFDEC; } /*********** HERE include code for Field KEYWORDS **********/ if (FldIdx < p_QDFFRINF->WDFFFLD -1) { p_QDFWFLDI = (QDFWFLDI_t *)((char *) p_QDFWFLDI + p_QDFWFLDI->WDFWFLDL); p_QDFFFITB = (QDFFFITB_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFOFIT + ( p_QDFWFLDI->WDFWRRDX -1) * sizeof(QDFFFITB_t)); } NumFlds += 1; Odata->EndDta = 0; /* End ofthe Fields */ if ((EndFlds EQ 1) && (FldIdx EQ p_QDFFRINF->WDFFFLD -1) ) { Odata->EndDta = 1; *GotIt = 2; free(ReturnVar); }; /* Return the requested Field */ memmove(Functn,p_iFunc, strlen(p_iFunc)); if ( (!memcmp(Functn , "#FIRST", 6)) || (*GotIt EQ 2)) { *GotIt = 1; return(0); }; /* We know we are about to get the NEXT record when we have */ /* found the record just before */ if (!memcmp(Functn , "#NEXT" , 5) && !memcmp(p_iRecord, Odata->RecordName, 10) && !memcmp(p_iField, Odata->FldNam, 10 ) && (*p_iRow == *Odata->ROW) && (*p_iCol == *Odata->COL)) *GotIt = 2; } } /* ######################################### */ int ProcessCons() { /*------------------------------------------------*/ /* This loops through all keyword categories */ /* for a constant field (text on the screen.) */ /*------------------------------------------------*/ int cc; if (p_QDFFFDPD->WDFFFDOC > 0) { /* p_QDFFRINF = (QDFFRINF_t *)((char *) p_QDFFINFO + p_QDFFFINF );*/ /* p_QDFFRINF = p_QDFFINFO + QDFARFTE.WDFARFOF */ p_QDFFCOSA = (QDFFCOSA_t *) ((char *) p_QDFFFINF + p_QDFFFDPD->WDFFFDOC); cc = 0; for (cc=0; cc<=p_QDFFCOSA->WDFFCCT -1 ; ++cc) { p_QDFFCCOA = (QDFFCCOA_t *)((char *) p_QDFFCOSA + sizeof(QDFFCOSA_t) + sizeof(QDFFCCOA_t) * cc); if (p_QDFFCCOA->WDFFCAID EQ 0x22) { p_QDFKMFDK = (QDFKMFDK_t *)((char *) p_QDFFFINF + p_QDFFCCOA->WDFFCAOF); ProcessCat22(); } if (p_QDFFCCOA->WDFFCAID EQ 0x23) { p_QDFKDFT = (QDFKDFT_t *)((char *) p_QDFFFINF + p_QDFFCCOA->WDFFCAOF); ProcessCat23(); } if (p_QDFFCCOA->WDFFCAID EQ 0x24) { p_QDFKEDTR = (QDFKEDTR_t *)((char *) p_QDFFFINF + p_QDFFCCOA->WDFFCAOF); ProcessCat24(); } } } } /* ######################################### */ int ProcessCat22() { /*-----------------------------------------------*/ /* This loops through all keywords that fall into*/ /* category 22 */ /*-----------------------------------------------*/ } /* ######################################### */ int ProcessCat23() { /*------------------------------------------------*/ /* This loops through all keywords that fall into */ /* category 23 (DFT, MSGCON, DFTVAL, HTML) */ /*------------------------------------------------*/ typedef _Packed struct KwdData { char Temp[3000]; } KwdData_t; KwdData_t *p_KwdData; int ck; for (ck=1; ck <= p_QDFKDFT->WDFKDFS ; ++ck) { if (ck EQ 1 ) { p_QDFKDFPM = (QDFKDFPM_t *)((char *) p_QDFKDFT + sizeof(QDFKDFT_t)); } else {p_QDFKDFPM = (QDFKDFPM_t *)((char *) p_QDFKDFPM + sizeof(QDFKDFPM_t)); } if (p_QDFKDFPM->WDFKDFID EQ 0x01) { memcpy(Odata->FldNam," ",10); Odata->FldPlen = p_QDFKDFPM->WDFKDFLN; *Odata->FldIO = p_QDFFFINF->WDFFFIOA; p_KwdData = (KwdData_t *) ((char *) p_QDFKDFPM + sizeof(QDFKDFPM_t) ); memcpy(Odata->FldCom, p_KwdData->Temp, p_QDFKDFPM->WDFKDFLN); } } } /* ######################################### */ int ProcessCat24() { /*-----------------------------------------------*/ /* This loops through all keywords that fall into*/ /* category 24 (Date, Time) */ /*-----------------------------------------------*/ } RTVFLDCL2 PGM (&LIB &FILE) /* CRTBNDCL PGM(urlib/RTVFLDCL2) SRCFILE(urlib/C) */ /* SRCMBR(RTVFLDCL2) REPLACE(*YES) */ DCL &LIB *CHAR 10 DCL &FILE *CHAR 10 CALL RTVFLD2 (&LIB &FILE) RCLACTGRP ACTGRP(DISPINFO2) ENDPGM RTVFLD2 /* CRTRPGMOD MODULE(urlib/RTVFLD2) SRCFILE(urlib/C) */ /* SRCMBR(RTVFLD2) REPLACE(*YES) */ /* CRTPGM PGM(urlib/RTVFLD2) */ /* MODULE(urlib/RTVFLD2 urlib/DISPINFOC2) */ /* ACTGRP(DISPINFO2) */ h Option(*NODEBUGIO) D RTVFLD2 PR D 10A D 10A D RTVFLD2 PI D iLib 10A D iFile 10A D DISPINFOC PR EXTPROC('DISPINFOC2') D Lib 10A const D File 10A const D oRecord 10A const D oField 10A const D oRow 1A const D oCol 1A const D Func 10A const D Fdata like(RTVDATA) // returned data D RTVDATA DS D RecordName 10A D ROW 1A D COL 1A D FldIO 1A D FldAtr 1A D FldNam 10A D FldCom 3000A D FLdPlen 10I 0 D FldDec 10I 0 D EndDta 10I 0 D oRecordName 10A D oFldNam 10A D oRow 1A D oCol 1A /free *INLR = *ON; CALLP DISPINFOC( iLib : iFile : ' ': ' ' : ' ': ' ': '#FIRST ' : RTVDATA ); DOW (EndDta = 0); oRecordName = RecordName ; oFldNam = FldNam ; oROW = ROW ; oCOL = COL ; // To get the next record the previous fields info is also passed CALLP DISPINFOC(iLib : iFile : oRecordName : oFldNam : oROW : oCOL : '#NEXT ' : RTVDATA ); ENDDO; /end-free