home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga MA Magazine 1998 #3
/
amigamamagazinepolishissue1998.iso
/
bazy
/
kingfisher-distribution
/
developer
/
readme
< prev
next >
Wrap
Text File
|
1995-05-30
|
6KB
|
160 lines
KingFisher Release 2 Development Kit
Copyright © 1992,1993,1994,1995 Udo Schuermann
All rights reserved
The development kit is written with SAS/C 6.55 in mind but may be adaptable
to other compilers. I have no access to other compilers, so if you send me
information on what changes are required, I will try to incorporate them in
a future release.
The most important file in the development kit is
kf-api.h
This is the one your own project would #include; documentation for all API
(Application Programming Interface) is at the head of every function proto-
type.
Once you have gained some understanding (with the help of the kf-api.h file
and this introductory document) you should proceed to compile kf-api.c into
kf-api.o, which is the object file you must link into your final binary.
···········································································
Here is a small project to get you started (available as demo.c)
------------------------------(snip snip)------------------------------
#include <stdio.h>
#include "kf-api.h"
void main( void ) {
KFHANDLE myHandle; /* defines an active connection to the server */
extern BOOL KFAPISilentRun; /* defined in kf-api.c */
KFAPISilentRun = TRUE; /* stop those pesky status messages while the
* server is being started...
*/
/* try to establish a connection to the server; this will attempt to
* start the server if it is not already running!
*/
if( (myHandle = KFLogin("First Test Project")) != NULL ) {
/* If we get here, then the server is running and we are connected
* to it with a default database ready to be examined!
*/
/* ask the server how many connections it can handle */
ULONG maxlogins = KFMaxClients( myHandle );
if( maxlogins <= 2 )
printf("Unregistered");
else
if( maxlogins <= 32767 )
printf("Beta release");
else
printf("Registered");
printf(" server software is ready!\n");
/* ask the server to give us some status information */
if( KFStatus( myHandle ) )
printf("********************\n"
"%s\n"
"********************\n",myHandle->Buffer);
else
printf("Status information could not be obtained!\n");
/* logout from the server again (i.e. disconnect) */
KFLogout( myHandle );
} else
printf("The KFServer couldn't be started?!\n");
} /* main() */
------------------------------(snip snip)------------------------------
Compile and link this program with the following commands:
sc demo NOLINK
slink FROM lib:c.o+demo.o+kf-api.o LIBRARY lib:sc.lib+lib:amiga.lib TO demo
THAT'S ALL THERE IS TO IT!
···········································································
Next, you may want to take a look at the ReOrder.c program. It is a little
longer than our little demo above, but still quite short. It demonstrates
how ONE program can establish TWO separate connections to the server. The
ReOrder tool copies a range of records from the first connection and writes
these to the second connection. This effectively is a copy operation, and
can be used in a variety of ways:
1. Simply duplicate an entire database but perhaps with slightly different
sections. See the 1000Fish.kfdb file for an example where a database is
split into two sections. You could easily create a file Fishies.kfdb
and specify something like:
section=0000,0999,fishies-1.data
section=1000,1999,fishies-2.data
section=2000,2999,fishies-3.data
section=3000,3999,fishies-4.data
section=4000,4999,fishies-5.data
or break it up into hundreds of tiny files. Using ReOrder, you could
then produce a new database with a different organization:
ReOrder 1000Fish.kfdb Fishies.kfdb
2. Copy only a portion of one database to a new one. Repeating this
process multiple times with various input databases and a single output
database would effectively collect choice records from several databases
into a new database.
···········································································
The third tool you may wish to look at, CLIent, is the most sizable pile of
junk code you will ever find from me ;-) and there are many reasons why I
say that:
The program does not use the prescribed kf-api files; it uses the
message port interface directly. This makes it much more difficult to
read, understand, maintain, and upgrade. Avoid writing code like that!
CLIent was the very first interface that I created to test the earliest
KFServer software, before the kf-api files were written to make the
whole MESSage port MESS more managable.
If you compare the simplicity of ReOrder.c with the open complexities of
CLIent.c, you will come to appreciate how much of the ugly details are
handled for you by the kf-api.
···········································································
And that is the end of this introductory overview. If you think this is
all a bit too complicated, I urge you to compile and run the demo.c program
to get started. Next, add a command such as:
if( KFGetFish( myHandle, 1 ) )
printf("Record #1 looks like this:\n\n%s\n",
myHandle->Buffer);
else
printf("Cannot load fish #1\n");
and see what that gets you! Chances are that this will take care of 90% of
your interaction with the server. The rest is up to you!
NIFTY FORMATTING?
No, the server does not provide data formatting services. The neat
stuff with wordwrap and all that KingFisher and RexxFisher do is all custom
coded; these routines will not become available in source form, although a
future version of the KFServer *may* provide them as services to clients
that do not wish to implement such code on their own.
···········································································
If you have suggestions for improvement to this Developer Kit, please don't
hesitate to let me know what is lacking or what can be enhanced. Thanks!
._. Udo Schuermann
( ) walrus@wam.umd.edu