home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #3 / amigamamagazinepolishissue1998.iso / bazy / kingfisher-distribution / developer / demo.c < prev    next >
C/C++ Source or Header  |  1995-02-06  |  2KB  |  67 lines

  1. #include <stdio.h>       /* Standard I/O is all we really need from the system */
  2. #include "kf-api.h"      /* The KF-API prototypes ensure proper type checking! */
  3.  
  4.  
  5. /* Try a DEFINE=__MYDATE__="`AmigaDate`" as part of the compiler's command
  6.  * line, provided, of course, you have a program named 'AmigaDate' available
  7.  * which produces a proper format for output, such as: "(17.1.95)"
  8.  *    If you don't use it, the statement below will use the standard SAS/C
  9.  * __AMIGADATE__ instead, which is buggy with 6.51 (whenever BOTH month AND
  10.  * day occupy 2 digits.)
  11.  */
  12. #ifndef __MYDATE__
  13. #define __MYDATE__ __AMIGADATE__
  14. #endif
  15.  
  16.  
  17. /* ALWAYS a good idea to have in the code! */
  18. char const VER[] = "$VER: KFDemo 1.0 "__MYDATE__;
  19.  
  20.  
  21. int main( int argc, char *argv[] ) {
  22.  
  23.   KFHANDLE myHandle;       /* defines an active connection to the server */
  24.   extern BOOL KFAPISilentRun;   /* defined in kf-api.c */
  25.  
  26.  
  27.   KFAPISilentRun = TRUE;   /* stop those pesky status messages while the
  28.                             * server is being started...
  29.                             */
  30.  
  31.   /* try to establish a connection to the server; this will attempt to
  32.    * start the server if it is not already running!  If the server cannot
  33.    * be started, it may take as much as 10 seconds for the command to try
  34.    * a second time before deciding that not even slow floppy drives should
  35.    * take that long.
  36.    */
  37.   if( (myHandle = KFLogin("First Test Project")) != NULL ) {
  38.  
  39.     /* If we get here, then the server is running and we are connected
  40.      * to it with a default database ready to be examined!
  41.      */
  42.  
  43.     /* ask the server how many connections it can handle */
  44.     ULONG maxlogins = KFMaxClients( myHandle );
  45.     if( maxlogins <= 2 )
  46.       printf("Unregistered");
  47.     else
  48.     if( maxlogins <= 32767 )
  49.       printf("Beta release");
  50.     else
  51.       printf("Registered");
  52.     printf(" server software is ready!\n");
  53.  
  54.     /* ask the server to give us some status information */
  55.     if( KFStatus( myHandle ) )
  56.       printf("********************\n"
  57.              "%s\n"
  58.              "********************\n",myHandle->Buffer);
  59.     else
  60.       printf("Status information could not be obtained!\n");
  61.  
  62.     /* logout from the server again (i.e. disconnect) */
  63.     KFLogout( myHandle );
  64.   } else
  65.     printf("The KFServer couldn't be started?!\n");
  66. } /* main() */
  67.