Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

233 lines
6.6 KiB

  1. /*
  2. * tools.h - Header file for accessing TOOLS.LIB routines
  3. * includes stdio.h and ctype.h
  4. *
  5. * 4/14/86 daniel lipkie added U_* flags for upd return values
  6. *
  7. * 31-Jul-1986 mz Add Connect definitions
  8. * 02-Dec-1986 bw Added DOS5 FindFirst buffer definition & A_ALL constant
  9. * 21-Jan-1987 bw Add DWORD define
  10. * Add PIPE_READ / PIPE_WRITE values
  11. * Add new rspawn return typedef
  12. * 27-Jan-1987 bw Make DOS 3 findType available to DOS 5
  13. * 18-Aug-1987 bw change .max to .vmax to make C 5.x happy
  14. * 08-Mar-1988 bw Copy WORD() and DWORD() to MAKE*()
  15. * 10-Mar-1988 mz Add LOADDS/EXPORT definitions
  16. * 12-May-1988 mz Add VECTOR typedef
  17. * 19-Aug-1988 mz Conditionally define TRUE/FALSE
  18. *
  19. * 03-Aug-1990 davegi Changed findType.attr & findType date/time stamps
  20. * from unsigned to unsigned short (OS/2 2.0)
  21. *
  22. * 02-Oct-1990 w-barry Modified the findType structure to use
  23. * FILEFINDBUF4 structure.
  24. *
  25. * 16-Nov-1990 w-barry Updated the FILE_XXXXX defines to the Win32
  26. * standard.
  27. *
  28. * 21-Nov-1990 w-barry Redefined FindType to use the Win32 structure.
  29. *
  30. */
  31. #include "config.h"
  32. #if !defined (FALSE)
  33. #define FALSE 0
  34. #endif
  35. #if !defined (TRUE)
  36. #define TRUE (!FALSE)
  37. #endif
  38. #if MSDOS
  39. #define PSEPSTR "\\"
  40. #define PSEPCHR '\\'
  41. #else
  42. #define PSEPSTR "/"
  43. #define PSEPCHR '/'
  44. #endif
  45. #if !defined( _FLAGTYPE_DEFINED_ )
  46. typedef char flagType;
  47. #endif
  48. typedef long ptrType;
  49. #define SETFLAG(l,f) ((l) |= (f))
  50. #define TESTFLAG(v,f) (((v)&(f))!=0)
  51. #define RSETFLAG(l,f) ((l) &= ~(f))
  52. #define SHIFT(c,v) {c--; v++;}
  53. #if !defined(CW)
  54. #define WORD(h,l) ((LOW((h))<<8)|LOW((l)))
  55. #define DWORD(h,l) ((DLOW(h)<<16|DLOW(l)))
  56. #if !defined(MAKEWORD)
  57. #define MAKEWORD(l, h) ((LOW((h))<<8)|LOW((l)))
  58. #endif
  59. #if !defined(MAKELONG)
  60. #define MAKELONG(l, h) ((DLOW(h)<<16|DLOW(l)))
  61. #endif
  62. #endif
  63. #define LOW(w) ((int)(w)&0xFF)
  64. #define HIGH(w) LOW((int)(w)>>8)
  65. #define DLOW(l) ((long)(l)&0xFFFF)
  66. #define DHIGH(l) DLOW((long)(l)>>16)
  67. #define POINTER(seg,off) ((((long)(seg))<<4)+ (long)(off))
  68. #define FNADDR(f) (f)
  69. #define SELECT if(FALSE){
  70. #define CASE(x) }else if((x)){
  71. #define OTHERWISE }else{
  72. #define ENDSELECT }
  73. #define MAXARG 128 /* obsolete and begin deleted */
  74. #define MAXLINELEN 1024 /* longest line of input */
  75. #define MAXPATHLEN 260 /* longest filename acceptable */
  76. #define PIPE_READ 0
  77. #define PIPE_WRITE 1
  78. #define FILE_ATTRIBUTE_VOLUME_LABEL 0x00
  79. /*
  80. * This is the value returned by rspawnl. The PID field will always hold
  81. * the process ID of the background process. The in* fields will hold the
  82. * handles of the pipe attached to the new processes stdin, and the out*
  83. * fields correspond to stdout. If input/output from/to a pipe has not been
  84. * requested, the fields will be -1. The fields are ordered read-write
  85. * to allow a call pipe(&val.inReadHndl) or pipe(&val.outreadHndl).
  86. */
  87. struct spawnInfo {
  88. unsigned PID;
  89. int inReadHndl;
  90. int inWriteHndl;
  91. int outReadHndl;
  92. int outWriteHndl;
  93. };
  94. /* buffer description for findfirst and findnext
  95. When DOS 3 and DOS 5 version have the same field name, the field contains
  96. the same information
  97. DOS 5 version includes the directory handle
  98. */
  99. /***
  100. *
  101. * Old Style def'n
  102. *
  103. struct findType {
  104. unsigned type ;
  105. unsigned dir_handle ;
  106. unsigned short create_date ;
  107. unsigned short create_time ;
  108. unsigned short access_date ;
  109. unsigned short access_time ;
  110. unsigned short date ;
  111. unsigned short time ;
  112. long length ;
  113. long alloc ;
  114. unsigned long attr ;
  115. unsigned char nam_len ;
  116. char name[MAXPATHLEN] ;
  117. };
  118. *
  119. * ...end old def'n.
  120. *
  121. **/
  122. /*
  123. * NT Def'n
  124. */
  125. //struct findType {
  126. // unsigned type; /* type of object being searched */
  127. // unsigned dir_handle; /* Dir search handle for FindNext */
  128. // FILEFINDBUF4 fbuf; /* Aligned structure for Cruiser and NT */
  129. //};
  130. struct findType {
  131. unsigned type; /* type of object being searched */
  132. HANDLE dir_handle; /* Dir search handle for FindNext */
  133. long attr; /* File attributes */
  134. WIN32_FIND_DATA fbuf; /* Aligned structure for Cruiser and NT */
  135. };
  136. #define DWORD_SHIFT (sizeof(DWORD) * 8)
  137. #define FILESIZE(wfd) (((DWORDLONG)(wfd).nFileSizeHigh << DWORD_SHIFT) + (wfd).nFileSizeLow)
  138. #define FT_DONE 0xFF /* closed handle */
  139. #define FT_FILE 0x00 /* enumerating files */
  140. #define FT_SERV 0x01 /* enumerating servers */
  141. #define FT_SHAR 0x02 /* enumerating shares */
  142. #define FT_MASK 0xFF /* mask for type */
  143. #define FT_MIX 0x8000 /* mixed case supported flag */
  144. struct DOS3findType {
  145. char reserved[21]; /* reserved for start up */
  146. char attr; /* attribute found */
  147. unsigned time; /* time of last modify */
  148. unsigned date; /* date of last modify */
  149. long length; /* file size */
  150. char name[13]; /* asciz file name */
  151. };
  152. typedef struct findType FIND;
  153. typedef FIND near * NPFIND;
  154. // These attributes are redef'd from the previous hard coded versions.
  155. /* attributes */
  156. //#define A_RO FILE_ATTRIBUTE_READONLY /* read only */
  157. //#define A_H FILE_ATTRIBUTE_HIDDEN /* hidden */
  158. //#define A_S FILE_ATTRIBUTE_SYSTEM /* system */
  159. //#define A_V FILE_ATTRIBUTE_VOLUME_LABEL /* volume id */
  160. //#define A_D FILE_ATTRIBUTE_DIRECTORY /* directory */
  161. //#define A_A FILE_ATTRIBUTE_ARCHIVE /* archive */
  162. #define A_MOD ( FILE_ATTRIBUTE_READONLY + FILE_ATTRIBUTE_HIDDEN + FILE_ATTRIBUTE_SYSTEM + FILE_ATTRIBUTE_ARCHIVE) /* changeable attributes */
  163. //#define A_ALL (A_RO|A_H|A_S|A_V|A_D|A_A)
  164. #define A_ALL ( FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_VOLUME_LABEL )
  165. #define HASATTR(a,v) TESTFLAG(a,v) /* true if a has attribute v */
  166. extern char XLTab[], XUTab[];
  167. struct vectorType {
  168. int vmax; /* max the vector can hold */
  169. int count; /* count of elements in vector */
  170. UINT_PTR elem[1]; /* elements in vector */
  171. };
  172. typedef struct vectorType VECTOR;
  173. #include "parse.h"
  174. #include "exe.h"
  175. #include "fcb.h"
  176. #include "dir.h"
  177. #include "times.h"
  178. #include "ttypes.h"
  179. /* return flags for upd */
  180. #define U_DRIVE 0x8
  181. #define U_PATH 0x4
  182. #define U_NAME 0x2
  183. #define U_EXT 0x1
  184. /* Connect definitions */
  185. #define REALDRIVE 0x8000
  186. #define ISTMPDRIVE(x) (((x)&REALDRIVE)==0)
  187. #define TOKTODRV(x) ((x)&~REALDRIVE)
  188. /* Heap Checking return codes */
  189. #define HEAPOK 0
  190. #define HEAPBADBEGIN -1
  191. #define HEAPBADNODE -2