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.

99 lines
1.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1997
  6. //
  7. // File: parsfile.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. //
  11. // parsfile.cpp
  12. //
  13. #include "basics.h"
  14. #include "parsfile.h"
  15. PARSIN :: ~ PARSIN ()
  16. {
  17. }
  18. PARSOUT :: ~ PARSOUT ()
  19. {
  20. }
  21. void PARSOUT :: Fprint ( SZC szcFmt, ... )
  22. {
  23. va_list valist;
  24. va_start( valist, szcFmt );
  25. Vsprint( szcFmt, valist ) ;
  26. va_end( valist );
  27. }
  28. PARSIN_DSC :: PARSIN_DSC ()
  29. :_pfile(NULL)
  30. {
  31. }
  32. PARSIN_DSC :: ~ PARSIN_DSC ()
  33. {
  34. Close();
  35. }
  36. void PARSIN_DSC :: Close ()
  37. {
  38. if ( _pfile )
  39. ::fclose(_pfile);
  40. _pfile = NULL;
  41. }
  42. bool PARSIN_DSC :: Open ( SZC szcFileName, SZC szcMode )
  43. {
  44. Close();
  45. _pfile = ::fopen(szcFileName,szcMode);
  46. _zsFn = szcFileName;
  47. return _pfile != NULL;
  48. }
  49. int PARSIN_DSC :: Getch ()
  50. {
  51. if ( ! _pfile )
  52. return EOF;
  53. return ::fgetc(_pfile);
  54. }
  55. bool PARSIN_DSC :: BEof ()
  56. {
  57. return feof(_pfile);
  58. }
  59. bool PARSIN_DSC :: BOpen ()
  60. {
  61. return _pfile != NULL;
  62. }
  63. PARSOUT_STD :: PARSOUT_STD ( FILE * pfile )
  64. : _pfile(pfile)
  65. {
  66. }
  67. PARSOUT_STD :: ~ PARSOUT_STD ()
  68. {
  69. _pfile = NULL;
  70. }
  71. void PARSOUT_STD :: Vsprint ( SZC szcFmt, va_list valist )
  72. {
  73. if ( _pfile == NULL )
  74. return;
  75. vfprintf( _pfile, szcFmt, valist );
  76. }
  77. void PARSOUT_STD :: Flush ()
  78. {
  79. if ( _pfile )
  80. fflush(_pfile);
  81. }