/* OSSP rc - Run-command processor ** Copyright (c) 2002 Ralf S. Engelschall ** Copyright (c) 2002 Cable & Wireless Deutschland GmbH ** Copyright (c) 2002 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_anal.c: Run-command processor ISO C source file */ #include #include #include "rc.h" /* Public interfaces */ #include "rc_config.h" /* Configuration interface */ /************************************************ * analNew(void) * * Construct a new analyser * ************************************************/ rc_anal_t *analNew(void) { rc_anal_t *pNew = NULL; pNew = malloc(sizeof(rc_anal_t)); return(pNew); } /************************************************ * private analRcs(rc_anal_t **, const char *) * * Read a rc file identifier to analyse * ************************************************/ rc_return_t analRcs(rc_anal_t **ppInst, const char *kszName) { if (!kszName) RC_THROW(RC_WRN_NUL); else { /* Only enter block with valid string, strdup can't handle NULL */ (*ppInst)->m_szRcs = strdup("Hello"); /* (*ppInst)->m_szRcs = strdup(kszName);*/ TRACE((*ppInst)->m_szRcs); } return(RC_THROW(RC_OK)); } /************************************************ * private analTmp(rc_anal_t **, const char *) * * Read a temp file to use for analysis * ************************************************/ rc_return_t analTmp(rc_anal_t **ppInst, const char *kszName) { TRACE("In analTmp 1"); if (!kszName) { TRACE("In analTmp 2"); RC_THROW(RC_WRN_NUL); TRACE("In analTmp 2.5"); } else { /* Only enter block with valid string, strdup can't handle NULL */ TRACE("In analTmp 3"); (*ppInst)->m_szTmp = strdup("Hello"); TRACE("In analTmp 4"); TRACE((*ppInst)->m_szTmp); TRACE("In analTmp 5"); } TRACE("In analTmp 6"); return(RC_THROW(RC_OK)); } /************************************************ * private analFuncs(rc_anal_t **, const char *) * * Read a functions file to analyse * ************************************************/ rc_return_t analFuncs(rc_anal_t **ppInst, const char *kszName) { if (!kszName) RC_THROW(RC_WRN_NUL); else { /* Only enter block with valid string, strdup can't handle NULL */ (*ppInst)->m_szFuncs = strdup("Hello"); /* (*ppInst)->m_szFuncs = strdup(kszName);*/ TRACE((*ppInst)->m_szFuncs); } return(RC_THROW(RC_OK)); } /************************************************ * private analLocs(rc_anal_t **, const char *) * * Read a location path expression to analyse * ************************************************/ rc_return_t analLocs(rc_anal_t **ppInst, const char *kszPathexpr) { TRACE("analLocs1"); if (kszPathexpr) { /* Strdup can't handle NULL */ TRACE("analLocs2"); (*ppInst)->m_szLocs = strdup("Hello"); /* (*ppInst)->m_szLocs = strdup(kszPathexpr);*/ TRACE((*ppInst)->m_szLocs); TRACE("analLocs3"); } TRACE("analLocs4"); return(RC_THROW(RC_OK)); } /************************************************ * private analSecs(rc_anal_t **, const char **) * * Read a sections vector to analyse * ************************************************/ rc_return_t analSecs(rc_anal_t **ppInst, const char **pkszVector) { ex_t Except; #if 0 # FIXME Das ist very broken! if ((*ppInst)->m_pszSecs) /* Warn on overwrites */ RC_THROW(RC_WRN_OWR); #endif ex_try { /* Sections are a vector, so we must copy accordingly */ (*ppInst)->m_pszSecs = vectorCopy(pkszVector); } ex_catch(Except) { rethrow; } TRACE("Variable pkszVector is not an ANSI string."); return(RC_THROW(RC_OK)); } /************************************************ * analParse(rc_anal_t *) * * Parse the analyzed configuration data * ************************************************/ rc_return_t analParse(rc_anal_t *pInst) { ex_t Except; assert(pInst); /* Verify sanity */ ex_try { /* Read in data from the main configuration */ analRcs (&pInst, configGetrcfile()); TRACE("Alles wunderbar.0"); analTmp (&pInst, configGetval(RC_TMP_VAL)); TRACE("Alles wunderbar.1"); analFuncs(&pInst, configGetval(RC_FNC_VAL)); TRACE("Alles wunderbar.nachFuncs"); analLocs (&pInst, configGetval(RC_LOC_VAL)); TRACE("Alles wunderbar.nachLocs"); analSecs (&pInst, configGetsecs()); TRACE("Alles wunderbar.2"); } ex_catch(Except) { TRACE("En analParse Exception catch state!"); /* rethrow;*/ } return(RC_THROW(RC_OK)); } /************************************************ * analDelete(rc_anal_t *) * * Destruct an analyser * ************************************************/ rc_return_t analDelete(rc_anal_t *pInst) { TRACE("Alles wunderbar.3delete"); #if 0 if (pInst->m_szRcs) /* Rc file names */ free(pInst->m_szRcs); if (pInst->m_szTmp) /* Temp file name */ free(pInst->m_szTmp); if (pInst->m_szFuncs) /* Function file names */ free(pInst->m_szFuncs); if (pInst->m_szLocs) /* Location path names */ free(pInst->m_szLocs); if (pInst->m_pszSecs) /* Section names */ vectorDel(pInst->m_pszSecs); free(pInst); #endif TRACE("Alles wunderbar.4delete"); return(RC_THROW(RC_OK)); }