home *** CD-ROM | disk | FTP | other *** search
/ The AGA Experience 2 / agavol2.iso / software / utilities / comms / ncp / developer / source / ncplib / openncp.c < prev    next >
C/C++ Source or Header  |  1994-09-20  |  1KB  |  61 lines

  1. /*
  2. **    SAS/C 6.51 constructor for opening
  3. **  "ncp.library"
  4. **/
  5.  
  6. #include <constructor.h>
  7. #define __USE_SYSBASE
  8. #include <proto/exec.h> 
  9. #include <exec/execbase.h>
  10. #include <proto/intuition.h>
  11. #include <proto/dos.h>
  12. #include <libraries/ncplib.h>
  13. #include <string.h>
  14. struct Library *NCPBase;
  15. static struct Library *libbase;
  16.  
  17. CONSTRUCTOR_P(ncplib,500)
  18. {
  19.     struct EasyStruct eas;
  20.     char buffer[ 128 ];
  21.     struct Task *pr = FindTask( NULL );
  22.  
  23.     if( SysBase->LibNode.lib_Version < 37 )
  24.         return( 1 );
  25.  
  26.     FOREVER
  27.     {
  28.         libbase = OpenLibrary( NCP_NAME, NCP_VERSION );
  29.         if( !libbase )
  30.             libbase = OpenLibrary( "PROGDIR:" NCP_NAME, NCP_VERSION );
  31.         if( !libbase )
  32.             libbase = OpenLibrary( "PROGDIR:Libs/" NCP_NAME, NCP_VERSION );
  33.         if( libbase )
  34.         {
  35.             NCPBase = libbase;
  36.             return( 0 );
  37.         }
  38.  
  39.         eas.es_StructSize = sizeof( eas );
  40.         eas.es_Flags = 0;
  41.         eas.es_Title = buffer;
  42.         strncpy( buffer, pr->tc_Node.ln_Name, 127 );
  43.         GetProgramName( buffer, 127 );
  44.         buffer[ 127 ] = 0;
  45.         eas.es_TextFormat = "Requires V%ld (or higher))\nof \"" NCP_NAME "\"";
  46.         eas.es_GadgetFormat = "Retry|Cancel";
  47.         if( !EasyRequest( NULL, &eas, NULL, NCP_VERSION ) )
  48.             return( 1 );
  49.  
  50.    }
  51. }
  52.  
  53. DESTRUCTOR_P(ncplib,500)
  54. {
  55.    if (libbase)
  56.    {
  57.       CloseLibrary((struct Library *)libbase);
  58.       libbase = NCPBase = NULL;
  59.    }
  60. }
  61.