38 #define _XOPEN_SOURCE 600
50 # include <sys/utsname.h>
55 #if defined(__DEBUG__) && defined(__FL5__)
62 # define fopen_nowarn fopen
159 #define CLE_VSN_STR "1.3.81"
160 #define CLE_VSN_MAJOR 1
161 #define CLE_VSN_MINOR 3
162 #define CLE_VSN_REVISION 81
166 #define CLEINI_PROSIZ 1024
168 #define CLE_BUILTIN_IDX_SYNTAX 0
169 #define CLE_BUILTIN_IDX_HELP 1
170 #define CLE_BUILTIN_IDX_MANPAGE 2
171 #define CLE_BUILTIN_IDX_GENDOCU 3
172 #define CLE_BUILTIN_IDX_HTMLDOC 4
173 #define CLE_BUILTIN_IDX_GENPROP 5
174 #define CLE_BUILTIN_IDX_SETPROP 6
175 #define CLE_BUILTIN_IDX_CHGPROP 7
176 #define CLE_BUILTIN_IDX_DELPROP 8
177 #define CLE_BUILTIN_IDX_GETPROP 9
178 #define CLE_BUILTIN_IDX_SETOWNER 10
179 #define CLE_BUILTIN_IDX_GETOWNER 11
180 #define CLE_BUILTIN_IDX_SETENV 12
181 #define CLE_BUILTIN_IDX_GETENV 13
182 #define CLE_BUILTIN_IDX_DELENV 14
183 #define CLE_BUILTIN_IDX_TRACE 15
184 #define CLE_BUILTIN_IDX_CONFIG 16
185 #define CLE_BUILTIN_IDX_GRAMMAR 17
186 #define CLE_BUILTIN_IDX_LEXEMES 18
187 #define CLE_BUILTIN_IDX_LICENSE 19
188 #define CLE_BUILTIN_IDX_VERSION 20
189 #define CLE_BUILTIN_IDX_ABOUT 21
190 #define CLE_BUILTIN_IDX_ERRORS 22
194 typedef struct CnfEnt {
195 struct CnfEnt* psNxt;
196 struct CnfEnt* psBak;
203 typedef struct CnfHdl {
213 typedef struct CleBuiltin {
222 #define CLEBIF_OPN(name) TsCleBuiltin name[]
223 #define CLETAB_BIF(idx,kyw,hlp,syn,man,bif) {(idx),(kyw),(hlp),(syn),(man), (bif)},
224 #define CLEBIF_CLS { -1, NULL, NULL, NULL, NULL, FALSE}
226 typedef struct CleDocPar {
266 static int siClePropertyInit(
298 static int siClePropertyFinish(
311 static int siCleChangeProperties(
342 static int siCleCommandInit(
372 static int siCleSimpleInit(
382 static int siCleEndExecution(
392 static void vdCleManProgram(
408 static void vdCleManFunction(
410 const unsigned int uiLev,
426 static void vdPrnStaticSyntax(
435 static void vdPrnStaticHelp(
442 static void vdPrnCommandSyntax(
450 static void vdPrnCommandHelp(
457 static void vdPrnCommandManpage(
466 static void vdPrnProperties(
471 static int siCleGetProperties(
484 static int siCleGetCommand(
512 static const char* pcCnfGet(
516 static int siCnfPutEnv(
521 static int siCnfPrnEnv(
536 static void vdCnfCls(
543 snprintc(b,s,
"%2.2d FLAM-CLE VERSION: %s-%u BUILD: %s %s %s\n",l,
CLE_VSN_STR,__BUILDNR__,__BUILD__,__DATE__,__TIME__);
547 extern const char*
pcCleAbout(
const int l,
const int s,
char* b)
550 "%2.2d Frankenstein Limes Command Line Execution (FLAM-CLE)\n"
551 " Version: %s-%u Build: %s %s %s\n"
552 " Copyright (C) limes datentechnik (R) gmbh\n"
553 " This library is open source from the FLAM(R) project: http://www.flam.de\n"
554 " for license see: https://github.com/limes-datentechnik-gmbh/flamclep\n"
555 "This library uses the internal library below:\n"
556 ,l,
CLE_VSN_STR,__BUILDNR__,__BUILD__,__DATE__,__TIME__);
560 static inline const char* pcMapDocTyp(
const unsigned int uiTyp) {
579 default:
return(
"UNKOWN");
583 static inline const char* pcMapCleRtc(
int siRtc) {
587 case CLERTC_FIN:
return(
"finish function failed");
593 case CLERTC_INI:
return(
"initialization failed");
594 case CLERTC_CFG:
return(
"configuration wrong");
595 case CLERTC_TAB:
return(
"table error (CLP) ");
597 case CLERTC_ACS:
return(
"license/access error");
599 case CLERTC_MEM:
return(
"memory/allocation failed");
601 default :
return(
"special condition code");
605 static int siClpFile2String(
void* gbl,
void* hdl,
const char* filename,
char** buf,
int* bufsize,
char* errmsg,
const int msgsiz) {
608 if (pcFil==NULL)
return(-1);
609 int siErr=
file2str(hdl, pcFil, buf, bufsize, errmsg, msgsiz);
615 #define ERROR(x,b) do { \
616 int r = siCleEndExecution((x),psCnf,pfTrh,pfDoc,pfPro,ppArg,pvHdl,(b));\
618 if (pcBld!=NULL && *pcBld) {\
619 if (pfErr!=NULL) efprintf(pfErr,"%s Program '%s' (Build: %s (%s %s)) ends with completion code %d (%s)\n",cstime(0,acTs),(pcProgram!=NULL)?pcProgram:"-NULL-",pcBld,__DATE__,__TIME__,r,pcMapCleRtc(r));\
621 if (pfErr!=NULL) efprintf(pfErr,"%s Program '%s' (Build: %s %s) ends with completion code %d (%s)\n",cstime(0,acTs),(pcProgram!=NULL)?pcProgram:"-NULL-",__DATE__,__TIME__,r,pcMapCleRtc(r));\
624 if (pcBld!=NULL && *pcBld) {\
625 if (pfOut!=NULL) efprintf(pfOut,"%s Program '%s' (Build: %s (%s %s)) run successfully\n",cstime(0,acTs),(pcProgram!=NULL)?pcProgram:"-NULL-",pcBld,__DATE__,__TIME__);\
627 if (pfOut!=NULL) efprintf(pfOut,"%s Program '%s' (Build: %s %s) run successfully\n",cstime(0,acTs),(pcProgram!=NULL)?pcProgram:"-NULL-",__DATE__,__TIME__);\
630 if (pfOut!=NULL) efprintf(pfOut,"%s Total runtime %us / Total CPU time %3.3fs\n",cstime(0,acTs),(U32)(time(NULL)-uiTime),((double)(clock()-uiClock))/CLOCKS_PER_SEC);\
643 static inline TsCnfHdl* psOpenConfig(FILE* pfOut, FILE* pfErr,
const char* pcHom,
const char* pcPgm,
const char* pcPgu,
const char* pcPgl,
const int isCas) {
651 srprintf(&pcCnf,&szCnf,strlen(pcPgu),
"%s_CONFIG_FILE",pcPgu);
654 fprintf(pfErr,
"Memory allocation for %s_CONFIG_FILE failed\n",pcPgu);
665 srprintf(&pcFil,&szFil,strlen(pcPgu)+8,
"'%s.",
userid(
sizeof(acUsr),acUsr));
668 fprintf(pfErr,
"Memory allocation for default configuration file name failed\n");
673 for (j=strlen(pcFil),i=0;i<8 && pcPgu[i];i++) {
674 if (isalnum(pcPgu[i])) {
679 strcpy(pcFil+j,
".CONFIG'");
683 srprintf(&pcFil,&szFil,strlen(pcPgl),
".%s.config",pcPgl);
686 fprintf(pfErr,
"Memory allocation for default configuration file name failed\n");
693 srprintf(&pcFil,&szFil,strlen(pcHom)+strlen(pcPgl),
"%s.%s.config",pcHom,pcPgl);
696 fprintf(pfErr,
"Memory allocation for default configuration file name failed\n");
703 fprintf(pfOut,
"%s Use default configuration file (%s) in home directory\n",
cstime(0,acTs),pcFil);
709 fprintf(pfOut,
"%s Use existing configuration file (%s) in working directory\n",
cstime(0,acTs),pcFil);
713 srprintf(&pcFil,&szFil,strlen(pcPgl),
".%s.config",pcPgl);
716 fprintf(pfErr,
"Memory allocation for default configuration file name failed\n");
723 fprintf(pfOut,
"%s Use default configuration file (%s) in working directory\n",
cstime(0,acTs),pcFil);
728 srprintf(&pcFil,&szFil,strlen(m),
"%s",m);
731 fprintf(pfErr,
"Memory allocation for configuration file name (%s) from environment variable failed\n",pcCnf);
738 fprintf(pfOut,
"%s Using configuration file (%s) defined by environment variable (%s)\n",
cstime(0,acTs),pcFil,pcCnf);
742 psCnf=psCnfOpn(pfErr,isCas,pcPgm,pcFil);
750 static int siPrintChapter(FILE* pfErr, FILE* pfDoc,
const TsCleDoc* psDoc,
const char* pcOwn,
const char* pcPgm,
const char* pcAut,
const char* pcAdr,
const char* pcBld,
const int isHdr,
const int isNbr,
const int isIdt) {
753 char acKyw[strlen(psDoc->
pcKyw)+4];
754 snprintf(acKyw,
sizeof(acKyw),
"[%s]",psDoc->
pcKyw);
755 fprintm(pfDoc,pcOwn,pcPgm,pcBld,acKyw,1);
758 char acAnc[strlen(psDoc->
pcAnc)+8];
759 snprintf(acAnc,
sizeof(acAnc),
"[[%s]]",psDoc->
pcAnc);
760 fprintm(pfDoc,pcOwn,pcPgm,pcBld,acAnc,1);
762 for (
unsigned int i=0;i<psDoc->
uiLev;i++) {
767 if (isHdr && pcAut!=NULL && *pcAut) {
770 if (pcAdr!=NULL && *pcAdr) {
771 snprintf(acHdr,
sizeof(acHdr),
"%s <%s>\nv&{BLD}, &{DATE}: &{state}.",pcAut,pcAdr);
773 snprintf(acHdr,
sizeof(acHdr),
"%s\nv&{BLD}, &{DATE}: &{state}.",pcAut);
775 fprintm(pfDoc,pcOwn,pcPgm,pcBld,acHdr,2);
779 if (isIdt && psDoc->
pcIdt!=NULL && *psDoc->
pcIdt) {
781 const char* pcIdt=psDoc->
pcIdt;
782 for (pcHlp=strchr(pcIdt,
'\n');pcHlp!=NULL;pcHlp=strchr(pcIdt,
'\n')) {
783 char acIdt[strlen(pcIdt)+16];
784 snprintf(acIdt,
sizeof(acIdt),
"indexterm:[%.*s]",(
int)(pcHlp-pcIdt),pcIdt);
785 fprintm(pfDoc,pcOwn,pcPgm,pcBld,acIdt,1);
788 char acIdt[strlen(pcIdt)+16];
789 snprintf(acIdt,
sizeof(acIdt),
"indexterm:[%s]",pcIdt);
790 fprintm(pfDoc,pcOwn,pcPgm,pcBld,acIdt,2);
795 if (pfErr!=NULL) fprintf(pfErr,
"No manual page for chapter '%s' provided\n",psDoc->
pcHdl);
801 if (pfErr!=NULL) fprintf(pfErr,
"No head line for chapter defined\n");
806 static int siClePrintCover(FILE* pfErr, FILE* pfDoc,
const TsCleDoc* psDoc,
const char* pcOwn,
const char* pcPgm,
const char* pcAut,
const char* pcAdr,
const char* pcBld,
const int isHdr,
const int isNbr,
const int isIdt) {
807 if (psDoc->
uiLev!=1) {
808 if (pfErr!=NULL) fprintf(pfErr,
"The level (%u) for the cover page must be 1\n",psDoc->
uiLev);
812 efprintf(pfDoc,
":doctype: book\n\n");
814 return(siPrintChapter(pfErr,pfDoc,psDoc,pcOwn,pcPgm,pcAut,pcAdr,pcBld,isHdr,isNbr,isIdt));
817 static int siClePrintChapter(FILE* pfErr, FILE* pfDoc,
const TsCleDoc* psDoc,
const char* pcOwn,
const char* pcPgm,
const char* pcBld,
const int isNbr,
const int isIdt) {
819 if (pfErr!=NULL) fprintf(pfErr,
"The level (%u) for a chapter must be between 2 and 6\n",psDoc->
uiLev);
822 return(siPrintChapter(pfErr,pfDoc,psDoc,pcOwn,pcPgm,NULL,NULL,pcBld,FALSE,isNbr,isIdt));
825 static int siClePrintPgmSynopsis(FILE* pfErr, FILE* pfDoc,
const TsCleDoc* psDoc,
const char* pcOwn,
const char* pcPgm,
const char* pcBld,
const char* pcHlp,
const int isPat,
const int isNbr,
const int isIdt) {
826 int siErr=siClePrintChapter(pfErr,pfDoc,psDoc,pcOwn,pcPgm,pcBld,isNbr,isIdt);
827 if (siErr)
return(siErr);
828 efprintf(pfDoc,
"-----------------------------------------------------------------------\n");
833 efprintf(pfDoc,
"SYNTAX: > %s COMMAND/FUNCTION ...\n",pcPgm);
834 efprintf(pfDoc,
"-----------------------------------------------------------------------\n\n");
839 const char* pcOwn,
const char* pcPgm,
const char* pcBld,
const char* pcDep,
const char* pcOpt,
const char* pcDpa,
const int isNbr,
const int isIdt) {
840 int siErr=siClePrintChapter(pfErr,pfDoc,psDoc,pcOwn,pcPgm,pcBld,isNbr,isIdt);
841 if (siErr)
return(siErr);
842 efprintf(pfDoc,
"------------------------------------------------------------------------\n");
843 efprintf(pfDoc,
"Syntax for program '%s':\n",pcPgm);
844 vdPrnStaticSyntax(pfDoc,psCmd,psBif,pcPgm,pcDep,pcOpt,pcDpa);
845 efprintf(pfDoc,
"------------------------------------------------------------------------\n\n");
850 const char* pcOwn,
const char* pcPgm,
const char* pcBld,
const char* pcDep,
const int isNbr,
const int isIdt) {
851 int siErr=siClePrintChapter(pfErr,pfDoc,psDoc,pcOwn,pcPgm,pcBld,isNbr,isIdt);
852 if (siErr)
return(siErr);
853 efprintf(pfDoc,
"------------------------------------------------------------------------\n");
854 efprintf(pfDoc,
"Help for program '%s':\n",pcPgm);
855 vdPrnStaticHelp(pfDoc,psCmd,psBif,pcPgm,pcDep);
856 efprintf(pfDoc,
"------------------------------------------------------------------------\n\n");
860 static int siClePrintBuiltIn(FILE* pfErr, FILE* pfDoc,
const TsCleDoc* psDoc,
const char* pcOwn,
const char* pcPgm,
const char* pcBld,
const int isPat,
const int isNbr,
const int isShl,
const int isIdt,
const TsCleBuiltin* psBif) {
861 int siErr=siClePrintChapter(pfErr,pfDoc,psDoc,pcOwn,pcPgm,pcBld,isNbr,isIdt);
862 if (siErr)
return(siErr);
863 for (
int i=0;psBif[i].pcKyw!=NULL;i++) {
864 char acNum[strlen(psDoc->
pcNum)+16];
865 if (psDoc->
pcNum!=NULL && *psDoc->
pcNum) snprintf(acNum,
sizeof(acNum),
"%s%d.",psDoc->
pcNum,i+1);
else snprintf(acNum,
sizeof(acNum),
"%d.",i+1);
866 vdCleManFunction(pfDoc,psDoc->
uiLev+1,
S_TLD,acNum,psBif[i].pcKyw,psBif[i].pcHlp,pcOwn,pcPgm,pcBld,psBif[i].pcSyn,psBif[i].pcMan,FALSE,isPat,isNbr,isShl,isIdt);
871 static int siClePrintLexemes(FILE* pfErr, FILE* pfDoc,
const TsCleDoc* psDoc,
const char* pcOwn,
const char* pcPgm,
const char* pcBld,
872 const int isPfl,
const int isRpl,
const char* pcDep,
const char* pcOpt,
const char* pcEnt,
const int isNbr,
const int isIdt) {
874 int siErr=siClePrintChapter(pfErr,pfDoc,psDoc,pcOwn,pcPgm,pcBld,isNbr,isIdt);
875 if (siErr)
return(siErr);
876 siErr=siCleSimpleInit(NULL,pfErr,isPfl,isRpl,pcDep,pcOpt,pcEnt,&pvHdl);
877 if (siErr)
return(siErr);
878 efprintf(pfDoc,
"------------------------------------------------------------------------\n");
879 efprintf(pfDoc,
"Lexemes (regular expressions) for argument list or parameter file\n");
882 efprintf(pfDoc,
"------------------------------------------------------------------------\n\n");
886 static int siClePrintGrammar(FILE* pfErr, FILE* pfDoc,
const TsCleDoc* psDoc,
const char* pcOwn,
const char* pcPgm,
const char* pcBld,
887 const int isPfl,
const int isRpl,
const char* pcDep,
const char* pcOpt,
const char* pcEnt,
const int isNbr,
const int isIdt) {
889 int siErr=siClePrintChapter(pfErr,pfDoc,psDoc,pcOwn,pcPgm,pcBld,isNbr,isIdt);
890 if (siErr)
return(siErr);
891 siErr=siCleSimpleInit(NULL,pfErr,isPfl,isRpl,pcDep,pcOpt,pcEnt,&pvHdl);
892 if (siErr)
return(siErr);
893 efprintf(pfDoc,
"------------------------------------------------------------------------\n");
894 efprintf(pfDoc,
"Grammar for argument list, parameter file or property file\n");
897 efprintf(pfDoc,
"------------------------------------------------------------------------\n\n");
901 static int siClePrintPreformatedText(FILE* pfErr, FILE* pfDoc,
const TsCleDoc* psDoc,
const char* pcOwn,
const char* pcPgm,
const char* pcBld,
const char* pcTxt,
const int isNbr,
const int isIdt) {
902 if (pcTxt!=NULL && *pcTxt) {
903 int siErr=siClePrintChapter(pfErr,pfDoc,psDoc,pcOwn,pcPgm,pcBld,isNbr,isIdt);
904 if (siErr)
return(siErr);
905 efprintf(pfDoc,
"------------------------------------------------------------------------\n");
907 efprintf(pfDoc,
"------------------------------------------------------------------------\n\n");
910 if (pfErr!=NULL) fprintf(pfErr,
"No pre-formatted text provided but print requested (version, about)\n");
915 static int siClePrintPropRemain(FILE* pfErr, FILE* pfDoc,
const TsCleDoc* psDoc,
const TsCleCommand* psCmd,
void* pvCnf,
const char* pcOwn,
const char* pcPgm,
const char* pcBld,
916 const int isCas,
const int isPfl,
const int isRpl,
const int siMkl,
const char* pcDep,
const char* pcOpt,
const char* pcEnt,
const int isNbr,
const int isIdt) {
917 int siErr=siClePrintChapter(pfErr,pfDoc,psDoc,pcOwn,pcPgm,pcBld,isNbr,isIdt);
918 if (siErr)
return(siErr);
919 for (
int j=0;siErr==0 && psCmd[j].
pcKyw!=NULL;j++) {
921 siErr=siClePropertyInit(NULL,psCmd[j].pfIni,psCmd[j].pvClp,pcOwn,pcPgm,pcBld,psCmd[j].pcKyw,psCmd[j].pcMan,psCmd[j].pcHlp,
922 psCmd[j].piOid,psCmd[j].psTab,isCas,isPfl,isRpl,siMkl,NULL,pfErr,NULL,
923 pcDep,pcOpt,pcEnt,(
TsCnfHdl*)pvCnf,&pvHdl,NULL,NULL,NULL,NULL,siClpFile2String,NULL,NULL);
933 static int siClePrintPropDefaults(FILE* pfErr, FILE* pfDoc,
const TsCleDoc* psDoc,
const TsCleCommand* psCmd,
void* pvCnf,
const char* pcOwn,
const char* pcPgm,
const char* pcBld,
934 const int isCas,
const int isPfl,
const int isRpl,
const int siMkl,
const char* pcDep,
const char* pcOpt,
const char* pcEnt,
const int isNbr,
const int isIdt) {
935 int siErr=siClePrintChapter(pfErr,pfDoc,psDoc,pcOwn,pcPgm,pcBld,isNbr,isIdt);
936 if (siErr)
return(siErr);
937 efprintf(pfDoc,
"------------------------------------------------------------------------\n");
938 efprintf(pfDoc,
"\n# Property file for: %s.%s #\n",pcOwn,pcPgm);
939 efprintf(pfDoc,
"%s",HLP_CLE_PROPFIL);
940 for (
int j=0;siErr==0 && psCmd[j].
pcKyw!=NULL;j++) {
942 siErr=siClePropertyInit(NULL,psCmd[j].pfIni,psCmd[j].pvClp,pcOwn,pcPgm,pcBld,psCmd[j].pcKyw,psCmd[j].pcMan,psCmd[j].pcHlp,
943 psCmd[j].piOid,psCmd[j].psTab,isCas,isPfl,isRpl,siMkl,NULL,pfErr,NULL,
944 pcDep,pcOpt,pcEnt,(
TsCnfHdl*)pvCnf,&pvHdl,NULL,NULL,NULL,NULL,siClpFile2String,NULL,NULL);
951 efprintf(pfDoc,
"------------------------------------------------------------------------\n\n");
955 static int siClePrintReasonCodes(FILE* pfErr, FILE* pfDoc,
const TsCleDoc* psDoc,
const char* pcOwn,
const char* pcPgm,
const char* pcBld,
TfMsg* pfMsg,
const int isNbr,
const int isIdt) {
959 int siErr=siClePrintChapter(pfErr,pfDoc,psDoc,pcOwn,pcPgm,pcBld,isNbr,isIdt);
960 if (siErr)
return(siErr);
961 for (r=1,m=pfMsg(r);m!=NULL;r++,m=pfMsg(r)) {
962 if (*m)
efprintf(pfDoc,
"* %d - %s\n",r,m);
967 if (pfErr!=NULL) fprintf(pfErr,
"The pointer to the message function to map the reason codes is NULL but print was requested\n");
974 static int siCleWritePage(FILE* pfErr, FILE* pfDoc,
const TsCleDoc* psDoc,
const TsCleDocPar* psPar) {
975 switch (psDoc->
uiTyp) {
976 case CLE_DOCTYP_COVER:
return(siClePrintCover(pfErr,pfDoc,psDoc,psPar->pcOwn,psPar->pcPgm,psPar->pcAut,psPar->pcAdr,psPar->pcBld,psPar->isHdr,psPar->isNbr,psPar->isIdt));
977 case CLE_DOCTYP_CHAPTER:
return(siClePrintChapter(pfErr,pfDoc,psDoc,psPar->pcOwn,psPar->pcPgm,psPar->pcBld,psPar->isNbr,psPar->isIdt));
978 case CLE_DOCTYP_BUILTIN:
return(siClePrintBuiltIn(pfErr,pfDoc,psDoc,psPar->pcOwn,psPar->pcPgm,psPar->pcBld,psPar->isPat,psPar->isNbr,psPar->isShl,psPar->isIdt,psPar->psBif));
979 case CLE_DOCTYP_PROGRAM:
return(siClePrintChapter(pfErr,pfDoc,psDoc,psPar->pcOwn,psPar->pcPgm,psPar->pcBld,psPar->isNbr,psPar->isIdt));
980 case CLE_DOCTYP_PGMSYNOPSIS:
return(siClePrintPgmSynopsis(pfErr,pfDoc,psDoc,psPar->pcOwn,psPar->pcPgm,psPar->pcBld,psPar->pcHlp,psPar->isPat,psPar->isNbr,psPar->isIdt));
981 case CLE_DOCTYP_PGMSYNTAX:
return(siClePrintPgmSyntax(pfErr,pfDoc,psDoc,psPar->psCmd,psPar->psBif,psPar->pcOwn,psPar->pcPgm,psPar->pcBld,psPar->pcDep,psPar->pcOpt,psPar->pcDpa,psPar->isNbr,psPar->isIdt));
982 case CLE_DOCTYP_PGMHELP:
return(siClePrintPgmHelp(pfErr,pfDoc,psDoc,psPar->psCmd,psPar->psBif,psPar->pcOwn,psPar->pcPgm,psPar->pcBld,psPar->pcDep,psPar->isNbr,psPar->isIdt));
983 case CLE_DOCTYP_COMMANDS:
return(siClePrintChapter(pfErr,pfDoc,psDoc,psPar->pcOwn,psPar->pcPgm,psPar->pcBld,psPar->isNbr,psPar->isIdt));
984 case CLE_DOCTYP_OTHERCLP:
return(siClePrintChapter(pfErr,pfDoc,psDoc,psPar->pcOwn,psPar->pcPgm,psPar->pcBld,psPar->isNbr,psPar->isIdt));
985 case CLE_DOCTYP_LEXEMES:
return(siClePrintLexemes(pfErr,pfDoc,psDoc,psPar->pcOwn,psPar->pcPgm,psPar->pcBld,psPar->isPfl,psPar->isRpl,psPar->pcDep,psPar->pcOpt,psPar->pcEnt,psPar->isNbr,psPar->isIdt));
986 case CLE_DOCTYP_GRAMMAR:
return(siClePrintGrammar(pfErr,pfDoc,psDoc,psPar->pcOwn,psPar->pcPgm,psPar->pcBld,psPar->isPfl,psPar->isRpl,psPar->pcDep,psPar->pcOpt,psPar->pcEnt,psPar->isNbr,psPar->isIdt));
987 case CLE_DOCTYP_PROPREMAIN:
return(siClePrintPropRemain(pfErr,pfDoc,psDoc,psPar->psCmd,psPar->pvCnf,psPar->pcOwn,psPar->pcPgm,psPar->pcBld,
988 psPar->isCas,psPar->isPfl,psPar->isRpl,psPar->siMkl,psPar->pcDep,psPar->pcOpt,psPar->pcEnt,psPar->isNbr,psPar->isIdt));
989 case CLE_DOCTYP_PROPDEFAULTS:
return(siClePrintPropDefaults(pfErr,pfDoc,psDoc,psPar->psCmd,psPar->pvCnf,psPar->pcOwn,psPar->pcPgm,psPar->pcBld,
990 psPar->isCas,psPar->isPfl,psPar->isRpl,psPar->siMkl,psPar->pcDep,psPar->pcOpt,psPar->pcEnt,psPar->isNbr,psPar->isIdt));
991 case CLE_DOCTYP_SPECIALCODES:
return(siClePrintChapter(pfErr,pfDoc,psDoc,psPar->pcOwn,psPar->pcPgm,psPar->pcBld,psPar->isNbr,psPar->isIdt));
992 case CLE_DOCTYP_REASONCODES:
return(siClePrintReasonCodes(pfErr,pfDoc,psDoc,psPar->pcOwn,psPar->pcPgm,psPar->pcBld,psPar->pfMsg,psPar->isNbr,psPar->isIdt));
993 case CLE_DOCTYP_VERSION:
return(siClePrintPreformatedText(pfErr,pfDoc,psDoc,psPar->pcOwn,psPar->pcPgm,psPar->pcBld,psPar->pcVsn,psPar->isNbr,psPar->isIdt));
994 case CLE_DOCTYP_ABOUT:
return(siClePrintPreformatedText(pfErr,pfDoc,psDoc,psPar->pcOwn,psPar->pcPgm,psPar->pcBld,psPar->pcAbo,psPar->isNbr,psPar->isIdt));
996 if (pfErr!=NULL) fprintf(pfErr,
"Documentation type (%u) not supported\n",psDoc->
uiTyp);
1003 if (psDoc->
pcHdl==NULL) {
1004 if (pfErr!=NULL) fprintf(pfErr,
"Headline is NULL\n");
1008 fprintf(pfOut,
"... print %24s ",pcMapDocTyp(psDoc->
uiTyp));
1009 for (i=0;i<psDoc->
uiLev;i++) fprintf(pfOut,
"=");
1010 fprintf(pfOut,
" %s\n",psDoc->
pcHdl);
1014 if (pfErr!=NULL) fprintf(pfErr,
"Open of temporary file to print manual page '%s' failed (%d - %s)\n",psDoc->
pcHdl,errno,strerror(errno));
1017 int siErr=siCleWritePage(pfErr,pfDoc,psDoc,psPar);
1022 size_t s=(size_t)ftell(pfDoc);
1024 char* pcPge=malloc(s+1);
1026 if (pfErr!=NULL) fprintf(pfErr,
"Allocation of memory for temporary file to print manual '%s' page failed\n",psDoc->
pcHdl);
1030 size_t r=fread(pcPge,1,s,pfDoc);
1034 if (pfErr!=NULL) fprintf(pfErr,
"Read of temporary file to print manual page '%s' failed (%d - %s)\n",psDoc->
pcHdl,errno,strerror(errno));
1039 const char* p=strchr(pcPge,
'=');
1042 if (pfErr!=NULL) fprintf(pfErr,
"No headline found in manual page '%s' (no sign)\n",psDoc->
pcHdl);
1045 while (*p==
'=') p++;
1048 if (pfErr!=NULL) fprintf(pfErr,
"No headline found in manual page '%s' (no blank after sign)\n",psDoc->
pcHdl);
1052 const char* e=strchr(p,
'\n');
1055 if (pfErr!=NULL) fprintf(pfErr,
"No end of headline found in manual page '%s'\n",psDoc->
pcHdl);
1064 unsigned int uiHsh=fnvHash(l,(
const unsigned char*)pcFil);
1066 if (pcFil[i]==
'\t') {
1067 acFil[i]=psPar->siPs1;
1068 }
else if (pcFil[i]==
'\v') {
1069 acFil[i]=psPar->siPs2;
1070 }
else if (isalnum(pcFil[i])) {
1071 acFil[i]=tolower(pcFil[i]);
1073 acFil[i]=psPar->siPr3;
1077 snprintc(acFil,
sizeof(acFil),
"%c%04x",psPar->siPr3,uiHsh&0xFFFF);
1078 siErr=pfPrn(pvPrn,psDoc->
uiLev,acHdl,NULL,acFil,psDoc->
pcMan,pcPge);
1081 if (pfErr!=NULL) fprintf(pfErr,
"Print page over call back function for command '%s' failed with %d\n",psDoc->
pcHdl,siErr);
1091 void* pvHtmlDoc=LoadLibrary(TEXT(
"htmldoc.dll"));
1092 if (pvHtmlDoc==NULL)
return(NULL);
1093 *ppHtmlOpn=(
TfCleOpenPrint*)GetProcAddress(pvHtmlDoc,
"opnHtmlDoc");
1094 *ppHtmlPrn=(
TfClpPrintPage*)GetProcAddress(pvHtmlDoc,
"prnHtmlDoc");
1097 void* pvHtmlDoc=dlopen(
"libhtmldoc.so",RTLD_LAZY);
1098 if (pvHtmlDoc==NULL)
return(NULL);
1106 static void vdFreeHtmlDoc(
void** ppLib) {
1107 if (ppLib!=NULL && *ppLib!=NULL) {
1109 FreeLibrary(*ppLib);
1117 static int siPrintPage(
void* pvHdl,
const int siLev,
const char* pcHdl,
const char* pcPat,
const char* pcFil,
const char* pcOrg,
const char* pcPge) {
1118 int l=strlen(pcPge);
1119 int r=fwrite(pcPge,1,l,(FILE*)pvHdl);
1123 static int siPrintDocu(
1133 const char* apPat[8]={
"",
"",
"",
"",
"",
"",
"",
""};
1134 for (
int i=0; psDoc[i].
uiTyp && psDoc[i].
uiLev>0 && psDoc[i].
uiLev<7; i++) {
1136 char acFil[1024]=
"";
1137 apPat[psDoc[i].
uiLev]=psDoc[i].pcHdl;
1138 for (
int j=1;j<=psDoc[i].uiLev;j++) {
1140 if (x<
sizeof(acFil)-1) {
1145 for (
int k=0;apPat[j][k];k++) {
1146 if (x<
sizeof(acFil)-1) {
1147 acFil[x]=apPat[j][k];
1153 int siErr=siClePrintPage(pfOut,pfErr,psDoc+i,acFil,psPar,pvPrn,pfPrn);
1154 if (siErr)
return(siErr);
1156 for (
int j=0;psPar->psCmd[j].pcKyw!=NULL;j++) {
1157 if (psPar->psCmd[j].siFlg) {
1160 siErr=siCleCommandInit(pvGbl,psPar->psCmd[j].pfIni,psPar->psCmd[j].pvClp,psPar->pcOwn,psPar->pcPgm,psPar->pcBld,psPar->psCmd[j].pcKyw,psPar->psCmd[j].pcMan,psPar->psCmd[j].pcHlp,psPar->psCmd[j].piOid,psPar->psCmd[j].psTab,
1161 psPar->isCas,psPar->isPfl,psPar->isRpl,psPar->siMkl,pfOut,pfErr,NULL,psPar->pcDep,psPar->pcOpt,psPar->pcEnt,psPar->pvCnf,&pvClp,psPar->pfMsg,psPar->pvF2S,psPar->pfF2S,psPar->pvSaf,psPar->pfSaf);
1162 if (siErr)
return(siErr);
1163 if (psDoc[i].pcNum!=NULL && *psDoc[i].pcNum) {
1164 snprintf(acNum,
sizeof(acNum),
"%s%d.",psDoc[i].pcNum,j+1);
1166 snprintf(acNum,
sizeof(acNum),
"%d.",j+1);
1168 siErr=
siClpPrint(pvClp,acFil,acNum,
"Command",TRUE,psPar->isDep,psPar->isAnc,psPar->isNbr,psPar->isShl,psPar->isIdt,psPar->isPat,
1169 psDoc[i].uiLev+1,psPar->siPs1,psPar->siPs2,psPar->siPr3,pvPrn,pfPrn);
1172 if (pfErr!=NULL) fprintf(pfErr,
"Creation of documentation for command '%s' failed\n",psPar->psCmd[j].pcKyw);
1178 if (psPar->psOth==NULL) {
1179 if (pfErr!=NULL) fprintf(pfErr,
"The pointer to the list of other CLP strings is NULL but DOCTYP OTHERCLP requested\n");
1182 for (
int j=0;psPar->psOth[j].pcKyw!=NULL;j++) {
1185 pvClp=
pvClpOpen(psPar->isCas,psPar->isPfl,psPar->isRpl,psPar->siMkl,psPar->pcOwn,psPar->psOth[j].pcRot,psPar->pcBld,psPar->psOth[j].pcKyw,psPar->psOth[j].pcMan,psPar->psOth[j].pcHlp,psPar->psOth[j].isOvl,
1186 psPar->psOth[j].psTab,NULL,pfOut,pfErr,NULL,NULL,NULL,NULL,psPar->pcDep,psPar->pcOpt,psPar->pcEnt,NULL,pvGbl,psPar->pvF2S,psPar->pfF2S,psPar->pvSaf,psPar->pfSaf);
1188 if (pfErr!=NULL) fprintf(pfErr,
"Open of parser for CLP string of appendix '%s' failed\n",psPar->psOth[j].pcKyw);
1191 if (psDoc[i].pcNum!=NULL && *psDoc[i].pcNum) {
1192 snprintf(acNum,
sizeof(acNum),
"%s%d.",psDoc[i].pcNum,j+1);
1194 snprintf(acNum,
sizeof(acNum),
"%d.",j+1);
1196 siErr=
siClpPrint(pvClp,acFil,acNum,
"String",FALSE,psPar->isDep,psPar->isAnc,psPar->isNbr,psPar->isShl,psPar->isIdt,psPar->isPat,
1197 psDoc[i].uiLev+1,psPar->siPs1,psPar->siPs2,psPar->siPr3,pvPrn,pfPrn);
1200 if (pfErr!=NULL) fprintf(pfErr,
"Creation of documentation for other CLP string '%s' failed\n",psPar->psOth[j].pcKyw);
1207 if (pfErr!=NULL) fprintf(pfErr,
"No table for documentation generation given\n");
1220 const char* pcOwner,
1221 const char* pcProgram,
1250 int i,j,l,siErr,siDep,siCnt;
1259 const char* pcMsg=NULL;
1264 FILE* pfStd=(pfOut!=NULL)?pfOut:stderr;
1265 FILE* pfErr=(pfOut!=NULL)?pfOut:stderr;
1273 const char* pcPgmNum=
"2.";
1274 const char* pcCmdNum=
"3.";
1275 const char* pcBifNum=
"4.";
1276 const char* pcSccMan=NULL;
1277 const char* pcPgmMan=NULL;
1280 time_t uiTime=time(NULL);
1281 clock_t uiClock=clock();
1311 if (
strxcmp(isCas,argv[argc-1],
"SILENT",0,0,FALSE)==0) {
1315 }
else if (
strxcmp(isCas,argv[argc-1],
"QUIET",0,0,FALSE)==0) {
1322 if (psCmd==NULL || argc==0 || argv==NULL || pcOwner==NULL || pcProgram==NULL || pcHlp==NULL ||
1323 pcDep==NULL || pcOpt==NULL || pcEnt==NULL || *pcOwner==0x00 || *pcProgram==0x00 || *pcHlp==0 || psDoc==NULL) {
1324 if (pfErr!=NULL) fprintf(pfErr,
"CLE call parameter incorrect (NULL pointer or empty strings)\n");
1329 char* pcwinvers = NULL;
1331 if (pfOut!=NULL)
efprintf(pfOut,
"%s Run on %s\n",
cstime(0,acTs),windowsversionstring(&pcwinvers, &szwv));
1332 if (pcwinvers != NULL) free(pcwinvers);
1335 if(uname(&uts)>=0) {
1336 if (pfOut!=NULL)
efprintf(pfOut,
"%s Run on %s(%s)v(%s)r(%s)m(%s)\n",
cstime(0,acTs),uts.sysname,uts.nodename,uts.version,uts.release,uts.machine);
1340 if (pfOut!=NULL)
efprintf(pfOut,
"%s Start program '%s' (Build: %s (%s %s))\n",
cstime(0,acTs),(pcProgram!=NULL)?pcProgram:
"-NULL-",pcBld,__DATE__,__TIME__);
1342 for (i=0;asBif[i].pcKyw!=NULL;i++) {
1343 if (asBif[i].siIdx!=i) {
1344 if (pfErr!=NULL) fprintf(pfErr,
"Index of built-in function '%s' not valid\n",asBif[i].pcKyw);
1349 for (i=0;psDoc[i].
uiTyp;i++) {
1351 pcPgmNum=psDoc[i].
pcNum;
1354 pcCmdNum=psDoc[i].
pcNum;
1357 pcBifNum=psDoc[i].
pcNum;
1360 pcPgmMan=psDoc[i].
pcMan;
1363 pcSccMan=psDoc[i].
pcMan;
1369 pfF2S=siClpFile2String;
1374 if (siErr<0)
return(-1*siErr);
1379 if (pfErr!=NULL) fprintf(pfErr,
"Determination of home directory failed\n");
1385 if (pfErr!=NULL) fprintf(pfErr,
"Conversion of program name failed (not enough memory)\n");
1391 if (pfErr!=NULL) fprintf(pfErr,
"Conversion of program name to upper case failed (not enough memory)\n");
1397 if (pfErr!=NULL) fprintf(pfErr,
"Conversion of program name to lower case failed (not enough memory)\n");
1401 srprintf(&pcCnf,&szCnf,strlen(pcPgm),
"%s_DEFAULT_OWNER_ID",pcPgu);
1403 if (pfErr!=NULL) fprintf(pfErr,
"Memory allocation for %s_DEFAULT_OWNER_ID failed\n",pcPgu);
1407 if (m!=NULL && *m)
srprintf(&pcOwn,&szOwn,strlen(m),
"%s",m);
else srprintf(&pcOwn,&szOwn,strlen(pcOwner),
"%s",pcOwner);
1409 if (pfErr!=NULL) fprintf(pfErr,
"Determination of owner id failed\n");
1413 psCnf=psOpenConfig(pfOut,pfErr,pcHom,pcPgm,pcPgu,pcPgl,isCas);
1416 srprintf(&pcCnf,&szCnf,strlen(pcPgl),
"%s.owner.id",pcPgl);
1418 if (pfErr!=NULL) fprintf(pfErr,
"Memory allocation for configuration element owner id failed\n");
1421 m=pcCnfGet(psCnf,pcCnf);
1422 if (m!=NULL && *m) {
1423 srprintf(&pcOwn,&szOwn,strlen(m),
"%s",m);
1425 if (pfErr!=NULL) fprintf(pfErr,
"Memory allocation for owner name (%s) failed\n",m);
1430 i=siCnfPutEnv(psCnf,pcOwn,pcPgm);
1434 fprintf(pfOut,
"%s Load successfully %d environment variable using the configuration file.\n",
cstime(0,acTs),i);
1436 fprintf(pfOut,
"%s Load successfully %d environment variables using the configuration file.\n",
cstime(0,acTs),i);
1442 if (m==NULL || *m==0x00) {
1443 if (
SETENV(
"OWNERID",pcOwn)) {
1444 if (pfErr!=NULL) fprintf(pfErr,
"Put variable (%s=%s) to environment failed (%d - %s)\n",
"OWNERID",pcOwn,errno,strerror(errno));
1446 if (strcmp(pcOwn,
GETENV(
"OWNERID"))) {
1447 if (pfErr!=NULL) fprintf(pfErr,
"Put variable (%s=%s) to environment failed (strcmp(%s,GETENV(%s)))\n",
"OWNERID",pcOwn,pcOwn,
"OWNERID");
1450 if (pfOut!=NULL) fprintf(pfOut,
"%s Put variable (%s=%s) to environment was successful\n",
cstime(0,acTs),
"OWNERID",pcOwn);
1457 if (pfOut!=NULL) fprintf(pfOut,
"%s Environment variable OWNERID already defined (%s)\n",
cstime(0,acTs),pcOwn);
1463 fprintf(pfOut,
"%s Complete load of environment ...\n",
cstime(0,acTs));
1465 init_char(gsDiaChr.exc);
1470 char acDep[strlen(pcDep)+1];
1471 char acOpt[strlen(pcOpt)+1];
1472 char acEnt[strlen(pcEnt)+1];
1473 esnprintf(acDep,
sizeof(acDep),
"%s",pcDep);
1474 esnprintf(acOpt,
sizeof(acOpt),
"%s",pcOpt);
1475 esnprintf(acEnt,
sizeof(acEnt),
"%s",pcEnt);
1480 srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgl),
"%s.%s.trace",pcOwn,pcPgl);
1482 if (pfErr!=NULL) fprintf(pfErr,
"Memory allocation for configuration element trace failed\n");
1485 m=pcCnfGet(psCnf,pcCnf);
1486 if (m!=NULL &&
strxcmp(isCas,m,
"ON",0,0,FALSE)==0) {
1487 srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgl),
"%s.%s.trace.file",pcOwn,pcPgl);
1489 if (pfErr!=NULL) fprintf(pfErr,
"Memory allocation for configuration element trace file failed\n");
1492 m=pcCnfGet(psCnf,pcCnf);
1493 if (m!=NULL && *m) {
1498 if (pfErr!=NULL) fprintf(pfErr,
"Open of trace file (\"%s\",\"%s\") failed\n",pcFil,
"w");
1505 for (i=0; psCmd[i].
pcKyw!=NULL; i++) {
1506 if (psCmd[i].psTab==NULL || psCmd[i].pvClp==NULL || psCmd[i].pvPar==NULL ||
1507 psCmd[i].pfIni==NULL || psCmd[i].pfMap==NULL || psCmd[i].pfRun==NULL || psCmd[i].pfFin==NULL ||
1508 psCmd[i].pcMan==NULL || psCmd[i].pcHlp==NULL || *psCmd[i].pcKyw==0 || *psCmd[i].pcMan==0 || *psCmd[i].pcHlp==0) {
1509 if (pfErr!=NULL) fprintf(pfErr,
"Row %d of command table not initialized properly\n",i);
1514 if (pfErr!=NULL) fprintf(pfErr,
"Command table is empty\n");
1519 if (pcDef!=NULL && *pcDef) {
1520 ppArg=malloc((argc+1)*
sizeof(*ppArg));
1521 if (ppArg == NULL) {
1522 if (pfErr!=NULL) fprintf(pfErr,
"Memory allocation for argument list to run the default command '%s' failed\n",pcDef);
1525 ppArg[0]=argv[0]; ppArg[1]=(
char*)pcDef; argc=2; argv=ppArg;
1528 fprintf(pfErr,
"Command or built-in function required\n");
1529 vdPrnStaticSyntax(pfErr,psCmd,asBif,argv[0],pcDep,pcOpt,pcDpa);
1535 if (argv[1][0]==
'-') argv[1]++;
1536 if (argv[1][0]==
'-') argv[1]++;
1540 if (pfOut==NULL) pfOut=pfStd;
1541 if (pfErr==NULL) pfErr=pfStd;
1543 fprintf(pfOut,
"License of program '%s':\n",pcPgm);
1545 fprintf(pfOut,
"No license information available\n");
1547 fprintf(pfOut,
"%s\n",pcLic);
1551 fprintf(pfErr,
"Syntax for built-in function 'LICENSE' not valid\n");
1552 fprintf(pfErr,
"%s %s LICENSE\n",pcDep,argv[0]);
1555 if (pfOut==NULL) pfOut=pfStd;
1556 if (pfErr==NULL) pfErr=pfStd;
1558 fprintf(pfOut,
"Version for program '%s':\n",pcPgm);
1560 fprintf(pfOut,
"No version information available\n");
1562 fprintf(pfOut,
"%s\n",pcVsn);
1566 fprintf(pfErr,
"Syntax for built-in function 'VERSION' not valid\n");
1567 fprintf(pfErr,
"%s %s VERSION\n",pcDep,argv[0]);
1570 if (pfOut==NULL) pfOut=pfStd;
1571 if (pfErr==NULL) pfErr=pfStd;
1573 fprintf(pfOut,
"About program '%s':\n",pcPgm);
1575 fprintf(pfOut,
"No about information available\n");
1577 fprintf(pfOut,
"%s\n",pcAbo);
1581 fprintf(pfErr,
"Syntax for built-in function 'ABOUT' not valid\n");
1582 fprintf(pfErr,
"%s %s ABOUT\n",pcDep,argv[0]);
1584 }
else if (asBif[
CLE_BUILTIN_IDX_LEXEMES].isBif && (
strxcmp(isCas,argv[1],
"LEXEMES",0,0,FALSE)==0 ||
strxcmp(isCas,argv[1],
"LEXEM",0,0,FALSE)==0)) {
1585 if (pfOut==NULL) pfOut=pfStd;
1586 if (pfErr==NULL) pfErr=pfStd;
1588 siErr=siCleSimpleInit(pfOut,pfErr,isPfl,isRpl,pcDep,pcOpt,pcEnt,&pvHdl);
1589 if (siErr)
ERROR(siErr,NULL);
1590 fprintf(pfOut,
"Lexemes (regular expressions) for argument list or parameter file:\n");
1594 fprintf(pfErr,
"Syntax for built-in function 'LEXEMES' not valid\n");
1595 fprintf(pfErr,
"%s %s LEXEMES\n",pcDep,argv[0]);
1598 if (pfOut==NULL) pfOut=pfStd;
1599 if (pfErr==NULL) pfErr=pfStd;
1601 siErr=siCleSimpleInit(pfOut,pfErr,isPfl,isRpl,pcDep,pcOpt,pcEnt,&pvHdl);
1602 if (siErr)
ERROR(siErr,NULL);
1603 fprintf(pfOut,
"Grammar for argument list, parameter file or property file\n");
1607 fprintf(pfErr,
"Syntax for built-in function 'GRAMMAR' not valid\n");
1608 fprintf(pfErr,
"%s %s GRAMMAR\n",pcDep,argv[0]);
1611 if (pfOut==NULL) pfOut=pfStd;
1612 if (pfErr==NULL) pfErr=pfStd;
1615 efprintf(pfOut,
"Return/condition/exit codes of the executable\n");
1616 efprintf(pfOut,
"---------------------------------------------\n\n");
1617 fprintm(pfOut,pcOwn,pcPgm,pcBld,MAN_CLE_APPENDIX_RETURNCODES,1);
1618 if (pcSccMan!=NULL && *pcSccMan) {
1619 efprintf(pfOut,
"Special condition codes\n");
1620 efprintf(pfOut,
"~~~~~~~~~~~~~~~~~~~~~~~\n\n");
1621 fprintm(pfOut,pcOwn,pcPgm,pcBld,pcSccMan,1);
1624 efprintf(pfOut,
"Reason codes of the different commands\n");
1625 efprintf(pfOut,
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
1626 fprintm(pfOut,pcOwn,pcPgm,pcBld,MAN_CLE_APPENDIX_REASONCODES,1);
1627 for (i=1,m=pfMsg(i);m!=NULL;i++,m=pfMsg(i)) {
1628 if (*m) fprintf(pfOut,
" * %d - %s\n",i,m);
1633 fprintf(pfErr,
"Syntax for built-in function 'ERRORS' not valid\n");
1634 fprintf(pfErr,
"%s %s ERRORS\n",pcDep,argv[0]);
1637 if (pfOut==NULL) pfOut=pfStd;
1638 if (pfErr==NULL) pfErr=pfStd;
1640 fprintf(pfOut,
"Syntax for program '%s':\n",pcPgm);
1641 vdPrnStaticSyntax(pfOut,psCmd,asBif,argv[0],pcDep,pcOpt,pcDpa);
1643 }
else if (argc>=3) {
1646 }
else if (argc==4) {
1647 if (argv[3][0]==
'-') argv[3]++;
1648 if (argv[3][0]==
'-') argv[3]++;
1649 if (
strxcmp(isCas,argv[3],
"ALL",0,0,FALSE)==0) {
1651 }
else if (
strxcmp(isCas,argv[3],
"DEPTH1",0,0,FALSE)==0) {
1653 }
else if (
strxcmp(isCas,argv[3],
"DEPTH2",0,0,FALSE)==0) {
1655 }
else if (
strxcmp(isCas,argv[3],
"DEPTH3",0,0,FALSE)==0) {
1657 }
else if (
strxcmp(isCas,argv[3],
"DEPTH4",0,0,FALSE)==0) {
1659 }
else if (
strxcmp(isCas,argv[3],
"DEPTH5",0,0,FALSE)==0) {
1661 }
else if (
strxcmp(isCas,argv[3],
"DEPTH6",0,0,FALSE)==0) {
1663 }
else if (
strxcmp(isCas,argv[3],
"DEPTH7",0,0,FALSE)==0) {
1665 }
else if (
strxcmp(isCas,argv[3],
"DEPTH8",0,0,FALSE)==0) {
1667 }
else if (
strxcmp(isCas,argv[3],
"DEPTH9",0,0,FALSE)==0) {
1670 fprintf(pfErr,
"Syntax for built-in function 'SYNTAX' not valid\n");
1671 for (i=0;psCmd[i].
pcKyw!=NULL ;i++) {
1672 if (psCmd[i].siFlg) {
1673 fprintf(pfErr,
"%s %s SYNTAX %s",pcDep,argv[0],psCmd[i].pcKyw);
1674 efprintf(pfErr,
"[.path] [DEPTH1 | DEPTH2 | ... | DEPTH9 | ALL]\n");
1680 fprintf(pfErr,
"Syntax for built-in function 'SYNTAX' not valid\n");
1681 for (i=0;psCmd[i].
pcKyw!=NULL ;i++) {
1682 if (psCmd[i].siFlg) {
1683 fprintf(pfErr,
"%s %s SYNTAX %s",pcDep,argv[0],psCmd[i].pcKyw);
1684 efprintf(pfErr,
"[.path] [DEPTH1 | DEPTH2 | ... | DEPTH9 | ALL]\n");
1689 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
1690 if (
strxcmp(isCas,argv[2],psCmd[i].pcKyw,strlen(psCmd[i].pcKyw),
'.',TRUE)==0) {
1691 siErr=siCleCommandInit(pvGbl,psCmd[i].pfIni,psCmd[i].pvClp,pcOwn,pcPgm,pcBld,psCmd[i].pcKyw,psCmd[i].pcMan,psCmd[i].pcHlp,psCmd[i].piOid,psCmd[i].psTab,
1692 isCas,isPfl,isRpl,siMkl,pfOut,pfErr,pfTrc,pcDep,pcOpt,pcEnt,psCnf,&pvHdl,pfMsg,pvF2S,pfF2S,pvSaf,pfSaf);
1693 if (siErr)
ERROR(siErr,NULL);
1694 if (strlen(argv[2])==strlen(psCmd[i].pcKyw)) {
1695 fprintf(pfOut,
"Syntax for command '%s':\n",argv[2]);
1697 fprintf(pfOut,
"Syntax for argument '%s':\n",argv[2]);
1699 vdPrnCommandSyntax(pvHdl,pfOut,argv[0],argv[2],pcDep,siDep);
1703 if (pcDef!=NULL && *pcDef) {
1704 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
1705 if (
strxcmp(isCas,pcDef,psCmd[i].pcKyw,0,0,FALSE)==0) {
1706 char acPat[strlen(pcDef)+strlen(argv[2])+2];
1707 siErr=siCleCommandInit(pvGbl,psCmd[i].pfIni,psCmd[i].pvClp,pcOwn,pcPgm,pcBld,psCmd[i].pcKyw,psCmd[i].pcMan,psCmd[i].pcHlp,psCmd[i].piOid,psCmd[i].psTab,
1708 isCas,isPfl,isRpl,siMkl,pfOut,pfErr,pfTrc,pcDep,pcOpt,pcEnt,psCnf,&pvHdl,pfMsg,pvF2S,pfF2S,pvSaf,pfSaf);
1709 if (siErr)
ERROR(siErr,NULL);
1710 sprintf(acPat,
"%s.%s",pcDef,argv[2]);
1711 fprintf(pfOut,
"Syntax for argument '%s':\n",acPat);
1712 vdPrnCommandSyntax(pvHdl,pfOut,argv[0],acPat,pcDep,siDep);
1718 fprintf(pfErr,
"Syntax for built-in function 'SYNTAX' not valid\n");
1719 for (i=0;psCmd[i].
pcKyw!=NULL ;i++) {
1720 if (psCmd[i].siFlg) {
1721 fprintf(pfErr,
"%s %s SYNTAX %s\n",pcDep,argv[0],psCmd[i].pcKyw);
1722 efprintf(pfErr,
"[.path] [DEPTH1 | DEPTH2 | ... | DEPTH9 | ALL]\n");
1727 if (pfOut==NULL) pfOut=pfStd;
1728 if (pfErr==NULL) pfErr=pfStd;
1730 fprintf(pfOut,
"Help for program '%s':\n",pcPgm);
1731 vdPrnStaticHelp(pfOut,psCmd,asBif,argv[0],pcDep);
1733 }
else if (argc>=3) {
1735 if (
strxcmp(isCas,argv[2],
"MAN",0,0,FALSE)==0 ||
strxcmp(isCas,argv[2],
"-MAN",0,0,FALSE)==0 ||
strxcmp(isCas,argv[2],
"--MAN",0,0,FALSE)==0) {
1736 if (pcPgmMan!=NULL && *pcPgmMan) {
1737 fprintf(pfOut,
"Help for program '%s':\n",pcPgm);
1738 fprintm(pfOut,pcOwn,pcPgm,pcBld,pcPgmMan,1);
1741 fprintf(pfErr,
"No manual page available for program '%s'\n",pcPgm);
1742 fprintf(pfErr,
"CLE_DOCTYP_PROGRAM not found in documentation table\n");
1746 }
else if (argc==4) {
1747 if (argv[3][0]==
'-') argv[3]++;
1748 if (argv[3][0]==
'-') argv[3]++;
1749 if (
strxcmp(isCas,argv[3],
"MAN",0,0,FALSE)==0) {
1751 }
else if (
strxcmp(isCas,argv[3],
"DEPTH1",0,0,FALSE)==0) {
1753 }
else if (
strxcmp(isCas,argv[3],
"DEPTH2",0,0,FALSE)==0) {
1755 }
else if (
strxcmp(isCas,argv[3],
"DEPTH3",0,0,FALSE)==0) {
1757 }
else if (
strxcmp(isCas,argv[3],
"DEPTH4",0,0,FALSE)==0) {
1759 }
else if (
strxcmp(isCas,argv[3],
"DEPTH5",0,0,FALSE)==0) {
1761 }
else if (
strxcmp(isCas,argv[3],
"DEPTH6",0,0,FALSE)==0) {
1763 }
else if (
strxcmp(isCas,argv[3],
"DEPTH7",0,0,FALSE)==0) {
1765 }
else if (
strxcmp(isCas,argv[3],
"DEPTH8",0,0,FALSE)==0) {
1767 }
else if (
strxcmp(isCas,argv[3],
"DEPTH9",0,0,FALSE)==0) {
1769 }
else if (
strxcmp(isCas,argv[3],
"ALL",0,0,FALSE)==0) {
1772 fprintf(pfErr,
"Syntax for built-in function 'HELP' not valid\n");
1773 for (i=0;psCmd[i].
pcKyw!=NULL ;i++) {
1774 if (psCmd[i].siFlg) {
1775 fprintf(pfErr,
"%s %s HELP %s",pcDep,argv[0],psCmd[i].pcKyw);
1776 efprintf(pfErr,
"[.path] [DEPTH1 | DEPTH2 | ... | DEPTH9 | ALL] [MAN]\n");
1782 fprintf(pfErr,
"Syntax for built-in function 'HELP' not valid\n");
1783 for (i=0;psCmd[i].
pcKyw!=NULL ;i++) {
1784 if (psCmd[i].siFlg) {
1785 fprintf(pfErr,
"%s %s HELP %s",pcDep,argv[0],psCmd[i].pcKyw);
1786 efprintf(pfErr,
"[.path] [DEPTH1 | DEPTH2 | ... | DEPTH9 | ALL] [MAN]\n");
1791 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
1792 if (
strxcmp(isCas,argv[2],psCmd[i].pcKyw,strlen(psCmd[i].pcKyw),
'.',TRUE)==0) {
1793 siErr=siCleCommandInit(pvGbl,psCmd[i].pfIni,psCmd[i].pvClp,pcOwn,pcPgm,pcBld,psCmd[i].pcKyw,psCmd[i].pcMan,psCmd[i].pcHlp,psCmd[i].piOid,psCmd[i].psTab,
1794 isCas,isPfl,isRpl,siMkl,pfOut,pfErr,pfTrc,pcDep,pcOpt,pcEnt,psCnf,&pvHdl,pfMsg,pvF2S,pfF2S,pvSaf,pfSaf);
1795 if (siErr)
ERROR(siErr,NULL);
1796 if (strlen(argv[2])==strlen(psCmd[i].pcKyw)) {
1797 fprintf(pfOut,
"Help for command '%s': %s\n",argv[2],psCmd[i].pcHlp);
1799 fprintf(pfOut,
"Help for argument '%s': %s\n",argv[2],
pcClpInfo(pvHdl,argv[2]));
1801 vdPrnCommandHelp(pvHdl,argv[2],siDep,siDep>9,TRUE);
1803 fprintf(pfOut,
"ARGUMENTS\n");
1804 fprintf(pfOut,
"---------\n");
1805 vdPrnCommandHelp(pvHdl,argv[2],1,TRUE,FALSE);
1810 if (pcDef!=NULL && *pcDef) {
1811 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
1812 if (
strxcmp(isCas,pcDef,psCmd[i].pcKyw,0,0,FALSE)==0) {
1813 char acPat[strlen(psCmd[i].pcKyw)+strlen(argv[2])+2];
1814 siErr=siCleCommandInit(pvGbl,psCmd[i].pfIni,psCmd[i].pvClp,pcOwn,pcPgm,pcBld,psCmd[i].pcKyw,psCmd[i].pcMan,psCmd[i].pcHlp,psCmd[i].piOid,psCmd[i].psTab,
1815 isCas,isPfl,isRpl,siMkl,pfOut,pfErr,pfTrc,pcDep,pcOpt,pcEnt,psCnf,&pvHdl,pfMsg,pvF2S,pfF2S,pvSaf,pfSaf);
1816 if (siErr)
ERROR(siErr,NULL);
1817 sprintf(acPat,
"%s.%s",psCmd[i].pcKyw,argv[2]);
1818 fprintf(pfOut,
"Help for argument '%s': %s\n",acPat,
pcClpInfo(pvHdl,acPat));
1819 vdPrnCommandHelp(pvHdl,acPat,siDep,siDep>9,TRUE);
1821 fprintf(pfOut,
"ARGUMENTS\n");
1822 fprintf(pfOut,
"---------\n");
1823 vdPrnCommandHelp(pvHdl,acPat,1,TRUE,FALSE);
1830 fprintf(pfErr,
"Syntax for built-in function 'HELP' not valid\n");
1831 for (i=0;psCmd[i].
pcKyw!=NULL ;i++) {
1832 if (psCmd[i].siFlg) {
1833 fprintf(pfErr,
"%s %s HELP %s\n",pcDep,argv[0],psCmd[i].pcKyw);
1834 efprintf(pfErr,
"[.path] [DEPTH1 | DEPTH2 | ... | DEPTH9 | ALL] [MAN]\n");
1839 if (pfOut==NULL) pfOut=pfStd;
1840 if (pfErr==NULL) pfErr=pfStd;
1843 if (pcPgmMan!=NULL && *pcPgmMan) {
1844 fprintf(pfOut,
"Manual page for program '%s':\n\n",pcPgm);
1845 vdCleManProgram(pfOut,psCmd,asBif,pcOwn,pcPgm,pcBld,pcHlp,pcPgmMan,pcDep,pcOpt,pcDpa,pcPgmNum,FALSE,TRUE);
1848 fprintf(pfErr,
"No manual page available for program '%s'\n",pcPgm);
1849 fprintf(pfErr,
"CLE_DOCTYP_PROGRAM not found in documentation table\n");
1853 }
else if (argc==3) {
1858 pcSgn=strchr(argv[2],
'=');
1860 *((
char*)pcSgn)=EOS; pcSgn++; pcCmd=argv[2]; isMan=TRUE;
1863 fprintf(pfErr,
"Allocation of memory for file name (%s) failed\n",pcSgn);
1869 fprintf(pfErr,
"Open of manual page file (\"%s\",\"%s\") failed (%d - %s)\n",pcFil,
"w",errno,strerror(errno));
1876 srprintf(&pcFil,&szFil,0,
":STDOUT:");
1878 fprintf(pfErr,
"Allocation of memory for file name (:STDOUT:) failed\n");
1882 if (
strxcmp(isCas,pcCmd,
"ALL",0,0,FALSE)==0 ||
strxcmp(isCas,pcCmd,
"-ALL",0,0,FALSE)==0 ||
strxcmp(isCas,pcCmd,
"--ALL",0,0,FALSE)==0) {
1883 if (pcPgmMan!=NULL && *pcPgmMan) {
1885 if (isMan==FALSE) fprintf(pfOut,
"Manual page for program '%s':\n\n",pcPgm);
1886 vdCleManProgram(pfDoc,psCmd,asBif,pcOwn,pcPgm,pcBld,pcHlp,pcPgmMan,pcDep,pcOpt,pcDpa,pcPgmNum,isMan,TRUE);
1887 if (isMan==TRUE) fprintf(pfOut,
"Manual page for program '%s' successfully written to file (%s)\n",pcPgm,pcFil);
1889 fprintf(pfErr,
"No manual page available for program '%s'\n",pcPgm);
1890 fprintf(pfErr,
"CLE_DOCTYP_PROGRAM not found in documentation table\n");
1894 for (i=0;asBif[i].pcKyw!=NULL;i++) {
1895 if (asBif[i].isBif) {
1896 if (
strxcmp(isCas,pcCmd,asBif[i].pcKyw,0,0,FALSE)==0 || isAll) {
1898 if (isMan==FALSE) fprintf(pfOut,
"Manual page for built-in function '%s':\n\n",asBif[i].pcKyw);
1899 snprintf(acNum,
sizeof(acNum),
"%s%d.",pcBifNum,i+1);
1900 vdCleManFunction(pfDoc,0,
S_TLD,acNum,asBif[i].pcKyw,asBif[i].pcHlp,pcOwn,pcPgm,pcBld,asBif[i].pcSyn,asBif[i].pcMan,isMan,TRUE,TRUE,FALSE,FALSE);
1901 if (isMan==TRUE) fprintf(pfOut,
"Manual page for built-in function '%s' successfully written to file (%s)\n",asBif[i].pcKyw,pcFil);
1906 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
1908 if (psCmd[i].siFlg) {
1909 pcCmd=psCmd[i].
pcKyw;
1914 if (
strxcmp(isCas,pcCmd,psCmd[i].pcKyw,strlen(psCmd[i].pcKyw),
'.',TRUE)==0) {
1915 siErr=siCleCommandInit(pvGbl,psCmd[i].pfIni,psCmd[i].pvClp,pcOwn,pcPgm,pcBld,psCmd[i].pcKyw,psCmd[i].pcMan,psCmd[i].pcHlp,psCmd[i].piOid,psCmd[i].psTab,
1916 isCas,isPfl,isRpl,siMkl,pfOut,pfErr,pfTrc,pcDep,pcOpt,pcEnt,psCnf,&pvHdl,pfMsg,pvF2S,pfF2S,pvSaf,pfSaf);
1917 if (siErr)
ERROR(siErr,NULL);
1919 if (strlen(pcCmd)==strlen(psCmd[i].pcKyw)) {
1920 fprintf(pfOut,
"Manual page for command '%s':\n\n",pcCmd);
1922 fprintf(pfOut,
"Manual page for argument '%s':\n\n",pcCmd);
1925 vdPrnCommandManpage(pvHdl,pfDoc,pcCmdNum,pcCmd,i,isMan,TRUE);
1928 if (strlen(pcCmd)==strlen(psCmd[i].pcKyw)) {
1929 fprintf(pfOut,
"Manual page for command '%s' successfully written to file (%s)\n",pcCmd,pcFil);
1931 fprintf(pfOut,
"Manual page for argument '%s' successfully written to file (%s)\n",pcCmd,pcFil);
1939 if (pcDef!=NULL && *pcDef) {
1940 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
1941 if (
strxcmp(isCas,pcDef,psCmd[i].pcKyw,0,0,FALSE)==0) {
1942 char acPat[strlen(pcDef)+strlen(pcCmd)+2];
1943 siErr=siCleCommandInit(pvGbl,psCmd[i].pfIni,psCmd[i].pvClp,pcOwn,pcPgm,pcBld,psCmd[i].pcKyw,psCmd[i].pcMan,psCmd[i].pcHlp,psCmd[i].piOid,psCmd[i].psTab,
1944 isCas,isPfl,isRpl,siMkl,pfOut,pfErr,pfTrc,pcDep,pcOpt,pcEnt,psCnf,&pvHdl,pfMsg,pvF2S,pfF2S,pvSaf,pfSaf);
1945 if (siErr)
ERROR(siErr,NULL);
1946 sprintf(acPat,
"%s.%s",pcDef,pcCmd);
1947 if (pfOut!=NULL)fprintf(pfOut,
"Manual page fo'argument '%s':\n\n",acPat);
1948 vdPrnCommandManpage(pvHdl,pfDoc,pcCmdNum,acPat,i,isMan,TRUE);
1950 fprintf(pfOut,
"Manual page for argument '%s' successfully written to file (%s)\n",acPat,pcFil);
1960 fprintf(pfErr,
"Allocation of memory for file name (%s) failed\n",argv[2]);
1967 fprintf(pfErr,
"Open of manual page file (\"%s\",\"%s\") failed (%d - %s)\n",pcFil,
"w",errno,strerror(errno));
1970 if (pcPgmMan!=NULL && *pcPgmMan) {
1971 vdCleManProgram(pfDoc,psCmd,asBif,pcOwn,pcPgm,pcBld,pcHlp,pcPgmMan,pcDep,pcOpt,pcDpa,pcPgmNum,isMan,TRUE);
1972 if (pfOut!=NULL) fprintf(pfOut,
"Manual page for program '%s' successfully written to file (%s)\n",pcPgm,pcFil);
1975 fprintf(pfErr,
"No manual page available for program '%s'\n",pcPgm);
1976 fprintf(pfErr,
"CLE_DOCTYP_PROGRAM not found in documentation table\n");
1980 fprintf(pfErr,
"Syntax for built-in function 'MANPAGE' not valid\n");
1981 for (i=0;psCmd[i].
pcKyw!=NULL ;i++) {
1982 if (psCmd[i].siFlg) {
1983 fprintf(pfErr,
"%s %s MANPAGE %s",pcDep,argv[0],psCmd[i].pcKyw);
1987 fprintf(pfErr,
"%s %s MANPAGE function\n",pcDep,argv[0]);
1988 fprintf(pfErr,
"%s %s MANPAGE\n",pcDep,argv[0]);
1991 const char* pcCmd=NULL;
1992 const char* pcSgn=NULL;
1995 if (pfOut==NULL) pfOut=pfStd;
1996 if (pfErr==NULL) pfErr=pfStd;
1997 if (argc==3 || argc==4 || argc==5) {
1999 if (argv[3][0]==
'-') argv[3]++;
2000 if (argv[3][0]==
'-') argv[3]++;
2001 if (
strxcmp(isCas,argv[3],
"NONBR",0,0,FALSE)==0) {
2003 }
else if(
strxcmp(isCas,argv[3],
"SHORT",0,0,FALSE)==0) {
2006 fprintf(pfErr,
"Syntax for built-in function 'GENDOCU' not valid\n");
2007 for (i=0;psCmd[i].
pcKyw!=NULL ;i++) {
2008 if (psCmd[i].siFlg) {
2009 efprintf(pfErr,
"%s %s GENDOCU %s[.path]=filename [NONBR][SHORT]\n",pcDep,argv[0],psCmd[i].pcKyw);
2012 efprintf(pfErr,
"%s %s GENDOCU filename [NONBR][SHORT]\n",pcDep,argv[0]);
2015 }
else if (argc==5) {
2016 if (argv[3][0]==
'-') argv[3]++;
2017 if (argv[3][0]==
'-') argv[3]++;
2018 if (argv[4][0]==
'-') argv[4]++;
2019 if (argv[4][0]==
'-') argv[4]++;
2020 if (
strxcmp(isCas,argv[3],
"NONBR",0,0,FALSE)==0 &&
strxcmp(isCas,argv[4],
"SHORT",0,0,FALSE)==0) {
2023 }
else if(
strxcmp(isCas,argv[3],
"SHORT",0,0,FALSE)==0 &&
strxcmp(isCas,argv[4],
"NONBR",0,0,FALSE)==0) {
2027 fprintf(pfErr,
"Syntax for built-in function 'GENDOCU' not valid\n");
2028 for (i=0;psCmd[i].
pcKyw!=NULL ;i++) {
2029 if (psCmd[i].siFlg) {
2030 efprintf(pfErr,
"%s %s GENDOCU %s[.path]=filename [NONBR][SHORT]\n",pcDep,argv[0],psCmd[i].pcKyw);
2033 efprintf(pfErr,
"%s %s GENDOCU filename [NONBR][SHORT]\n",pcDep,argv[0]);
2037 pcSgn=strchr(argv[2],
'=');
2039 *((
char*)pcSgn)=EOS; pcSgn++; pcCmd=argv[2];
2041 pcSgn=argv[2]; pcCmd=NULL;
2045 fprintf(pfErr,
"Allocation of memory for file name (%s) failed\n",pcSgn);
2048 szFil=strlen(pcFil)+1;
2051 fprintf(pfErr,
"Open of documentation file (\"%s\",\"%s\") failed (%d - %s)\n",pcFil,
"w",errno,strerror(errno));
2055 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
2056 if (
strxcmp(isCas,pcCmd,psCmd[i].pcKyw,strlen(psCmd[i].pcKyw),
'.',TRUE)==0) {
2058 siErr=siCleCommandInit(pvGbl,psCmd[i].pfIni,psCmd[i].pvClp,pcOwn,pcPgm,pcBld,psCmd[i].pcKyw,psCmd[i].pcMan,psCmd[i].pcHlp,psCmd[i].piOid,psCmd[i].psTab,
2059 isCas,isPfl,isRpl,siMkl,pfOut,pfErr,pfTrc,pcDep,pcOpt,pcEnt,psCnf,&pvHdl,pfMsg,pvF2S,pfF2S,pvSaf,pfSaf);
2060 if (siErr)
ERROR(siErr,NULL);
2061 snprintf(acNum,
sizeof(acNum),
"%s%d.",pcCmdNum,i+1);
2062 siErr=
siClpDocu(pvHdl,pfDoc,pcCmd,acNum,
"Command",TRUE,TRUE,FALSE,FALSE,isNbr,FALSE,TRUE,0);
2064 fprintf(pfErr,
"Creation of documentation file (%s) failed (%d - %s)\n",pcFil,errno,strerror(errno));
2067 if (strlen(pcCmd)==strlen(psCmd[i].pcKyw)) {
2068 fprintf(pfOut,
"Documentation for command '%s' successfully created\n",pcCmd);
2070 fprintf(pfOut,
"Documentation for argument '%s' successfully created\n",pcCmd);
2076 if (pcDef!=NULL && *pcDef) {
2077 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
2078 if (
strxcmp(isCas,pcDef,psCmd[i].pcKyw,0,0,FALSE)==0) {
2080 char acPat[strlen(pcDef)+strlen(pcCmd)+2];
2081 siErr=siCleCommandInit(pvGbl,psCmd[i].pfIni,psCmd[i].pvClp,pcOwn,pcPgm,pcBld,psCmd[i].pcKyw,psCmd[i].pcMan,psCmd[i].pcHlp,psCmd[i].piOid,psCmd[i].psTab,
2082 isCas,isPfl,isRpl,siMkl,pfOut,pfErr,pfTrc,pcDep,pcOpt,pcEnt,psCnf,&pvHdl,pfMsg,pvF2S,pfF2S,pvSaf,pfSaf);
2083 if (siErr)
ERROR(siErr,NULL);
2084 snprintf(acNum,
sizeof(acNum),
"%s%d.",pcCmdNum,i+1);
2085 sprintf(acPat,
"%s.%s",pcDef,pcCmd);
2086 siErr=
siClpDocu(pvHdl,pfDoc,acPat,acNum,
"Command",TRUE,TRUE,FALSE,FALSE,isNbr,FALSE,TRUE,0);
2088 fprintf(pfErr,
"Creation of documentation file (%s) failed (%d - %s)\n",pcFil,errno,strerror(errno));
2091 fprintf(pfOut,
"Documentation for argument '%s' successfully created\n",acPat);
2099 stDocPar.isHdr=TRUE; stDocPar.pcAut=pcAut; stDocPar.pcAdr=pcAdr;
2100 stDocPar.isAnc=TRUE; stDocPar.isNbr=isNbr; stDocPar.isIdt=FALSE; stDocPar.isPat=TRUE;
2101 stDocPar.isDep=isDep; stDocPar.isCas=isCas; stDocPar.isPfl=isPfl; stDocPar.isRpl=isRpl;
2102 stDocPar.pcAbo=pcAbo; stDocPar.pcDep=pcDep; stDocPar.pcDpa=pcDpa; stDocPar.pcEnt=pcEnt;
2103 stDocPar.pcHlp=pcHlp; stDocPar.pcOpt=pcOpt; stDocPar.pcOwn=pcOwn; stDocPar.pcPgm=pcPgm;
2104 stDocPar.pcBld=pcBld; stDocPar.pcVsn=pcVsn; stDocPar.pfMsg=pfMsg; stDocPar.pvCnf=psCnf;
2105 stDocPar.siMkl=siMkl; stDocPar.psBif=asBif; stDocPar.psCmd=psCmd; stDocPar.psOth=psOth;
2106 stDocPar.pvF2S=pvF2S; stDocPar.pfF2S=pfF2S; stDocPar.pvSaf=pvSaf; stDocPar.pfSaf=pfSaf;
2107 stDocPar.siPs1=
'/'; stDocPar.siPs2=
'-'; stDocPar.siPr3=
'_'; stDocPar.isShl=FALSE;
2108 siErr=siPrintDocu(pvGbl,pfOut,pfErr,psDoc,&stDocPar,pfDoc,siPrintPage);
2110 fprintf(pfErr,
"Generation of documentation for program '%s' failed\n",pcPgm);
2113 fprintf(pfOut,
"Documentation for program '%s' successfully created\n",pcPgm);
2118 fprintf(pfErr,
"Syntax for built-in function 'GENDOCU' not valid\n");
2119 for (i=0;psCmd[i].
pcKyw!=NULL ;i++) {
2120 if (psCmd[i].siFlg) {
2121 fprintf(pfErr,
"%s %s GENDOCU %s",pcDep,argv[0],psCmd[i].pcKyw);
2122 efprintf(pfErr,
"[.path]=filename [NONBR][SHORT]\n");
2125 efprintf(pfErr,
"%s %s GENDOCU filename [NONBR][SHORT]\n",pcDep,argv[0]);
2129 const char* pcPar=
".";
2133 if (pfOut==NULL) pfOut=pfStd;
2134 if (pfErr==NULL) pfErr=pfStd;
2136 fprintf(pfErr,
"Syntax for built-in function 'HTMLDOC' not valid (too many arguments)\n");
2137 efprintf(pfErr,
"%s %s %s\n",pcDep,argv[0],SYN_CLE_BUILTIN_HTMLDOC);
2140 for (i=2;i<argc;i++) {
2141 if (argv[i][0]==
'-') argv[i]++;
2142 if (argv[i][0]==
'-') argv[i]++;
2143 if (
strxcmp(isCas,argv[i],
"NUMBERS",0,0,FALSE)==0) {
2145 }
else if (
strxcmp(isCas,argv[i],
"TYPES",0,0,FALSE)==0) {
2147 }
else if (
strxcmp(isCas,argv[i],
"SHORT",0,0,FALSE)==0) {
2151 fprintf(pfErr,
"Syntax for built-in function 'HTMLDOC' not valid (more than one path)\n");
2152 efprintf(pfErr,
"%s %s %s\n",pcDep,argv[0],SYN_CLE_BUILTIN_HTMLDOC);
2164 fprintf(pfErr,
"Allocation of memory for path name (%s) failed\n",pcHlp);
2167 void* pvLib=pfLoadHtmlDoc(&pfHtmlOpn,&pfHtmlPrn,&pfHtmlCls);
2169 fprintf(pfErr,
"There is no service provider DLL/SO (libhtmldoc) available for HTML generation\n");
2173 stDocPar.isHdr=TRUE; stDocPar.pcAut=pcAut; stDocPar.pcAdr=pcAdr;
2174 stDocPar.isAnc=TRUE; stDocPar.isNbr=isNbr; stDocPar.isIdt=TRUE; stDocPar.isPat=FALSE;
2175 stDocPar.isDep=isDep; stDocPar.isCas=isCas; stDocPar.isPfl=isPfl; stDocPar.isRpl=isRpl;
2176 stDocPar.pcAbo=pcAbo; stDocPar.pcDep=pcDep; stDocPar.pcDpa=pcDpa; stDocPar.pcEnt=pcEnt;
2177 stDocPar.pcHlp=pcHlp; stDocPar.pcOpt=pcOpt; stDocPar.pcOwn=pcOwn; stDocPar.pcPgm=pcPgm;
2178 stDocPar.pcBld=pcBld; stDocPar.pcVsn=pcVsn; stDocPar.pfMsg=pfMsg; stDocPar.pvCnf=psCnf;
2179 stDocPar.siMkl=siMkl; stDocPar.psBif=asBif; stDocPar.psCmd=psCmd; stDocPar.psOth=psOth;
2180 stDocPar.pvF2S=pvF2S; stDocPar.pfF2S=pfF2S; stDocPar.pvSaf=pvSaf; stDocPar.pfSaf=pfSaf;
2181 stDocPar.siPs1=
'-'; stDocPar.siPs2=
'-'; stDocPar.siPr3=
'_'; stDocPar.isShl=isShl;
2182 if (pfHtmlOpn!=NULL && pfHtmlPrn!=NULL && pfHtmlCls!=NULL) {
2183 void* pvDocHdl=pfHtmlOpn(pfOut,pfErr,pcPat,pcOwn,pcPgm,pcBld,&stDocPar.isHdr,&stDocPar.isAnc,&stDocPar.isIdt,&stDocPar.isPat,&stDocPar.siPs1,&stDocPar.siPs2,&stDocPar.siPr3);
2184 if (pvDocHdl==NULL) {
2185 fprintf(pfErr,
"Open service provider for HTML generation failed\n");
2188 siErr=siPrintDocu(pvGbl,pfOut,pfErr,psDoc,&stDocPar,pvDocHdl,pfHtmlPrn);
2190 fprintf(pfErr,
"Generation of %s HTML documentation to folder '%s' failed\n",isDep?
"long":
"short",pcPat);
2191 pfHtmlCls(pvDocHdl);
2194 siErr=pfHtmlCls(pvDocHdl);
2196 fprintf(pfErr,
"Finalise generation of HTML documentation to folder '%s' failed (%d)\n",pcPat,siErr);
2199 fprintf(pfErr,
"Generation of %s HTML documentation to folder '%s' was successful\n",isDep?
"long":
"short",pcPat);
2203 vdFreeHtmlDoc(&pvLib);
2204 fprintf(pfErr,
"There is no service provider function (opnHtmlDoc, prnHtmlDoc or clsHtmlDoc) available for HTML generation\n");
2208 if (pfOut==NULL) pfOut=pfStd;
2209 if (pfErr==NULL) pfErr=pfStd;
2213 pcSgn=strchr(argv[2],
'=');
2215 *((
char*)pcSgn)=EOS; pcSgn++; pcCmd=argv[2];
2217 pcSgn=argv[2]; pcCmd=NULL;
2221 fprintf(pfErr,
"Allocation of memory for file name (%s) failed\n",pcSgn);
2224 szFil=strlen(pcFil)+1;
2227 fprintf(pfErr,
"Open of property file (\"%s\",\"%s\") failed (%d-%s)\n",pcFil,
"w",errno,strerror(errno));
2230 if (pcCmd==NULL) fprintf(pfPro,
"\n%c Property file for: %s.%s %c\n\n",
C_HSH,pcOwn,pcPgm,
C_HSH);
2231 else fprintf(pfPro,
"\n%c Property file for: %s.%s.%s %c\n\n",
C_HSH,pcOwn,pcPgm,pcCmd,
C_HSH);
2232 efprintf(pfPro,
"%s",HLP_CLE_PROPFIL);
2236 siErr=siClePropertyInit(pvGbl,psCmd[i].pfIni,psCmd[i].pvClp,pcOwn,pcPgm,pcBld,psCmd[i].pcKyw,psCmd[i].pcMan,psCmd[i].pcHlp,
2237 psCmd[i].piOid,psCmd[i].psTab,isCas,isPfl,isRpl,siMkl,pfOut,pfErr,pfTrc,pcDep,pcOpt,pcEnt,psCnf,&pvHdl,NULL,NULL,pfMsg,pvF2S,pfF2S,pvSaf,pfSaf);
2238 if (siErr)
ERROR(siErr,NULL);
2243 fprintf(pfErr,
"Write property file (%s) for program '%s' failed (%d-%s)\n",pcFil,pcPgm,errno,strerror(errno));
2246 fprintf(pfOut,
"Property file (%s) for program '%s' successfully written\n",pcFil,pcPgm);
2250 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
2251 if (
strxcmp(isCas,pcCmd,psCmd[i].pcKyw,0,0,FALSE)==0) {
2252 siErr=siClePropertyInit(pvGbl,psCmd[i].pfIni,psCmd[i].pvClp,pcOwn,pcPgm,pcBld,psCmd[i].pcKyw,psCmd[i].pcMan,psCmd[i].pcHlp,
2253 psCmd[i].piOid,psCmd[i].psTab,isCas,isPfl,isRpl,siMkl,pfOut,pfErr,pfTrc,pcDep,pcOpt,pcEnt,psCnf,&pvHdl,NULL,NULL,pfMsg,pvF2S,pfF2S,pvSaf,pfSaf);
2254 if (siErr)
ERROR(siErr,NULL);
2258 fprintf(pfErr,
"Write property file (%s) for command '%s' failed (%d-%s)\n",pcFil,pcCmd,errno,strerror(errno));
2261 fprintf(pfOut,
"Property file (%s) for command '%s' successfully written\n",pcFil,pcCmd);
2268 fprintf(pfErr,
"Syntax for built-in function 'GENPROP' not valid\n");
2269 for (i=0;psCmd[i].
pcKyw!=NULL ;i++) {
2270 if (psCmd[i].siFlg) {
2271 fprintf(pfErr,
"%s %s GENPROP %s=filename\n",pcDep,argv[0],psCmd[i].pcKyw);
2274 fprintf(pfErr,
"%s %s GENPROP filename\n",pcDep,argv[0]);
2277 if (pfOut==NULL) pfOut=pfStd;
2278 if (pfErr==NULL) pfErr=pfStd;
2282 pcSgn=strchr(argv[2],
'=');
2284 *((
char*)pcSgn)=EOS; pcSgn++; pcCmd=argv[2];
2285 for (i=0;psCmd[i].
pcKyw!=NULL &&
strxcmp(isCas,pcCmd,psCmd[i].pcKyw,0,0,FALSE);i++);
2286 if (psCmd[i].pcKyw==NULL) {
2287 fprintf(pfErr,
"Syntax for built-in function 'SETPROP' not valid\n");
2288 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
2289 if (psCmd[i].siFlg) {
2290 fprintf(pfErr,
"%s %s SETPROP %s=filename\n",pcDep,argv[0],psCmd[i].pcKyw);
2295 srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgm)+strlen(pcCmd),
"%s.%s.%s.property.file",pcOwn,pcPgm,pcCmd);
2297 fprintf(pfErr,
"Allocation of memory for property string failed\n");
2301 pcSgn=argv[2]; pcCmd=NULL;
2302 srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgm),
"%s.%s.property.file",pcOwn,pcPgm);
2304 fprintf(pfErr,
"Allocation of memory for property string failed\n");
2309 fprintf(pfErr,
"Syntax for built-in function 'SETPROP' not valid\n");
2310 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
2311 if (psCmd[i].siFlg) {
2312 fprintf(pfErr,
"%s %s SETPROP %s=filename\n",pcDep,argv[0],psCmd[i].pcKyw);
2315 fprintf(pfErr,
"File name was not specified.\n"
2316 "To delete a property file from the list, please use the function DELPROP %ccommand%c\n",
C_SBO,
C_SBC);
2319 siErr=siCnfSet(psCnf,pfOut,pcCnf,pcSgn,TRUE);
2321 fprintf(pfOut,
"Setting configuration keyword '%s' to value '%s' was successful\n",pcCnf,pcSgn);
2325 fprintf(pfErr,
"Syntax for built-in function 'SETPROP' not valid\n");
2326 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
2327 if (psCmd[i].siFlg) {
2328 fprintf(pfErr,
"%s %s SETPROP %s=filename\n",pcDep,argv[0],psCmd[i].pcKyw);
2331 fprintf(pfErr,
"%s %s SETPROP filename\n",pcDep,argv[0]);
2333 }
else if ((asBif[
CLE_BUILTIN_IDX_CHGPROP].isBif &&
strxcmp(isCas,argv[1],
"CHGPROP",0,0,FALSE)==0) || (pcDef!=NULL &&
strxcmp(isCas,pcDef,
"flam",0,0,FALSE)==0 &&
strxcmp(isCas,argv[1],
"DEFAULTS",0,0,FALSE)==0)) {
2334 if (pfOut==NULL) pfOut=pfStd;
2335 if (pfErr==NULL) pfErr=pfStd;
2337 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
2338 if (
strxcmp(isCas,argv[2],psCmd[i].pcKyw,0,0,FALSE)==0) {
2340 char* pcPro=(
char*)calloc(1,szPro);
2342 fprintf(pfErr,
"Memory allocation for property list failed\n");
2345 for (j=3;j<argc;j++) {
2347 srprintc(&pcPro,&szPro,strlen(pcOwn)+strlen(pcPgm)+strlen(psCmd[i].pcKyw),
" %s.%s.%s.",pcOwn,pcPgm,psCmd[i].pcKyw);
2349 srprintc(&pcPro,&szPro,strlen(pcOwn)+strlen(pcPgm)+strlen(psCmd[i].pcKyw),
"%s.%s.%s.",pcOwn,pcPgm,psCmd[i].pcKyw);
2351 char* pcSgn=strchr(argv[j],
'=');
2353 *pcSgn=0x00; pcSgn++;
2354 srprintc(&pcPro,&szPro,strlen(argv[j])+strlen(pcSgn),
"%s=\"%s\"",argv[j],pcSgn);
2356 srprintc(&pcPro,&szPro,strlen(argv[j]),
"%s=\"\"",argv[j]);
2359 siErr=siCleChangeProperties(pvGbl,psCmd[i].pfIni,psCmd[i].pvClp,pcHom,pcOwn,pcPgm,pcBld,psCmd[i].pcKyw,psCmd[i].pcMan,psCmd[i].pcHlp,pcPro,
2360 psCmd[i].piOid,psCmd[i].psTab,isCas,isPfl,isRpl,siMkl,pfOut,pfErr,pfTrc,pcDep,pcOpt,pcEnt,psCnf,pfMsg,pvF2S,pfF2S,pvSaf,pfSaf);
2365 if (pcDef!=NULL && *pcDef) {
2366 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
2367 if (
strxcmp(isCas,pcDef,psCmd[i].pcKyw,0,0,FALSE)==0) {
2369 char* pcPro=calloc(1,szPro);
2371 fprintf(pfErr,
"Memory allocation for property list failed\n");
2374 for (j=2;j<argc;j++) {
2376 srprintc(&pcPro,&szPro,strlen(pcOwn)+strlen(pcPgm)+strlen(psCmd[i].pcKyw),
" %s.%s.%s.",pcOwn,pcPgm,psCmd[i].pcKyw);
2378 srprintc(&pcPro,&szPro,strlen(pcOwn)+strlen(pcPgm)+strlen(psCmd[i].pcKyw),
"%s.%s.%s.",pcOwn,pcPgm,psCmd[i].pcKyw);
2380 char* pcSgn=strchr(argv[j],
'=');
2382 *pcSgn=0x00; pcSgn++;
2383 srprintc(&pcPro,&szPro,strlen(argv[j])+strlen(pcSgn),
"%s=\"%s\"",argv[j],pcSgn);
2385 srprintc(&pcPro,&szPro,strlen(argv[j]),
"%s=\"\"",argv[j]);
2388 siErr=siCleChangeProperties(pvGbl,psCmd[i].pfIni,psCmd[i].pvClp,pcHom,pcOwn,pcPgm,pcBld,psCmd[i].pcKyw,psCmd[i].pcMan,psCmd[i].pcHlp,pcPro,
2389 psCmd[i].piOid,psCmd[i].psTab,isCas,isPfl,isRpl,siMkl,pfOut,pfErr,pfTrc,pcDep,pcOpt,pcEnt,psCnf,pfMsg,pvF2S,pfF2S,pvSaf,pfSaf);
2394 fprintf(pfErr,
"Syntax for built-in function 'CHGPROP' not valid\n");
2395 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
2396 if (psCmd[i].siFlg) {
2397 fprintf(pfErr,
"%s %s CHGPROP %s",pcDep,argv[0],psCmd[i].pcKyw);
2398 efprintf(pfErr,
" [path[=value]]*\n");
2403 if (pfOut==NULL) pfOut=pfStd;
2404 if (pfErr==NULL) pfErr=pfStd;
2406 srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgm),
"%s.%s.property.file",pcOwn,pcPgm);
2408 fprintf(pfErr,
"Allocation of memory for property string failed\n");
2411 }
else if (argc==3) {
2412 for (i=0;psCmd[i].
pcKyw!=NULL &&
strxcmp(isCas,argv[2],psCmd[i].pcKyw,0,0,FALSE);i++);
2413 if (psCmd[i].pcKyw==NULL) {
2414 fprintf(pfErr,
"Syntax for built-in function 'DELPROP' not valid\n");
2415 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
2416 if (psCmd[i].siFlg) {
2417 fprintf(pfErr,
"%s %s DELPROP %s\n",pcDep,argv[0],psCmd[i].pcKyw);
2422 srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgm)+strlen(argv[2]),
"%s.%s.%s.property.file",pcOwn,pcPgm,argv[2]);
2424 fprintf(pfErr,
"Allocation of memory for property string failed\n");
2428 fprintf(pfErr,
"Syntax for built-in function 'DELPROP' not valid\n");
2429 for (i=0;psCmd[i].
pcKyw!=NULL ;i++) {
2430 if (psCmd[i].siFlg) {
2431 fprintf(pfErr,
"%s %s DELPROP %s\n",pcDep,argv[0],psCmd[i].pcKyw);
2434 fprintf(pfErr,
"%s %s DELPROP\n",pcDep,argv[0]);
2437 siErr=siCnfSet(psCnf,pfOut,pcCnf,
"",TRUE);
2439 fprintf(pfOut,
"Delete configuration keyword '%s' was successful\n",pcCnf);
2442 }
else if ((asBif[
CLE_BUILTIN_IDX_GETPROP].isBif &&
strxcmp(isCas,argv[1],
"GETPROP",0,0,FALSE)==0) || (pcDef!=NULL &&
strxcmp(isCas,pcDef,
"flam",0,0,FALSE)==0 &&
strxcmp(isCas,argv[1],
"LIST",0,0,FALSE)==0)) {
2443 if (pfOut==NULL) pfOut=pfStd;
2444 if (pfErr==NULL) pfErr=pfStd;
2446 fprintf(pfOut,
"Properties for program '%s':\n",pcPgm);
2447 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
2448 siErr=siClePropertyInit(pvGbl,psCmd[i].pfIni,psCmd[i].pvClp,pcOwn,pcPgm,pcBld,psCmd[i].pcKyw,psCmd[i].pcMan,psCmd[i].pcHlp,
2449 psCmd[i].piOid,psCmd[i].psTab,isCas,isPfl,isRpl,siMkl,pfOut,pfErr,pfTrc,pcDep,pcOpt,pcEnt,psCnf,
2450 &pvHdl,NULL,NULL,pfMsg,pvF2S,pfF2S,pvSaf,pfSaf);
2451 if (siErr)
ERROR(siErr,NULL);
2452 vdPrnProperties(pvHdl,psCmd[i].pcKyw,10);
2456 }
else if (argc>=3) {
2459 }
else if (argc==4) {
2460 if (argv[3][0]==
'-') argv[3]++;
2461 if (argv[3][0]==
'-') argv[3]++;
2462 if (
strxcmp(isCas,argv[3],
"DEFALL",0,0,FALSE)==0) {
2464 }
else if (
strxcmp(isCas,argv[3],
"DEPALL",0,0,FALSE)==0) {
2466 }
else if (
strxcmp(isCas,argv[3],
"DEPTH1",0,0,FALSE)==0) {
2468 }
else if (
strxcmp(isCas,argv[3],
"DEPTH2",0,0,FALSE)==0) {
2470 }
else if (
strxcmp(isCas,argv[3],
"DEPTH3",0,0,FALSE)==0) {
2472 }
else if (
strxcmp(isCas,argv[3],
"DEPTH4",0,0,FALSE)==0) {
2474 }
else if (
strxcmp(isCas,argv[3],
"DEPTH5",0,0,FALSE)==0) {
2476 }
else if (
strxcmp(isCas,argv[3],
"DEPTH6",0,0,FALSE)==0) {
2478 }
else if (
strxcmp(isCas,argv[3],
"DEPTH7",0,0,FALSE)==0) {
2480 }
else if (
strxcmp(isCas,argv[3],
"DEPTH8",0,0,FALSE)==0) {
2482 }
else if (
strxcmp(isCas,argv[3],
"DEPTH9",0,0,FALSE)==0) {
2485 fprintf(pfErr,
"Syntax for built-in function 'GETPROP' not valid\n");
2486 for (i=0;psCmd[i].
pcKyw!=NULL ;i++) {
2487 if (psCmd[i].siFlg) {
2488 fprintf(pfErr,
"%s %s GETPROP %s",pcDep,argv[0],psCmd[i].pcKyw);
2489 efprintf(pfErr,
"[.path] [DEPTH1 | DEPTH2 | ... | DEPTH9 | DEPALL | DEFALL]\n");
2495 fprintf(pfErr,
"Syntax for built-in function 'GETPROP' not valid\n");
2496 for (i=0;psCmd[i].
pcKyw!=NULL ;i++) {
2497 if (psCmd[i].siFlg) {
2498 fprintf(pfErr,
"%s %s GETPROP %s",pcDep,argv[0],psCmd[i].pcKyw);
2499 efprintf(pfErr,
"[.path] [DEPTH1 | DEPTH2 | ... | DEPTH9 | DEPALL | DEFALL]\n");
2504 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
2505 if (
strxcmp(isCas,argv[2],psCmd[i].pcKyw,strlen(psCmd[i].pcKyw),
'.',TRUE)==0) {
2506 siErr=siClePropertyInit(pvGbl,psCmd[i].pfIni,psCmd[i].pvClp,pcOwn,pcPgm,pcBld,psCmd[i].pcKyw,psCmd[i].pcMan,psCmd[i].pcHlp,
2507 psCmd[i].piOid,psCmd[i].psTab,isCas,isPfl,isRpl,siMkl,pfOut,pfErr,pfTrc,pcDep,pcOpt,pcEnt,
2508 psCnf,&pvHdl,NULL,NULL,pfMsg,pvF2S,pfF2S,pvSaf,pfSaf);
2509 if (siErr)
ERROR(siErr,NULL);
2510 if (strlen(argv[2])==strlen(psCmd[i].pcKyw)) {
2511 fprintf(pfOut,
"Properties for command '%s':\n",argv[2]);
2513 fprintf(pfOut,
"Properties for argument '%s':\n",argv[2]);
2515 vdPrnProperties(pvHdl,argv[2],siDep);
2519 if (pcDef!=NULL && *pcDef) {
2520 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
2521 if (
strxcmp(isCas,pcDef,psCmd[i].pcKyw,0,0,FALSE)==0) {
2522 char acPat[strlen(pcDef)+strlen(argv[2])+2];
2523 siErr=siClePropertyInit(pvGbl,psCmd[i].pfIni,psCmd[i].pvClp,pcOwn,pcPgm,pcBld,psCmd[i].pcKyw,psCmd[i].pcMan,psCmd[i].pcHlp,
2524 psCmd[i].piOid,psCmd[i].psTab,isCas,isPfl,isRpl,siMkl,pfOut,pfErr,pfTrc,pcDep,pcOpt,pcEnt,
2525 psCnf,&pvHdl,NULL,NULL,pfMsg,pvF2S,pfF2S,pvSaf,pfSaf);
2526 if (siErr)
ERROR(siErr,NULL);
2527 sprintf(acPat,
"%s.%s",pcDef,argv[2]);
2528 fprintf(pfOut,
"Properties for argument '%s':\n",acPat);
2529 vdPrnProperties(pvHdl,acPat,siDep);
2535 fprintf(pfErr,
"Syntax for built-in function 'GETPROP' not valid\n");
2536 for (i=0;psCmd[i].
pcKyw!=NULL ;i++) {
2537 if (psCmd[i].siFlg) {
2538 fprintf(pfErr,
"%s %s GETPROP %s",pcDep,argv[0],psCmd[i].pcKyw);
2539 efprintf(pfErr,
"[.path] [DEPTH1 | DEPTH2 | ... | DEPTH9 | DEPALL | DEFALL]\n");
2542 fprintf(pfErr,
"%s %s GETPROP\n",pcDep,argv[0]);
2545 if (pfOut==NULL) pfOut=pfStd;
2546 if (pfErr==NULL) pfErr=pfStd;
2548 srprintf(&pcCnf,&szCnf,strlen(pcPgm),
"%s.owner.id",pcPgm);
2550 fprintf(pfErr,
"Allocation of memory for owner string failed\n");
2553 siErr=siCnfSet(psCnf,pfOut,pcCnf,argv[2],TRUE);
2555 fprintf(pfOut,
"Setting configuration key word '%s' to value '%s' was successful\n",pcCnf,argv[2]);
2559 fprintf(pfErr,
"Syntax for built-in function 'SETOWNER' not valid\n");
2560 fprintf(pfErr,
"%s %s SETOWNER name\n",pcDep,argv[0]);
2563 if (pfOut==NULL) pfOut=pfStd;
2564 if (pfErr==NULL) pfErr=pfStd;
2566 fprintf(pfOut,
"Current owner id for '%s' is: %s\n",argv[0],pcOwn);
2569 fprintf(pfErr,
"Syntax for built-in function 'GETOWNER' not valid\n");
2570 fprintf(pfErr,
"%s %s GETOWNER\n",pcDep,argv[0]);
2573 if (pfOut==NULL) pfOut=pfStd;
2574 if (pfErr==NULL) pfErr=pfStd;
2577 const char* pcEnv=
"";
2578 pcVal=strchr(argv[2],
'=');
2580 *((
char*)pcVal)=EOS; pcVal++; pcEnv=argv[2];
2582 fprintf(pfErr,
"Syntax for built-in function 'SETENV' not valid\n");
2583 fprintf(pfErr,
"%s %s SETENV variable=value\n",pcDep,argv[0]);
2586 srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgm)+strlen(pcEnv),
"%s.%s.envar.%s",pcOwn,pcPgm,pcEnv);
2588 fprintf(pfErr,
"Allocation of memory for envar string failed\n");
2591 siErr=siCnfSet(psCnf,pfOut,pcCnf,pcVal,TRUE);
2593 fprintf(pfOut,
"Setting environment variable '%s' to value '%s' was successful\n",pcCnf,pcVal);
2597 fprintf(pfErr,
"Syntax for built-in function 'SETENV' not valid\n");
2598 fprintf(pfErr,
"%s %s SETENV variable=value\n",pcDep,argv[0]);
2601 if (pfOut==NULL) pfOut=pfStd;
2602 if (pfErr==NULL) pfErr=pfStd;
2604 fprintf(pfOut,
"Current environment variables for owner '%s':\n",pcOwn);
2605 siCnt=siCnfPrnEnv(psCnf,pfOut,pcDep,pcOwn,pcPgm);
2607 fprintf(pfOut,
"Defined in file \"%s\"\n",psCnf->pcFil);
2609 fprintf(pfOut,
"No environment variables defined in file \"%s\" for owner '%s'\n",psCnf->pcFil,pcOwn);
2613 fprintf(pfErr,
"Syntax for built-in function 'GETENV' not valid\n");
2614 fprintf(pfErr,
"%s %s GETENV\n",pcDep,argv[0]);
2617 if (pfOut==NULL) pfOut=pfStd;
2618 if (pfErr==NULL) pfErr=pfStd;
2620 srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgm)+strlen(argv[2]),
"%s.%s.envar.%s",pcOwn,pcPgm,argv[2]);
2622 fprintf(pfErr,
"Allocation of memory for envar string failed\n");
2625 siErr=siCnfSet(psCnf,pfOut,pcCnf,
"",TRUE);
2627 fprintf(pfOut,
"Deleting the environment variable '%s' was successful\n",pcCnf);
2631 fprintf(pfErr,
"Syntax for built-in function 'DELENV' not valid\n");
2632 fprintf(pfErr,
"%s %s DELENV variable\n",pcDep,argv[0]);
2635 if (pfOut==NULL) pfOut=pfStd;
2636 if (pfErr==NULL) pfErr=pfStd;
2638 if (
strxcmp(isCas,argv[2],
"ON",0,0,FALSE)==0 ||
strxcmp(isCas,argv[2],
"-ON",0,0,FALSE)==0 ||
strxcmp(isCas,argv[2],
"--ON",0,0,FALSE)==0) {
2639 srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgm),
"%s.%s.trace",pcOwn,pcPgm);
2641 fprintf(pfErr,
"Allocation of memory for envar string failed\n");
2644 siErr=siCnfSet(psCnf,pfOut,pcCnf,
"ON",TRUE);
2646 fprintf(pfOut,
"Setting configuration keyword '%s' to value 'ON' was successful\n",pcCnf);
2649 }
else if (
strxcmp(isCas,argv[2],
"OFF",0,0,FALSE)==0 ||
strxcmp(isCas,argv[2],
"-OFF",0,0,FALSE)==0 ||
strxcmp(isCas,argv[2],
"--OFF",0,0,FALSE)==0) {
2650 srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgm),
"%s.%s.trace",pcOwn,pcPgm);
2652 fprintf(pfErr,
"Allocation of memory for envar string failed\n");
2655 siErr=siCnfSet(psCnf,pfOut,pcCnf,
"OFF",TRUE);
2657 fprintf(pfOut,
"Setting configuration keyword '%s' to value 'OFF' was successful\n",pcCnf);
2662 pcSgn=strchr(argv[2],
'=');
2664 const char* pcCmd=argv[2];
2665 *((
char*)pcSgn)=EOS; pcSgn++;
2666 if (
strxcmp(isCas,pcCmd,
"FILE",0,0,FALSE)==0) {
2667 srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgm),
"%s.%s.trace.file",pcOwn,pcPgm);
2669 fprintf(pfErr,
"Allocation of memory for envar string failed\n");
2672 siErr=siCnfSet(psCnf,pfOut,pcCnf,pcSgn,TRUE);
2675 fprintf(pfOut,
"Setting configuration keyword '%s' to value '%s' was successful\n",pcCnf,pcSgn);
2677 fprintf(pfOut,
"Deleting value from configuration keyword '%s' was successful\n",pcCnf);
2685 fprintf(pfErr,
"Syntax for built-in function 'TRACE' not valid\n");
2686 fprintf(pfErr,
"%s %s TRACE ON/OFF\n",pcDep,argv[0]);
2687 fprintf(pfErr,
"%s %s TRACE FILE=filenam\n",pcDep,argv[0]);
2690 if (pfOut==NULL) pfOut=pfStd;
2691 if (pfErr==NULL) pfErr=pfStd;
2693 fprintf(pfOut,
"Current configuration data:\n");
2694 siCnt=siCnfPrn(psCnf,pfOut,pcDep);
2696 fprintf(pfOut,
"Assigned to file \"%s\"\n",psCnf->pcFil);
2698 fprintf(pfOut,
"No configuration data defined for file \"%s\"\n",psCnf->pcFil);
2701 }
else if (argc==3) {
2702 if (argv[2][0]==
'-') argv[2]++;
2703 if (argv[2][0]==
'-') argv[2]++;
2704 if (
strxcmp(isCas,argv[2],
"CLEAR",0,0,FALSE)==0) {
2705 siCnt=siCnfClr(psCnf);
2707 fprintf(pfOut,
"Delete %d elements from file \"%s\"\n",siCnt,psCnf->pcFil);
2709 fprintf(pfOut,
"No configuration data defined for file \"%s\"\n",psCnf->pcFil);
2714 fprintf(pfErr,
"Syntax for built-in function 'CONFIG' not valid\n");
2715 fprintf(pfErr,
"%s %s CONFIG\n",pcDep,argv[0]);
2716 fprintf(pfErr,
"%s %s CONFIG CLEAR\n",pcDep,argv[0]);
2719 int siMaxCC=0x0FFFFFFF;
2720 int siMinCC=0x00000000;
2721 if (
strxcmp(isCas,argv[argc-1],
"MAXCC=",6,0,FALSE)==0) {
2722 char* h=strchr(&(argv[argc-1][6]),
'-');
2723 if (h!=NULL && isdigit(h[1])) siMinCC=atoi(h+1);
2724 if (isdigit(argv[argc-1][6])) siMaxCC=atoi(&(argv[argc-1][6]));
2727 if (
strxcmp(isCas,argv[1],
"OWNER=",6,0,FALSE)==0) {
2728 srprintf(&pcOwn,&szOwn,strlen(&argv[1][6]),
"%s",&argv[1][6]);
2730 if (pfErr!=NULL) fprintf(pfErr,
"Allocation of memory for owner string failed\n");
2732 ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2735 if (
SETENV(
"OWNERID",pcOwn)) {
2736 if (pfOut!=NULL) fprintf(pfOut,
"Use owner: '%s' (set as environment variable failed (%d - %s))\n",pcOwn,errno,strerror(errno));
2738 if (pfOut!=NULL) fprintf(pfOut,
"Use owner: '%s' (set as environment variable was successful)\n",pcOwn);
2741 if (pfOut!=NULL) fprintf(pfOut,
"Use owner: '%s' (environment variable was already defined)\n",pcOwn);
2743 for (i=2;i<argc;i++) argv[i-1]=argv[i];
2747 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
2748 l=strlen(psCmd[i].pcKyw);
2749 if (
strxcmp(isCas,argv[1],psCmd[i].pcKyw,0,-1,FALSE)==0 ||
2750 strxcmp(isCas,argv[1],psCmd[i].pcKyw,l,
'=',TRUE)==0 ||
2751 strxcmp(isCas,argv[1],psCmd[i].pcKyw,l,
'(',TRUE)==0 ||
2752 strxcmp(isCas,argv[1],psCmd[i].pcKyw,l,
'.',TRUE)==0) {
2756 clock_t ckCpu1=clock();
2758 siErr=siCleCommandInit(pvGbl,psCmd[i].pfIni,psCmd[i].pvClp,pcOwn,pcPgm,pcBld,psCmd[i].pcKyw,psCmd[i].pcMan,psCmd[i].pcHlp,psCmd[i].piOid,psCmd[i].psTab,
2759 isCas,isPfl,isRpl,siMkl,pfOut,pfErr,pfTrc,pcDep,pcOpt,pcEnt,psCnf,&pvHdl,pfMsg,pvF2S,pfF2S,pvSaf,pfSaf);
2760 if (siErr)
ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2763 fprintf(pfOut,
"%s Initializing of command '%s' was successful (CPU time %3.3fs)\n",
cstime(0,acTs),psCmd[i].pcKyw,((
double)(ckCpu2-ckCpu1))/CLOCKS_PER_SEC);
2767 siErr=siCleGetCommand(pfOut,pfErr,pfTrc,pcDep,psCmd[i].pcKyw,argc,argv,&pcFil,&pcCmd,pvGbl,pvF2S,pfF2S,pcDpa);
2768 if (siErr)
ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2771 fprintf(pfOut,
"%s Determination of parameter string for command '%s' was successful (CPU time %3.3fs)\n",
cstime(0,acTs),psCmd[i].pcKyw,((
double)(ckCpu2-ckCpu1))/CLOCKS_PER_SEC);
2775 siErr=
siClpParseCmd(pvHdl,pcFil,pcCmd,TRUE,TRUE,psCmd[i].piOid,&pcTls);
2777 if (pfErr!=NULL) fprintf(pfErr,
"Command line parser for command '%s' failed\n",psCmd[i].pcKyw);
2780 ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2783 pcLst=(
char*)malloc(strlen(pcTls)+1);
2785 strcpy(pcLst,pcTls);
2791 fprintf(pfOut,
"%s Parsing of parameter string for command '%s' was successful (CPU time %3.3fs)\n",
cstime(0,acTs),psCmd[i].pcKyw,((
double)(ckCpu2-ckCpu1))/CLOCKS_PER_SEC);
2795 siErr=psCmd[i].
pfMap(pvHdl,pfErr,pfTrc,pvGbl,psCmd[i].piOid,psCmd[i].pvClp,psCmd[i].pvPar);
2798 if (pfMsg!=NULL && (pcMsg=pfMsg(siErr))!=NULL) {
2799 if (pfErr!=NULL) fprintf(pfErr,
"Mapping of CLP structure for command '%s' failed (Return code: %d / Reason code: %d (%s))\n",psCmd[i].pcKyw,
CLERTC_MAP,siErr,pcMsg);
2801 if (pfErr!=NULL) fprintf(pfErr,
"Mapping of CLP structure for command '%s' failed (Return code: %d / Reason code: %d)\n",psCmd[i].pcKyw,
CLERTC_MAP,siErr);
2808 psCmd[i].
pfFin(pfErr,pfTrc,pvGbl,psCmd[i].pvPar);
2809 ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2813 fprintf(pfOut,
"%s Mapping of parameter structures for command '%s' was successful (CPU time %3.3fs)\n",
cstime(0,acTs),psCmd[i].pcKyw,((
double)(ckCpu2-ckCpu1))/CLOCKS_PER_SEC);
2817 siErr=psCmd[i].
pfRun(pvHdl,pfErr,pfTrc,pvGbl,pcOwn,pcPgm,pcVsn,pcAbo,pcLic,psCmd[i].pcKyw,pcCmd,pcLst,psCmd[i].pvPar,&isWrn,&siScc);
2820 if (isWrn&0x00010000) {
2821 if (pfMsg!=NULL && (pcMsg=pfMsg(siErr))!=NULL) {
2822 if (pfErr!=NULL) fprintf(pfErr,
"Run of command '%s' ends with warning (Return code: %d / Reason code: %d (%s))\n",psCmd[i].pcKyw,
CLERTC_WRN,siErr,pcMsg);
2824 if (pfErr!=NULL) fprintf(pfErr,
"Run of command '%s' ends with warning (Return code: %d / Reason code: %d)\n",psCmd[i].pcKyw,
CLERTC_WRN,siErr);
2826 psCmd[i].
pfFin(pfErr,pfTrc,pvGbl,psCmd[i].pvPar);
2828 ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2830 if (pfMsg!=NULL && (pcMsg=pfMsg(siErr))!=NULL) {
2831 if (pfErr!=NULL) fprintf(pfErr,
"Run of command '%s' failed (Return code: %d / Reason code: %d (%s))\n",psCmd[i].pcKyw,
CLERTC_RUN,siErr,pcMsg);
2833 if (pfErr!=NULL) fprintf(pfErr,
"Run of command '%s' failed (Return code: %d / Reason code: %d)\n",psCmd[i].pcKyw,
CLERTC_RUN,siErr);
2835 psCmd[i].
pfFin(pfErr,pfTrc,pvGbl,psCmd[i].pvPar);
2838 ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2841 ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2847 fprintf(pfOut,
"%s Run of command '%s' was successful (CPU time %3.3fs)\n",
cstime(0,acTs),psCmd[i].pcKyw,((
double)(ckCpu2-ckCpu1))/CLOCKS_PER_SEC);
2851 siErr=psCmd[i].
pfFin(pfErr,pfTrc,pvGbl,psCmd[i].pvPar);
2854 if (pfMsg!=NULL && (pcMsg=pfMsg(siErr))!=NULL) {
2855 if (pfErr!=NULL) fprintf(pfErr,
"Finish/cleanup for command '%s' failed (Return code: %d / Reason code: %d (%s))\n",psCmd[i].pcKyw,
CLERTC_FIN,siErr,pcMsg);
2857 if (pfErr!=NULL) fprintf(pfErr,
"Finish/cleanup for command '%s' failed (Return code: %d / Reason code: %d)\n",psCmd[i].pcKyw,
CLERTC_FIN,siErr);
2860 ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2864 fprintf(pfOut,
"%s Finalize for command '%s' was successful (CPU time %3.3fs)\n",
cstime(0,acTs),psCmd[i].pcKyw,((
double)(ckCpu2-ckCpu1))/CLOCKS_PER_SEC);
2866 siErr=isWrn&0x00000001;
2867 ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2871 if (pcDef!=NULL && *pcDef && ppArg==NULL) {
2872 ppArg=malloc((argc+1)*
sizeof(*ppArg));
2873 if (ppArg == NULL) {
2874 if (pfErr!=NULL) fprintf(pfErr,
"Memory allocation for argument list to run the default command '%s' failed\n",pcDef);
2876 ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2878 for (i=argc;i>1;i--) ppArg[i]=argv[i-1];
2879 ppArg[0]=argv[0]; ppArg[1]=(
char*)pcDef; argc++; argv=ppArg;
2883 fprintf(pfErr,
"Command or built-in function '%s' not supported\n",argv[1]);
2884 vdPrnStaticSyntax(pfErr,psCmd,asBif,argv[0],pcDep,pcOpt,pcDpa);
2887 ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2894 static int siClePropertyInit(
2927 int isOvl=(piOid==NULL)?FALSE:TRUE;
2932 if (piFil!=NULL) *piFil=0;
2933 if (ppFil!=NULL) *ppFil=NULL;
2934 *ppHdl=
pvClpOpen(isCas,isPfl,isRpl,siMkl,pcOwn,pcPgm,pcBld,pcCmd,pcMan,pcHlp,isOvl,psTab,pvClp,pfOut,pfErr,pfTrc,pfTrc,pfTrc,pfTrc,pcDep,pcOpt,pcEnt,NULL,pvGbl,pvF2S,pfF2S,pvSaf,pfSaf);
2936 if (pfErr!=NULL) fprintf(pfErr,
"Open of property parser for command '%s' failed\n",pcCmd);
2939 siErr=pfIni(*ppHdl,pfErr,pfTrc,pvGbl,pcOwn,pcPgm,pvClp);
2942 if (pfMsg!=NULL && (pcMsg=pfMsg(siErr))!=NULL) {
2943 if (pfErr!=NULL) fprintf(pfErr,
"Initialization of CLP structure for command '%s' failed (Return code: %d / Reason code: %d (%s))\n",pcCmd,
CLERTC_INI,siErr,pcMsg);
2945 if (pfErr!=NULL) fprintf(pfErr,
"Initialization of CLP structure for command '%s' failed (Return code: %d / Reason code: %d)\n",pcCmd,
CLERTC_INI,siErr);
2950 siErr=siCleGetProperties(pfErr,psCnf,pcOwn,pcPgm,pcCmd,&pcFil,&pcPro,&siFil,pvGbl,pvF2S,pfF2S);
2952 if (pcPro!=NULL) free(pcPro);
SAFE_FREE(pcFil);
2959 if (pfErr!=NULL) fprintf(pfErr,
"Parsing property file \"%s\" for command '%s' failed\n",pcFil,pcCmd);
2966 if (ppFil!=NULL) *ppFil=pcFil;
else {
2969 if (piFil!=NULL) *piFil=siFil;
2973 static int siClePropertyFinish(
2989 char acEnv[((pcHom!=NULL)?strlen(pcHom):0)+strlen(pcOwn)+strlen(pcPgm)+strlen(pcCmd)+64];
2996 snprintf(acEnv,
sizeof(acEnv),
"%s_%s_%s_PROPERTY_FILENAME",pcOwn,pcPgm,pcCmd);
2997 for (i=0;acEnv[i];i++) acEnv[i]=toupper(acEnv[i]);
2999 if (pcFil!=NULL && *pcFil) {
3000 srprintf(&pcEnv,&szEnv,strlen(pcFil),
"%s",pcFil);
3002 if (pfErr!=NULL) fprintf(pfErr,
"Allocation of memory for property file name (%s) failed\n",pcFil);
3011 strcpy(acEnv,
"<SYSUID>.");
3012 for (i=0;i<8 && pcOwn[i];i++) {
3013 if (isalnum(pcOwn[i])) {
3014 acEnv[j]=toupper(pcOwn[i]);
3018 if (i) acEnv[j]=
'.'; j++;
3019 for (i=0;i<8 && pcPgm[i];i++) {
3020 if (isalnum(pcPgm[i])) {
3021 acEnv[j]=toupper(pcPgm[i]);
3025 if (i) acEnv[j]=
'.'; j++;
3026 for (i=0;i<8 && pcCmd[i];i++) {
3027 if (isalnum(pcCmd[i])) {
3028 acEnv[j]=toupper(pcCmd[i]);
3033 strcat(acEnv,
".PROPS");
3036 if (pcHom!=NULL && *pcHom) {
3037 snprintf(acEnv,
sizeof(acEnv),
"%s.%s.%s.%s.properties",pcHom,pcOwn,pcPgm,pcCmd);
3039 snprintf(acEnv,
sizeof(acEnv),
".%s.%s.%s.properties",pcOwn,pcPgm,pcCmd);
3041 for (i=0;acEnv[i];i++) acEnv[i]=tolower(acEnv[i]);
3048 if (pfErr!=NULL) fprintf(pfErr,
"Allocation of memory for property file name (%s) failed\n",pcFil);
3055 if (pfErr!=NULL) fprintf(pfErr,
"Cannot open the property file (\"%s\",\"%s\") for write operation (%d-%s)\n",pcHlp,
"w",errno,strerror(errno));
3064 if (pfErr!=NULL) fprintf(pfErr,
"Write property file (%s) for command '%s' failed (%d-%s)\n",pcHlp,pcCmd,errno,strerror(errno));
3068 if (pfOut!=NULL) fprintf(pfOut,
"Property file (%s) for command '%s' successfully written\n",pcHlp,pcCmd);
3071 snprintf(acEnv,
sizeof(acEnv),
"%s.%s.%s.property.file",pcOwn,pcPgm,pcCmd);
3072 siErr=siCnfSet(psCnf,pfErr,acEnv,pcHlp,TRUE);
3074 if (pfErr!=NULL) fprintf(pfErr,
"Activation of property file (%s) for command '%s' failed\n",pcFil,pcCmd);
3079 fprintf(pfOut,
"Setting configuration keyword '%s' to value '%s' was successful\n",acEnv,pcFil);
3080 fprintf(pfOut,
"Activation of property file (%s) for command '%s' was successful\n",pcFil,pcCmd);
3087 static int siCleCommandInit(
3118 int isOvl=(piOid==NULL)?FALSE:TRUE;
3121 clock_t ckCpu1=clock();
3125 *ppHdl=
pvClpOpen(isCas,isPfl,isRpl,siMkl,pcOwn,pcPgm,pcBld,pcCmd,pcMan,pcHlp,isOvl,psTab,pvClp,pfOut,pfErr,pfTrc,pfTrc,pfTrc,pfTrc,pcDep,pcOpt,pcEnt,NULL,pvGbl,pvF2S,pfF2S,pvSaf,pfSaf);
3127 if (pfErr!=NULL) fprintf(pfErr,
"Open of parser for command '%s' failed\n",pcCmd);
3132 fprintf(pfTrc,
"%s Open of command line parser (CLP) for command '%s' was successful (CPU time %3.3fs)\n",
cstime(0,acTs),pcCmd,((
double)(ckCpu2-ckCpu1))/CLOCKS_PER_SEC);
3136 siErr=pfIni(*ppHdl,pfErr,pfTrc,pvGbl,pcOwn,pcPgm,pvClp);
3139 if (pfMsg!=NULL && (pcMsg=pfMsg(siErr))!=NULL) {
3140 if (pfErr!=NULL) fprintf(pfErr,
"Initialization of CLP structure for command '%s' failed (Return code: %d / Reason code: %d (%s))\n",pcCmd,
CLERTC_INI,siErr,pcMsg);
3142 if (pfErr!=NULL) fprintf(pfErr,
"Initialization of CLP structure for command '%s' failed (Return code: %d / Reason code: %d)\n",pcCmd,
CLERTC_INI,siErr);
3149 fprintf(pfTrc,
"%s Initialization of CLP structure for command '%s' was successful (CPU time %3.3fs)\n",
cstime(0,acTs),pcCmd,((
double)(ckCpu2-ckCpu1))/CLOCKS_PER_SEC);
3152 siErr=siCleGetProperties(pfErr,psCnf,pcOwn,pcPgm,pcCmd,&pcFil,&pcPro,&siFil,pvGbl,pvF2S,pfF2S);
3160 fprintf(pfTrc,
"%s Determine properties for command '%s' was successful (CPU time %3.3fs)\n",
cstime(0,acTs),pcCmd,((
double)(ckCpu2-ckCpu1))/CLOCKS_PER_SEC);
3166 if (pfErr!=NULL) fprintf(pfErr,
"Property parser for command '%s' failed\n",pcCmd);
3174 fprintf(pfTrc,
"%s Parsing of properties for command '%s' was successful (CPU time %3.3fs)\n",
cstime(0,acTs),pcCmd,((
double)(ckCpu2-ckCpu1))/CLOCKS_PER_SEC);
3181 static int siCleSimpleInit(
3192 {
CLPTYP_NUMBER,
"XX",NULL,0,1,1,0,0,
CLPFLG_NON,NULL,NULL,NULL,
"XX",0,0.0,NULL,
"NUMBER"},
3193 {
CLPTYP_NON ,NULL,NULL,0,0,0,0,0,
CLPFLG_NON,NULL,NULL,NULL,NULL,0,0.0,NULL,NULL}
3195 *ppHdl=
pvClpOpen(FALSE,isPfl,isRpl,0,
"",
"",
"",
"",
"",
"",FALSE,asTab,
"",pfOut,pfErr,NULL,NULL,NULL,NULL,pcDep,pcOpt,pcEnt,NULL,NULL,NULL,NULL,NULL,NULL);
3197 if (pfErr!=NULL) fprintf(pfErr,
"Open of command line parser for grammar and lexeme print out failed\n");
3203 static int siCleChangeProperties(
3239 siErr=siClePropertyInit(pvGbl,pfIni,pvClp,pcOwn,pcPgm,pcBld,pcCmd,pcMan,pcHlp,
3240 piOid,psTab,isCas,isPfl,isRpl,siMkl,pfOut,pfErr,pfTrc,
3241 pcDep,pcOpt,pcEnt,psCnf,&pvHdl,&pcFil,&siFil,pfMsg,pvF2S,pfF2S,pvSaf,pfSaf);
3249 if (pfErr!=NULL) fprintf(pfErr,
"Property parser for command '%s' failed\n",pcCmd);
3256 if (pfOut!=NULL) fprintf(pfOut,
"Don't update any property in property file (%s)\n",(NULL==pcFil)?
"null":pcFil);
3257 }
else if (siErr==1) {
3258 if (pfOut!=NULL) fprintf(pfOut,
"Updated 1 property in property file (%s)\n",(NULL==pcFil)?
"null":pcFil);
3260 if (pfOut!=NULL) fprintf(pfOut,
"Updated %d properties in property file (%s)\n",siErr,(NULL==pcFil)?
"null":pcFil);
3263 siErr=siClePropertyFinish(pcHom,pcOwn,pcPgm,pcCmd,pfOut,pfErr,pfTrc,psCnf,pvHdl,pcFil,siFil);
3273 static int siCleEndExecution(
3283 if (psCnf!=NULL) vdCnfCls(psCnf);
3284 if (pfTrc!=NULL) fclose(pfTrc);
3285 if (pfDoc!=NULL) fclose(pfDoc);
3286 if (pfPro!=NULL) fclose(pfPro);
3287 if (ppArg!=NULL) free(ppArg);
3289 if (pcBuf!=NULL) free(pcBuf);
3293 static void vdCleManProgram(
3311 for(
const char* p=pcPgm;*p;p++) fprintf(pfOut,
"%c",tolower(*p));
3312 fprintf(pfOut,
"(1)\n");
3314 for (i=0;i<l;i++) fprintf(pfOut,
"=");
3315 fprintf(pfOut,
"\n");
3316 fprintf(pfOut,
":doctype: manpage\n\n");
3317 fprintf(pfOut,
"NAME\n");
3318 fprintf(pfOut,
"----\n\n");
3319 for(
const char* p=pcPgm;*p;p++) fprintf(pfOut,
"%c",tolower(*p));
3320 efprintf(pfOut,
" - `%s`\n\n",pcHlp);
3321 fprintf(pfOut,
"SYNOPSIS\n");
3322 fprintf(pfOut,
"--------\n\n");
3323 fprintf(pfOut,
"-----------------------------------------------------------------------\n");
3324 fprintf(pfOut,
"PATH: %s\n",pcOwn);
3325 fprintf(pfOut,
"TYPE: PROGRAM\n");
3326 fprintf(pfOut,
"SYNTAX: > %s COMMAND/FUNCTION ...\n",pcPgm);
3327 fprintf(pfOut,
"-----------------------------------------------------------------------\n\n");
3328 fprintf(pfOut,
"DESCRIPTION\n");
3329 fprintf(pfOut,
"-----------\n\n");
3330 if (pcMan!=NULL && *pcMan) {
3331 fprintm(pfOut,pcOwn,pcPgm,pcBld,pcMan,2);
3333 fprintf(pfOut,
"No detailed description available for this program.\n\n");
3335 fprintf(pfOut,
"AUTHOR\n");
3336 fprintf(pfOut,
"------\n\n");
3337 fprintf(pfOut,
"limes datentechnik(r) gmbh (www.flam.de)\n\n");
3338 fprintf(pfOut,
"SEE ALSO\n");
3339 fprintf(pfOut,
"--------\n\n");
3340 for (i=0;psCmd[i].
pcKyw!=NULL;i++) {
3341 if (psCmd[i].siFlg) {
3342 for(
const char* p=pcPgm;*p;p++) fprintf(pfOut,
"%c",tolower(*p));
3344 for(
const char* p=psCmd[i].pcKyw;*p;p++) fprintf(pfOut,
"%c",tolower(*p));
3345 fprintf(pfOut,
"(1)\n");
3348 fprintf(pfOut,
"\n");
3351 fprintf(pfOut,
"%s Program '%s'\n",pcNum,pcPgm);
3352 l=strlen(pcNum)+strlen(pcPgm)+11;
3353 for (i=0;i<l;i++) fprintf(pfOut,
"%c",
'-');
3354 fprintf(pfOut,
"\n\n");
3355 fprintf(pfOut,
"%s1. Synopsis\n",pcNum);
3357 for (i=0;i<l;i++) fprintf(pfOut,
"%c",
C_TLD);
3358 fprintf(pfOut,
"\n\n");
3360 fprintf(pfOut,
"Program '%s'\n",pcPgm);
3362 for (i=0;i<l;i++) fprintf(pfOut,
"%c",
'-');
3363 fprintf(pfOut,
"\n\n");
3364 fprintf(pfOut,
"Synopsis\n");
3365 for (i=0;i<8;i++) fprintf(pfOut,
"%c",
C_TLD);
3366 fprintf(pfOut,
"\n\n");
3368 fprintf(pfOut,
"-----------------------------------------------------------------------\n");
3369 efprintf(pfOut,
"HELP: %s\n",pcHlp);
3370 fprintf(pfOut,
"PATH: %s\n",pcOwn);
3371 fprintf(pfOut,
"TYPE: PROGRAM\n");
3372 fprintf(pfOut,
"SYNTAX: > %s COMMAND/FUNCTION ...\n",pcPgm);
3373 fprintf(pfOut,
"-----------------------------------------------------------------------\n\n");
3376 fprintf(pfOut,
"%s2. Description\n",pcNum);
3378 for (i=0;i<l;i++) fprintf(pfOut,
"%c",
C_TLD);
3379 fprintf(pfOut,
"\n\n");
3381 fprintf(pfOut,
"Description\n");
3382 for (i=0;i<11;i++) fprintf(pfOut,
"%c",
C_TLD);
3383 fprintf(pfOut,
"\n\n");
3385 if (pcMan!=NULL && *pcMan) {
3386 fprintm(pfOut,pcOwn,pcPgm,pcBld,pcMan,2);
3388 fprintf(pfOut,
"No detailed description available for this program.\n\n");
3391 fprintf(pfOut,
"%s3. Syntax\n",pcNum);
3393 for (i=0;i<l;i++) fprintf(pfOut,
"%c",
C_TLD);
3394 fprintf(pfOut,
"\n\n");
3396 fprintf(pfOut,
"Syntax\n");
3397 for (i=0;i<6;i++) fprintf(pfOut,
"%c",
C_TLD);
3398 fprintf(pfOut,
"\n\n");
3400 fprintm(pfOut,pcOwn,pcPgm,pcBld,MAN_CLE_PROGRAM_SYNTAX,1);
3401 fprintf(pfOut,
"------------------------------------------------------------------------\n");
3402 fprintf(pfOut,
"Syntax for program '%s':\n",pcPgm);
3403 vdPrnStaticSyntax(pfOut,psCmd,psBif,pcPgm,pcDep,pcSep,pcDpa);
3404 fprintf(pfOut,
"------------------------------------------------------------------------\n\n");
3407 fprintf(pfOut,
"%s4. Help\n",pcNum);
3409 for (i=0;i<l;i++) fprintf(pfOut,
"%c",
C_TLD);
3410 fprintf(pfOut,
"\n\n");
3412 fprintf(pfOut,
"Help\n");
3413 for (i=0;i<4;i++) fprintf(pfOut,
"%c",
C_TLD);
3414 fprintf(pfOut,
"\n\n");
3416 fprintm(pfOut,pcOwn,pcPgm,pcBld,MAN_CLE_PROGRAM_HELP,1);
3417 fprintf(pfOut,
"------------------------------------------------------------------------\n");
3418 fprintf(pfOut,
"Help for program '%s':\n",pcPgm);
3419 vdPrnStaticHelp(pfOut,psCmd,psBif,pcPgm,pcDep);
3420 fprintf(pfOut,
"------------------------------------------------------------------------\n\n");
3424 static void vdCleManFunction(
3426 const unsigned int uiLev,
3444 for(
const char* p=pcPgm;*p;p++) fprintf(pfOut,
"%c",tolower(*p));
3445 fprintf(pfOut,
".");
3446 for(
const char* p=pcFct;*p;p++) fprintf(pfOut,
"%c",tolower(*p));
3447 fprintf(pfOut,
"(1)\n");
3448 l=strlen(pcPgm)+strlen(pcFct)+4;
3449 for (i=0;i<l;i++) fprintf(pfOut,
"=");
3450 fprintf(pfOut,
"\n");
3451 fprintf(pfOut,
":doctype: manpage\n\n");
3452 fprintf(pfOut,
"NAME\n");
3453 fprintf(pfOut,
"----\n\n");
3454 for(
const char* p=pcPgm;*p;p++) fprintf(pfOut,
"%c",tolower(*p));
3455 fprintf(pfOut,
".");
3456 for(
const char* p=pcFct;*p;p++) fprintf(pfOut,
"%c",tolower(*p));
3457 efprintf(pfOut,
" - `%s`\n\n",pcHlp);
3458 fprintf(pfOut,
"SYNOPSIS\n");
3459 fprintf(pfOut,
"--------\n\n");
3460 fprintf(pfOut,
"-----------------------------------------------------------------------\n");
3461 fprintf(pfOut,
"PATH: %s.%s\n",pcOwn,pcPgm);
3462 fprintf(pfOut,
"TYPE: BUILT-IN FUNCTION\n");
3463 fprintf(pfOut,
"SYNTAX: > %s %s\n",pcPgm,pcSyn);
3464 fprintf(pfOut,
"-----------------------------------------------------------------------\n\n");
3465 fprintf(pfOut,
"DESCRIPTION\n");
3466 fprintf(pfOut,
"-----------\n\n");
3467 fprintm(pfOut,pcOwn,pcPgm,pcBld,pcMan,2);
3468 fprintf(pfOut,
"AUTHOR\n------\n\n");
3469 fprintf(pfOut,
"limes datentechnik(r) gmbh (www.flam.de)\n\n");
3472 efprintf(pfOut,
"[[CLEP.BUILTIN.%s]]\n",pcFct);
3473 for (
unsigned int j=0;j<uiLev;j++)
efprintf(pfOut,
"=");
3474 if (isNbr)
efprintf(pfOut,
" %s",pcNum);
3478 efprintf(pfOut,
" Function '%s'\n\n",pcFct);
3480 if (isIdt)
efprintf(pfOut,
"indexterm:[Built-in Function, %s]\n\n",pcFct);
3482 efprintf(pfOut,
"-----------------------------------------------------------------------\n");
3483 efprintf(pfOut,
"HELP: %s\n",pcHlp);
3485 efprintf(pfOut,
"PATH: %s.%s\n",pcOwn,pcPgm);
3486 efprintf(pfOut,
"TYPE: BUILT-IN FUNCTION\n");
3487 efprintf(pfOut,
"SYNTAX: > %s %s\n",pcPgm,pcSyn);
3488 efprintf(pfOut,
"-----------------------------------------------------------------------\n\n");
3489 efprintf(pfOut,
".Description\n\n");
3490 fprintm(pfOut,pcOwn,pcPgm,pcBld,pcMan,2);
3492 efprintf(pfOut,
"[[CLEP.BUILTIN.%s]]\n",pcFct);
3495 fprintf(pfOut,
"%s %s\n",pcNum,pcFct);
3496 l=strlen(pcNum)+strlen(pcFct)+1;
3497 for (i=0;i<l;i++) fprintf(pfOut,
"%s",pcLev);
3498 fprintf(pfOut,
"\n\n");
3500 fprintf(pfOut,
"%s Function '%s'\n",pcNum,pcFct);
3501 l=strlen(pcNum)+strlen(pcFct)+12;
3502 for (i=0;i<l;i++) fprintf(pfOut,
"%s",pcLev);
3503 fprintf(pfOut,
"\n\n");
3507 fprintf(pfOut,
"%s\n",pcFct);
3509 for (i=0;i<l;i++) fprintf(pfOut,
"%s",pcLev);
3510 fprintf(pfOut,
"\n\n");
3512 fprintf(pfOut,
"Function '%s'\n",pcFct);
3514 for (i=0;i<l;i++) fprintf(pfOut,
"%s",pcLev);
3515 fprintf(pfOut,
"\n\n");
3518 if (isIdt)
efprintf(pfOut,
"indexterm:[Built-in Function, %s]\n\n",pcFct);
3519 fprintf(pfOut,
".Synopsis\n\n");
3520 fprintf(pfOut,
"-----------------------------------------------------------------------\n");
3521 efprintf(pfOut,
"HELP: %s\n",pcHlp);
3523 fprintf(pfOut,
"PATH: %s.%s\n",pcOwn,pcPgm);
3524 fprintf(pfOut,
"TYPE: BUILT-IN FUNCTION\n");
3525 fprintf(pfOut,
"SYNTAX: > %s %s\n",pcPgm,pcSyn);
3526 fprintf(pfOut,
"-----------------------------------------------------------------------\n\n");
3527 fprintf(pfOut,
".Description\n\n");
3528 fprintm(pfOut,pcOwn,pcPgm,pcBld,pcMan,2);
3533 static void vdPrnStaticSyntax(
3543 fprintf(pfOut,
"%s Commands: ",pcDep);
3544 for (
int i=0;psCmd[i].
pcKyw!=NULL;i++) {
3545 if (psCmd[i].siFlg) {
3546 if (f) fprintf(pfOut,
"%s",pcSep);
3547 fprintf(pfOut,
"%s",psCmd[i].pcKyw);
3551 fprintf(pfOut,
"\n");
3552 fprintf(pfOut,
"%s%s %s %cOWNER=oid%c command \"... argument list ...\" %cMAXCC=%cmax%c%c-min%c%c %cQUIET/SILENT%c\n",pcDep,pcDep,pcPgm,
C_SBO,
C_SBC,
C_SBO,
C_SBO,
C_SBC,
C_SBO,
C_SBC,
C_SBC,
C_SBO,
C_SBC);
3553 fprintf(pfOut,
"%s%s %s %cOWNER=oid%c command=\" parameter file name \" %cMAXCC=%cmax%c%c-min%c%c %cQUIET/SILENT%c\n",pcDep,pcDep,pcPgm,
C_SBO,
C_SBC,
C_SBO,
C_SBO,
C_SBC,
C_SBO,
C_SBC,
C_SBC,
C_SBO,
C_SBC);
3554 fprintf(pfOut,
"%s%s %s %cOWNER=oid%c command=>\"parameter file name \" %cMAXCC=%cmax%c%c-min%c%c %cQUIET/SILENT%c\n",pcDep,pcDep,pcPgm,
C_SBO,
C_SBC,
C_SBO,
C_SBO,
C_SBC,
C_SBO,
C_SBC,
C_SBC,
C_SBO,
C_SBC);
3555 fprintf(pfOut,
"%s%s You can optionally specify:\n",pcDep,pcDep);
3556 fprintf(pfOut,
"%s%s%s the owner id for this command (to use custom configuration files)\n",pcDep,pcDep,pcDep);
3557 fprintf(pfOut,
"%s%s%s the maximum condition code (max) to suppress warnings\n",pcDep,pcDep,pcDep);
3558 fprintf(pfOut,
"%s%s%s the minimum condition code (min), zero is returned if the condition code would be smaller\n",pcDep,pcDep,pcDep);
3559 fprintf(pfOut,
"%s%s%s QUIET disables the normal log output of the command line executer\n",pcDep,pcDep,pcDep);
3560 fprintf(pfOut,
"%s%s%s SILENT disables log and errors messages of the command line executer\n",pcDep,pcDep,pcDep);
3562 fprintf(pfOut,
"%s%s Additional the default parameter file '%s' is supported if only the command provided\n",pcDep,pcDep,pcDpa);
3564 fprintf(pfOut,
"%s Built-in functions:\n",pcDep);
3565 for (
int i=0;psBif[i].pcKyw!=NULL;i++) {
3566 if (psBif[i].isBif) {
3567 efprintf(pfOut,
"%s%s %s %s\n",pcDep,pcDep,pcPgm,psBif[i].pcSyn);
3572 static void vdPrnStaticHelp(
3579 fprintf(pfOut,
"%s Commands - to execute powerful subprograms\n",pcDep);
3580 for (
int i=0;psCmd[i].
pcKyw!=NULL;i++) {
3581 if (psCmd[i].siFlg) {
3582 fprintf(pfOut,
"%s%s %s %-8.8s - %s\n",pcDep,pcDep,pcPgm,psCmd[i].pcKyw,psCmd[i].pcHlp);
3585 fprintf(pfOut,
"%s Built-in functions - to give interactive support for the commands above\n",pcDep);
3586 for (
int i=0;psBif[i].pcKyw!=NULL;i++) {
3587 if (psBif[i].isBif) {
3588 efprintf(pfOut,
"%s%s %s %-8.8s - %s\n",pcDep,pcDep,pcPgm,psBif[i].pcKyw,psBif[i].pcHlp);
3591 fprintf(pfOut,
"For more information please use the built-in function 'MANPAGE'\n");
3594 static void vdPrnCommandSyntax(
3604 fprintf(pfOut,
"%s %s \"",pcDep,pcPgm);
3606 if (siErr==
CLP_OK) fprintf(pfOut,
"\"\n");
3612 static void vdPrnCommandHelp(
3619 siClpHelp(pvHdl,siDep,pcCmd,isAli,isMan);
3622 static void vdPrnCommandManpage(
3632 snprintf(acNum,
sizeof(acNum),
"%s%d.",pcNum,siInd+1);
3633 siClpDocu(pvHdl,pfOut,pcCmd,acNum,
"Command",TRUE,FALSE,isMan,FALSE,isNbr,FALSE,TRUE,0);
3636 static void vdPrnProperties(
3644 static int siCleGetProperties(
3658 const char* pcHlp=NULL;
3659 char acRoot[strlen(pcOwn)+strlen(pcPgm)+strlen(pcCmd)+17];
3660 char acMsg[1024]=
"";
3663 snprintf(acRoot,
sizeof(acRoot),
"%s.%s.%s.property.file",pcOwn,pcPgm,pcCmd);
3664 pcHlp=pcCnfGet(psCnf,acRoot);
3666 snprintf(acRoot,
sizeof(acRoot),
"%s.%s.property.file",pcOwn,pcPgm);
3667 pcHlp=pcCnfGet(psCnf,acRoot);
3669 snprintf(acRoot,
sizeof(acRoot),
"%s.property.file",pcOwn);
3670 pcHlp=pcCnfGet(psCnf,acRoot);
3679 if (pfErr!=NULL) fprintf(pfErr,
"Allocation of memory for property file name (%s) failed)\n",pcHlp);
3682 siErr=pfF2S(pvGbl,pvF2S,*ppFil,ppPro,&siSiz,acMsg,
sizeof(acMsg));
3684 if (pfErr!=NULL) fprintf(pfErr,
"Property file: %s\n",acMsg);
3692 static int siCleGetCommand(
3708 int l=strlen(pcFct);
3710 if (argv[1][l]==EOS) {
3712 siErr=
arry2str(argv+2,argc-2,
" ",1,ppCmd,&siSiz);
3716 case -1:
if (pfErr!=NULL) fprintf(pfErr,
"Illegal parameters passed to arry2str() (Bug)\n");
return(
CLERTC_FAT);
3717 case -2:
if (pfErr!=NULL) fprintf(pfErr,
"Allocation of memory for command line failed (%d - %s).\n",errno,strerror(errno));
return(
CLERTC_MEM);
3718 default:
if (pfErr!=NULL) fprintf(pfErr,
"An unknown error occurred while reading command line.\n");
return(
CLERTC_FAT);
3723 fprintf(pfTrc,
"%s Read parameter string in length %d from command line\n",
cstime(0,acTs),(
int)strlen(*ppCmd));
3726 if (pcDpa!=NULL && *pcDpa) {
3727 siErr=pfF2S(pvGbl,pvF2S,pcDpa,ppCmd,&siSiz,NULL,0);
3731 fprintf(pfTrc,
"%s Read parameter string in length %d from default parameter file '%s'\n",
cstime(0,acTs),siErr,pcDpa);
3734 char* pcHlp=(
char*)realloc(*ppCmd,1);
3736 if (pfErr!=NULL) fprintf(pfErr,
"Allocation of memory for command line failed (%d - %s).\n",errno,strerror(errno));
3743 char* pcHlp=(
char*)realloc(*ppCmd,1);
3745 if (pfErr!=NULL) fprintf(pfErr,
"Allocation of memory for command line failed (%d - %s).\n",errno,strerror(errno));
3752 }
else if (argv[1][l]==
'.' || argv[1][l]==
'(') {
3753 argv[1]=&argv[1][l];
3754 siErr=
arry2str(argv+1,argc-1,
" ",1,ppCmd,&siSiz);
3758 case -1:
if (pfErr!=NULL) fprintf(pfErr,
"Illegal parameters passed to arry2str() (Bug)\n");
return(
CLERTC_FAT);
3759 case -2:
if (pfErr!=NULL) fprintf(pfErr,
"Allocation of memory for command line failed (%d - %s).\n",errno,strerror(errno));
return(
CLERTC_MEM);
3760 default:
if (pfErr!=NULL) fprintf(pfErr,
"An unknown error occurred while reading command line.\n");
return(
CLERTC_FAT);
3765 fprintf(pfTrc,
"%s Read parameter string in length %d from command line\n",
cstime(0,acTs),(
int)strlen(*ppCmd));
3767 }
else if (argv[1][l]==
'=') {
3768 int o=(argv[1][l+1]==
'>')?l+2:l+1;
3771 fprintf(pfErr,
"The expected parameter file name for '%s' is split into more than one parameter\n",pcFct);
3772 fprintf(pfErr,
"The parameter file name must start with \" and end with \" to join anything into one parameter\n");
3773 fprintf(pfErr,
"Syntax for command '%s' not valid\n",pcFct);
3774 fprintf(pfErr,
"%s %s %s=\" parameter file name \"\n",pcDep,argv[0],pcFct);
3775 fprintf(pfErr,
"Please use '%s SYNTAX %s%c.path%c' for more information\n",argv[0],pcFct,
C_SBO,
C_SBC);
3781 if (pfErr!=NULL) fprintf(pfErr,
"Allocation of memory for command file (%s) failed\n",argv[1]+l+1);
3785 char acMsg[1024]=
"";
3786 siErr=pfF2S(pvGbl,pvF2S,*ppFil,ppCmd,&siSiz,acMsg,
sizeof(acMsg));
3790 fprintf(pfTrc,
"%s Read parameter string in length %d from file '%s'\n",
cstime(0,acTs),siErr,*ppFil);
3793 if (pfErr!=NULL) fprintf(pfErr,
"Command file: %s\n",acMsg);
3800 fprintf(pfErr,
"No blank space ' ', equal sign '=', dot '.' or bracket '(' behind '%s'\n",pcFct);
3801 fprintf(pfErr,
"Please use a blank space to define an argument list or an equal sign for a parameter file\n");
3802 fprintf(pfErr,
"Syntax for command '%s' not valid\n",pcFct);
3803 fprintf(pfErr,
"%s %s %cOWNER=oid%c %s \"... argument list ...\" %cMAXCC=%cmax%c%c-min%c%c %cQUIET%c\n",pcDep,argv[0],
C_SBO,
C_SBC,pcFct,
C_SBO,
C_SBO,
C_SBC,
C_SBO,
C_SBC,
C_SBC,
C_SBO,
C_SBC);
3804 fprintf(pfErr,
"%s %s %cOWNER=oid%c %s=\" parameter file name \" %cMAXCC=%cmax%c%c-min%c%c %cQUIET%c\n",pcDep,argv[0],
C_SBO,
C_SBC,pcFct,
C_SBO,
C_SBO,
C_SBC,
C_SBO,
C_SBC,
C_SBC,
C_SBO,
C_SBC);
3805 fprintf(pfErr,
"Please use '%s SYNTAX %s%c.path%c' for more information\n",argv[0],pcFct,
C_SBO,
C_SBC);
3830 if (pfErr!=NULL) fprintf(pfErr,
"Memory allocation for configuration data handle failed\n");
3837 if (pcFil==NULL || *pcFil==0)
return(psHdl);
3838 psHdl->pcFil=malloc(strlen(pcFil)+1);
3839 if (psHdl->pcFil==NULL) {
3840 if (pfErr!=NULL) fprintf(pfErr,
"Memory allocation for configuration file name (%s) failed\n",pcFil);
3844 strcpy(psHdl->pcFil,pcFil);
3847 if (pfFil==NULL && (errno==2 || errno==49 || errno==129))
return(psHdl);
3849 if (pfErr!=NULL) fprintf(pfErr,
"Cannot open the configuration file (\"%s\",\"r\") for read operation (%d - %s)\n",psHdl->pcFil,errno,strerror(errno));
3854 while (fgets(acBuf,
sizeof(acBuf)-1,pfFil)!=NULL) {
3856 if (pcHlp!=NULL) *pcHlp=EOS;
3857 size_t l=strlen(acBuf);
3860 while (isspace(*(pcHlp-1))) {
3861 pcHlp--; *pcHlp=EOS;
3863 pcHlp=strchr(acBuf,
'=');
3865 pcKyw=acBuf; pcVal=pcHlp+1; *pcHlp=EOS;
3866 while (isspace(*pcKyw)) pcKyw++;
3867 while (isspace(*pcVal)) pcVal++;
3868 for (
char* p=pcKyw+strlen(pcKyw);p>pcKyw && isspace(*(p-1));p--) *p=0x00;
3869 for (
char* p=pcVal+strlen(pcVal);p>pcVal && isspace(*(p-1));p--) *p=0x00;
3872 if (pfErr!=NULL) fprintf(pfErr,
"Memory allocation for configuration data element failed\n");
3877 siKyw=strlen(pcKyw); siVal=strlen(pcVal);
3878 if (siKyw && siVal) {
3879 srprintf(&psEnt->pcKyw,&psEnt->szKyw,siKyw,
"%s",pcKyw);
3880 srprintf(&psEnt->pcVal,&psEnt->szVal,siVal,
"%s",pcVal);
3881 if (psEnt->pcKyw==NULL || psEnt->pcVal==NULL) {
3882 if (pfErr!=NULL) fprintf(pfErr,
"Memory allocation for configuration data (%s=%s) failed\n",pcKyw,pcVal);
3888 if (psHdl->psLst!=NULL) {
3889 psEnt->psBak=psHdl->psLst;
3890 psEnt->psNxt=psHdl->psLst->psNxt;
3891 if (psHdl->psLst->psNxt!=NULL) {
3892 psHdl->psLst->psNxt->psBak=psEnt;
3894 psHdl->psLst->psNxt=psEnt;
3912 static int siCnfSet(
3921 for (psEnt=psHdl->psFst;psEnt!=NULL;psEnt=psEnt->psNxt) {
3922 if (
strxcmp(psHdl->isCas,psEnt->pcKyw,pcKyw,0,0,FALSE)==0) {
3923 if (pcVal==NULL || *pcVal==0x00) {
3924 if (psEnt->psNxt!=NULL) {
3925 psEnt->psNxt->psBak=psEnt->psBak;
3927 psHdl->psLst=psEnt->psBak;
3929 if (psEnt->psBak!=NULL) {
3930 psEnt->psBak->psNxt=psEnt->psNxt;
3932 psHdl->psFst=psEnt->psNxt;
3938 if (isOvr || psEnt->pcVal[0]==0) {
3939 srprintf(&psEnt->pcVal,&psEnt->szVal,strlen(pcVal),
"%s",pcVal);
3940 if (psEnt->pcVal==NULL) {
3941 if (pfErr!=NULL) fprintf(pfErr,
"Allocation of memory for configuration value (%s=%s) failed\n",pcKyw,pcVal);
3945 if (pfErr!=NULL) fprintf(pfErr,
"Configuration value (%s) for keyword '%s' already exists\n",psEnt->pcVal,psEnt->pcKyw);
3956 if (pfErr!=NULL) fprintf(pfErr,
"Memory allocation for configuration data element failed\n");
3959 siKyw=strlen(pcKyw); siVal=strlen(pcVal);
3960 if (siKyw && siVal) {
3961 srprintf(&psEnt->pcKyw,&psEnt->szKyw,siKyw,
"%s",pcKyw);
3962 srprintf(&psEnt->pcVal,&psEnt->szVal,siVal,
"%s",pcVal);
3963 if (psEnt->pcKyw==NULL || psEnt->pcVal==NULL) {
3964 if (pfErr!=NULL) fprintf(pfErr,
"Memory allocation for configuration data (%s=%s) failed\n",pcKyw,pcVal);
3968 if (psHdl->psLst!=NULL) {
3969 psEnt->psBak=psHdl->psLst;
3970 psEnt->psNxt=psHdl->psLst->psNxt;
3971 if (psHdl->psLst->psNxt!=NULL) {
3972 psHdl->psLst->psNxt->psBak=psEnt;
3974 psHdl->psLst->psNxt=psEnt;
3982 if (pfErr!=NULL) fprintf(pfErr,
"Configuration keyword(%s) and/or value(%s) is empty\n", pcKyw, pcVal);
3990 static const char* pcCnfGet(
3995 for (psEnt=psHdl->psFst;psEnt!=NULL;psEnt=psEnt->psNxt) {
3996 if (
strxcmp(psHdl->isCas,psEnt->pcKyw,pcKyw,0,0,FALSE)==0)
return(psEnt->pcVal);
4001 static int siCnfPutEnv(
4008 for (i=j=0,psEnt=psHdl->psFst;psEnt!=NULL;psEnt=psEnt->psNxt,i++) {
4009 if (strstr(psEnt->pcKyw,pcOwn)!=NULL &&
4010 strstr(psEnt->pcKyw,pcPgm)!=NULL &&
4011 strstr(psEnt->pcKyw,
".envar.")!=NULL) {
4012 const char* pcKyw=strstr(psEnt->pcKyw,
".envar.")+7;
4013 if (
SETENV(pcKyw,psEnt->pcVal)==0) {
4014 const char* pcEnv=
GETENV(pcKyw);
4016 if (strcmp(pcEnv,psEnt->pcVal)==0) {
4026 static int siCnfPrnEnv(
4036 for (i=0,psEnt=psHdl->psFst;psEnt!=NULL;psEnt=psEnt->psNxt,i++) {
4037 if (strstr(psEnt->pcKyw,pcOwn)!=NULL &&
4038 strstr(psEnt->pcKyw,pcPgm)!=NULL &&
4039 strstr(psEnt->pcKyw,
".envar.")!=NULL) {
4040 const char* pcKyw=strstr(psEnt->pcKyw,
".envar.")+7;
4041 const char* pcEnv=
GETENV(pcKyw);
4043 if (strcmp(pcEnv,psEnt->pcVal)==0) {
4044 pcAdd=
"was verified";
4045 }
else pcAdd=
"not verified";
4046 }
else pcAdd=
"not verified";
4047 if (pcPre!=NULL && *pcPre) {
4048 fprintf(pfOut,
"%s %s=%s %c %s\n",pcPre,pcKyw,psEnt->pcVal,
C_HSH,pcAdd);
4050 fprintf(pfOut,
"%s=%s %c %s\n",pcKyw,psEnt->pcVal,
C_HSH,pcAdd);
4057 static int siCnfPrn(
4064 for (i=0,psEnt=psHdl->psFst;psEnt!=NULL;psEnt=psEnt->psNxt,i++) {
4065 if (pcPre!=NULL && *pcPre) {
4066 fprintf(pfOut,
"%s %s=%s\n",pcPre,psEnt->pcKyw,psEnt->pcVal);
4068 fprintf(pfOut,
"%s=%s\n",psEnt->pcKyw,psEnt->pcVal);
4074 static int siCnfClr(
4081 while(psEnt!=NULL) {
4095 static void vdCnfCls(
4102 if (psHdl->pcFil!=NULL) {
4103 if ((psHdl->isChg || psHdl->isClr) && psHdl->pcFil[0]) {
4108 if (pfFil!=NULL && psHdl->pcPgm!=NULL) {
4109 fprintf(pfFil,
"%c Configuration file for program '%s'\n",
C_HSH,psHdl->pcPgm);
4111 for (psEnt=psHdl->psFst;psEnt!=NULL;psEnt=psHlp) {
4112 if (pfFil!=NULL && psHdl->isClr==FALSE){
4113 fprintf(pfFil,
"%s=%s\n",psEnt->pcKyw,psEnt->pcVal);
4120 if (pfFil!=NULL) fclose(pfFil);
4160 pvHdl=
pvClpOpen(isCas,isPfl,isRpl,siMkl,pcOwn,pcPgm,pcBld,pcCmd,pcMan,pcHlp,isOvl,
4161 psTab,pvDat,pfTmp,pfTmp,NULL,NULL,NULL,NULL,
4162 pcDep,pcOpt,pcEnt,&stErr,pvGbl,pvF2S,pfF2S,pvSaf,pfSaf);
4164 snprintf(pcErr,uiErr,
"CTX-MESSAGE : Open of string parser for command '%s' failed\n",pcCmd);
4165 if (pfTmp!=NULL) {rewind(pfTmp);
size_t l=strlen(pcErr);
size_t r=fread(pcErr+l,1,uiErr-(l+1),pfTmp);
fclose_tmp(pfTmp); pcErr[l+r]=0x00;}
4168 siErr=
siClpParseCmd(pvHdl,NULL,pcStr,TRUE,TRUE,(
int*)piMod,NULL);
4170 snprintf(pcErr,uiErr,
4171 "CTX-MESSAGE : Parsing of string for command '%s' failed\n"
4173 "CLP-ERROR : %d - %s\n"
4174 "CLP-MESSAGE : %s\n"
4175 "CLP-SOURCE : %s (ROW: %d COL: %d)\n",
4178 if (pfTmp!=NULL) {rewind(pfTmp);
size_t l=strlen(pcErr);
size_t r=fread(pcErr+l,1,uiErr-(l+1),pfTmp);
fclose_tmp(pfTmp); pcErr[l+r]=0x00;}