Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Support

Pages: 1 ... 51 52 [53] 54 55 ... 59
781
Installation / Installing Script Basic V2.1
« on: April 12, 2008, 08:42:23 PM »
If your using GCC 4.x then you need to download the ScriptBasic changes  that Peter made for the depreciated compiler functionality.

http://scriptbasic.org/forum/viewtopic.php?t=99

John

782
General Discussions / Script Basic on Mac OS X
« on: March 17, 2008, 08:40:22 PM »
Quote

I noticed in some of the compiler output that ld gave errors about the -shared switch being an unknown option.


You may want to check your 'ld' options as -shared may have been depreciated.


John

783
General Discussions / Script Basic on Mac OS X
« on: March 17, 2008, 02:23:53 PM »
Quote

Not all of the modules compiled. I noticed in some of the compiler output that ld gave errors about the -shared switch being an unknown option. The following modules failed:
the sbhttpd executable
libscriba library
the bdb module
the curses module
the mysql module
the xml module
psql


Are you still having issues with the 'port_t' reference?

The PostgreSQL module is a tricky one to compile as the extension module was written by one of Peter's students. I was able to contact him and he made the changes needed to compile with the PostgreSQL libraries under CentOS.

Do you have the MySQL dev libs installed?

Maybe your missing the XML, Berkeley DB and curses dependencies as well.

Please post the sections of the compile run your still having issues with. Be sure to include the final OK/Failed report at the end. (prizes for a clean compile will not be awarded without proof.  8)  )

John

784
General Discussions / Script Basic on Mac OS X
« on: March 17, 2008, 12:41:04 PM »
Tiger,

Were you able to get all the extension modules and sbhttpd compiled as well? (no error compile run)

After you do some testing, would you be willing to share your binaries? I have been waiting for a Mac user to come along and compile the latest code base.

Let me know if you get GTK-server working with ScriptBasic if GUI programming is part of the plan.


John

785
General Discussions / Script Basic on Mac OS X
« on: March 16, 2008, 08:52:37 PM »
It would be great if you could post a link to a redirected compile run output. (stdout/stderr)

This will give us a better idea what might be going wrong.


John

786
DYC / DYC - Documentation
« on: February 28, 2008, 12:30:02 PM »
The normal way to access external resources are via a ScriptBasic extension module. This requires creating an interface module in C. With the DYC extension the ScriptBasic programmer can make calls to system DLL's or custom one that you might create in another language.
Code: [Select]
include dyc.bas
 
a$ = "message text" & chr$(0)
print dyc::dyc("ms,i,USER32.DLL,MessageBox,PZZL",0,a$,"title",3)


Prints to the console the following values:
 
Titlebar Exit = 2
Yes = 6
No = 7
Cancel = 2

DYC("format", arguments)  - by Peter Verhas

This function calls an arbitrary function from an arbitrary dll. The first argument to the function has to be a format string and the rest of the arguments are the arguments for the function to be called. The format string has to specify the calling convention of the function, the return value, the name of the DLL and the function to call and the argument types. These have to be specified one after the other separated by commas. The format string should not contain space.

The format string has the following format:

"Xc,Xr,DllName,FunctionName,Xargs"

where


Xc specifies the calling convention
Xr specifies the return value
DllName is the name of the DLL
FunctionName is the name of the function
Xargs specifies the arguments

When the function is called the arguments are converted from their BASIC value and the function is called according to the format specification. However note that a misformed format string can cause access violation in the program and thus stopping the process. Therefore it is recommended that you fully debug your code and the way you use this function. It may be a wise idea not to install this module on a server where different programmers can develop their programs and run in shared process n multiple threads. For example a hosted web server running the Eszter SB Application Engine can be stopped by a BASIC program using this external module.

In the following I describe the format string specifiers.

Xc CALLING CONVENTION

The calling convention can be one, two or at most three characters. The character m or M means that the code was compiled using Microsoft compiler. This is the default behavour, thus there is no need to specify this. The opposite is b or B meaning that the code was compiled using Borland compiler. The difference between these two compilers is how the return value is passed back to the caller. You should not use both b and m at a time. Actually m will be ignored.

The calling convention can also be s or S meaning standard callign convention or c or C meaning language C calling convention. Only one of them is to be used in a function call. If you are callign some function from a Windows system DLL then it is certainly s. If you do not know which to use write a small test program and experiment.

The difference between standard and C calling convention is the order of the arguments placed on the stack and also who the responsible is to clean the arguments from the stack (the called function or the calling code).

Finally you can specify 4 or 8 to specify that the function is returning a four or eight-byte floating point number. Although this is a kind of return value specification, it is stated here, because this affects the calling convention. These values are returned not in a memory place from the function but rather in the co-processor register and function dyc has to know to fetch them from there rather than expection the function to return a four or eight-byte memory chunk.

Xr RETURN VALUE

The return value should be specified using a single character. This can be:

i or I int, l or L long, p or P pointer, f or F float, d or D for double or v or V for __int64.

The int and long types are converted to a BASIC integer number, which is stored as a long in ScriptBasic. float and double values are returned as real number, which is stored as double in ScriptBasic. A pointer value is converted to long and is returned in an integer value. An __int64 value is returned as an 8 byte string copiing the bytes of the original __int64 value to the bytes of the BASIC string.

DllName

This parameter has to specify the name of the DLL. This name will be used to load the DLL calling the system function LoadLibrary. This means that the name can but also may not include the full path to the file. In the latter case the system function will search the path for the DLL as specified int he Microsoft provided documentation for the function LoadLibrary.

When a function from a certain DLL is called first the module loads the DLL and when the BASIC program finishes and the module is unloaded it unloads all DLLs it loaded. Any DLL by the module will only be loaded once. Whent he module is used in a multi-thread environment the interpreter threads load and unload the DLLs independently. If you do not understand what it means then just ignore this explanation: nothing to worry about.

FunctionName

The name of the function to be called from the certain DLL. If the function is not present in the DLL then the program tries to use the function with the original name with an 'A' appended to it. Many system functions happen to have this format in the Windows librares.


Xargs argument types

This parameter should specify the arguments. It has to have as many character as many arguments there are. Each character should specify exactly one argument and will control how the actual BASIC arguments are converted to their native format. For each argument one of the following characters can be used:

1,2,4,8 specifies that the argument is an arbitrary 1-, 2-, 4- or 8-byte argument. The BASIC argument should be string value and should have at least as many characters as needed (1, 2, 4 or 8 as specified).
It is possible to use undefined, integer or real value for 1-, 2- or 4-byte values. In this case the value will be converted to integer and the bytes of the value will be used as argument. In case of 8-byte argument the BASIC argument is converted to string.

c specifies that the argument is a single character. If the BASIC argument is a string then the first character of the string is used. If the argument is a real number or an integer number then the value will be used as ASCII code. If the argument is undef or if the string has no characters in it then the value will be zero.

s specifies that the argument is a short(2-byte) value. The BASIC argument is converted to an integervalue if needed and truncated to two bytes if needed.

f specifies that the argument is a float value. The BASIC argument is converted to a real value and its precision is decreased from double to float.

h,p,l specifies that the argument is a handle, pointer or long. In these cases the BASIC argument is converted to an integer value if needed.

z specifies that the argument is a pointer that should point to a zero terminated string. The BASIC argument is converted to string and a pointer to the start of the string is passed as actual argument. Note that BASIC strings are not zero terminated and the function dyc does not append the terminating zero character to the string. Thus you have to append a zero character to the BASIC string before you pass it as zero terminated string.

On the other hand you can safely use string constants as argument like in the example above "title" because string constants in ScriptBasic contain an extra zero character following their normal characters.

d specifies that the argument is a double value. The BASIC argument is converted to a real value if needed, which is stored in BASIC internally as double and is passed to the function.

Note: that this is a wise idea to write a wrapper function in BASIC that gets the arguments performs some checks if needed and calls the module dyc instead of putting the dyc call into the main BASIC code.

787
General Discussions / REQ: Sqlite binding.
« on: February 13, 2008, 02:59:35 PM »
Quote

I've got 20 years programming behind me (ex-IT admin/programmer)... C/C++ and scripting languages were my mainstay...


Your hired !  :wink:

We can use all the help we can get and having a C background puts you on my very special member list. Did you say Bud or Coors Lite is your favorite refreshment?   :D

John

788
General Discussions / REQ: Sqlite binding.
« on: February 13, 2008, 02:20:22 PM »
If you have a C background, adding a new extension to ScriptBasic is rather easy. Unlike other languages that allow you to dynamically link to a library, ScriptBasic require a few more steps but the end result is richer interface with the language. The 'trial' extension module is a do-nothing example that is well document on how to add your own extension. Peter Verhas has created documentation as well. You can also check out the code in the gtk-server.c program for a single function call interface. (simple no frills interface)

I plan on doing the Rlib report generator extension and will documented my effort. C isn't the primary language I program in so there may be room for improvement in the code I write. I have been programming in all flavors of Basic for the last 30 years. Applications, interfaces and utility work is where I shine.

John

789
GTK-Server / GTK Glade - Hello World
« on: February 09, 2008, 02:05:35 AM »
Peter,

Thanks for the code clean-up !

John

P.S.

Here is a link to the GTK Widget Gallery.

790
General Discussions / Application Server Users
« on: February 04, 2008, 02:52:47 AM »
Forum Members,

I'm trying to get a head count of the ScriptBasic application server (sbhttpd) users. If you have an application server running, please reply and share your experience using it.

If your using scriba (command line interpreter) for your CGI scripts, let us know as well.

Thanks !

John

P.S.

Was the CGI programming tutorial or the explanation of how to setup the application server of help to anyone?

791
General Discussions / SBHTTPD
« on: January 27, 2008, 01:00:21 AM »
Quote from: "btechint"

note; this is on an windows xp system


Sorry about that. Well at least you'll know how to install it on a Linux box when your ready. :)

Here is my local XP / Apache basic.conf file as an example.

Code: [Select]

; ScriptBasic sample configuration file
;
; Note that this configuration file format is from v1.0b19 or later and has to be compiled
; to internal binary format before starting ScriptBasic

; this is the extension of the dynamic load libraries on this system
dll ".dll"

; where the modules are to be loaded from
module "C:/scriptbasic/\\modules\\"

; where to search system and module include files
; trailing / or \ is needed
include "C:/scriptbasic/\\include\\"

; this is where modules should install their documentation
docu "C:/scriptbasic/\\doc\\"

; the maximum number of includes that script basic processes
; this will stop the reading when the programmer makes error
; and includes files recursively. 1000 is the default value
maxinclude 100

;
; define preprocessors
;
preproc (
  internal (
    dbg "C:/scriptbasic/\\modules\\dbg.dll"
    )
  )
;
; LIMIT VALUES TO STOP INIFINITE LOOP
;

; the maximal number of steps allowed for a program to run
; comment it out or set to zero to have no limit
maxstep 0

; the maximal number of steps allowed for a program to run
; inside a function.
; comment it out or set to zero to have no limit
maxlocalstep 0

; the maximal number of recursive function call deepness
; essentially this is the "stack" size
maxlevel 300


; the maximal memory in bytes that a basic program is allowed to use
; for its variables
maxmem 0

;
; This is the directory where we store the compiled code
; to automatically avoid recompilation
;
; cache "C:/scriptbasic/\\cache\\"

cgi (
;
; These are the keys used by the CGI module
;
  debugfile "C:/scriptbasic/\\cgidebug.txt"
  )

;
; MySQL configuration
;
mysql (
  connections (
    ABC (             ; the name of the connection
    host "127.0.0.1"     ; the host for the connection
    db "db_abc"             ; database for the connection
    user "dbadmin"          ; user for the connection
    password "dbpw" ; password for the connection
    port 3306            ; the port to use
    socket ""            ; the name of the socket or ""
    flag 0               ; the client flag
    clients 10           ; how many clients to serve before really closing the connections
    )
  )
 )
;
; Configure the simple ScriptBasic httpd daemon
;
; Note that scripts may change the working directory therefore
; all directories should be specified here full path. For example
; the directory names here do not include the drive c: or e:
; because I develop it on two machines and it was inconvenient
; to alter and recompile the config file each time I moved the
; source to the other machine. When I run a script that changes
; the drive the http daemon stops in a few seconds because the
; guard thread do not find the pid file and therefore tells the
; engine to stop.
;
servers (
  server (
    port 8080
    ip "127.0.0.1"
    protocol "http"
   )
  threads 1024
  listenbacklog 3
  home "C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\app\\"
  proxyip 1
  pid (
    file "C:/scriptbasic/\\httpdlog\\pid.txt"
    delay 60
    wait (
      period 10
      length 1
     )
   )
  vdirs (
    dir "/sb/:C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\app\\sb\\"
    dir "/fts/:C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\app\\fts\\"
    dir "/nwmls/:C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\app\\nwmls\\"
    )

  errmsgdest 3
  nolog 1 ; set this true not to use logs or ignore erroneouslog configuration
  log (
    panic ( file "C:/scriptbasic/\\httpdlog\\panic.log" )
    app   ( file "C:/scriptbasic/\\httpdlog\\app.log" )
    err   ( file "C:/scriptbasic/\\httpdlog\\err.log" )
    hit   ( file "C:/scriptbasic/\\httpdlog\\hit.log" )
    stat  ( file "C:/scriptbasic/\\httpdlog\\stat.log" )
    )
  ; the error page when a page is not found
msg404 """
<HTML>
<HEAD>
<TITLE>Error 404 page not found</TITLE>
</HEAD>
<BODY>
<FONT FACE="Verdana" SIZE="2">
<H1>Page not found</H1>
We regretfully inform you that the page you have requested can not be found on this server.
<p>
In case you are sure that this is a server configuration error, please contact
<FONT SIZE="3"><TT>root@localhost</TT></FONT>
</FONT>
</BODY>
</HTML>
 """
  code404 "200 OK" ; the http error code for page not found. The default is 404
  ; the program to run when a page is not found
  ;run404 "C:/scriptbasic/\\source\\examples\\run404.bas"
  )


John

792
General Discussions / SBHTTPD
« on: January 26, 2008, 03:55:31 PM »
Quote

I was able to get sbhttd working. I had questions about the ip allow-disallow, but your help notes answered them. I was also wondering about the pid.txt. A problem I have now is that the sbhttd will not stop. I have tried
sbhttd stop
sbhttd -stop
I see that I can use kill [-pid (number)]. Not sure yet what that is or how to use it.


The pid.txt file contains the main active process ID for sbhttpd. Just cat the file, get the number and kill -9 ####.

You can delete the pid.txt file and sbhttpd will die on it's own. (it may take a minute due to running threads need to finish)

Good to hear you got it going !

John

793
General Discussions / SBHTTPD
« on: January 26, 2008, 02:28:47 AM »
Code: [Select]

client (
    allowed "127.0.0.1/255.255.255.255"
    allowed "16.94.58.4/0.0.0.0"

    denied "127.0.0.1/0.0.0.0"
    denied "16.192.68.5/255.255.0.0"
    )


Quote from: "Peter Verhas"

You can define the client IPs that are allowed and denied to connect to the engine. This is the real client that is connecting to the listener on the socket and trying to get access via HTTP and not the client reported by any proxy header field. You can use this configuration option to allow only the web server machine to connect to the engine via the proxy module and disallow all external connections that may try to connect from external machines. You can also use this option to configure a client application not to be accessed by external computer.

A connection is accepted by the engine if there is at least one allowed configuration line that allows the connection and there is no any denied configuration line that denies the connections.

The string following the keywords allowed or denied should contains the IP number and the MASK separated by a slash. When the client IP is calculated first it is bitwise AND-ed by the MASK and compared to the IP number. Thus

allowed "127.0.0.1/255.255.255.255"

allows only connections from the localhost and

denied "127.0.0.1/0.0.0.0"

denies access for no-one (in other word this line is waste of CPU and text file, but is good as an example). The line

denied "16.192.68.5/255.255.0.0"

disallows all requests that come from an IP number 16.192.*.* that is some internal sub-network of the once existed firm: Digital Equipment Corporation.


The ScriptBasic application server gives you the flexibility to extend your reach to other system facilities but gives you the means to protect your site from unwanted external activity. (web and intranet environments)

And finally to answer your original question.

Code: [Select]

' sibawastart.bas
'
' This program is started by the SIBAWA system when the application starts.
'
' This program loads the cache authentication and access control into memory
' and also maintains the session data handling session time outs.


This feature manages the directory .htaccess authentication and caches it. Peter has included session handling support and a browser based management interface to setup users and access levels.

Quote
If you have information on your web site that is sensitive, or intended for only a small group of people, the techniques in this tutorial will help you make sure that the people that see those pages are the people that you wanted to see them.

Apache Authentication, Authorization, and Access Control

(One of the ScriptBasic gifts I haven't opened yet.  :wink: )

794
General Discussions / SBHTTPD
« on: January 26, 2008, 02:20:41 AM »
If you prefer not to expose your database host, login, password and db_name with the mysql::RealConnect() function, you can define this in the basic.conf file and use the mysql::Connect("accounting") function instead.
Code: [Select]

;
; MySQL configuration
;
mysql (
  connections (
    accounting (  ; the name of the connection
    host "127.0.0.1"  ; the host for the connection
    db "acct"  ; database for the connection
    user "db_user_id"  ; user for the connection
    password "db_password"  ; password for the connection
    port 3306  ; the port to use
    socket ""  ; the name of the socket or ""
    flag 0  ; the client flag
    clients 10  ; how many clients to serve before really closing the connections
    )
  )
 )



John

795
General Discussions / SBHTTPD
« on: January 26, 2008, 01:50:53 AM »
You can expand your application directory structure and hide it's files behind the web root directory. The "/var/www/html/app-bin" directory is the interface between Apache and sbhttpd. It doesn't have to contain any files if you use the ScriptBasic "vdirs" feature.
Code: [Select]

  vdirs (
    dir "/client/:/var/www/private/"
   )


http://sb.dev/app-bin/echo.bas   <-- this will run echo.bas in the webroot /app-bin (if you prefer, the 'home' directory can be defined below webroot , another drive, ... which allows for virtual mapping of your script resources.)

http://sb.dev/app-bin/client/echo.bas  <-- this runs the client version of the program located below the webroot in the private directory
Code: [Select]

Partial echo.bas output:

ServerSoftware  = ScriptBasic Application Server 2.1.1
ServerName      = undef
GatewayInterface= CGI/1.1
ServerProtocol  = HTTP/1.1
ServerPort      = 80
RequestMethod   = POST
PathInfo        = undef
PathTranslated  = /var/www/private/echo.bas
ScriptName      = echo.bas
QueryString     =
RemoteHost      = 192.168.1.101
RemoteAddress   = 192.168.1.101
AuthType        = undef
RemoteUser      =
RemoteIdent     = undef
ContentType     = application/x-www-form-urlencoded
ContentLength   = 44
UserAgent       = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
Cookie          = cookie1=1; cookie2=2; cookie3=3
Referer         = http://sb.dev/app-bin/client/echo.bas
Password        =
Full auth string= undef

Code: [Select]

/var/www/
drwxr-xr-x  4 root      root 4096 Jan 15 17:36 cgi-bin
drwxr-xr-x  3 root      root 4096 Jan 25 02:47 error
drwxr-xr-x  3 root      root 4096 Jan 25 20:13 html
drwxr-xr-x  3 root      root 4096 Jan 25 02:47 icons
drwxr-xr-x 14 root      root 4096 Jan 25 02:47 manual
drwxr-xr-x  2 root      root 4096 Jan 26 18:20 private
drwxr-xr-x  2 webalizer root 4096 Jan 25 02:47 usage

/var/www/html/
drwxr-xr-x 2 root root 4096 Jan 26 18:20 app-bin

/var/www/html/app-bin/
-rw-r--r-- 1 root root 4068 Jan 26 01:33 echo.bas

/var/www/private/
-rw-r--r-- 1 root root 4068 Jan 26 06:32 echo.bas


John

Pages: 1 ... 51 52 [53] 54 55 ... 59