/usr/include/libraw/libraw_datastream.h is in libraw-dev 0.18.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | /* -*- C -*-
* File: libraw_datastream.h
* Copyright 2008-2017 LibRaw LLC (info@libraw.org)
* Created: Sun Jan 18 13:07:35 2009
*
* LibRaw Data stream interface
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of two licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
*/
#ifndef __LIBRAW_DATASTREAM_H
#define __LIBRAW_DATASTREAM_H
#include <stdio.h>
#include <sys/types.h>
#include <errno.h>
#include <string.h>
#ifndef __cplusplus
#else /* __cplusplus */
#include "libraw_const.h"
#include "libraw_types.h"
#include <fstream>
#include <memory>
#if defined WIN32 || defined (__MINGW32__)
#include <winsock2.h>
/* MSVS 2008 and above... */
#if _MSC_VER >= 1500
#define WIN32SECURECALLS
#endif
#endif
#ifdef USE_DNGSDK
#if defined WIN32 || defined (__MINGW32__)
#define qWinOS 1
#define qMacOS 0
#elif defined(__APPLE__)
#define qWinOS 0
#define qMacOS 1
#else
/* define OS types for DNG here */
#endif
#define qDNGXMPDocOps 0
#define qDNGUseLibJPEG 1
#define qDNGXMPFiles 0
#define qDNGExperimental 1
#define qDNGThreadSafe 1
#include "dng_stream.h"
#endif /* DNGSDK */
#define IOERROR() do { throw LIBRAW_EXCEPTION_IO_EOF; } while(0)
class LibRaw_buffer_datastream;
class LibRaw_bit_buffer;
class DllDef LibRaw_abstract_datastream
{
public:
LibRaw_abstract_datastream(){ substream=0;};
virtual ~LibRaw_abstract_datastream(void){if(substream) delete substream;}
virtual int valid() = 0;
virtual int read(void *,size_t, size_t ) = 0;
virtual int seek(INT64 , int ) = 0;
virtual INT64 tell() = 0;
virtual INT64 size() = 0;
virtual int get_char() = 0;
virtual char* gets(char *, int) = 0;
virtual int scanf_one(const char *, void *) = 0;
virtual int eof() = 0;
virtual void * make_jas_stream() = 0;
virtual int jpeg_src(void *) { return -1; }
/* reimplement in subclass to use parallel access in xtrans_load_raw() if OpenMP is not used */
virtual int lock() { return 1;} /* success */
virtual void unlock(){}
/* subfile parsing not implemented in base class */
virtual const char* fname(){ return NULL;};
#if defined(_WIN32) && !defined(__MINGW32__) && defined(_MSC_VER) && (_MSC_VER > 1310)
virtual const wchar_t* wfname(){ return NULL;};
virtual int subfile_open(const wchar_t*) { return -1;}
#endif
virtual int subfile_open(const char*) { return -1;}
virtual void subfile_close() { }
virtual int tempbuffer_open(void*, size_t);
virtual void tempbuffer_close();
protected:
LibRaw_abstract_datastream *substream;
};
#ifdef WIN32
template class DllDef std::auto_ptr<std::streambuf>;
#endif
class DllDef LibRaw_file_datastream: public LibRaw_abstract_datastream
{
protected:
std::auto_ptr<std::streambuf> f; /* will close() automatically through dtor */
std::auto_ptr<std::streambuf> saved_f; /* when *f is a subfile, *saved_f is the master file */
std::string filename;
INT64 _fsize;
#ifdef WIN32
std::wstring wfilename;
#endif
FILE *jas_file;
public:
virtual ~LibRaw_file_datastream();
LibRaw_file_datastream(const char *fname);
#if defined(_WIN32) && !defined(__MINGW32__) && defined(_MSC_VER) && (_MSC_VER > 1310)
LibRaw_file_datastream(const wchar_t *fname);
#endif
virtual void *make_jas_stream();
virtual int jpeg_src(void *jpegdata);
virtual int valid();
virtual int read(void * ptr,size_t size, size_t nmemb);
virtual int eof();
virtual int seek(INT64 o, int whence);
virtual INT64 tell();
virtual INT64 size() { return _fsize;}
virtual int get_char()
{
if(substream) return substream->get_char();
return f->sbumpc();
}
virtual char* gets(char *str, int sz);
virtual int scanf_one(const char *fmt, void*val);
virtual const char* fname();
#if defined(_WIN32) && !defined(__MINGW32__) && defined(_MSC_VER) && (_MSC_VER > 1310)
virtual const wchar_t* wfname();
virtual int subfile_open(const wchar_t *fn);
#endif
virtual int subfile_open(const char *fn);
virtual void subfile_close();
};
class DllDef LibRaw_buffer_datastream : public LibRaw_abstract_datastream
{
public:
LibRaw_buffer_datastream(void *buffer, size_t bsize);
virtual ~LibRaw_buffer_datastream();
virtual int valid();
virtual void *make_jas_stream();
virtual int jpeg_src(void *jpegdata);
virtual int read(void * ptr,size_t sz, size_t nmemb);
virtual int eof();
virtual int seek(INT64 o, int whence);
virtual INT64 tell();
virtual INT64 size() { return streamsize;}
virtual char* gets(char *s, int sz);
virtual int scanf_one(const char *fmt, void* val);
virtual int get_char()
{
if(substream) return substream->get_char();
if(streampos>=streamsize)
return -1;
return buf[streampos++];
}
private:
unsigned char *buf;
size_t streampos,streamsize;
};
class DllDef LibRaw_bigfile_datastream : public LibRaw_abstract_datastream
{
public:
LibRaw_bigfile_datastream(const char *fname);
#if defined(_WIN32) && !defined(__MINGW32__) && defined(_MSC_VER) && (_MSC_VER > 1310)
LibRaw_bigfile_datastream(const wchar_t *fname);
#endif
virtual ~LibRaw_bigfile_datastream();
virtual int valid();
virtual int jpeg_src(void *jpegdata);
virtual void *make_jas_stream();
virtual int read(void * ptr,size_t size, size_t nmemb);
virtual int eof();
virtual int seek(INT64 o, int whence);
virtual INT64 tell();
virtual INT64 size() { return _fsize;}
virtual char* gets(char *str, int sz);
virtual int scanf_one(const char *fmt, void*val);
virtual const char *fname();
#if defined(_WIN32) && !defined(__MINGW32__) && defined(_MSC_VER) && (_MSC_VER > 1310)
virtual const wchar_t* wfname();
virtual int subfile_open(const wchar_t *fn);
#endif
virtual int subfile_open(const char *fn);
virtual void subfile_close();
virtual int get_char()
{
#if !defined(_WIN32) && !defined(__MINGW32__)
return substream?substream->get_char():getc_unlocked(f);
#else
return substream?substream->get_char():fgetc(f);
#endif
}
protected:
FILE *f,*sav;
std::string filename;
INT64 _fsize;
#ifdef WIN32
std::wstring wfilename;
#endif
};
#ifdef WIN32
class DllDef LibRaw_windows_datastream : public LibRaw_buffer_datastream
{
public:
/* ctor: high level constructor opens a file by name */
LibRaw_windows_datastream(const TCHAR* sFile);
/* ctor: construct with a file handle - caller is responsible for closing the file handle */
LibRaw_windows_datastream(HANDLE hFile);
/* dtor: unmap and close the mapping handle */
virtual ~LibRaw_windows_datastream();
virtual INT64 size() { return cbView_;}
protected:
void Open(HANDLE hFile);
inline void reconstruct_base()
{
/* this subterfuge is to overcome the private-ness of LibRaw_buffer_datastream */
(LibRaw_buffer_datastream&)*this = LibRaw_buffer_datastream(pView_, (size_t)cbView_);
}
HANDLE hMap_; /* handle of the file mapping */
void* pView_; /* pointer to the mapped memory */
__int64 cbView_; /* size of the mapping in bytes */
};
#endif
#ifdef USE_DNGSDK
class libraw_dng_stream: public dng_stream
{
public:
libraw_dng_stream(LibRaw_abstract_datastream* p): dng_stream((dng_abort_sniffer*)NULL,kBigBufferSize,0),parent_stream(p)
{
if(parent_stream)
{
off = parent_stream->tell();
parent_stream->seek(0UL,SEEK_SET); /* seek to start */
}
}
~libraw_dng_stream(){
if(parent_stream)
parent_stream->seek(off,SEEK_SET);
}
virtual uint64 DoGetLength (){
if(parent_stream)
return parent_stream->size();
return 0;
}
virtual void DoRead (void *data, uint32 count, uint64 offset)
{
if(parent_stream)
{
parent_stream->seek(offset,SEEK_SET);
parent_stream->read(data,1,count);
}
}
private:
libraw_dng_stream (const libraw_dng_stream &stream);
libraw_dng_stream & operator= (const libraw_dng_stream &stream);
LibRaw_abstract_datastream *parent_stream;
INT64 off;
};
#endif
#endif /* cplusplus */
#endif
|