config.c
来自「Dos6.0」· C语言 代码 · 共 884 行 · 第 1/3 页
C
884 行
/* RETURNS: int - OK if successfull else ERROR */
/* */
/***************************************************************************/
/*lint -e715 */
int NewConfigFirst( int iStatus )
{
register i;
for ( i = 0; i < MAX_DEV_LINE; i++ )
DeviceLines[ i ] = NULL; /* Set line ptrs to NULL */
RamDriveCount = 0;
/* Add the line "DEVICE=X:\dos\SETVER.EXE" and any new drivers */
if ( (iStatus = AddNewDevice( "SETVER.EXE", DEVICE )) == OK )
iStatus = InstallNewDrivers();
return( iStatus );
} /*lint +e715 */
/***************************************************************************/
/* Adds any lines to the end of the config.sys file which need to be added */
/* or which needed to moved to the end of the file and frees any memory */
/* allocated for device line strings in DevicesLines[]. If status value arg*/
/* reflects an error the lines will not be written and only the allocated */
/* memory will be freed. */
/* */
/* int NewConfigLast( int iStatus ) */
/* */
/* ARGUMENTS: iStatus - Current processing status */
/* RETURNS: int - Original arg status if successfull else ERROR */
/* */
/***************************************************************************/
int NewConfigLast( int iStatus )
{
register i;
if ( !DevFlags.fHaveComspec ) /* See if shell= needs to be added */
{
DefaultShellLine( szNewString );
NewFilePuts( szNewString, NewFile );
}
/* See if Himem.sys needs to be added */
if ( vInfo.Hw.ExtMem >= HIMEM_K_SIZE )
DevFlags.fNeedHiMem = TRUE;
if ( vInfo.NoCopy[ NO_HIMEM ] == FALSE &&
(DevFlags.fNeedHiMem && !DevFlags.fHimem) )
MoveToEndFile( Devices[ HIMEMSYS ], HIMEMSYS );
if ( vInfo.Hw.VideoType == VIDEO_EGA && !DevFlags.fHaveEga )
MoveToEndFile( Devices[ EGASYS ], EGASYS );
for ( i = 0; i < MAX_DEV_LINE; i++ )
{
if ( DeviceLines[ i ] != NULL )
{
if ( iStatus == OK )
iStatus = AddNewDevice( DeviceLines[ i ], DEVICE );
FreeMemory( DeviceLines[ i ] );
}
}
if ( vInfo.Hw.ExtMem >= HIMEM_K_SIZE && !DevFlags.fHaveDosEqu )
iStatus = fputs( DOS_HIGH, NewFile );
return( iStatus );
}
/***************************************************************************/
/* Process a line in the config.sys file. Search for DEVICE= or SHELL= */
/* line and then calls function to process that line. If neither of these */
/* commands are detected the original string is copied to the new string */
/* buffer for adding to the new file. */
/* */
/* int ProcessConfigStr( void ) */
/* */
/* ARGUMENTS: NONE */
/* RETURNS: int - OK if sucessfull else ERROR to signal don't */
/* write this string to the new config.sys */
/* */
/***************************************************************************/
int ProcessConfigLine( int iStatus )
{
char *szPtr;
static char *ConfEntry[] = { "BUFFERS", "BREAK", "DEVICE", "DEVICEHIGH",
"FILES", "FCBS", "LASTDRIVE", "MULTITRACK",
"DRIVPARM", "STACKS", "COUNTRY", "SHELL",
"INSTALL", "COMMENT", "REM", "SWITCHES",
"DOS", NULL };
iStatus = OK;
szPtr = szOldString;
while ( *szPtr == ' ' || *szPtr == '\t' )
szPtr++;
/* szPtr = SkipLeadingWhite( szOldString ); */
ExtractNextWord( szPtr, szNewString, 25 ); /* Get the entry type */
strupr( szNewString );
szPtr = SkipWord( szPtr ); /* Skip to device name */
if ( *szPtr != EOL ) /* Check for null str */
{
/* Check for "DOS=" */
if ( strcmpi( szDosEqu, szNewString ) == OK )
{
DevFlags.fHaveDosEqu = TRUE;
strcpy( szNewString, szOldString );
iStatus = OK;
}
else if ( strcmpi( szDeviceEqu, szNewString ) == OK )
iStatus = ProcessDeviceLine( szPtr, DEVICE );
/* Check for "INSTALL=" */
else if ( strcmpi( szInstallEqu, szNewString ) == OK )
iStatus = ProcessDeviceLine( szPtr, INSTALL );
else if ( strcmpi( szLoadHiEqu, szNewString ) == OK )
iStatus = ProcessDeviceLine( szPtr, LOAD_HIGH );
/* Check for "SHELL=" */
else if ( strcmpi( szShellEqu, szNewString ) == OK )
iStatus = ProcessShellLine( szPtr );
/* Check for invalid entry */
else if ( StrSearch( szNewString, ConfEntry ) == -1 &&
*szNewString != EOL )
iStatus = REM_LINE;
else /* Using existing string */
strcpy( szNewString, szOldString );
}
return( iStatus );
}
/***************************************************************************/
/* Processes the SHELL= line from the config.sys. If the command file */
/* name is COMMAND the path to it will be removed and any reload path will */
/* be removed. This will force it to always be loaded from the root dir. */
/* Any existing parameters for /e or /p will be used in the new string. */
/* */
/* int ProcessShellLine( char *szStr ) */
/* */
/* ARGUMENTS: szStr - Ptr to device pathname */
/* RETURNS: void */
/* */
/***************************************************************************/
static int near ProcessShellLine( char *szString )
{
char *szPtr;
char *szOpts;
strcpy( szNewString, szShell ); /* Copy "SHELL=" */
szPtr = strchr( szNewString, EOL );
BuildPath( szPtr, HD_BOOT_DRV, vInfo.szPath + 2, szCommandShell );
szPtr = strchr( szNewString, EOL );
BuildPath( szPtr, HD_BOOT_DRV, vInfo.szPath + 2, " " );
/* If the existing shell is COMMAND.COM we have to check */
/* the /E: switch and if found copy it to the new string */
szPtr = ParseFileName( szString ); /* Get original comspec file */
if ( strnicmp( szPtr, szCommandShell, 11 ) == OK )
{
if ( (szPtr = strchr( szPtr, '/' )) != NULL )
{
do /* Loop looking at all switches but only save the /E switch */
{
szOpts = strchr( szNewString, EOL );
szPtr++; /* Ptr to option */
if ( UCASE_E == toupper( *szPtr ) )
{
*(szOpts++) = '/';
ExtractNextWord( szPtr, szOpts, 25 );
}
}
while ( (szPtr = strchr( szPtr, '/' )) != NULL );
}
}
strcat( szNewString, " /p" );
DevFlags.fHaveComspec = TRUE;
return( OK );
}
/***************************************************************************/
/* Processes the DEVICE= line from the config.sys. Changes the paths for */
/* devices or deletes the entry based on entries in the dosdata file. The */
/* new SMARTDRV, EMM386 and RAMDRIVE need HIMEM installed to work so */
/* SMARTDRV and RAMDRIVE entries as copied to a buffer to be added at the */
/* end of the config file and if EMM386 is detected a line to load HIMEM */
/* will be added at the current location and the xma already installed */
/* flag will be set so it won't be added at the end if it is needed by */
/* smartdrive or ramdrive. */
/* */
/* NOTE: See the file SYS.DOC for an explaination of work done to support */
/* changes to RAMDRIVE, SMARTDRV and EMM386 which now require XMA. */
/* */
/* Changed to also process the INSTALL= lines */
/* Changed to cause any DEVICE=SETVER.EXE lines to be deleted */
/* */
/* int ProcessDeviceLine( char *szStr ) */
/* */
/* ARGUMENTS: szStr - Ptr to device pathname */
/* iType - Determine if device is DEVICE= or INSTALL= */
/* RETURNS: void */
/* */
/***************************************************************************/
int near ProcessDeviceLine( char *szStr, int iType )
{
char szDevName[25]; /* Storage for device file name */
char *szPtr; /* String ptr */
register i; /* Array index */
struct TmpFlags
{
unsigned fDelete :1; /* Delete current line */
unsigned fChangePath :1; /* Change path on this line */
unsigned fNoCopy :1; /* Already copied to szNewString */
}f;
*((unsigned *)(&f)) = 0;
szPtr = ParseFileName( szStr );
ExtractNextWord( szPtr, szDevName, 25 );
for ( i = 0; i < LAST_DEVICE; i++ )
if ( strnicmp( szDevName, Devices[i], (size_t)DeviceNameLen[i] ) == OK )
break;
switch( i )
{
case HIMEMSYS: /* Process "DEVICE=HIMEM.SYS" line */
case HIMEMDOS: /* M006: Process "DEVICE=HIMEM.DOS" line */
if ( DevFlags.fHimem != TRUE )
{
DevFlags.fHimem = TRUE;
if ( !vInfo.NoCopy[ NO_HIMEM ] )
{
/* Need to create a new name in case was HIMEM.DOS. */
memcpy( szPtr, HIMEM_SYS, strlen(szDevName) );
f.fChangePath = TRUE;
}
}
else
f.fDelete = TRUE;
break;
case SMARTDRV: /* Process "DEVICE=SMARTDRV.SYS" line */
if ( !vInfo.NoCopy[ NO_SMARTDRV ] )
{
if ( DevFlags.fSmartDrv ) /* Check for duplicate entry */
f.fDelete = TRUE;
else if ( !DevFlags.fHimem && /* If XMA not installed */
FindParam( szPtr, 'A' ) == FALSE ) /* Using EMM mem? */
{
DevFlags.fNeedHiMem = TRUE; /* If not need himem */
MoveToEndFile( szPtr, SMARTDRV );
f.fDelete = TRUE;
}
else
f.fChangePath = TRUE;
DevFlags.fSmartDrv = TRUE;
}
break;
case RAMDRIVE: /* Process "DEVICE=RAMDRIVE.SYS" line */
if ( !vInfo.NoCopy[ NO_RAMDRV ] )
{
if ( !DevFlags.fHimem && FindParam( szPtr, 'E' ) == TRUE )
{
MoveToEndFile( szPtr, RAMDRIVE + RamDriveCount );
f.fDelete = TRUE;
DevFlags.fNeedHiMem = TRUE;
RamDriveCount++;
}
else
f.fChangePath = TRUE;
}
break;
case EMM386SYS: /* Process "DEVICE=EMM386.SYS" line */
case EMM386DOS: /* M006: Process "DEVICE=EMM386.DOS" line */
case EMM386EXE: /* Process "DEVICE=EMM386.EXE" line */
if ( vInfo.NoCopy[ NO_EMM386 ] )
break;
else if ( DevFlags.fEmm386 ) /* Check for duplicate entries */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?