📄 data.c
字号:
/* RETURNS: char * - Ptr to sting or NULL if no more strings */
/* */
/***************************************************************************/
char *GetDataString( int Type, int Index )
{
return ( (Type < 0 || Type >= END_CLASS || Data[ Type ] == NULL) ?
NULL : *(Data[ Type ] + Index) );
}
/***************************************************************************/
/* Returns an array of ptrs to all of the strings in the specified class. */
/* Returns NULL ptr if argument is not a valid class. */
/* */
/* Valid class type are the enunerated values defined by "UpgradeData". */
/* */
/* char **GetClassList( int Type ) */
/* */
/* ARGUMENTS: Type - Specifies the data class to array to return */
/* RETURNS: char ** - Array of ptrs to strings in the specified class */
/* */
/***************************************************************************/
char **GetClassList( int Type )
{
return ( (Type < 0 || Type >= END_CLASS || Data[ Type ] == NULL) ?
NULL : Data[ Type ] );
}
/***************************************************************************/
/* Returns the distribution disk type where 1=360K, 2 = 720K, 3 = 1.2meg, */
/* 4 = 1.44meg */
/* */
/* void GetDistrDiskType( int iType ) */
/* */
/* ARGUMENTS: void */
/* RETURNS: void */
/* */
/***************************************************************************/
int GetDistrDiskType( void )
{
return( iDiskType );
}
/***************************************************************************/
/* Returns the total number of distrubution disks for the upgrade. */
/* */
/* int GetNumberDisks( void ) */
/* */
/* ARGUMENTS: NONE */
/* RETURNS: int - Total number of distribution disks */
/* */
/***************************************************************************/
int GetNumberDisks( void )
{
return ( GetNumberStrings( Data[ USER_LABEL ] ) );
}
/***************************************************************************/
/* Returns a ptr to a disk label string for the specified disk. No error */
/* checking is done for disk number. */
/* */
/* char *GetDiskLabel( int iDiskNum ) */
/* */
/* ARGUMENTS: iDiskNum - File seqence number */
/* RETURNS: char * - Ptr to label string */
/* */
/***************************************************************************/
char *GetDistribLabel( int iDiskNum )
{
return( GetDataString( DIST_LABEL, iDiskNum) );
}
/***************************************************************************/
/* Returns a ptr to a prompt string for the specified distribution disk. */
/* No error checking is done for disk type or prompt number. */
/* */
/* char *GetDiskPrompt( int iDiskNum ) */
/* */
/* ARGUMENTS: iDiskNum - File seqence number */
/* RETURNS: char * - Ptr to prompt string */
/* */
/***************************************************************************/
char *GetDistribPrompt( int iDiskNum )
{
return( GetDataString( PROMPT, iDiskNum) );
}
/***************************************************************************/
/* Returns a ptr to a prompt string for the specified user supplied disk. */
/* No error checking is done for disk type or prompt number. */
/* */
/* char *GetDiskPrompt( int iDiskNum ) */
/* */
/* ARGUMENTS: iDiskNum - File seqence number */
/* RETURNS: char * - Ptr to prompt string */
/* */
/***************************************************************************/
char *GetUserPrompt( int iDiskNum )
{
return( GetDataString( USER_PROMPT, iDiskNum) );
}
/***************************************************************************/
/* Returns a ptr to a prompt string for the specified disk. No error */
/* checking is done for disk number. */
/* */
/* char *GetUserLabel( int iDiskNum ) */
/* */
/* ARGUMENTS: iDiskNum - File seqence number */
/* RETURNS: char * - Ptr to label string */
/* */
/***************************************************************************/
char *GetUserLabel( int iDiskNum )
{
return( GetDataString( USER_LABEL, iDiskNum ) );
}
/***************************************************************************/
/* Returns a ptr to the specified file on the specified disk. The name is */
/* directly from the DosData file and is not translated. Error checking */
/* is done to be sure the disk number is valid but there is no checking */
/* done on the file number but if caller gets the files name using a valid */
/* sequence a NULL ptr will be returned to signal the end of the list. */
/* */
/* char *GetFileName( int iDisk, iFile ) */
/* */
/* ARGUMENTS: Disk - Distribution disk number */
/* iFile - File seqence number */
/* RETURNS: char * - Ptr to file name or NULL if invalid file # */
/* */
/***************************************************************************/
char *GetFileName( int iDisk, int iFile )
{
if (iDisk < 0)
{
/* This is maintenance mode -- get the file */
/* from the optional components list. */
/* No error checking is performed. */
return (GetDataString (-iDisk, iFile));
}
else
{
/* This is for non-maintenance mode */
iDisk += DISK_0;
return ((iDisk >= DISK_0 && iDisk < END_CLASS) ?
GetDataString (iDisk, iFile) : NULL);
}
}
/***************************************************************************/
/* Translates a file name based on the content of the data field RENAME */
/* and NO_COPY from the data file. The return ptr will be the correct name */
/* to be used when creating it on the user's disk. If the file is marked */
/* don't copy a NULL ptr will be returned. The order of precedence is */
/* NO_COPY then GLOBAL_RENAME. */
/* */
/* Updated 08/21/90 to return NULL if floppy upgrade and the file is a net */
/* upgrade file. */
/* */
/* char *GetRealDestName ( char *szFileName ) */
/* */
/* ARGUMENTS: szFileName - Ptr to name of file to translate */
/* RETURNS: char * - Ptr to correct file name for destination file */
/* */
/***************************************************************************/
char *GetRealDestName( char *szFileName )
{
register i;
char *szString;
/* See if file in in the NO_COPY list */
if ( FindDataMatch( szFileName, NO_INSTALL ) )
return( NULL );
/* Now check for drivers which may not */
/* need copying and net update files */
if ( Data[ DRIVER_VERSION ] != NULL &&
((i = StrSearch( szFileName, Data[ DRIVER_VERSION ] )) != -1 &&
vInfo.NoCopy[ (UINT)i >> 1 ] == TRUE) )
{
#if defined(UPGRADE_PROGRAM) || defined(RECOVERY_PROGRAM)
// If HIMEM.SYS, check if we copy it anyway even though there's already
// an existing XMS driver active (we won't update CONFIG.SYS though).
//
if ((i>>1) != NO_HIMEM && (i>>1) != NO_EMM386)
return ( NULL );
#else
return (NULL);
#endif
}
#if defined(UPGRADE_PROGRAM) || defined(RECOVERY_PROGRAM)
/* Update only Microsoft DOS Mouse drivers */
/* BUGBUG - this should be handled via the vInfo.NoCopy array in */
/* the future. */
if (vInfo.Flag.fMouse == FALSE &&
stricmp (szFileName, "MOUSE.COM") == 0)
return (NULL);
#endif
#ifndef OEM_PROGRAM
if ( (!vInfo.Flag.fHardInstall || vInfo.chSource < vInfo.chFirstHd)
&& FindDataMatch( szFileName, NET_FILES ) )
return( NULL );
#endif
/* Now see if it get's renamed */
if ( (szString = TranslateString( GLOBAL_RENAME, szFileName )) != NULL )
return( szString );
else
return( szFileName );
}
/***************************************************************************/
/* Scans the DIF_PATH class to see if the specified file name is in the */
/* list. If the file name is found the new path associated with the */
/* file name is returned. If the file name is not found in the list the */
/* ptr to the default path is returned. */
/* */
/* Updated 09/21/90 to support a different path for network files which */
/* will be copied to a new directory in OLD_DOS.xxx. */
/* */
/* char *GetRealPath( char *szFile, char *szOldPath ) */
/* */
/* ARGUMENTS: szFile - Ptr to file name string */
/* szOldPath- Ptr to default path */
/* RETURNS: char * - Ptr to real path for specified file */
/* */
/***************************************************************************/
char *GetRealDestPath( char *szFile, char *szOldPath )
{
char *szNewPath;
szNewPath = TranslateString( DIF_PATH, szFile );
#ifndef OEM_PROGRAM
if ( szNewPath == NULL && vInfo.Flag.fHardInstall &&
FindDataMatch( szFile, NET_FILES ) )
szNewPath = vInfo.szNetDir + 3;
#endif
return( szNewPath != NULL ? szNewPath : szOldPath );
}
/***************************************************************************/
/* Scans the DISTRIB_X classes to see if the specified file name is in the */
/* list. If the file name is found the disk number associated with this */
/* file name is returned. If the file name is not found in the list the */
/* orignal disk number is returned. */
/* */
/* int GetRealDisk( char *szFile, int iDiskNum ) */
/* */
/* ARGUMENTS: szFile - Ptr to file name string */
/* iDiskNum - Default disk number */
/* RETURNS: int - Disk number for this disk or -1 if not found */
/* */
/***************************************************************************/
int GetRealSrcDisk( char *szFile, int iDiskNum )
{
register i;
register iEnd;
iEnd = DISTR_0 + MAX_NUM_DISKS;
for ( i = DISTR_0; i < iEnd && Data[ i ] != NULL; i++ )
{
if ( StrSearch( szFile, Data[ i ] ) != -1 )
{
iDiskNum = i - DISTR_0;
break;
}
}
return( iDiskNum );
}
/***************************************************************************/
/* Scans the specified class of translation strings for a string matching */
/* the arugment szString. If a match is found a ptr to the string */
/* associated with the matched string is return. If a match is not found */
/* a NULL ptr is returned. */
/* */
/* char *TranslateString( int Type, char *szString ) */
/* */
/* ARGUMENTS: Type - Specifies the data class to scan */
/* szString - Ptr to string to be translated */
/* RETURNS: char * - Ptr to new string if argument string was found */
/* in specified class else NULL ptr */
/* */
/***************************************************************************/
char *TranslateString( int Type, char *szString )
{
register i;
char *szMatch;
for( i = 0; (szMatch = GetDataString( Type, i)) != NULL; i += 2 )
if ( strcmpi( szMatch, szString ) == OK )
{
szMatch = GetDataString( Type, ++i );
break;
}
return( szMatch );
}
/***************************************************************************/
/* Checks for a matching string in the specified OEM information class. */
/* */
/* int FindOemInfo( char *szString, int Type ) */
/* */
/* ARGUMENTS: szString - Ptr to a string */
/* RETURNS: int - TRUE string exists in the specifed class */
/* else FALSE */
/* */
/***************************************************************************/
int FindDataMatch( char *szString, int Type )
{
if ( Data[ Type ] == NULL )
return( FALSE );
else
return( StrSearch( szString, Data[ Type ] ) == -1 ? FALSE : TRUE );
}
/***************************************************************************/
/* Returns the total bytes that would be read plus bytes written when */
/* the specified disk is copied. */
/* */
/* long GetDiskBytes( iDiskNum ) */
/* */
/* ARGUMENTS: iDiskNum - Disk number to get bytes on (0 based) */
/* RETURNS: long - Total bytes */
/* */
/***************************************************************************/
long GetDiskBytes( int iDiskNum )
{
char *szByteStr;
szByteStr = GetDataString( DISK_BYTES, iDiskNum);
if ( szByteStr != NULL )
return( atol( szByteStr ) );
else
return( 0L );
}
/***************************************************************************/
#ifndef OEM_PROGRAM
/***************************************************************************/
/* Initializes the Data[ OEM_TABLE ] array with arrays of pointers to */
/* strings which describe all the information needed to search a series of */
/* files for a specific string to determine the user's OEM. Returns an */
/* array of pointers to the strings that specify this information. */
/* */
/* char **InitSearchData( int MajorVer, int MinorVer ) */
/* */
/* ARGUMENTS: MajorVer - DOS major version number */
/* MinorVer - DOS minor verison number */
/* RETURNS: char ** - Array of pointer to file,search,OEM strings */
/* or NULL if no information for this version */
/* */
/* Array format: */
/* */
/* "FILENAME.EXT" */
/* "string" */
/* "OEMNAME" */
/* "string" */
/* "OEMNAME */
/* "&&" */
/* "FILENAME.EXT" */
/* "string1" */
/* "OEMNAME" */
/* "string" */
/* "OEMNAME" */
/* NULL */
/* */
/***************************************************************************/
char **InitSearchData( int MajorVer, int MinorVer )
{
static char *szVer = "[0.00]";
struct DDR *Oem;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -