Leaked source code of windows server 2003
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.

69 lines
1.9 KiB

  1. /*****************************************************************************
  2. *
  3. * io.h
  4. *
  5. *****************************************************************************/
  6. #ifdef POSIX
  7. typedef int HF;
  8. #define hfNil (-1)
  9. #define hfIn 0
  10. #define hfOut 1
  11. #define hfErr 2
  12. #define hfOpenPtchOf open
  13. #define hfCreatPtch(p) creat(p, 0600)
  14. #define cbReadHfPvCb read
  15. #define cbWriteHfPvCb write
  16. #define CloseHf close
  17. #define OF_READ O_RDONLY
  18. #define OF_WRITE O_WRONLY
  19. #define fInteractiveHf isatty
  20. #define c_tszNullDevice TEXT("/dev/null")
  21. #else
  22. typedef HFILE HF;
  23. #define hfNil ((HF)HFILE_ERROR)
  24. #define hfIn ((HF)(UINT_PTR)GetStdHandle(STD_INPUT_HANDLE))
  25. #define hfOut ((HF)(UINT_PTR)GetStdHandle(STD_OUTPUT_HANDLE))
  26. #define hfErr ((HF)(UINT_PTR)GetStdHandle(STD_ERROR_HANDLE))
  27. #define hfOpenPtchOf _lopen
  28. #define hfCreatPtch(p) _lcreat(p, 0)
  29. #define cbReadHfPvCb _lread
  30. #define CloseHf _lclose
  31. #define c_tszNullDevice TEXT("nul")
  32. /*
  33. * _lwrite has the quirk that writing zero bytes causes the file
  34. * to be truncated. (Instead of just plain writing zero bytes.)
  35. */
  36. INLINE CB
  37. cbWriteHfPvCb(HF hf, PCVOID pv, CB cb) {
  38. if (cb) {
  39. return _lwrite(hf, pv, cb);
  40. } else {
  41. return 0;
  42. }
  43. }
  44. #define fInteractiveHf(hf) (GetFileType((HANDLE)IntToPtr(hf)) == FILE_TYPE_CHAR)
  45. #endif
  46. void STDCALL WriteHfPvCb(HF hf, PCVOID pv, CB cb);
  47. INLINE void
  48. WriteHfPtchCtch(HF hf, PCTCH ptch, CTCH ctch)
  49. {
  50. WriteHfPvCb(hf, ptch, cbCtch(ctch));
  51. }
  52. #ifdef POSIX
  53. UINT GetTempFileName(PCSTR, PCSTR, UINT, PTCH);
  54. #endif