Skip to content
Snippets Groups Projects
Select Git revision
  • dailybuild_linux-x64
  • dailybuild_win32
  • master default protected
  • sqlite
  • rip_abstraction
  • dailybuild_macos-armv8
  • dd_file_lister_filanem_in_desc_color
  • mode7
  • dd_msg_reader_are_you_there_warning_improvement
  • c23-playing
  • syncterm-1.3
  • syncterm-1.2
  • test-build
  • hide_remote_connection_with_telgate
  • 638-can-t-control-c-during-a-file-search
  • add_body_to_pager_email
  • mingw32-build
  • cryptlib-3.4.7
  • ree/mastermind
  • new_user_dat
  • sbbs320d
  • syncterm-1.6
  • syncterm-1.5
  • syncterm-1.4
  • sbbs320b
  • syncterm-1.3
  • syncterm-1.2
  • syncterm-1.2rc6
  • syncterm-1.2rc5
  • push
  • syncterm-1.2rc4
  • syncterm-1.2rc2
  • syncterm-1.2rc1
  • sbbs319b
  • sbbs318b
  • goodbuild_linux-x64_Sep-01-2020
  • goodbuild_win32_Sep-01-2020
  • goodbuild_linux-x64_Aug-31-2020
  • goodbuild_win32_Aug-31-2020
  • goodbuild_win32_Aug-30-2020
40 results

sutils.js

Blame
  • sutils.js 4.03 KiB
    "use strict";
    
    const REVISION = "$Revision: 1.0 $".split(' ')[1];
    
    load("sbbsdefs.js");
    
    print("******************************************************************************");
    print("*                         Synchronet Utilities v" + format("%-28s", REVISION) + " *");
    print("*                 Use Ctrl-C to abort the process if desired                 *");
    print("******************************************************************************");
    
    var file = new File(system.exec_dir + "sutils.ini");
    var categories;
    if(file.open("r")) {
        categories = file.iniGetObject('categories');
        file.close();
    }
    
    
    var which, dopause;
    var categoryitems = [];
    //while((!which || which < 1) && !aborted()) {
    while((!which || which < 1) && !aborted()) {
        dopause = false;
        print("");
        print(">>>> Main Menu");
        print("");
        if (typeof categories !== "undefined") {
            var x = 1;
            for (var catid in categories) {
                printf("%2d. %s\r\n", x, categories[catid]);
                categoryitems[x] = catid;
                x++;
            };
            print("");
            print(" Q. Quit");
        }
        print("");
        var str = prompt("Which Selection? ");
        if (str && str.toUpperCase() == 'Q') {
            exit(0);
        }
        which = parseInt(str, 10);
        if (which && (typeof categoryitems[which] !== "undefined")) {
            docategorymenu(categoryitems[which], categories[categoryitems[which]]);
        }
    
        which = -1; // redisplay menu
    }
    
    function docategorymenu(catid, catname) {
        var which, utilitemids;
        var menuitems = [];
        var utilitems = [];
    
        if (file.open("r")) {
            utilitemids = file.iniGetSections(catid);
        }
    
        for (var i in utilitemids) {
            utilitems[utilitemids[i]] = file.iniGetObject(utilitemids[i]);
        }
    
        file.close();
    
        while ((!which || which < 1) && !aborted()) {
            print("");
            print(">>>> " + catname);
            print("");
    
            if (typeof utilitems !== "undefined") {
                var x = 1;
                for (var iniid in utilitems) {
                    if (file_exists(js.exec_dir + utilitems[iniid].filename)) {
                        printf("%2d. %-20s %s\r\n", x, utilitems[iniid].name, utilitems[iniid].desc);
                        menuitems[x] = iniid;
                        x++;
                    }
                }
                print("");
                print(" Q. Return to Prior Menu");
            }
    
            print("");
            var str = prompt("Which Selection? ");
            if (str && str.toUpperCase() == 'Q') {
                return;
            }
            which = parseInt(str, 10);
            if (which && (typeof utilitems[menuitems[which]] !== "undefined")) {
                var program = utilitems[menuitems[which]];
    
                if (program.showhelpcmd) {
                    print("");
                    system.exec(js.exec_dir + program.showhelpcmd);
                    print("");
                }
                if (program.showhelptext) {
                    print("");
                    print("Program Help: ");
                    var helptexts = program.showhelptext.split("||");
                    for (var h in helptexts) {
                        print(helptexts[h]);
                    }
                    print("");
                }
                if (program.promptforargs) {
                    var consoleargs = prompt("Enter command line arguments (Q to quit): ");
                    if (!consoleargs || (consoleargs && consoleargs.toUpperCase() != 'Q')) {
                        print("Running " + js.exec_dir + program.cmd + " " + consoleargs);
                        system.exec(js.exec_dir + program.cmd + " " + consoleargs);
                    }
                } else {
                    print("Running " + js.exec_dir + program.cmd);
                    system.exec(js.exec_dir + program.cmd);
                }
                // pause so the redisplayed menu doesn't wipe out the prior program's output
                if (program.dopause) {
                    var cont = prompt("Press ENTER to Continue");
                }
            }
    
            which = -1; // redisplay menu4
        }
    
    }
    
    function aborted()
    {
        if (js.terminated || (js.global.console && console.aborted)) {
            exit(1);
        }
        return false;
    }