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.

72 lines
1.7 KiB

  1. // Copyright (C) 1994-1997 Microsoft Corporation. All rights reserved.
  2. #if _MSC_VER > 1000
  3. #pragma once
  4. #endif
  5. #ifndef __CINPUT_H__
  6. #define __CINPUT_H__
  7. #include "cstr.h"
  8. class CHmData; // forward reference
  9. class CFSClient; // forward reference
  10. class CInput
  11. {
  12. public:
  13. CInput();
  14. CInput(LPCSTR pszFileName);
  15. ~CInput(void);
  16. BOOL Open(PCSTR pszFile, CHmData* phmData = NULL);
  17. void Close();
  18. HANDLE GetFileHandle() { return m_hfile; }
  19. BOOL isInitialized() ;
  20. BOOL getline(CStr* pcsz);
  21. protected:
  22. BOOL ReadNextBuffer(void);
  23. CFSClient* m_pfsClient;
  24. HANDLE m_hfile; // this will be non-NULL but invalid if m_pfsClient is used
  25. PBYTE m_pbuf; // allocated buffer for reading
  26. PBYTE m_pCurBuf; // current buffer location
  27. PBYTE m_pEndBuf; // buffer end position
  28. BOOL fFastRead; // TRUE if we can search for /r in getline
  29. };
  30. typedef struct {
  31. CInput* pin;
  32. PSTR pszBaseName;
  33. } AINPUT;
  34. const int MAX_NEST_INPUT = 20; // maximum nested include file
  35. class CAInput
  36. {
  37. public:
  38. CAInput() { m_curInput = -1; }
  39. ~CAInput() {
  40. while (m_curInput >= 0)
  41. Remove();
  42. }
  43. BOOL Add(PCSTR pszFile);
  44. BOOL Remove(void) {
  45. if (m_curInput >= 0) {
  46. lcFree(m_ainput[m_curInput].pszBaseName);
  47. delete m_ainput[m_curInput].pin;
  48. --m_curInput;
  49. }
  50. return (m_curInput >= 0);
  51. }
  52. BOOL getline(CStr* pcsz) { return m_ainput[m_curInput].pin->getline(pcsz); }
  53. PSTR GetBaseName(void) const { return m_ainput[m_curInput].pszBaseName; }
  54. protected:
  55. int m_curInput;
  56. AINPUT m_ainput[MAX_NEST_INPUT + 1];
  57. };
  58. #endif // __CINPUT_H__