home *** CD-ROM | disk | FTP | other *** search
- /***************************** DETECT.C *********************************/
- /* An "universal" initialization routine that automatically */
- /* "detects" any appropriate user driver. It does this either by using */
- /* the name of a driver passed to it, or an enviroment variable. */
- /* The enviroment variable is BGIDRIVER and by placing a line like */
- /* */
- /* SET BGIDRIVER= drivername drivermode */
- /* */
- /* in the 'autoexec.bat' this routine will use that to "detect" and */
- /* initialize the driver named 'drivername' in the mode 'drivermade'. */
- /* This selection may be overridden either by specifying a specific */
- /* builtin driver or by passing the name of the driver to detect. */
- /* */
- /* int universal_initgraph( */
- /* char *driver_name, Name of user driver to use. */
- /* int *driver_no, Either DETECT (if autodetection is */
- /* wanted, or the # of the internal */
- /* driver to use. */
- /* int *mode, Mode to init driver to. */
- /* char *path Path containing the driver. */
- /* ); */
- /* */
- /* This routine either returns zero, or it will return -1 if the */
- /* enviroment variable BGIDRIVER is badly formed. */
- /* */
- /* Copyright 1990 Robert Adsett. This routine may be freely used as */
- /* long as an appropriate acknowledgement is made. */
- /* */
- /* V 1.00 18/05/90 R. Adsett Original Version. */
- /************************************************************************/
-
- #include <graphics.h>
-
- static int DetectMode; /* Mode for detect routine to use. */
-
- /* Autodetect routine, tell kernal to init to' DetectMode'. */
- static int huge Universal_Auto_Detect( void )
- {
-
- return( DetectMode);
- }
-
- int universal_initgraph( /* Initialize to (possible) user driver.*/
- char *driver_name, /* Name of user driver to use. */
- int *driver_no, /* Either DETECT (if autodetection is */
- /* wanted, or the # of the internal */
- /* driver to use. */
- int *mode, /* Mode to init driver to. */
- char *path /* Path containing the driver. */
- )
- {
- char new_driver[8];
-
- if( *driver_no == DETECT) /* Auto detect wanted. */
- {
- /* If no driver name is provided attempt to get one from the */
- /* environment. If there is not one there either, a */
- /* conventional autodect will be done. If a driver name is */
- /* found somewhere it is installed via 'installuserdriver()'. */
- if( driver_name == NULL)
- {
- if( (driver_name = getenv( "BGIDRIVER")) != NULL)
- {
- if( sscanf( driver_name, "%s %d", new_driver, &DetectMode)
- != 2)
- {
- return( -1);
- }
- installuserdriver( new_driver, Universal_Auto_Detect);
- }
- }
- else
- {
- DetectMode = *mode;
- installuserdriver( driver_name, Universal_Auto_Detect);
- }
- }
- initgraph( driver_no, mode, path); /* Init. */
- return( 0);
- }
-
-
-