2 \ #
! /home
/ygrek
/work
/forth
/spf
/spf4
4 REQUIRE ATTACH ~pinka
/samples
/2005/lib
/append
-file
.f
5 REQUIRE USER
-TYPE ~ygrek
/lib
/typestr
.f
6 REQUIRE XHTML ~ygrek
/lib
/xhtml
/core
.f
7 REQUIRE NOT ~profit
/lib
/logic
.f
8 REQUIRE DateTime
>PAD ~ygrek
/lib
/spec
/unixdate
.f
9 REQUIRE FileLines
=> ~ygrek
/lib
/filelines
.f
10 REQUIRE BACKSTRFREE ~ygrek
/lib
/backstr
.f
11 REQUIRE StartAppWait ~ygrek
/lib
/linux
/process
.f
12 REQUIRE content
:html ~ygrek
/lib
/net
/cgi
.f
13 REQUIRE XHTML
-EXTRA ~ygrek
/lib
/xhtml
/extra
.f
19 : <page
> ( `title
-- )
25 << `application
/xhtml
+xml
;charset
=utf
-8 `content
-type http
-equiv
>>
26 << `title tag
( `title
) TYPE
>>
32 : sdiv
( `style
--> \
<-- ) PRO
%[ `style $$
]% `div atag CONT
;
33 : option
( `value `name
-- ) 2SWAP
%[ `value $$
]% `option atag TYPE
;
35 : render
-edit
( a u
-- )
38 S
" float:left; margin: 0 1em 1em 0" sdiv
40 %[ `content `name $$ `
25 `rows $$ `
80 `cols $$
]% `textarea atag
44 << S
" float:left; padding: 0 1em; background-color: #eee; border: 1px solid green" sdiv
45 << `h3 tag S
" Example" TYPE
>>
47 " CREATE TABLE t1 (x INT, name TEXT);
48 CREATE TABLE t2 (y INT, name TEXT);
49 CREATE TABLE t3 (z INT, r INT);
51 SELECT *, y+z AS q FROM t1
54 WHERE x = @val;" STYPE
61 ( << `div tag S
" Output query parameters substitution :" TYPE
63 %[ `params `name $$
]% `select atag
64 `input S
" As is" option
65 `named S
" Only named" option
66 `unnamed S
" Only unnamed" option
72 %[ `gen `name $$
]% `select atag
80 S
" generate code " `button `submit input
84 20 1024 * CONSTANT limit
86 : gen
-param
( `s
-- `s2
)
87 2DUP `caml CEQUAL
IF EXIT
THEN
88 2DUP `xml CEQUAL
IF EXIT
THEN
89 2DUP `java CEQUAL
IF EXIT
THEN
90 2DUP `csharp CEQUAL
IF EXIT
THEN
96 << `h2 tag S
" Input" TYPE
>>
97 DUP limit
> IF DROP limit S
" Input too long, truncated" TYPE CR
THEN
98 << `pre tag
2DUP TYPE
>>
100 (( S
" data_sqlgg" DROP
0x1FF )) mkdir DROP
101 ms@
{ tick | src dst err gen
}
102 `gen GetParam gen
-param
>STR
TO gen
103 tick
" data_sqlgg/{n}.in" -> src
104 tick
" data_sqlgg/{n}.out" -> dst
105 tick
" data_sqlgg/{n}.err" -> err
106 \ src STR@ TYPE CR dst STR@ TYPE CR err STR@ TYPE CR
108 err STR@ dst STR@ src STR@ gen STR@
109 " ./sqlgg.native -gen {s} {s} > {s} 2> {s}" STR@ StartAppWait DROP
111 << `h2 tag S
" Output" TYPE
>>
114 err STR@ FILE DUP
0= IF 2DROP EXIT
THEN
115 << `h2 tag S
" Errors" TYPE
>>
122 S
" Input SQL statements terminated with semicolon (;) each. " TYPE
123 S
" Use ? or @name for binding slots" TYPE
128 S
" SQL Guided (code) generator" 2DUP
<page
>
129 << `h1 tag `
/p
/sqlgg
/ link
-text
>>
130 `content GetParam DUP
0= IF 2DROP ask
-input
ELSE process
THEN
131 \ S
" CREATE TABLE x (z INT);" process
137 : env ENVIRONMENT? NOT
IF S
" " THEN ;
145 TIME
&DATE DateTime
>PAD TYPE TAB
146 `REMOTE_ADDR env TYPE TAB
147 `REQUEST_METHOD env TYPE TAB
148 `SCRIPT_NAME env TYPE SPACE
149 `QUERY_STRING env TYPE TAB
150 `HTTP_USER_AGENT env TYPE
151 } TYPE
>STR BACKSTRFREE STR@ `request
.log ATTACH
-LINE
-CATCH DROP
;
155 \ S
" Cache-Control: no-cache" TYPE CR
166 ['] content TYPE>STR DUP STRLEN content-length
173 \ : index headers CR content ;
175 \ : REQUEST_METHOD S" GET" ;
176 \ : QUERY_STRING S" page_name=MainPage" ;
178 \ ' TYPE1
TO USER
-TYPE
183 `sqlgg.cgi.o DELETE-FILE DROP
184 `sqlgg.cgi.ld DELETE-FILE DROP