Index: ossp-pkg/rc/rc.c RCS File: /v/ossp/cvs/ossp-pkg/rc/rc.c,v rcsdiff -q -kk '-r1.36' '-r1.37' -u '/v/ossp/cvs/ossp-pkg/rc/rc.c,v' 2>/dev/null --- rc.c 2002/06/28 18:23:10 1.36 +++ rc.c 2002/07/01 15:03:32 1.37 @@ -39,10 +39,8 @@ void rcError(ex_t Localerr) { if (FAILED((rc_return_t)Localerr.ex_value)) { /* Error condition */ - if ((rc_return_t)Localerr.ex_value == RC_WRN_TRM) + if ((rc_return_t)Localerr.ex_value == RC_ERR_TRM) exit(0); - else if ((rc_return_t)Localerr.ex_value == RC_ERR_USE) - clioptPrintusage(); 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) Index: ossp-pkg/rc/rc.h RCS File: /v/ossp/cvs/ossp-pkg/rc/rc.h,v rcsdiff -q -kk '-r1.33' '-r1.34' -u '/v/ossp/cvs/ossp-pkg/rc/rc.h,v' 2>/dev/null --- rc.h 2002/06/28 17:43:23 1.33 +++ rc.h 2002/07/01 15:03:32 1.34 @@ -62,19 +62,18 @@ RC_ERR_FNC = 8, /* Func file not found */ RC_ERR_DIR = 9, /* Location dir not found */ RC_ERR_RCF = 10, /* Rc file not found */ - RC_WRN_0 = 11, /* Warning base */ - RC_WRN_OWR = 12, /* Overwrite warning */ - RC_WRN_NUL = 13, /* NULL pointer warning */ - RC_WRN_TRM = 14 /* Request to terminate app */ + RC_ERR_TRM = 11, /* Request to terminate app */ + RC_WRN_0 = 12, /* Warning base */ + RC_WRN_OWR = 13, /* Overwrite warning */ + RC_WRN_NUL = 14 /* NULL pointer warning */ } rc_return_t; /* Config function prototypes */ rc_return_t configNew(void); rc_return_t configLoad(int, const char **); +rc_return_t configInfo(void); rc_return_t configVerify(void); rc_return_t configDelete(void); -const char *configSummarize(void); -void configDebug(void); /* FIXME Remove */ /* Config accessor prototypes */ const char *configGetval(rc_opt_t); Index: ossp-pkg/rc/rc_config.c RCS File: /v/ossp/cvs/ossp-pkg/rc/rc_config.c,v rcsdiff -q -kk '-r1.19' '-r1.20' -u '/v/ossp/cvs/ossp-pkg/rc/rc_config.c,v' 2>/dev/null --- rc_config.c 2002/06/27 15:35:58 1.19 +++ rc_config.c 2002/07/01 15:03:33 1.20 @@ -35,35 +35,43 @@ #include "rc_const.h" /* String constants */ static int m_nLocks = 0; /* Server locks, not thread-safe FIXME */ -static char *m_szSummary = NULL; /* Configuration summary storage */ /*************************************** -* configDebug(void) * -* Debug a configuration * -* Warning: There is no error checking * -* or debugging of this * -* debugger block * +* configInfo(void) * +* Print the configuration information * ***************************************/ -void configDebug(void) +rc_return_t configInfo(void) { - int i = 0; ex_t Except; - char **szTemp = NULL; + int i = 0; + char **pszTemp = NULL; /* For holding the section string vector */ try { fprintf(stderr, "Run command file: %s\n", configGetrcfile()); - szTemp = (char **)configGetsecs(); + pszTemp = (char **)configGetsecs(); fprintf(stderr, "Sections:"); - while (szTemp[i]) - fprintf(stderr, " %s", szTemp[i++]); + for (i = 0; pszTemp[i]; i++) + fprintf(stderr, " %s", pszTemp[i]); + fputc('\n', stderr); - fprintf(stderr, "\n%s", configSummarize()); + /* FIXME Not threadsafe, wrap with crit section */ + for (i = 0; i < RC_NUMOPTS; i++) { + if (configGetval(i) == NULL); /* NOP */ + else if (!(strcmp(configGetval(i), "1"))) + fprintf(stderr, "Option %s is on.\n", configGetname(i)); + else + fprintf(stderr, "Option %s is %s.\n", configGetname(i),\ + configGetval(i)); + } } + catch(Except) { rethrow; } + + return(RC_THROW(RC_OK)); } /*************************************** @@ -181,58 +189,6 @@ return(NULL); /* Not reached */ } -/*************************************** -* configSummarize(void) * -* Configuration summary * -***************************************/ -const char *configSummarize(void) -{ - ex_t Except; - int i = 0; - char *szTemp = NULL; - - /* Make sure we start with a blank slate */ - if (m_szSummary) { - free(m_szSummary); - m_szSummary = NULL; - } - - for (i = 0; i < RC_NUMOPTS; i++) - { - try { /* FIXME Not threadsafe, wrap with crit section */ - if (configGetval(i) == NULL); /* NOP */ - else if (!(strcmp(configGetval(i), "1"))) { - szTemp = calloc(1, (m_szSummary ? strlen(m_szSummary) : 0) + strlen(configGetval(i))); - if (m_szSummary) - strcpy(szTemp, m_szSummary); - strcat(szTemp, "Option "); - strcat(szTemp, configGetname(i)); - strcat(szTemp, " is on.\n"); - if (m_szSummary) - free(m_szSummary); - m_szSummary = szTemp; - } - else { - szTemp = malloc(strlen(m_szSummary) + strlen(configGetval(i))); - strcpy(szTemp, m_szSummary); - strcat(szTemp, "Option "); - strcat(szTemp, configGetname(i)); - strcat(szTemp, " is "); - strcat(szTemp, configGetval(i)); - strcat(szTemp, ".\n"); - if (m_szSummary) - free(m_szSummary); - m_szSummary = szTemp; - } - } /* FIXME Not threadsafe, wrap with crit section */ - catch(Except) { /* Breaks the otherwise endless loop above */ - rethrow; - } - } - - return ((const char *)m_szSummary); -} - /************************************************ * configLoad(int, const char **) * * Load a configuration * @@ -264,25 +220,29 @@ short bStop = FALSE; try { /* Basic checks of version, usage, and help options */ - if (configGetval(RC_VER_VAL)) { - fprintf(stdout, "OSSP rc %s\n", RC_VERSION); - bStop = TRUE; - } if (configGetval(RC_USE_VAL)) { clioptPrintusage(); bStop = TRUE; } - if (configGetval(RC_HLP_VAL)) { + else if (configGetval(RC_HLP_VAL)) { clioptPrintusage(); /* FIXME Replace with real help FIXME */ bStop = TRUE; } + else if (configGetval(RC_VER_VAL)) { + fprintf(stdout, "OSSP rc %s\n", RC_VERSION); + bStop = TRUE; + } + else if (configGetval(RC_INF_VAL)) { + configInfo(); + bStop = TRUE; + } } catch(Except) { rethrow; } if (bStop) /* Did user request a non-operation? */ - return(RC_THROW(RC_WRN_TRM)); /* Yes, so terminate after handling. */ + return(RC_THROW(RC_ERR_TRM)); /* Yes, so terminate after handling. */ else return(RC_THROW(RC_OK)); /* No, we should continue processing. */ } @@ -298,8 +258,6 @@ if (--m_nLocks == 0) { /* If m_nLocks is 0, deallocate */ try { /* FIXME, not thread-safe */ clioptDelete(); - if (m_szSummary) - free(m_szSummary); } catch(Except) { rethrow; Index: ossp-pkg/rc/rc_proc.c RCS File: /v/ossp/cvs/ossp-pkg/rc/rc_proc.c,v rcsdiff -q -kk '-r1.9' '-r1.10' -u '/v/ossp/cvs/ossp-pkg/rc/rc_proc.c,v' 2>/dev/null --- rc_proc.c 2002/06/28 18:23:10 1.9 +++ rc_proc.c 2002/07/01 15:03:33 1.10 @@ -166,11 +166,15 @@ ************************************************/ rc_return_t procRun(rc_proc_t *pRc) { - if (configGetval(RC_DBG_VAL)) /* Dump the running config table */ - configDebug(); /* if debug switch is turned on */ - - /* This will print the script to a hardcoded dump device, probably stderr */ - scriptDump(pRc->m_pScript); + /* This will evaluate, execute, or print the script to stdout */ + if (configGetval(RC_EVL_VAL)) /* Evaluate */ + fprintf(stderr, "Error: Evaluate is not implemented yet.\n"); /* FIX */ + else if (configGetval(RC_EXC_VAL)) /* Execute */ + fprintf(stderr, "Error: Execute is not implemented yet.\n"); /* FIX */ + else if (configGetval(RC_PRN_VAL)) /* Print */ + scriptDump(pRc->m_pScript); + else + return(RC_THROW(RC_ERR_INT)); /* Not reached */ return(RC_THROW(RC_OK)); } Index: ossp-pkg/rc/rc_test.sh RCS File: /v/ossp/cvs/ossp-pkg/rc/rc_test.sh,v rcsdiff -q -kk '-r1.13' '-r1.14' -u '/v/ossp/cvs/ossp-pkg/rc/rc_test.sh,v' 2>/dev/null --- rc_test.sh 2002/06/28 17:43:23 1.13 +++ rc_test.sh 2002/07/01 15:03:33 1.14 @@ -64,29 +64,31 @@ echo; echo "./rc --func /u/ms/ossp/rc/rcfunc/rc.func --print --verbose openssh stop sleep=4 start" ./rc --func /u/ms/ossp/rc/rcfunc/rc.func --print --verbose openssh stop sleep=4 start -echo; echo "./rc --func /u/ms/ossp/rc/rcfunc/rc.func --debug --eval uucp restart" -./rc --func /u/ms/ossp/rc/rcfunc/rc.func --debug --eval uucp restart -echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --exec uucp start" -./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --exec uucp start -echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --debug --exec ntp sync" -./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --debug --exec ntp sync -echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --debug --silent --exec ralf feed suppe" -./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --debug --silent --exec ralf feed suppe -echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --L /u/ms/ossp/rc/rcfiles/ --tmp /tmp --silent --exec samba search finish destroy" -./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /u/ms/ossp/rc/rcfiles/ --tmp /tmp --silent --exec samba search finish destroy +echo; echo "./rc --func /u/ms/ossp/rc/rcfunc/rc.func --info --eval uucp restart" +./rc --func /u/ms/ossp/rc/rcfunc/rc.func --info --eval uucp restart +echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --print uucp start" +./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --print uucp start +echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --debug --print ntp sync" +./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --debug --print ntp sync +echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --debug --silent --print ralf feed suppe" +./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --debug --silent --print ralf feed suppe +echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /u/ms/ossp/rc/rcfiles/ --tmp /tmp --silent --print samba search finish destroy" +./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /u/ms/ossp/rc/rcfiles/ --tmp /tmp --silent --print samba search finish destroy -echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /u/ms/ossp/rc/rcfiles/ --tmp /tmp --silent --exec all feed suppe" -./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /u/ms/ossp/rc/rcfiles/ --tmp /tmp --silent --exec all go feed suppe +echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /u/ms/ossp/rc/rcfiles/ --tmp /tmp --silent --print all feed suppe" +./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /u/ms/ossp/rc/rcfiles/ --tmp /tmp --silent --print all go feed suppe -echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /sw/etc/rc.d --tmp /tmp --silent --debug --exec all config barf gag" -./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /sw/etc/rc.d --tmp /tmp --silent --debug --exec all config barf gag +echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /sw/etc/rc.d --tmp /tmp --silent --debug --print all config barf gag" +./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /sw/etc/rc.d --tmp /tmp --silent --debug --print all config barf gag + +echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /sw/etc/rc.d --tmp /tmp --silent --debug --eval all config start" +./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /sw/etc/rc.d --tmp /tmp --silent --debug --eval all config start echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /sw/etc/rc.d --tmp /tmp --silent --debug --exec all config start" ./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /sw/etc/rc.d --tmp /tmp --silent --debug --exec all config start -echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /sw/etc/rc.d --tmp /tmp --silent --debug --exec pam info" -./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /sw/etc/rc.d --tmp /tmp --silent --debug --exec pam info +echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /sw/etc/rc.d --tmp /tmp --silent --debug --print pam info" +./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func -L /sw/etc/rc.d --tmp /tmp --silent --debug --print pam info # Next milestone #RequireOwner