/ Check-in [36306fb935]
DEMO | DOWNLOAD | DEPLOY | SEARCH
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:pre-release "2.8.37".
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:36306fb935b5a648efddb96ccb7edfa1c83bcfd0
User & Date: pmacdona 2019-06-14 19:00:16
Original Comment: Release "2.8.37". Rename most "Jsi_XXX.jsi" files to "XXX.jsi".
Context
2019-06-14
19:07
Release "2.8.37" Rename most "Jsi_XXX.jsi" files to "XXX.jsi". check-in: f1b7aa0069 user: pmacdona tags: trunk
19:00
pre-release "2.8.37". check-in: 36306fb935 user: pmacdona tags: trunk
2019-06-11
15:33
Fix markdown memory leak. Support "-m Markdown" instead of "-m Jsi_Markdown", etc... check-in: 137a26a0bf user: pmacdona tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to DBI/Makefile.

1
2
3
4
5
6
7
8
9
CDCMD=../jsish -c
#CDCMD=../jsish ../lib/Jsi_CData.jsi
#CDOPTS= -noline true
#CC=cc -fsanitize=address 

DBI.so: DBI.c
	$(CC)  `$(CDCMD) -cflags true DBI.so` -ldbi

DBI.c: DBI.jsc DBIinc.c

|







1
2
3
4
5
6
7
8
9
CDCMD=../jsish -c
#CDCMD=../jsish ../lib/CData.jsi
#CDOPTS= -noline true
#CC=cc -fsanitize=address 

DBI.so: DBI.c
	$(CC)  `$(CDCMD) -cflags true DBI.so` -ldbi

DBI.c: DBI.jsc DBIinc.c

Changes to Make.jsi.

247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
...
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
    if (!JSI__ZIPLIB)
       $.run('cp -f '+PROGBINA+' '+ PROGBIN);
    else {
        $.run('rm -f '+DST);
        $.run('cp '+PROGBINA+' '+DST);
        if (File.exists('../.fslckout'))
            $.run('fossil info | grep ^checkout | cut -b15- > lib/sourceid.txt');
;       $.run(PROGBINMIN+' lib/Jsi_Zip.jsi create '+DST+' '+ZIPDIR+' lib');
    }
    puts("Congratulations, build is now complete. Test with './jsish -u tests'");
};

:'apps': 'ledger.zip':
//apps: sqliteui$(EXEEXT)

................................................................................
    //.FORCE
    $.run('rm '+DST);
    $.run('cd ../Ledger && zip -r  ../jsi/'+DST+' .');
};

:'sqliteui'+EXEEXT::{
    $.run('cp '+PROGBINA+' '+ DST);
    $.run(PROGBINMIN+' lib/Jsi_Zip.jsi create  '+DST+' ../sqliteui lib');
};

:'libwebsocket': WEBSOCKLIB:

:WEBSOCKLIB::{
    $.run($.MAKE+' -C '+WEBSOCKDIR+' CC='+$.CC+' AR='+$.AR+' WIN='+WIN+' TARGET='+TARGET+' USECMAKE='+USECMAKE+' MINIZ='+JSI__MINIZ);
};







|







 







|







247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
...
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
    if (!JSI__ZIPLIB)
       $.run('cp -f '+PROGBINA+' '+ PROGBIN);
    else {
        $.run('rm -f '+DST);
        $.run('cp '+PROGBINA+' '+DST);
        if (File.exists('../.fslckout'))
            $.run('fossil info | grep ^checkout | cut -b15- > lib/sourceid.txt');
;       $.run(PROGBINMIN+' lib/Zip.jsi create '+DST+' '+ZIPDIR+' lib');
    }
    puts("Congratulations, build is now complete. Test with './jsish -u tests'");
};

:'apps': 'ledger.zip':
//apps: sqliteui$(EXEEXT)

................................................................................
    //.FORCE
    $.run('rm '+DST);
    $.run('cd ../Ledger && zip -r  ../jsi/'+DST+' .');
};

:'sqliteui'+EXEEXT::{
    $.run('cp '+PROGBINA+' '+ DST);
    $.run(PROGBINMIN+' lib/Zip.jsi create  '+DST+' ../sqliteui lib');
};

:'libwebsocket': WEBSOCKLIB:

:WEBSOCKLIB::{
    $.run($.MAKE+' -C '+WEBSOCKDIR+' CC='+$.CC+' AR='+$.AR+' WIN='+WIN+' TARGET='+TARGET+' USECMAKE='+USECMAKE+' MINIZ='+JSI__MINIZ);
};

Changes to Makefile.

281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
	cp -f $(PROGBINA) $(PROGBIN)
else
	rm -f $@
	cp $(PROGBINA) $@
ifneq ($(wildcard .fslckout),) 
	fossil info | grep ^checkout | cut -b15- > lib/sourceid.txt
endif
	$(PROGBINMIN) lib/Jsi_Zip.jsi create $@ $(ZIPDIR) lib
endif
	@echo "Finished '$(TARGET)' build. Test with './jsish -u tests'"

apps: ledger.zip
#apps: sqliteui$(EXEEXT)

ledger.zip: .FORCE
	rm $@
	(cd ../Ledger && zip -r  ../jsi/$@ .)


sqliteui$(EXEEXT):  .FORCE
	cp $(PROGBINA) $@
	$(PROGBINMIN) lib/Jsi_Zip.jsi create  $@ ../sqliteui lib

libwebsocket: $(WEBSOCKLIB)
USECMAKE=0

$(WEBSOCKLIB):
ifeq ($(USECMAKE), 1)
	$(MAKE) -C $(WEBSOCKDIR) -f Makefile.cmake CC=$(CC) AR=$(AR) WIN=$(WIN) TARGET=$(TARGET) USECMAKE=$(USECMAKE) MINIZ=$(JSI__MINIZ)







|













|







281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
	cp -f $(PROGBINA) $(PROGBIN)
else
	rm -f $@
	cp $(PROGBINA) $@
ifneq ($(wildcard .fslckout),) 
	fossil info | grep ^checkout | cut -b15- > lib/sourceid.txt
endif
	$(PROGBINMIN) lib/Zip.jsi create $@ $(ZIPDIR) lib
endif
	@echo "Finished '$(TARGET)' build. Test with './jsish -u tests'"

apps: ledger.zip
#apps: sqliteui$(EXEEXT)

ledger.zip: .FORCE
	rm $@
	(cd ../Ledger && zip -r  ../jsi/$@ .)


sqliteui$(EXEEXT):  .FORCE
	cp $(PROGBINA) $@
	$(PROGBINMIN) lib/Zip.jsi create  $@ ../sqliteui lib

libwebsocket: $(WEBSOCKLIB)
USECMAKE=0

$(WEBSOCKLIB):
ifeq ($(USECMAKE), 1)
	$(MAKE) -C $(WEBSOCKDIR) -f Makefile.cmake CC=$(CC) AR=$(AR) WIN=$(WIN) TARGET=$(TARGET) USECMAKE=$(USECMAKE) MINIZ=$(JSI__MINIZ)

Changes to c-demos/cdata/Makefile.

1
2
3
4
5
6
7
8
9
10
JSIDIR=../../src
OTHER=
CSTRFN=../../lib/Jsi_CData.jsi 
JSISH=../../jsish
#CSTRPP=$(JSISH) $(CSTRFN) 
CSTRPP=$(JSISH) -c
CCGET=$(CSTRPP) -cflags true
DEPS=$(CSTRFN) $(JSIDIR)/jsi.c $(JSIDIR)/jsi.h Makefile

all: shared


|







1
2
3
4
5
6
7
8
9
10
JSIDIR=../../src
OTHER=
CSTRFN=../../lib/Cdata.jsi 
JSISH=../../jsish
#CSTRPP=$(JSISH) $(CSTRFN) 
CSTRPP=$(JSISH) -c
CCGET=$(CSTRPP) -cflags true
DEPS=$(CSTRFN) $(JSIDIR)/jsi.c $(JSIDIR)/jsi.h Makefile

all: shared

Deleted js-demos/compat.jsi.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
require('Jsish');

var numbers = [65, 44, 12, 4];

function getSum(total, num) {
    return total + num;
}
;numbers.reduce(getSum);
;numbers.reduceRight(getSum);
;numbers.entries();

/*
=!EXPECTSTART!=
numbers.reduce(getSum) ==> 125
numbers.reduceRight(getSum) ==> 125
numbers.entries() ==> [ 0, 65, 1, 44, 2, 12, 3, 4 ]
=!EXPECTEND!=
*/
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































Changes to js-demos/vfsfossil.jsi.

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17


var target = '../../jsi.fossil';
File.size(target);

var mnt, mnt2, mnt3, mnt4, mnt5, fn, fp, stat, x;
;mnt=Vfs.mount('fossil', target);
x = File.read(mnt+'/lib/Jsi_SqliteUI/html/sqlite.jsi');
;File.glob(mnt+'/lib/*');
;fn = mnt+'/README.md';
;File.read(fn);
;File.size(fn);
;File.mtime(fn);
;stat=File.lstat(fn);
;format('%#o', stat.mode);







|







3
4
5
6
7
8
9
10
11
12
13
14
15
16
17


var target = '../../jsi.fossil';
File.size(target);

var mnt, mnt2, mnt3, mnt4, mnt5, fn, fp, stat, x;
;mnt=Vfs.mount('fossil', target);
x = File.read(mnt+'/lib/SqliteUI/html/sqlite.jsi');
;File.glob(mnt+'/lib/*');
;fn = mnt+'/README.md';
;File.read(fn);
;File.size(fn);
;File.mtime(fn);
;stat=File.lstat(fn);
;format('%#o', stat.mode);

Changes to js-demos/warndemo2.jsi.



1
2
3
4
5
6
7
8
9
10
11
12


// Demonstrates warnings.

function warndemo2() {
    exec();           // Builtin.
    System.exec('a',2,3,4);  // Builtin.
    warndemoA(1,2,3); // No warning
    warndemoB();      // Missing arg.
    warndemoB(1,2,3); // Extra args
    warndemoB('abc'); // Wrong type
}

provide('warndemo2');
>
>












1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/local/bin/jsish --U %s

// Demonstrates warnings.

function warndemo2() {
    exec();           // Builtin.
    System.exec('a',2,3,4);  // Builtin.
    warndemoA(1,2,3); // No warning
    warndemoB();      // Missing arg.
    warndemoB(1,2,3); // Extra args
    warndemoB('abc'); // Wrong type
}

provide('warndemo2');

Changes to js-demos/wsdemo2.jsi.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
..
62
63
64
65
66
67
68
69





























70
71
72
73
74
75
76
77
78
#!/usr/local/bin/jsish
require('Jsish');
require('WebSocket', '2');

function wsdemo2(args:array|string=void, conf:object=void) {

    var self = { };
    var options = { // Demo for exercising Jsi_Websrv. Called with arg 1-6
        noexit:false,    // Ignore exit request in websocket demo.
        timeout:5000    // Shutdown for non-WebSocket demos.
    };
    
    parseOpts(self, options, conf);

    var page = 'wspage.html';
    
    function main(arg) {
        switch (arg?parseInt(arg):'') {
            case 1:
                puts('Serve out file', page);
                Jsi_Websrv(page);
                break;
            case 2:
                puts('Serve out string');
                Jsi_Websrv([], {pageStr:'Hello <b>world</b>', timeout:self.timeout});
                break;
            case 3:
                puts('Serve out string read from file', page);
                Jsi_Websrv([], {pageStr:File.read(page), timeout:self.timeout});
                break;
            case 4:
                puts('Serve out file', page, 'with custom callback');
                Jsi_Websrv(page, {onRecv:onRecv});
                break;
            case 5:
                puts('Serve out file', page, 'with static password: login "abc:123"');
                Jsi_Websrv(page, {onRecv:onRecv, useridPass:'abc:123', timeout:self.timeout});
                break;
            case 6:
                puts('Serve out file', page, 'with onAuth callback: login "abc:xyz"');
                Jsi_Websrv(page, {wsOpts:{onAuth:onAuth}, timeout:self.timeout});
                break;
            default:
                throw("call with arg: 1-6");
        }
    }
    
    function onAuth(ws:userobj, id:number, url:string, userpass:string) {
        puts('Url=',url,' UP=',userpass);
        puts(ws.conf({realm:'altRealm'}));
        return (userpass === 'abc:xyz');
    }
    
    function onRecv(ws:userobj, id:number, dat:object)
................................................................................
            case 'exit': if (!self.noexit) exit(0); return 'exiting';
                
            default: break;
        }
    }
    
    assert(args.length<=1);
    main(args[0]);





























}

provide(wsdemo2);

if (isMain())
    runModule(wsdemo2);

    
    







|








<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16































17
18
19
20
21
22
23
..
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/local/bin/jsish
require('Jsish');
require('WebSocket', '2');

function wsdemo2(args:array|string=void, conf:object=void) {

    var self = { };
    var options = { // Demo for exercising Websrv. Called with arg 1-6
        noexit:false,    // Ignore exit request in websocket demo.
        timeout:5000    // Shutdown for non-WebSocket demos.
    };
    
    parseOpts(self, options, conf);

    var page = 'wspage.html';
    































    function onAuth(ws:userobj, id:number, url:string, userpass:string) {
        puts('Url=',url,' UP=',userpass);
        puts(ws.conf({realm:'altRealm'}));
        return (userpass === 'abc:xyz');
    }
    
    function onRecv(ws:userobj, id:number, dat:object)
................................................................................
            case 'exit': if (!self.noexit) exit(0); return 'exiting';
                
            default: break;
        }
    }
    
    assert(args.length<=1);
    var arg = args[0];

    switch (arg?parseInt(arg):'') {
        case 1:
            puts('Serve out file', page);
            Websrv(page);
            break;
        case 2:
            puts('Serve out string');
            Websrv([], {pageStr:'Hello <b>world</b>', timeout:self.timeout});
            break;
        case 3:
            puts('Serve out string read from file', page);
            Websrv([], {pageStr:File.read(page), timeout:self.timeout});
            break;
        case 4:
            puts('Serve out file', page, 'with custom callback');
            Websrv(page, {onRecv:onRecv});
            break;
        case 5:
            puts('Serve out file', page, 'with static password: login "abc:123"');
            Websrv(page, {onRecv:onRecv, useridPass:'abc:123', timeout:self.timeout});
            break;
        case 6:
            puts('Serve out file', page, 'with onAuth callback: login "abc:xyz"');
            Websrv(page, {wsOpts:{onAuth:onAuth}, timeout:self.timeout});
            break;
        default:
            throw("call with arg: 1-6");
    }
}

provide(wsdemo2);

if (isMain())
    runModule(wsdemo2);

    
    

Changes to js-demos/wsget.jsi.

1
2
3
4
5
6
7
8
9
#!/usr/bin/env jsish
// Test overriding Jsi_Wget to return data.  FYI, could now just use instead {O:'.'}
var response = '';
function WsRecv(ws:userobj, id:number, str:string) { response += str; }
var w = Jsi_Wget(console.args, {nowait:true, O:'-', wsOpts:{onRecv:WsRecv}});
while (!w.done)
    update(200);
printf('%s', response);
        

|


|




1
2
3
4
5
6
7
8
9
#!/usr/bin/env jsish
// Test overriding Wget to return data.  FYI, could now just use instead {O:'.'}
var response = '';
function WsRecv(ws:userobj, id:number, str:string) { response += str; }
var w = Wget(console.args, {nowait:true, O:'-', wsOpts:{onRecv:WsRecv}});
while (!w.done)
    update(200);
printf('%s', response);
        

Name change from lib/Jsi_Archive.jsi to lib/Archive.jsi.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
..
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env jsish

require('Jsish');

// Run module or main.js from a zip, sqlar or fossil repository.

require('Jsi_Vfs');

function Jsi_Archive(args:array, conf:object=void)
{
    var self = {
        app         :'',
        cnt         :0
    };
    var options = { // Run application from a zip, sqlar or fossil repository.
        mainFile    :'main.jsi',// File to execute, if no module given.
................................................................................
                } catch(e) {
                    puts('update failed', e);
                }
            } // TODO: possible to support zip/sqlar as well?
        }
        var info;
        if (ext !== '.zip') {
            mnt = Vfs.vmount({type:ext.substr(1), file:fn, version:self.version, noPatches:self.noPatches});
        } else {
            mnt = Zvfs.mount(fn);
        }
        var dlst = [mnt];
        sbn=mnt+'/lib';
        if (File.isdir(sbn))
            pkgDirs.unshift(sbn);
................................................................................
        console.args = console.args.slice(1);
        LogTrace('Source:', msrc, console.args);
        return source(msrc, {global:true, isMain:true});
    }
    return main();
}

provide(Jsi_Archive);

if (isMain()) 
    runModule(Jsi_Archive);







|

|







 







|







 







|


|

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
..
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env jsish

require('Jsish');

// Run module or main.js from a zip, sqlar or fossil repository.

require('VFS');

function Archive(args:array, conf:object=void)
{
    var self = {
        app         :'',
        cnt         :0
    };
    var options = { // Run application from a zip, sqlar or fossil repository.
        mainFile    :'main.jsi',// File to execute, if no module given.
................................................................................
                } catch(e) {
                    puts('update failed', e);
                }
            } // TODO: possible to support zip/sqlar as well?
        }
        var info;
        if (ext !== '.zip') {
            mnt = VFS.vmount({type:ext.substr(1), file:fn, version:self.version, noPatches:self.noPatches});
        } else {
            mnt = Zvfs.mount(fn);
        }
        var dlst = [mnt];
        sbn=mnt+'/lib';
        if (File.isdir(sbn))
            pkgDirs.unshift(sbn);
................................................................................
        console.args = console.args.slice(1);
        LogTrace('Source:', msrc, console.args);
        return source(msrc, {global:true, isMain:true});
    }
    return main();
}

provide(Archive);

if (isMain()) 
    runModule(Archive);

Name change from lib/Jsi_CData.jsi to lib/Cdata.jsi.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
..
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
...
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
....
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
#!/usr/bin/env jsish

require('Jsish');

// A C-API generator for structs, enums, maps, and extensions.

function Jsi_CData(args:array, conf:object=void)
{
    
    var options = {         // The C-API preprocessor for structs and enums.
        cc          :'gcc', // Compiler to use with -compile.
        compile       :false,// Compile shared lib directly from .jsc arg: uses -cflags
        confSuffix  :'',    // Suffix to add to struct used for object config.
        cflags      :false, // Return CFLAGS to compile FILE/FILE.so from .c generated by a .jsc.
................................................................................
        init:[], types:'',  structs:'', enums:'', vars:'', cmds:'',
        varnames:[], mapnames:[], cmdnames:[], 
        structmap:{}, enummap:{}, enumzero:{}, structfieldmap:{},
        vardefs:'',  siglst:[], varinits:'', mapinits:'', enumIni:{},
        portlst:[], statlst:[], cmddefs:'', cmddef:'',
        enumvals:{}, indata:'', infile:'', outFile:null, rootname:null,
        lnstart:0, setCons:0, icode:[], outcode:'', addflags:'',
        preface: '// DO NOT EDIT: file generated by Jsi_CData.jsi'
    };
    self.pkg = require('Jsi_CData', 0);
    self.version = self.pkg.version;
    self.verStr = self.pkg.verStr;
    var Ex = {asize:0, offs:1, size:2, sig:3};
    var EV = { enum:[], struct:[], vars:[] };

    parseOpts(self, options, conf);

................................................................................
        +", .types=CS_TYPES_"+name
        +"  };\n\n"

        + self.cmddef

        
        + "\n\nstatic const Jsi_CData_Static* jsi_c_init_"+name+"(Jsi_Interp *interp) {\n"
        + '  if (interp && (Jsi_PkgRequire(interp, "CData", 0)<0 || \n'
        + "      JSI_OK != Jsi_CDataRegister(interp, &CS_STATICS_"+name+"))) return NULL;\n\n"

        + self.cmddefs 

        + "\n  return &CS_STATICS_"+name+";\n}\n\n"
        + "\n#endif\n#endif\n"
        + format(self.selfSuffix.replace(/Demo/g, name), scnm);
................................................................................

    var retval = main();
    if (retval === undefined)
        return '';
    return retval;
}

provide(Jsi_CData, "2");

if (isMain())
    runModule(Jsi_CData);







|







 







|

|







 







|







 







|


|

1
2
3
4
5
6
7
8
9
10
11
12
13
14
..
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
...
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
....
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
#!/usr/bin/env jsish

require('Jsish');

// A C-API generator for structs, enums, maps, and extensions.

function Cdata(args:array, conf:object=void)
{
    
    var options = {         // The C-API preprocessor for structs and enums.
        cc          :'gcc', // Compiler to use with -compile.
        compile       :false,// Compile shared lib directly from .jsc arg: uses -cflags
        confSuffix  :'',    // Suffix to add to struct used for object config.
        cflags      :false, // Return CFLAGS to compile FILE/FILE.so from .c generated by a .jsc.
................................................................................
        init:[], types:'',  structs:'', enums:'', vars:'', cmds:'',
        varnames:[], mapnames:[], cmdnames:[], 
        structmap:{}, enummap:{}, enumzero:{}, structfieldmap:{},
        vardefs:'',  siglst:[], varinits:'', mapinits:'', enumIni:{},
        portlst:[], statlst:[], cmddefs:'', cmddef:'',
        enumvals:{}, indata:'', infile:'', outFile:null, rootname:null,
        lnstart:0, setCons:0, icode:[], outcode:'', addflags:'',
        preface: '// DO NOT EDIT: file generated by '
    };
    self.pkg = require('Cdata', 0);
    self.version = self.pkg.version;
    self.verStr = self.pkg.verStr;
    var Ex = {asize:0, offs:1, size:2, sig:3};
    var EV = { enum:[], struct:[], vars:[] };

    parseOpts(self, options, conf);

................................................................................
        +", .types=CS_TYPES_"+name
        +"  };\n\n"

        + self.cmddef

        
        + "\n\nstatic const Jsi_CData_Static* jsi_c_init_"+name+"(Jsi_Interp *interp) {\n"
        + '  if (interp && (Jsi_PkgRequire(interp, "Cdata", 0)<0 || \n'
        + "      JSI_OK != Jsi_CDataRegister(interp, &CS_STATICS_"+name+"))) return NULL;\n\n"

        + self.cmddefs 

        + "\n  return &CS_STATICS_"+name+";\n}\n\n"
        + "\n#endif\n#endif\n"
        + format(self.selfSuffix.replace(/Demo/g, name), scnm);
................................................................................

    var retval = main();
    if (retval === undefined)
        return '';
    return retval;
}

provide(Cdata, "2");

if (isMain())
    runModule(Cdata);

Name change from lib/Jsi_Csspp.jsi to lib/Csspp.jsi.

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
...
102
103
104
105
106
107
108
109
110
111
112
113
 * 
 *  #mybut1 { color:$mycolor; font-size:$mysize}
 *  #myentry { $mydefn; margin:1px }
 * 
 *
 */

function Jsi_Csspp(files:array|string=null, conf:object=undefined):string|object
{
    var options = { // A CSS preprocessor providing $var substitution
        debug       :false,      // Enable debug.
        fatal       :false,      // Throw error on redefine/undefined.
        trimDef     :true,       // Trim whitespace from definitions.
        trimAll     :true        // Trim whitespace from final.
    };
................................................................................
    if (files)
        return parse(files);
        
    self.parse = parse;
    return self;
}

provide(Jsi_Csspp, 1.0);

if (isMain())
    runModule(Jsi_Csspp);








|







 







|


|

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
...
102
103
104
105
106
107
108
109
110
111
112
113
 * 
 *  #mybut1 { color:$mycolor; font-size:$mysize}
 *  #myentry { $mydefn; margin:1px }
 * 
 *
 */

function Csspp(files:array|string=null, conf:object=undefined):string|object
{
    var options = { // A CSS preprocessor providing $var substitution
        debug       :false,      // Enable debug.
        fatal       :false,      // Throw error on redefine/undefined.
        trimDef     :true,       // Trim whitespace from definitions.
        trimAll     :true        // Trim whitespace from final.
    };
................................................................................
    if (files)
        return parse(files);
        
    self.parse = parse;
    return self;
}

provide(Csspp, 1.0);

if (isMain())
    runModule(Csspp);

Name change from lib/Jsi_Debug.jsi to lib/Debug.jsi.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
...
488
489
490
491
492
493
494
495
496
497
498
#! /usr/bin/env jsish

require('Jsish');

// A Debugger for Jsi scripts.  Scripts are executed in a sub-interpreter.

function Jsi_Debug(fileargs:array, conf:object=void):number {

    var options = { // A command-line Debugger for Jsi scripts.
        echoCmd     :true,      // Echo user cmds.
        safe        :false      // Debug program in a safe interp (untested)
    };
    var self = {
        curline:0,      // Next 3 are changed by up/down.
................................................................................
        puts("JSI DEBUGGER EXIT: "+(rc===undefined?"":rc));
        return 0;
    }
    LogDebug('Starting');
    return main();
}

provide(Jsi_Debug, 1.0);

if (isMain())
    exit( runModule(Jsi_Debug) );






|







 







|


|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
...
488
489
490
491
492
493
494
495
496
497
498
#! /usr/bin/env jsish

require('Jsish');

// A Debugger for Jsi scripts.  Scripts are executed in a sub-interpreter.

function Debug(fileargs:array, conf:object=void):number {

    var options = { // A command-line Debugger for Jsi scripts.
        echoCmd     :true,      // Echo user cmds.
        safe        :false      // Debug program in a safe interp (untested)
    };
    var self = {
        curline:0,      // Next 3 are changed by up/down.
................................................................................
        puts("JSI DEBUGGER EXIT: "+(rc===undefined?"":rc));
        return 0;
    }
    LogDebug('Starting');
    return main();
}

provide(Debug, 1.0);

if (isMain())
    exit( runModule(Debug) );

Name change from lib/Jsi_DebugUI/Jsi_DebugUI.jsi to lib/DebugUI/DebugUI.jsi.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
...
767
768
769
770
771
772
773
774
775
776
777
778
#!/usr/bin/env jsish
"use strict,!error";
// Jsi_DebugUI: A jsi debugger with a web user interface.
// This module combines code from Jsi_Debug and Jsi_Websrv.

require('Jsish');
require('Sqlite');
require('WebSocket', '2');

function Jsi_DebugUI(fileargs:array, conf:object=void)
{

    var options = { // A web-based debugger for Jsi scripts
        browser     :null,      // Browser program to use.
        closeTimeout:10000,     // When last client exits, grace time after before exiting (in ms).
        debug       :false,     // Debugging output
        echoCmd     :false,     // Echo user cmds.
................................................................................
        if (self.debug)
            LogDebug("PROGRAM RUNNING");
        return true;
    };

    function main() {
        debugger;
        var req = require("Jsi_DebugUI", 1.0);
        if (!self.rootdir)
            self.rootdir=File.dirname(req.loadFile);
        self.args = null;
        if (typeof(fileargs) !== 'array')
            self.dbfile = fileargs;
        else {
            self.dbfile = fileargs[0];
................................................................................
        delete self.interp;
        return 0;
    }
    
    return main();
}

provide(Jsi_DebugUI, 1.0);

if (isMain())
    exit(runModule(Jsi_DebugUI));



|
|





|







 







|







 







|


|

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
...
767
768
769
770
771
772
773
774
775
776
777
778
#!/usr/bin/env jsish
"use strict,!error";
// DebugUI: A jsi debugger with a web user interface.
// This module combines code from Debug and Websrv.

require('Jsish');
require('Sqlite');
require('WebSocket', '2');

function DebugUI(fileargs:array, conf:object=void)
{

    var options = { // A web-based debugger for Jsi scripts
        browser     :null,      // Browser program to use.
        closeTimeout:10000,     // When last client exits, grace time after before exiting (in ms).
        debug       :false,     // Debugging output
        echoCmd     :false,     // Echo user cmds.
................................................................................
        if (self.debug)
            LogDebug("PROGRAM RUNNING");
        return true;
    };

    function main() {
        debugger;
        var req = require("DebugUI", 1.0);
        if (!self.rootdir)
            self.rootdir=File.dirname(req.loadFile);
        self.args = null;
        if (typeof(fileargs) !== 'array')
            self.dbfile = fileargs;
        else {
            self.dbfile = fileargs[0];
................................................................................
        delete self.interp;
        return 0;
    }
    
    return main();
}

provide(DebugUI, 1.0);

if (isMain())
    exit(runModule(DebugUI));

Name change from lib/Jsi_DebugUI/html/debugui.cssi to lib/DebugUI/html/debugui.cssi.

Name change from lib/Jsi_DebugUI/html/debugui.jsi to lib/DebugUI/html/debugui.jsi.

1
2
3
4
5
6
7
8
// Web browser side of the user interface communicating with Jsi_DebugUI.jsi.
// This file is preprocessed to support function parameters with types.
"use strict";

var self = {
    autosel:true,
    breakpoints:[],
    curline:0, curfunc:null, curfile:null, curfdata:'',  // Current state info.
|







1
2
3
4
5
6
7
8
// Web browser side of the user interface communicating with DebugUI.jsi.
// This file is preprocessed to support function parameters with types.
"use strict";

var self = {
    autosel:true,
    breakpoints:[],
    curline:0, curfunc:null, curfile:null, curfdata:'',  // Current state info.

Name change from lib/Jsi_DebugUI/html/debugui_doc.html to lib/DebugUI/html/debugui_doc.html.

1
2
3
4
5
6
7
8
9
10
11
12
..
43
44
45
46
47
48
49
50
51
<div style="margin:8px">
<H2>Jsi_DebugUI: a debugger for Jsi</H2>

<a href="http://jsish.org">Jsi</a> is a scripting language for C developers, and
<i>Jsi_DebugUI</i> is it's web-based script debugger supporting:
<ul>
  <li>Breakpoint toggle by double clicking (on whitespace in a line).</li>
  <li>Command buttons for <b>step</b> and <b>next</b>, moving <b>up</b> and <b>down</b> call stack, etc.</li>
  <li>Printing/evaluating values by highlighting a variable and clicking Print or Eval.</li>
  <li>A <b>halt</b> command to stop execution (in place of control-c).</li>
  <li>Dialogs/navigators for Functions, Breakpoint, Options and the Stack.</li>
</ul>
................................................................................
<b>tbreak</b>    : Sets a temporary breakpoint
<b>up</b>        : Move up one or more stack levels
<b>where</b>     : Display current location
<b>xeval</b>     : Does eval in debugger context
</pre>

<p>
The backed for Jsi_DebugUI is builtin in <a href=http://jsish.org/jsi/www/home.html  target=_blank>Jsish</a>.
</div>

|


|







 







|

1
2
3
4
5
6
7
8
9
10
11
12
..
43
44
45
46
47
48
49
50
51
<div style="margin:8px">
<H2>DebugUI: a debugger for Jsi</H2>

<a href="http://jsish.org">Jsi</a> is a scripting language for C developers, and
<i>DebugUI</i> is it's web-based script debugger supporting:
<ul>
  <li>Breakpoint toggle by double clicking (on whitespace in a line).</li>
  <li>Command buttons for <b>step</b> and <b>next</b>, moving <b>up</b> and <b>down</b> call stack, etc.</li>
  <li>Printing/evaluating values by highlighting a variable and clicking Print or Eval.</li>
  <li>A <b>halt</b> command to stop execution (in place of control-c).</li>
  <li>Dialogs/navigators for Functions, Breakpoint, Options and the Stack.</li>
</ul>
................................................................................
<b>tbreak</b>    : Sets a temporary breakpoint
<b>up</b>        : Move up one or more stack levels
<b>where</b>     : Display current location
<b>xeval</b>     : Does eval in debugger context
</pre>

<p>
The backed for DebugUI is builtin in <a href=http://jsish.org/jsi/www/home.html  target=_blank>Jsish</a>.
</div>

Name change from lib/Jsi_DebugUI/html/dialog.html to lib/DebugUI/html/dialog.html.

Name change from lib/Jsi_DebugUI/html/main.htmli to lib/DebugUI/html/main.htmli.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!DOCTYPE html>
<html style="height: 100%">
  <head>
    <meta charset=utf-8 />
    <title>DebugUI</title>
    <link rel="icon" href="data:;base64,iVBORw0KGgo=">

    <script src="/jsi/web/JSig.js"></script>
    <script src="/jsi/web/bind.js"></script>
<? 
    // Load .jsi and .cssi for preprocessing inline.
    include(['debugui.jsi', 'debugui.cssi']);
?>
  </head>
  <body id="body" onload="onload()" style="display: flex; height: 97%; flex-direction: column; margin:3px">







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!DOCTYPE html>
<html style="height: 100%">
  <head>
    <meta charset=utf-8 />
    <title>DebugUI</title>
    <link rel="icon" href="data:;base64,iVBORw0KGgo=">

    <script src="/jsi/web/jsig.js"></script>
    <script src="/jsi/web/bind.js"></script>
<? 
    // Load .jsi and .cssi for preprocessing inline.
    include(['debugui.jsi', 'debugui.cssi']);
?>
  </head>
  <body id="body" onload="onload()" style="display: flex; height: 97%; flex-direction: column; margin:3px">

Name change from lib/Jsi_DebugUI/main.jsi to lib/DebugUI/main.jsi.

1
2
3
4
5
#!/usr/bin/env jsish

source('Jsi_DebugUI.jsi', {isMain:true});




|


1
2
3
4
5
#!/usr/bin/env jsish

source('DebugUI.jsi', {isMain:true});


Name change from lib/Jsi_GenDeep.jsi to lib/GenDeep.jsi.

1
2
3
4
5
6
7
8
9
10
...
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/env jsish

function Jsi_GenDeep(args:array=void, opts:object=void) {

    var self = {
        query   :'export=save',
        onRecv  :DeepFileSave,
        fileList:[]
    };
    var options = { // Load markdeep and export (via websocket) to local file.
................................................................................
             onRecv  :DeepFileSave,
             query   :self.query,
             wsOpts  : {extArgs :{mdi:'{dumpScript:"dumpdeep.js"}'}}
             // htmlPrefix : '<p>',
             // htmlSuffix : '<p>',
         };
        wsopts.url = fl[0];
        Jsi_Websrv([], wsopts);
        return;
    }
    return main();
}

if (Info.isMain()) {
    runModule(Jsi_GenDeep);
}


|







 







|






|

1
2
3
4
5
6
7
8
9
10
...
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/env jsish

function GenDeep(args:array=void, opts:object=void) {

    var self = {
        query   :'export=save',
        onRecv  :DeepFileSave,
        fileList:[]
    };
    var options = { // Load markdeep and export (via websocket) to local file.
................................................................................
             onRecv  :DeepFileSave,
             query   :self.query,
             wsOpts  : {extArgs :{mdi:'{dumpScript:"dumpdeep.js"}'}}
             // htmlPrefix : '<p>',
             // htmlSuffix : '<p>',
         };
        wsopts.url = fl[0];
        Websrv([], wsopts);
        return;
    }
    return main();
}

if (Info.isMain()) {
    runModule(GenDeep);
}

Name change from lib/Jsi_Help.jsi to lib/Help.jsi.

1
2
3
4
5
6
7
8
9
10
11
12
...
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
...
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
...
369
370
371
372
373
374
375
376
377
378
379
380
#!/usr/local/bin/jsish %s -Debug true Socket.conf

require('Jsish');

function Jsi_Help(args:array, conf:object=void) {

    var options = { // Provide help for Jsi commands.
        max         :32,        // Max lines to output, if not web
        timeout     :10000,     // Time to wait for browser to open with -web.
        web         :false,     // Format for the web.
        wiki        :false      // For -web, return instead of opening browser.
    };
................................................................................
        LogDebug('HELP:',str);
        str = str.trim();
        var rv = '';
        if (str === '' || str === '?' || str === 'help') {
            rv += 'Jsish interactive executes commands, uses tab for completions, and has help for '
                + 'the following builtin commands:\n\n'+ljoin(Info.cmds(), 68, '     ');
                rv += "\n\nHelp can also take options.  For example to display in a web browser try:\n\n    help -web true WebSocket";
                rv += "\n\nModule help can also be displayed (non-web), as in 'help Jsi_Websrv`.\n";
                rv += 'Builtin modules include:\n\n';
                var nowork = ['Jsi_Conf', 'Jsi_Conf', 'Jsi_Opts', 'Jsi_Zip', 'Jsi_AutoMake', 'Jsi_Make', 
                    'Jsi_Main', 'Jsi_AutoPkg', 'Jsi_LogFile', 'Jsi_Run'],
                    modl=[];
                for (var i of Jsi_Auto.keys()) {
                    if (i.substr(0,4) != 'Jsi_') continue;
                    if (nowork.indexOf(i)>=0) continue;
                    modl.push(i);
                }
................................................................................
        debugger;
        if (args.length>1)
            throw('expected 0 or 1 args');
        var rv, arg = (args.length?args[0]:'');
        if (self.web) {
            rv = dumpWeb();
            if (!self.wiki) {
                if (require('Jsi_Websrv')<0)
                    throw("websrv unavailable");
                var css = File.read('/zvfs/lib/web/jsiweb.css');
                rv = '<style>'+css+'</style>\n' + rv;
                var anchor = (arg===''?'':'#'+arg);
                if (System[arg])
                    anchor = '#System';
                else if (arg.indexOf('.')>0)
                    anchor = '#'+arg.split('.')[0];
                Jsi_Websrv([], {pageStr:rv, anchor:anchor, timeout:self.timeout});
                rv = '';
            }
        } else {
            rv = help(arg);
            if (self.max>0) {
                var rvl = rv.split('\n');
                if (rvl.length>self.max)
................................................................................
        }
        return rv;
    }
    
    return main();
}

provide(Jsi_Help, 1);


if (isMain())
    runModule(Jsi_Help);




|







 







|

|







 







|








|







 







|



|
1
2
3
4
5
6
7
8
9
10
11
12
...
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
...
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
...
369
370
371
372
373
374
375
376
377
378
379
380
#!/usr/local/bin/jsish %s -Debug true Socket.conf

require('Jsish');

function Help(args:array, conf:object=void) {

    var options = { // Provide help for Jsi commands.
        max         :32,        // Max lines to output, if not web
        timeout     :10000,     // Time to wait for browser to open with -web.
        web         :false,     // Format for the web.
        wiki        :false      // For -web, return instead of opening browser.
    };
................................................................................
        LogDebug('HELP:',str);
        str = str.trim();
        var rv = '';
        if (str === '' || str === '?' || str === 'help') {
            rv += 'Jsish interactive executes commands, uses tab for completions, and has help for '
                + 'the following builtin commands:\n\n'+ljoin(Info.cmds(), 68, '     ');
                rv += "\n\nHelp can also take options.  For example to display in a web browser try:\n\n    help -web true WebSocket";
                rv += "\n\nModule help can also be displayed (non-web), as in 'help Websrv`.\n";
                rv += 'Builtin modules include:\n\n';
                var nowork = ['Jsi_Conf', 'Jsi_Conf', 'Jsi_Opts', 'Zip', 'Jsi_AutoMake', 'Make', 
                    'Jsi_Main', 'Jsi_AutoPkg', 'Jsi_LogFile', 'Jsi_Run'],
                    modl=[];
                for (var i of Jsi_Auto.keys()) {
                    if (i.substr(0,4) != 'Jsi_') continue;
                    if (nowork.indexOf(i)>=0) continue;
                    modl.push(i);
                }
................................................................................
        debugger;
        if (args.length>1)
            throw('expected 0 or 1 args');
        var rv, arg = (args.length?args[0]:'');
        if (self.web) {
            rv = dumpWeb();
            if (!self.wiki) {
                if (require('Websrv')<0)
                    throw("websrv unavailable");
                var css = File.read('/zvfs/lib/web/jsiweb.css');
                rv = '<style>'+css+'</style>\n' + rv;
                var anchor = (arg===''?'':'#'+arg);
                if (System[arg])
                    anchor = '#System';
                else if (arg.indexOf('.')>0)
                    anchor = '#'+arg.split('.')[0];
                Websrv([], {pageStr:rv, anchor:anchor, timeout:self.timeout});
                rv = '';
            }
        } else {
            rv = help(arg);
            if (self.max>0) {
                var rvl = rv.split('\n');
                if (rvl.length>self.max)
................................................................................
        }
        return rv;
    }
    
    return main();
}

provide(Help, 1);


if (isMain())
    runModule(Help);

Name change from lib/Jsi_Htmlpp.jsi to lib/Htmlpp.jsi.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
...
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
...
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
...
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
...
229
230
231
232
233
234
235
236
237
238
239
240
/*
 * Preprocess html, css and js within the webserver. Evaluates javascript between  <? ?> tags (like php).
 * Evaluation occurs within a subinterp to which defines 2 new commands: include(file,...) and echo(str).
 */

var JsiHtmlpp_callback = null;

function Jsi_Htmlpp(files:array|string=null, conf:object=undefined):string|object
{
    var options = { // Preprocess html evaluating Jsi code between  <? ?> tags (like php).
        delInterp   :true,      // Delete interp when done.
        incsMax     :1000,      // Maximum number of includes
        interpOptStr:'',        // Options for subinterp as JSON string.
        interp      :null,      // Interp to use (instead of creating one)
        maxOpCnt    :10000000,  // Max opcnt in subinterp (to prevent infinite loop)
        noCatch     :true,      // Do not use try/catch for includes
        noCheck     :false,     // Disable typechecking for jsi functions.
        noMark      :false      // Do not insert comments delimiting included files.
    };
    var self = {
        package:"Jsi_Htmlpp",
        intOpts:{},
        rc:'', files:[], files:[], chpos:0, curdir:'', data:'', errs:'', dir:'',
        jsifiles:[], cssfiles:[], mdfiles:[]
    };
    
    parseOpts(self, options, conf);
    
................................................................................
                        pre += File.read(fn);
                    else {
                        if (self.jsifiles.length==1 && self.noCheck) {
                            pre += File.read(self.dir+'/web/jsig.js');
                            if (self.noCheck)
                                pre += '$jsi.conf({enable:false});\n';
                        }
                        pre += Jsi_Jspp([fn]);
                    }
                    pre += end + "</script>\n";
                    echo(pre);
                    continue;
                    
                case '.cssi':
                    ispp = true;
................................................................................
                    }
                    x = pre; // .cssi file contains a <? tags so preprocess it.
                    break;
                    
                case '.mdi':
                    self.mdfiles.push(fn);
                    if (!self.mdpp)
                        self.mdpp = Jsi_Markdown(null);
                    pre += self.mdpp.parse([fn]);
                    echo(pre);
                    continue;
                    break;
                default:
                    notMarked = true;
            }
................................................................................
        self.data = odata;
    }
       
    function parse(files:array|string) {
        //debugger;
        LogTrace('PARSE:', files); 
        var oint = self.interp;
        self.dir = File.dirname(require("Jsi_Htmlpp", 0).loadFile);
        
        if (!self.intOpts.busyCallback)
            self.intOpts.busyCallback = "JsiHtmlpp_callback";
        if (!self.interp)
            self.interp = new Interp(self.intOpts);
            
        if (!self.interp.alias('echo'))
................................................................................
    if (files)
        return parse(files);
        
    self.parse = parse;
    return self;
};

provide(Jsi_Htmlpp, 1);

if (isMain())
    runModule(Jsi_Htmlpp);








|












|







 







|







 







|







 







|







 







|


|

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
...
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
...
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
...
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
...
229
230
231
232
233
234
235
236
237
238
239
240
/*
 * Preprocess html, css and js within the webserver. Evaluates javascript between  <? ?> tags (like php).
 * Evaluation occurs within a subinterp to which defines 2 new commands: include(file,...) and echo(str).
 */

var JsiHtmlpp_callback = null;

function Htmlpp(files:array|string=null, conf:object=undefined):string|object
{
    var options = { // Preprocess html evaluating Jsi code between  <? ?> tags (like php).
        delInterp   :true,      // Delete interp when done.
        incsMax     :1000,      // Maximum number of includes
        interpOptStr:'',        // Options for subinterp as JSON string.
        interp      :null,      // Interp to use (instead of creating one)
        maxOpCnt    :10000000,  // Max opcnt in subinterp (to prevent infinite loop)
        noCatch     :true,      // Do not use try/catch for includes
        noCheck     :false,     // Disable typechecking for jsi functions.
        noMark      :false      // Do not insert comments delimiting included files.
    };
    var self = {
        package:"Htmlpp",
        intOpts:{},
        rc:'', files:[], files:[], chpos:0, curdir:'', data:'', errs:'', dir:'',
        jsifiles:[], cssfiles:[], mdfiles:[]
    };
    
    parseOpts(self, options, conf);
    
................................................................................
                        pre += File.read(fn);
                    else {
                        if (self.jsifiles.length==1 && self.noCheck) {
                            pre += File.read(self.dir+'/web/jsig.js');
                            if (self.noCheck)
                                pre += '$jsi.conf({enable:false});\n';
                        }
                        pre += Jspp([fn]);
                    }
                    pre += end + "</script>\n";
                    echo(pre);
                    continue;
                    
                case '.cssi':
                    ispp = true;
................................................................................
                    }
                    x = pre; // .cssi file contains a <? tags so preprocess it.
                    break;
                    
                case '.mdi':
                    self.mdfiles.push(fn);
                    if (!self.mdpp)
                        self.mdpp = Markdown(null);
                    pre += self.mdpp.parse([fn]);
                    echo(pre);
                    continue;
                    break;
                default:
                    notMarked = true;
            }
................................................................................
        self.data = odata;
    }
       
    function parse(files:array|string) {
        //debugger;
        LogTrace('PARSE:', files); 
        var oint = self.interp;
        self.dir = File.dirname(require("Htmlpp", 0).loadFile);
        
        if (!self.intOpts.busyCallback)
            self.intOpts.busyCallback = "JsiHtmlpp_callback";
        if (!self.interp)
            self.interp = new Interp(self.intOpts);
            
        if (!self.interp.alias('echo'))
................................................................................
    if (files)
        return parse(files);
        
    self.parse = parse;
    return self;
};

provide(Htmlpp, 1);

if (isMain())
    runModule(Htmlpp);

Deleted lib/JsiCompat.jsi.

1
2
3
4
//Compatibility or polyfill functions.

// Caution: use of "prototype" here will fail if noproto mode set.

<
<
<
<








Name change from lib/Jsi_Jspp.jsi to lib/Jspp.jsi.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
156
157
158
159
160
161
162
163
164
165
166
167
 *    function foo(s, n) { s=Jsi.ArgCheck(...
 * 
 * Code to perform type checking/default values is provided by "web/jsig.js".
 * 
 * Limitation: Comments within function signatures are not supported.
 */

function Jsi_Jspp(files:array|string=null, conf:object=undefined):string|object
{
    var options = { // A JS preprocessor to convert "typed" functions out to web-browser compatible form
        checkRet    :false,     // Check return code by creating wrapper functions
        disable     :false,     // Preprocess to vanilla JS. WARNING: use of default values may break things.
        listFuncs   :false,     // Echo function list.
        inline      :false,      // Inline signature parse.
        noCheck     :false      // Disable argument type checking.
................................................................................
    if (files)
        return parse(files);

    self.parse = parse;
    return self;
}

provide(Jsi_Jspp, 1);

if (isMain()) 
    runModule(Jsi_Jspp);








|







 







|


|

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
156
157
158
159
160
161
162
163
164
165
166
167
 *    function foo(s, n) { s=Jsi.ArgCheck(...
 * 
 * Code to perform type checking/default values is provided by "web/jsig.js".
 * 
 * Limitation: Comments within function signatures are not supported.
 */

function Jspp(files:array|string=null, conf:object=undefined):string|object
{
    var options = { // A JS preprocessor to convert "typed" functions out to web-browser compatible form
        checkRet    :false,     // Check return code by creating wrapper functions
        disable     :false,     // Preprocess to vanilla JS. WARNING: use of default values may break things.
        listFuncs   :false,     // Echo function list.
        inline      :false,      // Inline signature parse.
        noCheck     :false      // Disable argument type checking.
................................................................................
    if (files)
        return parse(files);

    self.parse = parse;
    return self;
}

provide(Jspp, 1);

if (isMain()) 
    runModule(Jspp);

Name change from lib/Jsi_Make.jsi to lib/Make.jsi.

1
2
3
4
5
6
7
8
9
10
..
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
#!/usr/local/bin/jsish

function Jsi_Make(files:array|string=null, opts:object=undefined):number
{
    var options = {
        debug:false,     // Debugging level.
        file:'Make.jsi', // File to use as the make file.
        nocache:false,   // Disable caching of dependancies.
        noimplicit:false,// Disable implicit rules.
        trace:false,     // Tracing level.
................................................................................
            str += mi+';\n';
        }
        return str;
    }
    
    function subMake(target:string) {
        var cmd = Info.executable();
        if (File.isdir('/zvfs/lib/Jsi_Make.jsi'))
            Run(cmd+' -M '+target);
        else
            Run(cmd+' lib/Jsi_Make.jsi '+target);    
    }
    
    // Add dependancy for each target.
    function makePushDep(target:string, dep:string|array) {
        var name = target.trim();
        LogTrace('TARGET: ',target, 'DEP: ',dep);
        if (DEP[name]) console.puts('target redefined: '+name);
................................................................................
    $ = that;
    
    return main();
}

var $; // Global state

provide('Jsi_Make');

if (Info.isMain()) {
    runModule(Jsi_Make);
}





|







 







|


|







 







|


|




1
2
3
4
5
6
7
8
9
10
..
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
#!/usr/local/bin/jsish

function Make(files:array|string=null, opts:object=undefined):number
{
    var options = {
        debug:false,     // Debugging level.
        file:'Make.jsi', // File to use as the make file.
        nocache:false,   // Disable caching of dependancies.
        noimplicit:false,// Disable implicit rules.
        trace:false,     // Tracing level.
................................................................................
            str += mi+';\n';
        }
        return str;
    }
    
    function subMake(target:string) {
        var cmd = Info.executable();
        if (File.isdir('/zvfs/lib/Make.jsi'))
            Run(cmd+' -M '+target);
        else
            Run(cmd+' lib/Make.jsi '+target);    
    }
    
    // Add dependancy for each target.
    function makePushDep(target:string, dep:string|array) {
        var name = target.trim();
        LogTrace('TARGET: ',target, 'DEP: ',dep);
        if (DEP[name]) console.puts('target redefined: '+name);
................................................................................
    $ = that;
    
    return main();
}

var $; // Global state

provide('Make');

if (Info.isMain()) {
    runModule(Make);
}



Name change from lib/Jsi_Markdown.jsi to lib/Markdown.jsi.

1
2
3
4
5
6
7
8
9
10
..
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env jsish

function Jsi_Markdown(files:array|string=null, conf:object=undefined):string|object
{
    var options = { // Convert markdown to html.
        root        :'',        // Url root
        title       :''         // Page title
    };
    var self = {
    };
................................................................................
    if (files && files.length)
        return parse(files);
        
    self.parse = parse;
    return self;
}

provide(Jsi_Markdown);

if (isMain())
    runModule(Jsi_Markdown);



|







 







|


|

1
2
3
4
5
6
7
8
9
10
..
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env jsish

function Markdown(files:array|string=null, conf:object=undefined):string|object
{
    var options = { // Convert markdown to html.
        root        :'',        // Url root
        title       :''         // Page title
    };
    var self = {
    };
................................................................................
    if (files && files.length)
        return parse(files);
        
    self.parse = parse;
    return self;
}

provide(Markdown);

if (isMain())
    runModule(Markdown);

Name change from lib/Jsi_Module.jsi to lib/Module.jsi.

1
2
3
4
5
6
7
8
9
10
11
12
..
19
20
21
22
23
24
25
26
27









28
29
30
31
32
33
34
..
46
47
48
49
50
51
52
53
54
55
56
#! /usr/bin/env jsish

require('Jsi', '2.4');

function Jsi_Module(args:array, conf:object=void) {

    var options = { // Run or create a Jsi module.
        create  :'',        // Create a Jsi module template with this name.
        output  :'',        // Override the output filename default of create + .jsi.
        force   :false,     // Remove output if exists.
        quiet   :false,     // No messages.
        web     :false      // Use websock server template.
................................................................................
    
    function main() {
        LogDebug('Starting');
        if (self.rootdir === '')
            self.rootdir=Info.scriptDir();
        debugger;
        var fn = self.create;
        if (fn === '')
            throw('must specify create');









        var ext = File.extension(fn);
        if (ext !== '.jsi')
            fn += '.jsi';
        if (self.output !== '')
            fn = self.output;
        if (File.exists(fn)) {
            if (!self.force)
................................................................................
        if (!self.quiet)
            console.printf("Created module '%s' in %s\n", pat, fn);
    }
    
    return main();
}

provide(Jsi_Module, 1);

if (isMain())
    runModule(Jsi_Module);




|







 







|
|
>
>
>
>
>
>
>
>
>







 







|


|
1
2
3
4
5
6
7
8
9
10
11
12
..
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
..
55
56
57
58
59
60
61
62
63
64
65
#! /usr/bin/env jsish

require('Jsi', '2.4');

function Module(args:array, conf:object=void) {

    var options = { // Run or create a Jsi module.
        create  :'',        // Create a Jsi module template with this name.
        output  :'',        // Override the output filename default of create + .jsi.
        force   :false,     // Remove output if exists.
        quiet   :false,     // No messages.
        web     :false      // Use websock server template.
................................................................................
    
    function main() {
        LogDebug('Starting');
        if (self.rootdir === '')
            self.rootdir=Info.scriptDir();
        debugger;
        var fn = self.create;
        if (fn === '') {
            var lst = File.glob('/zvfs/lib/*'), rc = [];
            for (var i of lst) {
                var ft = File.tail(i), fr = File.rootname(ft), ext = File.extension(ft);
                if (File.isdir(i) && File.exists(i+'/'+fr+'.jsi'))
                    rc.push(fr);
                else if (ext === '.jsi' && ft !== 'Jsish.jsi' && ft !=='autoload.jsi')
                    rc.push(fr);
            }
            throw('missing required module name or builtin:\n    '+rc.sort().join(', ')+'\n');
        }
        var ext = File.extension(fn);
        if (ext !== '.jsi')
            fn += '.jsi';
        if (self.output !== '')
            fn = self.output;
        if (File.exists(fn)) {
            if (!self.force)
................................................................................
        if (!self.quiet)
            console.printf("Created module '%s' in %s\n", pat, fn);
    }
    
    return main();
}

provide(Module, 1);

if (isMain())
    runModule(Module);

Name change from lib/Jsi_Proxy.jsi to lib/Proxy.jsi.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
...
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
...
268
269
270
271
272
273
274
275
276
277
278
279
#!/usr/bin/env jsish

require('Jsish');

// Create a websocket-capabled proxy web server.(UNFINISHED)

require('WebSocket');
require('Jsi_Vfs');

function Jsi_Proxy(args:array, conf:object=void):void
{
    var self = {
        wsOpts:{}
    };
    var options = { // Run a proxy web server.
        closeTimeout:0,         // Milliseconds til we exit after close of final client websocket.
        browser     :'',        // The browser to exec, eg. "chrome-browser"
................................................................................
            self.ws.idconf(id, {rootdir:'/zvfs/jsifs'});
            return '!!!'+'/'+u.slice(3).join('/');
        }
        var nid = u[2];
        switch (nid) {
            case 'sqliteui':
                if (!Reqs[nid])
                    Reqs[nid] = require('Jsi_SqliteUI', 0);
                req = Reqs[nid];
                dir = File.dirname(req.loadFile) + '/html';
                self.ws.idconf(id, {rootdir:dir});
                return '!!!'+'/'+u.slice(3).join('/');
        }
    }
    
................................................................................
    {
        LogDebug("Opening WS: "+id);
        var url =  self.ws.header(id,'get'),
            u = url.split('/');
        puts('OPEN:', url);
        switch (u[2]) {
            case 'sqliteui':
                var nobj = Jsi_SqliteUI("~/tmp/test2.db", {wsObj:self.ws, wsId:id, Debug:true});
                break;
            case 'jsifs':
                require('Ledger');
                nobj = Ledger([], {wsObj:self.ws, wsId:id, Debug:true});
                break;
            default:
                puts("UNKNOWN WSOPEN "+u[2]);
................................................................................
        delete self.ws;
    }
    
    main();
    
}

provide(Jsi_Proxy, 0.1);

if (isMain()) 
    runModule(Jsi_Proxy);








|

|







 







|







 







|







 







|


|

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
...
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
...
268
269
270
271
272
273
274
275
276
277
278
279
#!/usr/bin/env jsish

require('Jsish');

// Create a websocket-capabled proxy web server.(UNFINISHED)

require('WebSocket');
require('VFS');

function Proxy(args:array, conf:object=void):void
{
    var self = {
        wsOpts:{}
    };
    var options = { // Run a proxy web server.
        closeTimeout:0,         // Milliseconds til we exit after close of final client websocket.
        browser     :'',        // The browser to exec, eg. "chrome-browser"
................................................................................
            self.ws.idconf(id, {rootdir:'/zvfs/jsifs'});
            return '!!!'+'/'+u.slice(3).join('/');
        }
        var nid = u[2];
        switch (nid) {
            case 'sqliteui':
                if (!Reqs[nid])
                    Reqs[nid] = require('SqliteUI', 0);
                req = Reqs[nid];
                dir = File.dirname(req.loadFile) + '/html';
                self.ws.idconf(id, {rootdir:dir});
                return '!!!'+'/'+u.slice(3).join('/');
        }
    }
    
................................................................................
    {
        LogDebug("Opening WS: "+id);
        var url =  self.ws.header(id,'get'),
            u = url.split('/');
        puts('OPEN:', url);
        switch (u[2]) {
            case 'sqliteui':
                var nobj = SqliteUI("~/tmp/test2.db", {wsObj:self.ws, wsId:id, Debug:true});
                break;
            case 'jsifs':
                require('Ledger');
                nobj = Ledger([], {wsObj:self.ws, wsId:id, Debug:true});
                break;
            default:
                puts("UNKNOWN WSOPEN "+u[2]);
................................................................................
        delete self.ws;
    }
    
    main();
    
}

provide(Proxy, 0.1);

if (isMain()) 
    runModule(Proxy);

Name change from lib/Jsi_Safe.jsi to lib/Safe.jsi.

1
2
3
4
5
6
7
8
9
10
11
12
...
121
122
123
124
125
126
127
128
129
130
131
132
#! /usr/bin/env jsish

require('Jsish');

function Jsi_Safe(fileargs:array, conf:object=void) {

    var options = { // Run script in safe interpreter and return value. With a dir or no arg runs interactively.
        evalStr     :'',        // Code-string to eval instead of sourcing filearg.
        msgCmd      :null,      // Command to relay Interp.msgCallback..
        noRead      :false,     // Omit setting safeReadDirs that lets source() be used.
        opts        :{},        // Options for sub-interp create.
        paranoid    :false,     // Extra safety: sets noRead=true, and disables subinterps, networking, etc.
................................................................................
        all.retVal = val;
        return all;
    }
    
    return main();
}

provide(Jsi_Safe, 1);


if (isMain())
    runModule(Jsi_Safe);




|







 







|



|
1
2
3
4
5
6
7
8
9
10
11
12
...
121
122
123
124
125
126
127
128
129
130
131
132
#! /usr/bin/env jsish

require('Jsish');

function Safe(fileargs:array, conf:object=void) {

    var options = { // Run script in safe interpreter and return value. With a dir or no arg runs interactively.
        evalStr     :'',        // Code-string to eval instead of sourcing filearg.
        msgCmd      :null,      // Command to relay Interp.msgCallback..
        noRead      :false,     // Omit setting safeReadDirs that lets source() be used.
        opts        :{},        // Options for sub-interp create.
        paranoid    :false,     // Extra safety: sets noRead=true, and disables subinterps, networking, etc.
................................................................................
        all.retVal = val;
        return all;
    }
    
    return main();
}

provide(Safe, 1);


if (isMain())
    runModule(Safe);

Name change from lib/Jsi_SqliteUI/Jsi_SqliteUI.jsi to lib/SqliteUI/SqliteUI.jsi.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
...
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
...
646
647
648
649
650
651
652
653
654
655
656
657
#!/usr/bin/env jsish

require('Jsish');
require('Sqlite');
require('WebSocket', '2');
// An sqlite browser user interface.

function Jsi_SqliteUI(files:array|string, conf:object=void)
{
    var options = { // Provide an sqlite user interface via a browser.
        Debug       :false,             // LogDebug output.
        Trace       :false,             // LogTrace output.
        closeTimeout:5000,              // Time til exit after close of final client websocket (ms).
        browser     :'',                // Browser program to use.
        dump        :false,             // Dump database.
................................................................................
            self.optdb.eval("INSERT OR REPLACE INTO saved_queries (query,dbID) VALUES($req(query),$self(dbID))");
        else
            self.optdb.eval("DELETE FROM saved_queries WHERE query == $req(query) AND dbID == $self(dbID)");
    }
    
    function dbLoad(id:number, req:object) // Open new view.
    {
        //Jsi_SqliteUI(req.dbFile, {noUpdate:true});
        setTimeout(function () { Jsi_SqliteUI(req.dbFile, {noUpdate:true}); }, 100);
        return;
    }
    
    function loadAll(id:number)
    {
        LogDebug("LOADALL");
        WsSend(id,'loadAll', loadTList(id));
................................................................................
        if (!self.wsObj)
            delete self.ws;
    }
    
    function main() {
        debugger;
        self.done = 0;
        var req = require("Jsi_SqliteUI", 1.0);
        if (!self.rootdir)
            self.rootdir=File.dirname(req.loadFile);
        if (files === undefined)
            throw("expected a db file argument");
        if (typeof(files) === 'string')
            self.dbfile = files;
        else
................................................................................
        cleanup();
        return 0;
    }
    
    return main();
}

provide(Jsi_SqliteUI, 1.1);

if (isMain())
    exit(runModule(Jsi_SqliteUI));








|







 







|
|







 







|







 







|


|

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
...
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
...
646
647
648
649
650
651
652
653
654
655
656
657
#!/usr/bin/env jsish

require('Jsish');
require('Sqlite');
require('WebSocket', '2');
// An sqlite browser user interface.

function SqliteUI(files:array|string, conf:object=void)
{
    var options = { // Provide an sqlite user interface via a browser.
        Debug       :false,             // LogDebug output.
        Trace       :false,             // LogTrace output.
        closeTimeout:5000,              // Time til exit after close of final client websocket (ms).
        browser     :'',                // Browser program to use.
        dump        :false,             // Dump database.
................................................................................
            self.optdb.eval("INSERT OR REPLACE INTO saved_queries (query,dbID) VALUES($req(query),$self(dbID))");
        else
            self.optdb.eval("DELETE FROM saved_queries WHERE query == $req(query) AND dbID == $self(dbID)");
    }
    
    function dbLoad(id:number, req:object) // Open new view.
    {
        //SqliteUI(req.dbFile, {noUpdate:true});
        setTimeout(function () { SqliteUI(req.dbFile, {noUpdate:true}); }, 100);
        return;
    }
    
    function loadAll(id:number)
    {
        LogDebug("LOADALL");
        WsSend(id,'loadAll', loadTList(id));
................................................................................
        if (!self.wsObj)
            delete self.ws;
    }
    
    function main() {
        debugger;
        self.done = 0;
        var req = require("SqliteUI", 1.0);
        if (!self.rootdir)
            self.rootdir=File.dirname(req.loadFile);
        if (files === undefined)
            throw("expected a db file argument");
        if (typeof(files) === 'string')
            self.dbfile = files;
        else
................................................................................
        cleanup();
        return 0;
    }
    
    return main();
}

provide(SqliteUI, 1.1);

if (isMain())
    exit(runModule(SqliteUI));

Name change from lib/Jsi_SqliteUI/html/dialog.html to lib/SqliteUI/html/dialog.html.

Name change from lib/Jsi_SqliteUI/html/main.htmli to lib/SqliteUI/html/main.htmli.

Name change from lib/Jsi_SqliteUI/html/sqlite.cssi to lib/SqliteUI/html/sqlite.cssi.

Name change from lib/Jsi_SqliteUI/html/sqlite.jsi to lib/SqliteUI/html/sqlite.jsi.

1
2
3
4
5
6
7
8
// JS for Web browser side of Jsi_SqliteUI user interface.
"use strict";

var self = {
    debug:0,
    msg:null,
    tlist:{ opened:[], dblclick:null, clkcnt:0 },
    qlist:{ sel:-1, dblclick:null, clkcnt:0, data:[] },
|







1
2
3
4
5
6
7
8
// JS for Web browser side of SqliteUI user interface.
"use strict";

var self = {
    debug:0,
    msg:null,
    tlist:{ opened:[], dblclick:null, clkcnt:0 },
    qlist:{ sel:-1, dblclick:null, clkcnt:0, data:[] },

Name change from lib/Jsi_SqliteUI/html/sqliteui_doc.html to lib/SqliteUI/html/sqliteui_doc.html.

Name change from lib/Jsi_SqliteUI/main.jsi to lib/SqliteUI/main.jsi.

1
2
3
4
5
#!/usr/bin/env jsish

source('Jsi_SqliteUI.jsi', {isMain:true});




|


1
2
3
4
5
#!/usr/bin/env jsish

source('SqliteUI.jsi', {isMain:true});


Name change from lib/Jsi_UnitTest.jsi to lib/UnitTest.jsi.

1
2
3
4
5
6
7
8
9
10
11
12
...
283
284
285
286
287
288
289
290
291
292
293
294
#! /usr/bin/env jsish

require('Jsish');

function Jsi_UnitTest(fileargs:array, conf:object=void):number {

    var options = { // Run script(s) as unit-tests; return code is the number of failed tests.
        args        :'',        // Argument string to call script with
        context     :99,         // Number of context lines for DIFF (>3 forces dir diff).
        echo        :false,     // Run with puts/assert output showing file:line number.
        evalFile    :'',        // File to source in subinterp before test.
        exec        :false,     // Use exec instead of running test in a sub-interp.
................................................................................
            printf("%d FAIL, %d PASS: runtime %u ms\n", self.fails, self.cnt-self.fails, (strptime()-self.startTime));
        return self.fails;
    }
    
    return main();
}

provide(Jsi_UnitTest, 1);


if (isMain())
    exit(runModule(Jsi_UnitTest));




|







 







|



|
1
2
3
4
5
6
7
8
9
10
11
12
...
283
284
285
286
287
288
289
290
291
292
293
294
#! /usr/bin/env jsish

require('Jsish');

function UnitTest(fileargs:array, conf:object=void):number {

    var options = { // Run script(s) as unit-tests; return code is the number of failed tests.
        args        :'',        // Argument string to call script with
        context     :99,         // Number of context lines for DIFF (>3 forces dir diff).
        echo        :false,     // Run with puts/assert output showing file:line number.
        evalFile    :'',        // File to source in subinterp before test.
        exec        :false,     // Use exec instead of running test in a sub-interp.
................................................................................
            printf("%d FAIL, %d PASS: runtime %u ms\n", self.fails, self.cnt-self.fails, (strptime()-self.startTime));
        return self.fails;
    }
    
    return main();
}

provide(UnitTest, 1);


if (isMain())
    exit(runModule(UnitTest));

Name change from lib/Jsi_Websrv.jsi to lib/Websrv.jsi.

1
2
3
4
5
6
7
8
9
10
11
12
13
..
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
...
437
438
439
440
441
442
443
444
445
446
447
#!/usr/bin/env jsish

require('Jsish');
require('WebSocket', '2');

function Jsi_Websrv(args:string|array, conf:object=void):void
{
    var self = {
        chans   :{}
    };
    var options = { // Run a standalone web server, opening browser to serve out url.
        anchor      :'',        // Anchor after url.
        closeTimeout:0,         // Time til exit after close of final client websocket (ms).
................................................................................
        noWait      :false,     // Just return object: caller will provide an update() loop.
        onRecv      :null,      // Callback command to handle websocket msgs.
        pageStr     :'',        // String to serve out as url.
        port        :0,         // Start search for port.
        query       :'',        // Query to append to url.
        rootdir     :null,      // Base directory.
        server      :false,     // Server mode: same as noGui=true and closeTimout=0
        srcFile     :'',        // File of code to source inside the Jsi_Websrv function.
        uploadDir   :'/tmp',    // Upload files go here
        timeout     :60000,     // Set timeout (in ms) to shutdown. This is idle time, unless negative.
        trace       :false,     // Tracing output.
        url         :"",        // The file/url to serve out and clears timeout.
        urlPrefix   :'/Websrv', // Prefix for urls
        useridPass  :'',        // USER:PASS for web GUI.
        wsdebug     :0,         // Debug option for websockets.
................................................................................
    if (self.srcFile !== '')
        source(self.srcFile);
    
    main();
    
}

provide(Jsi_Websrv, "1.1");

if (isMain())
    runModule(Jsi_Websrv);





|







 







|







 







|


|
1
2
3
4
5
6
7
8
9
10
11
12
13
..
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
...
437
438
439
440
441
442
443
444
445
446
447
#!/usr/bin/env jsish

require('Jsish');
require('WebSocket', '2');

function Websrv(args:string|array, conf:object=void):void
{
    var self = {
        chans   :{}
    };
    var options = { // Run a standalone web server, opening browser to serve out url.
        anchor      :'',        // Anchor after url.
        closeTimeout:0,         // Time til exit after close of final client websocket (ms).
................................................................................
        noWait      :false,     // Just return object: caller will provide an update() loop.
        onRecv      :null,      // Callback command to handle websocket msgs.
        pageStr     :'',        // String to serve out as url.
        port        :0,         // Start search for port.
        query       :'',        // Query to append to url.
        rootdir     :null,      // Base directory.
        server      :false,     // Server mode: same as noGui=true and closeTimout=0
        srcFile     :'',        // File of code to source inside the Websrv function.
        uploadDir   :'/tmp',    // Upload files go here
        timeout     :60000,     // Set timeout (in ms) to shutdown. This is idle time, unless negative.
        trace       :false,     // Tracing output.
        url         :"",        // The file/url to serve out and clears timeout.
        urlPrefix   :'/Websrv', // Prefix for urls
        useridPass  :'',        // USER:PASS for web GUI.
        wsdebug     :0,         // Debug option for websockets.
................................................................................
    if (self.srcFile !== '')
        source(self.srcFile);
    
    main();
    
}

provide(Websrv, "1.1");

if (isMain())
    runModule(Websrv);

Name change from lib/Jsi_Wget.jsi to lib/Wget.jsi.

1
2
3
4
5
6
7
8
9
10
...
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/env jsish

function Jsi_Wget(fileargs:array|string, conf:object=void) {
    
    var options = { // Web client for downloading files from url
        force       : false,        // Overwrite output file, if exists.
        headers     : [],           // Header fields to send.
        nowait      : false,        // Just return object: caller will call update.
        onDone      : null,         // Callback when done.
        O           : '',           // Output file name, or - for stdout, . for return contents: default is url tail.
................................................................................
        if (self.response !== '')
            return self.response;
    }
    
    return main();
}

provide(Jsi_Wget, "1.2");

if (isMain())
    runModule(Jsi_Wget);




|







 







|


|


1
2
3
4
5
6
7
8
9
10
...
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/env jsish

function Wget(fileargs:array|string, conf:object=void) {
    
    var options = { // Web client for downloading files from url
        force       : false,        // Overwrite output file, if exists.
        headers     : [],           // Header fields to send.
        nowait      : false,        // Just return object: caller will call update.
        onDone      : null,         // Callback when done.
        O           : '',           // Output file name, or - for stdout, . for return contents: default is url tail.
................................................................................
        if (self.response !== '')
            return self.response;
    }
    
    return main();
}

provide(Wget, "1.2");

if (isMain())
    runModule(Wget);


Name change from lib/Jsi_Zip.jsi to lib/Zip.jsi.

1
2
3
4
5
6
7
8
9
10
11
12
..
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
...
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/env jsish

// Utility for creating and managing zip files, especially when appended to a jsish executable-archive.

function Jsi_Zip(args:string|array, conf:object=void) {

    var options = { // Implements zip functionality
        userDir     :'',        // User directory to add to zip (zvfs)
        outfile     :'',        // Output file for zvfs instead of appending "sh"
        indir       :'',        // Input directory
        verbose     :false      // Echo file name of unzip.
    };
................................................................................
        if (zdest == '')
            zdest = fname+'sh';
        if (File.exists(zdest))
            return usage('target file already exists: '+zdest);
        var tdir = File.tempfile('DIR_XXXXXX');
        File.remove(tdir);
        File.mkdir(tdir);
        Jsi_Zip(['unzip', Info.executable(), tdir]);
        if (self.userDir !== '') {
            if (!File.isdir(self.userDir)) throw('userDir not found: '+self.userDir);
            File.link(File.realpath(self.userDir), tdir+'/lib/user');
        }
        File.copy(fname, zdest);
        Jsi_Zip(['create',zdest,tdir]);
        File.remove(tdir, true);
    }
    
    function fuse(fname:string) {
        var zdest = File.rootname(fname);
        if (File.exists(zdest))
            return usage('target file already exists: '+zdest);
        var tdir = File.tempfile('DIR_XXXXXX');
        File.remove(tdir);
        File.mkdir(tdir);
        Jsi_Zip(['unzip', Info.executable(), tdir]);
        Jsi_Zip(['unzip', fname, tdir]);
        File.copy(fname, zdest);
        Zvfs.truncate(fname, true);
        Jsi_Zip(['create',zdest,tdir]);
        File.remove(tdir, true);
    }
    
    function list(fname:string) {
        fname = File.realpath(fname);
        if (fname === Info.executable())
            zdir = '/zvfs';
................................................................................
    var emsg = 'Arg 1 must be one of:\n';
    for (i of cmdList) {
        emsg += '  ' + i[0] + '      \t: ' + i[2] + '\n';
    }
    throw(emsg); 
}

provide(Jsi_Zip, 1.0);

if (Info.isMain()) {
    //exit(Jsi_Zip(console.args));
    runModule(Jsi_Zip);
}




|







 







|





|










|
|


|







 







|


|
|

1
2
3
4
5
6
7
8
9
10
11
12
..
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
...
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/env jsish

// Utility for creating and managing zip files, especially when appended to a jsish executable-archive.

function Zip(args:string|array, conf:object=void) {

    var options = { // Implements zip functionality
        userDir     :'',        // User directory to add to zip (zvfs)
        outfile     :'',        // Output file for zvfs instead of appending "sh"
        indir       :'',        // Input directory
        verbose     :false      // Echo file name of unzip.
    };
................................................................................
        if (zdest == '')
            zdest = fname+'sh';
        if (File.exists(zdest))
            return usage('target file already exists: '+zdest);
        var tdir = File.tempfile('DIR_XXXXXX');
        File.remove(tdir);
        File.mkdir(tdir);
        Zip(['unzip', Info.executable(), tdir]);
        if (self.userDir !== '') {
            if (!File.isdir(self.userDir)) throw('userDir not found: '+self.userDir);
            File.link(File.realpath(self.userDir), tdir+'/lib/user');
        }
        File.copy(fname, zdest);
        Zip(['create',zdest,tdir]);
        File.remove(tdir, true);
    }
    
    function fuse(fname:string) {
        var zdest = File.rootname(fname);
        if (File.exists(zdest))
            return usage('target file already exists: '+zdest);
        var tdir = File.tempfile('DIR_XXXXXX');
        File.remove(tdir);
        File.mkdir(tdir);
        Zip(['unzip', Info.executable(), tdir]);
        Zip(['unzip', fname, tdir]);
        File.copy(fname, zdest);
        Zvfs.truncate(fname, true);
        Zip(['create',zdest,tdir]);
        File.remove(tdir, true);
    }
    
    function list(fname:string) {
        fname = File.realpath(fname);
        if (fname === Info.executable())
            zdir = '/zvfs';
................................................................................
    var emsg = 'Arg 1 must be one of:\n';
    for (i of cmdList) {
        emsg += '  ' + i[0] + '      \t: ' + i[2] + '\n';
    }
    throw(emsg); 
}

provide(Zip, 1.0);

if (Info.isMain()) {
    //exit(Zip(console.args));
    runModule(Zip);
}

Changes to lib/autoload.jsi.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Jsi_Auto.Jsi_AutoMake   =
Jsi_Auto.Jsi_AutoPkg    =
Jsi_Auto.Jsi_Main       =
Jsi_Auto.Jsi_Run        =
Jsi_Auto.Jsi_LogFile    =
Jsi_Auto.Jsi_Opts       =
Jsi_Auto.Jsi_Conf       = 'source("'+Info.scriptDir()+'/Jsish.jsi")';
Jsi_Auto.Jsi_Htmlpp     = 'source("'+Info.scriptDir()+'/Jsi_Htmlpp.jsi")';
Jsi_Auto.Jsi_Csspp      = 'source("'+Info.scriptDir()+'/Jsi_Csspp.jsi")';
Jsi_Auto.Jsi_Jspp       = 'source("'+Info.scriptDir()+'/Jsi_Jspp.jsi")';
Jsi_Auto.Jsi_Markdown   = 'source("'+Info.scriptDir()+'/Jsi_Markdown.jsi")';
Jsi_Auto.Jsi_CData      = 'source("'+Info.scriptDir()+'/Jsi_CData.jsi")';
Jsi_Auto.Jsi_Websrv     = 'source("'+Info.scriptDir()+'/Jsi_Websrv.jsi")';
Jsi_Auto.Jsi_Wget       = 'source("'+Info.scriptDir()+'/Jsi_Wget.jsi")';
Jsi_Auto.Jsi_Debug      = 'source("'+Info.scriptDir()+'/Jsi_Debug.jsi")';
Jsi_Auto.Jsi_Safe       = 'source("'+Info.scriptDir()+'/Jsi_Safe.jsi")';
Jsi_Auto.Jsi_Zip        = 'source("'+Info.scriptDir()+'/Jsi_Zip.jsi")';
Jsi_Auto.Jsi_UnitTest   = 'source("'+Info.scriptDir()+'/Jsi_UnitTest.jsi")';
Jsi_Auto.Jsi_DebugUI    = 'source("'+Info.scriptDir()+'/Jsi_DebugUI/Jsi_DebugUI.jsi")';
Jsi_Auto.Jsi_SqliteUI   = 'source("'+Info.scriptDir()+'/Jsi_SqliteUI/Jsi_SqliteUI.jsi")';
Jsi_Auto.Jsi_Make       = 'source("'+Info.scriptDir()+'/Jsi_Make.jsi")';
Jsi_Auto.Jsi_Vfs        = 'source("'+Info.scriptDir()+'/Jsi_Vfs.jsi")';
Jsi_Auto.Jsi_Archive    = 'source("'+Info.scriptDir()+'/Jsi_Archive.jsi")';
Jsi_Auto.Jsi_Module     = 'source("'+Info.scriptDir()+'/Jsi_Module.jsi")';
Jsi_Auto.Jsi_Help       = 'source("'+Info.scriptDir()+'/Jsi_Help.jsi")';
Jsi_Auto.Jsi_GenDeep    = 'source("'+Info.scriptDir()+'/Jsi_GenDeep.jsi")';

Jsi_Auto.Sqlite         = 'require("Sqlite");';
Jsi_Auto.MySql          = 'require("MySql");';
Jsi_Auto.Websocket      = 'require("WebSocket");';
Jsi_Auto.Socket         = 'require("Socket");';
Jsi_Auto.DebugUI        = 'require("DebugUI");';

source(Info.scriptDir()+'/JsiCompat.jsi');

source(Info.scriptDir()+'/user/autoload.jsi', {exists:true});

Jsi_Auto.__autoloaded__ =true;








|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







<
<




11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43


44
45
46
47
Jsi_Auto.Jsi_AutoMake   =
Jsi_Auto.Jsi_AutoPkg    =
Jsi_Auto.Jsi_Main       =
Jsi_Auto.Jsi_Run        =
Jsi_Auto.Jsi_LogFile    =
Jsi_Auto.Jsi_Opts       =
Jsi_Auto.Jsi_Conf       = 'source("'+Info.scriptDir()+'/Jsish.jsi")';
Jsi_Auto.Htmlpp     = 'source("'+Info.scriptDir()+'/Htmlpp.jsi")';
Jsi_Auto.Csspp      = 'source("'+Info.scriptDir()+'/Csspp.jsi")';
Jsi_Auto.Jspp       = 'source("'+Info.scriptDir()+'/Jspp.jsi")';
Jsi_Auto.Markdown   = 'source("'+Info.scriptDir()+'/Markdown.jsi")';
Jsi_Auto.Cdata      = 'source("'+Info.scriptDir()+'/Cdata.jsi")';
Jsi_Auto.Websrv     = 'source("'+Info.scriptDir()+'/Websrv.jsi")';
Jsi_Auto.Wget       = 'source("'+Info.scriptDir()+'/Wget.jsi")';
Jsi_Auto.Debug      = 'source("'+Info.scriptDir()+'/Debug.jsi")';
Jsi_Auto.Safe       = 'source("'+Info.scriptDir()+'/Safe.jsi")';
Jsi_Auto.Zip        = 'source("'+Info.scriptDir()+'/Zip.jsi")';
Jsi_Auto.UnitTest   = 'source("'+Info.scriptDir()+'/UnitTest.jsi")';
Jsi_Auto.Make       = 'source("'+Info.scriptDir()+'/Make.jsi")';
Jsi_Auto.Vfs        = 'source("'+Info.scriptDir()+'/VFS.jsi")';
Jsi_Auto.Archive    = 'source("'+Info.scriptDir()+'/Archive.jsi")';
Jsi_Auto.Module     = 'source("'+Info.scriptDir()+'/Module.jsi")';
Jsi_Auto.Help       = 'source("'+Info.scriptDir()+'/Help.jsi")';
Jsi_Auto.GenDeep    = 'source("'+Info.scriptDir()+'/GenDeep.jsi")';
Jsi_Auto.DebugUI        = 'source("'+Info.scriptDir()+'/DebugUI/DebugUI.jsi")';
Jsi_Auto.SqliteUI       = 'source("'+Info.scriptDir()+'/SqliteUI/SqliteUI.jsi")';

Jsi_Auto.Sqlite         = 'require("Sqlite");';
Jsi_Auto.MySql          = 'require("MySql");';
Jsi_Auto.Websocket      = 'require("WebSocket");';
Jsi_Auto.Socket         = 'require("Socket");';
Jsi_Auto.DebugUI        = 'require("DebugUI");';



source(Info.scriptDir()+'/user/autoload.jsi', {exists:true});

Jsi_Auto.__autoloaded__ =true;

Changes to md/Debug.md.

222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237

### Implementation

The debugger runs the target script in a [sub-interpreter](Interp.md).

The sources are here:

- [Command-line](../lib/Jsi_Debug.jsi)
- [Gui](../lib/Jsi_DebugUI/Jsi_DebugUI.jsi)

**Warning**:
    Jsi bends the memory management rules of Sub-interps a bit to make debugging mode work,
    which means a small amount of memory may leak
    during debug sessions.

Debugging Aids







|
|







222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237

### Implementation

The debugger runs the target script in a [sub-interpreter](Interp.md).

The sources are here:

- [Command-line](../lib/Debug.jsi)
- [Gui](../lib/DebugUI/DebugUI.jsi)

**Warning**:
    Jsi bends the memory management rules of Sub-interps a bit to make debugging mode work,
    which means a small amount of memory may leak
    during debug sessions.

Debugging Aids

Changes to md/Download.md.

263
264
265
266
267
268
269
270
271
272
273
274
275
276
277



### Modules
Help for module commands can similarly be displayed, eg:

    jsish -d -h
    /zvfs/lib/Jsi_Debug.jsi:34: help: ...
    A command-line Debugger for Jsi scripts..  Options are:
        -echoCmd    true        // Echo user cmds.
        -safe       false       // Debug program in a safe interp (untested)
    
    Accepted by all .jsi modules: -Debug, -Trace, -Test

and use as in:







|







263
264
265
266
267
268
269
270
271
272
273
274
275
276
277



### Modules
Help for module commands can similarly be displayed, eg:

    jsish -d -h
    /zvfs/lib/Debug.jsi:34: help: ...
    A command-line Debugger for Jsi scripts..  Options are:
        -echoCmd    true        // Echo user cmds.
        -safe       false       // Debug program in a safe interp (untested)
    
    Accepted by all .jsi modules: -Debug, -Trace, -Test

and use as in:

Changes to md/Interp.md.

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
From the command-line, safe execution of scripts can be invoked via -S:


    jsish -S tests/while.js a b c
    jsish -S tests/file.js a b c;  // kicks a file access error.
    jsish -S         // With no arguments runs the safe interp in interactive mode

The implemenatation is [here](../lib/Jsi_Safe.jsi).


Thread-Interps
--------------
A sub-interp can be created in a threaded:

    var interp1 = new Interp({subthread:true, scriptFile:'mythrd.js'});







|







58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
From the command-line, safe execution of scripts can be invoked via -S:


    jsish -S tests/while.js a b c
    jsish -S tests/file.js a b c;  // kicks a file access error.
    jsish -S         // With no arguments runs the safe interp in interactive mode

The implemenatation is [here](../lib/Safe.jsi).


Thread-Interps
--------------
A sub-interp can be created in a threaded:

    var interp1 = new Interp({subthread:true, scriptFile:'mythrd.js'});

Changes to src/jsi.c.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
.....
20630
20631
20632
20633
20634
20635
20636
20637
20638
20639
20640
20641
20642
20643
20644
20645
20646
20647
20648
20649
20650
20651
20652
20653
20654
20655
20656
20657
20658
20659
.....
20688
20689
20690
20691
20692
20693
20694
20695
20696
20697
20698
20699
20700
20701
20702
20703
20704
20705
20706
20707
20708
20709
20710
20711
20712
20713
.....
20715
20716
20717
20718
20719
20720
20721
20722
20723
20724
20725
20726
20727
20728
20729
20730
20731
20732
20733
20734
20735
20736
20737
20738
20739
20740
20741
20742
20743
20744
20745
20746
20747

20748
20749
20750
20751
20752
20753
20754
20755
20756
20757
20758
20759
20760
20761
20762
20763
20764
.....
20767
20768
20769
20770
20771
20772
20773
20774
20775
20776
20777
20778
20779
20780
20781
20782
20783
20784
20785
20786
20787
.....
20797
20798
20799
20800
20801
20802
20803
20804
20805
20806
20807
20808
20809
20810
20811
.....
23958
23959
23960
23961
23962
23963
23964
23965
23966
23967
23968
23969
23970
23971
23972
23973
23974
23975
23976
.....
47382
47383
47384
47385
47386
47387
47388
47389
47390
47391
47392
47393
47394
47395
47396
.....
55445
55446
55447
55448
55449
55450
55451
55452
55453
55454
55455
55456
55457
55458
55459
55460
55461
55462
55463
.....
60675
60676
60677
60678
60679
60680
60681

60682
60683
60684
60685
60686
60687
60688
.....
60985
60986
60987
60988
60989
60990
60991

60992
60993
60994
60995
60996
60997
60998
.....
61009
61010
61011
61012
61013
61014
61015

61016
61017
61018
61019
61020
61021
61022
.....
61037
61038
61039
61040
61041
61042
61043

61044
61045
61046
61047
61048
61049
61050
61051

61052
61053
61054
61055
61056
61057
61058
.....
61076
61077
61078
61079
61080
61081
61082

61083
61084
61085
61086
61087
61088
61089
.....
62015
62016
62017
62018
62019
62020
62021
62022
62023
62024
62025
62026
62027
62028
62029
.....
62057
62058
62059
62060
62061
62062
62063
62064
62065
62066
62067
62068
62069
62070


62071
62072
62073
62074
62075
62076
62077
/* jsi.h : External API header file for Jsi. */
#ifndef __JSI_H__
#define __JSI_H__

#define JSI_VERSION_MAJOR   2
#define JSI_VERSION_MINOR   8
#define JSI_VERSION_RELEASE 36

#define JSI_VERSION (JSI_VERSION_MAJOR + ((Jsi_Number)JSI_VERSION_MINOR/100.0) + ((Jsi_Number)JSI_VERSION_RELEASE/10000.0))

#ifndef JSI_EXTERN
#define JSI_EXTERN extern
#endif

................................................................................
                return jsi_DoExit(interp, 1);
            }
        }
    }
#endif
    const char *ext = NULL, *ai1, *iext = (argc<=1?NULL:Jsi_Strrchr(argv[1], '.'));
    if (interp->selfZvfs && iext && Jsi_Strcmp(iext,".fossil")==0) {
        rc = Jsi_EvalString(interp, "runModule('Jsi_Archive');", JSI_EVAL_ISMAIN);
        goto done;
    }
    Jsi_ShiftArgs(interp, NULL);
    if (argc <= 1) {
        if (interp->opts.no_interactive && !interp->interactive)
            return interp;
        rc = Jsi_Interactive(interp, JSI_OUTPUT_QUOTE|JSI_OUTPUT_NEWLINES);
        goto done;
    }
    ai1 = argv[1];
    if ((!Jsi_Strcmp(ai1, "-help") || !Jsi_Strcmp(ai1, "-h")) && argc<=3) {
        if (argc>2) {
            if (Jsi_PkgRequire(interp, "Jsi_Help", 0)>=0) {
                char tbuf[BUFSIZ];
                snprintf(tbuf, sizeof(tbuf), "return runModule('Jsi_Help', '%s'.trim().split(null));", argv[2]);
                Jsi_RC rc = Jsi_EvalString(interp, tbuf, 0);
                const char *hstr = Jsi_ValueToString(interp, interp->retValue, NULL);
                if (rc == JSI_OK)
                    puts(hstr);
                return jsi_DoExit(interp, 1);
            }
        }
................................................................................
    }
    if (!Jsi_Strcmp(ai1, "-version"))
        ai1 = "-v";
    int first = 1;
    if (ai1[0] == '-') {
        switch (ai1[1]) {
            case 'a':
                rc = Jsi_EvalString(interp, "runModule('Jsi_Archive');", JSI_EVAL_ISMAIN);
                break;
            case 'c':
                rc = Jsi_EvalString(interp, "runModule('Jsi_CData');", JSI_EVAL_ISMAIN);
                break;
            case 'd':
                interp->debugOpts.isDebugger = 1;
                rc = Jsi_EvalString(interp, "runModule('Jsi_Debug');", JSI_EVAL_ISMAIN);
                break;
            case 'D':
                interp->debugOpts.isDebugger = 1;
                rc = Jsi_EvalString(interp, "runModule('Jsi_DebugUI');", JSI_EVAL_ISMAIN);
                break;
            case 'e':
                if (argc < 3)
                    rc = Jsi_LogError("missing argument");
                else {
                    rc = Jsi_EvalString(interp, argv[2], JSI_EVAL_ISMAIN|JSI_EVAL_NOSKIPBANG);
                    if (rc == JSI_OK && argc>3) {
................................................................................
                        Jsi_ShiftArgs(interp, NULL);
                        Jsi_ShiftArgs(interp, NULL);
                        goto dofile;
                    }
                }
                break;
            case 'g':
                rc = Jsi_EvalString(interp, "runModule('Jsi_GenDeep');", JSI_EVAL_ISMAIN);
                break;
            case 'h':
                goto dohelp;
            case 'J':
                rc = Jsi_EvalString(interp, "runModule('Jsi_Jspp');", JSI_EVAL_ISMAIN);
                break;
            case 'm':
                if (argc <= 2)
                    rc = Jsi_LogError("missing argument");
                else if (argv[2][0] == '-')
                    rc = Jsi_EvalString(interp, "runModule('Jsi_Module');", JSI_EVAL_ISMAIN);
                else {
                    Jsi_DString dStr = {};
                    const char *cps, *cpe;
                    cps = Jsi_Strrchr(argv[2], '/');
                    if (cps) cps++; else cps = argv[2];
                    cpe = Jsi_Strrchr(cps, '.');
                    int len = (cpe?cpe-cps:(int)Jsi_Strlen(cps));
                    if (cpe)
                        Jsi_DSPrintf(&dStr, "source(\"%s\");", argv[2]);
                    else
                        Jsi_DSPrintf(&dStr, "require(\"%s\");", argv[2]);
                    Jsi_DSPrintf(&dStr, "puts(runModule(\"%.*s\",console.args.slice(1)));", len, cps);
                    rc = Jsi_EvalString(interp, Jsi_DSValue(&dStr), JSI_EVAL_NOSKIPBANG);
                    Jsi_DSFree(&dStr);

                }
                break;
            case 's':
                rc = Jsi_EvalString(interp, "runModule('Jsi_Safe');", JSI_EVAL_ISMAIN);
                break;
            case 'S':
                rc = Jsi_EvalString(interp, "runModule('Jsi_SqliteUI');", JSI_EVAL_ISMAIN);
                break;
            case 'u':
                rc = Jsi_EvalString(interp, "exit(runModule('Jsi_UnitTest'));", JSI_EVAL_ISMAIN);
                break;
            case 'v': {
                char str[200] = "\n";
                    
#ifndef JSI__JSIMIN
                Jsi_Channel chan = Jsi_Open(interp, Jsi_ValueNewStringKey(interp, "/zvfs/lib/sourceid.txt"), "r");
                if (chan)
................................................................................
                if (argc>2)
                    printf("%u.%u.%u\n", JSI_VERSION_MAJOR, JSI_VERSION_MINOR, JSI_VERSION_RELEASE);
                else 
                    printf("%u.%u.%u %." JSI_VERFMT_LEN JSI_NUMGFMT " %s", JSI_VERSION_MAJOR, JSI_VERSION_MINOR, JSI_VERSION_RELEASE, Jsi_Version(), str);
                return jsi_DoExit(interp, 1);
            }
            case 'w':
                rc = Jsi_EvalString(interp, "runModule('Jsi_Wget');", JSI_EVAL_ISMAIN);
                break;
            case 'W':
                rc = Jsi_EvalString(interp, "runModule('Jsi_Websrv');", JSI_EVAL_ISMAIN);
                break;
            case 'z':
                rc = Jsi_EvalString(interp, "runModule('Jsi_Zip');", JSI_EVAL_ISMAIN);
                break;
            default:
                puts("usage: jsish [ --I OPT:VAL | --T OPT | --U | --V | --F ] | -e STRING |\n\t"
                "| -a | -c | -d | -D | -h | -m | -s | -S | -u | -v | -w | -W | -z | FILE ...\nUse -help for long help.");
                return jsi_DoExit(interp, 1);
        }
    } else {
................................................................................
            }
            if (!(jsFound&JSI_ZIP_MAIN)) {
                fprintf(stderr, "main.jsi not found\n");
                return jsi_DoExit(interp, 1);
            }
        } else if (ext && !Jsi_Strcmp(ext,".jsc")) {
            Jsi_DString dStr = {};
            Jsi_DSPrintf(&dStr, "console.args.unshift('%s'); runModule('Jsi_CData');", argv[first]);
            rc = Jsi_EvalString(interp, Jsi_DSValue(&dStr), JSI_EVAL_ISMAIN|JSI_EVAL_NOSKIPBANG);
            Jsi_DSFree(&dStr);

        } else {
            if (argc>1) {
                jsi_vf = Jsi_ValueNewStringKey(interp, argv[first]);
                Jsi_IncrRefCount(interp, jsi_vf);
................................................................................
                fputs(Jsi_DSValue(&sHist), stdout);
                Jsi_DSSetLength(&dStr, 0);
                continue;
            }
#endif
            if (!Jsi_Strncmp(buf, "help", 4) && (buf[4] == 0 || isspace(buf[4]))) {
                if (!chkHelp++)
                    hasHelp = (Jsi_PkgRequire(interp, "Jsi_Help", 0)>=0);
                if (hasHelp) {
                    wantHelp = 1;
                    char tbuf[BUFSIZ];
                    snprintf(tbuf, sizeof(tbuf), "return runModule('Jsi_Help', '%s'.trim().split(null));", buf+4);
                    rc = Jsi_EvalString(interp, tbuf, JSI_RETURN);
                }
            }
            if (!wantHelp) {
                if (!Jsi_Strncmp(buf,"var ", 4) && Jsi_Strchr(buf, '\n')==NULL && Jsi_Strchr(buf, ';')==NULL)
                    Jsi_Strcpy(buf+Jsi_Strlen(buf), ";"); // Added space above so strcat ok.
                rc = Jsi_EvalString(interp, buf, JSI_EVAL_RETURN);
................................................................................
    return JSI_OK;
}

static Jsi_Value*
dump_socket_info(SocketObj *cmdPtr, SocketPss *pss)
{
    Jsi_Interp *interp = cmdPtr->interp;
    Jsi_Value *ret = Jsi_ValueNew(interp);
#ifdef JSI_MEM_DEBUG
    jsi_ValueDebugLabel(ret, "socket", "dump_socket");
#endif
    Jsi_JSONParseFmt(interp, &ret, "{address:\"%s\"}", inet_ntoa(pss->sa.sin.sin_addr));
    return ret;
}

................................................................................

    Jsi_Obj *fobj = Jsi_ValueGetObj(interp, toacc);
    if ((cmdPtr->objId = Jsi_UserObjNew(interp, &websockobject, fobj, cmdPtr))<0) {
        goto bail;
    }
    cmdPtr->handlers = Jsi_HashNew(interp, JSI_KEYS_STRING, jsi_wsfreeHandlers);
    if (cmdPtr->extHandlers) {
        jsi_wsHandlerAdd(interp, cmdPtr, ".jsi",   "Jsi_Jspp",     jsi_wsStrValGet(cmdPtr, "jsi"),   1);
        jsi_wsHandlerAdd(interp, cmdPtr, ".htmli", "Jsi_Htmlpp",   jsi_wsStrValGet(cmdPtr, "htmli"), 1);
        jsi_wsHandlerAdd(interp, cmdPtr, ".cssi",  "Jsi_Csspp",    jsi_wsStrValGet(cmdPtr, "cssi"),  1);
        //jsi_wsHandlerAdd(interp, cmdPtr, ".mdi",   "Jsi_Markdeep", jsi_wsStrValGet(cmdPtr, "mdi"),   1);
        jsi_wsHandlerAdd(interp, cmdPtr, ".mdi",   "Jsi_Markdown",  jsi_wsStrValGet(cmdPtr, "mdi"), 1);
    }
    cmdPtr->fobj = fobj;
#ifdef LWS_LIBRARY_VERSION_NUMBER
    Jsi_JSONParseFmt(interp, &cmdPtr->version, "{libVer:\"%s\", hdrVer:\"%s\", hdrNum:%d, pkgVer:%d}",
        (char *)lws_get_library_version(), LWS_LIBRARY_VERSION, LWS_LIBRARY_VERSION_NUMBER, jsi_WsPkgVersion);
#endif
    return JSI_OK;
................................................................................
            /* no action from the callback */
            end = i+1;
        } else {
            i += end;
            end = i;
        }
    }

}


/* find_emph_char -- looks for the next emph char, skipping other constructs */
static size_t find_emph_char(char *data, size_t size, char c) {
    size_t i = 1;

................................................................................
    }

    /* real code span */
    if( f_begin<f_end ) {
        Jsi_DString work = {};
        jsi_DSInitAppend(&work, data+f_begin, f_end-f_begin);
        if( !rndr->make.codespan(ob, &work, rndr->make.opts) ) end = 0;

    } else {
        if( !rndr->make.codespan(ob, 0, rndr->make.opts) ) end = 0;
    }
    return end;
}


................................................................................
        if( rndr->make.normal_text ) {
            jsi_DSInitAppend(&work, data+1,1);
            rndr->make.normal_text(ob, &work, rndr->make.opts);
        } else {
            Jsi_DSAppendLen(ob, data+1, 1);
        }
    }

    return 2;
}


/* char_entity -- '&' escaped when it doesn't belong to an entity */
/* valid entities are assumed to be anything matching &#?[A-Za-z0-9]+; */
static size_t char_entity(
................................................................................
        end++;
    }
    if( end<size && data[end]==';' ) {
        /* real entity */
        end++;
    } else {
        /* lone '&' */

        return 0;
    }
    if( rndr->make.entity ) {
        jsi_DSInitAppend(&work, data, end);
        rndr->make.entity(ob, &work, rndr->make.opts);
    } else {
        Jsi_DSAppendLen(ob, data, end);
    }

    return end;
}


/* char_langle_tag -- '<' when tags or autolinks are allowed */
static size_t char_langle_tag(
    Jsi_DString *ob,
................................................................................
    }

    if( !ret ) {
        return 0;
    } else {
        return end;
    }

}


/* get_link_inline -- extract inline-style link and title from
** parenthesed data
*/
static int get_link_inline(
................................................................................
                    rndr->make.blockhtml(ob, &work, rndr->make.opts);
                    return work_size;
                }
            }
        }

        /* no special case recognised */
        return 0;
    }

    /* looking for an unindented matching closing tag */
    /*  followed by a blank line */
    i = 1;
    found = 0;
#if 0
................................................................................
                i += j-1;
                found = 1;
                break;
            }
        }
    }

    if( !found ) return 0;

    /* the end of the block has been found */
    jsi_DSInitAppend(&work, data, i);
    if( rndr->make.blockhtml ) {
        rndr->make.blockhtml(ob, &work, rndr->make.opts);
    }


    return i;
}


/* parse_table_cell -- parse a cell inside a table */
static void parse_table_cell(
    Jsi_DString *ob,     /* output blob */






|







 







|












|

|







 







|


|



|



|







 







|




|


|
<
<
|

|












>



|


|


|







 







|


|


|







 







|







 







|



|







 







|







 







|
|
|
|
|







 







>







 







>







 







>







 







>








>







 







>







 







|







 







|






>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
.....
20630
20631
20632
20633
20634
20635
20636
20637
20638
20639
20640
20641
20642
20643
20644
20645
20646
20647
20648
20649
20650
20651
20652
20653
20654
20655
20656
20657
20658
20659
.....
20688
20689
20690
20691
20692
20693
20694
20695
20696
20697
20698
20699
20700
20701
20702
20703
20704
20705
20706
20707
20708
20709
20710
20711
20712
20713
.....
20715
20716
20717
20718
20719
20720
20721
20722
20723
20724
20725
20726
20727
20728
20729
20730


20731
20732
20733
20734
20735
20736
20737
20738
20739
20740
20741
20742
20743
20744
20745
20746
20747
20748
20749
20750
20751
20752
20753
20754
20755
20756
20757
20758
20759
20760
20761
20762
20763
.....
20766
20767
20768
20769
20770
20771
20772
20773
20774
20775
20776
20777
20778
20779
20780
20781
20782
20783
20784
20785
20786
.....
20796
20797
20798
20799
20800
20801
20802
20803
20804
20805
20806
20807
20808
20809
20810
.....
23957
23958
23959
23960
23961
23962
23963
23964
23965
23966
23967
23968
23969
23970
23971
23972
23973
23974
23975
.....
47381
47382
47383
47384
47385
47386
47387
47388
47389
47390
47391
47392
47393
47394
47395
.....
55444
55445
55446
55447
55448
55449
55450
55451
55452
55453
55454
55455
55456
55457
55458
55459
55460
55461
55462
.....
60674
60675
60676
60677
60678
60679
60680
60681
60682
60683
60684
60685
60686
60687
60688
.....
60985
60986
60987
60988
60989
60990
60991
60992
60993
60994
60995
60996
60997
60998
60999
.....
61010
61011
61012
61013
61014
61015
61016
61017
61018
61019
61020
61021
61022
61023
61024
.....
61039
61040
61041
61042
61043
61044
61045
61046
61047
61048
61049
61050
61051
61052
61053
61054
61055
61056
61057
61058
61059
61060
61061
61062
.....
61080
61081
61082
61083
61084
61085
61086
61087
61088
61089
61090
61091
61092
61093
61094
.....
62020
62021
62022
62023
62024
62025
62026
62027
62028
62029
62030
62031
62032
62033
62034
.....
62062
62063
62064
62065
62066
62067
62068
62069
62070
62071
62072
62073
62074
62075
62076
62077
62078
62079
62080
62081
62082
62083
62084
/* jsi.h : External API header file for Jsi. */
#ifndef __JSI_H__
#define __JSI_H__

#define JSI_VERSION_MAJOR   2
#define JSI_VERSION_MINOR   8
#define JSI_VERSION_RELEASE 37

#define JSI_VERSION (JSI_VERSION_MAJOR + ((Jsi_Number)JSI_VERSION_MINOR/100.0) + ((Jsi_Number)JSI_VERSION_RELEASE/10000.0))

#ifndef JSI_EXTERN
#define JSI_EXTERN extern
#endif

................................................................................
                return jsi_DoExit(interp, 1);
            }
        }
    }
#endif
    const char *ext = NULL, *ai1, *iext = (argc<=1?NULL:Jsi_Strrchr(argv[1], '.'));
    if (interp->selfZvfs && iext && Jsi_Strcmp(iext,".fossil")==0) {
        rc = Jsi_EvalString(interp, "runModule('Archive');", JSI_EVAL_ISMAIN);
        goto done;
    }
    Jsi_ShiftArgs(interp, NULL);
    if (argc <= 1) {
        if (interp->opts.no_interactive && !interp->interactive)
            return interp;
        rc = Jsi_Interactive(interp, JSI_OUTPUT_QUOTE|JSI_OUTPUT_NEWLINES);
        goto done;
    }
    ai1 = argv[1];
    if ((!Jsi_Strcmp(ai1, "-help") || !Jsi_Strcmp(ai1, "-h")) && argc<=3) {
        if (argc>2) {
            if (Jsi_PkgRequire(interp, "Help", 0)>=0) {
                char tbuf[BUFSIZ];
                snprintf(tbuf, sizeof(tbuf), "return runModule('Help', '%s'.trim().split(null));", argv[2]);
                Jsi_RC rc = Jsi_EvalString(interp, tbuf, 0);
                const char *hstr = Jsi_ValueToString(interp, interp->retValue, NULL);
                if (rc == JSI_OK)
                    puts(hstr);
                return jsi_DoExit(interp, 1);
            }
        }
................................................................................
    }
    if (!Jsi_Strcmp(ai1, "-version"))
        ai1 = "-v";
    int first = 1;
    if (ai1[0] == '-') {
        switch (ai1[1]) {
            case 'a':
                rc = Jsi_EvalString(interp, "runModule('Archive');", JSI_EVAL_ISMAIN);
                break;
            case 'c':
                rc = Jsi_EvalString(interp, "runModule('Cdata');", JSI_EVAL_ISMAIN);
                break;
            case 'd':
                interp->debugOpts.isDebugger = 1;
                rc = Jsi_EvalString(interp, "runModule('Debug');", JSI_EVAL_ISMAIN);
                break;
            case 'D':
                interp->debugOpts.isDebugger = 1;
                rc = Jsi_EvalString(interp, "runModule('DebugUI');", JSI_EVAL_ISMAIN);
                break;
            case 'e':
                if (argc < 3)
                    rc = Jsi_LogError("missing argument");
                else {
                    rc = Jsi_EvalString(interp, argv[2], JSI_EVAL_ISMAIN|JSI_EVAL_NOSKIPBANG);
                    if (rc == JSI_OK && argc>3) {
................................................................................
                        Jsi_ShiftArgs(interp, NULL);
                        Jsi_ShiftArgs(interp, NULL);
                        goto dofile;
                    }
                }
                break;
            case 'g':
                rc = Jsi_EvalString(interp, "runModule('GenDeep');", JSI_EVAL_ISMAIN);
                break;
            case 'h':
                goto dohelp;
            case 'J':
                rc = Jsi_EvalString(interp, "runModule('Jspp');", JSI_EVAL_ISMAIN);
                break;
            case 'm':
                if (argc <= 2 || argv[2][0] == '-')


                    rc = Jsi_EvalString(interp, "runModule('Module');", JSI_EVAL_ISMAIN);
                else {
                    Jsi_DString dStr = {}, eStr = {};
                    const char *cps, *cpe;
                    cps = Jsi_Strrchr(argv[2], '/');
                    if (cps) cps++; else cps = argv[2];
                    cpe = Jsi_Strrchr(cps, '.');
                    int len = (cpe?cpe-cps:(int)Jsi_Strlen(cps));
                    if (cpe)
                        Jsi_DSPrintf(&dStr, "source(\"%s\");", argv[2]);
                    else
                        Jsi_DSPrintf(&dStr, "require(\"%s\");", argv[2]);
                    Jsi_DSPrintf(&dStr, "puts(runModule(\"%.*s\",console.args.slice(1)));", len, cps);
                    rc = Jsi_EvalString(interp, Jsi_DSValue(&dStr), JSI_EVAL_NOSKIPBANG);
                    Jsi_DSFree(&dStr);
                    Jsi_DSFree(&eStr);
                }
                break;
            case 's':
                rc = Jsi_EvalString(interp, "runModule('Safe');", JSI_EVAL_ISMAIN);
                break;
            case 'S':
                rc = Jsi_EvalString(interp, "runModule('SqliteUI');", JSI_EVAL_ISMAIN);
                break;
            case 'u':
                rc = Jsi_EvalString(interp, "exit(runModule('UnitTest'));", JSI_EVAL_ISMAIN);
                break;
            case 'v': {
                char str[200] = "\n";
                    
#ifndef JSI__JSIMIN
                Jsi_Channel chan = Jsi_Open(interp, Jsi_ValueNewStringKey(interp, "/zvfs/lib/sourceid.txt"), "r");
                if (chan)
................................................................................
                if (argc>2)
                    printf("%u.%u.%u\n", JSI_VERSION_MAJOR, JSI_VERSION_MINOR, JSI_VERSION_RELEASE);
                else 
                    printf("%u.%u.%u %." JSI_VERFMT_LEN JSI_NUMGFMT " %s", JSI_VERSION_MAJOR, JSI_VERSION_MINOR, JSI_VERSION_RELEASE, Jsi_Version(), str);
                return jsi_DoExit(interp, 1);
            }
            case 'w':
                rc = Jsi_EvalString(interp, "runModule('Wget');", JSI_EVAL_ISMAIN);
                break;
            case 'W':
                rc = Jsi_EvalString(interp, "runModule('Websrv');", JSI_EVAL_ISMAIN);
                break;
            case 'z':
                rc = Jsi_EvalString(interp, "runModule('Zip');", JSI_EVAL_ISMAIN);
                break;
            default:
                puts("usage: jsish [ --I OPT:VAL | --T OPT | --U | --V | --F ] | -e STRING |\n\t"
                "| -a | -c | -d | -D | -h | -m | -s | -S | -u | -v | -w | -W | -z | FILE ...\nUse -help for long help.");
                return jsi_DoExit(interp, 1);
        }
    } else {
................................................................................
            }
            if (!(jsFound&JSI_ZIP_MAIN)) {
                fprintf(stderr, "main.jsi not found\n");
                return jsi_DoExit(interp, 1);
            }
        } else if (ext && !Jsi_Strcmp(ext,".jsc")) {
            Jsi_DString dStr = {};
            Jsi_DSPrintf(&dStr, "console.args.unshift('%s'); runModule('CData');", argv[first]);
            rc = Jsi_EvalString(interp, Jsi_DSValue(&dStr), JSI_EVAL_ISMAIN|JSI_EVAL_NOSKIPBANG);
            Jsi_DSFree(&dStr);

        } else {
            if (argc>1) {
                jsi_vf = Jsi_ValueNewStringKey(interp, argv[first]);
                Jsi_IncrRefCount(interp, jsi_vf);
................................................................................
                fputs(Jsi_DSValue(&sHist), stdout);
                Jsi_DSSetLength(&dStr, 0);
                continue;
            }
#endif
            if (!Jsi_Strncmp(buf, "help", 4) && (buf[4] == 0 || isspace(buf[4]))) {
                if (!chkHelp++)
                    hasHelp = (Jsi_PkgRequire(interp, "Help", 0)>=0);
                if (hasHelp) {
                    wantHelp = 1;
                    char tbuf[BUFSIZ];
                    snprintf(tbuf, sizeof(tbuf), "return runModule('Help', '%s'.trim().split(null));", buf+4);
                    rc = Jsi_EvalString(interp, tbuf, JSI_RETURN);
                }
            }
            if (!wantHelp) {
                if (!Jsi_Strncmp(buf,"var ", 4) && Jsi_Strchr(buf, '\n')==NULL && Jsi_Strchr(buf, ';')==NULL)
                    Jsi_Strcpy(buf+Jsi_Strlen(buf), ";"); // Added space above so strcat ok.
                rc = Jsi_EvalString(interp, buf, JSI_EVAL_RETURN);
................................................................................
    return JSI_OK;
}

static Jsi_Value*
dump_socket_info(SocketObj *cmdPtr, SocketPss *pss)
{
    Jsi_Interp *interp = cmdPtr->interp;
    Jsi_Value *ret = Jsi_ValueNew1(interp);
#ifdef JSI_MEM_DEBUG
    jsi_ValueDebugLabel(ret, "socket", "dump_socket");
#endif
    Jsi_JSONParseFmt(interp, &ret, "{address:\"%s\"}", inet_ntoa(pss->sa.sin.sin_addr));
    return ret;
}

................................................................................

    Jsi_Obj *fobj = Jsi_ValueGetObj(interp, toacc);
    if ((cmdPtr->objId = Jsi_UserObjNew(interp, &websockobject, fobj, cmdPtr))<0) {
        goto bail;
    }
    cmdPtr->handlers = Jsi_HashNew(interp, JSI_KEYS_STRING, jsi_wsfreeHandlers);
    if (cmdPtr->extHandlers) {
        jsi_wsHandlerAdd(interp, cmdPtr, ".jsi",   "Jspp",     jsi_wsStrValGet(cmdPtr, "jsi"),   1);
        jsi_wsHandlerAdd(interp, cmdPtr, ".htmli", "Htmlpp",   jsi_wsStrValGet(cmdPtr, "htmli"), 1);
        jsi_wsHandlerAdd(interp, cmdPtr, ".cssi",  "Csspp",    jsi_wsStrValGet(cmdPtr, "cssi"),  1);
        //jsi_wsHandlerAdd(interp, cmdPtr, ".mdi",   "Markdeep", jsi_wsStrValGet(cmdPtr, "mdi"),   1);
        jsi_wsHandlerAdd(interp, cmdPtr, ".mdi",   "Markdown",  jsi_wsStrValGet(cmdPtr, "mdi"), 1);
    }
    cmdPtr->fobj = fobj;
#ifdef LWS_LIBRARY_VERSION_NUMBER
    Jsi_JSONParseFmt(interp, &cmdPtr->version, "{libVer:\"%s\", hdrVer:\"%s\", hdrNum:%d, pkgVer:%d}",
        (char *)lws_get_library_version(), LWS_LIBRARY_VERSION, LWS_LIBRARY_VERSION_NUMBER, jsi_WsPkgVersion);
#endif
    return JSI_OK;
................................................................................
            /* no action from the callback */
            end = i+1;
        } else {
            i += end;
            end = i;
        }
    }
    Jsi_DSFree(&work);
}


/* find_emph_char -- looks for the next emph char, skipping other constructs */
static size_t find_emph_char(char *data, size_t size, char c) {
    size_t i = 1;

................................................................................
    }

    /* real code span */
    if( f_begin<f_end ) {
        Jsi_DString work = {};
        jsi_DSInitAppend(&work, data+f_begin, f_end-f_begin);
        if( !rndr->make.codespan(ob, &work, rndr->make.opts) ) end = 0;
        Jsi_DSFree(&work);
    } else {
        if( !rndr->make.codespan(ob, 0, rndr->make.opts) ) end = 0;
    }
    return end;
}


................................................................................
        if( rndr->make.normal_text ) {
            jsi_DSInitAppend(&work, data+1,1);
            rndr->make.normal_text(ob, &work, rndr->make.opts);
        } else {
            Jsi_DSAppendLen(ob, data+1, 1);
        }
    }
    Jsi_DSFree(&work);
    return 2;
}


/* char_entity -- '&' escaped when it doesn't belong to an entity */
/* valid entities are assumed to be anything matching &#?[A-Za-z0-9]+; */
static size_t char_entity(
................................................................................
        end++;
    }
    if( end<size && data[end]==';' ) {
        /* real entity */
        end++;
    } else {
        /* lone '&' */
        Jsi_DSFree(&work);
        return 0;
    }
    if( rndr->make.entity ) {
        jsi_DSInitAppend(&work, data, end);
        rndr->make.entity(ob, &work, rndr->make.opts);
    } else {
        Jsi_DSAppendLen(ob, data, end);
    }
    Jsi_DSFree(&work);
    return end;
}


/* char_langle_tag -- '<' when tags or autolinks are allowed */
static size_t char_langle_tag(
    Jsi_DString *ob,
................................................................................
    }

    if( !ret ) {
        return 0;
    } else {
        return end;
    }
    Jsi_DSFree(&work);
}


/* get_link_inline -- extract inline-style link and title from
** parenthesed data
*/
static int get_link_inline(
................................................................................
                    rndr->make.blockhtml(ob, &work, rndr->make.opts);
                    return work_size;
                }
            }
        }

        /* no special case recognised */
        i=0; goto done;
    }

    /* looking for an unindented matching closing tag */
    /*  followed by a blank line */
    i = 1;
    found = 0;
#if 0
................................................................................
                i += j-1;
                found = 1;
                break;
            }
        }
    }

    if( !found ) {i=0; goto done;}

    /* the end of the block has been found */
    jsi_DSInitAppend(&work, data, i);
    if( rndr->make.blockhtml ) {
        rndr->make.blockhtml(ob, &work, rndr->make.opts);
    }
done:
    Jsi_DSFree(&work);
    return i;
}


/* parse_table_cell -- parse a cell inside a table */
static void parse_table_cell(
    Jsi_DString *ob,     /* output blob */

Changes to src/jsi.h.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* jsi.h : External API header file for Jsi. */
#ifndef __JSI_H__
#define __JSI_H__

#define JSI_VERSION_MAJOR   2
#define JSI_VERSION_MINOR   8
#define JSI_VERSION_RELEASE 36

#define JSI_VERSION (JSI_VERSION_MAJOR + ((Jsi_Number)JSI_VERSION_MINOR/100.0) + ((Jsi_Number)JSI_VERSION_RELEASE/10000.0))

#ifndef JSI_EXTERN
#define JSI_EXTERN extern
#endif







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* jsi.h : External API header file for Jsi. */
#ifndef __JSI_H__
#define __JSI_H__

#define JSI_VERSION_MAJOR   2
#define JSI_VERSION_MINOR   8
#define JSI_VERSION_RELEASE 37

#define JSI_VERSION (JSI_VERSION_MAJOR + ((Jsi_Number)JSI_VERSION_MINOR/100.0) + ((Jsi_Number)JSI_VERSION_RELEASE/10000.0))

#ifndef JSI_EXTERN
#define JSI_EXTERN extern
#endif

Changes to src/jsiInterp.c.

682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
...
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
...
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
...
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
...
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
                return jsi_DoExit(interp, 1);
            }
        }
    }
#endif
    const char *ext = NULL, *ai1, *iext = (argc<=1?NULL:Jsi_Strrchr(argv[1], '.'));
    if (interp->selfZvfs && iext && Jsi_Strcmp(iext,".fossil")==0) {
        rc = Jsi_EvalString(interp, "runModule('Jsi_Archive');", JSI_EVAL_ISMAIN);
        goto done;
    }
    Jsi_ShiftArgs(interp, NULL);
    if (argc <= 1) {
        if (interp->opts.no_interactive && !interp->interactive)
            return interp;
        rc = Jsi_Interactive(interp, JSI_OUTPUT_QUOTE|JSI_OUTPUT_NEWLINES);
        goto done;
    }
    ai1 = argv[1];
    if ((!Jsi_Strcmp(ai1, "-help") || !Jsi_Strcmp(ai1, "-h")) && argc<=3) {
        if (argc>2) {
            if (Jsi_PkgRequire(interp, "Jsi_Help", 0)>=0) {
                char tbuf[BUFSIZ];
                snprintf(tbuf, sizeof(tbuf), "return runModule('Jsi_Help', '%s'.trim().split(null));", argv[2]);
                Jsi_RC rc = Jsi_EvalString(interp, tbuf, 0);
                const char *hstr = Jsi_ValueToString(interp, interp->retValue, NULL);
                if (rc == JSI_OK)
                    puts(hstr);
                return jsi_DoExit(interp, 1);
            }
        }
................................................................................
    }
    if (!Jsi_Strcmp(ai1, "-version"))
        ai1 = "-v";
    int first = 1;
    if (ai1[0] == '-') {
        switch (ai1[1]) {
            case 'a':
                rc = Jsi_EvalString(interp, "runModule('Jsi_Archive');", JSI_EVAL_ISMAIN);
                break;
            case 'c':
                rc = Jsi_EvalString(interp, "runModule('Jsi_CData');", JSI_EVAL_ISMAIN);
                break;
            case 'd':
                interp->debugOpts.isDebugger = 1;
                rc = Jsi_EvalString(interp, "runModule('Jsi_Debug');", JSI_EVAL_ISMAIN);
                break;
            case 'D':
                interp->debugOpts.isDebugger = 1;
                rc = Jsi_EvalString(interp, "runModule('Jsi_DebugUI');", JSI_EVAL_ISMAIN);
                break;
            case 'e':
                if (argc < 3)
                    rc = Jsi_LogError("missing argument");
                else {
                    rc = Jsi_EvalString(interp, argv[2], JSI_EVAL_ISMAIN|JSI_EVAL_NOSKIPBANG);
                    if (rc == JSI_OK && argc>3) {
................................................................................
                        Jsi_ShiftArgs(interp, NULL);
                        Jsi_ShiftArgs(interp, NULL);
                        goto dofile;
                    }
                }
                break;
            case 'g':
                rc = Jsi_EvalString(interp, "runModule('Jsi_GenDeep');", JSI_EVAL_ISMAIN);
                break;
            case 'h':
                goto dohelp;
            case 'J':
                rc = Jsi_EvalString(interp, "runModule('Jsi_Jspp');", JSI_EVAL_ISMAIN);
                break;
            case 'm':
                if (argc <= 2)
                    rc = Jsi_LogError("missing argument");
                else if (argv[2][0] == '-')
                    rc = Jsi_EvalString(interp, "runModule('Jsi_Module');", JSI_EVAL_ISMAIN);
                else {
                    Jsi_DString dStr = {}, eStr = {};
                    const char *cps, *cpe;
                    cps = Jsi_Strrchr(argv[2], '/');
                    if (cps) cps++; else cps = argv[2];
                    cpe = Jsi_Strrchr(cps, '.');
                    int len = (cpe?cpe-cps:(int)Jsi_Strlen(cps));
                    if (cpe)
                        Jsi_DSPrintf(&dStr, "source(\"%s\");", argv[2]);
                    else {
                        const char *av = argv[2];
                        if (Jsi_Strncmp(av, "Jsi_", 4)) { // Support Jsi_Safe using just Safe, etc.
                            Jsi_DSPrintf(&eStr, "%s/lib/Jsi_%s.jsi", JSI_ZVFS_DIR, av);
                            Jsi_Value *fv = jsi_AccessFile(interp, Jsi_DSValue(&eStr), R_OK);
                            if (fv) {
                                Jsi_DecrRefCount(interp, fv);
                                Jsi_DSFree(&eStr);
                                Jsi_DSPrintf(&eStr, "Jsi_%s", av);
                                cps = av = Jsi_DSValue(&eStr);
                                len = Jsi_Strlen(cps);
                            }
                        }
                        Jsi_DSPrintf(&dStr, "require(\"%s\");", av);
                    }
                    Jsi_DSPrintf(&dStr, "puts(runModule(\"%.*s\",console.args.slice(1)));", len, cps);
                    rc = Jsi_EvalString(interp, Jsi_DSValue(&dStr), JSI_EVAL_NOSKIPBANG);
                    Jsi_DSFree(&dStr);
                    Jsi_DSFree(&eStr);
                }
                break;
            case 's':
                rc = Jsi_EvalString(interp, "runModule('Jsi_Safe');", JSI_EVAL_ISMAIN);
                break;
            case 'S':
                rc = Jsi_EvalString(interp, "runModule('Jsi_SqliteUI');", JSI_EVAL_ISMAIN);
                break;
            case 'u':
                rc = Jsi_EvalString(interp, "exit(runModule('Jsi_UnitTest'));", JSI_EVAL_ISMAIN);
                break;
            case 'v': {
                char str[200] = "\n";
                    
#ifndef JSI__JSIMIN
                Jsi_Channel chan = Jsi_Open(interp, Jsi_ValueNewStringKey(interp, "/zvfs/lib/sourceid.txt"), "r");
                if (chan)
................................................................................
                if (argc>2)
                    printf("%u.%u.%u\n", JSI_VERSION_MAJOR, JSI_VERSION_MINOR, JSI_VERSION_RELEASE);
                else 
                    printf("%u.%u.%u %." JSI_VERFMT_LEN JSI_NUMGFMT " %s", JSI_VERSION_MAJOR, JSI_VERSION_MINOR, JSI_VERSION_RELEASE, Jsi_Version(), str);
                return jsi_DoExit(interp, 1);
            }
            case 'w':
                rc = Jsi_EvalString(interp, "runModule('Jsi_Wget');", JSI_EVAL_ISMAIN);
                break;
            case 'W':
                rc = Jsi_EvalString(interp, "runModule('Jsi_Websrv');", JSI_EVAL_ISMAIN);
                break;
            case 'z':
                rc = Jsi_EvalString(interp, "runModule('Jsi_Zip');", JSI_EVAL_ISMAIN);
                break;
            default:
                puts("usage: jsish [ --I OPT:VAL | --T OPT | --U | --V | --F ] | -e STRING |\n\t"
                "| -a | -c | -d | -D | -h | -m | -s | -S | -u | -v | -w | -W | -z | FILE ...\nUse -help for long help.");
                return jsi_DoExit(interp, 1);
        }
    } else {
................................................................................
            }
            if (!(jsFound&JSI_ZIP_MAIN)) {
                fprintf(stderr, "main.jsi not found\n");
                return jsi_DoExit(interp, 1);
            }
        } else if (ext && !Jsi_Strcmp(ext,".jsc")) {
            Jsi_DString dStr = {};
            Jsi_DSPrintf(&dStr, "console.args.unshift('%s'); runModule('Jsi_CData');", argv[first]);
            rc = Jsi_EvalString(interp, Jsi_DSValue(&dStr), JSI_EVAL_ISMAIN|JSI_EVAL_NOSKIPBANG);
            Jsi_DSFree(&dStr);

        } else {
            if (argc>1) {
                jsi_vf = Jsi_ValueNewStringKey(interp, argv[first]);
                Jsi_IncrRefCount(interp, jsi_vf);







|












|

|







 







|


|



|



|







 







|




|


|
<
<
|









|
<
<
<
<
<
<
<
<
<
<
<
<
|
<







|


|


|







 







|


|


|







 







|







682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
...
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
...
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782


783
784
785
786
787
788
789
790
791
792
793












794

795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
...
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
...
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
                return jsi_DoExit(interp, 1);
            }
        }
    }
#endif
    const char *ext = NULL, *ai1, *iext = (argc<=1?NULL:Jsi_Strrchr(argv[1], '.'));
    if (interp->selfZvfs && iext && Jsi_Strcmp(iext,".fossil")==0) {
        rc = Jsi_EvalString(interp, "runModule('Archive');", JSI_EVAL_ISMAIN);
        goto done;
    }
    Jsi_ShiftArgs(interp, NULL);
    if (argc <= 1) {
        if (interp->opts.no_interactive && !interp->interactive)
            return interp;
        rc = Jsi_Interactive(interp, JSI_OUTPUT_QUOTE|JSI_OUTPUT_NEWLINES);
        goto done;
    }
    ai1 = argv[1];
    if ((!Jsi_Strcmp(ai1, "-help") || !Jsi_Strcmp(ai1, "-h")) && argc<=3) {
        if (argc>2) {
            if (Jsi_PkgRequire(interp, "Help", 0)>=0) {
                char tbuf[BUFSIZ];
                snprintf(tbuf, sizeof(tbuf), "return runModule('Help', '%s'.trim().split(null));", argv[2]);
                Jsi_RC rc = Jsi_EvalString(interp, tbuf, 0);
                const char *hstr = Jsi_ValueToString(interp, interp->retValue, NULL);
                if (rc == JSI_OK)
                    puts(hstr);
                return jsi_DoExit(interp, 1);
            }
        }
................................................................................
    }
    if (!Jsi_Strcmp(ai1, "-version"))
        ai1 = "-v";
    int first = 1;
    if (ai1[0] == '-') {
        switch (ai1[1]) {
            case 'a':
                rc = Jsi_EvalString(interp, "runModule('Archive');", JSI_EVAL_ISMAIN);
                break;
            case 'c':
                rc = Jsi_EvalString(interp, "runModule('Cdata');", JSI_EVAL_ISMAIN);
                break;
            case 'd':
                interp->debugOpts.isDebugger = 1;
                rc = Jsi_EvalString(interp, "runModule('Debug');", JSI_EVAL_ISMAIN);
                break;
            case 'D':
                interp->debugOpts.isDebugger = 1;
                rc = Jsi_EvalString(interp, "runModule('DebugUI');", JSI_EVAL_ISMAIN);
                break;
            case 'e':
                if (argc < 3)
                    rc = Jsi_LogError("missing argument");
                else {
                    rc = Jsi_EvalString(interp, argv[2], JSI_EVAL_ISMAIN|JSI_EVAL_NOSKIPBANG);
                    if (rc == JSI_OK && argc>3) {
................................................................................
                        Jsi_ShiftArgs(interp, NULL);
                        Jsi_ShiftArgs(interp, NULL);
                        goto dofile;
                    }
                }
                break;
            case 'g':
                rc = Jsi_EvalString(interp, "runModule('GenDeep');", JSI_EVAL_ISMAIN);
                break;
            case 'h':
                goto dohelp;
            case 'J':
                rc = Jsi_EvalString(interp, "runModule('Jspp');", JSI_EVAL_ISMAIN);
                break;
            case 'm':
                if (argc <= 2 || argv[2][0] == '-')


                    rc = Jsi_EvalString(interp, "runModule('Module');", JSI_EVAL_ISMAIN);
                else {
                    Jsi_DString dStr = {}, eStr = {};
                    const char *cps, *cpe;
                    cps = Jsi_Strrchr(argv[2], '/');
                    if (cps) cps++; else cps = argv[2];
                    cpe = Jsi_Strrchr(cps, '.');
                    int len = (cpe?cpe-cps:(int)Jsi_Strlen(cps));
                    if (cpe)
                        Jsi_DSPrintf(&dStr, "source(\"%s\");", argv[2]);
                    else












                        Jsi_DSPrintf(&dStr, "require(\"%s\");", argv[2]);

                    Jsi_DSPrintf(&dStr, "puts(runModule(\"%.*s\",console.args.slice(1)));", len, cps);
                    rc = Jsi_EvalString(interp, Jsi_DSValue(&dStr), JSI_EVAL_NOSKIPBANG);
                    Jsi_DSFree(&dStr);
                    Jsi_DSFree(&eStr);
                }
                break;
            case 's':
                rc = Jsi_EvalString(interp, "runModule('Safe');", JSI_EVAL_ISMAIN);
                break;
            case 'S':
                rc = Jsi_EvalString(interp, "runModule('SqliteUI');", JSI_EVAL_ISMAIN);
                break;
            case 'u':
                rc = Jsi_EvalString(interp, "exit(runModule('UnitTest'));", JSI_EVAL_ISMAIN);
                break;
            case 'v': {
                char str[200] = "\n";
                    
#ifndef JSI__JSIMIN
                Jsi_Channel chan = Jsi_Open(interp, Jsi_ValueNewStringKey(interp, "/zvfs/lib/sourceid.txt"), "r");
                if (chan)
................................................................................
                if (argc>2)
                    printf("%u.%u.%u\n", JSI_VERSION_MAJOR, JSI_VERSION_MINOR, JSI_VERSION_RELEASE);
                else 
                    printf("%u.%u.%u %." JSI_VERFMT_LEN JSI_NUMGFMT " %s", JSI_VERSION_MAJOR, JSI_VERSION_MINOR, JSI_VERSION_RELEASE, Jsi_Version(), str);
                return jsi_DoExit(interp, 1);
            }
            case 'w':
                rc = Jsi_EvalString(interp, "runModule('Wget');", JSI_EVAL_ISMAIN);
                break;
            case 'W':
                rc = Jsi_EvalString(interp, "runModule('Websrv');", JSI_EVAL_ISMAIN);
                break;
            case 'z':
                rc = Jsi_EvalString(interp, "runModule('Zip');", JSI_EVAL_ISMAIN);
                break;
            default:
                puts("usage: jsish [ --I OPT:VAL | --T OPT | --U | --V | --F ] | -e STRING |\n\t"
                "| -a | -c | -d | -D | -h | -m | -s | -S | -u | -v | -w | -W | -z | FILE ...\nUse -help for long help.");
                return jsi_DoExit(interp, 1);
        }
    } else {
................................................................................
            }
            if (!(jsFound&JSI_ZIP_MAIN)) {
                fprintf(stderr, "main.jsi not found\n");
                return jsi_DoExit(interp, 1);
            }
        } else if (ext && !Jsi_Strcmp(ext,".jsc")) {
            Jsi_DString dStr = {};
            Jsi_DSPrintf(&dStr, "console.args.unshift('%s'); runModule('CData');", argv[first]);
            rc = Jsi_EvalString(interp, Jsi_DSValue(&dStr), JSI_EVAL_ISMAIN|JSI_EVAL_NOSKIPBANG);
            Jsi_DSFree(&dStr);

        } else {
            if (argc>1) {
                jsi_vf = Jsi_ValueNewStringKey(interp, argv[first]);
                Jsi_IncrRefCount(interp, jsi_vf);

Changes to src/jsiSocket.c.

654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
    return JSI_OK;
}

static Jsi_Value*
dump_socket_info(SocketObj *cmdPtr, SocketPss *pss)
{
    Jsi_Interp *interp = cmdPtr->interp;
    Jsi_Value *ret = Jsi_ValueNew(interp);
#ifdef JSI_MEM_DEBUG
    jsi_ValueDebugLabel(ret, "socket", "dump_socket");
#endif
    Jsi_JSONParseFmt(interp, &ret, "{address:\"%s\"}", inet_ntoa(pss->sa.sin.sin_addr));
    return ret;
}








|







654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
    return JSI_OK;
}

static Jsi_Value*
dump_socket_info(SocketObj *cmdPtr, SocketPss *pss)
{
    Jsi_Interp *interp = cmdPtr->interp;
    Jsi_Value *ret = Jsi_ValueNew1(interp);
#ifdef JSI_MEM_DEBUG
    jsi_ValueDebugLabel(ret, "socket", "dump_socket");
#endif
    Jsi_JSONParseFmt(interp, &ret, "{address:\"%s\"}", inet_ntoa(pss->sa.sin.sin_addr));
    return ret;
}

Changes to src/jsiUtils.c.

1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
                fputs(Jsi_DSValue(&sHist), stdout);
                Jsi_DSSetLength(&dStr, 0);
                continue;
            }
#endif
            if (!Jsi_Strncmp(buf, "help", 4) && (buf[4] == 0 || isspace(buf[4]))) {
                if (!chkHelp++)
                    hasHelp = (Jsi_PkgRequire(interp, "Jsi_Help", 0)>=0);
                if (hasHelp) {
                    wantHelp = 1;
                    char tbuf[BUFSIZ];
                    snprintf(tbuf, sizeof(tbuf), "return runModule('Jsi_Help', '%s'.trim().split(null));", buf+4);
                    rc = Jsi_EvalString(interp, tbuf, JSI_RETURN);
                }
            }
            if (!wantHelp) {
                if (!Jsi_Strncmp(buf,"var ", 4) && Jsi_Strchr(buf, '\n')==NULL && Jsi_Strchr(buf, ';')==NULL)
                    Jsi_Strcpy(buf+Jsi_Strlen(buf), ";"); // Added space above so strcat ok.
                rc = Jsi_EvalString(interp, buf, JSI_EVAL_RETURN);







|



|







1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
                fputs(Jsi_DSValue(&sHist), stdout);
                Jsi_DSSetLength(&dStr, 0);
                continue;
            }
#endif
            if (!Jsi_Strncmp(buf, "help", 4) && (buf[4] == 0 || isspace(buf[4]))) {
                if (!chkHelp++)
                    hasHelp = (Jsi_PkgRequire(interp, "Help", 0)>=0);
                if (hasHelp) {
                    wantHelp = 1;
                    char tbuf[BUFSIZ];
                    snprintf(tbuf, sizeof(tbuf), "return runModule('Help', '%s'.trim().split(null));", buf+4);
                    rc = Jsi_EvalString(interp, tbuf, JSI_RETURN);
                }
            }
            if (!wantHelp) {
                if (!Jsi_Strncmp(buf,"var ", 4) && Jsi_Strchr(buf, '\n')==NULL && Jsi_Strchr(buf, ';')==NULL)
                    Jsi_Strcpy(buf+Jsi_Strlen(buf), ";"); // Added space above so strcat ok.
                rc = Jsi_EvalString(interp, buf, JSI_EVAL_RETURN);

Changes to src/jsiWebSocket.c.

2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788

    Jsi_Obj *fobj = Jsi_ValueGetObj(interp, toacc);
    if ((cmdPtr->objId = Jsi_UserObjNew(interp, &websockobject, fobj, cmdPtr))<0) {
        goto bail;
    }
    cmdPtr->handlers = Jsi_HashNew(interp, JSI_KEYS_STRING, jsi_wsfreeHandlers);
    if (cmdPtr->extHandlers) {
        jsi_wsHandlerAdd(interp, cmdPtr, ".jsi",   "Jsi_Jspp",     jsi_wsStrValGet(cmdPtr, "jsi"),   1);
        jsi_wsHandlerAdd(interp, cmdPtr, ".htmli", "Jsi_Htmlpp",   jsi_wsStrValGet(cmdPtr, "htmli"), 1);
        jsi_wsHandlerAdd(interp, cmdPtr, ".cssi",  "Jsi_Csspp",    jsi_wsStrValGet(cmdPtr, "cssi"),  1);
        //jsi_wsHandlerAdd(interp, cmdPtr, ".mdi",   "Jsi_Markdeep", jsi_wsStrValGet(cmdPtr, "mdi"),   1);
        jsi_wsHandlerAdd(interp, cmdPtr, ".mdi",   "Jsi_Markdown",  jsi_wsStrValGet(cmdPtr, "mdi"), 1);
    }
    cmdPtr->fobj = fobj;
#ifdef LWS_LIBRARY_VERSION_NUMBER
    Jsi_JSONParseFmt(interp, &cmdPtr->version, "{libVer:\"%s\", hdrVer:\"%s\", hdrNum:%d, pkgVer:%d}",
        (char *)lws_get_library_version(), LWS_LIBRARY_VERSION, LWS_LIBRARY_VERSION_NUMBER, jsi_WsPkgVersion);
#endif
    return JSI_OK;







|
|
|
|
|







2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788

    Jsi_Obj *fobj = Jsi_ValueGetObj(interp, toacc);
    if ((cmdPtr->objId = Jsi_UserObjNew(interp, &websockobject, fobj, cmdPtr))<0) {
        goto bail;
    }
    cmdPtr->handlers = Jsi_HashNew(interp, JSI_KEYS_STRING, jsi_wsfreeHandlers);
    if (cmdPtr->extHandlers) {
        jsi_wsHandlerAdd(interp, cmdPtr, ".jsi",   "Jspp",     jsi_wsStrValGet(cmdPtr, "jsi"),   1);
        jsi_wsHandlerAdd(interp, cmdPtr, ".htmli", "Htmlpp",   jsi_wsStrValGet(cmdPtr, "htmli"), 1);
        jsi_wsHandlerAdd(interp, cmdPtr, ".cssi",  "Csspp",    jsi_wsStrValGet(cmdPtr, "cssi"),  1);
        //jsi_wsHandlerAdd(interp, cmdPtr, ".mdi",   "Markdeep", jsi_wsStrValGet(cmdPtr, "mdi"),   1);
        jsi_wsHandlerAdd(interp, cmdPtr, ".mdi",   "Markdown",  jsi_wsStrValGet(cmdPtr, "mdi"), 1);
    }
    cmdPtr->fobj = fobj;
#ifdef LWS_LIBRARY_VERSION_NUMBER
    Jsi_JSONParseFmt(interp, &cmdPtr->version, "{libVer:\"%s\", hdrVer:\"%s\", hdrNum:%d, pkgVer:%d}",
        (char *)lws_get_library_version(), LWS_LIBRARY_VERSION, LWS_LIBRARY_VERSION_NUMBER, jsi_WsPkgVersion);
#endif
    return JSI_OK;

Changes to tools/protos.jsi.

1
2
3
4
5
6
7
8
//JSI Command Prototypes: version 2.8.36
throw("NOT EXECUTABLE: USE FILE IN GEANY EDITOR FOR CMD LINE COMPLETION + GOTO TAG");

var Array = function(cmd,args) {};
Array.prototype.concat = function(...):array {};
Array.prototype.every = function(callback:function):any {};
Array.prototype.fill = function(value:any, start:number=0, end:number=-1):array {};
Array.prototype.filter = function(callback:function, this:object=void):array {};
|







1
2
3
4
5
6
7
8
//JSI Command Prototypes: version 2.8.37
throw("NOT EXECUTABLE: USE FILE IN GEANY EDITOR FOR CMD LINE COMPLETION + GOTO TAG");

var Array = function(cmd,args) {};
Array.prototype.concat = function(...):array {};
Array.prototype.every = function(callback:function):any {};
Array.prototype.fill = function(value:any, start:number=0, end:number=-1):array {};
Array.prototype.filter = function(callback:function, this:object=void):array {};

Changes to www/app/websrv.wiki.

29
30
31
32
33
34
35
36

You can find the source for <b>websrv</b> in the <b>jsi/lib</b> subdirectory.
For convenience, here is a link to the [42ce24f6574c88ea|websrv source from jsish 1.0.6].

Although <b>websrv</b> is not actually used by the demo applications [./ledger.wiki|ledger]
and [./sqliteui.wiki|sqliteui], it did serve as the model.

The source: [../lib/Jsi_Websrv.jsi]







|
29
30
31
32
33
34
35
36

You can find the source for <b>websrv</b> in the <b>jsi/lib</b> subdirectory.
For convenience, here is a link to the [42ce24f6574c88ea|websrv source from jsish 1.0.6].

Although <b>websrv</b> is not actually used by the demo applications [./ledger.wiki|ledger]
and [./sqliteui.wiki|sqliteui], it did serve as the model.

The source: [../lib/Websrv.jsi]

Changes to www/debug.wiki.

274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#2==>
</pre></nowiki>

<h3 id=impl>Implementation</h3>

The debugger runs the target script in a [./js-interp.wiki|sub-interpreter].

The source: [../lib/Jsi_Debug.jsi]

Source for the GUI: [../lib/Jsi_DebugUI/Jsi_DebugUI.jsi]

<b>Caveat:</b> Jsi
bends the memory management rules of Sub-interps a bit to make debugging mode work seamlessly,
a side-effect of which is that a small amount of memory may leak 
during the debug session.








|

|






274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#2==>
</pre></nowiki>

<h3 id=impl>Implementation</h3>

The debugger runs the target script in a [./js-interp.wiki|sub-interpreter].

The source: [../lib/Debug.jsi]

Source for the GUI: [../lib/DebugUI/DebugUI.jsi]

<b>Caveat:</b> Jsi
bends the memory management rules of Sub-interps a bit to make debugging mode work seamlessly,
a side-effect of which is that a small amount of memory may leak 
during the debug session.

Changes to www/js-interp.wiki.

109
110
111
112
113
114
115
116
117
118
119
120
121
122
123

    <nowiki><pre class=verbatim>
<b>jsish -S</b> tests/while.js a b c
<b>jsish -S</b> tests/file.js a b c;  <i>// kicks a file access error.</i>
<b>jsish -S</b>         <i>// With no arguments runs the safe interp in interactive mode</i>
</pre></nowiki>

The implemenation is here: [../lib/Jsi_Safe.jsi].
 
<hr>

<h3 id=threads>Thread-Interps</h3>

A sub-interp can be created in a threaded:








|







109
110
111
112
113
114
115
116
117
118
119
120
121
122
123

    <nowiki><pre class=verbatim>
<b>jsish -S</b> tests/while.js a b c
<b>jsish -S</b> tests/file.js a b c;  <i>// kicks a file access error.</i>
<b>jsish -S</b>         <i>// With no arguments runs the safe interp in interactive mode</i>
</pre></nowiki>

The implemenation is here: [../lib/Safe.jsi].
 
<hr>

<h3 id=threads>Thread-Interps</h3>

A sub-interp can be created in a threaded:

Changes to www/markdown.wiki.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<title>Markdown</title>

<b>Markdown</b> provides a wiki-style markup language.
It is available as the <b>markdown </b> subcommand in [./reference.wiki#Util|Util].

Files ending in the suffix ".md" are
supported in [../lib/Jsi_Websrv.jsi].

The [../lib/Jsi_SqliteUI/Jsi_SqliteUI.jsi] application uses markdown.

The markdown code was extraced from <b>fossil</b>.

Here is the [./markdown.md|markdown specification].







|

|





1
2
3
4
5
6
7
8
9
10
11
12
13
14
<title>Markdown</title>

<b>Markdown</b> provides a wiki-style markup language.
It is available as the <b>markdown </b> subcommand in [./reference.wiki#Util|Util].

Files ending in the suffix ".md" are
supported in [../lib/Websrv.jsi].

The [../lib/SqliteUI/SqliteUI.jsi] application uses markdown.

The markdown code was extraced from <b>fossil</b>.

Here is the [./markdown.md|markdown specification].

Changes to www/web.wiki.

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
...
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<tr><td>.jsi</td><td>Javascript</td><td>Translate [./functions.wiki|typed-functions] (for use within browsers)</td><tr>
</table>

Pre-processors are enabled via <b>handlers</b>:

    <nowiki><pre class=verbatim>
<b>var</b> ws = <b>new WebSocket</b>({callback:ws_input});
ws.<b>handler</b>(<i>'.htmli'</i>, <i>'Jsi_Htmlpp'</i>,  null);
ws.<b>handler</b>(<i>'.jsi'</i>,   <i>'Jsi_Jspp'</i>, null);
ws.<b>handler</b>(<i>'.cssi'</i>,  <i>'Jsi_Csspp'</i>,  null);
</pre></nowiki>

The specifics are described below.

<hr>
<h3 id=webpp>HTML Preprocessing</h3>
The HTML preprocessor is triggered by the extension <b>.htmli</b>.
................................................................................


This provides runtime type-checking of function calls.

To debug, we set a breakpoint on warnings which are output
to the console.

The Jsi support functions are included from: <b>/jsi/lib/JSig.js</b>

<hr>
<h2 id=utilities>Utilities</h2>

The following resources are available to include from <b>/jsi/lib/</b>:

  *  [../lib/web/JSig.js|JSig.js]: Support code for type-checking.
  *  [https://github.com/remy/bind.js|bind.js]: Two way binding between data and elements.
  *  [http://zeptojs.com/|zepto.js]: Lite subset of JQuery.







|
|
|







 







|






|


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
...
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<tr><td>.jsi</td><td>Javascript</td><td>Translate [./functions.wiki|typed-functions] (for use within browsers)</td><tr>
</table>

Pre-processors are enabled via <b>handlers</b>:

    <nowiki><pre class=verbatim>
<b>var</b> ws = <b>new WebSocket</b>({callback:ws_input});
ws.<b>handler</b>(<i>'.htmli'</i>, <i>'Htmlpp'</i>,  null);
ws.<b>handler</b>(<i>'.jsi'</i>,   <i>'Jspp'</i>, null);
ws.<b>handler</b>(<i>'.cssi'</i>,  <i>'Csspp'</i>,  null);
</pre></nowiki>

The specifics are described below.

<hr>
<h3 id=webpp>HTML Preprocessing</h3>
The HTML preprocessor is triggered by the extension <b>.htmli</b>.
................................................................................


This provides runtime type-checking of function calls.

To debug, we set a breakpoint on warnings which are output
to the console.

The Jsi support functions are included from: <b>/jsi/lib/jsig.js</b>

<hr>
<h2 id=utilities>Utilities</h2>

The following resources are available to include from <b>/jsi/lib/</b>:

  *  [../lib/web/JSig.js|jsig.js]: Support code for type-checking.
  *  [https://github.com/remy/bind.js|bind.js]: Two way binding between data and elements.
  *  [http://zeptojs.com/|zepto.js]: Lite subset of JQuery.