⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 diskinfo.c

📁 Dos6.0
💻 C
📖 第 1 页 / 共 3 页
字号:
          if (++wDrivesThisLine > MAX_DRIVES_PER_LINE)
            {
              wDrivesThisLine = 1;

              /* Is there another line that we can use */
              if (++i > 1)
                {
                  /* There are more drives than will fit on   */
                  /*   summary screen.  Put "..." at the end. */
                  /*
                  wNmbrChars = strlen (szSumStrings[1]);
                  szSumStrings[1][wNmbrChars - 4] = '\0';
                  strcat (szSumStrings[1], "...");
                  */
                  return (NULL);
                }
              else
                szSumStrings[i][0] = '\0';
            }

          strncat (szSumStrings[i], chBuffer,
                   MAX_SUMM_INFO - strlen (szSumStrings[0]));
        }

      return (NULL);
    }


  /* Calculate the amount of space required for the strings */

  wNmbrStrings = pDisk->wNmbrDrives + 3;

  for (i = 0; i < pDisk->wNmbrDrives; ++i)
    {
      if (pDisk->asdi[i].wCylinders > 0 ||
          pDisk->asdi[i].wHeads > 0)
        ++wNmbrStrings;

      if (pDisk->asdi[i].wBytesPerSector > 0 ||
          pDisk->asdi[i].wSectorsPerTrack > 0)
        ++wNmbrStrings;

      if (pDisk->asdi[i].wDriveType == DISK_FIXED_DISK)
        {
          /* If the CMOS settings do not match, display the lines. */
          /*   The CMOS cylinders can be off by 2.                 */

          if (!((pDisk->asdi[i].wCylinders      ==
                 pDisk->asdi[i].wCmosCylinders)     ||
                (pDisk->asdi[i].wCylinders + 1  ==
                 pDisk->asdi[i].wCmosCylinders)     ||
                (pDisk->asdi[i].wCylinders + 2  ==
                 pDisk->asdi[i].wCmosCylinders)     &&
                pDisk->asdi[i].wHeads           ==
                pDisk->asdi[i].wCmosHeads           &&
                pDisk->asdi[i].wSectorsPerTrack ==
                pDisk->asdi[i].wCmosSectorsPerTrack))
            {
              wNmbrStrings += 3;
            }
        }
    }
  if (pDisk->fJoinInstalled)
    ++wNmbrStrings;

  if (pDisk->fSubstInstalled)
    ++wNmbrStrings;

  if (pDisk->fShareInstalled)
    ++wNmbrStrings;

  if (pDisk->fAssignInstalled)
    ++wNmbrStrings;

  if (pDisk->fAppendInstalled)
    ++wNmbrStrings;

  if (pDisk->wMscdexMajor != 0)
    ++wNmbrStrings;


  wUnderlineLength = strlen (pszDiskUnderline);

  wNmbrChars   = wNmbrStrings * (wUnderlineLength + 1);


  /* Allocate space for the pointer area and string area */
  pqszStrings = AllocStringSpace (wNmbrStrings, wNmbrChars);
  if (pqszStrings == NULL)
    return (NULL);


  /* Put the first two strings in place */

  Qstrcpy (pqszStrings[0], pszDiskHeader);
  pqszStrings[1] = pqszStrings[0] + Qstrlen (pqszStrings[0]) + 1;

  Qstrcpy (pqszStrings[1], pszDiskUnderline);
  pqszStrings[2] = pqszStrings[1] + wUnderlineLength + 1;


  /* Put the Disk information in place */

  for (i = 2, wDriveIndex = 0; wDriveIndex < pDisk->wNmbrDrives;
       ++i, ++wDriveIndex)
    {
      WORD wLength;       /* Current length of string        */


      /* Clear out the string */
      Qmemset (pqszStrings[i], ' ', wUnderlineLength);
      pqszStrings[i][wUnderlineLength] = '\0';


      /* Drive Letter */
      wLength = sprintf (chBuffer, "%c:",
                         pDisk->asdi[wDriveIndex].chDriveLetter);
      Qstrncpy (&pqszStrings[i][DISK_DRIVE_COL], chBuffer, wLength);


      /* Type */
      Qstrncpy (&pqszStrings[i][DISK_TYPE_COL],
               pDisk->asdi[wDriveIndex].szDriveType,
               strlen (pDisk->asdi[wDriveIndex].szDriveType));


      /* Free Space */
      if (pDisk->asdi[wDriveIndex].dwFreeBytes > (DWORD) 0 ||
          pDisk->asdi[wDriveIndex].dwTotalBytes > (DWORD) 0)
        {
          if (pDisk->asdi[wDriveIndex].dwFreeBytes > 9000000L)
            wLength = sprintf (chBuffer, "%9luM",
                          pDisk->asdi[wDriveIndex].dwFreeBytes / (1024L * 1024L));
          else
            wLength = sprintf (chBuffer, "%9luK",
                          pDisk->asdi[wDriveIndex].dwFreeBytes / 1024);
          Qstrncpy (&pqszStrings[i][DISK_FREE_SPACE_COL], chBuffer, wLength);
        }


      /* Total Free */
      if (pDisk->asdi[wDriveIndex].dwTotalBytes > (DWORD) 0)
        {
          if (pDisk->asdi[wDriveIndex].dwTotalBytes > 9000000L)
            wLength = sprintf (chBuffer, "%9luM",
                          pDisk->asdi[wDriveIndex].dwTotalBytes / (1024L * 1024L));
          else
            wLength = sprintf (chBuffer, "%9luK",
                          pDisk->asdi[wDriveIndex].dwTotalBytes / 1024);
          Qstrncpy (&pqszStrings[i][DISK_TOTAL_FREE_COL], chBuffer, wLength);
        }


      /* Prep the current and next strings */
      PrepNextString (pqszStrings, i);


      /* Cylinders / Heads line */

      if (pDisk->asdi[wDriveIndex].wCylinders > 0 ||
          pDisk->asdi[wDriveIndex].wHeads > 0)
        {
          /* Next string */
          ++i;


          /* Clear out the string */
          Qmemset (pqszStrings[i], ' ', DISK_EXTRA_INFO_COL);
          pqszStrings[i][DISK_EXTRA_INFO_COL] = '\0';


          /* Cylinders */
          if (pDisk->asdi[wDriveIndex].wCylinders > 0)
            {
              sprintf (chBuffer, pszCylinders,
                       pDisk->asdi[wDriveIndex].wCylinders);
              Qstrcat (pqszStrings[i], chBuffer);
            }


          /* Comma space */
          if (pDisk->asdi[wDriveIndex].wCylinders > 0 &&
              pDisk->asdi[wDriveIndex].wHeads > 0)
            Qstrcat (pqszStrings[i], pszCommaSpace);


          /* Heads */
          if (pDisk->asdi[wDriveIndex].wHeads > 0)
            {
              sprintf (chBuffer, pszHeads,
                       pDisk->asdi[wDriveIndex].wHeads);
              Qstrcat (pqszStrings[i], chBuffer);
            }


          /* Prep the current and next strings */
          PrepNextString (pqszStrings, i);
        }


      /* Bytes per sector / Sectors per track line */

      if (pDisk->asdi[wDriveIndex].wBytesPerSector > 0 ||
          pDisk->asdi[wDriveIndex].wSectorsPerTrack > 0)
        {
          /* Next string */
          ++i;


          /* Clear out the string */
          Qmemset (pqszStrings[i], ' ', DISK_EXTRA_INFO_COL);
          pqszStrings[i][DISK_EXTRA_INFO_COL] = '\0';


          /* Bytes per sector */
          if (pDisk->asdi[wDriveIndex].wBytesPerSector > 0)
            {
              sprintf (chBuffer, pszBytesPerSector,
                       pDisk->asdi[wDriveIndex].wBytesPerSector);
              Qstrcat (pqszStrings[i], chBuffer);
            }


          /* Comma space */
          if (pDisk->asdi[wDriveIndex].wBytesPerSector > 0 &&
              pDisk->asdi[wDriveIndex].wSectorsPerTrack > 0)
            Qstrcat (pqszStrings[i], pszCommaSpace);


          /* Sectors per track */
          if (pDisk->asdi[wDriveIndex].wSectorsPerTrack > 0)
            {
              sprintf (chBuffer, pszSectorsPerTrack,
                       pDisk->asdi[wDriveIndex].wSectorsPerTrack);
              Qstrcat (pqszStrings[i], chBuffer);
            }


          /* Prep the current and next strings */
          PrepNextString (pqszStrings, i);
        }

      /* If this is a fixed disk, check the CMOS settings */
      if (pDisk->asdi[wDriveIndex].wDriveType == DISK_FIXED_DISK)
        {
          /* If the CMOS settings do not match, display the lines. */
          /*   The CMOS cylinders can be off by 2.                 */

          if (!((pDisk->asdi[wDriveIndex].wCylinders      ==
                 pDisk->asdi[wDriveIndex].wCmosCylinders)     ||
                (pDisk->asdi[wDriveIndex].wCylinders + 1  ==
                 pDisk->asdi[wDriveIndex].wCmosCylinders)     ||
                (pDisk->asdi[wDriveIndex].wCylinders + 2  ==
                 pDisk->asdi[wDriveIndex].wCmosCylinders)     &&
                pDisk->asdi[wDriveIndex].wHeads           ==
                pDisk->asdi[wDriveIndex].wCmosHeads           &&
                pDisk->asdi[wDriveIndex].wSectorsPerTrack ==
                pDisk->asdi[wDriveIndex].wCmosSectorsPerTrack))
            {
              /* Clear out the string */
              Qmemset (pqszStrings[++i], ' ', wUnderlineLength);
              pqszStrings[i][wUnderlineLength] = '\0';


              /* CMOS title */
              Qstrcpy (&pqszStrings[i][DISK_TYPE_COL],
                      "CMOS Fixed Disk Parameters");
              PrepNextString (pqszStrings, i++);

              /* Clear out the string */
              Qmemset (pqszStrings[i], ' ', DISK_EXTRA_INFO_COL);
              pqszStrings[i][DISK_EXTRA_INFO_COL] = '\0';


              /* Cylinders */
              sprintf (chBuffer, pszCylinders,
                       pDisk->asdi[wDriveIndex].wCmosCylinders);
              Qstrcat (pqszStrings[i], chBuffer);
              Qstrcat (pqszStrings[i], pszCommaSpace);

              /* Heads */
              sprintf (chBuffer, pszHeads,
                       pDisk->asdi[wDriveIndex].wCmosHeads);
              Qstrcat (pqszStrings[i], chBuffer);


              /* Next line */
              PrepNextString (pqszStrings, i++);

              /* Clear out the string */
              Qmemset (pqszStrings[i], ' ', DISK_EXTRA_INFO_COL);
              pqszStrings[i][DISK_EXTRA_INFO_COL] = '\0';


              /* Sectors per track */
              sprintf (chBuffer, pszSectorsPerTrack,
                       pDisk->asdi[wDriveIndex].wCmosSectorsPerTrack);
              Qstrcat (pqszStrings[i], chBuffer);

              PrepNextString (pqszStrings, i);
            }
        }
    }


  /* JOIN */
  if (pDisk->fJoinInstalled)
    {
      /* Clear out the string */
      pqszStrings[i][0] = '\0';

      Qstrcat (pqszStrings[i], pszJoinInstalled);

      /* Prep the current and next strings */
      PrepNextString (pqszStrings, i++);
    }


  /* SUBST */
  if (pDisk->fSubstInstalled)
    {
      /* Clear out the string */
      pqszStrings[i][0] = '\0';

      Qstrcat (pqszStrings[i], pszSubstInstalled);

      /* Prep the current and next strings */
      PrepNextString (pqszStrings, i++);
    }


  /* SHARE */
  if (pDisk->fShareInstalled)
    {
      /* Clear out the string */
      pqszStrings[i][0] = '\0';

      Qstrcat (pqszStrings[i], pszShareInstalled);

      /* Prep the current and next strings */
      PrepNextString (pqszStrings, i++);
    }


  /* ASSIGN */
  if (pDisk->fAssignInstalled)
    {
      /* Clear out the string */
      pqszStrings[i][0] = '\0';

      if (pDisk->atAssignTable[0].chAssignTo == '\0')
        Qstrcat (pqszStrings[i], pszAssignInstalled);
      else
        {
          WORD u;   /* Looping variable */

          Qstrcat (pqszStrings[i], pszAssign);

          /* List the ASSIGNed drive letters */
          for (u = 0; pDisk->atAssignTable[u].chAssignTo != '\0'; ++u)
            {
              sprintf (chBuffer, " %c:=%c:",
                       pDisk->atAssignTable[u].chAssignTo + 'A' - 1,
                       pDisk->atAssignTable[u].chAssignFrom + 'A' - 1);

              Qstrcat (pqszStrings[i], chBuffer);
            }
        }

      /* Prep the current and next strings */
      PrepNextString (pqszStrings, i++);
    }


  /* APPEND */
  if (pDisk->fAppendInstalled)
    {
      /* Clear out the string */
      pqszStrings[i][0] = '\0';

      if (pDisk->szAppendPath[0] == '\0')
        Qstrcat (pqszStrings[i], pszAppendInstalled);
      else
        {
          Qstrcat (pqszStrings[i], pszAppendPath);
          Qstrcat (pqszStrings[i], pDisk->szAppendPath);
        }

      /* Prep the current and next strings */
      PrepNextString (pqszStrings, i++);
    }


  /* MSCDEX */
  if (pDisk->wMscdexMajor != 0)
    {
      /* Clear out the string */
      pqszStrings[i][0] = '\0';

      /* Special case for MSCDEX 1.x */
      if (pDisk->wMscdexMinor == 0xFF)
        sprintf (chBuffer, pszMscdex1x, pDisk->wMscdexMajor);
      else
        sprintf (chBuffer, pszMscdexInstalled, pDisk->wMscdexMajor,
                 pDisk->wMscdexMinor);

      Qstrcat (pqszStrings[i], chBuffer);

      /* Prep the current and next strings */
      PrepNextString (pqszStrings, i++);
    }


  /* LASTDRIVE */

  /* Clear out the string */
  pqszStrings[i][0] = '\0';

  sprintf (chBuffer, pszLastdrive, pDisk->chLastDrive);
  Qstrcat (pqszStrings[i], chBuffer);


  /* Set the last pointer to a NULL */
  pqszStrings[++i] = NULL;

  /* Return the pointer to pqszStrings */
  return (pqszStrings);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -