home *** CD-ROM | disk | FTP | other *** search
- /*
- ** SAS/C 6.51 constructor for opening
- ** "ncp.library"
- **/
-
- #include <constructor.h>
- #define __USE_SYSBASE
- #include <proto/exec.h>
- #include <exec/execbase.h>
- #include <proto/intuition.h>
- #include <proto/dos.h>
- #include <libraries/ncplib.h>
- #include <string.h>
- struct Library *NCPBase;
- static struct Library *libbase;
-
- CONSTRUCTOR_P(ncplib,500)
- {
- struct EasyStruct eas;
- char buffer[ 128 ];
- struct Task *pr = FindTask( NULL );
-
- if( SysBase->LibNode.lib_Version < 37 )
- return( 1 );
-
- FOREVER
- {
- libbase = OpenLibrary( NCP_NAME, NCP_VERSION );
- if( !libbase )
- libbase = OpenLibrary( "PROGDIR:" NCP_NAME, NCP_VERSION );
- if( !libbase )
- libbase = OpenLibrary( "PROGDIR:Libs/" NCP_NAME, NCP_VERSION );
- if( libbase )
- {
- NCPBase = libbase;
- return( 0 );
- }
-
- eas.es_StructSize = sizeof( eas );
- eas.es_Flags = 0;
- eas.es_Title = buffer;
- strncpy( buffer, pr->tc_Node.ln_Name, 127 );
- GetProgramName( buffer, 127 );
- buffer[ 127 ] = 0;
- eas.es_TextFormat = "Requires V%ld (or higher))\nof \"" NCP_NAME "\"";
- eas.es_GadgetFormat = "Retry|Cancel";
- if( !EasyRequest( NULL, &eas, NULL, NCP_VERSION ) )
- return( 1 );
-
- }
- }
-
- DESTRUCTOR_P(ncplib,500)
- {
- if (libbase)
- {
- CloseLibrary((struct Library *)libbase);
- libbase = NCPBase = NULL;
- }
- }
-