home *** CD-ROM | disk | FTP | other *** search
/ PC to Maximum / PC-na-maximum.bin / DriveSpeed / SRC / DRSP / DRSP.H < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-04  |  4.1 KB  |  152 lines

  1. /*
  2.  *  DRSP - DriveSpeed, version 3.10 (GPL FREEWARE)
  3.  *  Copyleft (l) Stanislav Sokolov, May 1998 and onwards.
  4.  *
  5.  *  This program is subject to GNU General Public License ver. 2 of June 1991
  6.  *  and any later version.
  7.  *
  8.  *  You may use this source with your programs, provided
  9.  *  due credits are given.
  10.  *
  11.  *  Contact the author by e-mail: stanislavs@hotmail.com
  12.  *
  13.  *  Internet:  http://members.tripod.com/~stanislavs/prog/prog.htm
  14.  */
  15.  
  16. #ifndef __DRSP_H
  17. #define __DRSP_H
  18.  
  19. #include <stdlib.h>
  20. #include <stdio.h>
  21. #include <string.h>
  22. #include <io.h>
  23. #include <time.h>
  24. #include <sys\stat.h>
  25.  
  26. #include <fcntl.h>
  27.  
  28. #include <conio.h>
  29. #include <dos.h>
  30. #include <bios.h>
  31. #include <dir.h>
  32. #include <signal.h>
  33.  
  34.  
  35. //Hardware return codes
  36. #define IGNORE  0
  37. #define RETRY   1
  38. #define ABORT   2
  39.  
  40. //Results table
  41. #define L1         "#│Test MB│Turns│  Write KB/Sec  │ Write MB/Min │   Read KB/Sec  │  Read MB/Min "
  42. #define L2         "─┼───────┼─────┼────────────────┼──────────────┼────────────────┼──────────────"
  43. #define DISK_STAT  "%c│ %#6.2f│ %3i │%#16.9f│%#14.9f│%#16.9f│%#14.9f\n"
  44. #define L3         "┌┴───────┴─────┴────┬───────────┴──────────────┴────────────────┴─────────────┐"
  45. #define FAS_STAT   "│ %02d.%02d.%4d, %02d:%02d │           FAS is %#9.3f operations per second         │\n"
  46. #define NO_FAS     "│ %02d.%02d.%4d, %02d:%02d │       Read-only mode - FAS test was not performed       │\n"
  47. #define L4         "└───────────────────┴─────────────────────────────────────────────────────────┘"
  48. #define DBL_LINE   "\n═════════════════════════════════════════════════════════════════════════════\n"
  49.  
  50. #define FILE_NAME "A:\\DRSPTEST.TMP"
  51.  
  52. #define MAX_FBUF 17
  53. #define MAX_PATH 81
  54.  
  55. //Exit values
  56. #define EX_OK            0
  57. #define EX_ABORT         1
  58. #define EX_NO_LOG        2
  59. #define EX_OPEN_ERR        3
  60. #define EX_WRITE_ERR    4
  61. #define EX_CLOSE_ERR    5
  62. #define EX_DEL_ERR        6
  63. #define EX_OLD_DOS        7
  64. #define EX_NO_MEM        8
  65. #define EX_MATH_ERR        9
  66. #define EX_BAD_DRV        10
  67. #define EX_BAD_SIZE        11
  68. #define EX_BAD_TURN        12
  69.  
  70.  
  71. enum Bool {False, True};
  72. enum Ro_mode {Off, Single, Multi};
  73.  
  74. extern int HError;
  75. extern Bool fError;
  76.  
  77. //This struct and union are used to find segment:offset of a pointer
  78. //(can also be used to find high and low int's of a long value)
  79. typedef struct{
  80.     int Low;
  81.     int High;
  82. } Long;
  83.  
  84. typedef union{
  85.     long Whole;
  86.     Long Part;
  87. }FindLong;
  88.  
  89.  
  90. typedef struct{
  91.     char Path[256];
  92.     unsigned long Size;
  93. } TestFile;
  94.  
  95. //A collection of data used in drive testing and reporting
  96. typedef struct{
  97.     char           Drive;
  98.     unsigned long Size;
  99.     float         TestSize;
  100.     unsigned int  Turns;
  101.     Ro_mode       RO;
  102.     Bool          Batch;
  103.     char         *LogFile;
  104. }TestData;
  105.  
  106. //Function prototypes
  107.  //drsp.c
  108. TestData ParseArg(int argc, char *argv[]);
  109. char Ask(const char *Prompt);
  110. void Abort(int Handle, const char *FName, const char *Msg, int status);
  111. void Info(Bool Help);
  112. void ClearCache(void);
  113. void nfree(void *ptr);
  114. void nexit(int status);
  115.  
  116.  //handlers.c
  117. void interrupt Brk(void);
  118. int FatalHandler(int errval, int ax, int bp, int si);
  119. void Trap(int sType);
  120.  
  121.  //getsinfo.c
  122. void ScanDrv(void);
  123. char GetDrive(void);
  124. unsigned long GetTestSize(TestData *TD);
  125. unsigned int GetTurns(void);
  126. Ro_mode SetRO(TestData TD);
  127. char *SearchRO(TestData *TD, TestFile TF[]);
  128. Bool DriveIsOK(char Drive);
  129. char *FindPath(char *Path);
  130. unsigned long ScanPath(unsigned long maxSize, const char *Path, char **RetPath, unsigned long biggest);
  131. unsigned long ScanPath(unsigned long maxSize, const char *Path, TestFile TF[]);
  132.  
  133.  //diags.c
  134. void DoTest(TestData TD, float *ReadSpd, float *WriteSpd); //RW
  135. float DoTest(char *RetPath, TestData TD);                  //RO m-pass
  136. float DoTest(TestFile TF[], unsigned long Size);           //RO s-pass
  137. float TestFAS(char Drive);                                 //File Access Speed
  138. float finddiff(struct time on, struct time off);
  139.  
  140.  //results.c
  141. void Analyze(TestData TD, float WriteSpd, float ReadSpd, float FAS);
  142. void Analyze(TestData TD, float ReadSpd);
  143. FILE *OpenLog(TestData TD, char *FName);
  144. //End of function prototypes
  145.  
  146. #endif
  147.  
  148.  
  149.  
  150.  
  151.  
  152.