Wapp

Check-in [55e40e4c93]
Login

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

Overview
Comment:Add a Makefile and code to generate the stand-alone "wapptclsh" binary.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 55e40e4c9331f2aa8ece7883008fa92a284c523f0854fbe0a42fa5d377d5aba2
User & Date: drh 2017-12-15 21:43:02.212
Context
2017-12-15
21:44
Add a "clean" target to the Makefile, and optimize for size. (check-in: b9b69d4d68 user: drh tags: trunk)
21:43
Add a Makefile and code to generate the stand-alone "wapptclsh" binary. (check-in: 55e40e4c93 user: drh tags: trunk)
2017-12-13
17:28
Typo fix in the README.md (check-in: 0d5698a0e2 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Added Makefile.




























>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/make

CC = gcc -O0 -static
TCLLIB = /home/drh/tcl/lib/libtcl8.6.a -lm -lz -lpthread -ldl
TCLINC = /home/drh/tcl/include
TCLSH = tclsh

all: wapptclsh

wapptclsh: wapptclsh.c
	$(CC) -I. -I$(TCLINC) -o $@ wapptclsh.c $(TCLLIB)

wapptclsh.c:	wapptclsh.c.in wapp.tcl wapptclsh.tcl tclsqlite3.c mkccode.tcl
	$(TCLSH) mkccode.tcl wapptclsh.c.in >$@
Added tclsqlite3.c.

more than 10,000 changes

Added wapptclsh.c.in.
















































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
55
56
/*
** A TCLSH that reads itself as its initialization script.  This is
** intended for use as CGI.  The CGI script should look like:
**
**      #/usr/bin/cgitclsh
**      #
**      proc wapp-default {} {
**        wapp "<h1>Hello, World!</h1>\n"
**      }
**      wapp-default -cgi
**
*/
#define SQLITE_THREADSAFE 0
#undef SQLITE_ENABLE_COLUMN_METADATA
#define SQLITE_OMIT_DECLTYPE 1
#define SQLITE_OMIT_DEPRECATED 1
#define SQLITE_OMIT_PROGRESS_CALLBACK 1
#define SQLITE_OMIT_SHARED_CACHE 1
#define SQLITE_DEFAULT_MEMSTATUS 0
#define SQLITE_MAX_EXPR_DEPTH 0
#define SQLITE_OMIT_LOAD_EXTENSION 1
#define SQLITE_ENABLE_FTS4 1
#define SQLITE_ENABLE_FTS5 1
#define SQLITE_ENABLE_RTREE 1
#define TCLSH_INIT_PROC wapptclsh_init_proc
INCLUDE tclsqlite3.c

/* The wapp.tcl script contains the useful web-application interface
** procedures.  After loading this script, "package require wapp" becomes
** a no-op
*/
static const char zWapp[] = 
BEGIN_STRING
INCLUDE $ROOT/wapp.tcl
END_STRING
;

/* This script runs to figure out what the main script should be.  It
** loads the main script into a TCL variable named "main_script".  Or,
** if an interactive shell is desired, "main_script" is unset.
*/
static const char zWappTclshInit[] = 
BEGIN_STRING
INCLUDE $ROOT/wapptclsh.tcl
END_STRING
;

/*
** Return the text of the script to run.  Or, return NULL to run an
** interactive shell.
*/
const char *wapptclsh_init_proc(Tcl_Interp *interp){
  Tcl_GlobalEval(interp, zWapp);  /* Load the wapp.tcl extension */
  Tcl_GlobalEval(interp, zWappTclshInit); /* Load the main loop script */
  return Tcl_GetVar(interp, "main_script", TCL_GLOBAL_ONLY);
}
Added wapptclsh.tcl.




























>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# This script runs to initialize wapptclsh.
#
proc initialize_wapptclsh {} {
  global argv main_script
  if {[llength $argv]==0} return
  set script [lindex $argv 0]
  if {[file readable $script]} {
    set fd [open $script rb]
    set main_script [read $fd]
    close $fd
    set argv [lrange $argv 1 end]
  }
}
initialize_wapptclsh