1. 33a34
  2. > #include <stdlib.h>
  3. 36,38c37,38
  4. < struct SCIP_File
  5. < {
  6. < gzFile file; /**< zlib file stream */
  7. ---
  8. > struct SCIP_File {
  9. > gzFile file; /**< zlib file stream */
  10. 41,43c41,50
  11. < SCIP_FILE* SCIPfopen(const char *path, const char *mode)
  12. < {
  13. < return (SCIP_FILE*)gzopen(path, mode);
  14. ---
  15. > SCIP_FILE *SCIPfopen(const char *path, const char *mode) {
  16. > gzFile f = gzopen(path, mode);
  17. >
  18. > if (f == NULL) {
  19. > return NULL;
  20. > } else {
  21. > SCIP_FILE *s = (SCIP_FILE *) malloc(sizeof(SCIP_FILE));
  22. > s->file = f;
  23. > return s;
  24. > }
  25. 46,48c53,62
  26. < SCIP_FILE* SCIPfdopen(int fildes, const char *mode)
  27. < {
  28. < return (SCIP_FILE*)gzdopen(fildes, mode);
  29. ---
  30. > SCIP_FILE *SCIPfdopen(int fildes, const char *mode) {
  31. > gzFile f = gzdopen(fildes, mode);
  32. >
  33. > if (f == NULL) {
  34. > return NULL;
  35. > } else {
  36. > SCIP_FILE *s = (SCIP_FILE *) malloc(sizeof(SCIP_FILE));
  37. > s->file = f;
  38. > return s;
  39. > }
  40. 51,53c65,66
  41. < size_t SCIPfread(void *ptr, size_t size, size_t nmemb, SCIP_FILE *stream)
  42. < {
  43. < return gzread((gzFile*)stream, ptr, size * nmemb);
  44. ---
  45. > size_t SCIPfread(void *ptr, size_t size, size_t nmemb, SCIP_FILE *stream) {
  46. > return gzread(stream->file, ptr, size * nmemb);
  47. 56,58c69,70
  48. < size_t SCIPfwrite(const void *ptr, size_t size, size_t nmemb, SCIP_FILE *stream)
  49. < {
  50. < return gzwrite((gzFile*)stream, ptr, size * nmemb);
  51. ---
  52. > size_t SCIPfwrite(const void *ptr, size_t size, size_t nmemb, SCIP_FILE *stream) {
  53. > return gzwrite(stream->file, ptr, size * nmemb);
  54. 61,65c73,80
  55. < int SCIPfprintf(SCIP_FILE *stream, const char *format, ...)
  56. < {
  57. < char buffer[BUFFER_LEN];
  58. < va_list ap;
  59. < int n;
  60. ---
  61. > int SCIPfprintf(SCIP_FILE *stream, const char *format, ...) {
  62. > char buffer[BUFFER_LEN];
  63. > va_list ap;
  64. > int n;
  65. >
  66. > va_start(ap, format); /*lint !e826*/
  67. > n = vsnprintf(buffer, BUFFER_LEN, format, ap);
  68. > va_end(ap);
  69. 67,72c82,86
  70. < va_start(ap, format); /*lint !e826*/
  71. < n = vsnprintf(buffer, BUFFER_LEN, format, ap);
  72. < va_end(ap);
  73. < if( n < 0 || n > BUFFER_LEN)
  74. < buffer[BUFFER_LEN-1] = '\0';
  75. < return gzputs((gzFile*)stream, buffer);
  76. ---
  77. > if (n < 0 || n > BUFFER_LEN) {
  78. > buffer[BUFFER_LEN-1] = '\0';
  79. > }
  80. >
  81. > return gzputs(stream->file, buffer);
  82. 75,77c89,90
  83. < int SCIPfputc(int c, SCIP_FILE *stream)
  84. < {
  85. < return gzputc((gzFile*)stream, c);
  86. ---
  87. > int SCIPfputc(int c, SCIP_FILE *stream) {
  88. > return gzputc(stream->file, c);
  89. 80,82c93,94
  90. < int SCIPfputs(const char *s, SCIP_FILE *stream)
  91. < {
  92. < return gzputs((gzFile*)stream, s);
  93. ---
  94. > int SCIPfputs(const char *s, SCIP_FILE *stream) {
  95. > return gzputs(stream->file, s);
  96. 85,87c97,98
  97. < int SCIPfgetc(SCIP_FILE *stream)
  98. < {
  99. < return gzgetc((gzFile*)stream);
  100. ---
  101. > int SCIPfgetc(SCIP_FILE *stream) {
  102. > return gzgetc(stream->file);
  103. 90,92c101,102
  104. < char* SCIPfgets(char *s, int size, SCIP_FILE *stream)
  105. < {
  106. < return gzgets((gzFile*)stream, s, size);
  107. ---
  108. > char* SCIPfgets(char *s, int size, SCIP_FILE *stream) {
  109. > return gzgets(stream->file, s, size);
  110. 95,97c105,106
  111. < int SCIPfflush(SCIP_FILE *stream)
  112. < {
  113. < return gzflush((gzFile*)stream, Z_SYNC_FLUSH);
  114. ---
  115. > int SCIPfflush(SCIP_FILE *stream) {
  116. > return gzflush(stream->file, Z_SYNC_FLUSH);
  117. 100,102c109,110
  118. < int SCIPfseek(SCIP_FILE *stream, long offset, int whence)
  119. < {
  120. < return gzseek((gzFile*)stream, offset, whence);
  121. ---
  122. > int SCIPfseek(SCIP_FILE *stream, long offset, int whence) {
  123. > return gzseek(stream->file, offset, whence);
  124. 105,107c113,114
  125. < void SCIPrewind(SCIP_FILE *stream)
  126. < {
  127. < gzrewind((gzFile*)stream);
  128. ---
  129. > void SCIPrewind(SCIP_FILE *stream) {
  130. > gzrewind(stream->file);
  131. 110,112c117,118
  132. < long SCIPftell(SCIP_FILE *stream)
  133. < {
  134. < return gztell((gzFile*)stream);
  135. ---
  136. > long SCIPftell(SCIP_FILE *stream) {
  137. > return gztell(stream->file);
  138. 115,117c121,122
  139. < int SCIPfeof(SCIP_FILE *stream)
  140. < {
  141. < return gzeof((gzFile*)stream);
  142. ---
  143. > int SCIPfeof(SCIP_FILE *stream) {
  144. > return gzeof(stream->file);
  145. 120,122c125,129
  146. < int SCIPfclose(SCIP_FILE *fp)
  147. < {
  148. < return gzclose((gzFile*)fp);
  149. ---
  150. > int SCIPfclose(SCIP_FILE *fp) {
  151. > int status = gzclose(fp->file);
  152. > free(fp);
  153. >
  154. > return status;