bzfeof.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. /*
  10. * THIS FILE IS NOT IDENTICAL TO THE ORIGINAL
  11. * FROM THE BZIP2 DISTRIBUTION.
  12. *
  13. * It has been modified, mainly to break the library
  14. * into smaller pieces.
  15. *
  16. * Russ Cox
  17. * rsc@plan9.bell-labs.com
  18. * July 2000
  19. */
  20. /*-------------------------------------------------------------*/
  21. /*--- Library top-level functions. ---*/
  22. /*--- bzlib.c ---*/
  23. /*-------------------------------------------------------------*/
  24. /*--
  25. This file is a part of bzip2 and/or libbzip2, a program and
  26. library for lossless, block-sorting data compression.
  27. Copyright (C) 1996-2000 Julian R Seward. All rights reserved.
  28. Redistribution and use in source and binary forms, with or without
  29. modification, are permitted provided that the following conditions
  30. are met:
  31. 1. Redistributions of source code must retain the above copyright
  32. notice, this list of conditions and the following disclaimer.
  33. 2. The origin of this software must not be misrepresented; you must
  34. not claim that you wrote the original software. If you use this
  35. software in a product, an acknowledgment in the product
  36. documentation would be appreciated but is not required.
  37. 3. Altered source versions must be plainly marked as such, and must
  38. not be misrepresented as being the original software.
  39. 4. The name of the author may not be used to endorse or promote
  40. products derived from this software without specific prior written
  41. permission.
  42. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  43. OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  44. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  45. ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  46. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  47. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  48. GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  49. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  50. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  51. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  52. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  53. Julian Seward, Cambridge, UK.
  54. jseward@acm.org
  55. bzip2/libbzip2 version 1.0 of 21 March 2000
  56. This program is based on (at least) the work of:
  57. Mike Burrows
  58. David Wheeler
  59. Peter Fenwick
  60. Alistair Moffat
  61. Radford Neal
  62. Ian H. Witten
  63. Robert Sedgewick
  64. Jon L. Bentley
  65. For more information on these sources, see the manual.
  66. --*/
  67. /*--
  68. CHANGES
  69. ~~~~~~~
  70. 0.9.0 -- original version.
  71. 0.9.0a/b -- no changes in this file.
  72. 0.9.0c
  73. * made zero-length BZ_FLUSH work correctly in bzCompress().
  74. * fixed bzWrite/bzRead to ignore zero-length requests.
  75. * fixed bzread to correctly handle read requests after EOF.
  76. * wrong parameter order in call to bzDecompressInit in
  77. bzBuffToBuffDecompress. Fixed.
  78. --*/
  79. #include "os.h"
  80. #include "bzlib.h"
  81. #include "bzlib_private.h"
  82. #include "bzlib_stdio.h"
  83. #include "bzlib_stdio_private.h"
  84. Bool bz_feof ( FILE* f )
  85. {
  86. Int32 c = fgetc ( f );
  87. if (c == EOF) return True;
  88. ungetc ( c, f );
  89. return False;
  90. }