head 1.45; access; symbols OSSP_RC_0_7_3:1.44 OSSP_RC_0_7_2:1.44 OSSP_RC_0_7_1:1.44 OSSP_RC_ALPHA_06:1.41 OSSP_RC_EXBROKEN:1.41 OSSP_RC_SPEC:1.3; locks; strict; comment @ * @; 1.45 date 2003.07.11.14.13.16; author ms; state Exp; branches; next 1.44; 1.44 date 2003.07.07.13.30.51; author ms; state Exp; branches; next 1.43; 1.43 date 2003.07.07.12.55.42; author ms; state Exp; branches; next 1.42; 1.42 date 2003.07.01.13.26.25; author ms; state Exp; branches; next 1.41; 1.41 date 2002.08.01.11.59.55; author ms; state Exp; branches; next 1.40; 1.40 date 2002.07.29.16.34.58; author ms; state Exp; branches; next 1.39; 1.39 date 2002.07.10.19.02.24; author ms; state Exp; branches; next 1.38; 1.38 date 2002.07.05.14.10.24; author ms; state Exp; branches; next 1.37; 1.37 date 2002.07.01.15.03.32; author ms; state Exp; branches; next 1.36; 1.36 date 2002.06.28.18.23.10; author ms; state Exp; branches; next 1.35; 1.35 date 2002.06.28.17.43.23; author ms; state Exp; branches; next 1.34; 1.34 date 2002.06.28.14.20.23; author ms; state Exp; branches; next 1.33; 1.33 date 2002.06.26.14.42.53; author ms; state Exp; branches; next 1.32; 1.32 date 2002.06.26.14.11.16; author ms; state Exp; branches; next 1.31; 1.31 date 2002.06.05.16.24.20; author ms; state Exp; branches; next 1.30; 1.30 date 2002.05.29.12.42.08; author ms; state Exp; branches; next 1.29; 1.29 date 2002.05.22.16.01.49; author ms; state Exp; branches; next 1.28; 1.28 date 2002.05.22.14.32.20; author ms; state Exp; branches; next 1.27; 1.27 date 2002.05.22.13.29.40; author ms; state Exp; branches; next 1.26; 1.26 date 2002.05.22.09.47.27; author ms; state Exp; branches; next 1.25; 1.25 date 2002.05.13.16.57.00; author ms; state Exp; branches; next 1.24; 1.24 date 2002.04.25.16.17.57; author ms; state Exp; branches; next 1.23; 1.23 date 2002.04.25.09.51.29; author ms; state Exp; branches; next 1.22; 1.22 date 2002.04.24.16.47.07; author ms; state Exp; branches; next 1.21; 1.21 date 2002.04.22.15.22.39; author ms; state Exp; branches; next 1.20; 1.20 date 2002.04.22.12.16.39; author ms; state Exp; branches; next 1.19; 1.19 date 2002.04.12.19.15.12; author ms; state Exp; branches; next 1.18; 1.18 date 2002.04.11.16.52.45; author ms; state Exp; branches; next 1.17; 1.17 date 2002.03.26.17.11.06; author ms; state Exp; branches; next 1.16; 1.16 date 2002.03.01.22.48.23; author ms; state Exp; branches; next 1.15; 1.15 date 2002.02.28.18.24.04; author ms; state Exp; branches; next 1.14; 1.14 date 2002.02.28.15.30.04; author ms; state Exp; branches; next 1.13; 1.13 date 2002.02.13.19.19.28; author ms; state Exp; branches; next 1.12; 1.12 date 2002.02.08.18.36.40; author ms; state Exp; branches; next 1.11; 1.11 date 2002.02.07.15.37.54; author ms; state Exp; branches; next 1.10; 1.10 date 2002.02.07.12.38.32; author ms; state Exp; branches; next 1.9; 1.9 date 2002.02.06.18.16.40; author ms; state Exp; branches; next 1.8; 1.8 date 2002.02.05.20.37.34; author ms; state Exp; branches; next 1.7; 1.7 date 2002.02.05.19.12.24; author ms; state Exp; branches; next 1.6; 1.6 date 2002.02.05.17.29.17; author ms; state Exp; branches; next 1.5; 1.5 date 2002.02.04.22.35.20; author ms; state Exp; branches; next 1.4; 1.4 date 2002.02.04.21.48.22; author ms; state Exp; branches; next 1.3; 1.3 date 2002.01.30.17.29.15; author ms; state Exp; branches; next 1.2; 1.2 date 2002.01.08.15.49.02; author ms; state Exp; branches; next 1.1; 1.1 date 2002.01.04.17.14.45; author openpkg-cvs; state Exp; branches; next ; desc @@ 1.45 log @Flush of configuration changes before upcoming configuration structure is completed. @ text @/* OSSP rc - Run-Command Processor ** Copyright (c) 2002-2003 Ralf S. Engelschall ** Copyright (c) 2002-2003 Cable & Wireless Deutschland GmbH ** Copyright (c) 2002-2003 The OSSP Project ** ** This file is part of OSSP rc, a portable run-command processor ** which can be found at http://www.ossp.org/pkg/lib/rc/ ** ** Permission to use, copy, modify, and distribute this software for ** any purpose with or without fee is hereby granted, provided that ** the above copyright notice and this permission notice appear in all ** copies. ** ** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR ** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ** SUCH DAMAGE. ** ** rc.c: Run-Command Processor ISO C source file */ #include /* Just for calling 'exit(3)' once */ #include "rc.h" /* Public interfaces */ /************************************************ * main(int, char **) * * Main rc control block * ************************************************/ int main(int argc, char *argv[]) { ex_t Except; rc_config_t *pConf = NULL; rc_proc_t *pProc = NULL; try { /* Configuration block, config is built here */ pConf = configNew(); /* Construct a new config, add default values */ configLoad(pConf, argc, (const char **)argv); /* Load cli, env, conf */ configDefaults(pConf); /* Add default values to empty config members */ } catch(Except) /* Exceptions of the configuration block */ rcError(Except); try { /* Main processing block, script built */ pProc = procNew(); /* Construct a new processor */ procPopulate(pProc); /* Populate with run commands */ procRun(pProc); /* [Execute|Evaluate|Print] script */ procDelete(pProc); /* Destroy the processor */ configDelete(pConf); /* Destroy the configuration */ } catch(Except) /* Exceptions while script processing */ rcError(Except); exit(0); /* Return success */ } @ 1.44 log @More header corrections and improvements. @ text @d41 2 d45 3 a47 3 configNew(); /* Construct a new config, add default values */ configLoad(argc, (const char **)argv); /* Load cli, env, and conf */ configDefaults(); /* Add default values to empty config members */ a52 1 rc_proc_t *pProc = NULL; d57 1 a57 1 configDelete(); /* Destroy the configuration */ @ 1.43 log @Correct and update copyrights and source headers. @ text @d1 1 a1 1 /* OSSP rc - Run-command processor d6 1 a6 1 ** This file is part of OSSP rc, a portable Run-command processor d27 1 a27 1 ** rc.c: Run-command processor ISO C source file @ 1.42 log @Processor separation, removing logic from generic procRun method and implementing procEval, procExec, procPrint, and procParse methods. @ text @d2 3 a4 3 ** Copyright (c) 2002 Ralf S. Engelschall ** Copyright (c) 2002 Cable & Wireless Deutschland GmbH ** Copyright (c) 2002 The OSSP Project @ 1.41 log @Moved call to configVerify to squash yet another early error bug. @ text @d50 1 a50 1 try { /* Main processing block, script built here */ d52 5 a56 5 pProc = procNew(); /* Construct a new processor, build script */ procPopulate(pProc); /* Populate with run commands */ procRun(pProc); /* [Execute|Evaluate|Print] script */ procDelete(pProc); /* Destroy the processor */ configDelete(); /* Destroy the configuration */ d58 1 a58 1 catch(Except) /* Exception thrown while script processing */ @ 1.40 log @Implement about half of the necessary default configuration members. @ text @a44 1 configVerify(); /* Test for usage, help and version options */ @ 1.39 log @Make the main source file even smaller by splitting out the error handling logic into a new rc_error source file. @ text @d42 1 a42 1 try { /* Configuration block */ d46 1 @ 1.38 log @Prepare for config defaults through addition of the config visitor object. @ text @d30 1 a30 2 #include a32 28 /************************************************ * rcError(ex_t) * * Main rc error handler * ************************************************/ void rcError(ex_t Localerr) { if (FAILED((rc_return_t)Localerr.ex_value)) { /* Error condition */ if ((rc_return_t)Localerr.ex_value == RC_ERR_TRM) exit(0); else if ((rc_return_t)Localerr.ex_value == RC_ERR_FNC) fprintf(stderr, " Error condition, function file could not be opened.\n"); else if ((rc_return_t)Localerr.ex_value == RC_ERR_DIR) fprintf(stderr, " Error condition, location dir could not be opened.\n"); else if ((rc_return_t)Localerr.ex_value == RC_ERR_RCF) fprintf(stderr, " Error condition, rc file could not be opened.\n"); else fprintf(stderr, " Error condition of class '%s',\n exception %d in %s:%s():%d.\n", (char *)Localerr.ex_class, (int)Localerr.ex_value, Localerr.ex_file, Localerr.ex_func, Localerr.ex_line); exit(1); /* Return failure */ } #ifdef DEBUG else /* Warning condition */ fprintf(stderr, " Warning condition of class '%s',\n exception %d in %s:%s():%d.\n", (char *)Localerr.ex_class, (int)Localerr.ex_value, Localerr.ex_file, Localerr.ex_func, Localerr.ex_line); #else else /* Warning condition */ RC_NOP; /* No operation on warnings */ #endif } @ 1.37 log @Wrote configInfo, removed config debugging, prepared procRun for eval/exec/print logic, and improved test conditions. @ text @d71 4 a74 4 try { /* Configuration block */ configNew(); /* Construct a new configuration */ configLoad(argc, (const char **)argv); /* Load cli, env, and conf */ configVerify(); /* Test for usage, help and version options */ d76 1 a76 1 catch(Except) /* Exceptions of the configuration block */ d79 1 a79 1 try { /* Main processing block, script built here */ d81 5 a85 5 pProc = procNew(); /* Construct a new processor, build script */ procPopulate(pProc); /* Populate with run commands */ procRun(pProc); /* [Execute|Evaluate|Print] script */ procDelete(pProc); /* Destroy the processor */ configDelete(); /* Destroy the configuration */ d87 1 a87 1 catch(Except) /* Exception thrown while script processing */ @ 1.36 log @Cleaned main program block and consolidated error handling into rcError(). Also made output of missing section warnings optional according to --debug flag. @ text @d42 1 a42 1 if ((rc_return_t)Localerr.ex_value == RC_WRN_TRM) a43 2 else if ((rc_return_t)Localerr.ex_value == RC_ERR_USE) clioptPrintusage(); @ 1.35 log @Improved section parsing and added back most error condition logic. All combinations of wildcard globbing, multiple section parsing, and error handling now work (except for a problem relating to or using ex). @ text @d36 2 a37 2 * main(int, char **) * * Main rc control block * d39 1 a39 1 int main(int argc, char *argv[]) d41 2 a42 9 ex_t Except; try { /* Configuration block */ configNew(); /* Construct a new configuration */ configLoad(argc, (const char **)argv); /* Load cli, env, and conf */ configVerify(); /* Test for usage, help, and version options */ } catch(Except) { /* Exceptions of the configuration block */ if ((rc_return_t)Except.ex_value == RC_WRN_TRM) d44 1 a44 1 else if ((rc_return_t)Except.ex_value == RC_ERR_USE) d46 6 d53 3 a55 4 if (FAILED((rc_return_t)Except.ex_value)) { /* Error condition */ fprintf(stderr, " Error condition in proc, class '%s',\n exception %d in %s:%s():%d.\n", (char *)Except.ex_class, (int)Except.ex_value, Except.ex_file, Except.ex_func, Except.ex_line); exit(1); /* Return failure */ } d57 2 a58 2 else /* Warning condition */ fprintf(stderr, " Warning condition in proc, class '%s',\n exception %d in %s:%s():%d.\n", (char *)Except.ex_class, (int)Except.ex_value, Except.ex_file, Except.ex_func, Except.ex_line); d60 2 a61 2 else /* Warning condition */ RC_NOP; /* No operation on warnings */ d63 14 d78 2 d81 1 a81 1 try { /* Main processing block, the script is built here */ d89 2 a90 20 catch(Except) { /* Error exceptions thrown during script processing */ if (FAILED((rc_return_t)Except.ex_value)) { /* Error condition */ if ((rc_return_t)Except.ex_value == RC_ERR_FNC) fprintf(stderr, " Error condition, function file could not be opened.\n"); else if ((rc_return_t)Except.ex_value == RC_ERR_DIR) fprintf(stderr, " Error condition, location dir could not be opened.\n"); else if ((rc_return_t)Except.ex_value == RC_ERR_RCF) fprintf(stderr, " Error condition, rc file could not be opened.\n"); else fprintf(stderr, " Error condition in proc, class '%s',\n exception %d in %s:%s():%d.\n", (char *)Except.ex_class, (int)Except.ex_value, Except.ex_file, Except.ex_func, Except.ex_line); exit(1); /* Return failure */ } #ifdef DEBUG else /* Warning condition */ fprintf(stderr, " Warning condition in proc, class '%s',\n exception %d in %s:%s():%d.\n", (char *)Except.ex_class, (int)Except.ex_value, Except.ex_file, Except.ex_func, Except.ex_line); #else else /* Warning condition */ RC_NOP; /* No operation on warnings */ #endif } d92 1 a92 1 exit(0); /* Return success */ @ 1.34 log @Fixed memory bound violation and added section parsing logic. @ text @d43 1 a43 1 ex_try { /* Configuration block */ d48 1 a48 1 ex_catch(Except) { /* Exceptions of the configuration block */ d53 4 a56 4 else { fprintf(stderr, "Class '%s' threw exception %d in %s:%s():%d.\n",\ (char *)Except.ex_class, (int)Except.ex_value,\ Except.ex_file, Except.ex_func, Except.ex_line); d58 7 a64 2 if (FAILED((rc_return_t)Except.ex_value)) /* NOP on warnings */ exit(1); /* Report failure and exit the program */ d67 1 a67 1 ex_try { /* Main processing block, the script is built here */ d75 10 a84 6 ex_catch(Except) { /* Error exceptions thrown during script processing */ TRACE("Also, exception dans le processor bloque"); if (FAILED((rc_return_t)Except.ex_value)) { /* NOP on warnings */ fprintf(stderr, "Class '%s' threw exception %d in %s:%s():%d.\n",\ (char *)Except.ex_class, (int)Except.ex_value,\ Except.ex_file, Except.ex_func, Except.ex_line); d87 5 a91 1 else d93 1 @ 1.33 log @Relocate debug config dumping logic and clean up terminal option handling. @ text @d84 1 @ 1.32 log @Intermediate committal, lots of additions, compiles and works very limited. @ text @a45 1 configDebug(); /* FIXME Remove FIXME */ d49 3 a51 2 TRACE("Hopla, in config exception block"); if ((rc_return_t)Except.ex_value == RC_ERR_USE) { a52 1 } @ 1.31 log @Found segfault bug to be a problem with ex_throw(3), so we go without error reporting during analysis for the moment. @ text @a41 1 rc_anal_t *pAnal = NULL; /* Holds preprocessed configuration */ d43 1 a43 1 ex_try { /* Configuration and abstract analysis block */ a47 3 pAnal = analNew(); /* Construct a new configuration analyser */ analParse(pAnal); /* Preprocess the analysed configuration */ d49 2 a50 2 ex_catch(Except) { /* Exceptions during configuration and analysis */ TRACE("Hopla, in config and anal exception block"); d59 1 a59 1 if (FAILED((rc_return_t)Except.ex_value)) { /* NOP on warnings */ a60 3 } else { } d63 7 a69 11 ex_try { /* Main script building and processing block */ /* rc_script_t *pScript = NULL;*/ /* rc_proc_t *pProc = NULL;*/ /* pScript = scriptNew(pAnal);*/ /* Construct a new script */ /* scriptBuild(pScript);*/ /* pProc = procNew(pScript);*/ /* Construct a new processor */ /* procRun(pProc);*/ /* [Execute|Evaluate|Print] script */ /* procDelete(pProc);*/ /* Destroy the processor */ /* scriptDelete(pScript);*/ /* Destroy the script */ d72 1 a72 12 fprintf(stderr, "Class '%s' threw exception %d in %s:%s():%d.\n",\ (char *)Except.ex_class, (int)Except.ex_value,\ Except.ex_file, Except.ex_func, Except.ex_line); if (FAILED((rc_return_t)Except.ex_value)) /* NOP on warnings */ exit(1); /* Report failure and exit the program */ } ex_try { /* Shutdown of main program */ analDelete(pAnal); /* Destroy the analyser */ configDelete(); /* Destroy the configuration */ } ex_catch(Except) { /* Error exceptions thrown during program shutdown */ d79 2 @ 1.30 log @Temporary debug segfault committal. @ text @a50 1 TRACE("BeforeAnalparse"); a51 1 TRACE("AfterAnalparse"); d54 1 a54 1 TRACE("Hopla1"); a55 1 TRACE("Hopla2"); a56 1 TRACE("Hopla3"); a58 1 TRACE("Hopla4"); a61 1 TRACE("Hopla5"); a62 1 TRACE("Hopla6"); a63 1 TRACE("Hopla7"); a64 1 TRACE("Hopla8"); a66 1 TRACE("Hopla9"); @ 1.29 log @Addition of configuration analyiser and related adjustments to other sources. @ text @d51 1 d53 1 d56 3 a58 1 if ((rc_return_t)Except.ex_value == RC_ERR_USE) d60 4 a63 1 else d67 5 a71 1 if (FAILED((rc_return_t)Except.ex_value)) /* NOP on warnings */ d73 5 d100 1 a100 1 ex_try { /* Start shutdown of main program */ d105 1 a105 1 if (FAILED((rc_return_t)Except.ex_value)) { @ 1.28 log @Minor logic corrections, but mostly cleanup before continuing. @ text @d44 2 a45 2 ex_try { /* Configuration and abstract analysis block */ configNew(); /* Construct a new configuration */ d47 2 a48 2 configDebug(); /* FIXME Remove FIXME */ configVerify(); /* Test for usage, help, and version options */ d50 2 a51 2 /* pAnal = analNew();*/ /* Construct a new analyzer */ /* analParse(pAnal);*/ /* Preprocess the analyzed configuration */ d53 1 a53 1 ex_catch(Except) { /* Exceptions thrown during configuration and analysis */ d66 1 a66 1 rc_proc_t *pProc = NULL; d84 3 a86 3 ex_try { /* Start shutdown of main program */ /* analDelete(pAnal);*/ /* Destroy the analyzer */ configDelete(); /* Destroy the configuration */ @ 1.27 log @Fix the build, comment missing pieces, and synchronize throughout. @ text @d32 1 a32 3 #include "rc.h" /* Public interfaces */ #include "rc_const.h" /* Englisch string constants */ #include "rc_config.h" /* For RC_XXX_VAL definitions */ d42 1 a42 1 rc_anal_t *pAnal = NULL; /* Holds preprocessed configuration */ d44 5 a48 5 ex_try { /* Configuration and abstract analysis block */ configNew(); /* Construct a new configuration */ configLoad(argc, (const char **)argv); /* Load cli, env, and conf */ configDebug(); /* FIXME Remove FIXME */ configVerify(); /* Test for usage, help, and version options */ d54 1 a54 1 if ((rc_return_t)Except.ex_value == RC_ERR_USE) { d56 1 a56 2 } else if (FAILED((rc_return_t)Except.ex_value)) d58 4 a61 3 (char *)Except.ex_class, (int)Except.ex_value,\ Except.ex_file, Except.ex_func, Except.ex_line); exit(1); /* Report failure and exit the program */ d77 5 a81 6 if (FAILED((rc_return_t)Except.ex_value)) { fprintf(stderr, "Class '%s' threw exception %d in %s:%s():%d.\n",\ (char *)Except.ex_class, (int)Except.ex_value,\ Except.ex_file, Except.ex_func, Except.ex_line); exit(1); /* Return failure */ } @ 1.26 log @Architecture in main program body should reflect the design. @ text @d48 1 a48 1 configLoad(argc, argv); /* Read configuration from cli, env, and conf */ d52 2 a53 2 pAnal = analNew(); /* Construct a new analyzer */ analParse(pAnal); /* Preprocess the analyzed configuration */ d59 1 a59 1 else d67 1 a67 1 rc_script_t *pScript = NULL; d70 2 a71 2 pScript = scriptNew(pAnal); /* Construct a new script */ scriptBuild(pScript); d73 4 a76 4 pProc = procNew(pScript); /* Construct a new processor */ procRun(pProc); /* [Execute|Evaluate|Print] script */ procDelete(pProc); /* Destroy the processor */ scriptDelete(pScript); /* Destroy the script */ d78 7 a84 5 ex_catch(Except) { /* Exceptions thrown during script processing */ fprintf(stderr, "Class '%s' threw exception %d in %s:%s():%d.\n",\ (char *)Except.ex_class, (int)Except.ex_value,\ Except.ex_file, Except.ex_func, Except.ex_line); exit(1); /* Return failure */ d88 1 a88 1 analDelete(pAnal); /* Destroy the analyzer */ d91 7 a97 5 ex_catch(Except) { /* Exceptions thrown during program shutdown */ fprintf(stderr, "Class '%s' threw exception %d in %s:%s():%d.\n",\ (char *)Except.ex_class, (int)Except.ex_value,\ Except.ex_file, Except.ex_func, Except.ex_line); exit(1); /* Return failure */ @ 1.25 log @Flush minor work. Building successfuly again. @ text @d44 1 a44 1 rc_proc_t *pProc = NULL; d46 1 a46 1 ex_try { d52 2 a53 10 pProc = procNew(); procReadtmp(pProc, configGetval(RC_TMP_VAL)); /* procReadfuncs(pProc, configGetval(RC_FNC_VAL)); procReadrc(pProc, configGetrcfile()); for (i = 0; i < clioptGetseclen; procSection(pProc, configGetsec(i++))); procParse(pProc); /- Script generation -/ procRun(pProc);*/ /* [Execute|Evaluate|Print] script */ procDelete(pProc); configDelete(); d55 1 a55 1 ex_catch(Except) { d63 31 a93 1 exit(1); /* Failure */ d96 1 a96 1 exit(0); /* Success */ @ 1.24 log @Begin processor pieces. @ text @d44 1 a44 1 rc_t *pRc = NULL; d52 7 a58 7 pRc = procNew(); procReadtmp(pRc, configGetval(RC_TMP_VAL)); /* procReadfuncs(pRc, configGetval(RC_FNC_VAL)); procReadrc(pRc, configGetrcfile()); for (i = 0; i < clioptGetseclen; procSection(pRc, configGetsec(i++))); procParse(pRc); /- Script generation -/ procRun(pRc);*/ /* [Execute|Evaluate|Print] script */ d60 1 a60 1 procDelete(pRc); @ 1.23 log @Moved early option verify from main to config. @ text @a37 23 * rcIntro(void) * * Introduction to rc: help, usage, or version * ************************************************/ rc_return_t rcIntro(void) { ex_t Except; ex_try { /* Basic checks of version, usage, and help options */ if (configGetval(RC_VER_VAL)) fprintf(stdout, "OSSP rc %s\n", RC_VERSION); if (configGetval(RC_USE_VAL)) clioptPrintusage(); if (configGetval(RC_HLP_VAL)) clioptPrintusage(); /* FIXME Replace with real help FIXME */ } ex_catch(Except) { rethrow; } return(RC_THROW(RC_OK)); } /************************************************ d52 5 a56 5 /* pRc = procNew(); procReadrc(pRc); procReadfuncs(pRc); procReadtmp(pRc); for (i = 0; i < clioptGetseclen; procSection(pRc, configGetsec(i))); d58 1 a58 1 procRun(pRc); /- [Execute|Evaluate|Print] script -/ d60 1 a60 1 procDelete(pRc);*/ @ 1.22 log @Command line option configuration and some processor operations. @ text @d73 1 a73 1 rcIntro(); /* Test for usage, help, and version options */ d81 1 a81 1 procOut(pRc); /- [Execute|Evaluate|Print] script -/ @ 1.21 log @Remove obsolete specs and implementations. @ text @a29 1 #include d32 3 a34 3 #include "rc.h" #include "rc_const.h" #include "rc_private.h" d37 27 d67 1 d70 15 a84 9 configConstruct(); configLoad(argc, argv); /* Processing the runcommands */ /* procOpen(szRcfilist, szFuncfilist, szTmpfile); procConf(szEnvass, szSecdef, szSecref, szSecparm); procParse(); procSec(szUmask, szUser, szGroup); procEval(szSection1, szSection2, ...); configDestruct();*/ d87 7 a93 6 if ((int)Except.ex_value == RC_CNF_VRS) fprintf(stdout, "This is OSSP rc, version %s\n", RC_VERSION); fprintf(stderr, "Class '%s' threw exception %d in %s:%s():%d.\n",\ (char *)Except.ex_class, (int)Except.ex_value,\ Except.ex_file, Except.ex_func, Except.ex_line); a96 3 fprintf(stderr, configSummarize()); configDestruct(); /* FIXME Remove, allow first scope */ TRACE("No exceptions caught\n"); @ 1.20 log @Configuration string parsing logic. @ text @a36 4 /* FIXME BEGIN DEBUG */ #include "rc_config.h" #include /* FIXME END DEBUG */ d63 2 a64 23 /* FIXME BEGIN DEBUG */ { int i = 0; int bCaught = FALSE; while (!bCaught) { ex_try { if (configGetval(i)) { fprintf(stderr, "D Option %s: ", configGetname(i)); if (!(strcmp(configGetval(i), "1"))) fprintf(stderr, "on\n"); else fprintf(stderr, "%s\n", configGetval(i)); } } ex_catch(Except) { /* Breaks the otherwise endless while loop above */ bCaught = TRUE; } i++; } } /* FIXME END DEBUG */ configDestruct();/* FIXME Remove, allow first scope */ @ 1.19 log @Flush configuration and parsing work. @ text @d81 1 a81 1 ex_catch(Except) { @ 1.18 log @Flush the toilet. @ text @d37 4 d54 2 a55 2 procEval(szSection1, szSection2, ...);*/ configDestruct(); d67 24 a90 1 TRACE("No exceptions caught"); @ 1.17 log @Vacation flush, mostly build configuration details. Its not building very clean right now. @ text @a32 2 #include d34 1 a37 5 /*TRACE("Vor configLoad."); TRACEL((long)configGetvers()); TRACE("Nach configLoad."); TRACEL((long)configGetvers());*/ a40 1 int bCaught = 0; d45 7 d54 3 a56 1 bCaught = 1; a61 2 if (!bCaught) fprintf(stderr, "main: No exceptions caught.\n"); d63 1 a63 1 configDestruct(); /* Possibly destruct the configuration */ @ 1.16 log @Fixed the build, improved the design, improved the configuration and option processing. @ text @d1 2 a2 1 /* rc - OSSP Run-command processor a4 1 ** Copyright (c) 2002 Ralf S. Engelschall d7 1 a7 1 ** which can be found at http://www.ossp.org/pkg/rc/ @ 1.15 log @Configuration improvements. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d39 5 a50 2 TRACE("Vor configLoad."); TRACEL((long)configGetvers()); a51 2 TRACE("Nach configLoad."); TRACEL((long)configGetvers()); d58 1 a58 1 exit(1); /* Failure */ d63 2 a64 2 configDestruct(); /* Possibly destruct the configuration */ exit(0); /* Success */ @ 1.14 log @Cleanup and structuring. @ text @d33 2 a37 3 /* Initialize our global OSSP ex library identifier */ const char g_szOSSPrc[] = "OSSP rc"; a42 1 rc_config_t *pConf = NULL; d45 6 a50 2 configConstruct(&pConf); configLoad(pConf, argc, argv); d62 1 a62 2 if (pConf) /* If a configuration exists, then burn it */ configDestruct(pConf); @ 1.13 log @Small corrections in both logic and build configuration. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d36 3 d47 2 a48 2 configInit(&pConf); configFill(pConf, argc, argv); @ 1.12 log @Further abstraction and building in of the configuration logic. We now store configuration variables using OSSP val, also. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d49 2 a50 2 fprintf(stderr, "Class '%s' threw exception %s in %s:%s():%d.\n",\ (char *)Except.ex_class, *(int *)Except.ex_value,\ @ 1.11 log @Stop missing stdlib complaining. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d34 1 a34 7 #ifdef HAVE_CONFIG_H #include "rc_config.h" #endif /* Third party headers for libraries linked in */ #include "ex.h" /* OSSP ex exception library */ d41 1 d44 2 a45 1 parseopts(argc, argv); a47 3 if ((rc_return_t)Except.ex_value != RC_ERR_USE) fprintf(stderr, "Nonusage exception: %d\n",\ (rc_return_t)Except.ex_value); d49 4 d54 2 a55 8 if (!bCaught) { fprintf(stderr, "No exceptions caught.\n"); exit(0); /* Success */ } else fprintf(stderr, "Class '%s' threw exception %d in %s:%s():%d.\n",\ (char *)Except.ex_class, *(int *)Except.ex_value,\ Except.ex_file, Except.ex_func, Except.ex_line); d57 3 a59 1 exit(1); /* Failure */ @ 1.10 log @Abstract rc's config according to design. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d31 1 @ 1.9 log @Add exception handling. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @a32 2 #include "rc_p.h" /* FIXME, remove when options moves */ #include "rc_strings.h" /* FIXME, remove when options moves */ d38 1 a38 1 /* Third party headers for libraries linked in */ a39 3 #include "str.h" /* OSSP str string library */ #include "var.h" /* OSSP var variable library */ #include "popt.h" /* OSSP popt options library */ a40 5 /* FIXME if we only catch exceptions we might not need the following */ /* Catch OSSP ex based exceptions */ #define RC_THROW(rv) \ ( (rv) != RC_OK && (ex_catching && !ex_shielding) \ ? (ex_throw(ossprc_id, NULL, (rv)), (rv)) : (rv)) d42 1 a42 5 /* Unique identifier to use with OSSP ex library */ const char ossprc_id[] = "OSSP rc"; static void die(rc_return_t rv) d44 2 a45 3 fprintf(stderr, "OSSP rc: Error, dying.\n"); exit((int)rv); } d47 2 a48 70 int main(int argc, char *argv[]) { char cOpt = 0; /* For argument parsing */ int iBufpos = 0; /* For tracking options */ char *szCLIBuf = NULL; char *szFuncfile = NULL; /* Rc.func file name and location */ int nIter = 0; char pcBuf[BUFSIZ+1]; popt_context optCon; /* Context for parsing options */ struct popt_option optionsTable[] = { /* Long options with short keys but no arguments */ { "usage", '?', POPT_ARG_NONE, 0, RC_USE_VAL, RC_USE_DESC, NULL }, { "debug", 'd', POPT_ARG_NONE, 0, RC_DBG_VAL, RC_DBG_DESC, NULL }, { "version", 'V', POPT_ARG_NONE, 0, RC_VER_VAL, RC_VER_DESC, NULL }, { "eval", 'e', POPT_ARG_NONE, 0, RC_EVL_VAL, RC_EVL_DESC, NULL }, { "help", 'h', POPT_ARG_NONE, 0, RC_HLP_VAL, RC_HLP_DESC, NULL }, { "info", 'i', POPT_ARG_NONE, 0, RC_INF_VAL, RC_INF_DESC, NULL }, { "labels", 'l', POPT_ARG_NONE, 0, RC_LBL_VAL, RC_LBL_DESC, NULL }, { "print", 'p', POPT_ARG_NONE, 0, RC_PRN_VAL, RC_PRN_DESC, NULL }, { "silent", 's', POPT_ARG_NONE, 0, RC_SIL_VAL, RC_SIL_DESC, NULL }, { "raw", 'r', POPT_ARG_NONE, 0, RC_RAW_VAL, RC_RAW_DESC, NULL }, { "verbose", 'v', POPT_ARG_NONE, 0, RC_VRB_VAL, RC_VRB_DESC, NULL }, { "exec", 'x', POPT_ARG_NONE, 0, RC_EXC_VAL, RC_EXC_DESC, NULL }, /* Single argument long options with short keys */ { "locate", 'L', POPT_ARG_STRING, 0, RC_LOC_VAL, RC_LOC_DESC, "regx" }, { "conf", 'c', POPT_ARG_STRING, 0, RC_CNF_VAL, RC_CNF_DESC, "path" }, { "func", 'f', POPT_ARG_STRING, &szFuncfile,\ RC_FNC_VAL, RC_FNC_DESC, "path" }, { "query", 'q', POPT_ARG_STRING, 0, RC_QRY_VAL, RC_QRY_DESC, "varx" }, { "tmp", 't', POPT_ARG_STRING, 0, RC_TMP_VAL, RC_TMP_DESC, "path" }, /* Single argument long options without short keys */ { "RequireOwner", 0, POPT_ARG_STRING, 0,\ RC_OWN_VAL, RC_OWN_DESC, "user" }, { "RequireGroup", 0, POPT_ARG_STRING, 0,\ RC_GRP_VAL, RC_GRP_DESC, "group" }, { "RequireUmask", 0, POPT_ARG_INT, 0,\ RC_MSK_VAL, RC_MSK_DESC, "umask" }, { "ParseEnvAss", 0, POPT_ARG_STRING, 0,\ RC_ASS_VAL, RC_ASS_DESC, "regx" }, { "ParseSectionDef", 0, POPT_ARG_STRING, 0,\ RC_DEF_VAL, RC_DEF_DESC, "regx" }, { "ParseSectionRef", 0, POPT_ARG_STRING, 0,\ RC_REF_VAL, RC_REF_DESC, "regx" }, { "ParseSectionParam", 0, POPT_ARG_STRING, 0,\ RC_PRM_VAL, RC_PRM_DESC, "regx" }, { "ParseTerminal", 0, POPT_ARG_STRING, 0,\ RC_TRM_VAL, RC_TRM_DESC, "regx" }, { "NameConfig", 0, POPT_ARG_STRING, 0,\ RC_NCF_VAL, RC_NCF_DESC, "name" }, { "NameCommon", 0, POPT_ARG_STRING, 0,\ RC_CMN_VAL, RC_CMN_DESC, "name" }, { "NameDefault", 0, POPT_ARG_STRING, 0,\ RC_DFL_VAL, RC_DFL_DESC, "name" }, { "NameError", 0, POPT_ARG_STRING, 0,\ RC_ERR_VAL, RC_ERR_DESC, "name" }, POPT_AUTOHELP { NULL, 0, 0, NULL, 0 } }; optCon = popt_getcontext(NULL, argc, (const char **)argv, optionsTable, 0); popt_setotheroptionhelp(optCon, "[OPTIONS]* [rcfile] [[section [args]] ...]"); if (argc < 2) { popt_printusage(optCon, stderr, 0); exit(1); d50 5 a54 17 /* Now do options processing */ while ((cOpt = popt_getnextopt(optCon)) >= 0) { switch (cOpt) { case 'h': pcBuf[iBufpos++] = 'h'; break; case 'V': pcBuf[iBufpos++] = 'V'; break; case 'i': pcBuf[iBufpos++] = 'i'; break; case 'q': pcBuf[iBufpos++] = 'q'; break; } d56 3 a58 30 { /* FIXME Code snippet to use with throwable library calls FIXME */ ex_t Except; int bCaught = 0; ex_try { /* OSSP exception-enabled library calls go here */ } ex_catch(Except) { if ((rc_return_t)Except.ex_value != RC_ERR_USE) fprintf(stderr, "Nonusage exception: %d\n",\ (rc_return_t)Except.ex_value); bCaught = 1; } if (!bCaught) fprintf(stderr, "Great, we can keep executing exceptionless.\n"); } /* FIXME Code snippet to use with throwable library calls FIXME */ szCLIBuf = (char *)popt_getarg(optCon); if ((szCLIBuf == NULL)) { fprintf(stderr, "Please specify at least one rcfile and section.\n"); popt_printusage(optCon, stderr, 0); die(RC_THROW(RC_ERR_USE)); /* FIXME Vielleicht muss local = */ } /* (int)RC_THROW(RC_ERR_USE));die(local); oder etwas so FIXME */ if (cOpt < -1) { /* An error occurred during option processing */ fprintf(stderr, "%s: %s\n", popt_badoption(optCon, POPT_BADOPTION_NOALIAS), popt_strerror(cOpt)); die(RC_THROW(RC_ERR_INT)); /* FIXME Ebenso als vorherige Merkung */ d60 4 d65 1 a65 10 /* Print out options, szCLIBuf chosen */ fprintf(stderr, "Options chosen: "); for (nIter = 0; nIter < iBufpos ; nIter++) fprintf(stderr, "-%c ", pcBuf[nIter]); if (szFuncfile) fprintf(stderr, "-f %s ", szFuncfile); fprintf(stderr, "\nRun these commands: %s\n", szCLIBuf); popt_freecontext(optCon); exit(0); @ 1.8 log @Fixed copyright and updated the todo list. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d36 4 d46 9 a61 17 void usage(popt_context optCon, rc_return_t rv, char *szError) { popt_printusage(optCon, stderr, 0); if (szError) fprintf(stderr, "%s\n", szError); exit((int)rv); } /*void usage(char *szProgname) { popt_peekarg(optCon) == NULL; fprintf(stdout, "Usage: %s [-v|--verbose] [-h|--help]\n\ [-p|--print] [-e|--eval] [-c|--config]\ [-q|--query] [-r|--raw]\n\ [ ...]", szProgname); }*/ d66 1 a66 1 char *szCLIBuf = NULL; d137 12 a148 12 case 'h': pcBuf[iBufpos++] = 'h'; break; case 'V': pcBuf[iBufpos++] = 'V'; break; case 'i': pcBuf[iBufpos++] = 'i'; break; case 'q': pcBuf[iBufpos++] = 'q'; break; d152 16 d169 5 a173 2 if ((szCLIBuf == NULL)) usage(optCon, RC_ERR_ARG, "Specify at least one rcfile and section."); d178 3 a180 3 popt_badoption(optCon, POPT_BADOPTION_NOALIAS), popt_strerror(cOpt)); die(RC_ERR_ARG); @ 1.7 log @Popt option parsing works fundementally. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d27 1 a27 1 ** rc.c: Run-command processor ANSI C source file @ 1.6 log @Transition flush. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d94 2 a95 1 { "func", 'f', POPT_ARG_STRING, 0, RC_FNC_VAL, RC_FNC_DESC, "path" }, d165 1 a165 1 die(RC_ERR_INT); d169 1 a169 1 printf("Options chosen: "); d171 1 a171 1 printf("-%c ", pcBuf[nIter]); @ 1.5 log @Fixed copyright. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d66 7 a72 6 int main(int argc, char *argv[]) { char cOpt; /* For argument parsing */ int iBufpos = 0; /* For tracking options */ char *szCLIBuf; char szFuncfile; /* Rc.func file name and location */ int nIter; d74 1 a74 2 popt_context optCon; /* Context for parsing options */ rc_return_t nRet; d164 1 a164 1 die(nRet); @ 1.4 log @First cut at a popt enabled configuration. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d1 1 a1 1 /* rc - OSSP Runcommand processor d6 1 a6 1 ** This file is part of OSSP rc, a portable Runcommand processor d27 1 a27 1 ** rc.c: Runcommand processor ANSI C source file @ 1.3 log @Refresh current project state, add OSSP ex library, corrections. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @a30 2 #include #include d33 2 a34 3 #include "ex.h" /* OSSP ex exception library */ #include "str.h" /* OSSP str string library */ #include "var.h" /* OSSP var variable library */ d36 5 d42 16 a57 1 void usage(char *szProgname) d59 1 d64 1 a64 6 } int main(int argc, char *argv[]) { int nOpt = 0; /* holds getopt(3) return value */ int nFile = 0; /* for checking file existence */ d66 74 a139 13 int bVerbose = 0; /* v */ int bHelp = 0; /* h */ int bPrint = 0; /* p */ int bEval = 0; /* e */ int bConfig = 0; /* c */ int bQuery = 0; /* q */ int bRaw = 0; /* r */ while ((nOpt = getopt(argc, argv, "vhpecqr:")) != -1) switch (nOpt) { case 'v': bVerbose = TRUE; break; d141 1 a141 1 bHelp = TRUE; d143 2 a144 2 case 'p': bPrint = TRUE; d146 2 a147 5 case 'e': bEval = TRUE; break; case 'c': bConfig = TRUE; d150 1 a150 4 bQuery = TRUE; break; case 'r': bRaw = TRUE; a151 3 case '?': default: usage(*argv); d153 1 d155 19 a173 6 argc -= optind; argv += optind; /* check existence of file input to the run-command */ if ((nFile = open(optarg, O_RDONLY, 0)) < 0) err(1, "%s", optarg); d175 2 a176 1 return 0; /* success */ @ 1.2 log @Final move from OpenPKG project hierarchy to OSSP project hierarchy. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d33 5 a37 1 #include @ 1.1 log @First cut at bourne script to ANSI C (+improvements) of rc run-command processor @ text @d1 4 a4 5 /* ** OpenPKG rc - Run-Command Handling for OpenPKG ** Copyright (c) 2000-2001 Ralf S. Engelschall ** Copyright (c) 2001-2002 The OpenPKG Project (http://www.openpkg.org/) ** Copyright (c) 2001-2002 Cable & Wireless Deutschland (http://www.cw.com/de/) d6 2 a7 2 ** This file is part of OpenPKG, a packaging facility which can be ** found at http://www.openpkg.org/ d27 1 a27 1 ** rc.c: run-command processor ANSI C source file @