The top level, which is little more than a demarcation between subcommands.
§1. Every program using foundation must define this:
define PROGRAM_NAME "inprint"
int main(int argc, char **argv) { Initialise inprint2.1; inprint_instructions args = Configuration::read(argc, argv); Make some global settings2.2; if (no_inprint_errors == 0) Delegate to the subcommand2.3; Shut inprint down2.4; }
Foundation::start(argc, argv);
- This code is used in §2.
§3. We keep global settings to a minimum. Note that the installation path can only be set after the command-line switches are read, since they can change it.
pathname *path_to_inprint = NULL; /* where we are installed */ int no_inprint_errors = 0; int verbose_mode = FALSE, silent_mode = FALSE;
§2.2. Make some global settings2.2 =
verbose_mode = args.verbose_switch; silent_mode = args.silent_switch; path_to_inprint = Pathnames::installation_path("PRINT_PATH", I"inprint"); if (verbose_mode) { PRINT("Installation path is %p\n", path_to_inprint); Locales::write_locales(STDOUT); } pathname *M = Pathnames::path_to_inweb_materials(); Pathnames::set_path_to_LP_resources(M);
- This code is used in §2.
§2.3. Delegate to the subcommand2.3 =
switch (args.subcommand) { case NO_CLSUB: if (argc <= 1) PRINT("inprint: a tool for blueprints of file trees. See 'inprint help' for more.\n"); break; case BUILD_CLSUB: InprintBuild::run(&args); break; case DRAW_CLSUB: InprintDraw::run(&args); break; }
- This code is used in §2.
Foundation::end(); return (no_inprint_errors == 0)?0:1;
- This code is used in §2.