Tuesday 23 Oct, 2018
Welcome to RISCOS.org
Jump to 
Search Articles 
Search for Software 
 

Sponsored by Orpheus Internet - Quality Internet Services with RISC OS Support

Valid HTML 4.01!

Produced on RISC OS

We support the Any Browser Campaign

RISCOS.org Links Database Automaton Usage

The main Links Database engine can be interrogated by your own software which can aid you with package management or simply offering users the ability to upgrade if a newer version of an application is available.

To do this, you can consult a special version of the database which produces a vastly simplified, plain text output. Two steps are required:-

Step 1 - Finding out the unique database reference

Using the database search in the normal fashion, search for the application or module that you require. When you find it, view the full details page and make a note of it's unique Download ID. This is shown at the bottom of the Information section in the right-hand column.

The unique download ID is in the form xxyyyy where xx is a two digit alphabetic code signifying the catagory and yyyy is a four digit number.

Note this ID for future reference.

Step 2 - Checking the latest version of an entry

Armed with the unique database ID you can now interrogate the database using the following URL:-

http://www.riscos.org/cgi-bin/linksdb?d=x&pkg=x&q=IDNNNN

where IDNNNN is the unique database ID, as found in step 1.

Those of you who understand HTML and cgi scripting will notice that the line above is calling the cgi-bin/linksdb script on our server with three parameters. These are:-

d=xCompulsory - provide specific information on an ID reference.
pkg=xCompulsory - display output in shortform output.
q=IDNNNNCompulsory - q = unique database ID of entry required (see step 1)

Extra code required

If implementing version checking from software then you obviously don't want the user to have to enter the above URL in a standard web browser. Instead you want to implement some code in your application to fetch the reponse from RISCOS.org as painlessly and 'invisible' to the user as possible.

To do this you require an HTTP fetcher module or utility which will fetch a specific URL and save it locally as a file, which you can subsequently interrogate. Several such utilities exist for RISC OS, such as wget or cURL. The examples below will use wget.

Using wget

wget is a command line tool for retrieving files from the web using http and ftp. It has a number of parameters, but for our purposes we only need three parameters; the URL to fetch (described above), and two output files; one for logging the output of wget and one for storing the actual database results retrieved from RISCOS.org. The logging file is optional, but if used it will suppress output to the screen, which is useful for implementing into your own code.

The output files can either be standard files stored on a local disc or RAM disc, or could be sent to pipefs: - depending upon your coding skills and/or requirements.

An example CLI command using wget and interrogating the database to find the latest version of the tinct module would be:-

wget http://www.riscos.org/cgi-bin/linksdb?d=x&pkg=x&q=mo0038
 -o RAM::RamDisc0.$.log
 -O RAM::RamDisc0.$.pkginfo

(all on one line as a single command)

The first parameter is the full URL of our database (as described above)

The second parameter (optional) is the log file of the output from the wget command. In this example it will be saved as log on a local RAM Disc. This uses the -o parameter followed by the required filename.

The third parameter is the file to store the actual output returned from our server. In this example it will be saved as pkginfo, also on a local RAM Disc. This uses the -O parameter followed by the required filename.

The resulting file

The resulting file fetched from our server will be in plain text format and contain three lines (separated by linefeeds (\n). These are the name of the file, the latest version listed in the database and lastly, the URL of the download file for the latest update.

Eg. for tinct, the result will be:-