~ubuntu-branches/ubuntu/lucid/perl-tk/lucid

« back to all changes in this revision

Viewing changes to PNG/zlib/contrib/iostream/zfstream.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Colin Tuckley
  • Date: 2008-02-15 13:56:59 UTC
  • mfrom: (1.1.3 upstream) (4.1.1 hardy)
  • Revision ID: james.westby@ubuntu.com-20080215135659-ru2oqlykuju20fav
Tags: 1:804.028-1
* New Upstream Release (Closes: #463080).
* Update to Debhelper v5.
* Build with XFT=1 (Closes: #411129).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
 
#include <memory.h>
3
2
#include "zfstream.h"
4
3
 
5
4
gzfilebuf::gzfilebuf() :
17
16
}
18
17
 
19
18
gzfilebuf *gzfilebuf::open( const char *name,
20
 
                            int io_mode ) {
 
19
                            int io_mode ) {
21
20
 
22
21
  if ( is_open() )
23
22
    return NULL;
24
23
 
25
24
  char char_mode[10];
26
 
  char *p;
27
 
  memset(char_mode,'\0',10);
28
 
  p = char_mode;
 
25
  char *p = char_mode;
29
26
 
30
27
  if ( io_mode & ios::in ) {
31
28
    mode = ios::in;
48
45
    *p++ = '9';
49
46
  }
50
47
 
 
48
  // Put the end-of-string indicator
 
49
  *p = '\0';
 
50
 
51
51
  if ( (file = gzopen(name, char_mode)) == NULL )
52
52
    return NULL;
53
53
 
58
58
}
59
59
 
60
60
gzfilebuf *gzfilebuf::attach( int file_descriptor,
61
 
                              int io_mode ) {
 
61
                              int io_mode ) {
62
62
 
63
63
  if ( is_open() )
64
64
    return NULL;
65
65
 
66
66
  char char_mode[10];
67
 
  char *p;
68
 
  memset(char_mode,'\0',10);
69
 
  p = char_mode;
 
67
  char *p = char_mode;
70
68
 
71
69
  if ( io_mode & ios::in ) {
72
70
    mode = ios::in;
89
87
    *p++ = '9';
90
88
  }
91
89
 
 
90
  // Put the end-of-string indicator
 
91
  *p = '\0';
 
92
 
92
93
  if ( (file = gzdopen(file_descriptor, char_mode)) == NULL )
93
94
    return NULL;
94
95
 
112
113
 
113
114
}
114
115
 
115
 
int gzfilebuf::setcompressionlevel( short comp_level ) {
 
116
int gzfilebuf::setcompressionlevel( int comp_level ) {
116
117
 
117
118
  return gzsetparams(file, comp_level, -2);
118
119
 
119
120
}
120
121
 
121
 
int gzfilebuf::setcompressionstrategy( short comp_strategy ) {
 
122
int gzfilebuf::setcompressionstrategy( int comp_strategy ) {
122
123
 
123
124
  return gzsetparams(file, -2, comp_strategy);
124
125
 
151
152
 
152
153
    if ( out_waiting() ) {
153
154
      if ( flushbuf() == EOF )
154
 
        return EOF;
 
155
        return EOF;
155
156
    }
156
157
 
157
158
  }
180
181
    setg(0,0,0);
181
182
  } else {
182
183
    if (in_avail()) {
183
 
        return EOF;
 
184
        return EOF;
184
185
    }
185
186
    if (out_waiting()) {
186
187
      if (flushbuf() == EOF)
187
 
        return EOF;
 
188
        return EOF;
188
189
    }
189
190
  }
190
191
 
282
283
 
283
284
}
284
285
 
285
 
gzfilebuf *gzfilestream_common::rdbuf() {
286
 
 
 
286
gzfilebuf *gzfilestream_common::rdbuf()
 
287
{
287
288
  return &buffer;
 
289
}
288
290
 
289
 
}
290
 
     
291
291
gzifstream::gzifstream() :
292
292
  ios( gzfilestream_common::rdbuf() )
293
293
{