diff --git a/doc/fbc.1 b/doc/fbc.1
index 743d6edc75..13e88e908e 100644
--- a/doc/fbc.1
+++ b/doc/fbc.1
@@ -1,4 +1,4 @@
-.TH FBC 1 "2019-01-01" "FreeBASIC Compiler 1.07.0" "FreeBASIC Compiler"
+.TH FBC 1 "2019-05-20" "FreeBASIC Compiler 1.07.0" "FreeBASIC Compiler"
.SH NAME
fbc \- The FreeBASIC compiler
.SH DESCRIPTION
@@ -102,6 +102,9 @@ Do not include the default libraries
\fB\-noerrline\fR
Do not show source context in error messages
.TP
+\fB\-nostrip\fR
+Do not strip symbol information from the output file
+.TP
\fB\-o\fR \fIfile\fR
Set .o file name for corresponding input .bas
.TP
@@ -147,6 +150,9 @@ Select win32 subsystem
\fB\-static\fR
Prefer static libraries over dynamic ones when linking
.TP
+\fB\-strip\fR
+Omit all symbol information from the output file
+.TP
\fB\-t\fR \fIvalue\fR
Set Win32/DOS .exe stack size in kbytes, default: 1024
.TP
diff --git a/doc/fbchkdoc/chkdocs.bas b/doc/fbchkdoc/chkdocs.bas
index d6c350ddc9..30ae553823 100644
--- a/doc/fbchkdoc/chkdocs.bas
+++ b/doc/fbchkdoc/chkdocs.bas
@@ -2226,7 +2226,8 @@ if( app_opt.help ) then
end if
cmd_opts_resolve()
-cmd_opts_check()
+cmd_opts_check_cache()
+cmd_opts_check_url()
if( (opt and OPT_ALL) = 0 ) then
print "No options specified"
diff --git a/doc/fbchkdoc/cmd_opts.bas b/doc/fbchkdoc/cmd_opts.bas
index 8935c8021f..5885eda271 100644
--- a/doc/fbchkdoc/cmd_opts.bas
+++ b/doc/fbchkdoc/cmd_opts.bas
@@ -55,6 +55,7 @@ type CMD_OPTS_PRIVATE
enable_autocache as boolean '' automatically select a cache if none given on the command line
enable_pagelist as boolean '' enable reading in a text file with a list of page names
enable_manual as boolean '' enable the manual dir option
+ enable_database as boolean '' enable db_* options
print as boolean '' -printopts option on command line
@@ -89,6 +90,21 @@ type CMD_OPTS_PRIVATE
manual as boolean '' -manual_dir given on command line
manual_dir as string '' value of '-manual_dir DIR' given on command line
+ db_host_is_set as boolean '' -db_host given on command line
+ db_host as string '' value of '-db_host TEXT' given on command line
+
+ db_user_is_set as boolean '' -db_user given on command line
+ db_user as string '' value of '-db_user TEXT' given on command line
+
+ db_pass_is_set as boolean '' -db_pass given on command line
+ db_pass as string '' value of '-db_pass TEXT' given on command line
+
+ db_name_is_set as boolean '' -db_name given on command line
+ db_name as string '' value of '-db_name TEXT' given on command line
+
+ db_port_is_set as boolean '' -db_port given on command line
+ db_port as integer '' value of '-db_port NUMBER' given on command line
+
end type
dim shared cmd_opt as CMD_OPTS_PRIVATE
@@ -107,6 +123,7 @@ sub cmd_opts_init( byval opts_flags as const CMD_OPTS_ENABLE_FLAGS )
cmd_opt.enable_autocache = cbool( opts_flags and CMD_OPTS_ENABLE_AUTOCACHE )
cmd_opt.enable_pagelist = cbool( opts_flags and CMD_OPTS_ENABLE_PAGELIST )
cmd_opt.enable_manual = cbool( opts_flags and CMD_OPTS_ENABLE_MANUAL )
+ cmd_opt.enable_database = cbool( opts_flags and CMD_OPTS_ENABLE_DATABASE )
'' general options
@@ -132,6 +149,23 @@ sub cmd_opts_init( byval opts_flags as const CMD_OPTS_ENABLE_FLAGS )
cmd_opt.ca = false '' -certificate given on command line
cmd_opt.ca_file = "" '' value of '-certificate FILE' given on command line
+ '' database options
+
+ cmd_opt.db_host_is_set = false '' -db_host given on command line
+ cmd_opt.db_host = "" '' value of '-db_host TEXT' given on command line
+
+ cmd_opt.db_user_is_set = false '' -db_user given on command line
+ cmd_opt.db_user = "" '' value of '-db_user TEXT' given on command line
+
+ cmd_opt.db_pass_is_set = false '' -db_pass given on command line
+ cmd_opt.db_pass = "" '' value of '-db_pass TEXT' given on command line
+
+ cmd_opt.db_name_is_set = false '' -db_name given on command line
+ cmd_opt.db_name = "" '' value of '-db_name TEXT' given on command line
+
+ cmd_opt.db_port_is_set = false '' -db_port given on command line
+ cmd_opt.db_port = 0 '' value of '-db_port NUMBER' given on command line
+
'' login options
cmd_opt.user = false '' -u given on command line
@@ -146,6 +180,8 @@ sub cmd_opts_init( byval opts_flags as const CMD_OPTS_ENABLE_FLAGS )
cmd_opt.manual = false '' -manual_dir given on command line
cmd_opt.manual_dir = "" '' value of '-manual_dir DIR' given on command line
+ cmd_opt.db_user_is_set = false
+
'' resolved options
app_opt.wiki_url = "" '' export: resolved wiki url
@@ -156,9 +192,15 @@ sub cmd_opts_init( byval opts_flags as const CMD_OPTS_ENABLE_FLAGS )
app_opt.image_dir = "" '' export: image directory
app_opt.manual_dir = "" '' export: manual directory
- app_opt.webPageCount = 0
- redim app_opt.webPageList(1 to 1) as string
- redim app_opt.webPageComments(1 to 1) as string
+ app_opt.db_host = "" '' export: database host name
+ app_opt.db_user = "" '' export: database user name
+ app_opt.db_pass = "" '' export: database user password
+ app_opt.db_name = "" '' export: database name
+ app_opt.db_port = 0 '' export: database port number
+
+ app_opt.pageCount = 0
+ redim app_opt.pageList(1 to 1) as string
+ redim app_opt.pageComments(1 to 1) as string
if( command(1) = "" ) then
app_opt.help = true
@@ -188,15 +230,15 @@ sub cmd_opts_unexpected_die( byval i as const integer )
end sub
''
-sub cmd_opts_add_webpage( byref pagename as const string, byref cmt as const string )
+sub cmd_opts_add_page( byref pagename as const string, byref cmt as const string )
with app_opt
- .webPageCount += 1
- if( .webPageCount > ubound(.webPageList) ) then
- redim preserve .webPageList(1 to Ubound(.webPageList) * 2)
- redim preserve .webPageComments(1 to Ubound(.webPageComments) * 2)
+ .pageCount += 1
+ if( .pageCount > ubound(.pageList) ) then
+ redim preserve .pageList(1 to Ubound(.pageList) * 2)
+ redim preserve .pageComments(1 to Ubound(.pageComments) * 2)
end if
- .webPageList(.webPageCount) = pagename
- .webPageComments(.webPageCount) = cmt
+ .pageList(.pageCount) = pagename
+ .pageComments(.pageCount) = cmt
end with
end sub
@@ -350,6 +392,81 @@ function cmd_opts_read( byref i as integer ) as boolean
return false
end if
+ case "-db_host"
+
+ if( cmd_opt.enable_database ) then
+
+ if( cmd_opt.db_host_is_set ) then
+ cmd_opts_duplicate_die( i )
+ end if
+ cmd_opt.db_host_is_set = true
+ i += 1
+ cmd_opt.db_host = command(i)
+
+ else
+ return false
+ end if
+
+ case "-db_user"
+
+ if( cmd_opt.enable_database ) then
+
+ if( cmd_opt.db_user_is_set ) then
+ cmd_opts_duplicate_die( i )
+ end if
+ cmd_opt.db_user_is_set = true
+ i += 1
+ cmd_opt.db_user = command(i)
+
+ else
+ return false
+ end if
+
+ case "-db_pass"
+
+ if( cmd_opt.enable_database ) then
+
+ if( cmd_opt.db_pass_is_set ) then
+ cmd_opts_duplicate_die( i )
+ end if
+ cmd_opt.db_pass_is_set = true
+ i += 1
+ cmd_opt.db_pass = command(i)
+
+ else
+ return false
+ end if
+
+ case "-db_name"
+
+ if( cmd_opt.enable_database ) then
+
+ if( cmd_opt.db_name_is_set ) then
+ cmd_opts_duplicate_die( i )
+ end if
+ cmd_opt.db_name_is_set = true
+ i += 1
+ cmd_opt.db_name = command(i)
+
+ else
+ return false
+ end if
+
+ case "-db_port"
+
+ if( cmd_opt.enable_database ) then
+
+ if( cmd_opt.db_port_is_set ) then
+ cmd_opts_duplicate_die( i )
+ end if
+ cmd_opt.db_port_is_set = true
+ i += 1
+ cmd_opt.db_port = cint( command(i) )
+
+ else
+ return false
+ end if
+
case "-ini"
if( cmd_opt.ini ) then
cmd_opts_duplicate_die( i )
@@ -375,14 +492,14 @@ function cmd_opts_read( byref i as integer ) as boolean
line input #h, x
x = ParsePageName( x, cmt )
if( x > "" ) then
- cmd_opts_add_webpage( x, cmt )
+ cmd_opts_add_page( x, cmt )
end if
wend
close #h
end if
end scope
else
- cmd_opts_add_webpage( command(i), "" )
+ cmd_opts_add_page( command(i), "" )
end if
else
@@ -421,6 +538,11 @@ function cmd_opts_resolve() as boolean
dim as string dev_pass = ""
dim as string def_image_dir = hardcoded.default_image_dir
dim as string def_manual_dir = hardcoded.default_manual_dir
+ dim as string db_host = ""
+ dim as string db_user = ""
+ dim as string db_pass = ""
+ dim as string db_name = ""
+ dim as integer db_port = 3306
'' -ini FILE on the command line overrides the hardcoded value
if( cmd_opt.ini ) then
@@ -445,6 +567,11 @@ function cmd_opts_resolve() as boolean
dev_pass = opts->Get( "dev_password" )
def_image_dir = opts->Get( "image_dir" )
def_manual_dir = opts->Get( "manual_dir" )
+ db_host = opts->Get( "db_host" )
+ db_user = opts->Get( "db_user" )
+ db_pass = opts->Get( "db_pass" )
+ db_name = opts->Get( "db_name" )
+ db_port = cint( opts->Get( "db_port" ) )
delete opts
elseif( cmd_opt.ini ) then
'' if we explicitly gave the -ini FILE option, report the error
@@ -513,6 +640,36 @@ function cmd_opts_resolve() as boolean
app_opt.manual_dir = def_manual_dir
end if
+ if( cmd_opt.db_host_is_set ) then
+ app_opt.db_host = cmd_opt.db_host
+ else
+ app_opt.db_host = db_host
+ end if
+
+ if( cmd_opt.db_user_is_set ) then
+ app_opt.db_user = cmd_opt.db_user
+ else
+ app_opt.db_user = db_user
+ end if
+
+ if( cmd_opt.db_pass_is_set ) then
+ app_opt.db_pass = cmd_opt.db_pass
+ else
+ app_opt.db_pass = db_pass
+ end if
+
+ if( cmd_opt.db_name_is_set ) then
+ app_opt.db_name = cmd_opt.db_name
+ else
+ app_opt.db_name = db_name
+ end if
+
+ if( cmd_opt.db_port_is_set ) then
+ app_opt.db_port = cmd_opt.db_port
+ else
+ app_opt.db_port = db_port
+ end if
+
if( cmd_opt.print ) then
print "ini_file = " & ini_file
@@ -537,6 +694,11 @@ function cmd_opts_resolve() as boolean
print "wiki_password = " & "*****"
print "image_dir = " & app_opt.image_dir
print "manual_dir = " & app_opt.manual_dir
+ print "db_host = " & app_opt.db_host
+ print "db_user = " & app_opt.db_user
+ print "db_pass = " & app_opt.db_pass
+ print "db_name = " & app_opt.db_name
+ print "db_port = " & app_opt.db_port
print
end 1
@@ -548,7 +710,7 @@ function cmd_opts_resolve() as boolean
end function
''
-function cmd_opts_check() as boolean
+function cmd_opts_check_cache() as boolean
if( cmd_opt.enable_cache ) then
'' check that we have the values we need
@@ -557,6 +719,13 @@ function cmd_opts_check() as boolean
end if
end if
+ function = true
+
+end function
+
+''
+function cmd_opts_check_url() as boolean
+
if( cmd_opt.enable_url ) then
if( app_opt.wiki_url = "" ) then
cmd_opts_die( "no url specified" )
@@ -567,6 +736,28 @@ function cmd_opts_check() as boolean
end function
+''
+function cmd_opts_check_database() as boolean
+
+ if( cmd_opt.enable_database ) then
+ '' check that we have the values we need
+ if( app_opt.db_host = "" ) then
+ cmd_opts_die( "no database host specified" )
+ elseif( app_opt.db_user = "" ) then
+ cmd_opts_die( "no database user login name specified" )
+ elseif( app_opt.db_pass = "" ) then
+ cmd_opts_die( "no database user login password specified" )
+ elseif( app_opt.db_name = "" ) then
+ cmd_opts_die( "no database name specified" )
+ elseif( app_opt.db_port = 0 ) then
+ cmd_opts_die( "no database port specified" )
+ end if
+ end if
+
+ function = true
+
+end function
+
''
sub cmd_opts_show_help_item _
( _
@@ -655,5 +846,12 @@ sub cmd_opts_show_help( byref action as const string = "", locations as boolean
print " -manual_dir DIR override the manual directory location"
end if
+ if( cmd_opt.enable_database ) then
+ print " -db_host database host name"
+ print " -db_user database user login name"
+ print " -db_pass database user login password"
+ print " -db_name database name"
+ print " -db_port database port number"
+ end if
-end sub
\ No newline at end of file
+end sub
diff --git a/doc/fbchkdoc/cmd_opts.bi b/doc/fbchkdoc/cmd_opts.bi
index 35b2968517..ee2b92530a 100644
--- a/doc/fbchkdoc/cmd_opts.bi
+++ b/doc/fbchkdoc/cmd_opts.bi
@@ -27,6 +27,7 @@ enum CMD_OPTS_ENABLE_FLAGS
CMD_OPTS_ENABLE_IMAGE = 8
CMD_OPTS_ENABLE_PAGELIST = 16
CMD_OPTS_ENABLE_MANUAL = 32
+ CMD_OPTS_ENABLE_DATABASE = 64
CMD_OPTS_ENABLE_AUTOCACHE = &h1000
@@ -38,7 +39,9 @@ declare sub cmd_opts_unrecognized_die( byval i as const integer )
declare sub cmd_opts_unexpected_die( byval i as const integer )
declare function cmd_opts_read( byref i as integer ) as boolean
declare function cmd_opts_resolve() as boolean
-declare function cmd_opts_check() as boolean
+declare function cmd_opts_check_cache() as boolean
+declare function cmd_opts_check_url() as boolean
+declare function cmd_opts_check_database() as boolean
declare sub cmd_opts_show_help( byref action as const string = "", byval locations as boolean = true )
declare sub cmd_opts_show_help_item( byref opt_name as const string, byref opt_desc as const string )
@@ -56,10 +59,15 @@ type CMD_OPTS_GLOBAL
wiki_password as string
image_dir as string
manual_dir as string
+ db_host as string
+ db_user as string
+ db_pass as string
+ db_name as string
+ db_port as integer
- webPageCount as integer
- webPageList(any) as string
- webPageComments(any) as string
+ pageCount as integer
+ pageList(any) as string
+ pageComments(any) as string
end type
diff --git a/doc/fbchkdoc/delextra.bas b/doc/fbchkdoc/delextra.bas
index 2763f52a4d..9b5c67df41 100644
--- a/doc/fbchkdoc/delextra.bas
+++ b/doc/fbchkdoc/delextra.bas
@@ -199,7 +199,8 @@ if( app_opt.help ) then
end if
cmd_opts_resolve()
-cmd_opts_check()
+cmd_opts_check_cache()
+cmd_opts_check_url()
'' --------------------------------------------------------
diff --git a/doc/fbchkdoc/getimage.bas b/doc/fbchkdoc/getimage.bas
index 8f725efd29..2d7b73f330 100644
--- a/doc/fbchkdoc/getimage.bas
+++ b/doc/fbchkdoc/getimage.bas
@@ -165,7 +165,8 @@ if( app_opt.help ) then
end if
cmd_opts_resolve()
-cmd_opts_check()
+cmd_opts_check_cache()
+cmd_opts_check_url()
'' --------------------------------------------------------
diff --git a/doc/fbchkdoc/getindex.bas b/doc/fbchkdoc/getindex.bas
index 485759a4e0..84cbc05c30 100644
--- a/doc/fbchkdoc/getindex.bas
+++ b/doc/fbchkdoc/getindex.bas
@@ -20,7 +20,12 @@
'' chng: written [jeffm]
'' fbdoc headers
-#include once "CWikiCon.bi"
+#include once "CWikiConUrl.bi"
+#include once "CWikiConDir.bi"
+
+#if defined(HAVE_MYSQL)
+#include once "CWikiConSql.bi"
+#endif
'' fbchkdoc headers
#include once "fbchkdoc.bi"
@@ -34,216 +39,23 @@
using fb
using fbdoc
-#include "crt/stdlib.bi"
-#include "crt/string.bi"
const def_index_file = hardcoded.default_index_file
-'' temporary files
-const def_html_file = "PageIndex.html"
-const def_text_file = "PageIndex0.txt"
-
-'' --------------------------------------------------------
-
-''
-sub RemoveHTMLtags _
- ( _
- byref sBody as string _
- )
-
- '' remove HTML tags
-
- dim as string txt, html
- dim as integer n, b = 0, j = 1, atag = 0, i
- n = len(sBody)
- txt = ""
-
- print "Removing html tags"
- while( i <= n )
-
- if( lcase(mid( sBody, i, 4 )) = "<" ) then
- txt += "<"
- i += 4
- elseif( lcase(mid( sBody, i, 4 )) = ">" ) then
- txt += ">"
- i += 4
- elseif( lcase(mid( sBody, i, 5 )) = "&" ) then
- txt += "&"
- i += 5
- elseif( lcase(mid( sBody, i, 6 )) = " " ) then
- txt += " "
- i += 6
- elseif( mid( sBody, i, 4 ) = "All<" and atag = 1 ) then
- txt += "All" + crlf + "----" + crlf
- i += 3
- elseif( mid( sBody, i, 5 ) = "All <" and atag = 1 ) then
- txt += "All " + crlf + "----" + crlf
- i += 3
- elseif( lcase(mid( sBody, i, 1 )) = "<" ) then
- atag = 0
- b = 1
- j = i + 1
- while( j <= n and b > 0 )
- select case ( mid( sBody, j, 1 ))
- case "<"
- b += 1
- j += 1
- case ">"
- b -= 1
- j += 1
- case chr(34)
- j += 1
- while( j <= n )
- select case ( mid( sBody, j, 1 ))
- case chr(34)
- j += 1
- exit while
- case else
- j += 1
- end select
- wend
- case else
- j += 1
- end select
- wend
-
- html = mid( sBody, i, j - i )
- select case lcase( html )
- case " "," "
- txt += crlf
- case "
"," "
- txt += "----"
- case else
- if left( html, 3 ) = " 2 ) then
- for i = 1 to len(x)
- select case mid(x,i,1)
- case "A" to "Z", "a" to "z", "0" to "9", "_"
- case else
- exit for
- end select
- next
- if i > 1 then
- print #h2, left(x, i - 1)
- end if
- end if
- else
- if x = "----" then
- b = 1
- end if
- end if
- wend
- close #h2
- close #h1
-
- kill def_text_file
-
-end sub
-
-#ifdef __FB_LINUX__
-extern "c"
- declare function strcasecmp(byval as const zstring ptr, byval as const zstring ptr) as long
-end extern
-#define _stricmp strcasecmp
-#endif
-
-''
-function cmpPageName cdecl ( byval x as any ptr, byval y as any ptr ) as long
- function = _stricmp( *cast(zstring ptr ptr,x), *cast(zstring ptr ptr,y) )
-end function
-
-''
-sub ScanCacheDir _
- ( _
- byref p as string _
- )
-
- dim as string d, pages(1 to 2000)
- dim as integer i, h, n = 0
- dim as zstring ptr zpage(1 to 2000)
-
- d = dir( p & "*.wakka" )
- while( d > "" )
- i = instrrev( d, "." )
- if( i > 0 ) then
- d = left( d, i-1 )
- if( len(d) > 0 ) then
- n += 1
- pages(n) = d
- zpage(n) = strptr(pages(n))
- end if
- end if
- d = dir( )
- wend
-
- '' Sort
- qsort( @zpage(1), n, sizeof(zstring ptr), procptr(cmpPageName) )
-
- h = freefile
- open def_index_file for output as #h
- for i = 1 to n
- print #h, *zpage(i)
- next
- close #h
-
-end sub
-
'' --------------------------------------------------------
'' MAIN
'' --------------------------------------------------------
'' private options
-dim as boolean blocal = false '' -local given on command line
+dim as boolean bLocal = false '' -local given on command line
+dim as boolean bUseSql = false '' -usesql given on command line
'' enable url and cache
+#if defined(HAVE_MYSQL)
+cmd_opts_init( CMD_OPTS_ENABLE_URL or CMD_OPTS_ENABLE_CACHE or CMD_OPTS_ENABLE_DATABASE )
+#else
cmd_opts_init( CMD_OPTS_ENABLE_URL or CMD_OPTS_ENABLE_CACHE )
+#endif
dim i as integer = 1
while( command(i) > "" )
@@ -252,7 +64,11 @@ while( command(i) > "" )
elseif( left( command(i), 1 ) = "-" ) then
select case lcase(command(i))
case "-local"
- blocal = TRUE
+ bLocal = TRUE
+#if defined(HAVE_MYSQL)
+ case "-usesql"
+ bUseSql = TRUE
+#endif
case else
cmd_opts_unrecognized_die( i )
end select
@@ -274,6 +90,9 @@ if( app_opt.help ) then
print "options:"
print " -local use local cache only, don't query server, just"
print " read the cache dir to get the list of page names"
+#if defined(HAVE_MYSQL)
+ print " -usesql use MySQL connection to read index"
+#endif
print
print "if -local is specified, then just read the file names from the cache:"
print " -web get page names from cache_dir"
@@ -287,7 +106,6 @@ if( app_opt.help ) then
end if
cmd_opts_resolve()
-cmd_opts_check()
'' --------------------------------------------------------
@@ -296,56 +114,78 @@ dim sBody as string
sPage = "PageIndex"
-if( blocal ) then
+dim as CWikiCon ptr wikicon = NULL
+
+'' connect to the wiki and get PageIndex (list of all pages)
+
+if( bLocal ) then
+
+ cmd_opts_check_cache()
- ScanCacheDir( app_opt.cache_dir )
+ wikicon = new CWikiConDir( app_opt.cache_dir )
+ if wikicon = NULL then
+ print "Unable to create connection " + app_opt.cache_dir
+ end 1
+ end if
+
+ print "cache: "; app_opt.cache_dir
+
+#if defined(HAVE_MYSQL)
+elseif( bUseSql ) then
+
+ cmd_opts_check_database()
+
+ wikicon = new CWikiConSql( app_opt.db_host, app_opt.db_user, app_opt.db_pass, app_opt.db_name, app_opt.db_port )
+ if wikicon = NULL then
+ print "Unable to create connection " + app_opt.cache_dir
+ end 1
+ end if
+
+ dim as CWikiConSql ptr o = cast( CWikiConSql ptr, wikicon )
+ if( o->Connect() = FALSE ) then
+ print "Error"
+ end 1
+ end if
+#endif
else
+ cmd_opts_check_url()
if( len( app_opt.wiki_url ) = 0 ) then
print "wiki_url not set. use -url, -web, -web+, -dev, or -dev+"
end 1
end if
- '' connect to the wiki and get PageIndex as HTML
- scope
- dim as CWikiCon ptr wikicon = NULL
-
- wikicon = new CWikiCon( app_opt.wiki_url, app_opt.ca_file )
- if wikicon = NULL then
- print "Unable to create connection " + app_opt.wiki_url
- end 1
- end if
-
- print "URL: "; app_opt.wiki_url
-
- if( app_opt.ca_file > "" ) then
- print "Certificate: "; app_opt.ca_file
- else
- print "Certificate: none"
- end if
-
- print "Loading '" + sPage + "': ";
- if( wikicon->LoadPage( sPage, FALSE, FALSE, sBody ) = FALSE ) then
- print "Error"
- else
- print "OK"
- /'
- '' DEBUG
- dim as integer h = freefile
- open def_html_file for output as #h
- print #h, sBody
- close #h
- '/
- end if
-
- delete wikicon
- end scope
-
- RemoveHTMLtags( sBody )
-
- ExtractPageNames( )
+ print "URL: "; app_opt.wiki_url
+
+ wikicon = new CWikiConUrl( app_opt.wiki_url, app_opt.ca_file )
+ if wikicon = NULL then
+ print "Unable to create connection " + app_opt.wiki_url
+ end 1
+ end if
+
+ if( app_opt.ca_file > "" ) then
+ print "Certificate: "; app_opt.ca_file
+ else
+ print "Certificate: none"
+ end if
end if
+print "Loading '" + sPage + "': ";
+if( wikicon->LoadIndex( sPage, sBody ) = FALSE ) then
+ print "Error"
+else
+ print "OK"
+ print "Writing '" & def_index_file & "'"
+
+ dim as integer h = freefile
+ open def_index_file for output as #h
+ print #h, sBody;
+ close #h
+
+end if
+
+delete wikicon
+
print "Done."
diff --git a/doc/fbchkdoc/getpage.bas b/doc/fbchkdoc/getpage.bas
index 80a37e4c27..23ca152d7a 100644
--- a/doc/fbchkdoc/getpage.bas
+++ b/doc/fbchkdoc/getpage.bas
@@ -24,6 +24,10 @@
#include once "fbdoc_loader.bi"
#include once "fbdoc_loader_web.bi"
+#if defined(HAVE_MYSQL)
+#include once "CWikiConSql.bi"
+#endif
+
'' fbchkdoc headers
#include once "fbchkdoc.bi"
#include once "funcs.bi"
@@ -42,9 +46,14 @@ using fbdoc
'' private options
dim allow_retry as boolean = true
+dim as boolean bUseSql = false '' -usesql given on command line
'' enable url and cache
+#if defined(HAVE_MYSQL)
+cmd_opts_init( CMD_OPTS_ENABLE_URL or CMD_OPTS_ENABLE_CACHE or CMD_OPTS_ENABLE_PAGELIST or CMD_OPTS_ENABLE_DATABASE )
+#else
cmd_opts_init( CMD_OPTS_ENABLE_URL or CMD_OPTS_ENABLE_CACHE or CMD_OPTS_ENABLE_PAGELIST )
+#endif
dim i as integer = 1
while( command(i) > "" )
@@ -54,6 +63,10 @@ while( command(i) > "" )
select case lcase(command(i))
case "-auto"
allow_retry = false
+#if defined(HAVE_MYSQL)
+ case "-usesql"
+ bUseSql = true
+#endif
case else
cmd_opts_unrecognized_die( i )
end select
@@ -73,15 +86,26 @@ if( app_opt.help ) then
print " -dev+ get pages from the development server in to dev_cache_dir"
print
cmd_opts_show_help( "get page from", false )
+#if defined(HAVE_MYSQL)
+ print " -usesql use MySQL connection to read index"
+#endif
print
end 1
end if
cmd_opts_resolve()
-cmd_opts_check()
+cmd_opts_check_cache()
+cmd_opts_check_url()
+if( len( app_opt.wiki_url ) = 0 ) then
+ print "wiki_url not set. use -url, -web, -web+, -dev, or -dev+"
+ end 1
+end if
+if( bUseSql ) then
+ cmd_opts_check_database()
+end if
'' no pages? nothing to do...
-if( app_opt.webPageCount = 0 ) then
+if( app_opt.pageCount = 0 ) then
print "no pages specified."
end 1
end if
@@ -94,43 +118,76 @@ redim failedpages(1 to 1) as string
'' main loop - has option to retry/list failed pages
do
+ dim as CWikiCon ptr wikicon = NULL
+
'' Initialize the cache
if LocalCache_Create( app_opt.cache_dir, CWikiCache.CACHE_REFRESH_ALL ) = FALSE then
print "Unable to use local cache dir " + app_opt.cache_dir
end 1
end if
- '' Initialize the wiki connection
- Connection_SetUrl( app_opt.wiki_url, app_opt.ca_file )
-
- print "URL: "; app_opt.wiki_url
- if( app_opt.ca_file > "" ) then
- print "Certificate: "; app_opt.ca_file
+ if( bUseSql ) then
+#if defined(HAVE_MYSQL)
+ cmd_opts_check_database()
+
+ wikicon = new CWikiConSql( app_opt.db_host, app_opt.db_user, app_opt.db_pass, app_opt.db_name, app_opt.db_port )
+ if wikicon = NULL then
+ print "Unable to create connection " + app_opt.cache_dir
+ end 1
+ end if
+
+ dim as CWikiConSql ptr o = cast( CWikiConSql ptr, wikicon )
+ if( o->Connect() = FALSE ) then
+ print "Error"
+ end 1
+ end if
+#endif
else
- print "Certificate: none"
+ print "URL: "; app_opt.wiki_url
+
+ wikicon = new CWikiConUrl( app_opt.wiki_url, app_opt.ca_file )
+ if wikicon = NULL then
+ print "Unable to create connection " + app_opt.wiki_url
+ end 1
+ end if
+
+ if( app_opt.ca_file > "" ) then
+ print "Certificate: "; app_opt.ca_file
+ else
+ print "Certificate: none"
+ end if
+
+ print "cache: "; app_opt.cache_dir
end if
- print "cache: "; app_opt.cache_dir
nfailedpages = 0
- if( app_opt.webPageCount > 0 ) then
+ if( app_opt.pageCount > 0 ) then
dim as integer i, j
dim as string ret
- for i = 1 to app_opt.webPageCount
- ret = LoadPage( app_opt.webPageList(i), FALSE, TRUE )
- if( ret = "" ) then
- print "Failed to load '" & app_opt.webPageList(i) & "'"
+ for i = 1 to app_opt.pageCount
+ dim sBody as string = ""
+ print "Loading '" + app_opt.pageList(i) + "'"
+ if( wikicon->LoadPage( app_opt.pageList(i), sBody ) = FALSE ) then
+ print "Failed to load '" & app_opt.pageList(i) & "'"
nfailedpages += 1
redim preserve failedpages( 1 to nfailedpages )
- failedpages(nfailedpages) = app_opt.webPageList(i)
+ failedpages(nfailedpages) = app_opt.pageList(i)
+ else
+ if( wikicon->GetPageID() > 0 ) then
+ if( len(sBody) > 0 ) then
+ dim as CWikiCache ptr wikicache = LocalCache_Get()
+ wikicache->SavePage( app_opt.pageList(i), sBody )
+ end if
+ end if
end if
if( inkey = chr(27) ) then
- for j = i + 1 to app_opt.webPageCount
+ for j = i + 1 to app_opt.pageCount
nfailedpages += 1
redim preserve failedpages( 1 to nfailedpages )
- failedpages(nfailedpages) = app_opt.webPageList(j)
+ failedpages(nfailedpages) = app_opt.pageList(j)
next
exit for
@@ -140,7 +197,8 @@ do
next
end if
- Connection_Destroy()
+ delete wikicon
+
LocalCache_Destroy()
'' Check for failed pages
@@ -162,9 +220,9 @@ do
case "y"
for i = 1 to nfailedpages
- app_opt.webPageList(i) = failedpages(i)
+ app_opt.pageList(i) = failedpages(i)
next
- app_opt.webPageCount = nfailedpages
+ app_opt.pageCount = nfailedpages
exit do
diff --git a/doc/fbchkdoc/makefile b/doc/fbchkdoc/makefile
index baca92656e..5d63d2fdea 100644
--- a/doc/fbchkdoc/makefile
+++ b/doc/fbchkdoc/makefile
@@ -59,6 +59,11 @@ DEPS = ../libfbdoc/libfbdoc.a $(HEADERS)
FBCFLAGS += -exx -g -i ../libfbdoc
FBLFLAGS += -exx -g -p ../libfbdoc -l fbdoc
+ifdef HAVE_MYSQL
+ FBCFLAGS += -d HAVE_MYSQL
+ FBLFLAGS += -l mysql
+endif
+
ifeq ($(EXEEXT),.exe)
FBLFLAGS += -l ws2_32
endif
diff --git a/doc/fbchkdoc/mkimglst.bas b/doc/fbchkdoc/mkimglst.bas
index e4628fa2fb..f4bad39e6d 100644
--- a/doc/fbchkdoc/mkimglst.bas
+++ b/doc/fbchkdoc/mkimglst.bas
@@ -113,10 +113,11 @@ if( app_opt.help ) then
end if
cmd_opts_resolve()
-cmd_opts_check()
+cmd_opts_check_cache()
+cmd_opts_check_url()
'' no pages? nothing to do...
-if( app_opt.webPageCount = 0 ) then
+if( app_opt.pageCount = 0 ) then
print "no pages specified."
end 1
end if
@@ -135,7 +136,7 @@ if wikicache = NULL then
end 1
end if
-if( app_opt.webPageCount > 0 ) then
+if( app_opt.pageCount > 0 ) then
dim as integer i, h, h2
dim as string ret
@@ -144,9 +145,9 @@ if( app_opt.webPageCount > 0 ) then
h2 = freefile
open "imagepages.txt" for output as #h2
- for i = 1 to app_opt.webPageCount
+ for i = 1 to app_opt.pageCount
- sPage = app_opt.webPageList(i)
+ sPage = app_opt.pageList(i)
print "Loading '" + sPage + "':" ;
if( wikicache->LoadPage( sPage, sBody ) ) = FALSE then
diff --git a/doc/fbchkdoc/mkprntoc.bas b/doc/fbchkdoc/mkprntoc.bas
index 860f4134e0..27ab5427e9 100644
--- a/doc/fbchkdoc/mkprntoc.bas
+++ b/doc/fbchkdoc/mkprntoc.bas
@@ -320,7 +320,8 @@ if( app_opt.help ) then
end if
cmd_opts_resolve()
-cmd_opts_check()
+cmd_opts_check_cache()
+cmd_opts_check_url()
'' --------------------------------------------------------
diff --git a/doc/fbchkdoc/putpage.bas b/doc/fbchkdoc/putpage.bas
index a4ddf44fe1..b49a598e99 100644
--- a/doc/fbchkdoc/putpage.bas
+++ b/doc/fbchkdoc/putpage.bas
@@ -87,7 +87,8 @@ if( app_opt.help ) then
end if
cmd_opts_resolve()
-cmd_opts_check()
+cmd_opts_check_cache()
+cmd_opts_check_url()
'' --------------------------------------------------------
@@ -97,9 +98,9 @@ sNote = "Auto-update"
sNoteDef = ""
dim as CWikiCache ptr wikicache = NULL
-dim as CWikiCon ptr wikicon = NULL
+dim as CWikiConUrl ptr wikicon = NULL
-if( app_opt.webPageCount = 0 ) then
+if( app_opt.pageCount = 0 ) then
print "No pages specified"
end if
@@ -110,7 +111,7 @@ if wikicache = NULL then
end 1
end if
-wikicon = new CWikiCon( app_opt.wiki_url, app_opt.ca_file )
+wikicon = new CWikiConUrl( app_opt.wiki_url, app_opt.ca_file )
if wikicon = NULL then
print "Unable to create connection " + app_opt.wiki_url
delete wikicache
@@ -118,7 +119,7 @@ if wikicon = NULL then
end if
'' we have web pages? go to work...
-if( app_opt.webPageCount > 0 ) then
+if( app_opt.pageCount > 0 ) then
dim as integer i
dim as string ret
print "URL: "; app_opt.wiki_url
@@ -128,16 +129,16 @@ if( app_opt.webPageCount > 0 ) then
print "Certificate: none"
end if
print "cache: "; app_opt.cache_dir
- for i = 1 to app_opt.webPageCount
- sPage = app_opt.webPageList(i)
- sComment = app_opt.webPageComments(i)
+ for i = 1 to app_opt.pageCount
+ sPage = app_opt.pageList(i)
+ sComment = app_opt.pageComments(i)
sBody = ""
print "Loading '" + sPage + "': ";
if( wikicache->LoadPage( sPage, sBody ) ) = FALSE then
print "Unable to load"
else
print "OK"
- if( wikicon->LoadPage( sPage, TRUE, TRUE, sBodyOld ) <> FALSE ) then
+ if( wikicon->LoadPage( sPage, sBodyOld ) <> FALSE ) then
if( wikicon->GetPageID() > 0 ) then
if( wikicon->Login( app_opt.wiki_username, app_opt.wiki_password ) ) = FALSE then
print "Unable to login"
diff --git a/doc/fbchkdoc/readme.txt b/doc/fbchkdoc/readme.txt
index 122299876a..b7905ba4c0 100644
--- a/doc/fbchkdoc/readme.txt
+++ b/doc/fbchkdoc/readme.txt
@@ -143,7 +143,7 @@ the '-ini FILE' command line option to any of the tools.
given. Set or override this option from the command line using the
'-cache DIR' command line option.
- dev_cache_dir
+ dev_cache_dir
like web_cache_dir, excect a duplicate of the off-line server's wiki.
This cache directory is selected when the '-dev+' command line option
is given. Set or override this option from the command line using
@@ -192,6 +192,12 @@ the '-ini FILE' command line option to any of the tools.
option is given. Set or override these options with
'-u USER -p PASS' command line options.
+ db_host, db_user, db_pass, db_name, db_port
+ db_host = database host name
+ db_user = database user login name
+ db_pass = database user login password
+ db_name = name of database to select for use
+ db_port = port on database host
Why all the extra directories and extra wiki, you ask? I have all these
extra copies of the wiki because many people have worked very hard to create
diff --git a/doc/fbchkdoc/rebuild.bas b/doc/fbchkdoc/rebuild.bas
index 4c81fc881c..a57877ecf5 100644
--- a/doc/fbchkdoc/rebuild.bas
+++ b/doc/fbchkdoc/rebuild.bas
@@ -91,10 +91,11 @@ if( app_opt.help ) then
end if
cmd_opts_resolve()
-cmd_opts_check()
+cmd_opts_check_cache()
+cmd_opts_check_url()
'' no pages? nothing to do...
-if( app_opt.webPageCount = 0 ) then
+if( app_opt.pageCount = 0 ) then
print "no pages specified."
end 1
end if
@@ -106,11 +107,11 @@ dim as CWiki ptr wiki
print "cache: "; app_opt.cache_dir
-for i = 1 to app_opt.webpagecount
+for i = 1 to app_opt.pageCount
wiki = new CWiki
- sPage = app_opt.webpagelist(i)
+ sPage = app_opt.pageList(i)
f = app_opt.cache_dir + sPage + ".wakka"
sBody1 = ReadTextFile( f )
diff --git a/doc/fbchkdoc/samps.bas b/doc/fbchkdoc/samps.bas
index 81cea63ec2..dcb3dbd04c 100644
--- a/doc/fbchkdoc/samps.bas
+++ b/doc/fbchkdoc/samps.bas
@@ -138,8 +138,8 @@ dim shared as string base_dir
dim shared as string manual_dir
dim shared as string wiki_cache_dir
-dim shared as integer webPageCount
-dim shared webPageList() as string
+dim shared as integer pageCount
+dim shared pageList() as string
dim shared wikicache as CWikiCache ptr = NULL
dim shared opt_force as boolean = false
@@ -205,9 +205,9 @@ function cmd_check_proc() as integer
dim as buffer b1, b2
dim as string ret
- for i = 1 to webPageCount
+ for i = 1 to pageCount
- sPage = webPageList(i)
+ sPage = pageList(i)
if( wikicache->LoadPage( sPage, sBody ) ) = FALSE then
logprint "Error while loading '" + sPage + "'"
@@ -373,9 +373,9 @@ function cmd_extract_proc() as integer
dim as string sPage, sBody, filename
dim as string ret
- for i = 1 to webPageCount
+ for i = 1 to pageCount
- sPage = webPageList(i)
+ sPage = pageList(i)
if( wikicache->LoadPage( sPage, sBody ) ) = FALSE then
logprint "Error loading '" + sPage + "'"
@@ -413,9 +413,9 @@ function cmd_update_proc() as integer
dim as integer nchanges = 0
dim as string ret
- for i = 1 to webPageCount
+ for i = 1 to pageCount
- sPage = webPageList(i)
+ sPage = pageList(i)
if( wikicache->LoadPage( sPage, sBody ) ) = FALSE then
logprint "Error while loading '" + sPage + "'"
@@ -464,9 +464,9 @@ function cmd_set_fb_proc() as integer
dim as string sPage, sBody
dim as string ret
- for i = 1 to webPageCount
+ for i = 1 to pageCount
- sPage = webPageList(i)
+ sPage = pageList(i)
if( wikicache->LoadPage( sPage, sBody ) ) = FALSE then
logprint "Error while loading '" + sPage + "'"
@@ -495,9 +495,9 @@ function cmd_getex_proc() as integer
dim as string sPage, sBody
dim as string ret
- for i = 1 to webPageCount
+ for i = 1 to pageCount
- sPage = webPageList(i)
+ sPage = pageList(i)
' if( lcase( left( spage, 3 )) <> "tut" ) then
' if( lcase( left( spage, 5 )) <> "propg" ) then
@@ -900,8 +900,8 @@ end if
if( (opt and opt_get_pages) <> 0 ) then
- webPageCount = 0
- redim webPageList(1 to 1) as string
+ pageCount = 0
+ redim pageList(1 to 1) as string
dim as string cmt
i = 2
while command(i) > ""
@@ -916,11 +916,11 @@ if( (opt and opt_get_pages) <> 0 ) then
line input #h, x
x = ParsePageName( x, cmt )
if( x > "" ) then
- webPageCount += 1
- if( webPageCount > ubound(webPageList) ) then
- redim preserve webPageList(1 to Ubound(webPageList) * 2)
+ pageCount += 1
+ if( pageCount > ubound(pageList) ) then
+ redim preserve pageList(1 to Ubound(pageList) * 2)
end if
- webPageList(webPageCount) = x
+ pageList(pageCount) = x
end if
wend
close #h
@@ -934,17 +934,17 @@ if( (opt and opt_get_pages) <> 0 ) then
logprint "Unrecognized option '" + command(i) + "'"
end select
else
- webPageCount += 1
- if( webPageCount > ubound(webPageList) ) then
- redim preserve webPageList(1 to Ubound(webPageList) * 2)
+ pageCount += 1
+ if( pageCount > ubound(pageList) ) then
+ redim preserve pageList(1 to Ubound(pageList) * 2)
end if
- webPageList(webPageCount) = command(i)
+ pageList(pageCount) = command(i)
end if
i += 1
wend
- if( webPageCount = 0 ) then
+ if( pageCount = 0 ) then
logprint "warning: no pages specified."
bAbort = TRUE
end if
diff --git a/doc/fbchkdoc/spell.bas b/doc/fbchkdoc/spell.bas
index 5af516ca79..70fe7d9097 100644
--- a/doc/fbchkdoc/spell.bas
+++ b/doc/fbchkdoc/spell.bas
@@ -373,10 +373,11 @@ if( app_opt.help ) then
end if
cmd_opts_resolve()
-cmd_opts_check()
+cmd_opts_check_cache()
+cmd_opts_check_url()
'' no pages? nothing to do...
-if( app_opt.webPageCount = 0 ) then
+if( app_opt.pageCount = 0 ) then
print "no pages specified."
end 1
end if
@@ -393,7 +394,7 @@ if wikicache = NULL then
end 1
end if
-if( app_opt.webPageCount > 0 ) then
+if( app_opt.pageCount > 0 ) then
dim as integer i, h, h2
dim as string ret
@@ -436,9 +437,9 @@ if( app_opt.webPageCount > 0 ) then
'' h = freefile
'' open "spellcheck.txt" for output as #h
- for i = 1 to app_opt.webPageCount
+ for i = 1 to app_opt.pageCount
- sPage = app_opt.webPageList(i)
+ sPage = app_opt.pageList(i)
CurrentPage = sPage
haveTitle = FALSE
diff --git a/doc/fbdoc/fbdoc.bas b/doc/fbdoc/fbdoc.bas
index 2147cf48f3..6a75aa0fd3 100644
--- a/doc/fbdoc/fbdoc.bas
+++ b/doc/fbdoc/fbdoc.bas
@@ -85,8 +85,8 @@ end sub
dim as string SinglePage = ""
dim as integer bSinglePage = FALSE
- redim as string webPageList(1 to 10)
- dim as integer webPageCount = 0, bWebPages = FALSE
+ redim as string pageList(1 to 10)
+ dim as integer pageCount = 0, bPages = FALSE
dim as string sTocPage = default_TocPage
@@ -145,9 +145,9 @@ end sub
i = 1
while( len( command(i) ) > 0 )
- if( bWebPages ) then
+ if( bPages ) then
if left( command(i), 1) = "-" then
- bWebPages = FALSE
+ bPages = FALSE
else
if left( command(i), 1) = "@" then
scope
@@ -160,22 +160,22 @@ end sub
line input #h, x
x = trim(x, any " " + chr(9))
if( x > "" ) then
- webPageCount += 1
- if( webPageCount > ubound(webPageList) ) then
- redim preserve webPageList(1 to Ubound(webPageList) * 2)
+ pageCount += 1
+ if( pageCount > ubound(pageList) ) then
+ redim preserve pageList(1 to Ubound(pageList) * 2)
end if
- webPageList(webPageCount) = x
+ pageList(pageCount) = x
end if
wend
close #h
end if
end scope
else
- webPageCount += 1
- if( webPageCount > ubound(webPageList) ) then
- redim preserve webPageList(1 to Ubound(webPageList) * 2)
+ pageCount += 1
+ if( pageCount > ubound(pageList) ) then
+ redim preserve pageList(1 to Ubound(pageList) * 2)
end if
- webPageList(webPageCount) = command(i)
+ pageList(pageCount) = command(i)
end if
end if
end if
@@ -188,7 +188,7 @@ end sub
end if
end if
- if(( bWebPages = FALSE ) and ( bSinglePage = FALSE )) then
+ if(( bPages = FALSE ) and ( bSinglePage = FALSE )) then
select case lcase(command(i))
case "-makeini"
@@ -214,7 +214,7 @@ end sub
case "-texinfo"
bEmitFormats or= OUT_TEXINFO
case "-getpage"
- bWebPages = TRUE
+ bPages = TRUE
case "-makepage"
bSinglePage = TRUE
case "-noscan"
@@ -338,11 +338,11 @@ end sub
dim as CPageList ptr paglist, toclist, lnklist
- if( webPageCount > 0 ) then
+ if( pageCount > 0 ) then
dim as integer i
dim as string ret
- for i = 1 to webPageCount
- ret = LoadPage( webPageList(i), FALSE, TRUE )
+ for i = 1 to pageCount
+ ret = LoadPage( pageList(i), FALSE, TRUE )
next
end 0
end if
diff --git a/doc/libfbdoc/CWikiCon.bas b/doc/libfbdoc/CWikiCon.bas
index 218c44eb9d..366ecbc12d 100644
--- a/doc/libfbdoc/CWikiCon.bas
+++ b/doc/libfbdoc/CWikiCon.bas
@@ -18,466 +18,58 @@
'' CWikiCon
''
-'' chng: apr/2006 written [v1ctor]
-'' chng: sep/2006 updated [coderJeff]
-'' dec/2006 updated [coderJeff] - using classes
+'' chng: may/2019 written [coderJeff]
''
-#include once "CHttp.bi"
-#include once "CHttpForm.bi"
-#include once "CHttpStream.bi"
#include once "CWikiCon.bi"
namespace fb.fbdoc
- type CWikiConCtx_
- as CHttp ptr http
- as zstring ptr url
- as zstring ptr ca_file
- as zstring ptr pagename
- as integer pageid
- as string csrftoken
- declare function queryCsrfToken( ) as string
- declare function queryCsrfTokenIfNeeded( ) as boolean
- declare sub maybeAddCsrfTokenToForm( byval form as CHttpForm ptr )
- end type
-
- const wakka_prefix = "?wakka="
- const wakka_loginpage = "UserSettings"
- const wakka_raw = "/raw"
- const wakka_edit = "/edit"
- const wakka_getid = "/getid"
- const wakka_error = "wiki-error"
- const wakka_response = "wiki-response"
-
- '':::::
- private function build_url _
- ( _
- byval ctx as CWikiConCtx ptr, _
- byval page as zstring ptr = NULL, _
- byval method as zstring ptr = NULL _
- ) as string
-
- dim as string url
-
- url = *ctx->url + wakka_prefix
-
- if( page = NULL ) then
- page = ctx->pagename
- end if
-
- url += *page
-
- if( method <> NULL ) then
- url += *method
- end if
-
- function = url
-
- end function
-
- private function strIsAlphaNumOnly( byref token as string ) as boolean
- for i as integer = 0 to len( token ) - 1
- select case as const( token[i] )
- case asc( "a" ) to asc( "z" ), _
- asc( "A" ) to asc( "Z" ), _
- asc( "0" ) to asc( "9" )
- case else
- return FALSE
- end select
- next
- return TRUE
- end function
-
- '' Extract the CSRFToken value embedded in a UserSettings html page (or
- '' rather, the Login form on it) generated by Wikka
- private function extractCsrfToken( byref htmlpage as string ) as string
- const CSRFTokenHead = " 0 ) then
- form->Add( "CSRFToken", csrftoken )
- end if
- end sub
-
- '':::::
- static sub CWikiCon.GlobalInit()
- CHttp.GlobalInit()
- end sub
-
'':::::
constructor CWikiCon _
( _
- byval url as zstring ptr, _
- byval ca_file as zstring ptr = NULL _
)
-
- ctx = new CWikiConCtx
-
- ctx->http = new CHttp
- ctx->url = allocate( len( *url ) + 1 )
- *ctx->url = *url
-
- if( ca_file ) then
- ctx->ca_file = allocate( len( *ca_file ) + 1 )
- *ctx->ca_file = *ca_file
- else
- ctx->ca_file = NULL
- end if
-
- ctx->pagename = NULL
- ctx->pageid = 0
-
end constructor
'':::::
destructor CWikiCon _
( _
)
-
- if( ctx = NULL ) then
- exit destructor
- end if
-
- if( ctx->pagename <> NULL ) then
- deallocate( ctx->pagename )
- ctx->pagename = NULL
- end if
-
- if( ctx->ca_file <> NULL ) then
- deallocate( ctx->ca_file )
- ctx->ca_file = NULL
- end if
-
- if( ctx->url <> NULL ) then
- deallocate( ctx->url )
- ctx->url = NULL
- end if
-
- if( ctx->http <> NULL ) then
- delete ctx->http
- ctx->http = NULL
- end if
-
- delete ctx
-
end destructor
'':::::
- private function check_iserror _
- ( _
- byval body as zstring ptr _
- ) as integer
-
- if( len( *body ) = 0 ) then
- return TRUE
- end if
-
- function = ( instr( 1, *body, "<" + wakka_error + ">" ) > 0 )
-
- end function
-
- '':::::
- function CWikiCon.Login _
- ( _
- byval username as zstring ptr, _
- byval password as zstring ptr _
- ) as integer
-
- if( ctx = NULL ) then
- return FALSE
- end if
-
- if( ctx->queryCsrfTokenIfNeeded( ) = FALSE ) then
- return FALSE
- end if
-
- dim as CHttpForm ptr form
-
- form = new CHttpForm
- if( form = NULL ) then
- return FALSE
- end if
-
- form->Add( "action", "login" )
- form->Add( "wakka", "UserSettings" )
- form->Add( "name", username )
- form->Add( "password", password )
- form->Add( "submit", "Login" )
- ctx->maybeAddCsrfTokenToForm( form )
-
- dim as string response = ctx->http->Post( build_url( ctx, wakka_loginpage ), form, ctx->ca_file )
-
- function = ( check_iserror( response ) = FALSE )
-
- delete form
-
- end function
-
- '':::::
- private function get_response _
+ function CWikiCon.LoadPage _
( _
- byval body as zstring ptr _
- ) as string
-
- dim as string res
- dim as integer ps, pe, lgt, i
-
- function = ""
-
- if( len( *body ) = 0 ) then
- exit function
- end if
-
- ps = instr( 1, *body, "<" + wakka_response + ">" )
- if( ps = 0 ) then
- exit function
- end if
-
- pe = instr( ps, *body, "" + wakka_response + ">" )
- if( pe = 0 ) then
- exit function
- end if
-
- ps -= 1
- pe -= 1
-
- ps += 1 + len( wakka_response ) + 1
- lgt = ((pe - 1) - ps) + 1
- res = space( lgt )
- i = 0
- do while( i < lgt )
- res[i] = body[ps+i]
- i += 1
- loop
-
- function = res
-
- end function
-
- '':::::
- private sub remove_http_headers( byref body as string )
-
- dim as integer i = 1, n = len(body)
- const whitespace = chr(9,10,13,32)
- const crlfcrlf = chr(13,10,13,10)
-
- while( i <= n )
- if instr(whitespace,mid(body, i, 1)) = 0 then
- exit while
- end if
- i += 1
- wend
-
- if ( i < n ) then
- if( mid(body, i, 5) = "HTTP/" ) then
- i = instr( i, body, crlfcrlf )
- if( i > 0 ) then
- body = mid( body, i + 4 )
- end if
-
- end if
- end if
-
- end sub
-
- '':::::
- private sub remove_trailing_whitespace( byref body as string )
-
- dim as integer i, n = len(body)
- const whitespace = chr(9,10,13,32)
-
- i = n
- while( i >= 1 )
- if instr(whitespace,mid(body, i, 1)) = 0 then
- exit while
- end if
- i -= 1
- wend
-
- if( i < n ) then
- if( i > 0 ) then
- body = left( body, i )
- else
- body = chr(10)
- end if
- end if
-
- end sub
+ byval pagename as zstring ptr, _
+ byref body as string _
+ ) as boolean
- '':::::
- private function get_pageid _
- ( _
- byval ctx as CWikiConCtx ptr _
- ) as integer
-
- dim as CHttpStream ptr stream
-
- function = -1
-
- stream = new CHttpStream( ctx->http )
- if( stream = NULL ) then
- exit function
- end if
-
- dim as string body, URL
- URL = build_url( ctx, NULL, wakka_getid )
-
- if( stream->Receive( URL, TRUE, ctx->ca_file ) ) then
- body = stream->Read()
- end if
+ body = ""
+ function = false
- delete stream
-
- if( check_iserror( body ) = FALSE ) then
- remove_http_headers( body )
- function = valint( get_response( body ) )
- end if
-
end function
'':::::
- function CWikiCon.LoadPage _
+ function CWikiCon.LoadIndex _
( _
- byval page as zstring ptr, _
- byval israw as integer, _
- byval getid as integer, _
+ byval pagename as zstring ptr, _
byref body as string _
- ) as integer
+ ) as boolean
- function = FALSE
body = ""
-
- if( ctx = NULL ) then
- exit function
- end if
+ function = false
- ctx->pageid = -1
- ctx->pagename = reallocate( ctx->pagename, len( *page ) + 1 )
- *ctx->pagename = *page
-
- dim as CHttpStream ptr stream
-
- stream = new CHttpStream( ctx->http )
- if( stream = NULL ) then
- exit function
- end if
-
- dim as zstring ptr rawmethod = iif( israw, @wakka_raw, NULL )
-
- dim URL as string
- URL = build_url( ctx, NULL, rawmethod )
-
- if( stream->Receive( URL, TRUE, ctx->ca_file ) ) then
- body = stream->Read()
- remove_http_headers( body )
-'' remove_trailing_whitespace( body )
- end if
-
- delete stream
-
- if( getid ) then
- 'if( len( body ) > 0 ) then
- ctx->pageid = get_pageid( ctx )
- 'else
- ' ctx->pageid = -1
- 'end if
- else
- ctx->pageid = -1
- end if
-
- ''body += chr( 13, 10 )
-
- function = TRUE
-
end function
'':::::
function CWikiCon.StorePage _
( _
- byval body_in as zstring ptr, _
+ byval body as zstring ptr, _
byval note as zstring ptr _
- ) as integer
-
- dim body as string
-
- if( ctx = NULL ) then
- return FALSE
- end if
-
- if( ctx->pageid <= 0 ) then
- return FALSE
- end if
-
- dim as CHttpForm ptr form
+ ) as boolean
- form = new CHttpForm
- if( form = NULL ) then
- return FALSE
- end if
-
- form->Add( "wakka", *ctx->pagename + wakka_edit )
- form->Add( "previous", ctx->pageid )
- body = *body_in
-'' remove_trailing_whitespace( body )
- form->Add( "body", body, "text/html" )
- if( note ) then
- form->Add( "note", *note )
- else
- form->Add( "note", "updated" )
- end if
- form->Add( "submit", "Store" )
- ctx->maybeAddCsrfTokenToForm( form )
-
- dim url as string
- URL = build_url( ctx, NULL, wakka_edit )
+ function = false
- dim as string response = ctx->http->Post( url, form, ctx->ca_file )
-
- dim as integer res = ( check_iserror( response ) = FALSE )
-
- if( res ) then
- ctx->pageid = get_pageid( ctx )
- end if
-
- delete form
-
- function = res
-
end function
'':::::
@@ -485,41 +77,10 @@ namespace fb.fbdoc
( _
byval body as zstring ptr, _
byval pagename as zstring ptr _
- ) as integer
-
- if( ctx = NULL ) then
- return FALSE
- end if
-
- dim as CHttpForm ptr form
-
- form = new CHttpForm
- if( form = NULL ) then
- return FALSE
- end if
+ ) as boolean
- form->Add( "wakka", *pagename + wakka_edit )
- form->Add( "previous", " " )
- form->Add( "body", body, "text/html" )
- form->Add( "note", "new page" )
- form->Add( "submit", "Store" )
- ctx->maybeAddCsrfTokenToForm( form )
-
- dim URL as string
- URL = build_url( ctx, pagename, wakka_edit )
-
- dim as string response = ctx->http->Post( URL, form, ctx->ca_file )
-
- dim as integer res = ( check_iserror( response ) = FALSE )
+ function = false
- if( res ) then
- ctx->pageid = get_pageid( ctx )
- end if
-
- delete form
-
- function = res
-
end function
'':::::
@@ -527,11 +88,7 @@ namespace fb.fbdoc
( _
) as integer
- if( ctx = NULL ) then
- return 0
- end if
-
- return ctx->pageid
+ function = 0
end function
diff --git a/doc/libfbdoc/CWikiCon.bi b/doc/libfbdoc/CWikiCon.bi
index 9b10760383..d1bfe12726 100644
--- a/doc/libfbdoc/CWikiCon.bi
+++ b/doc/libfbdoc/CWikiCon.bi
@@ -23,55 +23,39 @@
namespace fb.fbdoc
- type CWikiConCtx as CWikiConCtx_
-
- type CWikiCon
+ type CWikiCon extends object
- declare static sub GlobalInit()
+ declare constructor()
+ declare virtual destructor()
- declare constructor _
+ declare virtual function LoadPage _
( _
- byval url as zstring ptr = NULL, _
- byval ca_file as zstring ptr = NULL _
- )
-
- declare destructor _
- ( _
- )
-
- declare function Login _
- ( _
- byval username as zstring ptr, _
- byval password as zstring ptr _
- ) as integer
-
+ byval pagename as zstring ptr, _
+ byref body as string _
+ ) as boolean
- declare function LoadPage _
+ declare virtual function LoadIndex _
( _
- byval page as zstring ptr, _
- byval israw as integer, _
- byval getid as integer = TRUE, _
+ byval pagename as zstring ptr, _
byref body as string _
- ) as integer
+ ) as boolean
- declare function StorePage _
+ declare virtual function StorePage _
( _
byval body as zstring ptr, _
byval note as zstring ptr _
- ) as integer
+ ) as boolean
- declare function StoreNewPage _
+ declare virtual function StoreNewPage _
( _
byval body as zstring ptr, _
byval pagename as zstring ptr _
- ) as integer
+ ) as boolean
- declare function GetPageID _
+ declare virtual function GetPageID _
( _
) as integer
- ctx as CWikiConCtx ptr
-
end type
end namespace
diff --git a/doc/libfbdoc/CWikiConDir.bas b/doc/libfbdoc/CWikiConDir.bas
new file mode 100644
index 0000000000..68b49c6064
--- /dev/null
+++ b/doc/libfbdoc/CWikiConDir.bas
@@ -0,0 +1,262 @@
+'' fbdoc - FreeBASIC User's Manual Converter/Generator
+'' Copyright (C) 2006-2019 The FreeBASIC development team.
+''
+'' This program is free software; you can redistribute it and/or modify
+'' it under the terms of the GNU General Public License as published by
+'' the Free Software Foundation; either version 2 of the License, or
+'' (at your option) any later version.
+''
+'' This program is distributed in the hope that it will be useful,
+'' but WITHOUT ANY WARRANTY; without even the implied warranty of
+'' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+'' GNU General Public License for more details.
+''
+'' You should have received a copy of the GNU General Public License
+'' along with this program; if not, write to the Free Software
+'' Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA.
+
+
+'' CWikiConDir
+''
+'' chng: may/2019 written [coderJeff]
+''
+
+#include once "CWikiConDir.bi"
+#include once "fbdoc_string.bi"
+#include once "file.bi"
+#include "crt/stdlib.bi"
+#include "crt/string.bi"
+
+#ifdef __FB_LINUX__
+extern "c"
+ declare function strcasecmp(byval as const zstring ptr, byval as const zstring ptr) as long
+end extern
+#define _stricmp strcasecmp
+#endif
+
+namespace fb.fbdoc
+
+ type CWikiConDirCtx_
+ as zstring ptr path
+ as zstring ptr pagename
+ as integer pageid
+ end type
+
+ const cache_ext = ".wakka"
+
+ '':::::
+ constructor CWikiConDir _
+ ( _
+ byval path as zstring ptr _
+ )
+
+ ctx = new CWikiConDirCtx
+ ZSet @ctx->path, path
+ ctx->pagename = NULL
+ ctx->pageid = -1
+
+ end constructor
+
+ '':::::
+ destructor CWikiConDir _
+ ( _
+ )
+
+ if( ctx = NULL ) then
+ exit destructor
+ end if
+ ZFree @ctx->path
+ ZFree @ctx->pagename
+ delete ctx
+
+ end destructor
+
+ '':::::
+ function CWikiConDir.LoadPage _
+ ( _
+ byval pagename as zstring ptr, _
+ byref body as string _
+ ) as boolean
+
+ dim sLocalFile as string
+ dim h as integer
+
+ function = FALSE
+ body = ""
+
+ if( ctx = NULL ) then
+ exit function
+ end if
+
+ ZSet @ctx->pagename, pagename
+ ctx->pageid = -1
+
+ sLocalFile = *ctx->path & *ctx->pagename & cache_ext
+
+ if( fileexists( sLocalFile ) ) then
+ h = freefile
+ if( open( sLocalFile for binary as #h) = 0 ) then
+ if( lof(h) > 0 ) then
+ body = space( lof( h ) )
+ get #h,,body
+ end if
+ close #h
+ function = TRUE
+ end if
+ end if
+
+ end function
+
+ ''
+ function cmpPageName cdecl ( byval x as any ptr, byval y as any ptr ) as long
+ function = _stricmp( *cast(zstring ptr ptr,x), *cast(zstring ptr ptr,y) )
+ end function
+
+ '':::::
+ private sub scan_cache_dir _
+ ( _
+ byval path as zstring ptr, _
+ byref body as string _
+ )
+
+ dim as integer pagecount = 0
+ dim as string d, lst
+
+ d = dir( *path & "*.wakka" )
+ while( d > "" )
+ dim as integer i = instrrev( d, "." )
+ if( i > 0 ) then
+ d = left( d, i-1 )
+ if( len(d) > 0 ) then
+ pagecount += 1
+ lst &= chr(0) & d
+ end if
+ end if
+ d = dir( )
+ wend
+
+ if( pagecount > 0 ) then
+ dim as zstring ptr zpage( 1 to pagecount )
+ dim as integer index = 1
+ for i as integer = 1 to len( lst )
+ if( lst[i] = 0 ) then
+ zpage(index) = @(lst[i+1])
+ index += 1
+ end if
+ next
+
+ '' Sort
+ qsort( @zpage(1), pagecount, sizeof(zstring ptr), procptr(cmpPageName) )
+
+ for i as integer = 1 to pagecount
+ body &= *zpage(i) & nl
+ next
+
+ else
+ body = ""
+
+ end if
+
+ end sub
+
+ '':::::
+ function CWikiConDir.LoadIndex _
+ ( _
+ byval page as zstring ptr, _
+ byref body as string _
+ ) as boolean
+
+ function = FALSE
+ body = ""
+
+ if( ctx = NULL ) then
+ exit function
+ end if
+
+ if( ctx->path = NULL ) then
+ exit function
+ end if
+
+ ctx->pageid = -1
+ ZSet @ctx->pagename, page
+
+ scan_cache_dir( *ctx->path, body )
+
+ function = TRUE
+
+ end function
+
+ '':::::
+ function CWikiConDir.StorePage _
+ ( _
+ byval body as zstring ptr, _
+ byval note as zstring ptr _
+ ) as boolean
+
+ if( ctx = NULL ) then
+ return FALSE
+ end if
+
+ if( body = NULL ) then
+ return FALSE
+ end if
+
+ if( len(*body) = 0) then
+ return FALSE
+ endif
+
+ if( ctx->pagename = NULL ) then
+ return FALSE
+ end if
+
+ dim as integer h
+ dim as string sLocalFile
+
+ function = FALSE
+
+ sLocalFile = *ctx->path + *ctx->pagename + cache_ext
+
+ if( fileexists( sLocalFile ) ) then
+ kill sLocalFile
+ end if
+
+ h = freefile
+ if( open(sLocalFile for binary as #h) = 0 ) then
+ put #h,,*body, len(*body)
+ close #h
+ function = TRUE
+ end if
+
+ end function
+
+ '':::::
+ function CWikiConDir.StoreNewPage _
+ ( _
+ byval body as zstring ptr, _
+ byval pagename as zstring ptr _
+ ) as boolean
+
+ if( ctx = NULL ) then
+ return FALSE
+ end if
+
+ ZSet @ctx->pagename, pagename
+
+ return StorePage( body, NULL )
+
+ end function
+
+ '':::::
+ function CWikiConDir.GetPageID _
+ ( _
+ ) as integer
+
+ if( ctx = NULL ) then
+ return 0
+ end if
+
+ return ctx->pageid
+
+ end function
+
+end namespace
diff --git a/doc/libfbdoc/CWikiConDir.bi b/doc/libfbdoc/CWikiConDir.bi
new file mode 100644
index 0000000000..e2e2775b85
--- /dev/null
+++ b/doc/libfbdoc/CWikiConDir.bi
@@ -0,0 +1,74 @@
+#ifndef __CWIKICONDIR_BI__
+#define __CWIKICONDIR_BI__
+
+'' fbdoc - FreeBASIC User's Manual Converter/Generator
+'' Copyright (C) 2006-2019 The FreeBASIC development team.
+''
+'' This program is free software; you can redistribute it and/or modify
+'' it under the terms of the GNU General Public License as published by
+'' the Free Software Foundation; either version 2 of the License, or
+'' (at your option) any later version.
+''
+'' This program is distributed in the hope that it will be useful,
+'' but WITHOUT ANY WARRANTY; without even the implied warranty of
+'' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+'' GNU General Public License for more details.
+''
+'' You should have received a copy of the GNU General Public License
+'' along with this program; if not, write to the Free Software
+'' Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA.
+
+
+#include once "fbdoc_defs.bi"
+#include once "CWikiCon.bi"
+
+namespace fb.fbdoc
+
+ type CWikiConDirCtx as CWikiConDirCtx_
+
+ type CWikiConDir extends CWikiCon
+
+ declare constructor _
+ ( _
+ byval path as zstring ptr = NULL _
+ )
+
+ declare destructor _
+ ( _
+ )
+
+ declare function LoadPage _
+ ( _
+ byval page as zstring ptr, _
+ byref body as string _
+ ) as boolean
+
+ declare function LoadIndex _
+ ( _
+ byval page as zstring ptr, _
+ byref body as string _
+ ) as boolean
+
+ declare function StorePage _
+ ( _
+ byval body as zstring ptr, _
+ byval note as zstring ptr _
+ ) as boolean
+
+ declare function StoreNewPage _
+ ( _
+ byval body as zstring ptr, _
+ byval pagename as zstring ptr _
+ ) as boolean
+
+ declare function GetPageID _
+ ( _
+ ) as integer
+
+ ctx as CWikiConDirCtx ptr
+
+ end type
+
+end namespace
+
+#endif
diff --git a/doc/libfbdoc/CWikiConSql.bas b/doc/libfbdoc/CWikiConSql.bas
new file mode 100644
index 0000000000..344f8414cd
--- /dev/null
+++ b/doc/libfbdoc/CWikiConSql.bas
@@ -0,0 +1,412 @@
+'' fbdoc - FreeBASIC User's Manual Converter/Generator
+'' Copyright (C) 2006-2019 The FreeBASIC development team.
+''
+'' This program is free software; you can redistribute it and/or modify
+'' it under the terms of the GNU General Public License as published by
+'' the Free Software Foundation; either version 2 of the License, or
+'' (at your option) any later version.
+''
+'' This program is distributed in the hope that it will be useful,
+'' but WITHOUT ANY WARRANTY; without even the implied warranty of
+'' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+'' GNU General Public License for more details.
+''
+'' You should have received a copy of the GNU General Public License
+'' along with this program; if not, write to the Free Software
+'' Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA.
+
+
+'' CWikiConSql
+''
+'' chng: may/2019 written [coderJeff]
+''
+
+#include once "CWikiConSql.bi"
+#include once "fbdoc_string.bi"
+#include once "mysql/mysql.bi"
+#include once "printlog.bi"
+
+namespace fb.fbdoc
+
+ type CMySqlCon
+
+ db as MYSQL ptr
+ connected as boolean
+
+ declare constructor _
+ ( _
+ )
+
+ declare destructor _
+ ( _
+ )
+
+ declare function Connect _
+ ( _
+ byval db_host as zstring ptr, _
+ byval db_user as zstring ptr, _
+ byval db_pass as zstring ptr, _
+ byval db_name as zstring ptr, _
+ byval db_port as integer _
+ ) as boolean
+
+ declare sub Disconnect _
+ ( _
+ )
+
+ end type
+
+ ''
+ constructor CMySqlCon _
+ ( _
+ )
+
+ db = NULL
+ connected = FALSE
+
+ end constructor
+
+ ''
+ destructor CMySqlCon _
+ ( _
+ )
+ if( connected ) then
+ Disconnect()
+ end if
+ db = NULL
+
+ end destructor
+
+ ''
+ function CMySqlCon.Connect _
+ ( _
+ byval db_host as zstring ptr, _
+ byval db_user as zstring ptr, _
+ byval db_pass as zstring ptr, _
+ byval db_name as zstring ptr, _
+ byval db_port as integer _
+ ) as boolean
+
+ function = FALSE
+
+ if( connected = TRUE ) then
+ return TRUE
+ end if
+
+ if( db_host = NULL ) then
+ exit function
+ end if
+
+ if( db_user = NULL ) then
+ exit function
+ end if
+
+ if( db_pass = NULL ) then
+ exit function
+ end if
+
+ if( db_name = NULL ) then
+ exit function
+ end if
+
+ printlog "Connecting to database: " + *db_name + " on " + *db_host + ":" + str(db_port)
+
+ '' we must let mysql_init() allocate; mysql/mysql.bi is
+ '' too out of date to trust the sizeof( MYSQL )
+ db = mysql_init( NULL )
+
+ if( NULL = db ) then
+ printlog "Error " + str(mysql_errno(db)) + ": " + *mysql_error(db)
+ printlog "Unable to initialize mysql"
+ return FALSE
+ end if
+
+ if( NULL = mysql_real_connect(db, db_host, db_user, db_pass, db_name, db_port, NULL, 0)) then
+ mysql_close( db )
+ printlog "Unable to connect to database"
+ return FALSE
+ end if
+
+ if( mysql_select_db( db, db_name ) <> 0 ) then
+ mysql_close( db )
+ printlog "Unable to use database " + *db_name
+ return FALSE
+ end if
+
+ connected = TRUE
+
+ function = TRUE
+
+ end function
+
+ ''
+ sub CMySqlCon.Disconnect _
+ ( _
+ )
+
+ if( connected ) then
+ if( db ) then
+ mysql_close( db )
+ end if
+ connected = FALSE
+ end if
+
+ end sub
+
+
+ type CWikiConSqlCtx_
+ as CMySqlCon ptr db_conn
+
+ as zstring ptr db_host
+ as zstring ptr db_user
+ as integer db_port
+
+ as zstring ptr db_pass
+ as zstring ptr db_name
+
+ as zstring ptr pagename
+ as integer pageid
+ end type
+
+ const cache_ext = ".wakka"
+
+ dim shared mysql_is_initialized as boolean = FALSE
+
+ '':::::
+ static sub CWikiConSql.GlobalInit()
+ '' !!! TODO !!! - need updated mysql.bi
+ '' mysql_server_init( 0, NULL, NULL )
+ mysql_is_initialized = TRUE
+ end sub
+
+ '':::::
+ static sub CWikiConSql.GlobalExit()
+ if( mysql_is_initialized ) then
+ '' !!! TODO !!! - need updated mysql.bi
+ '' mysql_server_end()
+ mysql_is_initialized = FALSE
+ end if
+ end sub
+
+ '':::::
+ constructor CWikiConSql _
+ ( _
+ byval db_host as zstring ptr, _
+ byval db_user as zstring ptr, _
+ byval db_pass as zstring ptr, _
+ byval db_name as zstring ptr, _
+ byval db_port as integer _
+ )
+
+ ctx = new CWikiConSqlCtx
+ ctx->db_conn = new CMySqlCon
+ ZSet @ctx->db_host, db_host
+ ZSet @ctx->db_user, db_user
+ ZSet @ctx->db_pass, db_pass
+ ZSet @ctx->db_name, db_name
+ ctx->db_port = db_port
+ ctx->pagename = NULL
+ ctx->pageid = -1
+
+ end constructor
+
+ '':::::
+ destructor CWikiConSql _
+ ( _
+ )
+
+ if( ctx = NULL ) then
+ exit destructor
+ end if
+ ZFree @ctx->db_host
+ ZFree @ctx->db_user
+ ZFree @ctx->db_pass
+ ZFree @ctx->db_name
+ ZFree @ctx->pagename
+ if( ctx->db_conn ) then
+ delete ctx->db_conn
+ end if
+ delete ctx
+
+ end destructor
+
+ '':::::
+ function CWikiConSql.Connect _
+ ( _
+ ) as boolean
+
+ function = FALSE
+
+ if( ctx = NULL ) then
+ exit function
+ end if
+
+ if( ctx->db_conn = NULL ) then
+ exit function
+ end if
+
+ function = ctx->db_conn->Connect( ctx->db_host, ctx->db_user, ctx->db_pass, ctx->db_name, ctx->db_port )
+
+ end function
+
+ '':::::
+ sub CWikiConSql.Disconnect _
+ ( _
+ )
+
+ ctx->db_conn->Disconnect()
+
+ end sub
+
+ '':::::
+ function CWikiConSql.LoadPage _
+ ( _
+ byval pagename as zstring ptr, _
+ byref body as string _
+ ) as boolean
+
+ function = FALSE
+ body = ""
+
+ if( ctx = NULL ) then
+ exit function
+ end if
+
+ if( pagename = NULL ) then
+ exit function
+ end if
+
+ ZSet @ctx->pagename, pagename
+ ctx->pageid = -1
+
+ scope
+ dim as string sql
+ dim as MYSQL_RES ptr res
+ dim as MYSQL_ROW row
+ dim as string sName, sBody
+
+ if( Connect() = FALSE ) then
+ return FALSE
+ end if
+
+ sql = "SELECT id, tag, CAST(CONVERT(body USING utf8) AS binary) FROM wikka_pages WHERE ( latest = 'Y' AND tag = '" & *pagename & "' )"
+
+ if( 0 <> mysql_real_query( ctx->db_conn->db, sql, len(sql)) ) then
+ return FALSE
+ end if
+
+ res = mysql_use_result( ctx->db_conn->db )
+ if( NULL = res ) then
+ return FALSE
+ end if
+
+ row = mysql_fetch_row( res )
+ if( NULL = row ) then
+ return FALSE
+ end if
+
+ ctx->pageid = cint( *row[0] )
+ body = *row[2]
+
+ mysql_free_result( res )
+
+ function = TRUE
+ end scope
+
+ end function
+
+ '':::::
+ function CWikiConSql.LoadIndex _
+ ( _
+ byval page as zstring ptr, _
+ byref body as string _
+ ) as boolean
+
+ function = FALSE
+ body = ""
+
+ if( ctx = NULL ) then
+ exit function
+ end if
+
+ if( page = NULL ) then
+ exit function
+ end if
+
+ ZSet @ctx->pagename, page
+ ctx->pageid = -1
+
+ scope
+ dim as string sql
+ dim as MYSQL_RES ptr res
+ dim as MYSQL_ROW row
+ dim as string sName, sBody
+
+ if( Connect() = FALSE ) then
+ return FALSE
+ end if
+
+ sql = "SELECT tag FROM wikka_pages WHERE ( latest = 'Y' ) ORDER BY tag"
+
+ if( 0 <> mysql_real_query( ctx->db_conn->db, sql, len(sql)) ) then
+ return FALSE
+ end if
+
+ res = mysql_use_result( ctx->db_conn->db )
+ if( NULL = res ) then
+ return FALSE
+ end if
+
+ do
+ row = mysql_fetch_row( res )
+ if( NULL = row ) then
+ exit do
+ end if
+ body &= *row[0] & nl
+ loop
+
+ mysql_free_result( res )
+
+ function = TRUE
+ end scope
+
+ function = TRUE
+
+ end function
+
+ '':::::
+ function CWikiConSql.StorePage _
+ ( _
+ byval body as zstring ptr, _
+ byval note as zstring ptr _
+ ) as boolean
+
+ function = FALSE
+
+ end function
+
+ '':::::
+ function CWikiConSql.StoreNewPage _
+ ( _
+ byval body as zstring ptr, _
+ byval pagename as zstring ptr _
+ ) as boolean
+
+ function = FALSE
+
+ end function
+
+ '':::::
+ function CWikiConSql.GetPageID _
+ ( _
+ ) as integer
+
+ if( ctx = NULL ) then
+ return 0
+ end if
+
+ return ctx->pageid
+
+ end function
+
+end namespace
diff --git a/doc/libfbdoc/CWikiConSql.bi b/doc/libfbdoc/CWikiConSql.bi
new file mode 100644
index 0000000000..30fe9f839e
--- /dev/null
+++ b/doc/libfbdoc/CWikiConSql.bi
@@ -0,0 +1,89 @@
+#ifndef __CWIKICONSQL_BI__
+#define __CWIKICONSQL_BI__
+
+'' fbdoc - FreeBASIC User's Manual Converter/Generator
+'' Copyright (C) 2006-2019 The FreeBASIC development team.
+''
+'' This program is free software; you can redistribute it and/or modify
+'' it under the terms of the GNU General Public License as published by
+'' the Free Software Foundation; either version 2 of the License, or
+'' (at your option) any later version.
+''
+'' This program is distributed in the hope that it will be useful,
+'' but WITHOUT ANY WARRANTY; without even the implied warranty of
+'' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+'' GNU General Public License for more details.
+''
+'' You should have received a copy of the GNU General Public License
+'' along with this program; if not, write to the Free Software
+'' Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA.
+
+
+#include once "fbdoc_defs.bi"
+#include once "CWikiCon.bi"
+
+namespace fb.fbdoc
+
+ type CWikiConSqlCtx as CWikiConSqlCtx_
+
+ type CWikiConSql extends CWikiCon
+
+ declare static sub GlobalInit()
+ declare static sub GlobalExit()
+
+ declare constructor _
+ ( _
+ byval db_host as zstring ptr, _
+ byval db_user as zstring ptr, _
+ byval db_pass as zstring ptr, _
+ byval db_name as zstring ptr, _
+ byval db_port as integer _ )
+ )
+
+ declare destructor _
+ ( _
+ )
+
+ declare function Connect _
+ ( _
+ ) as boolean
+
+ declare sub Disconnect _
+ ( _
+ )
+
+ declare function LoadPage _
+ ( _
+ byval page as zstring ptr, _
+ byref body as string _
+ ) as boolean
+
+ declare function LoadIndex _
+ ( _
+ byval page as zstring ptr, _
+ byref body as string _
+ ) as boolean
+
+ declare function StorePage _
+ ( _
+ byval body as zstring ptr, _
+ byval note as zstring ptr _
+ ) as boolean
+
+ declare function StoreNewPage _
+ ( _
+ byval body as zstring ptr, _
+ byval pagename as zstring ptr _
+ ) as boolean
+
+ declare function GetPageID _
+ ( _
+ ) as integer
+
+ ctx as CWikiConSqlCtx ptr
+
+ end type
+
+end namespace
+
+#endif
diff --git a/doc/libfbdoc/CWikiConUrl.bas b/doc/libfbdoc/CWikiConUrl.bas
new file mode 100644
index 0000000000..5ea7ee2716
--- /dev/null
+++ b/doc/libfbdoc/CWikiConUrl.bas
@@ -0,0 +1,706 @@
+'' fbdoc - FreeBASIC User's Manual Converter/Generator
+'' Copyright (C) 2006-2019 The FreeBASIC development team.
+''
+'' This program is free software; you can redistribute it and/or modify
+'' it under the terms of the GNU General Public License as published by
+'' the Free Software Foundation; either version 2 of the License, or
+'' (at your option) any later version.
+''
+'' This program is distributed in the hope that it will be useful,
+'' but WITHOUT ANY WARRANTY; without even the implied warranty of
+'' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+'' GNU General Public License for more details.
+''
+'' You should have received a copy of the GNU General Public License
+'' along with this program; if not, write to the Free Software
+'' Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA.
+
+
+'' CWikiConUrl
+''
+'' chng: apr/2006 written [v1ctor]
+'' chng: sep/2006 updated [coderJeff]
+'' dec/2006 updated [coderJeff] - using classes
+''
+
+#include once "CHttp.bi"
+#include once "CHttpForm.bi"
+#include once "CHttpStream.bi"
+#include once "CWikiConUrl.bi"
+#include once "fbdoc_string.bi"
+#include once "printlog.bi"
+
+namespace fb.fbdoc
+
+ type CWikiConUrlCtx_
+ as CHttp ptr http
+ as zstring ptr url
+ as zstring ptr ca_file
+ as zstring ptr pagename
+ as integer pageid
+ as string csrftoken
+ declare function queryCsrfToken( ) as string
+ declare function queryCsrfTokenIfNeeded( ) as boolean
+ declare sub maybeAddCsrfTokenToForm( byval form as CHttpForm ptr )
+ end type
+
+ const wakka_prefix = "?wakka="
+ const wakka_loginpage = "UserSettings"
+ const wakka_raw = "/raw"
+ const wakka_edit = "/edit"
+ const wakka_getid = "/getid"
+ const wakka_error = "wiki-error"
+ const wakka_response = "wiki-response"
+
+ '':::::
+ private function build_url _
+ ( _
+ byval ctx as CWikiConUrlCtx ptr, _
+ byval page as zstring ptr = NULL, _
+ byval method as zstring ptr = NULL _
+ ) as string
+
+ dim as string url
+
+ url = *ctx->url + wakka_prefix
+
+ if( page = NULL ) then
+ page = ctx->pagename
+ end if
+
+ url += *page
+
+ if( method <> NULL ) then
+ url += *method
+ end if
+
+ function = url
+
+ end function
+
+ private function strIsAlphaNumOnly( byref token as string ) as boolean
+ for i as integer = 0 to len( token ) - 1
+ select case as const( token[i] )
+ case asc( "a" ) to asc( "z" ), _
+ asc( "A" ) to asc( "Z" ), _
+ asc( "0" ) to asc( "9" )
+ case else
+ return FALSE
+ end select
+ next
+ return TRUE
+ end function
+
+ '' Extract the CSRFToken value embedded in a UserSettings html page (or
+ '' rather, the Login form on it) generated by Wikka
+ private function extractCsrfToken( byref htmlpage as string ) as string
+ const CSRFTokenHead = " 0 ) then
+ form->Add( "CSRFToken", csrftoken )
+ end if
+ end sub
+
+ '':::::
+ static sub CWikiConUrl.GlobalInit()
+ CHttp.GlobalInit()
+ end sub
+
+ '':::::
+ constructor CWikiConUrl _
+ ( _
+ byval url as zstring ptr, _
+ byval ca_file as zstring ptr = NULL _
+ )
+
+ ctx = new CWikiConUrlCtx
+
+ ctx->http = new CHttp
+ ZSet @ctx->url, url
+ if( ca_file ) then
+ ZSet @ctx->ca_file, ca_file
+ else
+ ctx->ca_file = NULL
+ end if
+
+ ctx->pagename = NULL
+ ctx->pageid = 0
+
+ end constructor
+
+ '':::::
+ destructor CWikiConUrl _
+ ( _
+ )
+
+ if( ctx = NULL ) then
+ exit destructor
+ end if
+ ZFree @ctx->pagename
+ ZFree @ctx->ca_file
+ ZFree @ctx->url
+
+ if( ctx->http <> NULL ) then
+ delete ctx->http
+ ctx->http = NULL
+ end if
+
+ delete ctx
+
+ end destructor
+
+ '':::::
+ private function check_iserror _
+ ( _
+ byval body as zstring ptr _
+ ) as integer
+
+ if( len( *body ) = 0 ) then
+ return TRUE
+ end if
+
+ function = ( instr( 1, *body, "<" + wakka_error + ">" ) > 0 )
+
+ end function
+
+ '':::::
+ function CWikiConUrl.Login _
+ ( _
+ byval username as zstring ptr, _
+ byval password as zstring ptr _
+ ) as boolean
+
+ if( ctx = NULL ) then
+ return FALSE
+ end if
+
+ if( ctx->queryCsrfTokenIfNeeded( ) = FALSE ) then
+ return FALSE
+ end if
+
+ dim as CHttpForm ptr form
+
+ form = new CHttpForm
+ if( form = NULL ) then
+ return FALSE
+ end if
+
+ form->Add( "action", "login" )
+ form->Add( "wakka", "UserSettings" )
+ form->Add( "name", username )
+ form->Add( "password", password )
+ form->Add( "submit", "Login" )
+ ctx->maybeAddCsrfTokenToForm( form )
+
+ dim as string response = ctx->http->Post( build_url( ctx, wakka_loginpage ), form, ctx->ca_file )
+
+ function = ( check_iserror( response ) = FALSE )
+
+ delete form
+
+ end function
+
+ '':::::
+ private function get_response _
+ ( _
+ byval body as zstring ptr _
+ ) as string
+
+ dim as string res
+ dim as integer ps, pe, lgt, i
+
+ function = ""
+
+ if( len( *body ) = 0 ) then
+ exit function
+ end if
+
+ ps = instr( 1, *body, "<" + wakka_response + ">" )
+ if( ps = 0 ) then
+ exit function
+ end if
+
+ pe = instr( ps, *body, "" + wakka_response + ">" )
+ if( pe = 0 ) then
+ exit function
+ end if
+
+ ps -= 1
+ pe -= 1
+
+ ps += 1 + len( wakka_response ) + 1
+ lgt = ((pe - 1) - ps) + 1
+ res = space( lgt )
+ i = 0
+ do while( i < lgt )
+ res[i] = body[ps+i]
+ i += 1
+ loop
+
+ function = res
+
+ end function
+
+ '':::::
+ private sub remove_http_headers( byref body as string )
+
+ dim as integer i = 1, n = len(body)
+ const whitespace = chr(9,10,13,32)
+ const crlfcrlf = chr(13,10,13,10)
+
+ while( i <= n )
+ if instr(whitespace,mid(body, i, 1)) = 0 then
+ exit while
+ end if
+ i += 1
+ wend
+
+ if ( i < n ) then
+ if( mid(body, i, 5) = "HTTP/" ) then
+ i = instr( i, body, crlfcrlf )
+ if( i > 0 ) then
+ body = mid( body, i + 4 )
+ end if
+
+ end if
+ end if
+
+ end sub
+
+ '':::::
+ private sub remove_trailing_whitespace( byref body as string )
+
+ dim as integer i, n = len(body)
+ const whitespace = chr(9,10,13,32)
+
+ i = n
+ while( i >= 1 )
+ if instr(whitespace,mid(body, i, 1)) = 0 then
+ exit while
+ end if
+ i -= 1
+ wend
+
+ if( i < n ) then
+ if( i > 0 ) then
+ body = left( body, i )
+ else
+ body = chr(10)
+ end if
+ end if
+
+ end sub
+
+ ''
+ private sub remove_html_tags _
+ ( _
+ byref sBody as string _
+ )
+
+ '' remove HTML tags from PageIndex
+
+ dim as string txt, html
+ dim as integer n, b = 0, j = 1, atag = 0, i
+ n = len(sBody)
+ txt = ""
+
+ while( i <= n )
+
+ if( lcase(mid( sBody, i, 4 )) = "<" ) then
+ txt += "<"
+ i += 4
+ elseif( lcase(mid( sBody, i, 4 )) = ">" ) then
+ txt += ">"
+ i += 4
+ elseif( lcase(mid( sBody, i, 5 )) = "&" ) then
+ txt += "&"
+ i += 5
+ elseif( lcase(mid( sBody, i, 6 )) = " " ) then
+ txt += " "
+ i += 6
+ elseif( mid( sBody, i, 4 ) = "All<" and atag = 1 ) then
+ txt += "All" + crlf + "----" + crlf
+ i += 3
+ elseif( mid( sBody, i, 5 ) = "All <" and atag = 1 ) then
+ txt += "All " + crlf + "----" + crlf
+ i += 3
+ elseif( lcase(mid( sBody, i, 1 )) = "<" ) then
+ atag = 0
+ b = 1
+ j = i + 1
+ while( j <= n and b > 0 )
+ select case ( mid( sBody, j, 1 ))
+ case "<"
+ b += 1
+ j += 1
+ case ">"
+ b -= 1
+ j += 1
+ case chr(34)
+ j += 1
+ while( j <= n )
+ select case ( mid( sBody, j, 1 ))
+ case chr(34)
+ j += 1
+ exit while
+ case else
+ j += 1
+ end select
+ wend
+ case else
+ j += 1
+ end select
+ wend
+
+ html = mid( sBody, i, j - i )
+ select case lcase( html )
+ case " "," "
+ txt += crlf
+ case " "," "
+ txt += "----"
+ case else
+ if left( html, 3 ) = " 2 ) then
+ '' find the page name
+ for i = 1 to len(x)
+ select case mid( x, i, 1 )
+ case "A" to "Z", "a" to "z", "0" to "9", "_"
+ case else
+ exit for
+ end select
+ next
+ if i > 1 then
+ txt &= left(x, i - 1) & nl
+ end if
+ end if
+ else
+ if x = "----" then
+ bFirstMark = TRUE
+ end if
+ end if
+
+ wend
+
+ sBody = txt
+
+ end sub
+
+ '':::::
+ private function get_pageid _
+ ( _
+ byval ctx as CWikiConUrlCtx ptr _
+ ) as integer
+
+ dim as CHttpStream ptr stream
+
+ function = -1
+
+ stream = new CHttpStream( ctx->http )
+ if( stream = NULL ) then
+ exit function
+ end if
+
+ dim as string body, URL
+ URL = build_url( ctx, NULL, wakka_getid )
+
+ if( stream->Receive( URL, TRUE, ctx->ca_file ) ) then
+ body = stream->Read()
+ end if
+
+ delete stream
+
+ if( check_iserror( body ) = FALSE ) then
+ remove_http_headers( body )
+ function = valint( get_response( body ) )
+ end if
+
+ end function
+
+ '':::::
+ function CWikiConUrl.LoadPage _
+ ( _
+ byval pagename as zstring ptr, _
+ byref body as string _
+ ) as boolean
+
+ function = FALSE
+ body = ""
+
+ if( ctx = NULL ) then
+ exit function
+ end if
+
+ ZSet @ctx->pagename, pagename
+ ctx->pageid = -1
+
+ dim as CHttpStream ptr stream
+
+ stream = new CHttpStream( ctx->http )
+ if( stream = NULL ) then
+ exit function
+ end if
+
+ dim URL as string
+ URL = build_url( ctx, NULL, @wakka_raw )
+
+ if( stream->Receive( URL, TRUE, ctx->ca_file ) ) then
+ body = stream->Read()
+ remove_http_headers( body )
+ end if
+
+ delete stream
+
+ ctx->pageid = get_pageid( ctx )
+
+ function = cbool( ctx->pageid > 0 )
+
+ end function
+
+ '':::::
+ function CWikiConUrl.LoadIndex _
+ ( _
+ byval page as zstring ptr, _
+ byref body as string _
+ ) as boolean
+
+ function = FALSE
+ body = ""
+
+ if( ctx = NULL ) then
+ exit function
+ end if
+
+ ZSet @ctx->pagename, page
+ ctx->pageid = -1
+
+ dim as CHttpStream ptr stream
+
+ stream = new CHttpStream( ctx->http )
+ if( stream = NULL ) then
+ exit function
+ end if
+
+ dim URL as string
+ URL = build_url( ctx, NULL, NULL )
+
+ if( stream->Receive( URL, TRUE, ctx->ca_file ) ) then
+ body = stream->Read()
+ remove_http_headers( body )
+ remove_html_tags( body )
+ extract_page_names( body )
+ function = TRUE
+ end if
+
+ delete stream
+
+ ctx->pageid = -1
+
+ end function
+
+ '':::::
+ function CWikiConUrl.StorePage _
+ ( _
+ byval body as zstring ptr, _
+ byval note as zstring ptr _
+ ) as boolean
+
+ dim body_out as string
+
+ if( ctx = NULL ) then
+ return FALSE
+ end if
+
+ if( ctx->pageid <= 0 ) then
+ return FALSE
+ end if
+
+ dim as CHttpForm ptr form
+
+ form = new CHttpForm
+ if( form = NULL ) then
+ return FALSE
+ end if
+
+ form->Add( "wakka", *ctx->pagename + wakka_edit )
+ form->Add( "previous", ctx->pageid )
+ body_out = *body
+
+ form->Add( "body", body_out, "text/html" )
+ if( note ) then
+ form->Add( "note", *note )
+ else
+ form->Add( "note", "updated" )
+ end if
+ form->Add( "submit", "Store" )
+ ctx->maybeAddCsrfTokenToForm( form )
+
+ dim url as string
+ URL = build_url( ctx, NULL, wakka_edit )
+
+ dim as string response = ctx->http->Post( url, form, ctx->ca_file )
+
+ dim as integer res = ( check_iserror( response ) = FALSE )
+
+ if( res ) then
+ ctx->pageid = get_pageid( ctx )
+ end if
+
+ delete form
+
+ function = res
+
+ end function
+
+ '':::::
+ function CWikiConUrl.StoreNewPage _
+ ( _
+ byval body as zstring ptr, _
+ byval pagename as zstring ptr _
+ ) as boolean
+
+ if( ctx = NULL ) then
+ return FALSE
+ end if
+
+ dim as CHttpForm ptr form
+
+ form = new CHttpForm
+ if( form = NULL ) then
+ return FALSE
+ end if
+
+ form->Add( "wakka", *pagename + wakka_edit )
+ form->Add( "previous", " " )
+ form->Add( "body", body, "text/html" )
+ form->Add( "note", "new page" )
+ form->Add( "submit", "Store" )
+ ctx->maybeAddCsrfTokenToForm( form )
+
+ dim URL as string
+ URL = build_url( ctx, pagename, wakka_edit )
+
+ dim as string response = ctx->http->Post( URL, form, ctx->ca_file )
+
+ dim as integer res = ( check_iserror( response ) = FALSE )
+
+ if( res ) then
+ ctx->pageid = get_pageid( ctx )
+ end if
+
+ delete form
+
+ function = res
+
+ end function
+
+ '':::::
+ function CWikiConUrl.GetPageID _
+ ( _
+ ) as integer
+
+ if( ctx = NULL ) then
+ return 0
+ end if
+
+ return ctx->pageid
+
+ end function
+
+end namespace
diff --git a/doc/libfbdoc/CWikiConUrl.bi b/doc/libfbdoc/CWikiConUrl.bi
new file mode 100644
index 0000000000..1d2600a6da
--- /dev/null
+++ b/doc/libfbdoc/CWikiConUrl.bi
@@ -0,0 +1,83 @@
+#ifndef __CWIKICONURL_BI__
+#define __CWIKICONURL_BI__
+
+'' fbdoc - FreeBASIC User's Manual Converter/Generator
+'' Copyright (C) 2006-2019 The FreeBASIC development team.
+''
+'' This program is free software; you can redistribute it and/or modify
+'' it under the terms of the GNU General Public License as published by
+'' the Free Software Foundation; either version 2 of the License, or
+'' (at your option) any later version.
+''
+'' This program is distributed in the hope that it will be useful,
+'' but WITHOUT ANY WARRANTY; without even the implied warranty of
+'' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+'' GNU General Public License for more details.
+''
+'' You should have received a copy of the GNU General Public License
+'' along with this program; if not, write to the Free Software
+'' Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA.
+
+
+#include once "fbdoc_defs.bi"
+#include once "CWikiCon.bi"
+
+namespace fb.fbdoc
+
+ type CWikiConUrlCtx as CWikiConUrlCtx_
+
+ type CWikiConUrl extends CWikiCon
+
+ declare static sub GlobalInit()
+
+ declare constructor _
+ ( _
+ byval url as zstring ptr = NULL, _
+ byval ca_file as zstring ptr = NULL _
+ )
+
+ declare destructor _
+ ( _
+ )
+
+ declare function Login _
+ ( _
+ byval username as zstring ptr, _
+ byval password as zstring ptr _
+ ) as boolean
+
+ declare function LoadPage _
+ ( _
+ byval page as zstring ptr, _
+ byref body as string _
+ ) as boolean
+
+ declare function LoadIndex _
+ ( _
+ byval page as zstring ptr, _
+ byref body as string _
+ ) as boolean
+
+ declare function StorePage _
+ ( _
+ byval body as zstring ptr, _
+ byval note as zstring ptr _
+ ) as boolean
+
+ declare function StoreNewPage _
+ ( _
+ byval body as zstring ptr, _
+ byval pagename as zstring ptr _
+ ) as boolean
+
+ declare function GetPageID _
+ ( _
+ ) as integer
+
+ ctx as CWikiConUrlCtx ptr
+
+ end type
+
+end namespace
+
+#endif
diff --git a/doc/libfbdoc/fbdoc_loader.bas b/doc/libfbdoc/fbdoc_loader.bas
index 239920b0ae..05d4ebcf86 100644
--- a/doc/libfbdoc/fbdoc_loader.bas
+++ b/doc/libfbdoc/fbdoc_loader.bas
@@ -78,9 +78,9 @@ namespace fb.fbdoc
end if
if( bLoadPage ) then
- dim as CWikiCon ptr wikicon = Connection_Create( )
+ dim as CWikiConUrl ptr wikicon = Connection_Create( )
printlog "Loading '" + *sPage + "'"
- if( wikicon->LoadPage( sPage, TRUE, TRUE, sBody ) <> FALSE ) then
+ if( wikicon->LoadPage( sPage, sBody ) <> FALSE ) then
if( wikicon->GetPageID() > 0 ) then
if( len(sBody) > 0 ) then
wikicache->SavePage( sPage, sBody )
diff --git a/doc/libfbdoc/fbdoc_loader_sql.bas b/doc/libfbdoc/fbdoc_loader_sql.bas
index e73b0bb1db..6f5c39c958 100644
--- a/doc/libfbdoc/fbdoc_loader_sql.bas
+++ b/doc/libfbdoc/fbdoc_loader_sql.bas
@@ -72,7 +72,7 @@ namespace fb.fbdoc
return FALSE
end if
- sql = "SELECT tag, body FROM wikka_pages WHERE ( latest = 'Y' )"
+ sql = "SELECT tag, CAST(CONVERT(body USING utf8) AS binary) FROM wikka_pages WHERE ( latest = 'Y' )"
if( 0 <> mysql_real_query( @db, sql, len(sql)) ) then
printlog "Unable to query wikka_pages"
diff --git a/doc/libfbdoc/fbdoc_loader_web.bas b/doc/libfbdoc/fbdoc_loader_web.bas
index c45b1ebaaf..880113711a 100644
--- a/doc/libfbdoc/fbdoc_loader_web.bas
+++ b/doc/libfbdoc/fbdoc_loader_web.bas
@@ -23,11 +23,11 @@
''
#include once "fbdoc_defs.bi"
-#include once "CWikiCon.bi"
+#include once "CWikiConUrl.bi"
namespace fb.fbdoc
- dim shared as CWikiCon ptr wikicon
+ dim shared as CWikiConUrl ptr wikicon
dim shared as string wiki_url
dim shared as string ca_file
@@ -42,12 +42,12 @@ namespace fb.fbdoc
end sub
'':::::
- function Connection_Create( ) as CWikiCon Ptr
+ function Connection_Create( ) as CWikiConUrl Ptr
if( wikicon <> NULL ) then
return wikicon
end if
- wikicon = new CWikiCon( wiki_url, ca_file )
+ wikicon = new CWikiConUrl( wiki_url, ca_file )
return wikicon
diff --git a/doc/libfbdoc/fbdoc_loader_web.bi b/doc/libfbdoc/fbdoc_loader_web.bi
index 88f450a647..d85ac69ec1 100644
--- a/doc/libfbdoc/fbdoc_loader_web.bi
+++ b/doc/libfbdoc/fbdoc_loader_web.bi
@@ -20,12 +20,12 @@
#include once "fbdoc_defs.bi"
-#include once "CWikiCon.bi"
+#include once "CWikiConUrl.bi"
namespace fb.fbdoc
declare sub Connection_SetUrl( byval url as zstring ptr, byval certificate as zstring ptr )
- declare function Connection_Create( ) as CWikiCon ptr
+ declare function Connection_Create( ) as CWikiConUrl ptr
declare sub Connection_Destroy( )
end namespace
diff --git a/doc/manual/cache/CatPgCompOpt.wakka b/doc/manual/cache/CatPgCompOpt.wakka
index 9a09a62586..9102796824 100644
--- a/doc/manual/cache/CatPgCompOpt.wakka
+++ b/doc/manual/cache/CatPgCompOpt.wakka
@@ -63,6 +63,8 @@ Command line compiler options for the fbc compiler:
- Do not show source line where error occurred
{{fbdoc item="keyword" value="CompilerOptnoobjinfo|-noobjinfo"}}
- Do not read/write compile-time info from/to .o and .a files
+ {{fbdoc item="keyword" value="CompilerOptnostrip|-nostrip"}}
+ - Do not strip symbol information from the output file
{{fbdoc item="keyword" value="CompilerOpto|-o < name >"}}
- Set object file path/name (must be passed after the .bas file)
{{fbdoc item="keyword" value="CompilerOptoptimization|-O < level >"}}
@@ -93,6 +95,8 @@ Command line compiler options for the fbc compiler:
- Display a tree of file names of ""#included"" files
{{fbdoc item="keyword" value="CompilerOptstatic|-static"}}
- Prefer static libraries over dynamic ones when linking
+ {{fbdoc item="keyword" value="CompilerOptstrip|-strip"}}
+ - Omit all symbol information from the output file
{{fbdoc item="keyword" value="CompilerOptt|-t < value >"}}
- Set stack size in kbytes (default: 1M)
{{fbdoc item="keyword" value="CompilerOpttarget|-target < platform >"}}
diff --git a/doc/manual/cache/CatPgPreProcess.wakka b/doc/manual/cache/CatPgPreProcess.wakka
index a1df8273e1..bf6621754c 100644
--- a/doc/manual/cache/CatPgPreProcess.wakka
+++ b/doc/manual/cache/CatPgPreProcess.wakka
@@ -78,5 +78,7 @@ Commands that control the preprocessor.
=={{fbdoc item="keyword" value="KeyPgMetaLang|'$LANG"}}==
Alternate form of the [[KeyPgPplang|#lang]] directive.
>>::c::
+{{fbdoc item="see"}}
+ - [[CatPgDddefines|Intrinsic Defines]]
{{fbdoc item="back" value="DocToc|Table of Contents"}}
\ No newline at end of file
diff --git a/doc/manual/cache/CatPgThreading.wakka b/doc/manual/cache/CatPgThreading.wakka
index 7999f88880..89d25ce728 100644
--- a/doc/manual/cache/CatPgThreading.wakka
+++ b/doc/manual/cache/CatPgThreading.wakka
@@ -6,22 +6,31 @@ Procedures for working with multithreaded applications.
**{{anchor name="THREADS|Threads"}}**
Procedures that start and wait for threaded procedures.
-**{{anchor name="CONDVARS|Conditional Varables"}}**
- Procedures that create and signal conditional variables.
**{{anchor name="MUTEXES|Mutexes"}}**
Procedures that deal with mutexes.
+**{{anchor name="CONDVARS|Conditional Varables"}}**
+ Procedures that create and signal conditional variables.
<<{{anchor name="THREADS"}}{{fbdoc item="section" value="Threads"}}
=={{fbdoc item="keyword" value="KeyPgThreadCall|THREADCALL"}}==
Starts a procedure with parameters in a separate thread of execution.
=={{fbdoc item="keyword" value="KeyPgThreadCreate|THREADCREATE"}}==
Starts a procedure in a separate thread of execution.
- =={{fbdoc item="keyword" value="KeyPgThreadDetach|THREADDETACH"}}==
- Releases a thread handle without waiting for the thread to finish.
=={{fbdoc item="keyword" value="KeyPgThreadWait|THREADWAIT"}}==
Waits for a thread to finish and releases the thread handle.
+ =={{fbdoc item="keyword" value="KeyPgThreadDetach|THREADDETACH"}}==
+ Releases a thread handle without waiting for the thread to finish.
-{{anchor name="CONDVARS"}}{{fbdoc item="section" value="Conditional Variables"}}
+{{anchor name="MUTEXES"}}{{fbdoc item="section" value="Mutexes"}}
+ =={{fbdoc item="keyword" value="KeyPgMutexCreate|MUTEXCREATE"}}==
+ Creates a mutex.
+ =={{fbdoc item="keyword" value="KeyPgMutexLock|MUTEXLOCK"}}==
+ Acquires a lock on a mutex.
+ =={{fbdoc item="keyword" value="KeyPgMutexUnlock|MUTEXUNLOCK"}}==
+ Releases a lock on a mutex.
+ =={{fbdoc item="keyword" value="KeyPgMutexDestroy|MUTEXDESTROY"}}==
+ Destroys a mutex that is no longer needed.
+<<>>{{anchor name="CONDVARS"}}{{fbdoc item="section" value="Conditional Variables"}}
=={{fbdoc item="keyword" value="KeyPgCondCreate|CONDCREATE"}}==
Creates a conditional variable.
=={{fbdoc item="keyword" value="KeyPgCondWait|CONDWAIT"}}==
@@ -32,15 +41,6 @@ Procedures for working with multithreaded applications.
Resumes all threaded procedures waiting for a conditional.
=={{fbdoc item="keyword" value="KeyPgCondDestroy|CONDDESTROY"}}==
Destroys a conditional variable that is no longer needed.
-<<>>{{anchor name="MUTEXES"}}{{fbdoc item="section" value="Mutexes"}}
- =={{fbdoc item="keyword" value="KeyPgMutexCreate|MUTEXCREATE"}}==
- Creates a mutex.
- =={{fbdoc item="keyword" value="KeyPgMutexLock|MUTEXLOCK"}}==
- Acquires a lock on a mutex.
- =={{fbdoc item="keyword" value="KeyPgMutexUnlock|MUTEXUNLOCK"}}==
- Releases a lock on a mutex.
- =={{fbdoc item="keyword" value="KeyPgMutexDestroy|MUTEXDESTROY"}}==
- Destroys a mutex that is no longer needed.
>>::c::
{{fbdoc item="target"}}
- These procedures are not supported in DOS.
diff --git a/doc/manual/cache/CompilerHistory.wakka b/doc/manual/cache/CompilerHistory.wakka
index 6c6e613d74..1081fef15b 100644
--- a/doc/manual/cache/CompilerHistory.wakka
+++ b/doc/manual/cache/CompilerHistory.wakka
@@ -3,18 +3,22 @@ Chronology of the ""FreeBASIC"" project.
{{fbdoc item="section" value="Chronology"}}
+ **2019 February 18**
+ - ""FreeBASIC"" 1.06.0 release
+ - Bugfixes
+
**2016 January 31**
- ""FreeBASIC"" 1.05.0 release
- Bugfixes
**2015 October 1**
- ""FreeBASIC"" 1.04.0 release
- - new data type "boolean"
+ - New data type "boolean"
- Bugfixes
**2014 December 28**
- ""FreeBASIC"" 1.01.0 release
- - started additionally providing "win32-mingworg" packages
+ - Started additionally providing "win32-mingworg" packages
- Bugfixes
**2014 September 24**
diff --git a/doc/manual/cache/CompilerOptWa.wakka b/doc/manual/cache/CompilerOptWa.wakka
index b5fac6240c..f719a91283 100644
--- a/doc/manual/cache/CompilerOptWa.wakka
+++ b/doc/manual/cache/CompilerOptWa.wakka
@@ -1,5 +1,5 @@
{{fbdoc item="title" value="Compiler Option: -Wa"}}----
-Pass options to the assembler when using the assembly emitter (-gen gas), the default.
+Pass options to the assembler when using the assembly emitter (-gen gas).
{{fbdoc item="syntax"}}##
**-Wa** < //options// >
@@ -9,10 +9,11 @@ Pass options to the assembler when using the assembly emitter (-gen gas), the de
Additional options to pass to the assembler.
{{fbdoc item="desc"}}
- The ##-Wa## compiler option passes additional options to GAS, the assembler. Options must be separated by commas only.
+ The ##-Wa## compiler option passes additional options to GAS, the assembler. Options must be separated by commas only. The ##-Wa## compiler option may be specified multiple times on the command line.
For example:
##fbc -Wa -o,output.o,--verbose##
+ ##fbc -Wa -o -Wa output.o -Wa --verbose##
{{fbdoc item="see"}}
- [[CompilerOptgen|Compiler Option: -gen]]
diff --git a/doc/manual/cache/CompilerOptWc.wakka b/doc/manual/cache/CompilerOptWc.wakka
index 6e02f59b0d..b67b6af2ae 100644
--- a/doc/manual/cache/CompilerOptWc.wakka
+++ b/doc/manual/cache/CompilerOptWc.wakka
@@ -9,10 +9,11 @@ Pass options to the C compiler when using the C emitter (-gen gcc).
Additional options to pass to the C compiler.
{{fbdoc item="desc"}}
- The ##-Wc## compiler option passes additional options to GCC, the C compiler. Options must be separated by commas only.
+ The ##-Wc## compiler option passes additional options to GCC, the C compiler. Options must be separated by commas only. The -Wc compiler option may be specified multiple times on the command line.
For example:
##fbc -gen gcc -Wc -m32,--verbose,-include,some-header.h##
+ ##fbc -gen gcc -Wc -m32 -Wc --verbose -Wc -include -Wc some-header.h##
{{fbdoc item="see"}}
- [[CompilerOptgen|Compiler Option: -gen]]
diff --git a/doc/manual/cache/CompilerOptWl.wakka b/doc/manual/cache/CompilerOptWl.wakka
index 0dc047958b..d917f3bbb0 100644
--- a/doc/manual/cache/CompilerOptWl.wakka
+++ b/doc/manual/cache/CompilerOptWl.wakka
@@ -9,10 +9,11 @@ Pass options to linker
Additional options to pass to the linker.
{{fbdoc item="desc"}}
- The ##-Wl## compiler option passes additional options to LD, the linker. Options must be separated by commas only.
+ The ##-Wl## compiler option passes additional options to LD, the linker. Options must be separated by commas only. The -Wl compiler option may be specified multiple times on the command line.
{{fbdoc item="see"}}
- [[CompilerOptWa|Compiler Option: -Wa]]
+ - [[CompilerOptWc|Compiler Option: -Wc]]
- [[CompilerCmdLine|Using the Command Line]]
{{fbdoc item="back" value="CatPgCompOpt|Compiler Options"}}
\ No newline at end of file
diff --git a/doc/manual/cache/CompilerOptnostrip.wakka b/doc/manual/cache/CompilerOptnostrip.wakka
new file mode 100644
index 0000000000..a27c420651
--- /dev/null
+++ b/doc/manual/cache/CompilerOptnostrip.wakka
@@ -0,0 +1,17 @@
+{{fbdoc item="title" value="Compiler Option: -nostrip"}}----
+Do not strip symbol information from the output file
+
+{{fbdoc item="syntax"}}##
+ **-nostrip**
+##
+{{fbdoc item="desc"}}
+ The ##-nostrip## compiler option explicitly prevents fbc from passing the option to strip (remove) all symbols to the linker. Object modules and libraries will retain any symbols present after linking.
+
+{{fbdoc item="target"}}
+ - fbc strips all symbols by default on Dos and Windows platforms only
+
+{{fbdoc item="see"}}
+ - [[CompilerOptstrip|-strip]]
+ - [[CompilerCmdLine|Using the Command Line]]
+
+{{fbdoc item="back" value="CatPgCompOpt|Compiler Options"}}
\ No newline at end of file
diff --git a/doc/manual/cache/CompilerOptstrip.wakka b/doc/manual/cache/CompilerOptstrip.wakka
new file mode 100644
index 0000000000..a8d5f07d2f
--- /dev/null
+++ b/doc/manual/cache/CompilerOptstrip.wakka
@@ -0,0 +1,17 @@
+{{fbdoc item="title" value="Compiler Option: -strip"}}----
+Omit all symbol information from the output file
+
+{{fbdoc item="syntax"}}##
+ **-strip**
+##
+{{fbdoc item="desc"}}
+ The ##-strip## compiler option passes an option to the linker to strip (remove) all symbols.
+
+{{fbdoc item="target"}}
+ - fbc strips all symbols by default on Dos and Windows platforms only
+
+{{fbdoc item="see"}}
+ - [[CompilerOptnostrip|-nostrip]]
+ - [[CompilerCmdLine|Using the Command Line]]
+
+{{fbdoc item="back" value="CatPgCompOpt|Compiler Options"}}
\ No newline at end of file
diff --git a/doc/manual/cache/DevBootstrap.wakka b/doc/manual/cache/DevBootstrap.wakka
index d88857ac12..d0bfc52587 100644
--- a/doc/manual/cache/DevBootstrap.wakka
+++ b/doc/manual/cache/DevBootstrap.wakka
@@ -4,13 +4,15 @@ fbc is written in FB itself, so you need a working fbc to build a new fbc. How t
{{fbdoc item="section" value="Bootstrapping using the FreeBASIC-x.xx.x-source-bootstrap package (if available)"}}
- The ""FreeBASIC-x.xx.x-source-bootstrap"" package contains the FB sources plus precompiled compiler sources, for multiple targets. After extracting, this can be built without requiring an existing fbc:
+ The ""FreeBASIC-x.xx.x-source-bootstrap"" package contains the FB sources plus precompiled compiler sources, for multiple targets. After extracting, this can be built without requiring an existing fbc (as long as the package contains the precompiled sources for the target system):
%%make bootstrap%%
- (as long as the package contains the precompiled sources for the target system)
+
+ To create a minimal build of fbc compiler, only building the components needed to recompile the fbc compiler itself:
+ %%make bootstrap-minimal%%
This package can be created by running:
%%make bootstrap-dist%%
-
+
{{fbdoc item="section" value="Bootstrapping by creating and using a bootstrap package"}}
1) On a system with a working fbc compiler, create the bootstrap package:
diff --git a/doc/manual/cache/GfxScancodes.wakka b/doc/manual/cache/GfxScancodes.wakka
index d09fc46b75..b6fc766acc 100644
--- a/doc/manual/cache/GfxScancodes.wakka
+++ b/doc/manual/cache/GfxScancodes.wakka
@@ -91,11 +91,10 @@ SC_INSERT &h52
SC_DELETE &h53
SC_F11 &h57
SC_F12 &h58
-
'' Extra scancodes not compatible with DOS scancodes
-SC_LWIN &h7D
-SC_RWIN &h7E
-SC_MENU &h7F
+SC_LWIN &h5B
+SC_RWIN &h5C
+SC_MENU &h5D
%%
{{fbdoc item="see"}}
diff --git a/doc/manual/cache/KeyPgAllocate.wakka b/doc/manual/cache/KeyPgAllocate.wakka
index b76b07e904..ac25a94ef4 100644
--- a/doc/manual/cache/KeyPgAllocate.wakka
+++ b/doc/manual/cache/KeyPgAllocate.wakka
@@ -60,8 +60,7 @@ Allocates a block of memory from the free store
%%
Output is:
- <<## 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377##
- <<::c::
+ %% 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377%%
It is important to free allocated memory if it's not going to be used anymore. Unused memory that isn't freed is simply wasting memory, and if the address of that memory is somehow overwritten or forgotten, that memory can never be freed. This condition is known as a memory leak, and should be avoided at all costs. Note that leaked memory is always completely freed when the application terminates, either by an "ordinary" exit or crash, so the leak "persists" only as long as the application runs, nevertheless it's a good habit to free any allocated memory inside your application. The following example demonstrates a function with a memory leak, where the address of allocated memory is lost and isn't and can't be freed anymore. If such a function is called frequently, the total amount of memory wasted can add up quickly.
diff --git a/doc/manual/cache/KeyPgAny.wakka b/doc/manual/cache/KeyPgAny.wakka
index 0a464c32a6..d2a0660d41 100644
--- a/doc/manual/cache/KeyPgAny.wakka
+++ b/doc/manual/cache/KeyPgAny.wakka
@@ -100,9 +100,9 @@ Dim c(Any, Any, Any) As Integer ' 3-dimensional dynamic array
' etc.
' Further Redims or array accesses must have a matching amount of dimensions
-Redim a(0 to 1) As Integer
-Redim b(1 to 10, 2 to 5) As Integer
-Redim c(0 to 9, 0 to 5, 0 to 1) As Integer
+Redim a(0 to 1)
+Redim b(1 to 10, 2 to 5)
+Redim c(0 to 9, 0 to 5, 0 to 1)
%%
{{fbdoc item="lang"}}
diff --git a/doc/manual/cache/KeyPgBoolean.wakka b/doc/manual/cache/KeyPgBoolean.wakka
index e5ff879424..15a8dcf854 100644
--- a/doc/manual/cache/KeyPgBoolean.wakka
+++ b/doc/manual/cache/KeyPgBoolean.wakka
@@ -33,6 +33,7 @@ Print "boolvar = ", boolvar
- New to ""FreeBASIC""
{{fbdoc item="see"}}
+ - ##[[KeyPgCbool|Cbool]]##
- ##[[KeyPgTrue|True]]##
- ##[[KeyPgFalse|False]]##
diff --git a/doc/manual/cache/KeyPgBsave.wakka b/doc/manual/cache/KeyPgBsave.wakka
index d5c3eaed2e..cc2d082951 100644
--- a/doc/manual/cache/KeyPgBsave.wakka
+++ b/doc/manual/cache/KeyPgBsave.wakka
@@ -54,9 +54,35 @@ CLS
LOCATE 13, 15: PRINT "Hello world!"
-' Save as BMP
+' Save screen as BMP
BSAVE "hello.bmp", 0
%%
+Save image buffer to bitmap file:
+{{fbdoc item="filename" value="examples/manual/gfx/bsave2.bas"}}%%(freebasic)
+'set graphics screen 640 x 480 pixels, 32 bit colors
+Const W = 640, H = 480 'width & hight
+Screenres W, H, 32
+'draw a smiley at screen center
+Circle (W \ 2, H \ 2), 180, &h00ffff00, , , , f 'yellow circle
+Circle (W \ 2 - 55, H \ 2 - 70), 35, &h00000000, , , 1.5, f 'left eye
+Circle (W \ 2 + 55, H \ 2 - 60), 35, &h00000000, , , 1.5, f 'right eye
+Circle (W \ 2, H \ 2 + 80), 70, &h00000000, , , 0.4, f 'mouth
+'allocate memory for image buffer
+Dim As Any Ptr pImageBuffer = Imagecreate(250, 250)
+'copy screen section to buffer
+Get (W \ 2 - 125, H \ 2 - 125)-step(250 - 1, 250 - 1), pImageBuffer
+'save image buffer to file
+Dim As String fileName = "Smiley.bmp"
+If Bsave(fileName, pImageBuffer) = 0 Then
+ Print "Saved succesful: " + fileName
+Else
+ Print "Error saving: " + fileName
+End If
+'free memory for image buffer
+Imagedestroy(pImageBuffer)
+'keep graphics screen open until key press
+Sleep
+%%
{{fbdoc item="diff"}}
- Support for saving more than 64KiB of arbitrary data is new to ""FreeBASIC"".
diff --git a/doc/manual/cache/KeyPgCircle.wakka b/doc/manual/cache/KeyPgCircle.wakka
index 177520905d..70a32f5166 100644
--- a/doc/manual/cache/KeyPgCircle.wakka
+++ b/doc/manual/cache/KeyPgCircle.wakka
@@ -48,6 +48,8 @@ Graphics statement to draw an ellipse or a circle
##F## is the fill flag. If you specify this flag, the circle/ellipse will be filled with the selected color. This only takes effect if you are drawing a full circle/ellipse.
Custom coordinates system set up by ##[[KeyPgWindow|Window]]## and/or ##[[KeyPgViewgraphics|View (Graphics)]]## affect the drawing operation; clipping set by ##[[KeyPgViewgraphics|View]]## also applies. When ##**Circle**## finishes drawing, the current graphics cursor position is set to the supplied center.
+
+ **Note:** Curves drawn with ##**Circle**## can induce pixels overdrawn at some locations. Thus, the resultant (blended) color of these overdrawn pixels is affected if a transparent color (in conjunction with the ##GFX_ALPHA_PRIMITIVES## option flag) is used.
{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/gfx/circle.bas"}}%%(freebasic)
diff --git a/doc/manual/cache/KeyPgCommon.wakka b/doc/manual/cache/KeyPgCommon.wakka
index 4fe854a20a..be5c917157 100644
--- a/doc/manual/cache/KeyPgCommon.wakka
+++ b/doc/manual/cache/KeyPgCommon.wakka
@@ -21,7 +21,7 @@ Declare Sub initme()
Common Shared foo() As Double
-Redim foo(0 To 2) As Double
+Redim foo(0 To 2)
initme()
diff --git a/doc/manual/cache/KeyPgInstrrev.wakka b/doc/manual/cache/KeyPgInstrrev.wakka
index ed10ba52e6..334da30418 100644
--- a/doc/manual/cache/KeyPgInstrrev.wakka
+++ b/doc/manual/cache/KeyPgInstrrev.wakka
@@ -20,9 +20,13 @@ Locates the last occurrence of a substring or character within a string
The position of the last occurrence of ##//substring//## in ##//str//##.
{{fbdoc item="desc"}}
- Locates the position of the last occurrence of a substring or character within a string. If ##//start//## parameter is not given or is -1, the search begins at the last character.
+ Locates the position of the last occurrence of a substring or character within a string. If ##//start//## parameter is not given or is less than zero, the search begins at the last character.
- Zero (0) is returned if: either ##//substring//## is not found, or either ##//str//## or ##//substring//## are empty strings, or ##//start//## is less than 1 (except for -1), or start is greater than the length of ##//str//##.
+ Zero (0) is returned if:
+ - ##//substring//## is not found, or
+ - either ##//str//## or ##//substring//## is an empty strings, or
+ - ##//start//## is zero, or
+ - start is greater than the length of ##//str//##.
If the ##**Any**## keyword is specified, ##**Instrrev**## returns the last occurrence of any character in ##//substring//##.
diff --git a/doc/manual/cache/KeyPgLinegraphics.wakka b/doc/manual/cache/KeyPgLinegraphics.wakka
index 2f1d088041..f83e223f7e 100644
--- a/doc/manual/cache/KeyPgLinegraphics.wakka
+++ b/doc/manual/cache/KeyPgLinegraphics.wakka
@@ -34,6 +34,8 @@ Draws a line
##//Style//##, if specified, allows styled line drawing; its value is interpreted as a 16-bit bitmask, and ##**Line**## will use it to skip pixel drawing. Starting at ##(//x1//,//y1//)##, the most significant bit of the style mask is checked: if ##1##, the pixel is drawn, if ##0##, it's skipped. This repeats for all the line pixels with the other bits, with the mask being reused when the 16 bits are all checked.
When ##**Line**## is used as ##**Line** - (x2, y2)##, a line is drawn from the current cursor position to the ##(//x2//,//y2//)## coordinates specified by ##**Line**##. Alternatively, ##[[KeyPgPoint|Point]]## can be used to get the current cursor position.
+
+ **Note:** Either chained use or boxes drawn with ##**Line**## can induce pixels overdrawn at some locations. Thus, the resultant (blended) color of these overdrawn pixels is affected if a transparent color (in conjunction with the ##GFX_ALPHA_PRIMITIVES## option flag) is used.
{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/gfx/line.bas"}}%%(freebasic)
diff --git a/doc/manual/cache/KeyPgOpNew.wakka b/doc/manual/cache/KeyPgOpNew.wakka
index a0910ef747..32a0f33460 100644
--- a/doc/manual/cache/KeyPgOpNew.wakka
+++ b/doc/manual/cache/KeyPgOpNew.wakka
@@ -24,7 +24,7 @@ Operator to dynamically allocate memory and construct data of a specified type.
For simple types, like integers, an initial value can be given. For types without constructors, initial values can be specified for each field (either with default initializer at data-field declaration, or with initializer list as in ##**New** //datatype// (**initializers, ..**)## if all type data-fields are numeric primitives only and without any default initializers). For types with at least one constructor, the initialize list (if any) must match an existing constructor. If no initializers are given, the default values for those types will be set.
- ##**New[] Expression**## operator is the array-version of the ##**New Expression**## operator and allocates enough memory for the specified number of objects. The default constructor for the type will be used to set the initial values for each item.
+ ##**New[] Expression**## operator is the (one-dimensional) array-version of the ##**New Expression**## operator and allocates enough memory for the specified number of objects. The default constructor for the type will be used to set the initial values for each item.
Objects created with ##**New Expression**## operator must be freed with ##[[KeyPgOpDelete|Delete Statement]]## operator. Object array created with ##**New[] Expression**## operator must be freed with ##**Delete[] Statement**## operator, the array-version of ##[[KeyPgOpDelete|Delete Statement]]## operator. You cannot mix and match the different versions of the operators.
@@ -50,6 +50,12 @@ scope
' Create and initialize a "rational" and store its address.
dim p as Rational ptr = new Rational(3, 4)
+
+ ' test if null return pointer
+ if (p = 0) then
+ print "Error: unable to allocate memory, quitting."
+ end -1
+ end if
print p->numerator & "/" & p->denominator
@@ -63,6 +69,12 @@ scope
' Allocate memory for 100 integers and store the address of the first one.
dim p as integer ptr = new integer[100]
+ ' test if null return pointer
+ if (p = 0) then
+ print "Error: unable to allocate memory, quitting."
+ end -1
+ end if
+
' Assign some values to the integers in the array.
for i as integer = 0 to 99
p[i] = i
@@ -72,7 +84,78 @@ scope
delete[] p
end scope
+
+sleep
+%%
+
+{{fbdoc item="filename" value="examples/manual/operator/nested_new.bas"}}%%(freebasic)
+'' Example of nested New [] to get a 2-dimentional object array (4*3)
+
+type UDT
+ dim as integer N
+ declare constructor ()
+ declare destructor ()
+end type
+
+constructor UDT ()
+ print "Constructor",
+end constructor
+
+destructor UDT ()
+ print "Destructor",
+end destructor
+
+dim as UDT ptr ptr p = new UDT ptr [4] '' New [] allocation for the first dimension:
+ '' no internal allocation of extra uinteger because
+ '' allocation of array of pointers (to UDT objects with destructor)
+for I as integer = 0 to 3
+ p[I] = new UDT [5] '' New [] allocations for the last dimension:
+ '' internal allocation of an extra uinteger for each New [],
+ '' because allocation of an array of UDT objects with destructor
+ print
+next I
+
+for I as integer = 0 to 3
+ for J as integer = 0 to 4
+ p[I][J].N = I * 10 + J '' assignment of each object array element
+ next J
+next I
+
+print
+for I as integer = 0 to 3
+ for J as integer = 0 to 4
+ print p[I][J].N, '' display of each object array element
+ next J
+ print
+next I
+print
+
+for I as integer = 0 to 3
+ delete [] p[I] '' Delete [] deallocations for the last dimension
+ print
+next I
+delete [] p '' Delete [] deallocation for the first dimension)
+print
+
+sleep
%%
+
+ Output example:
+ %%
+Constructor Constructor Constructor Constructor Constructor
+Constructor Constructor Constructor Constructor Constructor
+Constructor Constructor Constructor Constructor Constructor
+Constructor Constructor Constructor Constructor Constructor
+
+ 0 1 2 3 4
+ 10 11 12 13 14
+ 20 21 22 23 24
+ 30 31 32 33 34
+
+Destructor Destructor Destructor Destructor Destructor
+Destructor Destructor Destructor Destructor Destructor
+Destructor Destructor Destructor Destructor Destructor
+Destructor Destructor Destructor Destructor Destructor%%
{{fbdoc item="lang"}}
- Only available in the //[[CompilerOptlang|-lang fb]]// dialect.
diff --git a/doc/manual/cache/KeyPgOpNewOverload.wakka b/doc/manual/cache/KeyPgOpNewOverload.wakka
index e344036c9f..5ff9195c17 100644
--- a/doc/manual/cache/KeyPgOpNewOverload.wakka
+++ b/doc/manual/cache/KeyPgOpNewOverload.wakka
@@ -16,7 +16,7 @@ Member operator to overload dynamic memory allocation process part provided by #
The member operator ##**New Overload**## overloads the dynamic memory allocation process part provided by the ##[[KeyPgOpNew|New Expression]]## operator when applying to a UDT (User Defined Type). So the user can define its own dynamic memory allocation process part.
But after that, the UDT instance construction process part provided by the ##[[KeyPgOpNew|New Expression]]## operator is not modified.
- ##**New[] Overload**## operator is the array-version of the ##**New Overload**## operator and overloads the dynamic memory allocation process provided by the ##**New[] Expression**## operator when applying to a UDT (User Defined Type).
+ ##**New[] Overload**## operator is the (one-dimensional) array-version of the ##**New Overload**## operator and overloads the dynamic memory allocation process provided by the ##**New[] Expression**## operator when applying to a UDT (User Defined Type).
Memory allocated with ##**New Overload**## operator must be freed by also defining a ##[[KeyPgOpDeleteOverload|Delete Overload]]## operator. Memory allocated with ##**New[] Overload**## operator must be freed by also defining a ##**Delete[] Overload**## operator, the array-version of ##[[KeyPgOpDeleteOverload|Delete Overload]]## operator. You cannot mix and match the different versions of the operators.
diff --git a/doc/manual/cache/KeyPgOpPlacementNew.wakka b/doc/manual/cache/KeyPgOpPlacementNew.wakka
index 145d655d04..07e5570225 100644
--- a/doc/manual/cache/KeyPgOpPlacementNew.wakka
+++ b/doc/manual/cache/KeyPgOpPlacementNew.wakka
@@ -30,7 +30,7 @@ Operator to construct an object at a specified memory address.
It is incorrect to call ##[[KeyPgOpDelete|Delete Statement]]## on the address. The proper way is to only call the destructor if one exists (implicitly or explicitly), with syntax as for a member method by using member access operator.
See examples below for proper ##**Placement New**## operator usage.
- ##**Placement New[]**## operator is the array-version of the ##**Placement New**## operator and constructs the specified number of objects from the specified memory location. The default constructor for the type will be used to set the initial values for each item.
+ ##**Placement New[]**## operator is the (one-dimensional) array-version of the ##**Placement New**## operator and constructs the specified number of objects from the specified memory location. The default constructor for the type will be used to set the initial values for each item.
Specifying an initial value of ##[[KeyPgAny|Any]]##, as in ##**New**(//address//)//datatype// (**Any**)## or ##**New**(//address//)//datatype//[//count//] {**Any**}## will not initialize the data. This is only valid on data types that do not have constructors (otherwise for data types with constructors, syntax of simple pointer conversion, like //Cptr(datatype Ptr, address)//, can be substituted to the invalid use of New...Any).
diff --git a/doc/manual/cache/KeyPgOptiondynamic.wakka b/doc/manual/cache/KeyPgOptiondynamic.wakka
index c1706c2666..ea5b797234 100644
--- a/doc/manual/cache/KeyPgOptiondynamic.wakka
+++ b/doc/manual/cache/KeyPgOptiondynamic.wakka
@@ -19,7 +19,7 @@ Option Dynamic
Dim bar(99) As Integer ' declares a variable-length array
' ...
-ReDim bar(199) As Integer ' resize the array
+ReDim bar(199) ' resize the array
%%
{{fbdoc item="lang"}}
- Only available in the //[[CompilerOptlang|-lang fblite]]// and //[[CompilerOptlang|-lang qb]]// dialects.
diff --git a/doc/manual/cache/KeyPgPaint.wakka b/doc/manual/cache/KeyPgPaint.wakka
index 17be76d303..7a17a748ed 100644
--- a/doc/manual/cache/KeyPgPaint.wakka
+++ b/doc/manual/cache/KeyPgPaint.wakka
@@ -34,6 +34,8 @@ Fills an area delimited by a border of a specified color
##size = (8 * 8) * 4 = 256##
If the passed string is smaller, missing pixels will be 0. If the ##//paint//## argument is omitted, normal filling is performed using the current foreground color set by ##[[KeyPgColor|Color]]##. Flood-filling continues until pixels of the specified border color are found; if ##//border_color//## is omitted, the current background color is assumed.
+
+ **Warning:** If the border is drawn with a transparent color (in conjunction with the ##GFX_ALPHA_PRIMITIVES## option flag) and some pixels are overdrawn on it, the resultant (blended) color of these overdrawn pixels can cause a leak point through which the fill color escapes outside the border. So drawing a border with a transparent color is not recommended.
{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/gfx/paint.bas"}}%%(freebasic)
diff --git a/doc/manual/cache/KeyPgPutfileio.wakka b/doc/manual/cache/KeyPgPutfileio.wakka
index 1b17442b96..cc19f8b9ce 100644
--- a/doc/manual/cache/KeyPgPutfileio.wakka
+++ b/doc/manual/cache/KeyPgPutfileio.wakka
@@ -77,7 +77,6 @@ Put #f, 1, buffer()
Close #f
%%
-{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/fileio/put-buffer.bas"}}%%(freebasic)
Dim As Byte Ptr lpBuffer
Dim As Integer hFile, Counter, Size
diff --git a/doc/manual/cache/KeyPgRedim.wakka b/doc/manual/cache/KeyPgRedim.wakka
index 49e7857f8d..059fc099a7 100644
--- a/doc/manual/cache/KeyPgRedim.wakka
+++ b/doc/manual/cache/KeyPgRedim.wakka
@@ -48,7 +48,7 @@ Next
'' Resize a variable-length array with 10 elements
'' (the lower bound should be kept the same)
-ReDim Preserve array(0 to 9) As Integer
+ReDim Preserve array(0 to 9)
Print "index", "value"
For index As Integer = LBound(array) To UBound(array)
@@ -94,7 +94,7 @@ Print
'' ReDim Preserve array to have 4*4 elements, preserving the contents
'' (only the first upper bound should be changed)
-ReDim Preserve array(1 To 4, 1 To 4) As Integer
+ReDim Preserve array(1 To 4, 1 To 4)
Print "4 * 4:"
Print
@@ -109,7 +109,7 @@ Print
'' ReDim Preserve array to have 2*4 elements, preserving but trancating the contents
'' (only the first upper bound should be changed)
-ReDim Preserve array(1 To 2, 1 To 4) As Integer
+ReDim Preserve array(1 To 2, 1 To 4)
Print "2 * 4:"
Print
diff --git a/doc/manual/cache/KeyPgScreencontrol.wakka b/doc/manual/cache/KeyPgScreencontrol.wakka
index a0c99d4042..6017d2d8b6 100644
--- a/doc/manual/cache/KeyPgScreencontrol.wakka
+++ b/doc/manual/cache/KeyPgScreencontrol.wakka
@@ -123,10 +123,10 @@ Sets or gets internal graphics library settings
- (""**"") ##SET_GL_2D_MODE## Sets OpenGL 2D render
[IN] ##//param1//##:
##OGL_2D_NONE## No rendering
- ##OGL_2D_MANUAL_SYNC## Manual rendering (when ##[[KeyPgFlip|Flip]]##/##[[KeyPgScreencopy|ScreenCopy]]## is called)
+ ##OGL_2D_MANUAL_SYNC## Manual rendering (when ##[[KeyPgFlip|Flip]]## is called)
##OGL_2D_AUTO_SYNC## Automatic rendering
- (""**"") ##SET_GL_SCALE## Apply a zoom factor on OpenGL 2D render (only allowed if OpenGL 2D render mode has yet been activated via ##SET_GL_2D_MODE##)
- [IN] ##//param1//## Zoom factor (0: no rendering)
+ [IN] ##//param1//## zoom factor (0: no rendering)
**Other operations**
- ##POLL_EVENTS## Cause the library to poll all events, ie to check the system event queue, specifically used for retrieving keyboard and mouse events. This is most useful for ""OpenGL"" code where ##[[KeyPgFlip|Flip]]## is not used, as normally ##[[KeyPgFlip|Flip]]## will cause these events to be polled.
diff --git a/doc/manual/cache/KeyPgSwap.wakka b/doc/manual/cache/KeyPgSwap.wakka
index fa8f4d1d0c..812cb701d8 100644
--- a/doc/manual/cache/KeyPgSwap.wakka
+++ b/doc/manual/cache/KeyPgSwap.wakka
@@ -12,6 +12,10 @@ Exchanges the values of two variables
{{fbdoc item="desc"}}
Swaps the value of two variables, including UDT instances (swaps all data members).
+
+ **Note:** When the data are referenced by a pointer, alone or within a descriptive structure (a UDT, for example), ##**Swap**## only exchanges the values of the pointers or the contents of the descriptive structures without accessing data themselves.
+ For var-len strings, ##**Swap**## only exchanges the descriptors of the strings rather than reallocate memory for exchange all strings data characters.
+ For UDTs, ##**Swap**## simply exchanges the contents of the structures, without any operators or methods being called.
{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/memory/swap.bas"}}%%(freebasic)
diff --git a/doc/manual/cache/KeyPgWchr.wakka b/doc/manual/cache/KeyPgWchr.wakka
index 039601e8fd..8b48d3b2ea 100644
--- a/doc/manual/cache/KeyPgWchr.wakka
+++ b/doc/manual/cache/KeyPgWchr.wakka
@@ -27,11 +27,9 @@ print "The character represented by the UNICODE code of 934 is: "; WCHR(934)
print "Multiple UNICODE characters: "; WCHR(933, 934, 935)
%%
will produce the output:
-
-<numerator & "/" & p->denominator
@@ -27,6 +33,12 @@ Scope
' Allocate memory for 100 integers and store the address of the first one.
Dim p As Integer Ptr = New Integer[100]
+ ' test if null return pointer
+ If (p = 0) Then
+ Print "Error: unable to allocate memory, quitting."
+ End -1
+ End If
+
' Assign some values to the integers in the array.
For i As Integer = 0 To 99
p[i] = i
@@ -36,3 +48,5 @@ Scope
Delete[] p
End Scope
+
+Sleep
diff --git a/examples/manual/proguide/arrays/array3.bas b/examples/manual/proguide/arrays/array3.bas
index f067f2e57a..c76e743010 100644
--- a/examples/manual/proguide/arrays/array3.bas
+++ b/examples/manual/proguide/arrays/array3.bas
@@ -14,4 +14,4 @@ Dim flarray(1 To totalSingles) As Single
Dim vlarray() As Integer
' Resizes the array to 10 elements.
-ReDim vlarray(1 To 10) As Integer
+ReDim vlarray(1 To 10)
diff --git a/examples/manual/proguide/primer/primer5.bas b/examples/manual/proguide/primer/primer5.bas
index f3f7245ec1..61b707cab0 100644
--- a/examples/manual/proguide/primer/primer5.bas
+++ b/examples/manual/proguide/primer/primer5.bas
@@ -13,5 +13,5 @@ b = 7
c = a + b
Print "a = "; a
-Print "a = "; b
+Print "b = "; b
Print "a + b = "; c
diff --git a/examples/manual/switches/option-dynamic.bas b/examples/manual/switches/option-dynamic.bas
index 6a338f3afa..bac36ee508 100644
--- a/examples/manual/switches/option-dynamic.bas
+++ b/examples/manual/switches/option-dynamic.bas
@@ -16,4 +16,4 @@ Option Dynamic
Dim bar(99) As Integer ' declares a variable-length array
' ...
-ReDim bar(199) As Integer ' resize the array
+ReDim bar(199) ' resize the array