FLAMCLEP-Reference
Command Line Executor/Parser Source Reference
FLAMCLE.c
Go to the documentation of this file.
1 
30 /*
31  * TASK:0000086 Fehlermeldungen ueberarbeiten (Zentralisierung)
32  * TASK:0000086 Wide character support fuer command files einbauen
33  * TASK:0000086 Mehrsprachigkeit einbauen
34  */
35 /* Standard-Includes **************************************************/
36 
37 #ifndef _XOPEN_SOURCE
38 #define _XOPEN_SOURCE 600
39 #endif
40 #include <ctype.h>
41 #include <time.h>
42 #include <stdio.h>
43 #include <string.h>
44 #include <stdlib.h>
45 #include <errno.h>
46 #ifdef __WIN__
47 # include <windows.h>
48 #else
49 # include <dlfcn.h>
50 # include <sys/utsname.h>
51 #endif
52 
53 /* Include eigener Bibliotheken **************************************/
54 
55 #if defined(__DEBUG__) && defined(__FL5__)
56 # include "CHKMEM.h"
57 #endif
58 #include "CLEPUTL.h"
59 #include "FLAMCLP.h"
60 
61 #ifndef fopen_nowarn
62 # define fopen_nowarn fopen
63 #endif
64 
65 /* Include der Schnittstelle ******************************************/
66 
67 #include "FLAMCLE.h"
68 #include "CLEMAN.h"
69 #include "CLEMSG.h"
70 
71 /* Definition der Version von FL-CLE ***********************************
72  *
73  * Changelog:
74  * 1.1.1: Fix of the envar bug (ISSUE: 0000182)
75  * 1.1.2: Adjust version and about
76  * 1.1.3: Add clear of config
77  * 1.1.4: Call FIN if RUN failed
78  * 1.1.5: Property and command line specific parsing
79  * 1.1.6: Add support for DD:STDENV on mainframes
80  * 1.1.7: Remove message for envar's set on release build
81  * 1.1.8: Add arguments if flcl help path man used
82  * 1.1.9: Correct generation of manpages
83  * 1.1.10: Don't print manpage twice at end of path anymore
84  * 1.1.11: Correct PGM handling and support "-KYW" or "--KYW"
85  * 1.1.12: Support default command or built-in function
86  * 1.1.13: Provide license text at run and oid for the mapping function
87  * 1.1.14: Compare of keywords instead of compare up to key word length
88  * 1.1.15: Add built-in function CHGPROP
89  * 1.1.16: Add alias list for getprop and default for chgprop if pcDef=="flam"
90  * 1.1.17: Use HOMEDIR as default dir for config and property files
91  * 1.1.18: Support new option at GETPROP to print all or only defined (set) properties
92  * 1.1.19: search config file first in working dir and then in home dir for read operation
93  * 1.1.20: print aliases at help only if keyword ALL or MAN is used
94  * 1.1.21: eliminate isFlg from CleExecute() to accept file properties
95  * 1.1.22: Add support for parameter files for each object and overlay (read.text=parfilename.txt)
96  * 1.1.23: Invent CLEPUTL.h/c
97  * 1.1.24: Use file2str() and get it more thrad save
98  * 1.1.25: Support switch to enable parameter files for object and overlays
99  * Improve error handling (using new CLP error structure and printing)
100  * 1.1.26: Replace static variables for version and about to make it possible to use the lib as DLL
101  * 1.1.27: Fix issue 547: Parameter files working properly
102  * 1.1.28: Rework to make CLEP better usable with DLLs (eliminate global variables, adjust about and version, correct includes)
103  * 1.1.29: Use arry2str for command line to remove last static vars, fix object and overlay handling if default command (>flam4 "(flamin=...)")
104  * 1.1.30: fix memory leaks found with memchecker
105  * 1.1.31: Support definition of the owner per run of a command
106  * 1.1.32: Support DD names for write operation (log, trace, docs, ...)
107  * 1.1.33: Use setenv() instead of putenv() for DD:STDENV on z/OS
108  * 1.1.34: Use snprintf() instead of sprintf() for static array strings
109  * 1.1.35: Support file name mapping (+/<Cuser>)
110  * 1.1.36: Introduce SET/GETENV() macros
111  * 1.1.37: Rework and correct file handling, adjust documentation
112  * 1.1.38: Adjust printout for support of synopsis at help if keyword man is used
113  * 1.1.39: Correct clang warning (use only literal format strings)
114  * 1.1.40: fix potential memory leaks
115  * 1.1.41: Change to new condition codes (separation of warnings and error in RUN function)
116  * Add support of reason codes including generation of an appendix in GENDOCU for it
117  * Add new built-in function to print out error code messages
118  * 1.1.42: Code page specific interpretation of punctuation characters on EBCDIC systems
119  * 1.1.43: Replace unnecessary strlen()
120  * 1.1.44: Define command qualifier for ClpDocu("COMMAND")
121  * 1.1.45: Support replacement of &{OWN} and &{PGM} in man pages
122  * 1.1.46: Support MAXCC parameter for command execution
123  * 1.1.47: Print undefined/empty properties as comment
124  * 1.1.48: Add support for special condition codes (SCC)
125  * 1.1.49: Set owner id as environment variable if not already defined
126  * 1.1.50: Support appendix for other CLP strings in docu generation
127  * 1.1.51: Allow empty parameter lists for commands
128  * 1.1.52: Improve help output (print help message for path)
129  * 1.1.53: Fix typo by generating of indexterm
130  * 1.1.54: Redesign appendix properties
131  * 1.2.55: Make error message and source variable in length
132  * 1.2.56: Make root and property variable in length
133  * 1.2.57: Separate acNum (number) and acHdl (head line)
134  * 1.2.58: Support dynamic strings and arrays in CLP structure
135  * 1.2.59: Support pvClpAlloc in RUN functions
136  * 1.2.60: Support dynamic string for file names
137  * 1.2.61: Support condition code 1 if a relevant warning in the log
138  * 1.2.62: Support suppression of minimal condition codes as MAXCC extension
139  * 1.2.63: Support option QUIET in command syntax to suppress all printouts of CLE
140  * 1.2.64: Support option SILENT like QUIET but the error messages will be printed
141  * 1.2.65: Support pvClpAlloc in INI functions
142  * 1.2.66: Fix valgrind issue at read of configuration file
143  * 1.2.67: Read environment also from SYSUID.STDENV on z/OS
144  * 1.2.68: Separate version and build number with hyphen instead of dot
145  * 1.2.69: Use new file2str interface
146  * 1.2.70: Support callback function for file to string
147  * 1.2.71: Fix memory leak if GETPROP used without command
148  * 1.2.72: Fix several issues concerning dia-critical character support for EBCDIC
149  * 1.2.73: Support DD:FLAMPAR for FLAM command on z/OS
150  * 1.2.74: Support no run reason code (siNoR)
151  * 1.2.75: Add black box (handle) for all call back functions
152  * 1.2.76: Support additional authorization for CLP path
153  * 1.2.77: Use type of function and not type of pointer to function (usable for pragma's)
154  * 1.2.78: Support free defined appendix
155  * 1.3.79: Support new more flexible table based documentation generation
156  * 1.3.80: Support optional built-in function HTMLDOC
157  * 1.3.81: Improve printouts and add time stamps
158  */
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
163 
164 /* Definition der Konstanten ******************************************/
165 
166 #define CLEINI_PROSIZ 1024
167 
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
191 
192 /* Definition der Strukturen ******************************************/
193 
194 typedef struct CnfEnt {
195  struct CnfEnt* psNxt;
196  struct CnfEnt* psBak;
197  size_t szKyw;
198  char* pcKyw;
199  size_t szVal;
200  char* pcVal;
202 
203 typedef struct CnfHdl {
204  int isChg;
205  int isClr;
206  int isCas;
207  char* pcFil;
208  const char* pcPgm;
209  TsCnfEnt* psFst;
210  TsCnfEnt* psLst;
212 
213 typedef struct CleBuiltin {
214  int siIdx;
215  const char* pcKyw;
216  const char* pcHlp;
217  const char* pcSyn;
218  const char* pcMan;
219  int isBif;
221 
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}
225 
226 typedef struct CleDocPar {
227  const char* pcOwn;
228  const char* pcPgm;
229  const char* pcAut;
230  const char* pcAdr;
231  const char* pcBld;
232  const char* pcHlp;
233  const char* pcDep;
234  const char* pcOpt;
235  const char* pcEnt;
236  const char* pcDpa;
237  void* pvCnf;
238  int isPfl;
239  int isRpl;
240  int isCas;
241  int siMkl;
242  TfMsg* pfMsg;
243  const char* pcVsn;
244  const char* pcAbo;
245  int isDep;
246  int isHdr;
247  int isAnc;
248  int isNbr;
249  int isShl;
250  int isPat;
251  int isIdt;
252  const TsCleBuiltin* psBif;
253  const TsCleCommand* psCmd;
254  const TsCleOtherClp* psOth;
255  void* pvF2S;
256  TfF2S* pfF2S;
257  void* pvSaf;
258  TfSaf* pfSaf;
259  int siPs1;
260  int siPs2;
261  int siPr3;
263 
264 /* Deklaration der internen Funktionen ********************************/
265 
266 static int siClePropertyInit(
267  void* pvGbl,
268  TfIni* pfIni,
269  void* pvClp,
270  const char* pcOwn,
271  const char* pcPgm,
272  const char* pcBld,
273  const char* pcCmd,
274  const char* pcMan,
275  const char* pcHlp,
276  const int* piOid,
277  const TsClpArgument* psTab,
278  const int isCas,
279  const int isPfl,
280  const int isRpl,
281  const int siMkl,
282  FILE* pfOut,
283  FILE* pfErr,
284  FILE* pfTrc,
285  const char* pcDep,
286  const char* pcOpt,
287  const char* pcEnt,
288  TsCnfHdl* psCnf,
289  void** ppHdl,
290  char** ppFil,
291  int* piFil,
292  TfMsg* pfMsg,
293  void* pvF2S,
294  TfF2S* pfF2S,
295  void* pvSaf,
296  TfSaf* pfSaf);
297 
298 static int siClePropertyFinish(
299  const char* pcHom,
300  const char* pcOwn,
301  const char* pcPgm,
302  const char* pcCmd,
303  FILE* pfOut,
304  FILE* pfErr,
305  FILE* pfTrc,
306  TsCnfHdl* psCnf,
307  void* pvHdl,
308  const char* pcFil,
309  const int siFil);
310 
311 static int siCleChangeProperties(
312  void* pvGbl,
313  TfIni* pfIni,
314  void* pvClp,
315  const char* pcHom,
316  const char* pcOwn,
317  const char* pcPgm,
318  const char* pcBld,
319  const char* pcCmd,
320  const char* pcMan,
321  const char* pcHlp,
322  const char* pcPro,
323  const int* piOid,
324  const TsClpArgument* psTab,
325  const int isCas,
326  const int isPfl,
327  const int isRpl,
328  const int siMkl,
329  FILE* pfOut,
330  FILE* pfErr,
331  FILE* pfTrc,
332  const char* pcDep,
333  const char* pcOpt,
334  const char* pcEnt,
335  TsCnfHdl* psCnf,
336  TfMsg* pfMsg,
337  void* pvF2S,
338  TfF2S* pfF2S,
339  void* pvSaf,
340  TfSaf* pfSaf);
341 
342 static int siCleCommandInit(
343  void* pvGbl,
344  TfIni* pfIni,
345  void* pvClp,
346  const char* pcOwn,
347  const char* pcPgm,
348  const char* pcBld,
349  const char* pcCmd,
350  const char* pcMan,
351  const char* pcHlp,
352  const int* piOid,
353  const TsClpArgument* psTab,
354  const int isCas,
355  const int isPfl,
356  const int isRpl,
357  const int siMkl,
358  FILE* pfOut,
359  FILE* pfErr,
360  FILE* pfTrc,
361  const char* pcDep,
362  const char* pcOpt,
363  const char* pcEnt,
364  TsCnfHdl* psCnf,
365  void** ppHdl,
366  TfMsg* pfMsg,
367  void* pvF2S,
368  TfF2S* pfF2S,
369  void* pvSaf,
370  TfSaf* pfSaf);
371 
372 static int siCleSimpleInit(
373  FILE* pfOut,
374  FILE* pfErr,
375  const int isPfl,
376  const int isRpl,
377  const char* pcDep,
378  const char* pcOpt,
379  const char* pcEnt,
380  void** ppHdl);
381 
382 static int siCleEndExecution(
383  const int siErr,
384  TsCnfHdl* psCnf,
385  FILE* pfTrc,
386  FILE* pfDoc,
387  FILE* pfPro,
388  char** ppArg,
389  void* pvHdl,
390  char* pcBuf);
391 
392 static void vdCleManProgram(
393  FILE* pfOut,
394  const TsCleCommand* psCmd,
395  const TsCleBuiltin* psBif,
396  const char* pcOwn,
397  const char* pcPgm,
398  const char* pcBld,
399  const char* pcHlp,
400  const char* pcMan,
401  const char* pcDep,
402  const char* pcSep,
403  const char* pcDpa,
404  const char* pcNum,
405  const int isMan,
406  const int isNbr);
407 
408 static void vdCleManFunction(
409  FILE* pfOut,
410  const unsigned int uiLev,
411  const char* pcLev,
412  const char* pcNum,
413  const char* pcFct,
414  const char* pcHlp,
415  const char* pcOwn,
416  const char* pcPgm,
417  const char* pcBld,
418  const char* pcSyn,
419  const char* pcMan,
420  const int isMan,
421  const int isPat,
422  const int isNbr,
423  const int isShl,
424  const int isIdt);
425 
426 static void vdPrnStaticSyntax(
427  FILE* pfOut,
428  const TsCleCommand* psCmd,
429  const TsCleBuiltin* psBif,
430  const char* pcPgm,
431  const char* pcDep,
432  const char* pcSep,
433  const char* pcDpa);
434 
435 static void vdPrnStaticHelp(
436  FILE* pfOut,
437  const TsCleCommand* psCmd,
438  const TsCleBuiltin* psBif,
439  const char* pcPgm,
440  const char* pcDep);
441 
442 static void vdPrnCommandSyntax(
443  void* pvHdl,
444  FILE* pfOut,
445  const char* pcPgm,
446  const char* pcCmd,
447  const char* pcDep,
448  const int siDep);
449 
450 static void vdPrnCommandHelp(
451  void* pvHdl,
452  const char* pcCmd,
453  const int siDep,
454  const int isAli,
455  const int isMan);
456 
457 static void vdPrnCommandManpage(
458  void* pvHdl,
459  FILE* pfOut,
460  const char* pcNum,
461  const char* pcCmd,
462  const int siInd,
463  const int isMan,
464  const int isNbr);
465 
466 static void vdPrnProperties(
467  void* pvHdl,
468  const char* pcPat,
469  const int siDep);
470 
471 static int siCleGetProperties(
472  FILE* pfErr,
473  TsCnfHdl* psCnf,
474  const char* pcOwn,
475  const char* pcPgm,
476  const char* pcCmd,
477  char** ppFil,
478  char** ppPro,
479  int* piFlg,
480  void* pvGbl,
481  void* pvF2S,
482  TfF2S* pfF2S);
483 
484 static int siCleGetCommand(
485  FILE* pfOut,
486  FILE* pfErr,
487  FILE* pfTrc,
488  const char* pcDep,
489  const char* pcFct,
490  int argc,
491  char* argv[],
492  char** ppFil,
493  char** ppCmd,
494  void* pvGbl,
495  void* pvF2S,
496  TfF2S* pfF2S,
497  const char* pcDpa);
498 
499 static TsCnfHdl* psCnfOpn(
500  FILE* pfErr,
501  const int isCas,
502  const char* pcPgm,
503  const char* pcFil);
504 
505 static int siCnfSet(
506  TsCnfHdl* psHdl,
507  FILE* pfErr,
508  const char* pcKyw,
509  const char* pcVal,
510  const int isOvr);
511 
512 static const char* pcCnfGet(
513  TsCnfHdl* psHdl,
514  const char* pcKyw);
515 
516 static int siCnfPutEnv(
517  TsCnfHdl* psHdl,
518  const char* pcOwn,
519  const char* pcPgm);
520 
521 static int siCnfPrnEnv(
522  TsCnfHdl* psHdl,
523  FILE* pfOut,
524  const char* pcPre,
525  const char* pcOwn,
526  const char* pcPgm);
527 
528 static int siCnfPrn(
529  TsCnfHdl* psHdl,
530  FILE* pfOut,
531  const char* pcPre);
532 
533 static int siCnfClr(
534  TsCnfHdl* psHdl);
535 
536 static void vdCnfCls(
537  TsCnfHdl* psHdl);
538 
539 /* Implementierung der externen Funktionen ****************************/
540 
541 extern const char* pcCleVersion(const int l, const int s, char* b)
542 {
543  snprintc(b,s,"%2.2d FLAM-CLE VERSION: %s-%u BUILD: %s %s %s\n",l,CLE_VSN_STR,__BUILDNR__,__BUILD__,__DATE__,__TIME__);
544  return(pcClpVersion(l+1,s,b));
545 }
546 
547 extern const char* pcCleAbout(const int l, const int s, char* b)
548 {
549  snprintc(b,s,
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__);
557  return(pcClpAbout(l+1,s,b));
558 }
559 
560 static inline const char* pcMapDocTyp(const unsigned int uiTyp) {
561  switch(uiTyp) {
562  case CLE_DOCTYP_COVER: return("CLE_DOCTYP_COVER");
563  case CLE_DOCTYP_CHAPTER: return("CLE_DOCTYP_CHAPTER");
564  case CLE_DOCTYP_BUILTIN: return("CLE_DOCTYP_BUILTIN");
565  case CLE_DOCTYP_PROGRAM: return("CLE_DOCTYP_PROGRAM");
566  case CLE_DOCTYP_PGMSYNOPSIS: return("CLE_DOCTYP_PGMSYNOPSIS");
567  case CLE_DOCTYP_PGMSYNTAX: return("CLE_DOCTYP_PGMSYNTAX");
568  case CLE_DOCTYP_PGMHELP: return("CLE_DOCTYP_PGMHELP");
569  case CLE_DOCTYP_COMMANDS: return("CLE_DOCTYP_COMMANDS");
570  case CLE_DOCTYP_OTHERCLP: return("CLE_DOCTYP_OTHERCLP");
571  case CLE_DOCTYP_LEXEMES: return("CLE_DOCTYP_LEXEMES");
572  case CLE_DOCTYP_GRAMMAR: return("CLE_DOCTYP_GRAMMAR");
573  case CLE_DOCTYP_PROPREMAIN: return("CLE_DOCTYP_PROPREMAIN");
574  case CLE_DOCTYP_PROPDEFAULTS: return("CLE_DOCTYP_PROPDEFAULTS");
575  case CLE_DOCTYP_SPECIALCODES: return("CLE_DOCTYP_SPECIALCODES");
576  case CLE_DOCTYP_REASONCODES: return("CLE_DOCTYP_REASONCODES");
577  case CLE_DOCTYP_VERSION: return("CLE_DOCTYP_VERSION");
578  case CLE_DOCTYP_ABOUT: return("CLE_DOCTYP_ABOUT");
579  default: return("UNKOWN");
580  }
581 }
582 
583 static inline const char* pcMapCleRtc(int siRtc) {
584  switch(siRtc) {
585  case CLERTC_OK: return("o.k.");
586  case CLERTC_INF: return("info");
587  case CLERTC_FIN: return("finish function failed");
588  case CLERTC_WRN: return("warning");
589  case CLERTC_RUN: return("run failed");
590  case CLERTC_MAP: return("mapping failed");
591  case CLERTC_SYN: return("syntax error");
592  case CLERTC_CMD: return("command failed");
593  case CLERTC_INI: return("initialization failed");
594  case CLERTC_CFG: return("configuration wrong");
595  case CLERTC_TAB: return("table error (CLP) ");
596  case CLERTC_SYS: return("system error");
597  case CLERTC_ACS: return("license/access error");
598  case CLERTC_ITF: return("interface error");
599  case CLERTC_MEM: return("memory/allocation failed");
600  case CLERTC_FAT: return("fatal error");
601  default : return("special condition code");
602  }
603 }
604 
605 static int siClpFile2String(void* gbl, void* hdl, const char* filename, char** buf, int* bufsize, char* errmsg, const int msgsiz) {
606  (void)gbl;
607  char* pcFil=dcpmapfil(filename);
608  if (pcFil==NULL) return(-1);
609  int siErr=file2str(hdl, pcFil, buf, bufsize, errmsg, msgsiz);
610  free(pcFil);
611  return(siErr);
612 }
613 
614 #undef ERROR
615 #define ERROR(x,b) do { \
616  int r = siCleEndExecution((x),psCnf,pfTrh,pfDoc,pfPro,ppArg,pvHdl,(b));\
617  if (r) {\
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));\
620  } else {\
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));\
622  }\
623  } else {\
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__);\
626  } else {\
627  if (pfOut!=NULL) efprintf(pfOut,"%s Program '%s' (Build: %s %s) run successfully\n",cstime(0,acTs),(pcProgram!=NULL)?pcProgram:"-NULL-",__DATE__,__TIME__);\
628  }\
629  }\
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);\
631  SAFE_FREE(pcHom); \
632  SAFE_FREE(pcPgm); \
633  SAFE_FREE(pcPgu); \
634  SAFE_FREE(pcPgl); \
635  SAFE_FREE(pcCnf); \
636  SAFE_FREE(pcOwn); \
637  SAFE_FREE(pcFil); \
638  return(r); \
639 } while(FALSE)
640 
641 /**********************************************************************/
642 
643 static inline TsCnfHdl* psOpenConfig(FILE* pfOut, FILE* pfErr, const char* pcHom, const char* pcPgm, const char* pcPgu, const char* pcPgl, const int isCas) {
644  size_t szFil=0;
645  size_t szCnf=0;
646  char* pcCnf=NULL;
647  char* pcFil=NULL;
648  TsCnfHdl* psCnf;
649  const char* m;
650 
651  srprintf(&pcCnf,&szCnf,strlen(pcPgu),"%s_CONFIG_FILE",pcPgu);
652  if (pcCnf==NULL) {
653  if (pfErr!=NULL) {
654  fprintf(pfErr,"Memory allocation for %s_CONFIG_FILE failed\n",pcPgu);
655  }
656  return(NULL);
657  }
658  m=GETENV(pcCnf);
659 
660  if (m==NULL) {
661  #ifdef __ZOS__
662  {
663  int i,j;
664  char acUsr[16];
665  srprintf(&pcFil,&szFil,strlen(pcPgu)+8,"'%s.",userid(sizeof(acUsr),acUsr));
666  if (pcFil==NULL) {
667  if (pfErr!=NULL) {
668  fprintf(pfErr,"Memory allocation for default configuration file name failed\n");
669  }
670  free(pcCnf);
671  return(NULL);
672  }
673  for (j=strlen(pcFil),i=0;i<8 && pcPgu[i];i++) {
674  if (isalnum(pcPgu[i])) {
675  pcFil[j]=pcPgu[i];
676  j++;
677  }
678  }
679  strcpy(pcFil+j,".CONFIG'");
680  }
681  #else
682  if (pcHom[0]) {
683  srprintf(&pcFil,&szFil,strlen(pcPgl),".%s.config",pcPgl);
684  if (pcFil==NULL) {
685  if (pfErr!=NULL) {
686  fprintf(pfErr,"Memory allocation for default configuration file name failed\n");
687  }
688  free(pcCnf);
689  return(NULL);
690  }
691  FILE* pfTmp=fopen_nowarn(pcFil,"r");
692  if (pfTmp==NULL) {
693  srprintf(&pcFil,&szFil,strlen(pcHom)+strlen(pcPgl),"%s.%s.config",pcHom,pcPgl);
694  if (pcFil==NULL) {
695  if (pfErr!=NULL) {
696  fprintf(pfErr,"Memory allocation for default configuration file name failed\n");
697  }
698  free(pcCnf);
699  return(NULL);
700  }
701  if (pfOut!=NULL) {
702  char acTs[24];
703  fprintf(pfOut,"%s Use default configuration file (%s) in home directory\n",cstime(0,acTs),pcFil);
704  }
705  } else {
706  fclose(pfTmp);
707  if (pfOut!=NULL) {
708  char acTs[24];
709  fprintf(pfOut,"%s Use existing configuration file (%s) in working directory\n",cstime(0,acTs),pcFil);
710  }
711  }
712  } else {
713  srprintf(&pcFil,&szFil,strlen(pcPgl),".%s.config",pcPgl);
714  if (pcFil==NULL) {
715  if (pfErr!=NULL) {
716  fprintf(pfErr,"Memory allocation for default configuration file name failed\n");
717  }
718  free(pcCnf);
719  return(NULL);
720  }
721  if (pfOut!=NULL) {
722  char acTs[24];
723  fprintf(pfOut,"%s Use default configuration file (%s) in working directory\n",cstime(0,acTs),pcFil);
724  }
725  }
726  #endif
727  } else {
728  srprintf(&pcFil,&szFil,strlen(m),"%s",m);
729  if (pcFil==NULL) {
730  if (pfErr!=NULL) {
731  fprintf(pfErr,"Memory allocation for configuration file name (%s) from environment variable failed\n",pcCnf);
732  }
733  free(pcCnf);
734  return(NULL);
735  }
736  if (pfOut!=NULL) {
737  char acTs[24];
738  fprintf(pfOut,"%s Using configuration file (%s) defined by environment variable (%s)\n",cstime(0,acTs),pcFil,pcCnf);
739  }
740  }
741 
742  psCnf=psCnfOpn(pfErr,isCas,pcPgm,pcFil);
743  free(pcFil);
744  free(pcCnf);
745  return(psCnf);
746 }
747 
748 /**********************************************************************/
749 
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) {
751  if (psDoc->pcHdl!=NULL && *psDoc->pcHdl) {
752  if (psDoc->pcKyw!=NULL && *psDoc->pcKyw) {
753  char acKyw[strlen(psDoc->pcKyw)+4];
754  snprintf(acKyw,sizeof(acKyw),"[%s]",psDoc->pcKyw);/*nodiac*/
755  fprintm(pfDoc,pcOwn,pcPgm,pcBld,acKyw,1);
756  }
757  if (psDoc->pcAnc!=NULL && *psDoc->pcAnc) {
758  char acAnc[strlen(psDoc->pcAnc)+8];
759  snprintf(acAnc,sizeof(acAnc),"[[%s]]",psDoc->pcAnc);/*nodiac*/
760  fprintm(pfDoc,pcOwn,pcPgm,pcBld,acAnc,1);
761  }
762  for (unsigned int i=0;i<psDoc->uiLev;i++) {
763  efprintf(pfDoc,"=");
764  }
765  if (isNbr && psDoc->pcNum!=NULL && *psDoc->pcNum) efprintf(pfDoc," %s",psDoc->pcNum);
766  efprintf(pfDoc," ");
767  if (isHdr && pcAut!=NULL && *pcAut) {
768  char acHdr[1024];
769  fprintm(pfDoc,pcOwn,pcPgm,pcBld,psDoc->pcHdl,1);
770  if (pcAdr!=NULL && *pcAdr) {
771  snprintf(acHdr,sizeof(acHdr),"%s <%s>\nv&{BLD}, &{DATE}: &{state}.",pcAut,pcAdr); /*nodiac*/
772  } else {
773  snprintf(acHdr,sizeof(acHdr),"%s\nv&{BLD}, &{DATE}: &{state}.",pcAut); /*nodiac*/
774  }
775  fprintm(pfDoc,pcOwn,pcPgm,pcBld,acHdr,2);
776  } else {
777  fprintm(pfDoc,pcOwn,pcPgm,pcBld,psDoc->pcHdl,2);
778  }
779  if (isIdt && psDoc->pcIdt!=NULL && *psDoc->pcIdt) {
780  const char* pcHlp;
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);/*nodiac*/
785  fprintm(pfDoc,pcOwn,pcPgm,pcBld,acIdt,1);
786  pcIdt=pcHlp+1;
787  }
788  char acIdt[strlen(pcIdt)+16];
789  snprintf(acIdt,sizeof(acIdt),"indexterm:[%s]",pcIdt);/*nodiac*/
790  fprintm(pfDoc,pcOwn,pcPgm,pcBld,acIdt,2);
791  }
792  if (psDoc->pcMan!=NULL && *psDoc->pcMan) {
793  fprintm(pfDoc,pcOwn,pcPgm,pcBld,psDoc->pcMan,2);
794  } else {
795  if (pfErr!=NULL) fprintf(pfErr,"No manual page for chapter '%s' provided\n",psDoc->pcHdl);
796  return(CLERTC_TAB);
797 
798  }
799  return(CLERTC_OK);
800  } else {
801  if (pfErr!=NULL) fprintf(pfErr,"No head line for chapter defined\n");
802  return(CLERTC_TAB);
803  }
804 }
805 
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);
809  return(CLERTC_ITF);
810  }
811  if (isHdr) {
812  efprintf(pfDoc,":doctype: book\n\n");
813  }
814  return(siPrintChapter(pfErr,pfDoc,psDoc,pcOwn,pcPgm,pcAut,pcAdr,pcBld,isHdr,isNbr,isIdt));
815 }
816 
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) {
818  if (psDoc->uiLev<2 || psDoc->uiLev>5) {
819  if (pfErr!=NULL) fprintf(pfErr,"The level (%u) for a chapter must be between 2 and 6\n",psDoc->uiLev);
820  return(CLERTC_ITF);
821  }
822  return(siPrintChapter(pfErr,pfDoc,psDoc,pcOwn,pcPgm,NULL,NULL,pcBld,FALSE,isNbr,isIdt));
823 }
824 
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");
829  efprintf(pfDoc,"HELP: %s\n",pcHlp);
830  if (isPat)
831  efprintf(pfDoc,"PATH: %s\n",pcOwn);
832  efprintf(pfDoc,"TYPE: PROGRAM\n");
833  efprintf(pfDoc,"SYNTAX: > %s COMMAND/FUNCTION ...\n",pcPgm);
834  efprintf(pfDoc,"-----------------------------------------------------------------------\n\n");
835  return(CLERTC_OK);
836 }
837 
838 static int siClePrintPgmSyntax(FILE* pfErr, FILE* pfDoc, const TsCleDoc* psDoc, const TsCleCommand* psCmd, const TsCleBuiltin* psBif,
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");
846  return(CLERTC_OK);
847 }
848 
849 static int siClePrintPgmHelp(FILE* pfErr, FILE* pfDoc, const TsCleDoc* psDoc, const TsCleCommand* psCmd, const TsCleBuiltin* psBif,
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");
857  return(CLERTC_OK);
858 }
859 
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);
867  }
868  return(CLERTC_OK);
869 }
870 
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) {
873  void* pvHdl=NULL;
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");
880  int siRtc=siClpLexemes(pvHdl,pfDoc);
881  vdClpClose(pvHdl,CLPCLS_MTD_ALL);
882  efprintf(pfDoc,"------------------------------------------------------------------------\n\n");
883  return((siRtc)?CLERTC_SYN:CLERTC_OK);
884 }
885 
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) {
888  void* pvHdl=NULL;
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");
895  int siRtc=siClpGrammar(pvHdl,pfDoc);
896  vdClpClose(pvHdl,CLPCLS_MTD_ALL);
897  efprintf(pfDoc,"------------------------------------------------------------------------\n\n");
898  return((siRtc)?CLERTC_SYN:CLERTC_OK);
899 }
900 
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");
906  efprintf(pfDoc,"%s",pcTxt);
907  efprintf(pfDoc,"------------------------------------------------------------------------\n\n");
908  return(CLERTC_OK);
909  } else {
910  if (pfErr!=NULL) fprintf(pfErr,"No pre-formatted text provided but print requested (version, about)\n");
911  return(CLERTC_ITF);
912  }
913 }
914 
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++) {
920  void* pvHdl=NULL;
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);
924  if (siErr) {
925  return(siErr);
926  }
927  siErr=siClpProperties(pvHdl,CLPPRO_MTD_DOC,10,psCmd[j].pcKyw,pfDoc);
928  vdClpClose(pvHdl,CLPCLS_MTD_ALL);
929  }
930  return((siErr)?CLERTC_SYN:CLERTC_OK);
931 }
932 
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++) {
941  void* pvHdl=NULL;
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);
945  if (siErr) {
946  return(siErr);
947  }
948  siErr=siClpProperties(pvHdl,CLPPRO_MTD_SET,10,psCmd[j].pcKyw,pfDoc);
949  vdClpClose(pvHdl,CLPCLS_MTD_ALL);
950  }
951  efprintf(pfDoc,"------------------------------------------------------------------------\n\n");
952  return((siErr)?CLERTC_SYN:CLERTC_OK);
953 }
954 
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) {
956  if (pfMsg!=NULL) {
957  int r;
958  const char* m;
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);
963  }
964  efprintf(pfDoc,"\n");
965  return(CLERTC_OK);
966  } else {
967  if (pfErr!=NULL) fprintf(pfErr,"The pointer to the message function to map the reason codes is NULL but print was requested\n");
968  return(CLERTC_ITF);
969  }
970 }
971 
972 /***********************************************************************/
973 
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));
995  default:
996  if (pfErr!=NULL) fprintf(pfErr,"Documentation type (%u) not supported\n",psDoc->uiTyp);
997  return(CLERTC_TAB);
998  }
999 }
1000 
1001 static int siClePrintPage(FILE* pfOut, FILE* pfErr, const TsCleDoc* psDoc, const char* pcFil, const TsCleDocPar* psPar, void* pvPrn, TfClpPrintPage* pfPrn) {
1002  unsigned int i;
1003  if (psDoc->pcHdl==NULL) {
1004  if (pfErr!=NULL) fprintf(pfErr,"Headline is NULL\n");
1005  return(CLERTC_TAB);
1006  }
1007  if (pfOut!=NULL) {
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);
1011  }
1012  FILE* pfDoc=fopen_tmp();
1013  if (pfDoc==NULL) {
1014  if (pfErr!=NULL) fprintf(pfErr,"Open of temporary file to print manual page '%s' failed (%d - %s)\n",psDoc->pcHdl,errno,strerror(errno));
1015  return(CLERTC_SYS);
1016  }
1017  int siErr=siCleWritePage(pfErr,pfDoc,psDoc,psPar);
1018  if (siErr) {
1019  fclose_tmp(pfDoc);
1020  return(siErr);
1021  }
1022  size_t s=(size_t)ftell(pfDoc);
1023  rewind(pfDoc);
1024  char* pcPge=malloc(s+1);
1025  if (pcPge==NULL) {
1026  if (pfErr!=NULL) fprintf(pfErr,"Allocation of memory for temporary file to print manual '%s' page failed\n",psDoc->pcHdl);
1027  fclose_tmp(pfDoc);
1028  return(CLERTC_MEM);
1029  }
1030  size_t r=fread(pcPge,1,s,pfDoc);
1031  fclose_tmp(pfDoc);
1032  if (r!=s) {
1033  free(pcPge);
1034  if (pfErr!=NULL) fprintf(pfErr,"Read of temporary file to print manual page '%s' failed (%d - %s)\n",psDoc->pcHdl,errno,strerror(errno));
1035  return(CLERTC_SYS);
1036  }
1037  pcPge[r]=0x00;
1038 
1039  const char* p=strchr(pcPge,'=');
1040  if (p==NULL) {
1041  free(pcPge);
1042  if (pfErr!=NULL) fprintf(pfErr,"No headline found in manual page '%s' (no sign)\n",psDoc->pcHdl);
1043  return(CLERTC_FAT);
1044  }
1045  while (*p=='=') p++;
1046  if (*p!=' ') {
1047  free(pcPge);
1048  if (pfErr!=NULL) fprintf(pfErr,"No headline found in manual page '%s' (no blank after sign)\n",psDoc->pcHdl);
1049  return(CLERTC_FAT);
1050  }
1051  p++;
1052  const char* e=strchr(p,'\n');
1053  if (e==NULL) {
1054  free(pcPge);
1055  if (pfErr!=NULL) fprintf(pfErr,"No end of headline found in manual page '%s'\n",psDoc->pcHdl);
1056  return(CLERTC_FAT);
1057  }
1058  int l=e-p;
1059  char acHdl[l+1];
1060  memcpy(acHdl,p,l);
1061  acHdl[l]=0x00;
1062  l=strlen(pcFil);
1063  char acFil[l+16];
1064  unsigned int uiHsh=fnvHash(l,(const unsigned char*)pcFil);
1065  for (i=0;i<l;i++) {
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]);
1072  } else {
1073  acFil[i]=psPar->siPr3;
1074  }
1075  }
1076  acFil[i]=0x00;
1077  snprintc(acFil,sizeof(acFil),"%c%04x",psPar->siPr3,uiHsh&0xFFFF);
1078  siErr=pfPrn(pvPrn,psDoc->uiLev,acHdl,NULL,acFil,psDoc->pcMan,pcPge);
1079  free(pcPge);
1080  if (siErr) {
1081  if (pfErr!=NULL) fprintf(pfErr,"Print page over call back function for command '%s' failed with %d\n",psDoc->pcHdl,siErr);
1082  return(CLERTC_MEM);
1083  }
1084  return(CLERTC_OK);
1085 }
1086 
1087 /***********************************************************************/
1088 
1089 static void* pfLoadHtmlDoc(TfCleOpenPrint** ppHtmlOpn, TfClpPrintPage** ppHtmlPrn, TfCleClosePrint** ppHtmlCls) {
1090 #ifdef __WIN__
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");
1095  *ppHtmlCls=(TfCleClosePrint*)GetProcAddress(pvHtmlDoc, "clsHtmlDoc");
1096 #else
1097  void* pvHtmlDoc=dlopen("libhtmldoc.so",RTLD_LAZY);
1098  if (pvHtmlDoc==NULL) return(NULL);
1099  *ppHtmlOpn=(TfCleOpenPrint* )dlsym(pvHtmlDoc, "opnHtmlDoc");
1100  *ppHtmlPrn=(TfClpPrintPage* )dlsym(pvHtmlDoc, "prnHtmlDoc");
1101  *ppHtmlCls=(TfCleClosePrint*)dlsym(pvHtmlDoc, "clsHtmlDoc");
1102 #endif
1103  return(pvHtmlDoc);
1104 }
1105 
1106 static void vdFreeHtmlDoc(void** ppLib) {
1107  if (ppLib!=NULL && *ppLib!=NULL) {
1108 #ifdef __WIN__
1109  FreeLibrary(*ppLib);
1110 #else
1111  dlclose(*ppLib);
1112 #endif
1113  *ppLib=NULL;
1114  }
1115 }
1116 
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);
1120  return(r-l);
1121 }
1122 
1123 static int siPrintDocu(
1124  void* pvGbl,
1125  FILE* pfOut,
1126  FILE* pfErr,
1127  const TsCleDoc* psDoc,
1128  TsCleDocPar* psPar,
1129  void* pvPrn,
1130  TfClpPrintPage* pfPrn)
1131 {
1132  if (psDoc!=NULL) {
1133  const char* apPat[8]={"","","","","","","",""};
1134  for (int i=0; psDoc[i].uiTyp && psDoc[i].uiLev>0 && psDoc[i].uiLev<7; i++) {
1135  int x=0;
1136  char acFil[1024]="";
1137  apPat[psDoc[i].uiLev]=psDoc[i].pcHdl;
1138  for (int j=1;j<=psDoc[i].uiLev;j++) {
1139  if (j>1) {
1140  if (x<sizeof(acFil)-1) {
1141  acFil[x]='\t';
1142  x++;
1143  }
1144  }
1145  for (int k=0;apPat[j][k];k++) {
1146  if (x<sizeof(acFil)-1) {
1147  acFil[x]=apPat[j][k];
1148  x++;
1149  }
1150  }
1151  }
1152  acFil[x]=0x00;
1153  int siErr=siClePrintPage(pfOut,pfErr,psDoc+i,acFil,psPar,pvPrn,pfPrn);
1154  if (siErr) return(siErr);
1155  if (psDoc[i].uiTyp==CLE_DOCTYP_COMMANDS) {
1156  for (int j=0;psPar->psCmd[j].pcKyw!=NULL;j++) {
1157  if (psPar->psCmd[j].siFlg) {
1158  void* pvClp=NULL;
1159  char acNum[64];
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);
1165  } else {
1166  snprintf(acNum,sizeof(acNum),"%d.",j+1);
1167  }
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);
1170  vdClpClose(pvClp,CLPCLS_MTD_ALL); pvClp=NULL;
1171  if (siErr<0) {
1172  if (pfErr!=NULL) fprintf(pfErr,"Creation of documentation for command '%s' failed\n",psPar->psCmd[j].pcKyw);
1173  return(CLERTC_SYN);
1174  }
1175  }
1176  }
1177  } else if (psDoc[i].uiTyp==CLE_DOCTYP_OTHERCLP) {
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");
1180  return(CLERTC_ITF);
1181  }
1182  for (int j=0;psPar->psOth[j].pcKyw!=NULL;j++) {
1183  void* pvClp=NULL;
1184  char acNum[64];
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);
1187  if (pvClp==NULL) {
1188  if (pfErr!=NULL) fprintf(pfErr,"Open of parser for CLP string of appendix '%s' failed\n",psPar->psOth[j].pcKyw);
1189  return(CLERTC_TAB);
1190  }
1191  if (psDoc[i].pcNum!=NULL && *psDoc[i].pcNum) {
1192  snprintf(acNum,sizeof(acNum),"%s%d.",psDoc[i].pcNum,j+1);
1193  } else {
1194  snprintf(acNum,sizeof(acNum),"%d.",j+1);
1195  }
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);
1198  vdClpClose(pvClp,CLPCLS_MTD_ALL); pvClp=NULL;
1199  if (siErr<0) {
1200  if (pfErr!=NULL) fprintf(pfErr,"Creation of documentation for other CLP string '%s' failed\n",psPar->psOth[j].pcKyw);
1201  return(CLERTC_SYN);
1202  }
1203  }
1204  }
1205  }
1206  } else {
1207  if (pfErr!=NULL) fprintf(pfErr,"No table for documentation generation given\n");
1208  return(CLERTC_TAB);
1209  }
1210  return(CLERTC_OK);
1211 }
1212 
1213 /***********************************************************************/
1214 
1215 extern int siCleExecute(
1216  void* pvGbl,
1217  const TsCleCommand* psCmd,
1218  int argc,
1219  char* argv[],
1220  const char* pcOwner,
1221  const char* pcProgram,
1222  const char* pcAut,
1223  const char* pcAdr,
1224  const int isCas,
1225  const int isPfl,
1226  const int isRpl,
1227  const int isEnv,
1228  const int siMkl,
1229  FILE* pfOut,
1230  FILE* pfTrc,
1231  const char* pcDep,
1232  const char* pcOpt,
1233  const char* pcEnt,
1234  const char* pcLic,
1235  const char* pcBld,
1236  const char* pcVsn,
1237  const char* pcAbo,
1238  const char* pcHlp,
1239  const char* pcDef,
1240  TfMsg* pfMsg,
1241  const TsCleOtherClp* psOth,
1242  void* pvF2S,
1243  TfF2S* pfF2S,
1244  void* pvSaf,
1245  TfSaf* pfSaf,
1246  const char* pcDpa,
1247  const int siNoR,
1248  const TsCleDoc* psDoc)
1249 {
1250  int i,j,l,siErr,siDep,siCnt;
1251  TsCnfHdl* psCnf=NULL;
1252  size_t szCnf=0;
1253  char* pcCnf=NULL;
1254  size_t szOwn=0;
1255  char* pcOwn=NULL;
1256  char* pcPgm=NULL;
1257  char* pcPgu=NULL;
1258  char* pcPgl=NULL;
1259  const char* pcMsg=NULL;
1260  FILE* pfTrh=NULL;
1261  void* pvHdl=NULL;
1262  FILE* pfDoc=NULL;
1263  FILE* pfPro=NULL;
1264  FILE* pfStd=(pfOut!=NULL)?pfOut:stderr;
1265  FILE* pfErr=(pfOut!=NULL)?pfOut:stderr;
1266  char** ppArg=NULL;
1267  size_t szFil=0;
1268  char* pcFil=NULL;
1269  char* pcHom=NULL;
1270  int isWrn=FALSE;
1271  int siScc=0;
1272  int isEnvOwn;
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;
1278  const char* m;
1279  char acTs[24];
1280  time_t uiTime=time(NULL);
1281  clock_t uiClock=clock();
1282 
1283  CLEBIF_OPN(asBif) = {
1284  CLETAB_BIF(CLE_BUILTIN_IDX_SYNTAX ,"SYNTAX" ,HLP_CLE_BUILTIN_SYNTAX ,SYN_CLE_BUILTIN_SYNTAX ,MAN_CLE_BUILTIN_SYNTAX ,TRUE)
1285  CLETAB_BIF(CLE_BUILTIN_IDX_HELP ,"HELP" ,HLP_CLE_BUILTIN_HELP ,SYN_CLE_BUILTIN_HELP ,MAN_CLE_BUILTIN_HELP ,TRUE)
1286  CLETAB_BIF(CLE_BUILTIN_IDX_MANPAGE ,"MANPAGE" ,HLP_CLE_BUILTIN_MANPAGE ,SYN_CLE_BUILTIN_MANPAGE ,MAN_CLE_BUILTIN_MANPAGE ,TRUE)
1287  CLETAB_BIF(CLE_BUILTIN_IDX_GENDOCU ,"GENDOCU" ,HLP_CLE_BUILTIN_GENDOCU ,SYN_CLE_BUILTIN_GENDOCU ,MAN_CLE_BUILTIN_GENDOCU ,TRUE)
1288  CLETAB_BIF(CLE_BUILTIN_IDX_HTMLDOC ,"HTMLDOC" ,HLP_CLE_BUILTIN_HTMLDOC ,SYN_CLE_BUILTIN_HTMLDOC ,MAN_CLE_BUILTIN_HTMLDOC ,TRUE)
1289  CLETAB_BIF(CLE_BUILTIN_IDX_GENPROP ,"GENPROP" ,HLP_CLE_BUILTIN_GENPROP ,SYN_CLE_BUILTIN_GENPROP ,MAN_CLE_BUILTIN_GENPROP ,TRUE)
1290  CLETAB_BIF(CLE_BUILTIN_IDX_SETPROP ,"SETPROP" ,HLP_CLE_BUILTIN_SETPROP ,SYN_CLE_BUILTIN_SETPROP ,MAN_CLE_BUILTIN_SETPROP ,TRUE)
1291  CLETAB_BIF(CLE_BUILTIN_IDX_CHGPROP ,"CHGPROP" ,HLP_CLE_BUILTIN_CHGPROP ,SYN_CLE_BUILTIN_CHGPROP ,MAN_CLE_BUILTIN_CHGPROP ,TRUE)
1292  CLETAB_BIF(CLE_BUILTIN_IDX_DELPROP ,"DELPROP" ,HLP_CLE_BUILTIN_DELPROP ,SYN_CLE_BUILTIN_DELPROP ,MAN_CLE_BUILTIN_DELPROP ,TRUE)
1293  CLETAB_BIF(CLE_BUILTIN_IDX_GETPROP ,"GETPROP" ,HLP_CLE_BUILTIN_GETPROP ,SYN_CLE_BUILTIN_GETPROP ,MAN_CLE_BUILTIN_GETPROP ,TRUE)
1294  CLETAB_BIF(CLE_BUILTIN_IDX_SETOWNER,"SETOWNER",HLP_CLE_BUILTIN_SETOWNER,SYN_CLE_BUILTIN_SETOWNER,MAN_CLE_BUILTIN_SETOWNER,TRUE)
1295  CLETAB_BIF(CLE_BUILTIN_IDX_GETOWNER,"GETOWNER",HLP_CLE_BUILTIN_GETOWNER,SYN_CLE_BUILTIN_GETOWNER,MAN_CLE_BUILTIN_GETOWNER,TRUE)
1296  CLETAB_BIF(CLE_BUILTIN_IDX_SETENV ,"SETENV" ,HLP_CLE_BUILTIN_SETENV ,SYN_CLE_BUILTIN_SETENV ,MAN_CLE_BUILTIN_SETENV ,TRUE)
1297  CLETAB_BIF(CLE_BUILTIN_IDX_GETENV ,"GETENV" ,HLP_CLE_BUILTIN_GETENV ,SYN_CLE_BUILTIN_GETENV ,MAN_CLE_BUILTIN_GETENV ,TRUE)
1298  CLETAB_BIF(CLE_BUILTIN_IDX_DELENV ,"DELENV" ,HLP_CLE_BUILTIN_DELENV ,SYN_CLE_BUILTIN_DELENV ,MAN_CLE_BUILTIN_DELENV ,TRUE)
1299  CLETAB_BIF(CLE_BUILTIN_IDX_TRACE ,"TRACE" ,HLP_CLE_BUILTIN_TRACE ,SYN_CLE_BUILTIN_TRACE ,MAN_CLE_BUILTIN_TRACE ,TRUE)
1300  CLETAB_BIF(CLE_BUILTIN_IDX_CONFIG ,"CONFIG" ,HLP_CLE_BUILTIN_CONFIG ,SYN_CLE_BUILTIN_CONFIG ,MAN_CLE_BUILTIN_CONFIG ,TRUE)
1301  CLETAB_BIF(CLE_BUILTIN_IDX_GRAMMAR ,"GRAMMAR" ,HLP_CLE_BUILTIN_GRAMMAR ,SYN_CLE_BUILTIN_GRAMMAR ,MAN_CLE_BUILTIN_GRAMMAR ,TRUE)
1302  CLETAB_BIF(CLE_BUILTIN_IDX_LEXEMES ,"LEXEMES" ,HLP_CLE_BUILTIN_LEXEMES ,SYN_CLE_BUILTIN_LEXEMES ,MAN_CLE_BUILTIN_LEXEMES ,TRUE)
1303  CLETAB_BIF(CLE_BUILTIN_IDX_LICENSE ,"LICENSE" ,HLP_CLE_BUILTIN_LICENSE ,SYN_CLE_BUILTIN_LICENSE ,MAN_CLE_BUILTIN_LICENSE ,pcLic!=NULL)
1304  CLETAB_BIF(CLE_BUILTIN_IDX_VERSION ,"VERSION" ,HLP_CLE_BUILTIN_VERSION ,SYN_CLE_BUILTIN_VERSION ,MAN_CLE_BUILTIN_VERSION ,pcVsn!=NULL)
1305  CLETAB_BIF(CLE_BUILTIN_IDX_ABOUT ,"ABOUT" ,HLP_CLE_BUILTIN_ABOUT ,SYN_CLE_BUILTIN_ABOUT ,MAN_CLE_BUILTIN_ABOUT ,pcAbo!=NULL)
1306  CLETAB_BIF(CLE_BUILTIN_IDX_ERRORS ,"ERRORS" ,HLP_CLE_BUILTIN_ERRORS ,SYN_CLE_BUILTIN_ERRORS ,MAN_CLE_BUILTIN_ERRORS ,TRUE)
1307  CLEBIF_CLS
1308  };
1309 
1310  if (argc>0) {
1311  if (strxcmp(isCas,argv[argc-1],"SILENT",0,0,FALSE)==0) {
1312  pfErr=NULL;
1313  pfOut=NULL;
1314  argc--;
1315  } else if (strxcmp(isCas,argv[argc-1],"QUIET",0,0,FALSE)==0) {
1316  pfErr=pfOut;
1317  pfOut=NULL;
1318  argc--;
1319  }
1320  }
1321 
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");
1325  ERROR(CLERTC_FAT,NULL);
1326  }
1327 
1328 #ifdef __WIN__
1329  char* pcwinvers = NULL;
1330  size_t szwv = 0;
1331  if (pfOut!=NULL) efprintf(pfOut,"%s Run on %s\n",cstime(0,acTs),windowsversionstring(&pcwinvers, &szwv));
1332  if (pcwinvers != NULL) free(pcwinvers);
1333 #else
1334  struct utsname uts;
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);
1337  }
1338 #endif
1339 
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__);
1341 
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);
1345  ERROR(CLERTC_TAB,NULL);
1346  }
1347  }
1348 
1349  for (i=0;psDoc[i].uiTyp;i++) {
1350  if (psDoc[i].uiTyp==CLE_DOCTYP_PROGRAM) {
1351  pcPgmNum=psDoc[i].pcNum;
1352  }
1353  if (psDoc[i].uiTyp==CLE_DOCTYP_COMMANDS) {
1354  pcCmdNum=psDoc[i].pcNum;
1355  }
1356  if (psDoc[i].uiTyp==CLE_DOCTYP_BUILTIN) {
1357  pcBifNum=psDoc[i].pcNum;
1358  }
1359  if (psDoc[i].uiTyp==CLE_DOCTYP_PROGRAM) {
1360  pcPgmMan=psDoc[i].pcMan;
1361  }
1362  if (psDoc[i].uiTyp==CLE_DOCTYP_SPECIALCODES) {
1363  pcSccMan=psDoc[i].pcMan;
1364  }
1365  }
1366 
1367  if (pfF2S==NULL) {
1368  pvF2S=NULL;
1369  pfF2S=siClpFile2String;
1370  }
1371 
1372  if (isEnv) {
1373  siErr = readEnvars(NULL,pfOut,pfErr,NULL);
1374  if (siErr<0) return(-1*siErr);
1375  }
1376 
1377  pcHom=dhomedir(TRUE);
1378  if (pcHom==NULL) {
1379  if (pfErr!=NULL) fprintf(pfErr,"Determination of home directory failed\n");
1380  ERROR(CLERTC_MEM,NULL);
1381  }
1382 
1383  pcPgm=dmapstr(pcProgram,0);
1384  if (pcPgm==NULL) {
1385  if (pfErr!=NULL) fprintf(pfErr,"Conversion of program name failed (not enough memory)\n");
1386  ERROR(CLERTC_MEM,NULL);
1387  }
1388 
1389  pcPgu=dmapstr(pcProgram,1);
1390  if (pcPgu==NULL) {
1391  if (pfErr!=NULL) fprintf(pfErr,"Conversion of program name to upper case failed (not enough memory)\n");
1392  ERROR(CLERTC_MEM,NULL);
1393  }
1394 
1395  pcPgl=dmapstr(pcProgram,2);
1396  if (pcPgl==NULL) {
1397  if (pfErr!=NULL) fprintf(pfErr,"Conversion of program name to lower case failed (not enough memory)\n");
1398  ERROR(CLERTC_MEM,NULL);
1399  }
1400 
1401  srprintf(&pcCnf,&szCnf,strlen(pcPgm),"%s_DEFAULT_OWNER_ID",pcPgu);
1402  if (pcCnf==NULL) {
1403  if (pfErr!=NULL) fprintf(pfErr,"Memory allocation for %s_DEFAULT_OWNER_ID failed\n",pcPgu);
1404  ERROR(CLERTC_MEM,NULL);
1405  }
1406  m=GETENV(pcCnf);
1407  if (m!=NULL && *m) srprintf(&pcOwn,&szOwn,strlen(m),"%s",m); else srprintf(&pcOwn,&szOwn,strlen(pcOwner),"%s",pcOwner);
1408  if (pcOwn==NULL) {
1409  if (pfErr!=NULL) fprintf(pfErr,"Determination of owner id failed\n");
1410  ERROR(CLERTC_MEM,NULL);
1411  }
1412 
1413  psCnf=psOpenConfig(pfOut,pfErr,pcHom,pcPgm,pcPgu,pcPgl,isCas);
1414  if (psCnf==NULL) ERROR(CLERTC_CFG,NULL);
1415 
1416  srprintf(&pcCnf,&szCnf,strlen(pcPgl),"%s.owner.id",pcPgl);
1417  if (pcCnf==NULL) {
1418  if (pfErr!=NULL) fprintf(pfErr,"Memory allocation for configuration element owner id failed\n");
1419  ERROR(CLERTC_MEM,NULL);
1420  }
1421  m=pcCnfGet(psCnf,pcCnf);
1422  if (m!=NULL && *m) {
1423  srprintf(&pcOwn,&szOwn,strlen(m),"%s",m);
1424  if (pcOwn==NULL) {
1425  if (pfErr!=NULL) fprintf(pfErr,"Memory allocation for owner name (%s) failed\n",m);
1426  ERROR(CLERTC_MEM,NULL);
1427  }
1428  }
1429 
1430  i=siCnfPutEnv(psCnf,pcOwn,pcPgm);
1431  if (pfOut!=NULL) {
1432  if (i) {
1433  if (i==1) {
1434  fprintf(pfOut,"%s Load successfully %d environment variable using the configuration file.\n",cstime(0,acTs),i);
1435  } else {
1436  fprintf(pfOut,"%s Load successfully %d environment variables using the configuration file.\n",cstime(0,acTs),i);
1437  }
1438  }
1439  }
1440 
1441  m=GETENV("OWNERID");
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));
1445  } else {
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");
1448  } else {
1449 #ifdef __DEBUG__
1450  if (pfOut!=NULL) fprintf(pfOut,"%s Put variable (%s=%s) to environment was successful\n",cstime(0,acTs),"OWNERID",pcOwn);
1451 #endif
1452  }
1453  }
1454  isEnvOwn=TRUE;
1455  } else {
1456 #ifdef __DEBUG__
1457  if (pfOut!=NULL) fprintf(pfOut,"%s Environment variable OWNERID already defined (%s)\n",cstime(0,acTs),pcOwn);
1458 #endif
1459  isEnvOwn=FALSE;
1460  }
1461 
1462  if (pfOut!=NULL) {
1463  fprintf(pfOut,"%s Complete load of environment ...\n",cstime(0,acTs));
1464 #ifdef __EBCDIC__
1465  init_char(gsDiaChr.exc);
1466 #endif
1467  efprintf(pfOut,"%s Initialize dia-critical character (!$#@[\\]^`{|}~) conversion (%s)\n",cstime(0,acTs),mapccsid(localccsid()));
1468  }
1469 
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);
1476  pcDep=acDep;
1477  pcOpt=acOpt;
1478  pcEnt=acEnt;
1479 
1480  srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgl),"%s.%s.trace",pcOwn,pcPgl);
1481  if (pcCnf==NULL) {
1482  if (pfErr!=NULL) fprintf(pfErr,"Memory allocation for configuration element trace failed\n");
1483  ERROR(CLERTC_MEM,NULL);
1484  }
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);
1488  if (pcCnf==NULL) {
1489  if (pfErr!=NULL) fprintf(pfErr,"Memory allocation for configuration element trace file failed\n");
1490  ERROR(CLERTC_MEM,NULL);
1491  }
1492  m=pcCnfGet(psCnf,pcCnf);
1493  if (m!=NULL && *m) {
1494  pcFil=dcpmapfil(m);
1495  if (pcFil!=NULL) {
1496  pfTrh=fopen_hfq(pcFil,"w");
1497  if (pfTrh==NULL) {
1498  if (pfErr!=NULL) fprintf(pfErr,"Open of trace file (\"%s\",\"%s\") failed\n",pcFil,"w");
1499  } else pfTrc=pfTrh;
1500  SAFE_FREE(pcFil);
1501  }
1502  }
1503  } else pfTrc=NULL;
1504 
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);
1510  ERROR(CLERTC_TAB,NULL);
1511  }
1512  }
1513  if (i==0) {
1514  if (pfErr!=NULL) fprintf(pfErr,"Command table is empty\n");
1515  ERROR(CLERTC_TAB,NULL);
1516  }
1517 
1518  if (argc<2) {
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);
1523  ERROR(CLERTC_MEM,NULL);
1524  }
1525  ppArg[0]=argv[0]; ppArg[1]=(char*)pcDef; argc=2; argv=ppArg;
1526  } else {
1527  if (pfErr!=NULL) {
1528  fprintf(pfErr,"Command or built-in function required\n");
1529  vdPrnStaticSyntax(pfErr,psCmd,asBif,argv[0],pcDep,pcOpt,pcDpa);
1530  }
1531  ERROR(CLERTC_CMD,NULL);
1532  }
1533  }
1534 
1535  if (argv[1][0]=='-') argv[1]++;
1536  if (argv[1][0]=='-') argv[1]++;
1537 
1538 EVALUATE:
1539  if (asBif[CLE_BUILTIN_IDX_LICENSE].isBif && strxcmp(isCas,argv[1],"LICENSE",0,0,FALSE)==0) {
1540  if (pfOut==NULL) pfOut=pfStd;
1541  if (pfErr==NULL) pfErr=pfStd;
1542  if (argc==2) {
1543  fprintf(pfOut,"License of program '%s':\n",pcPgm);
1544  if (pcLic==NULL) {
1545  fprintf(pfOut,"No license information available\n");
1546  } else {
1547  fprintf(pfOut,"%s\n",pcLic);
1548  }
1549  ERROR(CLERTC_OK,NULL);
1550  }
1551  fprintf(pfErr,"Syntax for built-in function 'LICENSE' not valid\n");
1552  fprintf(pfErr,"%s %s LICENSE\n",pcDep,argv[0]);
1553  ERROR(CLERTC_CMD,NULL);
1554  } else if (asBif[CLE_BUILTIN_IDX_VERSION].isBif && strxcmp(isCas,argv[1],"VERSION",0,0,FALSE)==0) {
1555  if (pfOut==NULL) pfOut=pfStd;
1556  if (pfErr==NULL) pfErr=pfStd;
1557  if (argc==2) {
1558  fprintf(pfOut,"Version for program '%s':\n",pcPgm);
1559  if (pcVsn==NULL) {
1560  fprintf(pfOut,"No version information available\n");
1561  } else {
1562  fprintf(pfOut,"%s\n",pcVsn);
1563  }
1564  ERROR(CLERTC_OK,NULL);
1565  }
1566  fprintf(pfErr,"Syntax for built-in function 'VERSION' not valid\n");
1567  fprintf(pfErr,"%s %s VERSION\n",pcDep,argv[0]);
1568  ERROR(CLERTC_CMD,NULL);
1569  } else if (asBif[CLE_BUILTIN_IDX_ABOUT].isBif && strxcmp(isCas,argv[1],"ABOUT",0,0,FALSE)==0) {
1570  if (pfOut==NULL) pfOut=pfStd;
1571  if (pfErr==NULL) pfErr=pfStd;
1572  if (argc==2) {
1573  fprintf(pfOut,"About program '%s':\n",pcPgm);
1574  if (pcAbo==NULL) {
1575  fprintf(pfOut,"No about information available\n");
1576  } else {
1577  fprintf(pfOut,"%s\n",pcAbo);
1578  }
1579  ERROR(CLERTC_OK,NULL);
1580  }
1581  fprintf(pfErr,"Syntax for built-in function 'ABOUT' not valid\n");
1582  fprintf(pfErr,"%s %s ABOUT\n",pcDep,argv[0]);
1583  ERROR(CLERTC_CMD,NULL);
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;
1587  if (argc==2) {
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");
1591  siErr=siClpLexemes(pvHdl,pfOut);
1592  if (siErr<0) ERROR(CLERTC_SYN,NULL); else ERROR(CLERTC_OK,NULL);
1593  }
1594  fprintf(pfErr,"Syntax for built-in function 'LEXEMES' not valid\n");
1595  fprintf(pfErr,"%s %s LEXEMES\n",pcDep,argv[0]);
1596  ERROR(CLERTC_CMD,NULL);
1597  } else if (asBif[CLE_BUILTIN_IDX_GRAMMAR].isBif && strxcmp(isCas,argv[1],"GRAMMAR",0,0,FALSE)==0) {
1598  if (pfOut==NULL) pfOut=pfStd;
1599  if (pfErr==NULL) pfErr=pfStd;
1600  if (argc==2) {
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");
1604  siErr=siClpGrammar(pvHdl,pfOut);
1605  if (siErr<0) ERROR(CLERTC_SYN,NULL); else ERROR(CLERTC_OK,NULL);
1606  }
1607  fprintf(pfErr,"Syntax for built-in function 'GRAMMAR' not valid\n");
1608  fprintf(pfErr,"%s %s GRAMMAR\n",pcDep,argv[0]);
1609  ERROR(CLERTC_CMD,NULL);
1610  } else if (asBif[CLE_BUILTIN_IDX_ERRORS].isBif && strxcmp(isCas,argv[1],"ERRORS",0,0,FALSE)==0) {
1611  if (pfOut==NULL) pfOut=pfStd;
1612  if (pfErr==NULL) pfErr=pfStd;
1613  if (argc==2) {
1614  efprintf(pfOut,"\n");
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);
1622  }
1623  if (pfMsg!=NULL) {
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);
1629  }
1630  }
1631  ERROR(CLERTC_OK,NULL);
1632  }
1633  fprintf(pfErr,"Syntax for built-in function 'ERRORS' not valid\n");
1634  fprintf(pfErr,"%s %s ERRORS\n",pcDep,argv[0]);
1635  ERROR(CLERTC_CMD,NULL);
1636  } else if (asBif[CLE_BUILTIN_IDX_SYNTAX].isBif && strxcmp(isCas,argv[1],"SYNTAX",0,0,FALSE)==0) {
1637  if (pfOut==NULL) pfOut=pfStd;
1638  if (pfErr==NULL) pfErr=pfStd;
1639  if (argc==2) {
1640  fprintf(pfOut,"Syntax for program '%s':\n",pcPgm);
1641  vdPrnStaticSyntax(pfOut,psCmd,asBif,argv[0],pcDep,pcOpt,pcDpa);
1642  ERROR(CLERTC_OK,NULL);
1643  } else if (argc>=3) {
1644  if (argc==3) {
1645  siDep=1;
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) {
1650  siDep=10;
1651  } else if (strxcmp(isCas,argv[3],"DEPTH1",0,0,FALSE)==0) {
1652  siDep=1;
1653  } else if (strxcmp(isCas,argv[3],"DEPTH2",0,0,FALSE)==0) {
1654  siDep=2;
1655  } else if (strxcmp(isCas,argv[3],"DEPTH3",0,0,FALSE)==0) {
1656  siDep=3;
1657  } else if (strxcmp(isCas,argv[3],"DEPTH4",0,0,FALSE)==0) {
1658  siDep=4;
1659  } else if (strxcmp(isCas,argv[3],"DEPTH5",0,0,FALSE)==0) {
1660  siDep=5;
1661  } else if (strxcmp(isCas,argv[3],"DEPTH6",0,0,FALSE)==0) {
1662  siDep=6;
1663  } else if (strxcmp(isCas,argv[3],"DEPTH7",0,0,FALSE)==0) {
1664  siDep=7;
1665  } else if (strxcmp(isCas,argv[3],"DEPTH8",0,0,FALSE)==0) {
1666  siDep=8;
1667  } else if (strxcmp(isCas,argv[3],"DEPTH9",0,0,FALSE)==0) {
1668  siDep=9;
1669  } else {
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");
1675  }
1676  }
1677  ERROR(CLERTC_CMD,NULL);
1678  }
1679  } else {
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");
1685  }
1686  }
1687  ERROR(CLERTC_CMD,NULL);
1688  }
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]);
1696  } else {
1697  fprintf(pfOut,"Syntax for argument '%s':\n",argv[2]);
1698  }
1699  vdPrnCommandSyntax(pvHdl,pfOut,argv[0],argv[2],pcDep,siDep);
1700  ERROR(CLERTC_OK,NULL);
1701  }
1702  }
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);
1713  ERROR(CLERTC_OK,NULL);
1714  }
1715  }
1716  }
1717  }
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");
1723  }
1724  }
1725  ERROR(CLERTC_CMD,NULL);
1726  } else if (asBif[CLE_BUILTIN_IDX_HELP].isBif && strxcmp(isCas,argv[1],"HELP",0,0,FALSE)==0) {
1727  if (pfOut==NULL) pfOut=pfStd;
1728  if (pfErr==NULL) pfErr=pfStd;
1729  if (argc==2) {
1730  fprintf(pfOut,"Help for program '%s':\n",pcPgm);
1731  vdPrnStaticHelp(pfOut,psCmd,asBif,argv[0],pcDep);
1732  ERROR(CLERTC_OK,NULL);
1733  } else if (argc>=3) {
1734  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);
1739  ERROR(CLERTC_OK,NULL);
1740  } else {
1741  fprintf(pfErr,"No manual page available for program '%s'\n",pcPgm);
1742  fprintf(pfErr,"CLE_DOCTYP_PROGRAM not found in documentation table\n");
1743  ERROR(CLERTC_TAB,NULL);
1744  }
1745  } else siDep=1;
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) {
1750  siDep=0;
1751  } else if (strxcmp(isCas,argv[3],"DEPTH1",0,0,FALSE)==0) {
1752  siDep=1;
1753  } else if (strxcmp(isCas,argv[3],"DEPTH2",0,0,FALSE)==0) {
1754  siDep=2;
1755  } else if (strxcmp(isCas,argv[3],"DEPTH3",0,0,FALSE)==0) {
1756  siDep=3;
1757  } else if (strxcmp(isCas,argv[3],"DEPTH4",0,0,FALSE)==0) {
1758  siDep=4;
1759  } else if (strxcmp(isCas,argv[3],"DEPTH5",0,0,FALSE)==0) {
1760  siDep=5;
1761  } else if (strxcmp(isCas,argv[3],"DEPTH6",0,0,FALSE)==0) {
1762  siDep=6;
1763  } else if (strxcmp(isCas,argv[3],"DEPTH7",0,0,FALSE)==0) {
1764  siDep=7;
1765  } else if (strxcmp(isCas,argv[3],"DEPTH8",0,0,FALSE)==0) {
1766  siDep=8;
1767  } else if (strxcmp(isCas,argv[3],"DEPTH9",0,0,FALSE)==0) {
1768  siDep=9;
1769  } else if (strxcmp(isCas,argv[3],"ALL",0,0,FALSE)==0) {
1770  siDep=10;
1771  } else {
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");
1777  }
1778  }
1779  ERROR(CLERTC_CMD,NULL);
1780  }
1781  } else {
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");
1787  }
1788  }
1789  ERROR(CLERTC_CMD,NULL);
1790  }
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);
1798  } else {
1799  fprintf(pfOut,"Help for argument '%s': %s\n",argv[2],pcClpInfo(pvHdl,argv[2]));
1800  }
1801  vdPrnCommandHelp(pvHdl,argv[2],siDep,siDep>9,TRUE);
1802  if (siDep==0) {
1803  fprintf(pfOut,"ARGUMENTS\n");
1804  fprintf(pfOut,"---------\n");
1805  vdPrnCommandHelp(pvHdl,argv[2],1,TRUE,FALSE);
1806  }
1807  ERROR(CLERTC_OK,NULL);
1808  }
1809  }
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);
1820  if (siDep==0) {
1821  fprintf(pfOut,"ARGUMENTS\n");
1822  fprintf(pfOut,"---------\n");
1823  vdPrnCommandHelp(pvHdl,acPat,1,TRUE,FALSE);
1824  }
1825  ERROR(CLERTC_OK,NULL);
1826  }
1827  }
1828  }
1829  }
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");
1835  }
1836  }
1837  ERROR(CLERTC_CMD,NULL);
1838  } else if (asBif[CLE_BUILTIN_IDX_MANPAGE].isBif && strxcmp(isCas,argv[1],"MANPAGE",0,0,FALSE)==0) {
1839  if (pfOut==NULL) pfOut=pfStd;
1840  if (pfErr==NULL) pfErr=pfStd;
1841  if (argc==2) {
1842  if (pfOut!=NULL) {
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);
1846  ERROR(CLERTC_OK,NULL);
1847  } else {
1848  fprintf(pfErr,"No manual page available for program '%s'\n",pcPgm);
1849  fprintf(pfErr,"CLE_DOCTYP_PROGRAM not found in documentation table\n");
1850  ERROR(CLERTC_TAB,NULL);
1851  }
1852  }
1853  } else if (argc==3) {
1854  const char* pcSgn;
1855  const char* pcCmd;
1856  int isMan=FALSE;
1857  int isAll=FALSE;
1858  pcSgn=strchr(argv[2],'=');
1859  if (pcSgn!=NULL) {
1860  *((char*)pcSgn)=EOS; pcSgn++; pcCmd=argv[2]; isMan=TRUE;
1861  pcFil=dcpmapfil(pcSgn);
1862  if (pcFil==NULL) {
1863  fprintf(pfErr,"Allocation of memory for file name (%s) failed\n",pcSgn);
1864  ERROR(CLERTC_MEM,NULL);
1865  }
1866 // szFil=strlen(pcFil)+1; not used
1867  pfDoc=fopen_hfq(pcFil,"w");
1868  if (pfDoc==NULL) {
1869  fprintf(pfErr,"Open of manual page file (\"%s\",\"%s\") failed (%d - %s)\n",pcFil,"w",errno,strerror(errno));
1870  ERROR(CLERTC_SYS,NULL);
1871  }
1872  } else {
1873  pcCmd=argv[2];
1874  isMan=FALSE;
1875  pfDoc=pfOut;
1876  srprintf(&pcFil,&szFil,0,":STDOUT:");
1877  if (pcFil==NULL) {
1878  fprintf(pfErr,"Allocation of memory for file name (:STDOUT:) failed\n");
1879  ERROR(CLERTC_MEM,NULL);
1880  }
1881  }
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) {
1884  isAll=TRUE;
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);
1888  } else {
1889  fprintf(pfErr,"No manual page available for program '%s'\n",pcPgm);
1890  fprintf(pfErr,"CLE_DOCTYP_PROGRAM not found in documentation table\n");
1891  ERROR(CLERTC_TAB,NULL);
1892  }
1893  }
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) {
1897  char acNum[16];
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);
1902  if (isAll==FALSE) ERROR(CLERTC_OK,NULL);
1903  }
1904  }
1905  }
1906  for (i=0;psCmd[i].pcKyw!=NULL;i++) {
1907  if (isAll) {
1908  if (psCmd[i].siFlg) {
1909  pcCmd=psCmd[i].pcKyw;
1910  } else {
1911  pcCmd="";
1912  }
1913  }
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);
1918  if (isMan==FALSE) {
1919  if (strlen(pcCmd)==strlen(psCmd[i].pcKyw)) {
1920  fprintf(pfOut,"Manual page for command '%s':\n\n",pcCmd);
1921  } else {
1922  fprintf(pfOut,"Manual page for argument '%s':\n\n",pcCmd);
1923  }
1924  }
1925  vdPrnCommandManpage(pvHdl,pfDoc,pcCmdNum,pcCmd,i,isMan,TRUE);
1926  vdClpClose(pvHdl,CLPCLS_MTD_ALL); pvHdl=NULL;
1927  if (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);
1930  } else {
1931  fprintf(pfOut,"Manual page for argument '%s' successfully written to file (%s)\n",pcCmd,pcFil);
1932  }
1933  }
1934  if (isAll==FALSE) ERROR(CLERTC_OK,NULL);
1935  }
1936  }
1937  if (isAll==TRUE) ERROR(CLERTC_OK,NULL);
1938 
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);
1949  if (isMan==TRUE) {
1950  fprintf(pfOut,"Manual page for argument '%s' successfully written to file (%s)\n",acPat,pcFil);
1951  }
1952  ERROR(CLERTC_OK,NULL);
1953  }
1954  }
1955  }
1956  SAFE_FREE(pcFil);
1957 
1958  pcFil=dcpmapfil(argv[2]);
1959  if (pcFil==NULL) {
1960  fprintf(pfErr,"Allocation of memory for file name (%s) failed\n",argv[2]);
1961  ERROR(CLERTC_MEM,NULL);
1962  }
1963 // szFil=strlen(pcFil)+1; not used
1964  isMan=TRUE;
1965  pfDoc=fopen_hfq(pcFil,"w");
1966  if (pfDoc==NULL) {
1967  fprintf(pfErr,"Open of manual page file (\"%s\",\"%s\") failed (%d - %s)\n",pcFil,"w",errno,strerror(errno));
1968  ERROR(CLERTC_SYS,NULL);
1969  }
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);
1973  ERROR(CLERTC_OK,NULL);
1974  } else {
1975  fprintf(pfErr,"No manual page available for program '%s'\n",pcPgm);
1976  fprintf(pfErr,"CLE_DOCTYP_PROGRAM not found in documentation table\n");
1977  ERROR(CLERTC_TAB,NULL);
1978  }
1979  }
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);
1984  efprintf(pfErr,"[.path]\n");
1985  }
1986  }
1987  fprintf(pfErr,"%s %s MANPAGE function\n",pcDep,argv[0]);
1988  fprintf(pfErr,"%s %s MANPAGE\n",pcDep,argv[0]);
1989  ERROR(CLERTC_CMD,NULL);
1990  } else if (asBif[CLE_BUILTIN_IDX_GENDOCU].isBif && strxcmp(isCas,argv[1],"GENDOCU",0,0,FALSE)==0) {
1991  const char* pcCmd=NULL;
1992  const char* pcSgn=NULL;
1993  int isNbr=TRUE;
1994  int isDep=TRUE;
1995  if (pfOut==NULL) pfOut=pfStd;
1996  if (pfErr==NULL) pfErr=pfStd;
1997  if (argc==3 || argc==4 || argc==5) {
1998  if (argc==4) {
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) {
2002  isNbr=FALSE;
2003  } else if(strxcmp(isCas,argv[3],"SHORT",0,0,FALSE)==0) {
2004  isDep=FALSE;
2005  } else {
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);
2010  }
2011  }
2012  efprintf(pfErr,"%s %s GENDOCU filename [NONBR][SHORT]\n",pcDep,argv[0]);
2013  ERROR(CLERTC_CMD,NULL);
2014  }
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) {
2021  isNbr=FALSE;
2022  isDep=FALSE;
2023  } else if(strxcmp(isCas,argv[3],"SHORT",0,0,FALSE)==0 && strxcmp(isCas,argv[4],"NONBR",0,0,FALSE)==0) {
2024  isNbr=FALSE;
2025  isDep=FALSE;
2026  } else {
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);
2031  }
2032  }
2033  efprintf(pfErr,"%s %s GENDOCU filename [NONBR][SHORT]\n",pcDep,argv[0]);
2034  ERROR(CLERTC_CMD,NULL);
2035  }
2036  }
2037  pcSgn=strchr(argv[2],'=');
2038  if (pcSgn!=NULL) {
2039  *((char*)pcSgn)=EOS; pcSgn++; pcCmd=argv[2];
2040  } else {
2041  pcSgn=argv[2]; pcCmd=NULL;
2042  }
2043  pcFil=dcpmapfil(pcSgn);
2044  if (pcFil==NULL) {
2045  fprintf(pfErr,"Allocation of memory for file name (%s) failed\n",pcSgn);
2046  ERROR(CLERTC_MEM,NULL);
2047  }
2048  szFil=strlen(pcFil)+1;
2049  pfDoc=fopen_hfq(pcFil,"w");
2050  if (pfDoc==NULL) {
2051  fprintf(pfErr,"Open of documentation file (\"%s\",\"%s\") failed (%d - %s)\n",pcFil,"w",errno,strerror(errno));
2052  ERROR(CLERTC_SYS,NULL);
2053  }
2054  if (pcCmd!=NULL) {
2055  for (i=0;psCmd[i].pcKyw!=NULL;i++) {
2056  if (strxcmp(isCas,pcCmd,psCmd[i].pcKyw,strlen(psCmd[i].pcKyw),'.',TRUE)==0) {
2057  char acNum[64];
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);
2063  if (siErr<0) {
2064  fprintf(pfErr,"Creation of documentation file (%s) failed (%d - %s)\n",pcFil,errno,strerror(errno));
2065  ERROR(CLERTC_SYN,NULL);
2066  } else {
2067  if (strlen(pcCmd)==strlen(psCmd[i].pcKyw)) {
2068  fprintf(pfOut,"Documentation for command '%s' successfully created\n",pcCmd);
2069  } else {
2070  fprintf(pfOut,"Documentation for argument '%s' successfully created\n",pcCmd);
2071  }
2072  ERROR(CLERTC_OK,NULL);
2073  }
2074  }
2075  }
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) {
2079  char acNum[64];
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);
2087  if (siErr<0) {
2088  fprintf(pfErr,"Creation of documentation file (%s) failed (%d - %s)\n",pcFil,errno,strerror(errno));
2089  ERROR(CLERTC_SYN,NULL);
2090  } else {
2091  fprintf(pfOut,"Documentation for argument '%s' successfully created\n",acPat);
2092  ERROR(CLERTC_OK,NULL);
2093  }
2094  }
2095  }
2096  }
2097  } else {
2098  TsCleDocPar stDocPar;
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);
2109  if (siErr) {
2110  fprintf(pfErr,"Generation of documentation for program '%s' failed\n",pcPgm);
2111  ERROR(siErr,NULL);
2112  } else {
2113  fprintf(pfOut,"Documentation for program '%s' successfully created\n",pcPgm);
2114  ERROR(CLERTC_OK,NULL);
2115  }
2116  }
2117  }
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");
2123  }
2124  }
2125  efprintf(pfErr,"%s %s GENDOCU filename [NONBR][SHORT]\n",pcDep,argv[0]);
2126  ERROR(CLERTC_CMD,NULL);
2127  } else if (asBif[CLE_BUILTIN_IDX_HTMLDOC].isBif && strxcmp(isCas,argv[1],"HTMLDOC",0,0,FALSE)==0) {
2128  int isPat=FALSE;
2129  const char* pcPar=".";
2130  int isNbr=FALSE;
2131  int isDep=TRUE;
2132  int isShl=TRUE;
2133  if (pfOut==NULL) pfOut=pfStd;
2134  if (pfErr==NULL) pfErr=pfStd;
2135  if (argc>6) {
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);
2138  ERROR(CLERTC_CMD,NULL);
2139  }
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) {
2144  isNbr=TRUE;
2145  } else if (strxcmp(isCas,argv[i],"TYPES",0,0,FALSE)==0) {
2146  isShl=FALSE;
2147  } else if (strxcmp(isCas,argv[i],"SHORT",0,0,FALSE)==0) {
2148  isDep=FALSE;
2149  } else {
2150  if (isPat) {
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);
2153  ERROR(CLERTC_CMD,NULL);
2154  }
2155  pcPar=argv[i];
2156  isPat=TRUE;
2157  }
2158  }
2159  TfCleOpenPrint* pfHtmlOpn=NULL;
2160  TfClpPrintPage* pfHtmlPrn=NULL;
2161  TfCleClosePrint* pfHtmlCls=NULL;
2162  char* pcPat=dcpmapfil(pcPar);
2163  if (pcPat==NULL) {
2164  fprintf(pfErr,"Allocation of memory for path name (%s) failed\n",pcHlp);
2165  ERROR(CLERTC_MEM,NULL);
2166  }
2167  void* pvLib=pfLoadHtmlDoc(&pfHtmlOpn,&pfHtmlPrn,&pfHtmlCls);
2168  if (pvLib==NULL) {
2169  fprintf(pfErr,"There is no service provider DLL/SO (libhtmldoc) available for HTML generation\n");
2170  ERROR(CLERTC_FAT,pcPat);
2171  }
2172  TsCleDocPar stDocPar;
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");
2186  ERROR(CLERTC_FAT,pcPat);
2187  }
2188  siErr=siPrintDocu(pvGbl,pfOut,pfErr,psDoc,&stDocPar,pvDocHdl,pfHtmlPrn);
2189  if (siErr) {
2190  fprintf(pfErr,"Generation of %s HTML documentation to folder '%s' failed\n",isDep?"long":"short",pcPat);
2191  pfHtmlCls(pvDocHdl);
2192  ERROR(siErr,pcPat);
2193  }
2194  siErr=pfHtmlCls(pvDocHdl);
2195  if (siErr) {
2196  fprintf(pfErr,"Finalise generation of HTML documentation to folder '%s' failed (%d)\n",pcPat,siErr);
2197  ERROR(CLERTC_SYS,pcPat);
2198  } else {
2199  fprintf(pfErr,"Generation of %s HTML documentation to folder '%s' was successful\n",isDep?"long":"short",pcPat);
2200  ERROR(CLERTC_OK,pcPat);
2201  }
2202  } else {
2203  vdFreeHtmlDoc(&pvLib);
2204  fprintf(pfErr,"There is no service provider function (opnHtmlDoc, prnHtmlDoc or clsHtmlDoc) available for HTML generation\n");
2205  ERROR(CLERTC_FAT,pcPat);
2206  }
2207  } else if (asBif[CLE_BUILTIN_IDX_GENPROP].isBif && strxcmp(isCas,argv[1],"GENPROP",0,0,FALSE)==0) {
2208  if (pfOut==NULL) pfOut=pfStd;
2209  if (pfErr==NULL) pfErr=pfStd;
2210  if (argc==3) {
2211  const char* pcSgn;
2212  const char* pcCmd;
2213  pcSgn=strchr(argv[2],'=');
2214  if (pcSgn!=NULL) {
2215  *((char*)pcSgn)=EOS; pcSgn++; pcCmd=argv[2];
2216  } else {
2217  pcSgn=argv[2]; pcCmd=NULL;
2218  }
2219  pcFil=dcpmapfil(pcSgn);
2220  if (pcFil==NULL) {
2221  fprintf(pfErr,"Allocation of memory for file name (%s) failed\n",pcSgn);
2222  ERROR(CLERTC_MEM,NULL);
2223  }
2224  szFil=strlen(pcFil)+1;
2225  pfPro=fopen_hfq(pcFil,"w");
2226  if (pfPro==NULL) {
2227  fprintf(pfErr,"Open of property file (\"%s\",\"%s\") failed (%d-%s)\n",pcFil,"w",errno,strerror(errno));
2228  ERROR(CLERTC_SYS,NULL);
2229  }
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);
2233 
2234  if (pcCmd==NULL) {
2235  for (siErr=CLP_OK, i=0;psCmd[i].pcKyw!=NULL && siErr==CLP_OK;i++) {
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);
2239  siErr=siClpProperties(pvHdl,CLPPRO_MTD_CMT,10,psCmd[i].pcKyw,pfPro);
2240  vdClpClose(pvHdl,CLPCLS_MTD_ALL); pvHdl=NULL;
2241  }
2242  if (siErr<0) {
2243  fprintf(pfErr,"Write property file (%s) for program '%s' failed (%d-%s)\n",pcFil,pcPgm,errno,strerror(errno));
2244  ERROR(CLERTC_SYN,NULL);
2245  } else {
2246  fprintf(pfOut,"Property file (%s) for program '%s' successfully written\n",pcFil,pcPgm);
2247  ERROR(CLERTC_OK,NULL);
2248  }
2249  } else {
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);
2255  siErr=siClpProperties(pvHdl,CLPPRO_MTD_CMT,10,psCmd[i].pcKyw,pfPro);
2256  vdClpClose(pvHdl,CLPCLS_MTD_ALL); pvHdl=NULL;
2257  if (siErr<0) {
2258  fprintf(pfErr,"Write property file (%s) for command '%s' failed (%d-%s)\n",pcFil,pcCmd,errno,strerror(errno));
2259  ERROR(CLERTC_SYN,NULL);
2260  } else {
2261  fprintf(pfOut,"Property file (%s) for command '%s' successfully written\n",pcFil,pcCmd);
2262  ERROR(CLERTC_OK,NULL);
2263  }
2264  }
2265  }
2266  }
2267  }
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);
2272  }
2273  }
2274  fprintf(pfErr,"%s %s GENPROP filename\n",pcDep,argv[0]);
2275  ERROR(CLERTC_CMD,NULL);
2276  } else if (asBif[CLE_BUILTIN_IDX_SETPROP].isBif && strxcmp(isCas,argv[1],"SETPROP",0,0,FALSE)==0) {
2277  if (pfOut==NULL) pfOut=pfStd;
2278  if (pfErr==NULL) pfErr=pfStd;
2279  if (argc==3) {
2280  const char* pcSgn;
2281  const char* pcCmd;
2282  pcSgn=strchr(argv[2],'=');
2283  if (pcSgn!=NULL) {
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);
2291  }
2292  }
2293  ERROR(CLERTC_CMD,NULL);
2294  }
2295  srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgm)+strlen(pcCmd),"%s.%s.%s.property.file",pcOwn,pcPgm,pcCmd);
2296  if (pcCnf==NULL) {
2297  fprintf(pfErr,"Allocation of memory for property string failed\n");
2298  ERROR(CLERTC_MEM,NULL);
2299  }
2300  } else {
2301  pcSgn=argv[2]; pcCmd=NULL;
2302  srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgm),"%s.%s.property.file",pcOwn,pcPgm);
2303  if (pcCnf==NULL) {
2304  fprintf(pfErr,"Allocation of memory for property string failed\n");
2305  ERROR(CLERTC_MEM,NULL);
2306  }
2307  }
2308  if (*pcSgn==0) {
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);
2313  }
2314  }
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);
2317  ERROR(CLERTC_CMD,NULL);
2318  }
2319  siErr=siCnfSet(psCnf,pfOut,pcCnf,pcSgn,TRUE);
2320  if (siErr) ERROR(CLERTC_CFG,NULL); else {
2321  fprintf(pfOut,"Setting configuration keyword '%s' to value '%s' was successful\n",pcCnf,pcSgn);
2322  ERROR(CLERTC_OK,NULL);
2323  }
2324  }
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);
2329  }
2330  }
2331  fprintf(pfErr,"%s %s SETPROP filename\n",pcDep,argv[0]);
2332  ERROR(CLERTC_CMD,NULL);
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;
2336  if (argc>=3) {
2337  for (i=0;psCmd[i].pcKyw!=NULL;i++) {
2338  if (strxcmp(isCas,argv[2],psCmd[i].pcKyw,0,0,FALSE)==0) {
2339  size_t szPro=CLEINI_PROSIZ;
2340  char* pcPro=(char*)calloc(1,szPro);
2341  if (pcPro==NULL) {
2342  fprintf(pfErr,"Memory allocation for property list failed\n");
2343  ERROR(CLERTC_MEM,pcPro);
2344  }
2345  for (j=3;j<argc;j++) {
2346  if (j>3) {
2347  srprintc(&pcPro,&szPro,strlen(pcOwn)+strlen(pcPgm)+strlen(psCmd[i].pcKyw)," %s.%s.%s.",pcOwn,pcPgm,psCmd[i].pcKyw);
2348  } else {
2349  srprintc(&pcPro,&szPro,strlen(pcOwn)+strlen(pcPgm)+strlen(psCmd[i].pcKyw),"%s.%s.%s.",pcOwn,pcPgm,psCmd[i].pcKyw);
2350  }
2351  char* pcSgn=strchr(argv[j],'=');
2352  if (pcSgn!=NULL) {
2353  *pcSgn=0x00; pcSgn++;
2354  srprintc(&pcPro,&szPro,strlen(argv[j])+strlen(pcSgn),"%s=\"%s\"",argv[j],pcSgn);
2355  } else {
2356  srprintc(&pcPro,&szPro,strlen(argv[j]),"%s=\"\"",argv[j]);
2357  }
2358  }
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);
2361  ERROR(siErr,pcPro);
2362  }
2363  }
2364  }
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) {
2368  size_t szPro=CLEINI_PROSIZ;
2369  char* pcPro=calloc(1,szPro);
2370  if (pcPro==NULL) {
2371  fprintf(pfErr,"Memory allocation for property list failed\n");
2372  ERROR(CLERTC_MEM,pcPro);
2373  }
2374  for (j=2;j<argc;j++) {
2375  if (j>2) {
2376  srprintc(&pcPro,&szPro,strlen(pcOwn)+strlen(pcPgm)+strlen(psCmd[i].pcKyw)," %s.%s.%s.",pcOwn,pcPgm,psCmd[i].pcKyw);
2377  } else {
2378  srprintc(&pcPro,&szPro,strlen(pcOwn)+strlen(pcPgm)+strlen(psCmd[i].pcKyw),"%s.%s.%s.",pcOwn,pcPgm,psCmd[i].pcKyw);
2379  }
2380  char* pcSgn=strchr(argv[j],'=');
2381  if (pcSgn!=NULL) {
2382  *pcSgn=0x00; pcSgn++;
2383  srprintc(&pcPro,&szPro,strlen(argv[j])+strlen(pcSgn),"%s=\"%s\"",argv[j],pcSgn);
2384  } else {
2385  srprintc(&pcPro,&szPro,strlen(argv[j]),"%s=\"\"",argv[j]);
2386  }
2387  }
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);
2390  ERROR(siErr,pcPro);
2391  }
2392  }
2393  }
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");
2399  }
2400  }
2401  ERROR(CLERTC_CMD,NULL);
2402  } else if (asBif[CLE_BUILTIN_IDX_DELPROP].isBif && strxcmp(isCas,argv[1],"DELPROP",0,0,FALSE)==0) {
2403  if (pfOut==NULL) pfOut=pfStd;
2404  if (pfErr==NULL) pfErr=pfStd;
2405  if (argc==2) {
2406  srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgm),"%s.%s.property.file",pcOwn,pcPgm);
2407  if (pcCnf==NULL) {
2408  fprintf(pfErr,"Allocation of memory for property string failed\n");
2409  ERROR(CLERTC_MEM,NULL);
2410  }
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);
2418  }
2419  }
2420  ERROR(CLERTC_CMD,NULL);
2421  }
2422  srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgm)+strlen(argv[2]),"%s.%s.%s.property.file",pcOwn,pcPgm,argv[2]);
2423  if (pcCnf==NULL) {
2424  fprintf(pfErr,"Allocation of memory for property string failed\n");
2425  ERROR(CLERTC_MEM,NULL);
2426  }
2427  } else {
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);
2432  }
2433  }
2434  fprintf(pfErr,"%s %s DELPROP\n",pcDep,argv[0]);
2435  ERROR(CLERTC_CMD,NULL);
2436  }
2437  siErr=siCnfSet(psCnf,pfOut,pcCnf,"",TRUE);
2438  if (siErr) ERROR(CLERTC_CFG,NULL); else {
2439  fprintf(pfOut,"Delete configuration keyword '%s' was successful\n",pcCnf);
2440  ERROR(CLERTC_OK,NULL);
2441  }
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;
2445  if (argc==2) {
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);
2453  vdClpClose(pvHdl,CLPCLS_MTD_ALL); pvHdl=NULL;
2454  }
2455  ERROR(CLERTC_OK,NULL);
2456  } else if (argc>=3) {
2457  if (argc==3) {
2458  siDep=1;
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) {
2463  siDep=10;
2464  } else if (strxcmp(isCas,argv[3],"DEPALL",0,0,FALSE)==0) {
2465  siDep=10;
2466  } else if (strxcmp(isCas,argv[3],"DEPTH1",0,0,FALSE)==0) {
2467  siDep=1;
2468  } else if (strxcmp(isCas,argv[3],"DEPTH2",0,0,FALSE)==0) {
2469  siDep=2;
2470  } else if (strxcmp(isCas,argv[3],"DEPTH3",0,0,FALSE)==0) {
2471  siDep=3;
2472  } else if (strxcmp(isCas,argv[3],"DEPTH4",0,0,FALSE)==0) {
2473  siDep=4;
2474  } else if (strxcmp(isCas,argv[3],"DEPTH5",0,0,FALSE)==0) {
2475  siDep=5;
2476  } else if (strxcmp(isCas,argv[3],"DEPTH6",0,0,FALSE)==0) {
2477  siDep=6;
2478  } else if (strxcmp(isCas,argv[3],"DEPTH7",0,0,FALSE)==0) {
2479  siDep=7;
2480  } else if (strxcmp(isCas,argv[3],"DEPTH8",0,0,FALSE)==0) {
2481  siDep=8;
2482  } else if (strxcmp(isCas,argv[3],"DEPTH9",0,0,FALSE)==0) {
2483  siDep=9;
2484  } else {
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");
2490  }
2491  }
2492  ERROR(CLERTC_CMD,NULL);
2493  }
2494  } else {
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");
2500  }
2501  }
2502  ERROR(CLERTC_CMD,NULL);
2503  }
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]);
2512  } else {
2513  fprintf(pfOut,"Properties for argument '%s':\n",argv[2]);
2514  }
2515  vdPrnProperties(pvHdl,argv[2],siDep);
2516  ERROR(CLERTC_OK,NULL);
2517  }
2518  }
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);
2530  ERROR(CLERTC_OK,NULL);
2531  }
2532  }
2533  }
2534  }
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");
2540  }
2541  }
2542  fprintf(pfErr,"%s %s GETPROP\n",pcDep,argv[0]);
2543  ERROR(CLERTC_CMD,NULL);
2544  } else if (asBif[CLE_BUILTIN_IDX_SETOWNER].isBif && strxcmp(isCas,argv[1],"SETOWNER",0,0,FALSE)==0) {
2545  if (pfOut==NULL) pfOut=pfStd;
2546  if (pfErr==NULL) pfErr=pfStd;
2547  if (argc==3) {
2548  srprintf(&pcCnf,&szCnf,strlen(pcPgm),"%s.owner.id",pcPgm);
2549  if (pcCnf==NULL) {
2550  fprintf(pfErr,"Allocation of memory for owner string failed\n");
2551  ERROR(CLERTC_MEM,NULL);
2552  }
2553  siErr=siCnfSet(psCnf,pfOut,pcCnf,argv[2],TRUE);
2554  if (siErr) ERROR(CLERTC_CFG,NULL); else {
2555  fprintf(pfOut,"Setting configuration key word '%s' to value '%s' was successful\n",pcCnf,argv[2]);
2556  ERROR(CLERTC_OK,NULL);
2557  }
2558  }
2559  fprintf(pfErr,"Syntax for built-in function 'SETOWNER' not valid\n");
2560  fprintf(pfErr,"%s %s SETOWNER name\n",pcDep,argv[0]);
2561  ERROR(CLERTC_CMD,NULL);
2562  } else if (asBif[CLE_BUILTIN_IDX_GETOWNER].isBif && strxcmp(isCas,argv[1],"GETOWNER",0,0,FALSE)==0) {
2563  if (pfOut==NULL) pfOut=pfStd;
2564  if (pfErr==NULL) pfErr=pfStd;
2565  if (argc==2) {
2566  fprintf(pfOut,"Current owner id for '%s' is: %s\n",argv[0],pcOwn);
2567  ERROR(CLERTC_OK,NULL);
2568  }
2569  fprintf(pfErr,"Syntax for built-in function 'GETOWNER' not valid\n");
2570  fprintf(pfErr,"%s %s GETOWNER\n",pcDep,argv[0]);
2571  ERROR(CLERTC_CMD,NULL);
2572  } else if (asBif[CLE_BUILTIN_IDX_SETENV].isBif && strxcmp(isCas,argv[1],"SETENV",0,0,FALSE)==0) {
2573  if (pfOut==NULL) pfOut=pfStd;
2574  if (pfErr==NULL) pfErr=pfStd;
2575  if (argc==3) {
2576  const char* pcVal;
2577  const char* pcEnv="";
2578  pcVal=strchr(argv[2],'=');
2579  if (pcVal!=NULL) {
2580  *((char*)pcVal)=EOS; pcVal++; pcEnv=argv[2];
2581  } else {
2582  fprintf(pfErr,"Syntax for built-in function 'SETENV' not valid\n");
2583  fprintf(pfErr,"%s %s SETENV variable=value\n",pcDep,argv[0]);
2584  ERROR(CLERTC_CMD,NULL);
2585  }
2586  srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgm)+strlen(pcEnv),"%s.%s.envar.%s",pcOwn,pcPgm,pcEnv);
2587  if (pcCnf==NULL) {
2588  fprintf(pfErr,"Allocation of memory for envar string failed\n");
2589  ERROR(CLERTC_MEM,NULL);
2590  }
2591  siErr=siCnfSet(psCnf,pfOut,pcCnf,pcVal,TRUE);
2592  if (siErr) ERROR(CLERTC_CFG,NULL); else {
2593  fprintf(pfOut,"Setting environment variable '%s' to value '%s' was successful\n",pcCnf,pcVal);
2594  ERROR(CLERTC_OK,NULL);
2595  }
2596  }
2597  fprintf(pfErr,"Syntax for built-in function 'SETENV' not valid\n");
2598  fprintf(pfErr,"%s %s SETENV variable=value\n",pcDep,argv[0]);
2599  ERROR(CLERTC_CMD,NULL);
2600  } else if (asBif[CLE_BUILTIN_IDX_GETENV].isBif && strxcmp(isCas,argv[1],"GETENV",0,0,FALSE)==0) {
2601  if (pfOut==NULL) pfOut=pfStd;
2602  if (pfErr==NULL) pfErr=pfStd;
2603  if (argc==2) {
2604  fprintf(pfOut,"Current environment variables for owner '%s':\n",pcOwn);
2605  siCnt=siCnfPrnEnv(psCnf,pfOut,pcDep,pcOwn,pcPgm);
2606  if (siCnt) {
2607  fprintf(pfOut,"Defined in file \"%s\"\n",psCnf->pcFil);
2608  } else {
2609  fprintf(pfOut,"No environment variables defined in file \"%s\" for owner '%s'\n",psCnf->pcFil,pcOwn);
2610  }
2611  ERROR(CLERTC_OK,NULL);
2612  }
2613  fprintf(pfErr,"Syntax for built-in function 'GETENV' not valid\n");
2614  fprintf(pfErr,"%s %s GETENV\n",pcDep,argv[0]);
2615  ERROR(CLERTC_CMD,NULL);
2616  } else if (asBif[CLE_BUILTIN_IDX_DELENV].isBif && strxcmp(isCas,argv[1],"DELENV",0,0,FALSE)==0) {
2617  if (pfOut==NULL) pfOut=pfStd;
2618  if (pfErr==NULL) pfErr=pfStd;
2619  if (argc==3) {
2620  srprintf(&pcCnf,&szCnf,strlen(pcOwn)+strlen(pcPgm)+strlen(argv[2]),"%s.%s.envar.%s",pcOwn,pcPgm,argv[2]);
2621  if (pcCnf==NULL) {
2622  fprintf(pfErr,"Allocation of memory for envar string failed\n");
2623  ERROR(CLERTC_MEM,NULL);
2624  }
2625  siErr=siCnfSet(psCnf,pfOut,pcCnf,"",TRUE);
2626  if (siErr) ERROR(CLERTC_CFG,NULL); else {
2627  fprintf(pfOut,"Deleting the environment variable '%s' was successful\n",pcCnf);
2628  ERROR(CLERTC_OK,NULL);
2629  }
2630  }
2631  fprintf(pfErr,"Syntax for built-in function 'DELENV' not valid\n");
2632  fprintf(pfErr,"%s %s DELENV variable\n",pcDep,argv[0]);
2633  ERROR(CLERTC_CMD,NULL);
2634  } else if (asBif[CLE_BUILTIN_IDX_TRACE].isBif && strxcmp(isCas,argv[1],"TRACE",0,0,FALSE)==0) {
2635  if (pfOut==NULL) pfOut=pfStd;
2636  if (pfErr==NULL) pfErr=pfStd;
2637  if (argc==3) {
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);
2640  if (pcCnf==NULL) {
2641  fprintf(pfErr,"Allocation of memory for envar string failed\n");
2642  ERROR(CLERTC_MEM,NULL);
2643  }
2644  siErr=siCnfSet(psCnf,pfOut,pcCnf,"ON",TRUE);
2645  if (siErr) ERROR(CLERTC_CFG,NULL); else {
2646  fprintf(pfOut,"Setting configuration keyword '%s' to value 'ON' was successful\n",pcCnf);
2647  ERROR(CLERTC_OK,NULL);
2648  }
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);
2651  if (pcCnf==NULL) {
2652  fprintf(pfErr,"Allocation of memory for envar string failed\n");
2653  ERROR(CLERTC_MEM,NULL);
2654  }
2655  siErr=siCnfSet(psCnf,pfOut,pcCnf,"OFF",TRUE);
2656  if (siErr) ERROR(CLERTC_CFG,NULL); else {
2657  fprintf(pfOut,"Setting configuration keyword '%s' to value 'OFF' was successful\n",pcCnf);
2658  ERROR(CLERTC_OK,NULL);
2659  }
2660  } else {
2661  const char* pcSgn;
2662  pcSgn=strchr(argv[2],'=');
2663  if (pcSgn!=NULL) {
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);
2668  if (pcCnf==NULL) {
2669  fprintf(pfErr,"Allocation of memory for envar string failed\n");
2670  ERROR(CLERTC_MEM,NULL);
2671  }
2672  siErr=siCnfSet(psCnf,pfOut,pcCnf,pcSgn,TRUE);
2673  if (siErr) ERROR(CLERTC_CFG,NULL); else {
2674  if (*pcSgn) {
2675  fprintf(pfOut,"Setting configuration keyword '%s' to value '%s' was successful\n",pcCnf,pcSgn);
2676  } else {
2677  fprintf(pfOut,"Deleting value from configuration keyword '%s' was successful\n",pcCnf);
2678  }
2679  ERROR(CLERTC_OK,NULL);
2680  }
2681  }
2682  }
2683  }
2684  }
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]);
2688  ERROR(CLERTC_CMD,NULL);
2689  } else if (asBif[CLE_BUILTIN_IDX_CONFIG].isBif && strxcmp(isCas,argv[1],"CONFIG",0,0,FALSE)==0) {
2690  if (pfOut==NULL) pfOut=pfStd;
2691  if (pfErr==NULL) pfErr=pfStd;
2692  if (argc==2) {
2693  fprintf(pfOut,"Current configuration data:\n");
2694  siCnt=siCnfPrn(psCnf,pfOut,pcDep);
2695  if (siCnt) {
2696  fprintf(pfOut,"Assigned to file \"%s\"\n",psCnf->pcFil);
2697  } else {
2698  fprintf(pfOut,"No configuration data defined for file \"%s\"\n",psCnf->pcFil);
2699  }
2700  ERROR(CLERTC_OK,NULL);
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);
2706  if (siCnt) {
2707  fprintf(pfOut,"Delete %d elements from file \"%s\"\n",siCnt,psCnf->pcFil);
2708  } else {
2709  fprintf(pfOut,"No configuration data defined for file \"%s\"\n",psCnf->pcFil);
2710  }
2711  ERROR(CLERTC_OK,NULL);
2712  }
2713  }
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]);
2717  ERROR(CLERTC_CMD,NULL);
2718  } else {
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]));
2725  argc--;
2726  }
2727  if (strxcmp(isCas,argv[1],"OWNER=",6,0,FALSE)==0) {
2728  srprintf(&pcOwn,&szOwn,strlen(&argv[1][6]),"%s",&argv[1][6]);
2729  if (pcOwn==NULL) {
2730  if (pfErr!=NULL) fprintf(pfErr,"Allocation of memory for owner string failed\n");
2731  siErr=CLERTC_MEM;
2732  ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2733  }
2734  if (isEnvOwn) {
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));
2737  } else {
2738  if (pfOut!=NULL) fprintf(pfOut,"Use owner: '%s' (set as environment variable was successful)\n",pcOwn);
2739  }
2740  } else {
2741  if (pfOut!=NULL) fprintf(pfOut,"Use owner: '%s' (environment variable was already defined)\n",pcOwn);
2742  }
2743  for (i=2;i<argc;i++) argv[i-1]=argv[i];
2744  argc--;
2745  }
2746  if (argc>1) {
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) {
2753  char* pcCmd=NULL;
2754  char* pcTls=NULL;
2755  char* pcLst=NULL;
2756  clock_t ckCpu1=clock();
2757  clock_t ckCpu2;
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);
2761  if (pfOut!=NULL) {
2762  ckCpu2=clock();
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);
2764  ckCpu1=ckCpu2;
2765  }
2766 
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);
2769  if (pfOut!=NULL) {
2770  ckCpu2=clock();
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);
2772  ckCpu1=ckCpu2;
2773  }
2774 
2775  siErr=siClpParseCmd(pvHdl,pcFil,pcCmd,TRUE,TRUE,psCmd[i].piOid,&pcTls);
2776  if (siErr<0) {
2777  if (pfErr!=NULL) fprintf(pfErr,"Command line parser for command '%s' failed\n",psCmd[i].pcKyw);
2778  SAFE_FREE(pcCmd);
2779  siErr=CLERTC_SYN;
2780  ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2781  }
2782  if (pcTls!=NULL) {
2783  pcLst=(char*)malloc(strlen(pcTls)+1);
2784  if (pcLst!=NULL) {
2785  strcpy(pcLst,pcTls);
2786  }
2787  }
2788  vdClpClose(pvHdl,CLPCLS_MTD_KEP);
2789  if (pfOut!=NULL) {
2790  ckCpu2=clock();
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);
2792  ckCpu1=ckCpu2;
2793  }
2794 
2795  siErr=psCmd[i].pfMap(pvHdl,pfErr,pfTrc,pvGbl,psCmd[i].piOid,psCmd[i].pvClp,psCmd[i].pvPar);
2796  if (siErr) {
2797  if (siErr!=siNoR) {
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);
2800  } else {
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);
2802  }
2803  siErr=CLERTC_MAP;
2804  } else {
2805  siErr=CLERTC_OK;
2806  }
2807  SAFE_FREE(pcCmd); SAFE_FREE(pcLst);
2808  psCmd[i].pfFin(pfErr,pfTrc,pvGbl,psCmd[i].pvPar);
2809  ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2810  }
2811  if (pfOut!=NULL) {
2812  ckCpu2=clock();
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);
2814  ckCpu1=ckCpu2;
2815  }
2816 
2817  siErr=psCmd[i].pfRun(pvHdl,pfErr,pfTrc,pvGbl,pcOwn,pcPgm,pcVsn,pcAbo,pcLic,psCmd[i].pcKyw,pcCmd,pcLst,psCmd[i].pvPar,&isWrn,&siScc);
2818  SAFE_FREE(pcCmd); SAFE_FREE(pcLst);
2819  if (siErr) {
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);
2823  } else {
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);
2825  }
2826  psCmd[i].pfFin(pfErr,pfTrc,pvGbl,psCmd[i].pvPar);
2827  siErr=CLERTC_WRN;
2828  ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2829  } else {
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);
2832  } else {
2833  if (pfErr!=NULL) fprintf(pfErr,"Run of command '%s' failed (Return code: %d / Reason code: %d)\n",psCmd[i].pcKyw,CLERTC_RUN,siErr);
2834  }
2835  psCmd[i].pfFin(pfErr,pfTrc,pvGbl,psCmd[i].pvPar);
2836  if (siScc>CLERTC_MAX) {
2837  siErr=siScc;
2838  ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2839  } else {
2840  siErr=CLERTC_RUN;
2841  ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2842  }
2843  }
2844  }
2845  if (pfOut!=NULL) {
2846  ckCpu2=clock();
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);
2848  ckCpu1=ckCpu2;
2849  }
2850 
2851  siErr=psCmd[i].pfFin(pfErr,pfTrc,pvGbl,psCmd[i].pvPar);
2852  vdClpClose(pvHdl,CLPCLS_MTD_ALL); pvHdl=NULL;
2853  if (siErr) {
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);
2856  } else {
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);
2858  }
2859  siErr=CLERTC_FIN;
2860  ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2861  }
2862  if (pfOut!=NULL) {
2863  ckCpu2=clock();
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);
2865  }
2866  siErr=isWrn&0x00000001;
2867  ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2868  }
2869  }
2870  }
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);
2875  siErr=CLERTC_MEM;
2876  ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2877  }
2878  for (i=argc;i>1;i--) ppArg[i]=argv[i-1];
2879  ppArg[0]=argv[0]; ppArg[1]=(char*)pcDef; argc++; argv=ppArg;
2880  goto EVALUATE;
2881  }
2882  if (pfErr!=NULL) {
2883  fprintf(pfErr,"Command or built-in function '%s' not supported\n",argv[1]);
2884  vdPrnStaticSyntax(pfErr,psCmd,asBif,argv[0],pcDep,pcOpt,pcDpa);
2885  }
2886  siErr=CLERTC_CMD;
2887  ERROR(((siErr>siMaxCC)?siMaxCC:(siErr<siMinCC)?0:siErr),NULL);
2888  }
2889 }
2890 #undef ERROR
2891 
2892 /* Interne Funktionen *************************************************/
2893 
2894 static int siClePropertyInit(
2895  void* pvGbl,
2896  TfIni* pfIni,
2897  void* pvClp,
2898  const char* pcOwn,
2899  const char* pcPgm,
2900  const char* pcBld,
2901  const char* pcCmd,
2902  const char* pcMan,
2903  const char* pcHlp,
2904  const int* piOid,
2905  const TsClpArgument* psTab,
2906  const int isCas,
2907  const int isPfl,
2908  const int isRpl,
2909  const int siMkl,
2910  FILE* pfOut,
2911  FILE* pfErr,
2912  FILE* pfTrc,
2913  const char* pcDep,
2914  const char* pcOpt,
2915  const char* pcEnt,
2916  TsCnfHdl* psCnf,
2917  void** ppHdl,
2918  char** ppFil,
2919  int* piFil,
2920  TfMsg* pfMsg,
2921  void* pvF2S,
2922  TfF2S* pfF2S,
2923  void* pvSaf,
2924  TfSaf* pfSaf)
2925 {
2926  int siErr;
2927  int isOvl=(piOid==NULL)?FALSE:TRUE;
2928  char* pcPro=NULL;
2929  char* pcFil=NULL;
2930  int siFil=0;
2931 
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);
2935  if (*ppHdl==NULL) {
2936  if (pfErr!=NULL) fprintf(pfErr,"Open of property parser for command '%s' failed\n",pcCmd);
2937  return(CLERTC_TAB);
2938  }
2939  siErr=pfIni(*ppHdl,pfErr,pfTrc,pvGbl,pcOwn,pcPgm,pvClp);
2940  if (siErr) {
2941  const char* pcMsg;
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);
2944  } else {
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);
2946  }
2947  vdClpClose(*ppHdl,CLPCLS_MTD_ALL);*ppHdl=NULL;
2948  return(CLERTC_INI);
2949  }
2950  siErr=siCleGetProperties(pfErr,psCnf,pcOwn,pcPgm,pcCmd,&pcFil,&pcPro,&siFil,pvGbl,pvF2S,pfF2S);
2951  if (siErr) {
2952  if (pcPro!=NULL) free(pcPro); SAFE_FREE(pcFil);
2953  vdClpClose(*ppHdl,CLPCLS_MTD_ALL);*ppHdl=NULL;
2954  return(siErr);
2955  }
2956  if (pcPro!=NULL) {
2957  siErr=siClpParsePro(*ppHdl,pcFil,pcPro,FALSE,NULL);
2958  if (siErr<0) {
2959  if (pfErr!=NULL) fprintf(pfErr,"Parsing property file \"%s\" for command '%s' failed\n",pcFil,pcCmd);
2960  vdClpClose(*ppHdl,CLPCLS_MTD_ALL);*ppHdl=NULL;
2961  free(pcPro); SAFE_FREE(pcFil);
2962  return(CLERTC_SYN);
2963  }
2964  free(pcPro);
2965  }
2966  if (ppFil!=NULL) *ppFil=pcFil; else {
2967  SAFE_FREE(pcFil);
2968  }
2969  if (piFil!=NULL) *piFil=siFil;
2970  return(CLERTC_OK);
2971 }
2972 
2973 static int siClePropertyFinish(
2974  const char* pcHom,
2975  const char* pcOwn,
2976  const char* pcPgm,
2977  const char* pcCmd,
2978  FILE* pfOut,
2979  FILE* pfErr,
2980  FILE* pfTrc,
2981  TsCnfHdl* psCnf,
2982  void* pvHdl,
2983  const char* pcFil,
2984  const int siFil)
2985 {
2986  (void) pfTrc;
2987  int siErr;
2988  FILE* pfPro;
2989  char acEnv[((pcHom!=NULL)?strlen(pcHom):0)+strlen(pcOwn)+strlen(pcPgm)+strlen(pcCmd)+64];
2990  size_t szEnv=0;
2991  char* pcEnv=NULL;
2992  char* pcHlp=NULL;
2993 
2994  if (siFil!=3) {
2995  int i;
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]);
2998  pcFil=GETENV(acEnv);
2999  if (pcFil!=NULL && *pcFil) {
3000  srprintf(&pcEnv,&szEnv,strlen(pcFil),"%s",pcFil);
3001  if (pcEnv==NULL) {
3002  if (pfErr!=NULL) fprintf(pfErr,"Allocation of memory for property file name (%s) failed\n",pcFil);
3003  vdClpClose(pvHdl,CLPCLS_MTD_ALL);
3004  return(CLERTC_MEM);
3005  }
3006  pcFil=pcEnv;
3007  } else {
3008 #ifdef __ZOS__
3009  {
3010  int j=9;
3011  strcpy(acEnv,"<SYSUID>.");
3012  for (i=0;i<8 && pcOwn[i];i++) {
3013  if (isalnum(pcOwn[i])) {
3014  acEnv[j]=toupper(pcOwn[i]);
3015  j++;
3016  }
3017  }
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]);
3022  j++;
3023  }
3024  }
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]);
3029  j++;
3030  }
3031  }
3032  acEnv[j]=0x00;
3033  strcat(acEnv,".PROPS");
3034  }
3035 #else
3036  if (pcHom!=NULL && *pcHom) {
3037  snprintf(acEnv,sizeof(acEnv),"%s.%s.%s.%s.properties",pcHom,pcOwn,pcPgm,pcCmd);
3038  } else {
3039  snprintf(acEnv,sizeof(acEnv),".%s.%s.%s.properties",pcOwn,pcPgm,pcCmd);
3040  }
3041  for (i=0;acEnv[i];i++) acEnv[i]=tolower(acEnv[i]);
3042 #endif
3043  pcFil=acEnv;
3044  }
3045  }
3046  pcHlp=dcpmapfil(pcFil);
3047  if (pcHlp==NULL) {
3048  if (pfErr!=NULL) fprintf(pfErr,"Allocation of memory for property file name (%s) failed\n",pcFil);
3049  SAFE_FREE(pcEnv);
3050  vdClpClose(pvHdl,CLPCLS_MTD_ALL);
3051  return(CLERTC_MEM);
3052  }
3053  pfPro=fopen_hfq(pcHlp,"w");
3054  if (pfPro==NULL) {
3055  if (pfErr!=NULL) fprintf(pfErr,"Cannot open the property file (\"%s\",\"%s\") for write operation (%d-%s)\n",pcHlp,"w",errno,strerror(errno));
3056  SAFE_FREE(pcHlp); SAFE_FREE(pcEnv);
3057  vdClpClose(pvHdl,CLPCLS_MTD_ALL);
3058  return(CLERTC_SYS);
3059  }
3060 
3061  siErr=siClpProperties(pvHdl,CLPPRO_MTD_CMT,10,pcCmd,pfPro);
3062  vdClpClose(pvHdl,CLPCLS_MTD_ALL); fclose(pfPro);
3063  if (siErr<0) {
3064  if (pfErr!=NULL) fprintf(pfErr,"Write property file (%s) for command '%s' failed (%d-%s)\n",pcHlp,pcCmd,errno,strerror(errno));
3065  SAFE_FREE(pcHlp); SAFE_FREE(pcEnv);
3066  return(CLERTC_SYN);
3067  }
3068  if (pfOut!=NULL) fprintf(pfOut,"Property file (%s) for command '%s' successfully written\n",pcHlp,pcCmd);
3069 
3070  if (siFil!=3) {
3071  snprintf(acEnv,sizeof(acEnv),"%s.%s.%s.property.file",pcOwn,pcPgm,pcCmd);
3072  siErr=siCnfSet(psCnf,pfErr,acEnv,pcHlp,TRUE);
3073  if (siErr) {
3074  if (pfErr!=NULL) fprintf(pfErr,"Activation of property file (%s) for command '%s' failed\n",pcFil,pcCmd);
3075  SAFE_FREE(pcHlp); SAFE_FREE(pcEnv);
3076  return(CLERTC_CFG);
3077  }
3078  if (pfOut!=NULL) {
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);
3081  }
3082  }
3083  SAFE_FREE(pcHlp); SAFE_FREE(pcEnv);
3084  return(CLERTC_OK);
3085 }
3086 
3087 static int siCleCommandInit(
3088  void* pvGbl,
3089  TfIni* pfIni,
3090  void* pvClp,
3091  const char* pcOwn,
3092  const char* pcPgm,
3093  const char* pcBld,
3094  const char* pcCmd,
3095  const char* pcMan,
3096  const char* pcHlp,
3097  const int* piOid,
3098  const TsClpArgument* psTab,
3099  const int isCas,
3100  const int isPfl,
3101  const int isRpl,
3102  const int siMkl,
3103  FILE* pfOut,
3104  FILE* pfErr,
3105  FILE* pfTrc,
3106  const char* pcDep,
3107  const char* pcOpt,
3108  const char* pcEnt,
3109  TsCnfHdl* psCnf,
3110  void** ppHdl,
3111  TfMsg* pfMsg,
3112  void* pvF2S,
3113  TfF2S* pfF2S,
3114  void* pvSaf,
3115  TfSaf* pfSaf)
3116 {
3117  int siErr,siFil=0;
3118  int isOvl=(piOid==NULL)?FALSE:TRUE;
3119  char* pcFil=NULL;
3120  char* pcPro=NULL;
3121  clock_t ckCpu1=clock();
3122  clock_t ckCpu2;
3123  char acTs[24];
3124 
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);
3126  if (*ppHdl==NULL) {
3127  if (pfErr!=NULL) fprintf(pfErr,"Open of parser for command '%s' failed\n",pcCmd);
3128  return(CLERTC_TAB);
3129  }
3130  if (pfTrc!=NULL) {
3131  ckCpu2=clock();
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);
3133  ckCpu1=ckCpu2;
3134  }
3135 
3136  siErr=pfIni(*ppHdl,pfErr,pfTrc,pvGbl,pcOwn,pcPgm,pvClp);
3137  if (siErr) {
3138  const char* pcMsg;
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);
3141  } else {
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);
3143  }
3144  vdClpClose(*ppHdl,CLPCLS_MTD_ALL);*ppHdl=NULL;
3145  return(CLERTC_INI);
3146  }
3147  if (pfTrc!=NULL) {
3148  ckCpu2=clock();
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);
3150  ckCpu1=ckCpu2;
3151  }
3152  siErr=siCleGetProperties(pfErr,psCnf,pcOwn,pcPgm,pcCmd,&pcFil,&pcPro,&siFil,pvGbl,pvF2S,pfF2S);
3153  if (siErr) {
3154  vdClpClose(*ppHdl,CLPCLS_MTD_ALL);*ppHdl=NULL;
3155  SAFE_FREE(pcPro); SAFE_FREE(pcFil);
3156  return(siErr);
3157  }
3158  if (pfTrc!=NULL) {
3159  ckCpu2=clock();
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);
3161  ckCpu1=ckCpu2;
3162  }
3163  if (pcPro!=NULL) {
3164  siErr=siClpParsePro(*ppHdl,pcFil,pcPro,FALSE,NULL);
3165  if (siErr<0) {
3166  if (pfErr!=NULL) fprintf(pfErr,"Property parser for command '%s' failed\n",pcCmd);
3167  vdClpClose(*ppHdl,CLPCLS_MTD_ALL);*ppHdl=NULL;
3168  free(pcPro); SAFE_FREE(pcFil);
3169  return(CLERTC_SYN);
3170  }
3171  free(pcPro);
3172  if (pfTrc!=NULL) {
3173  ckCpu2=clock();
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);
3175  }
3176  }
3177  SAFE_FREE(pcFil);
3178  return(CLERTC_OK);
3179 }
3180 
3181 static int siCleSimpleInit(
3182  FILE* pfOut,
3183  FILE* pfErr,
3184  const int isPfl,
3185  const int isRpl,
3186  const char* pcDep,
3187  const char* pcOpt,
3188  const char* pcEnt,
3189  void** ppHdl)
3190 {
3191  const TsClpArgument asTab[]={
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}
3194  };
3195  *ppHdl=pvClpOpen(FALSE,isPfl,isRpl,0,"","","","","","",FALSE,asTab,"",pfOut,pfErr,NULL,NULL,NULL,NULL,pcDep,pcOpt,pcEnt,NULL,NULL,NULL,NULL,NULL,NULL);
3196  if (*ppHdl==NULL) {
3197  if (pfErr!=NULL) fprintf(pfErr,"Open of command line parser for grammar and lexeme print out failed\n");
3198  return(CLERTC_TAB);
3199  }
3200  return(CLERTC_OK);
3201 }
3202 
3203 static int siCleChangeProperties(
3204  void* pvGbl,
3205  TfIni* pfIni,
3206  void* pvClp,
3207  const char* pcHom,
3208  const char* pcOwn,
3209  const char* pcPgm,
3210  const char* pcBld,
3211  const char* pcCmd,
3212  const char* pcMan,
3213  const char* pcHlp,
3214  const char* pcPro,
3215  const int* piOid,
3216  const TsClpArgument* psTab,
3217  const int isCas,
3218  const int isPfl,
3219  const int isRpl,
3220  const int siMkl,
3221  FILE* pfOut,
3222  FILE* pfErr,
3223  FILE* pfTrc,
3224  const char* pcDep,
3225  const char* pcOpt,
3226  const char* pcEnt,
3227  TsCnfHdl* psCnf,
3228  TfMsg* pfMsg,
3229  void* pvF2S,
3230  TfF2S* pfF2S,
3231  void* pvSaf,
3232  TfSaf* pfSaf)
3233 {
3234  int siErr;
3235  void* pvHdl=NULL;
3236  char* pcFil=NULL;
3237  int siFil=0;
3238 
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);
3242  if (siErr) {
3243  SAFE_FREE(pcFil);
3244  return(siErr);
3245  }
3246 
3247  siErr=siClpParsePro(pvHdl,pcFil,pcPro,TRUE,NULL);
3248  if (siErr<0) {
3249  if (pfErr!=NULL) fprintf(pfErr,"Property parser for command '%s' failed\n",pcCmd);
3250  vdClpClose(pvHdl,CLPCLS_MTD_ALL);
3251  SAFE_FREE(pcFil);
3252  return(CLERTC_SYN);
3253  }
3254 
3255  if (siErr==0) {
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);
3259  } else {
3260  if (pfOut!=NULL) fprintf(pfOut, "Updated %d properties in property file (%s)\n",siErr,(NULL==pcFil)?"null":pcFil);
3261  }
3262 
3263  siErr=siClePropertyFinish(pcHom,pcOwn,pcPgm,pcCmd,pfOut,pfErr,pfTrc,psCnf,pvHdl,pcFil,siFil);
3264  if (siErr) {
3265  SAFE_FREE(pcFil);
3266  return(siErr);
3267  }
3268 
3269  SAFE_FREE(pcFil);
3270  return(CLERTC_OK);
3271 }
3272 
3273 static int siCleEndExecution(
3274  const int siErr,
3275  TsCnfHdl* psCnf,
3276  FILE* pfTrc,
3277  FILE* pfDoc,
3278  FILE* pfPro,
3279  char** ppArg,
3280  void* pvHdl,
3281  char* pcBuf)
3282 {
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);
3288  if (pvHdl!=NULL) vdClpClose(pvHdl,CLPCLS_MTD_ALL);
3289  if (pcBuf!=NULL) free(pcBuf);
3290  return(siErr);
3291 }
3292 
3293 static void vdCleManProgram(
3294  FILE* pfOut,
3295  const TsCleCommand* psCmd,
3296  const TsCleBuiltin* psBif,
3297  const char* pcOwn,
3298  const char* pcPgm,
3299  const char* pcBld,
3300  const char* pcHlp,
3301  const char* pcMan,
3302  const char* pcDep,
3303  const char* pcSep,
3304  const char* pcDpa,
3305  const char* pcNum,
3306  const int isMan,
3307  const int isNbr)
3308 {
3309  int i,l;
3310  if (isMan) {
3311  for(const char* p=pcPgm;*p;p++) fprintf(pfOut,"%c",tolower(*p));
3312  fprintf(pfOut, "(1)\n");
3313  l=strlen(pcPgm)+3;
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);
3332  } else {
3333  fprintf(pfOut,"No detailed description available for this program.\n\n");
3334  }
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));
3343  fprintf(pfOut,".");
3344  for(const char* p=psCmd[i].pcKyw;*p;p++) fprintf(pfOut,"%c",tolower(*p));
3345  fprintf(pfOut,"(1)\n");
3346  }
3347  }
3348  fprintf(pfOut,"\n");
3349  } else {
3350  if (isNbr) {
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);
3356  l=strlen(pcNum)+11;
3357  for (i=0;i<l;i++) fprintf(pfOut,"%c",C_TLD);
3358  fprintf(pfOut,"\n\n");
3359  } else {
3360  fprintf(pfOut,"Program '%s'\n",pcPgm);
3361  l=strlen(pcPgm)+10;
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");
3367  }
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");
3374 
3375  if (isNbr) {
3376  fprintf(pfOut,"%s2. Description\n",pcNum);
3377  l=strlen(pcNum)+14;
3378  for (i=0;i<l;i++) fprintf(pfOut,"%c",C_TLD);
3379  fprintf(pfOut,"\n\n");
3380  } else {
3381  fprintf(pfOut,"Description\n");
3382  for (i=0;i<11;i++) fprintf(pfOut,"%c",C_TLD);
3383  fprintf(pfOut,"\n\n");
3384  }
3385  if (pcMan!=NULL && *pcMan) {
3386  fprintm(pfOut,pcOwn,pcPgm,pcBld,pcMan,2);
3387  } else {
3388  fprintf(pfOut,"No detailed description available for this program.\n\n");
3389  }
3390  if (isNbr) {
3391  fprintf(pfOut,"%s3. Syntax\n",pcNum);
3392  l=strlen(pcNum)+9;
3393  for (i=0;i<l;i++) fprintf(pfOut,"%c",C_TLD);
3394  fprintf(pfOut,"\n\n");
3395  } else {
3396  fprintf(pfOut,"Syntax\n");
3397  for (i=0;i<6;i++) fprintf(pfOut,"%c",C_TLD);
3398  fprintf(pfOut,"\n\n");
3399  }
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");
3405 
3406  if (isNbr) {
3407  fprintf(pfOut,"%s4. Help\n",pcNum);
3408  l=strlen(pcNum)+7;
3409  for (i=0;i<l;i++) fprintf(pfOut,"%c",C_TLD);
3410  fprintf(pfOut,"\n\n");
3411  } else {
3412  fprintf(pfOut,"Help\n");
3413  for (i=0;i<4;i++) fprintf(pfOut,"%c",C_TLD);
3414  fprintf(pfOut,"\n\n");
3415  }
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");
3421  }
3422 }
3423 
3424 static void vdCleManFunction(
3425  FILE* pfOut,
3426  const unsigned int uiLev,
3427  const char* pcLev,
3428  const char* pcNum,
3429  const char* pcFct,
3430  const char* pcHlp,
3431  const char* pcOwn,
3432  const char* pcPgm,
3433  const char* pcBld,
3434  const char* pcSyn,
3435  const char* pcMan,
3436  const int isMan,
3437  const int isPat,
3438  const int isNbr,
3439  const int isShl,
3440  const int isIdt)
3441 {
3442  int i,l;
3443  if (isMan) {
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");
3470  } else {
3471  if (uiLev) {
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);
3475  if (isShl) {
3476  efprintf(pfOut," %s\n\n",pcFct);
3477  } else {
3478  efprintf(pfOut," Function '%s'\n\n",pcFct);
3479  }
3480  if (isIdt) efprintf(pfOut,"indexterm:[Built-in Function, %s]\n\n",pcFct);
3481  efprintf(pfOut,".Synopsis\n\n");
3482  efprintf(pfOut,"-----------------------------------------------------------------------\n");
3483  efprintf(pfOut,"HELP: %s\n",pcHlp);
3484  if(isPat)
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);
3491  } else {
3492  efprintf(pfOut,"[[CLEP.BUILTIN.%s]]\n",pcFct);
3493  if (isNbr) {
3494  if (isShl) {
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");
3499  } else {
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");
3504  }
3505  } else {
3506  if (isShl) {
3507  fprintf(pfOut,"%s\n",pcFct);
3508  l=strlen(pcFct);
3509  for (i=0;i<l;i++) fprintf(pfOut,"%s",pcLev);
3510  fprintf(pfOut,"\n\n");
3511  } else {
3512  fprintf(pfOut,"Function '%s'\n",pcFct);
3513  l=strlen(pcFct)+11;
3514  for (i=0;i<l;i++) fprintf(pfOut,"%s",pcLev);
3515  fprintf(pfOut,"\n\n");
3516  }
3517  }
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);
3522  if(isPat)
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);
3529  }
3530  }
3531 }
3532 
3533 static void vdPrnStaticSyntax(
3534  FILE* pfOut,
3535  const TsCleCommand* psCmd,
3536  const TsCleBuiltin* psBif,
3537  const char* pcPgm,
3538  const char* pcDep,
3539  const char* pcSep,
3540  const char* pcDpa)
3541 {
3542  int f=FALSE;
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);
3548  f=TRUE;
3549  }
3550  }
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);
3561 if (pcDpa!=NULL) {
3562  fprintf(pfOut,"%s%s Additional the default parameter file '%s' is supported if only the command provided\n",pcDep,pcDep,pcDpa);
3563 }
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);
3568  }
3569  }
3570 }
3571 
3572 static void vdPrnStaticHelp(
3573  FILE* pfOut,
3574  const TsCleCommand* psCmd,
3575  const TsCleBuiltin* psBif,
3576  const char* pcPgm,
3577  const char* pcDep)
3578 {
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);
3583  }
3584  }
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);
3589  }
3590  }
3591  fprintf(pfOut,"For more information please use the built-in function 'MANPAGE'\n");
3592 }
3593 
3594 static void vdPrnCommandSyntax(
3595  void* pvHdl,
3596  FILE* pfOut,
3597  const char* pcPgm,
3598  const char* pcCmd,
3599  const char* pcDep,
3600  const int siDep)
3601 {
3602  if (siDep==1) {
3603  int siErr;
3604  fprintf(pfOut,"%s %s \"",pcDep,pcPgm);
3605  siErr=siClpSyntax(pvHdl,FALSE,FALSE,siDep,pcCmd);
3606  if (siErr==CLP_OK) fprintf(pfOut,"\"\n");
3607  } else {
3608  siClpSyntax(pvHdl,TRUE,TRUE,siDep,pcCmd);
3609  }
3610 }
3611 
3612 static void vdPrnCommandHelp(
3613  void* pvHdl,
3614  const char* pcCmd,
3615  const int siDep,
3616  const int isAli,
3617  const int isMan)
3618 {
3619  siClpHelp(pvHdl,siDep,pcCmd,isAli,isMan);
3620 }
3621 
3622 static void vdPrnCommandManpage(
3623  void* pvHdl,
3624  FILE* pfOut,
3625  const char* pcNum,
3626  const char* pcCmd,
3627  const int siInd,
3628  const int isMan,
3629  const int isNbr)
3630 {
3631  char acNum[16];
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);
3634 }
3635 
3636 static void vdPrnProperties(
3637  void* pvHdl,
3638  const char* pcPat,
3639  const int siDep)
3640 {
3641  siClpProperties(pvHdl,CLPPRO_MTD_SET,siDep,pcPat,NULL);
3642 }
3643 
3644 static int siCleGetProperties(
3645  FILE* pfErr,
3646  TsCnfHdl* psCnf,
3647  const char* pcOwn,
3648  const char* pcPgm,
3649  const char* pcCmd,
3650  char** ppFil,
3651  char** ppPro,
3652  int* piFlg,
3653  void* pvGbl,
3654  void* pvF2S,
3655  TfF2S* pfF2S)
3656 {
3657  int siErr,siSiz=0;
3658  const char* pcHlp=NULL;
3659  char acRoot[strlen(pcOwn)+strlen(pcPgm)+strlen(pcCmd)+17];
3660  char acMsg[1024]="";
3661 
3662  SAFE_FREE(*ppFil);
3663  snprintf(acRoot,sizeof(acRoot),"%s.%s.%s.property.file",pcOwn,pcPgm,pcCmd);
3664  pcHlp=pcCnfGet(psCnf,acRoot);
3665  if (pcHlp==NULL) {
3666  snprintf(acRoot,sizeof(acRoot),"%s.%s.property.file",pcOwn,pcPgm);
3667  pcHlp=pcCnfGet(psCnf,acRoot);
3668  if (pcHlp==NULL) {
3669  snprintf(acRoot,sizeof(acRoot),"%s.property.file",pcOwn);
3670  pcHlp=pcCnfGet(psCnf,acRoot);
3671  if (pcHlp==NULL) {
3672  *piFlg=0;
3673  return(CLERTC_OK);
3674  } else *piFlg=1;
3675  } else *piFlg=2;
3676  } else *piFlg=3;
3677  *ppFil=dcpmapfil(pcHlp);
3678  if (*ppFil==NULL) {
3679  if (pfErr!=NULL) fprintf(pfErr,"Allocation of memory for property file name (%s) failed)\n",pcHlp);
3680  return(CLERTC_MEM);
3681  }
3682  siErr=pfF2S(pvGbl,pvF2S,*ppFil,ppPro,&siSiz,acMsg,sizeof(acMsg));
3683  if (siErr<0) {
3684  if (pfErr!=NULL) fprintf(pfErr,"Property file: %s\n",acMsg);
3685  SAFE_FREE(*ppFil);
3686  SAFE_FREE(*ppPro);
3687  return(CLERTC_SYS);
3688  }
3689  return(CLERTC_OK);
3690 }
3691 
3692 static int siCleGetCommand(
3693  FILE* pfOut,
3694  FILE* pfErr,
3695  FILE* pfTrc,
3696  const char* pcDep,
3697  const char* pcFct,
3698  int argc,
3699  char* argv[],
3700  char** ppFil,
3701  char** ppCmd,
3702  void* pvGbl,
3703  void* pvF2S,
3704  TfF2S* pfF2S,
3705  const char* pcDpa)
3706 {
3707  int siErr,siSiz=0;
3708  int l=strlen(pcFct);
3709  SAFE_FREE(*ppFil);
3710  if (argv[1][l]==EOS) {
3711  if (argc>2) {
3712  siErr=arry2str(argv+2,argc-2," ",1,ppCmd,&siSiz);
3713  if (siErr<0) {
3714  SAFE_FREE(*ppCmd);
3715  switch(siErr) {
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);
3719  }
3720  }
3721  if (pfTrc!=NULL) {
3722  char acTs[24];
3723  fprintf(pfTrc,"%s Read parameter string in length %d from command line\n",cstime(0,acTs),(int)strlen(*ppCmd));
3724  }
3725  } else {
3726  if (pcDpa!=NULL && *pcDpa) {
3727  siErr=pfF2S(pvGbl,pvF2S,pcDpa,ppCmd,&siSiz,NULL,0);
3728  if(siErr>0) {
3729  if (pfTrc!=NULL) {
3730  char acTs[24];
3731  fprintf(pfTrc,"%s Read parameter string in length %d from default parameter file '%s'\n",cstime(0,acTs),siErr,pcDpa);
3732  }
3733  } else {
3734  char* pcHlp=(char*)realloc(*ppCmd,1);
3735  if (pcHlp==NULL) {
3736  if (pfErr!=NULL) fprintf(pfErr,"Allocation of memory for command line failed (%d - %s).\n",errno,strerror(errno));
3737  return(CLERTC_MEM);
3738  }
3739  pcHlp[0]=0x00;
3740  *ppCmd=pcHlp;
3741  }
3742  } else {
3743  char* pcHlp=(char*)realloc(*ppCmd,1);
3744  if (pcHlp==NULL) {
3745  if (pfErr!=NULL) fprintf(pfErr,"Allocation of memory for command line failed (%d - %s).\n",errno,strerror(errno));
3746  return(CLERTC_MEM);
3747  }
3748  pcHlp[0]=0x00;
3749  *ppCmd=pcHlp;
3750  }
3751  }
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);
3755  if (siErr<0) {
3756  SAFE_FREE(*ppCmd);
3757  switch(siErr) {
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);
3761  }
3762  }
3763  if (pfTrc!=NULL) {
3764  char acTs[24];
3765  fprintf(pfTrc,"%s Read parameter string in length %d from command line\n",cstime(0,acTs),(int)strlen(*ppCmd));
3766  }
3767  } else if (argv[1][l]=='=') {
3768  int o=(argv[1][l+1]=='>')?l+2:l+1;
3769  if (argc!=2) {
3770  if (pfErr!=NULL) {
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);
3776  }
3777  return(CLERTC_CMD);
3778  }
3779  *ppFil=dcpmapfil(argv[1]+o);
3780  if (*ppFil==NULL) {
3781  if (pfErr!=NULL) fprintf(pfErr,"Allocation of memory for command file (%s) failed\n",argv[1]+l+1);
3782  return(CLERTC_MEM);
3783  }
3784 
3785  char acMsg[1024]="";
3786  siErr=pfF2S(pvGbl,pvF2S,*ppFil,ppCmd,&siSiz,acMsg,sizeof(acMsg));
3787  if(siErr>0) {
3788  if (pfTrc!=NULL) {
3789  char acTs[24];
3790  fprintf(pfTrc,"%s Read parameter string in length %d from file '%s'\n",cstime(0,acTs),siErr,*ppFil);
3791  }
3792  } else {
3793  if (pfErr!=NULL) fprintf(pfErr,"Command file: %s\n",acMsg);
3794  SAFE_FREE(*ppFil);
3795  SAFE_FREE(*ppCmd);
3796  return(CLERTC_SYS);
3797  }
3798  } else {
3799  if (pfErr!=NULL) {
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);
3806  }
3807  SAFE_FREE(*ppFil);
3808  return(CLERTC_CMD);
3809  }
3810  return(CLERTC_OK);
3811 }
3812 
3813 /**********************************************************************/
3814 
3815 static TsCnfHdl* psCnfOpn(
3816  FILE* pfErr,
3817  const int isCas,
3818  const char* pcPgm,
3819  const char* pcFil)
3820 {
3821  FILE* pfFil;
3822  char acBuf[4046];
3823  char* pcHlp=NULL;
3824  char* pcKyw=NULL;
3825  char* pcVal=NULL;
3826  int siKyw,siVal;
3827  TsCnfEnt* psEnt=NULL;
3828  TsCnfHdl* psHdl=(TsCnfHdl*)calloc(1,sizeof(TsCnfHdl));
3829  if (psHdl==NULL) {
3830  if (pfErr!=NULL) fprintf(pfErr,"Memory allocation for configuration data handle failed\n");
3831  return(NULL);
3832  }
3833  psHdl->isCas=isCas;
3834  psHdl->psFst=NULL;
3835  psHdl->psLst=NULL;
3836  psHdl->pcPgm=pcPgm;
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);
3841  vdCnfCls(psHdl);
3842  return(NULL);
3843  }
3844  strcpy(psHdl->pcFil,pcFil);
3845 
3846  pfFil=fopen_hfq(psHdl->pcFil,"r");
3847  if (pfFil==NULL && (errno==2 || errno==49 || errno==129)) return(psHdl);
3848  if (pfFil==NULL) {
3849  if (pfErr!=NULL) fprintf(pfErr,"Cannot open the configuration file (\"%s\",\"r\") for read operation (%d - %s)\n",psHdl->pcFil,errno,strerror(errno));
3850  vdCnfCls(psHdl);
3851  return(NULL);
3852  }
3853 
3854  while (fgets(acBuf,sizeof(acBuf)-1,pfFil)!=NULL) {
3855  pcHlp=strpbrk(acBuf,HSH_PBRK);//all variants of '#'
3856  if (pcHlp!=NULL) *pcHlp=EOS;
3857  size_t l=strlen(acBuf);
3858  if (l>0) {
3859  pcHlp=acBuf+l;
3860  while (isspace(*(pcHlp-1))) {
3861  pcHlp--; *pcHlp=EOS;
3862  }
3863  pcHlp=strchr(acBuf,'=');
3864  if (pcHlp!=NULL) {
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;
3870  psEnt=(TsCnfEnt*)calloc(1,sizeof(TsCnfEnt));
3871  if (psEnt==NULL) {
3872  if (pfErr!=NULL) fprintf(pfErr,"Memory allocation for configuration data element failed\n");
3873  fclose(pfFil);
3874  vdCnfCls(psHdl);
3875  return(NULL);
3876  }
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);
3883  free(psEnt);
3884  fclose(pfFil);
3885  vdCnfCls(psHdl);
3886  return(NULL);
3887  }
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;
3893  }
3894  psHdl->psLst->psNxt=psEnt;
3895  } else {
3896  psEnt->psNxt=NULL;
3897  psEnt->psBak=NULL;
3898  psHdl->psFst=psEnt;
3899  }
3900  psHdl->psLst=psEnt;
3901  } else {
3902  free(psEnt);
3903  }
3904  }
3905  }
3906  }
3907 
3908  fclose(pfFil);
3909  return(psHdl);
3910 }
3911 
3912 static int siCnfSet(
3913  TsCnfHdl* psHdl,
3914  FILE* pfErr,
3915  const char* pcKyw,
3916  const char* pcVal,
3917  const int isOvr)
3918 {
3919  TsCnfEnt* psEnt;
3920  int siKyw,siVal;
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;
3926  } else {
3927  psHdl->psLst=psEnt->psBak;
3928  }
3929  if (psEnt->psBak!=NULL) {
3930  psEnt->psBak->psNxt=psEnt->psNxt;
3931  } else {
3932  psHdl->psFst=psEnt->psNxt;
3933  }
3934  free(psEnt->pcKyw);
3935  free(psEnt->pcVal);
3936  free(psEnt);
3937  } else {
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);
3942  return(-1);
3943  }
3944  }else {
3945  if (pfErr!=NULL) fprintf(pfErr,"Configuration value (%s) for keyword '%s' already exists\n",psEnt->pcVal,psEnt->pcKyw);
3946  return(1);
3947  }
3948  }
3949  psHdl->isChg=TRUE;
3950  return(0);
3951  }
3952  }
3953 
3954  psEnt=(TsCnfEnt*)calloc(1,sizeof(TsCnfEnt));
3955  if (psEnt==NULL) {
3956  if (pfErr!=NULL) fprintf(pfErr,"Memory allocation for configuration data element failed\n");
3957  return(-1);
3958  }
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);
3965  free(psEnt);
3966  return(-1);
3967  }
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;
3973  }
3974  psHdl->psLst->psNxt=psEnt;
3975  } else {
3976  psEnt->psNxt=NULL;
3977  psEnt->psBak=NULL;
3978  psHdl->psFst=psEnt;
3979  }
3980  psHdl->psLst=psEnt;
3981  } else {
3982  if (pfErr!=NULL) fprintf(pfErr,"Configuration keyword(%s) and/or value(%s) is empty\n", pcKyw, pcVal);
3983  free(psEnt);
3984  return (-1);
3985  }
3986  psHdl->isChg=TRUE;
3987  return(0);
3988 }
3989 
3990 static const char* pcCnfGet(
3991  TsCnfHdl* psHdl,
3992  const char* pcKyw)
3993 {
3994  TsCnfEnt* psEnt;
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);
3997  }
3998  return(NULL);
3999 }
4000 
4001 static int siCnfPutEnv(
4002  TsCnfHdl* psHdl,
4003  const char* pcOwn,
4004  const char* pcPgm)
4005 {
4006  int i,j;
4007  TsCnfEnt* psEnt;
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);
4015  if (pcEnv!=NULL) {
4016  if (strcmp(pcEnv,psEnt->pcVal)==0) {
4017  j++;
4018  }
4019  }
4020  }
4021  }
4022  }
4023  return(j);
4024 }
4025 
4026 static int siCnfPrnEnv(
4027  TsCnfHdl* psHdl,
4028  FILE* pfOut,
4029  const char* pcPre,
4030  const char* pcOwn,
4031  const char* pcPgm)
4032 {
4033  int i;
4034  TsCnfEnt* psEnt;
4035  const char* pcAdd;
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);
4042  if (pcEnv!=NULL) {
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);
4049  } else {
4050  fprintf(pfOut,"%s=%s %c %s\n",pcKyw,psEnt->pcVal,C_HSH,pcAdd);
4051  }
4052  }
4053  }
4054  return(i);
4055 }
4056 
4057 static int siCnfPrn(
4058  TsCnfHdl* psHdl,
4059  FILE* pfOut,
4060  const char* pcPre)
4061 {
4062  int i;
4063  TsCnfEnt* psEnt;
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);
4067  } else {
4068  fprintf(pfOut,"%s=%s\n",psEnt->pcKyw,psEnt->pcVal);
4069  }
4070  }
4071  return(i);
4072 }
4073 
4074 static int siCnfClr(
4075  TsCnfHdl* psHdl)
4076 {
4077  int i=0;
4078  TsCnfEnt* psEnt;
4079  TsCnfEnt* psHlp;
4080  psEnt=psHdl->psFst;
4081  while(psEnt!=NULL) {
4082  psHlp=psEnt->psNxt;
4083  free(psEnt->pcKyw);
4084  free(psEnt->pcVal);
4085  free(psEnt);
4086  psEnt=psHlp;
4087  i++;
4088  }
4089  psHdl->psFst=NULL;
4090  psHdl->psLst=NULL;
4091  psHdl->isClr=TRUE;
4092  return(i);
4093 }
4094 
4095 static void vdCnfCls(
4096  TsCnfHdl* psHdl)
4097 {
4098  TsCnfEnt* psEnt;
4099  TsCnfEnt* psHlp;
4100  FILE* pfFil=NULL;
4101  if (psHdl!=NULL) {
4102  if (psHdl->pcFil!=NULL) {
4103  if ((psHdl->isChg || psHdl->isClr) && psHdl->pcFil[0]) {
4104  pfFil=fopen_hfq(psHdl->pcFil,"w");
4105  }
4106  free(psHdl->pcFil);
4107  }
4108  if (pfFil!=NULL && psHdl->pcPgm!=NULL) {
4109  fprintf(pfFil,"%c Configuration file for program '%s'\n",C_HSH,psHdl->pcPgm);
4110  }
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);
4114  }
4115  psHlp=psEnt->psNxt;
4116  free(psEnt->pcKyw);
4117  free(psEnt->pcVal);
4118  free(psEnt);
4119  }
4120  if (pfFil!=NULL) fclose(pfFil);
4121  free(psHdl);
4122  }
4123 }
4124 
4125 extern int siCleParseString(
4126  const int uiErr,
4127  char* pcErr,
4128  const int isCas,
4129  const int isPfl,
4130  const int isRpl,
4131  const int siMkl,
4132  const char* pcOwn,
4133  const char* pcPgm,
4134  const char* pcBld,
4135  const char* pcCmd,
4136  const char* pcMan,
4137  const char* pcHlp,
4138  const int isOvl,
4139  const char* pcStr,
4140  const TsClpArgument* psTab,
4141  const char* pcDep,
4142  const char* pcOpt,
4143  const char* pcEnt,
4144  int* piMod,
4145  void* pvDat,
4146  void* pvGbl,
4147  void* pvF2S,
4148  TfF2S* pfF2S,
4149  void* pvSaf,
4150  TfSaf* pfSaf,
4151  void** ppClp)
4152 {
4153  int siErr=0;
4154  void* pvHdl;
4155  FILE* pfTmp;
4156  TsClpError stErr;
4157 
4158  pfTmp=fopen_tmp();
4159 
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);
4163  if (pvHdl==NULL) {
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;}
4166  return -1;
4167  }
4168  siErr=siClpParseCmd(pvHdl,NULL,pcStr,TRUE,TRUE,(int*)piMod,NULL);
4169  if (siErr<0) {
4170  snprintf(pcErr,uiErr,
4171  "CTX-MESSAGE : Parsing of string for command '%s' failed\n"
4172  "CLP-STRING : %s\n"
4173  "CLP-ERROR : %d - %s\n"
4174  "CLP-MESSAGE : %s\n"
4175  "CLP-SOURCE : %s (ROW: %d COL: %d)\n",
4176  pcCmd,pcStr,siErr,pcClpError(siErr),
4177  *stErr.ppMsg,*stErr.ppSrc,*stErr.piRow,*stErr.piCol);
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;}
4179  vdClpClose(pvHdl,CLPCLS_MTD_ALL);
4180  return siErr;
4181  }
4182  if (pfTmp!=NULL) fclose_tmp(pfTmp);
4183  if(ppClp==NULL){
4184  vdClpClose(pvHdl,CLPCLS_MTD_ALL);
4185  }else{
4186  vdClpClose(pvHdl,CLPCLS_MTD_KEP);
4187  *ppClp=pvHdl;
4188  }
4189  return 0;
4190 }
4191 
4192 /**********************************************************************/
CleCommand::pcKyw
const char * pcKyw
Pointer to the key word for this command (:alpha:[:alnum:|'_']*).
Definition: CLEDEF.h:383
CLPFLG_NON
#define CLPFLG_NON
To define no special flags.
Definition: CLPDEF.h:188
CLERTC_INF
#define CLERTC_INF
Definition: CLEPUTL.h:895
CLERTC_MAX
#define CLERTC_MAX
Definition: CLEPUTL.h:940
cstime
char * cstime(signed long long t, char *p)
Definition: CLEPUTL.c:4054
strxcmp
int strxcmp(const int ca, const char *s1, const char *s2, const int n, const int c, const int f)
Definition: CLEPUTL.c:3947
efprintf
#define efprintf
Definition: CLEPUTL.h:1597
CLE_DOCTYP_CHAPTER
#define CLE_DOCTYP_CHAPTER
A chapter (level must > 1 and < 6).
Definition: CLEDEF.h:47
CLPTYP_NON
#define CLPTYP_NON
No type - Mark the end of an argument table.
Definition: CLPDEF.h:152
CLE_BUILTIN_IDX_CHGPROP
#define CLE_BUILTIN_IDX_CHGPROP
Definition: FLAMCLE.c:175
CLPPRO_MTD_DOC
#define CLPPRO_MTD_DOC
All property only parameter are printed as documentation.
Definition: CLPDEF.h:180
CLE_BUILTIN_IDX_HELP
#define CLE_BUILTIN_IDX_HELP
Definition: FLAMCLE.c:169
pcClpVersion
const char * pcClpVersion(const int l, const int s, char *b)
Get version information.
Definition: FLAMCLP.c:998
CLE_BUILTIN_IDX_DELPROP
#define CLE_BUILTIN_IDX_DELPROP
Definition: FLAMCLE.c:176
CleDoc::uiLev
unsigned int uiLev
The level of the chapter in the document (cover page is 1 all other chapter > 1).
Definition: CLEDEF.h:109
CLE_BUILTIN_IDX_GRAMMAR
#define CLE_BUILTIN_IDX_GRAMMAR
Definition: FLAMCLE.c:185
CLE_BUILTIN_IDX_VERSION
#define CLE_BUILTIN_IDX_VERSION
Definition: FLAMCLE.c:188
fprintm
int int int int void fprintm(FILE *file, const char *own, const char *pgm, const char *bld, const char *man, const int cnt)
Definition: CLEPUTL.c:1396
siClpPrint
int siClpPrint(void *pvHdl, const char *pcFil, const char *pcNum, const char *pcKnd, const int isCmd, const int isDep, const int isAnc, const int isNbr, const int isShl, const int isIdt, const int isPat, const unsigned int uiLev, const int siPs1, const int siPs2, const int siPr3, void *pvPrn, TfClpPrintPage *pfPrn)
Generate documentation using a callback function.
Definition: FLAMCLP.c:2082
CLE_DOCTYP_SPECIALCODES
#define CLE_DOCTYP_SPECIALCODES
The appendix which prints the special condition codes.
Definition: CLEDEF.h:61
CLERTC_INI
#define CLERTC_INI
Definition: CLEPUTL.h:916
CLE_BUILTIN_IDX_HTMLDOC
#define CLE_BUILTIN_IDX_HTMLDOC
Definition: FLAMCLE.c:172
readEnvars
int readEnvars(const char *pcFil, FILE *pfOut, FILE *pfErr, TsEnVarList **ppList)
Definition: CLEPUTL.c:4245
TfCleClosePrint
int() TfCleClosePrint(void *pvHdl)
Function 'clsHtmlDoc' of library 'libhtmldoc' called if built-in function HTMLDOC used.
Definition: CLEDEF.h:196
TsCnfHdl
struct CnfHdl TsCnfHdl
siClpDocu
int siClpDocu(void *pvHdl, FILE *pfDoc, const char *pcPat, const char *pcNum, const char *pcKnd, const int isCmd, const int isDep, const int isMan, const int isAnc, const int isNbr, const int isIdt, const int isPat, const unsigned int uiLev)
Generate documentation for command line syntax.
Definition: FLAMCLP.c:1674
CleDoc
CLE Structure for documentation table.
Definition: CLEDEF.h:107
SAFE_FREE
#define SAFE_FREE(x)
Definition: CLEPUTL.h:823
CLERTC_ITF
#define CLERTC_ITF
Definition: CLEPUTL.h:931
CLE_DOCTYP_PGMSYNOPSIS
#define CLE_DOCTYP_PGMSYNOPSIS
The program synopsis.
Definition: CLEDEF.h:49
TfIni
int() TfIni(void *pvHdl, FILE *pfOut, FILE *pfTrc, void *pvGbl, const char *pcOwn, const char *pcPgm, void *pvClp)
Type definition for initialization FLAMCLE command structure.
Definition: CLEDEF.h:224
CLPCLS_MTD_ALL
#define CLPCLS_MTD_ALL
Complete close, free anything including the dynamic allocated buffers in the CLP structure.
Definition: CLPDEF.h:167
CleCommand::pfRun
TfRun * pfRun
Pointer to the executed function (use the mapped parameter structure to execute the command....
Definition: CLEDEF.h:390
CLE_DOCTYP_COVER
#define CLE_DOCTYP_COVER
Cover page (level must be 1).
Definition: CLEDEF.h:46
TsCleBuiltin
struct CleBuiltin TsCleBuiltin
fclose_tmp
#define fclose_tmp(fp)
Definition: CLEPUTL.h:885
SETENV
#define SETENV(name, value)
Definition: CLEPUTL.h:861
CLE_BUILTIN_IDX_ABOUT
#define CLE_BUILTIN_IDX_ABOUT
Definition: FLAMCLE.c:189
ClpArgument
Table structure for arguments.
Definition: CLPDEF.h:271
CLE_DOCTYP_REASONCODES
#define CLE_DOCTYP_REASONCODES
The appendix which prints the reason codes (pfMsg must be provided).
Definition: CLEDEF.h:62
FLAMCLP.h
fopen_nowarn
#define fopen_nowarn
Definition: FLAMCLE.c:62
CLE_BUILTIN_IDX_MANPAGE
#define CLE_BUILTIN_IDX_MANPAGE
Definition: FLAMCLE.c:170
CLEMAN.h
fopen_tmp
#define fopen_tmp()
Definition: CLEPUTL.h:884
TsCnfEnt
struct CnfEnt TsCnfEnt
pcCleVersion
const char * pcCleVersion(const int l, const int s, char *b)
Get CLE-version information.
Definition: FLAMCLE.c:541
CLE_BUILTIN_IDX_CONFIG
#define CLE_BUILTIN_IDX_CONFIG
Definition: FLAMCLE.c:184
CLE_DOCTYP_PROGRAM
#define CLE_DOCTYP_PROGRAM
The main program chapter (like chapter but level must < 5).
Definition: CLEDEF.h:48
CLERTC_MAP
#define CLERTC_MAP
Definition: CLEPUTL.h:907
CleDoc::pcNum
const char * pcNum
String for numbering or NULL for no number prefix.
Definition: CLEDEF.h:110
CleCommand
CLE structure for command table.
Definition: CLEDEF.h:382
CLERTC_SYN
#define CLERTC_SYN
Definition: CLEPUTL.h:910
CLERTC_OK
#define CLERTC_OK
Definition: CLEPUTL.h:892
TsCleDocPar
struct CleDocPar TsCleDocPar
mapccsid
const char * mapccsid(const unsigned int uiCcsId)
Definition: CLEPUTL.c:1961
CLERTC_TAB
#define CLERTC_TAB
Definition: CLEPUTL.h:922
CLPPRO_MTD_SET
#define CLPPRO_MTD_SET
Only defined properties are printed (no manual pages used).
Definition: CLPDEF.h:178
siCleParseString
int siCleParseString(const int uiErr, char *pcErr, const int isCas, const int isPfl, const int isRpl, const int siMkl, const char *pcOwn, const char *pcPgm, const char *pcBld, const char *pcCmd, const char *pcMan, const char *pcHlp, const int isOvl, const char *pcStr, const TsClpArgument *psTab, const char *pcDep, const char *pcOpt, const char *pcEnt, int *piMod, void *pvDat, void *pvGbl, void *pvF2S, TfF2S *pfF2S, void *pvSaf, TfSaf *pfSaf, void **ppClp)
Definition: FLAMCLE.c:4125
GETENV
#define GETENV(name)
Definition: CLEPUTL.h:860
CLE_DOCTYP_GRAMMAR
#define CLE_DOCTYP_GRAMMAR
The appendix which prints the grammar.
Definition: CLEDEF.h:56
CLERTC_RUN
#define CLERTC_RUN
Definition: CLEPUTL.h:904
CLERTC_FAT
#define CLERTC_FAT
Definition: CLEPUTL.h:937
TfF2S
int() TfF2S(void *pvGbl, void *pvHdl, const char *pcFil, char **ppBuf, int *piBuf, char *pcMsg, const int siMsg)
Type definition for string to file call back function.
Definition: CLPDEF.h:466
CLE_BUILTIN_IDX_SETOWNER
#define CLE_BUILTIN_IDX_SETOWNER
Definition: FLAMCLE.c:178
C_SBC
#define C_SBC
Definition: CLEPUTL.h:1570
CLE_DOCTYP_PGMHELP
#define CLE_DOCTYP_PGMHELP
The program help.
Definition: CLEDEF.h:51
ClpError::piRow
const int * piRow
Points to an integer containing the current row for the error in *pcSrc*e.
Definition: CLPDEF.h:142
ClpError::piCol
const int * piCol
Points to an integer containing the current column for the error in pcSrc.
Definition: CLPDEF.h:143
siClpGrammar
int siClpGrammar(void *pvHdl, FILE *pfOut)
Print the grammar of the command line compiler.
Definition: FLAMCLP.c:4530
CLE_BUILTIN_IDX_GENDOCU
#define CLE_BUILTIN_IDX_GENDOCU
Definition: FLAMCLE.c:171
CLE_BUILTIN_IDX_ERRORS
#define CLE_BUILTIN_IDX_ERRORS
Definition: FLAMCLE.c:190
CLERTC_ACS
#define CLERTC_ACS
Definition: CLEPUTL.h:928
CleDoc::uiTyp
unsigned int uiTyp
One of the documentation types above.
Definition: CLEDEF.h:108
CLPCLS_MTD_KEP
#define CLPCLS_MTD_KEP
Free anything except the allocated memory in CLP structure and keep the handle open to close it later...
Definition: CLPDEF.h:168
CLE_BUILTIN_IDX_SETPROP
#define CLE_BUILTIN_IDX_SETPROP
Definition: FLAMCLE.c:174
pcClpAbout
const char * pcClpAbout(const int l, const int s, char *b)
Get about information.
Definition: FLAMCLP.c:1004
CLE_BUILTIN_IDX_GETOWNER
#define CLE_BUILTIN_IDX_GETOWNER
Definition: FLAMCLE.c:179
CleCommand::pfFin
TfFin * pfFin
Pointer to the finish function for cleanup (free memory, close files in parameter structure).
Definition: CLEDEF.h:392
CLERTC_FIN
#define CLERTC_FIN
Definition: CLEPUTL.h:898
siClpSyntax
int siClpSyntax(void *pvHdl, const int isSkr, const int isMin, const int siDep, const char *pcPat)
Print command line syntax.
Definition: FLAMCLP.c:1341
CLE_BUILTIN_IDX_GETPROP
#define CLE_BUILTIN_IDX_GETPROP
Definition: FLAMCLE.c:177
ERROR
#define ERROR(x, b)
Definition: FLAMCLE.c:615
CLEPUTL.h
TfSaf
int() TfSaf(void *pvGbl, void *pvHdl, const char *pcVal)
Type definition for resource access check.
Definition: CLPDEF.h:486
CLPPRO_MTD_CMT
#define CLPPRO_MTD_CMT
All properties are printed, but not defined properties are line comments .
Definition: CLPDEF.h:179
CLE_BUILTIN_IDX_LEXEMES
#define CLE_BUILTIN_IDX_LEXEMES
Definition: FLAMCLE.c:186
TfMsg
const char *() TfMsg(const int siRsn)
Type definition for the CLE message function.
Definition: CLEDEF.h:365
CLP_OK
#define CLP_OK
Return code for a successful parsing: 0, otherwize > 0.
Definition: CLPDEF.h:104
CLE_BUILTIN_IDX_GENPROP
#define CLE_BUILTIN_IDX_GENPROP
Definition: FLAMCLE.c:173
CLEBIF_CLS
#define CLEBIF_CLS
Definition: FLAMCLE.c:224
CLE_DOCTYP_PGMSYNTAX
#define CLE_DOCTYP_PGMSYNTAX
The program syntax.
Definition: CLEDEF.h:50
CLERTC_SYS
#define CLERTC_SYS
Definition: CLEPUTL.h:925
CleDoc::pcMan
const char * pcMan
Optional or required manual page with the content of this chapter).
Definition: CLEDEF.h:114
userid
char * userid(const int size, char *buffer)
Definition: CLEPUTL.c:1037
CleDoc::pcIdt
const char * pcIdt
Optional new line separated list of index term for this chapter (printed at the end (indexterm:[])).
Definition: CLEDEF.h:115
CLE_DOCTYP_BUILTIN
#define CLE_DOCTYP_BUILTIN
The built-in function section.
Definition: CLEDEF.h:54
CLERTC_CFG
#define CLERTC_CFG
Definition: CLEPUTL.h:919
siClpLexemes
int siClpLexemes(void *pvHdl, FILE *pfOut)
Print the lexems of the command line compiler.
Definition: FLAMCLP.c:3310
CLE_DOCTYP_LEXEMES
#define CLE_DOCTYP_LEXEMES
The appendix which prints the lexemes.
Definition: CLEDEF.h:55
C_HSH
#define C_HSH
Definition: CLEPUTL.h:1565
CLERTC_CMD
#define CLERTC_CMD
Definition: CLEPUTL.h:913
arry2str
int arry2str(char *array[], const int count, const char *separ, const int separLen, char **out, int *outlen)
Definition: CLEPUTL.c:3887
CLE_DOCTYP_ABOUT
#define CLE_DOCTYP_ABOUT
The appendix which prints the about (pcAbo must be given).
Definition: CLEDEF.h:58
CLERTC_MEM
#define CLERTC_MEM
Definition: CLEPUTL.h:934
ClpError::ppSrc
const char ** ppSrc
If a parameter file assigned and cause of the error pcSrc points to this file name.
Definition: CLPDEF.h:141
CLEBIF_OPN
#define CLEBIF_OPN(name)
Definition: FLAMCLE.c:222
CLE_BUILTIN_IDX_LICENSE
#define CLE_BUILTIN_IDX_LICENSE
Definition: FLAMCLE.c:187
CleOtherClp
CLE table structure for other CLP strings.
Definition: CLEDEF.h:448
file2str
int file2str(void *hdl, const char *filename, char **buf, int *bufsize, char *errmsg, const int msgsiz)
Definition: CLEPUTL.c:3820
CLEMSG.h
messages for Command Line Execution
TfClpPrintPage
int() TfClpPrintPage(void *pvHdl, const int siLev, const char *pcHdl, const char *pcPat, const char *pcFil, const char *pcOrg, const char *pcPge)
Function 'prnHtmlDoc' of library 'libhtmldoc' called if built-in function HTMLDOC used.
Definition: CLPDEF.h:516
esnprintf
#define esnprintf
Definition: CLEPUTL.h:1595
ClpError::ppMsg
const char ** ppMsg
Points to the pointer of a zero-terminated string containing the current error message.
Definition: CLPDEF.h:134
srprintc
int int int srprintc(char **buffer, size_t *size, const size_t expansion, const char *format,...) __PRINTF_CHECK__(4
siClpParseCmd
int siClpParseCmd(void *pvHdl, const char *pcSrc, const char *pcCmd, const int isChk, const int isPwd, int *piOid, char **ppLst)
Parse the command line.
Definition: FLAMCLP.c:1274
CleDoc::pcHdl
const char * pcHdl
Headline for this chapter.
Definition: CLEDEF.h:113
localccsid
unsigned int localccsid(void)
Definition: CLEPUTL.c:1548
CleCommand::pfMap
TfMap * pfMap
Pointer to the mapping function (transfers the argument structure to the parameter structure).
Definition: CLEDEF.h:389
pcCleAbout
const char * pcCleAbout(const int l, const int s, char *b)
Get about CLE-information.
Definition: FLAMCLE.c:547
FLAMCLE.h
Definitions for Command Line Execution.
CleDoc::pcAnc
const char * pcAnc
Optional anchor for this chapter (printed in front of headline in double square brackets).
Definition: CLEDEF.h:112
pcClpInfo
const char * pcClpInfo(void *pvHdl, const char *pcPat)
Give help message for given path.
Definition: FLAMCLP.c:1402
dhomedir
char * dhomedir(const int flag)
Definition: CLEPUTL.c:1148
CLE_BUILTIN_IDX_GETENV
#define CLE_BUILTIN_IDX_GETENV
Definition: FLAMCLE.c:181
dmapstr
char * dmapstr(const char *string, int method)
Definition: CLEPUTL.c:2797
CLE_DOCTYP_PROPREMAIN
#define CLE_DOCTYP_PROPREMAIN
The appendix which prints the remaining parameter documentation.
Definition: CLEDEF.h:59
dcpmapfil
char * dcpmapfil(const char *file)
Definition: CLEPUTL.c:2877
pcClpError
char * pcClpError(int siErr)
Provides error message.
Definition: FLAMCLP.c:1016
CLE_BUILTIN_IDX_SETENV
#define CLE_BUILTIN_IDX_SETENV
Definition: FLAMCLE.c:180
C_TLD
#define C_TLD
Definition: CLEPUTL.h:1576
vdClpClose
void vdClpClose(void *pvHdl, const int siMtd)
Close the command line parser.
Definition: FLAMCLP.c:2361
pvClpOpen
void * pvClpOpen(const int isCas, const int isPfl, const int isEnv, const int siMkl, const char *pcOwn, const char *pcPgm, const char *pcBld, const char *pcCmd, const char *pcMan, const char *pcHlp, const int isOvl, const TsClpArgument *psTab, void *pvDat, FILE *pfHlp, FILE *pfErr, FILE *pfSym, FILE *pfScn, FILE *pfPrs, FILE *pfBld, const char *pcDep, const char *pcOpt, const char *pcEnt, TsClpError *psErr, void *pvGbl, void *pvF2S, TfF2S *pfF2S, void *pvSaf, TfSaf *pfSaf)
Open command line parser.
Definition: FLAMCLP.c:1044
HSH_PBRK
#define HSH_PBRK
Definition: CLEPUTL.h:1561
CLEINI_PROSIZ
#define CLEINI_PROSIZ
Definition: FLAMCLE.c:166
CLE_BUILTIN_IDX_TRACE
#define CLE_BUILTIN_IDX_TRACE
Definition: FLAMCLE.c:183
ClpError
Defines a structure with error information.
Definition: CLPDEF.h:133
CLE_DOCTYP_PROPDEFAULTS
#define CLE_DOCTYP_PROPDEFAULTS
The appendix which prints the default parameter documentation.
Definition: CLEDEF.h:60
CLETAB_BIF
#define CLETAB_BIF(idx, kyw, hlp, syn, man, bif)
Definition: FLAMCLE.c:223
CLERTC_WRN
#define CLERTC_WRN
Definition: CLEPUTL.h:901
CLE_BUILTIN_IDX_SYNTAX
#define CLE_BUILTIN_IDX_SYNTAX
Definition: FLAMCLE.c:168
fopen_hfq
FILE * fopen_hfq(const char *name, const char *mode)
Definition: CLEPUTL.c:492
S_TLD
#define S_TLD
Definition: CLEPUTL.h:1589
CLE_VSN_STR
#define CLE_VSN_STR
Definition: FLAMCLE.c:159
CLE_DOCTYP_OTHERCLP
#define CLE_DOCTYP_OTHERCLP
Other CLP strings.
Definition: CLEDEF.h:53
CLE_DOCTYP_COMMANDS
#define CLE_DOCTYP_COMMANDS
The commands part.
Definition: CLEDEF.h:52
siCleExecute
int siCleExecute(void *pvGbl, const TsCleCommand *psCmd, int argc, char *argv[], const char *pcOwner, const char *pcProgram, const char *pcAut, const char *pcAdr, const int isCas, const int isPfl, const int isRpl, const int isEnv, const int siMkl, FILE *pfOut, FILE *pfTrc, const char *pcDep, const char *pcOpt, const char *pcEnt, const char *pcLic, const char *pcBld, const char *pcVsn, const char *pcAbo, const char *pcHlp, const char *pcDef, TfMsg *pfMsg, const TsCleOtherClp *psOth, void *pvF2S, TfF2S *pfF2S, void *pvSaf, TfSaf *pfSaf, const char *pcDpa, const int siNoR, const TsCleDoc *psDoc)
Execute CLE-command line.
Definition: FLAMCLE.c:1215
CLE_DOCTYP_VERSION
#define CLE_DOCTYP_VERSION
The appendix which prints the version (pcVsn must be given).
Definition: CLEDEF.h:57
CleDoc::pcKyw
const char * pcKyw
Optional ASCIIDOC key word (printed in front of headline in single square brackets).
Definition: CLEDEF.h:111
CLE_BUILTIN_IDX_DELENV
#define CLE_BUILTIN_IDX_DELENV
Definition: FLAMCLE.c:182
siClpParsePro
int siClpParsePro(void *pvHdl, const char *pcSrc, const char *pcPro, const int isChk, char **ppLst)
Parse the property list.
Definition: FLAMCLP.c:1210
srprintf
int int int int srprintf(char **buffer, size_t *size, const size_t expansion, const char *format,...) __PRINTF_CHECK__(4
siClpProperties
int siClpProperties(void *pvHdl, const int siMtd, const int siDep, const char *pcPat, FILE *pfOut)
Generate properties.
Definition: FLAMCLP.c:2200
TfCleOpenPrint
void *() TfCleOpenPrint(FILE *pfOut, FILE *pfErr, const char *pcPat, const char *pcOwn, const char *pcPgm, const char *pcBld, int *piHdr, int *piAnc, int *piIdt, int *piPat, int *psPs1, int *piPs2, int *piPr3)
Function 'opnHtmlDoc' of library 'libhtmldoc' called if built-in function HTMLDOC used.
Definition: CLEDEF.h:178
C_SBO
#define C_SBO
Definition: CLEPUTL.h:1568
CLPTYP_NUMBER
#define CLPTYP_NUMBER
Signed or unsigned integer number (8, 16, 32 or 64 bit).
Definition: CLPDEF.h:154
siClpHelp
int siClpHelp(void *pvHdl, const int siDep, const char *pcPat, const int isAli, const int isMan)
Print help for command line syntax.
Definition: FLAMCLP.c:1447
snprintc
int int snprintc(char *buffer, const size_t size, const char *format,...) __PRINTF_CHECK__(3