~ubuntu-branches/ubuntu/maverick/kdegraphics/maverick-proposed

« back to all changes in this revision

Viewing changes to libs/libkdcraw/libraw/libraw/libraw_datastream.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2009-12-02 14:03:43 UTC
  • mfrom: (1.1.35 upstream)
  • Revision ID: james.westby@ubuntu.com-20091202140343-2732gbkj69g89arq
Tags: 4:4.3.80-0ubuntu1
* New upstream beta release:
  - Add build-depend on shared-desktop-ontologies for nepomuk integration
  - Bump .so versions for libkexiv, libkdcraw and libkipi
  - Update various .install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- C -*-
2
2
 * File: libraw_datastream.h
3
 
 * Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
 
3
 * Copyright 2008-2009 LibRaw LLC (info@libraw.org)
4
4
 * Created: Sun Jan 18 13:07:35 2009
5
5
 *
6
6
 * LibRaw Data stream interface
33
33
 
34
34
struct LibRaw_abstract_datastream;
35
35
 
36
 
#else // __cplusplus
 
36
#else /* __cplusplus */
37
37
 
38
38
#include "libraw_const.h"
 
39
#include "libraw_types.h"
39
40
 
40
41
class LibRaw_buffer_datastream;
41
42
 
45
46
    LibRaw_abstract_datastream(){substream=0;};
46
47
    virtual             ~LibRaw_abstract_datastream(void){if(substream) delete substream;}
47
48
    virtual int         valid(){return 0;}
48
 
    // file input emulation
49
49
    virtual int         read(void *,size_t, size_t ){ return -1;}
50
 
    virtual int         seek(off_t /*o*/, int /*whence*/){return -1;}
51
 
    virtual int         tell(){return -1;}
 
50
    virtual int         seek(INT64 , int ){return -1;}
 
51
    virtual INT64       tell(){return -1;}
52
52
    virtual int         get_char(){return -1;}
53
53
    virtual char*       gets(char *, int){ return NULL;}
54
54
    virtual int         scanf_one(const char *, void *){return -1;}
96
96
        CHK(); 
97
97
        return substream?substream->eof():feof(f);
98
98
    }
99
 
    virtual int seek(off_t o, int whence) 
 
99
    virtual int seek(INT64 o, int whence) 
100
100
    { 
101
101
        CHK(); 
102
 
        return substream?substream->seek(o,whence):fseek(f,o,whence);
 
102
#if defined (WIN32) 
 
103
#if __MSVCRT_VERSION__ >= 0x800
 
104
        return substream?substream->seek(o,whence):_fseeki64(f,o,whence);
 
105
#else
 
106
        return substream?substream->seek(o,whence):fseek(f,(size_t)o,whence);
 
107
#endif
 
108
#else
 
109
        return substream?substream->seek(o,whence):fseeko(f,o,whence);
 
110
#endif
103
111
    }
104
 
    virtual int tell() 
 
112
    virtual INT64 tell() 
105
113
    { 
106
114
        CHK(); 
 
115
#if defined (WIN32)
 
116
#if __MSVCRT_VERSION__ >= 0x800
 
117
        return substream?substream->tell():_ftelli64(f);
 
118
#else
107
119
        return substream?substream->tell():ftell(f);
 
120
#endif
 
121
#else
 
122
        return substream?substream->tell():ftello(f);
 
123
#endif
108
124
    }
109
125
    virtual int get_char() 
110
126
    { 
124
140
 
125
141
    virtual const char *fname() { return filename; }
126
142
 
127
 
    // secondary 
128
143
    virtual int subfile_open(const char *fn)
129
144
    {
130
145
        if(sav) return EBUSY;
181
196
        return streampos >= streamsize;
182
197
    }
183
198
 
184
 
    virtual int seek(off_t o, int whence) 
 
199
    virtual int seek(INT64 o, int whence) 
185
200
    { 
186
201
        if(substream) return substream->seek(o,whence);
187
202
        switch(whence)
200
215
                        if(size_t(-o) >= streampos)
201
216
                            streampos = 0;
202
217
                        else
203
 
                            streampos += o;
 
218
                            streampos += (size_t)o;
204
219
                    }
205
220
                else if (o>0)
206
221
                    {
207
222
                        if(o+streampos> streamsize)
208
223
                            streampos = streamsize;
209
224
                        else
210
 
                            streampos += o;
 
225
                            streampos += (size_t)o;
211
226
                    }
212
227
                return 0;
213
228
            case SEEK_END:
216
231
                else if ( size_t(-o) > streamsize)
217
232
                    streampos = 0;
218
233
                else
219
 
                    streampos = streamsize+o;
 
234
                    streampos = streamsize+(size_t)o;
220
235
                return 0;
221
236
            default:
222
237
                return 0;
223
238
            }
224
239
    }
225
240
    
226
 
    virtual int tell() 
 
241
    virtual INT64 tell() 
227
242
    { 
228
243
        if(substream) return substream->tell();
229
 
        return int(streampos);
 
244
        return INT64(streampos);
230
245
    }
231
246
 
232
247
    virtual int get_char()