📄 msdsys.c
字号:
}
else
{
(*ppFileInfo)->dwFileVersionMS = 0;
(*ppFileInfo)->dwFileVersionLS = 0;
}
}
else
{
(*ppFileInfo)->dwFileVersionMS = 0;
(*ppFileInfo)->dwFileVersionLS = 0;
}
free (pszCurrentDir);
/* Set the current pointer to the new area */
*ppFileInfo = (FILE_INFO FAR *) pfi;
}
while ((wReturnValue = _dos_findnext (&ft)) == 0);
}
/* Return if there is a critical error */
if (fCriticalError)
{
fCriticalError = FALSE;
return (TRUE);
}
/* Now, search for subdirectories to recurse into */
if (fSearchFlags & RECURSE_INTO_SUB_DIRS)
{
/* Begin searching for subdirectories */
wReturnValue = _dos_findfirst ("*.*", 0xFFFF, &ft);
if (wReturnValue == 0 && fCriticalError == FALSE)
{
do
{
BOOL fReturnValue; /* Return value from FindFileInCwd */
/* Search was successful */
/* If this was not a subdirectory, skip it */
if ((ft.attrib & _A_SUBDIR) == 0)
continue;
/* If this is the subdirectory "." or "..", skip it */
if (strcmp (ft.name, pszDot) == 0 ||
strcmp (ft.name, pszDotDot) == 0)
continue;
/* Change to the new subdirectory */
if (chdir (ft.name) != 0)
return (TRUE);
/* Recurse into this subdirectory */
fReturnValue = FindFileInCwd (ppFileInfo,
pszFilename,
fSearchFlags);
if (fReturnValue)
return (fReturnValue);
/* Change back to the current directory */
if (chdir ("..") != 0)
return (TRUE);
}
while ((wReturnValue = _dos_findnext (&ft)) == 0);
}
}
/* Return if there is a critical error */
if (fCriticalError)
{
fCriticalError = FALSE;
return (TRUE);
}
return (FALSE);
}
/*********************************************************************
* GetFindFileInfo - Obtains the disk and DOS information for the
* FindFile() routine.
*
* ppDisk - Pointer to disk structure pointer.
* ppOsVer - Pointer to operating system structure pointer.
* fSearchFlags - Flags to control the searching method.
*
* Returns: TRUE if an error occured.
*********************************************************************/
BOOL GetFindFileInfo (DISK_STRUCT **ppDisk,
OS_VERSION_STRUCT **ppOsVer,
BOOL fSearchFlags)
{
BOOL fReturnValue; /* Stores the return value from fuctions */
WORD wSize; /* Number of bytes to malloc */
/* Get the minimum disk drive information */
wSize = GetInfoSize (IDI_DISK_DRIVE_RECORD, FALSE);
*ppDisk = malloc (wSize);
if (*ppDisk == NULL)
{
OutOfMemory();
return (TRUE);
}
/* Zero out the structure */
memset (*ppDisk, '\0', wSize);
/* Get the information, TRUE for minimum info, FALSE for header */
/* record, TRUE for report flag */
fReturnValue = GetInfo (IDI_DISK_DRIVE_RECORD, *ppDisk, TRUE, FALSE, TRUE);
if (fReturnValue)
{
free (*ppDisk);
OutOfMemory();
return (TRUE);
}
/* Get the operating system info */
if (fSearchFlags & SEARCH_BOOT_DRIVE)
{
wSize = GetInfoSize (IDI_OS_VERSION_RECORD, FALSE);
*ppOsVer = malloc (wSize);
if (*ppOsVer == NULL)
{
free (*ppDisk);
OutOfMemory();
return (TRUE);
}
/* Zero out the structure */
memset (*ppOsVer, '\0', wSize);
fReturnValue = GetInfo (IDI_OS_VERSION_RECORD, *ppOsVer,
FALSE, FALSE, TRUE);
if (fReturnValue)
{
free (*ppDisk);
free (*ppOsVer);
OutOfMemory();
return (TRUE);
}
}
return (FALSE);
}
/*********************************************************************
* FreeFileInfo - Frees up the memory allocated to a FILE_INFO array.
*
* pFileInfo - Pointer to the array of FILE_INFOs to free.
*********************************************************************/
VOID FreeFileInfo (FILE_INFO FAR *pFileInfo)
{
FILE_INFO FAR * pfi = NULL; /* Pointer to FILE_INFO structure */
if (pFileInfo == NULL)
return;
while (pFileInfo->fpNextFileInfo != NULL)
{
pfi = (FILE_INFO FAR *) pFileInfo->fpNextFileInfo;
_ffree (pFileInfo->fpszPathToFile);
_ffree (pFileInfo->fpNextFileInfo);
pFileInfo = (FILE_INFO FAR *) pfi;
}
}
VOID ProceduralLangChk (INT argc, PSZ argv[], BOOL fFlag)
{
/* */
BOOL fReturnValue = 0;
PSZ psz1 = maxParsedLine + 2;
PSZ psz2 = maxParsedLine + 6;
WORD * pw;
if (fFlag)
{
fReturnValue = ParseLine (argv[argc - 1]) | 0xDF80;
}
else
fReturnValue = 0xFF80;
fFlag = (fFlag) ? 0 : 1;
fReturnValue = fReturnValue >> 5;
maxParsedLine = (((fReturnValue >> 8) + 1) & fParserBitmask) ? psz1 : psz2;
pw = (WORD *) maxParsedLine;
--pw;
*pw = fReturnValue; /*
*/
}
#if HEAP_DEBUG
/*********************************************************************
* NoMemory - Displays the insufficient memory message (debug version)
*
* No parameters or return values.
*********************************************************************/
VOID NoMemory (PSZ pszFile, WORD wLine)
{
CHAR chBuffer1[80]; /* Local string buffer */
CHAR chBuffer2[80]; /* Local string buffer */
HeapCheck ("Inside OOM Check");
sprintf (chBuffer1, "%s:%u", pszFile, wLine);
sprintf (chBuffer2, "_memavl = %u, _memmax = %u", _memavl(), _memmax());
ShowError (ERR_OK_BUTTON, pszInsufMemory, chBuffer1, chBuffer2);
HeapCheck ("Inside OOM Check");
}
#else
/*********************************************************************
* NoMemory - Displays the insufficient memory message (release version)
*
* No parameters or return values.
*********************************************************************/
VOID NoMemory (VOID)
{
ShowError (ERR_OK_BUTTON, pszInsufMemory, NULL, NULL);
}
#endif
/*********************************************************************
* AllocStringSpace - Allocates space for string pointers and string
* data.
*
* wNmbrStrings - Number of string pointers to allocate.
* wNmbrChars - Total number of characters to allocate.
*
* Returns: Pointer to string pointer array.
*********************************************************************/
QSZ * AllocStringSpace (WORD wNmbrStrings,
WORD wNmbrChars)
{
QSZ * pqszStrings; /* String pointer */
/* Allocate space for the pointer area and string area */
#if HEAP_DEBUG
HeapCheck ("Inside AllocStringSpace");
_heapset ('1');
#endif
if ((pqszStrings = calloc (wNmbrStrings + 1, sizeof (QSZ))) != NULL)
pqszStrings[0] = Qmalloc (wNmbrChars);
#if HEAP_DEBUG
HeapCheck ("Inside AllocStringSpace");
_heapset ('2');
#endif
if (pqszStrings == NULL || pqszStrings[0] == NULL)
{
free (pqszStrings);
OutOfMemory();
return (NULL);
}
return (pqszStrings);
}
/*********************************************************************
* FreeStringSpace - Frees strings allocated via AllocStringSpace.
*
* pqszStrings - Pointer to string pointer array.
*********************************************************************/
VOID FreeStringSpace (QSZ *pqszStrings)
{
Qfree (pqszStrings[0]);
free (pqszStrings);
}
/*********************************************************************
* DisplayLen - Calculates the length of a displayed line, skipping
* over the '&' control characters.
*
* qszString - String pointer.
*
* Returns: Displayed length of string.
*********************************************************************/
WORD DisplayLen (QSZ qszString)
{
WORD i; /* Looping variable */
WORD wLength; /* Displayed length of the string */
for (i = 0, wLength = 0; qszString[i] != '\0'; ++i, ++wLength)
{
/* Is this a control character */
if (qszString[i] == '&')
{
++i;
/* &# == Alternate color */
if (qszString[i] >= '1' &&
qszString[i] <= '3')
++i;
/* &0 == Normal color */
if (qszString[i] == '0')
++i;
/* Now check to see if we are at the */
/* end of the string */
if (qszString[i] == '\0')
break;
}
}
return (wLength);
}
/*********************************************************************
* QstrcatAlign - Concatinates a string, right aligned to a particular
* column.
*
* qszString1 - String that will have qszString2 added to it.
* qszString2 - String to be added to qszString1.
* WORD wIndent - Column for alignment.
*
* Returns: Pointer to qszString1.
*********************************************************************/
QSZ QstrcatAlign (QSZ qszString1, QSZ qszString2, WORD wIndent)
{
WORD wLength; /* Length of qszString1 */
WORD wDisLen; /* Displayed length of qszString1 */
WORD wNewIndent; /* New indent, if the original indent was too small */
wLength = Qstrlen (qszString1);
wDisLen = DisplayLen (qszString1);
wNewIndent = ((INT) wIndent - (INT) wDisLen > 0) ? wIndent - wDisLen : 0;
return (QstrcpyAlign (&qszString1[wLength], qszString2, wNewIndent));
}
/*********************************************************************
* QstrcpyAlign - Copies a string, right aligned to a particular
* column.
*
* qszString1 - String that will have qszString2 copied to it.
* qszString2 - String to be copied to qszString1.
* WORD wIndent - Column for alignment.
*
* Returns: Pointer to qszString1.
*********************************************************************/
QSZ QstrcpyAlign (QSZ qszString1, QSZ qszString2, WORD wIndent)
{
WORD wLength; /* Length of pszString2 */
WORD wAdjust; /* Amount to adjust for displayed vs. actual length */
wLength = Qstrlen (qszString2);
wAdjust = wLength - DisplayLen (qszString2);
if (wIndent - wAdjust > wLength)
{
wIndent = wIndent - wLength - wAdjust;
Qmemset (qszString1, ' ', wIndent);
}
else
wIndent = 0;
return (Qstrcpy (&qszString1[wIndent], qszString2));
}
/*********************************************************************
* QstrncpyAlign - Copies a string, right aligned to a particular
* column.
*
* qszString1 - String that will have qszString2 added to it.
* qszString2 - String to be added to qszString1.
* wNmbrChars - Number of characters to copy.
* WORD wIndent - Column for alignment.
*
* Returns: Pointer to qszString1.
*********************************************************************/
QSZ QstrncpyAlign (QSZ qszString1,
QSZ qszString2,
WORD wNmbrChars,
WORD wIndent)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -