00TODO: Tasks left to accomplish before rc is complete Unfinished business Manpage options incorrectly specifies multiple rc.funcs. Manpage reorganization lacks important option combination info. What when multiple command interpreters and one --print or --eval given? File rc.func totally undocumented, but logic should be clear. Control flow Explain logical ordering of multiple section spanning multiple rcfiles. Give example semantics of a common scenario. No error semantics in pseudocode. Known bugs Not multithreaded (too many potentials for race conditions or overwrite) Document Refs, pri, user, group, ci, go only in normal (not special) sections. Consider Nice to have feature for ex, a pEx->pObj->strErr(pEx->Value); Removing the OSSP_RC_DEACT deactivation feature (thl.) Offer include directive in config file. Dynamic handling of command interpreter option. Interpreter option irgendwo dass hat global scope. Als variable in %config Section? Must do Translate rc bourne shell script to ISO C. Finish man page. Start latex or Docbook guide. If a variable is defined for which no default exists, warn user (Scholli.) Make own config, get rid of val because it doesn't hold strings. Write interlocking increment for thread-safe increments. Convert some normal assert() to real runtime checks. Use str_hash von ossp str or static RC_XXX_VAL array from rc_option.h. Detailed ;-) project plan ------------------------- Release v0.8 Milestone 1, Drop in replacement for OpenPKG. Release v0.9 Milestone 2, Additional features in build. Release v1.0 Milestone 3, Cleanup and bugfix. Release v1.2 Milestone 4, Krasse L2 Logging und eigene Sprache Dreams Log to an L2 channel Channel specification could go in rc.conf Processing language !if !else (conditional processing can cross-reference local config vars) !print (print something to stdout) !logit (log something, mstone1-3 to syslog, mstone4 to L2) !lineno [LAST] (the current line number or last successful command) !rcfile [EXISTS|ABSOLUTE] (info about an rcfile) # Is there a way to merge rcfile and rc processor contexts? !envarpush (push an environment variable on the rc stack) !envarpop (pop an environment variable from the rc stack) !throw [var] (returns var to rc processor and ask rc to return -1) !exit [var] (returns var to the rc processor and asks rc to abort execution) !return (signals end of section and returns var to rc processor) ... /-------------------OSSP rc Inhalt------------------\ | Manpage | | rc.1 Section 1 oder 8-Konflict? | | rc-sample.5 Vielleicht umnennen rc.samples.5 | | rc.conf.5 Beschreibung aber kein Beispiel | | | | Geliefert | | rc.env Leer | | rc.conf Ausgekommentet Beispiel | | | | Beispiele | | rc.example Soll rc.foo umgenannt werden | \---------------------------------------------------/ Pseudocode *********************************** * psoudocode implementation of rc * *********************************** parse command line merge all 'rc.conf' files read environment variables build option table parse 'Locate' Locate /cw/etc/rc.d/rc.%{RCFILE:s/^all$/*/} Locate /cw/local/etc/rc.d/rc.%{RCFILE:s/^all$/*/} Locate %{RCFILE}/.duerc Locate ${HOME}/.duerc:m/^(.*)<\/dir>/i Locate ${HOME}/.duerc.%{RCFILE:s/^\///:s/[\/]/-/g} Locate path/file/regex:regex_inside_file for each 'Locate' { for each (all rcfiles after variable expansion and shell globbing) { apply path conversion to rcfilename continue if (absolute path seen previously) // avoid duplicates if (filename matches given rcfile) if (securitycheck(RequireUmask, RequireOwner, RequireGroup)) read and strip file ('Locate' regex, after colon) } } for each rcfile_fraction { parse into blocks according to --ParseSectionDef take out %config section according to --NameConfig take out %common section according to --NameCommon take out %error section according to --NameError take out %default section according to --NameDefault app.mapSections; // create the section map } mapSections () // Map nonexisting %sections to %default { // from now on, 'section' implies 'section->lookupMapval' while (tempSection := ParsedCLI->nextSection) // CLI = command line iface if (rcfile_fraction->has(tempSection)) rcfile_fraction->sectionNames += tempSection; else if (rcfile_fraction->has(%default)) rcfile_fraction->sectionNames += %default; else handle error } for each section on command line { if (multiple rcfiles, i.e. all) sort rcfiles by section priority (%defaults are last) for each rcfile { script = ""; script += %config from rcfile script += rc.env (overriding any duplicate values) create_rcfile_script(script, section, recurse=no) expand internal variables execute, print, or printeval script with user & group priveleges and command interpreter according to options or section header } } EXIT create_rcfile_script(script, section, recurse) { script += "${body}" // start with a pseudo value if (!recurse) { // only one rc.func is possible if no ${body} in rc.func->%common prepend ${body} to rc.func->%common replace script->${body} with rc.func->%common } if no ${body} in rcfile->%common prepend ${body} to rcfile->%common replace script->${body} with rcfile->%common if (!recurse) { // only one rc.func is possible if no ${body} in rc.func->%section prepend ${body} to rc.func->%section replace script->${body} with rc.func->%section } replace script->${body} with rcfile->%section while (ref := ParseSectionRef(script)) ref->create_rcfile_script(recurse=yes); } Test cases ********************* * Test cases for rc * ********************* Pre: tar zxvf ossprc-0.9.tar.gz cd ossprc-0.9 ./configure make su make install export OSSP_RC_ROOT=/etc/ossprc/ Assume: Installed program 'mycom' in /usr/local/bin/mycom Valid OSSP run command file rc.mycom in /etc/ossprc/rc.d File rc.mycom contains the sections start, sync, and restart Begin: $ rc mycom start sync restart Output: Post: Procedure: