The top level, which is little more than a demarcation between subcommands.

§1. Every program using foundation must define this:

define PROGRAM_NAME "inprint"

§2. We do as little as possible here, and delegate everything to the subcommands.

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;
}

§2.1. Initialise inprint2.1 =

    Foundation::start(argc, argv);

§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);

§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;
    }

§2.4. Shut inprint down2.4 =

    Foundation::end();
    return (no_inprint_errors == 0)?0:1;