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.

36 lines
898 B

  1. #ifndef _CCSV
  2. #define _CCSV
  3. #include <windows.h>
  4. #define CCSVFILE_BUFFER_SIZE 2*512
  5. // simple file i/o for phone books
  6. class CCSVFile
  7. {
  8. public:
  9. void far * operator new( size_t cb ) { return GlobalAlloc(GPTR,cb); };
  10. void operator delete( void far * p ) {GlobalFree(p); };
  11. CCSVFile();
  12. ~CCSVFile();
  13. BOOLEAN Open(LPCSTR pszFileName);
  14. BOOLEAN ReadToken(LPSTR pszDest, DWORD cbMax); // reads up to comma or newline, returns fFalse on EOF
  15. void Close(void);
  16. inline int ILastRead(void)
  17. {
  18. return m_iLastRead;
  19. }
  20. private:
  21. BOOL FReadInBuffer(void);
  22. inline int ChNext(void);
  23. char m_rgchBuf[CCSVFILE_BUFFER_SIZE]; //buffer
  24. LPSTR m_pchBuf; //pointer to the next item in the buffer to read
  25. LPSTR m_pchLast; //pointer to the last item in the buffer
  26. int m_iLastRead; //the character last read.
  27. DWORD m_cchAvail;
  28. HANDLE m_hFile;
  29. }; // ccsv
  30. #endif //_CCSV