CMS 3D CMS Logo

Functions
7zStream.cc File Reference
#include <string.h>
#include "Types.h"

Go to the source code of this file.

Functions

SRes LookInStream_LookRead (ILookInStream *stream, void *buf, size_t *size)
 
SRes LookInStream_Read (ILookInStream *stream, void *buf, size_t size)
 
SRes LookInStream_Read2 (ILookInStream *stream, void *buf, size_t size, SRes errorType)
 
SRes LookInStream_SeekTo (ILookInStream *stream, UInt64 offset)
 
void LookToRead_CreateVTable (CLookToRead *p, int lookahead)
 
void LookToRead_Init (CLookToRead *p)
 
static SRes LookToRead_Look_Exact (void *pp, const void **buf, size_t *size)
 
static SRes LookToRead_Look_Lookahead (void *pp, const void **buf, size_t *size)
 
static SRes LookToRead_Read (void *pp, void *buf, size_t *size)
 
static SRes LookToRead_Seek (void *pp, Int64 *pos, ESzSeek origin)
 
static SRes LookToRead_Skip (void *pp, size_t offset)
 
void SecToLook_CreateVTable (CSecToLook *p)
 
static SRes SecToLook_Read (void *pp, void *buf, size_t *size)
 
void SecToRead_CreateVTable (CSecToRead *p)
 
static SRes SecToRead_Read (void *pp, void *buf, size_t *size)
 
SRes SeqInStream_Read (ISeqInStream *stream, void *buf, size_t size)
 
SRes SeqInStream_Read2 (ISeqInStream *stream, void *buf, size_t size, SRes errorType)
 
SRes SeqInStream_ReadByte (ISeqInStream *stream, Byte *buf)
 

Function Documentation

SRes LookInStream_LookRead ( ILookInStream stream,
void *  buf,
size_t *  size 
)

Definition at line 40 of file 7zStream.cc.

References ILookInStream::Look, RINOK, ILookInStream::Skip, and SZ_OK.

Referenced by SecToLook_Read().

41 {
42  const void *lookBuf;
43  if (*size == 0)
44  return SZ_OK;
45  RINOK(stream->Look(stream, &lookBuf, size));
46  memcpy(buf, lookBuf, *size);
47  return stream->Skip(stream, *size);
48 }
size
Write out results.
#define RINOK(x)
Definition: Types.h:52
#define SZ_OK
Definition: Types.h:25
SRes(* Look)(void *p, const void **buf, size_t *size)
Definition: Types.h:171
SRes(* Skip)(void *p, size_t offset)
Definition: Types.h:175
SRes LookInStream_Read ( ILookInStream stream,
void *  buf,
size_t  size 
)

Definition at line 64 of file 7zStream.cc.

References LookInStream_Read2(), and SZ_ERROR_INPUT_EOF.

65 {
66  return LookInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF);
67 }
size
Write out results.
#define SZ_ERROR_INPUT_EOF
Definition: Types.h:32
SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType)
Definition: 7zStream.cc:50
SRes LookInStream_Read2 ( ILookInStream stream,
void *  buf,
size_t  size,
SRes  errorType 
)

Definition at line 50 of file 7zStream.cc.

References ILookInStream::Read, RINOK, findQualityFiles::size, and SZ_OK.

Referenced by LookInStream_Read().

51 {
52  while (size != 0)
53  {
54  size_t processed = size;
55  RINOK(stream->Read(stream, buf, &processed));
56  if (processed == 0)
57  return errorType;
58  buf = (void *)((Byte *)buf + processed);
59  size -= processed;
60  }
61  return SZ_OK;
62 }
size
Write out results.
#define RINOK(x)
Definition: Types.h:52
#define SZ_OK
Definition: Types.h:25
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:178
unsigned char Byte
Definition: Types.h:55
SRes LookInStream_SeekTo ( ILookInStream stream,
UInt64  offset 
)

Definition at line 34 of file 7zStream.cc.

References PFRecoTauDiscriminationByIsolation_cfi::offset, ILookInStream::Seek, SZ_SEEK_SET, and lumiQTWidget::t.

35 {
36  Int64 t = offset;
37  return stream->Seek(stream, &t, SZ_SEEK_SET);
38 }
SRes(* Seek)(void *p, Int64 *pos, ESzSeek origin)
Definition: Types.h:180
long long int Int64
Definition: Types.h:82
void LookToRead_CreateVTable ( CLookToRead p,
int  lookahead 
)

Definition at line 134 of file 7zStream.cc.

References ILookInStream::Look, LookToRead_Look_Exact(), LookToRead_Look_Lookahead(), LookToRead_Read(), LookToRead_Seek(), LookToRead_Skip(), ILookInStream::Read, CLookToRead::s, ILookInStream::Seek, and ILookInStream::Skip.

135 {
136  p->s.Look = lookahead ?
139  p->s.Skip = LookToRead_Skip;
140  p->s.Read = LookToRead_Read;
141  p->s.Seek = LookToRead_Seek;
142 }
static SRes LookToRead_Read(void *pp, void *buf, size_t *size)
Definition: 7zStream.cc:113
static SRes LookToRead_Look_Lookahead(void *pp, const void **buf, size_t *size)
Definition: 7zStream.cc:69
static SRes LookToRead_Look_Exact(void *pp, const void **buf, size_t *size)
Definition: 7zStream.cc:87
SRes(* Seek)(void *p, Int64 *pos, ESzSeek origin)
Definition: Types.h:180
ILookInStream s
Definition: Types.h:194
static SRes LookToRead_Skip(void *pp, size_t offset)
Definition: 7zStream.cc:106
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:178
static SRes LookToRead_Seek(void *pp, Int64 *pos, ESzSeek origin)
Definition: 7zStream.cc:127
SRes(* Look)(void *p, const void **buf, size_t *size)
Definition: Types.h:171
SRes(* Skip)(void *p, size_t offset)
Definition: Types.h:175
void LookToRead_Init ( CLookToRead p)

Definition at line 144 of file 7zStream.cc.

References CLookToRead::pos, and CLookToRead::size.

145 {
146  p->pos = p->size = 0;
147 }
size_t size
Definition: Types.h:197
size_t pos
Definition: Types.h:196
static SRes LookToRead_Look_Exact ( void *  pp,
const void **  buf,
size_t *  size 
)
static

Definition at line 87 of file 7zStream.cc.

References CLookToRead::buf, LookToRead_BUF_SIZE, AlCaHLTBitMon_ParallelJobs::p, CLookToRead::pos, ISeekInStream::Read, CLookToRead::realStream, CLookToRead::size, findQualityFiles::size, and SZ_OK.

Referenced by LookToRead_CreateVTable().

88 {
89  SRes res = SZ_OK;
91  size_t size2 = p->size - p->pos;
92  if (size2 == 0 && *size > 0)
93  {
94  p->pos = 0;
97  res = p->realStream->Read(p->realStream, p->buf, size);
98  size2 = p->size = *size;
99  }
100  if (size2 < *size)
101  *size = size2;
102  *buf = p->buf + p->pos;
103  return res;
104 }
size
Write out results.
Byte buf[(1<< 14)]
Definition: Types.h:198
Definition: Electron.h:4
int SRes
Definition: Types.h:43
ISeekInStream * realStream
Definition: Types.h:195
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:165
#define SZ_OK
Definition: Types.h:25
#define LookToRead_BUF_SIZE
Definition: Types.h:190
size_t size
Definition: Types.h:197
size_t pos
Definition: Types.h:196
static SRes LookToRead_Look_Lookahead ( void *  pp,
const void **  buf,
size_t *  size 
)
static

Definition at line 69 of file 7zStream.cc.

References CLookToRead::buf, LookToRead_BUF_SIZE, AlCaHLTBitMon_ParallelJobs::p, CLookToRead::pos, ISeekInStream::Read, CLookToRead::realStream, CLookToRead::size, and SZ_OK.

Referenced by LookToRead_CreateVTable().

70 {
71  SRes res = SZ_OK;
73  size_t size2 = p->size - p->pos;
74  if (size2 == 0 && *size > 0)
75  {
76  p->pos = 0;
77  size2 = LookToRead_BUF_SIZE;
78  res = p->realStream->Read(p->realStream, p->buf, &size2);
79  p->size = size2;
80  }
81  if (size2 < *size)
82  *size = size2;
83  *buf = p->buf + p->pos;
84  return res;
85 }
size
Write out results.
Byte buf[(1<< 14)]
Definition: Types.h:198
Definition: Electron.h:4
int SRes
Definition: Types.h:43
ISeekInStream * realStream
Definition: Types.h:195
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:165
#define SZ_OK
Definition: Types.h:25
#define LookToRead_BUF_SIZE
Definition: Types.h:190
size_t size
Definition: Types.h:197
size_t pos
Definition: Types.h:196
static SRes LookToRead_Read ( void *  pp,
void *  buf,
size_t *  size 
)
static

Definition at line 113 of file 7zStream.cc.

References CLookToRead::buf, AlCaHLTBitMon_ParallelJobs::p, CLookToRead::pos, ISeekInStream::Read, CLookToRead::realStream, CLookToRead::size, findQualityFiles::size, and SZ_OK.

Referenced by LookToRead_CreateVTable().

114 {
115  CLookToRead *p = (CLookToRead *)pp;
116  size_t rem = p->size - p->pos;
117  if (rem == 0)
118  return p->realStream->Read(p->realStream, buf, size);
119  if (rem > *size)
120  rem = *size;
121  memcpy(buf, p->buf + p->pos, rem);
122  p->pos += rem;
123  *size = rem;
124  return SZ_OK;
125 }
size
Write out results.
Byte buf[(1<< 14)]
Definition: Types.h:198
ISeekInStream * realStream
Definition: Types.h:195
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:165
#define SZ_OK
Definition: Types.h:25
size_t size
Definition: Types.h:197
size_t pos
Definition: Types.h:196
static SRes LookToRead_Seek ( void *  pp,
Int64 pos,
ESzSeek  origin 
)
static

Definition at line 127 of file 7zStream.cc.

References AlCaHLTBitMon_ParallelJobs::p, CLookToRead::pos, CLookToRead::realStream, ISeekInStream::Seek, and CLookToRead::size.

Referenced by LookToRead_CreateVTable().

128 {
129  CLookToRead *p = (CLookToRead *)pp;
130  p->pos = p->size = 0;
131  return p->realStream->Seek(p->realStream, pos, origin);
132 }
ISeekInStream * realStream
Definition: Types.h:195
size_t size
Definition: Types.h:197
size_t pos
Definition: Types.h:196
SRes(* Seek)(void *p, Int64 *pos, ESzSeek origin)
Definition: Types.h:166
static SRes LookToRead_Skip ( void *  pp,
size_t  offset 
)
static
void SecToLook_CreateVTable ( CSecToLook p)

Definition at line 155 of file 7zStream.cc.

References ISeqInStream::Read, CSecToLook::s, and SecToLook_Read().

156 {
157  p->s.Read = SecToLook_Read;
158 }
static SRes SecToLook_Read(void *pp, void *buf, size_t *size)
Definition: 7zStream.cc:149
ISeqInStream s
Definition: Types.h:206
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:139
static SRes SecToLook_Read ( void *  pp,
void *  buf,
size_t *  size 
)
static

Definition at line 149 of file 7zStream.cc.

References LookInStream_LookRead(), AlCaHLTBitMon_ParallelJobs::p, and CSecToLook::realStream.

Referenced by SecToLook_CreateVTable().

150 {
151  CSecToLook *p = (CSecToLook *)pp;
152  return LookInStream_LookRead(p->realStream, buf, size);
153 }
size
Write out results.
ILookInStream * realStream
Definition: Types.h:207
SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size)
Definition: 7zStream.cc:40
void SecToRead_CreateVTable ( CSecToRead p)

Definition at line 166 of file 7zStream.cc.

References ISeqInStream::Read, CSecToRead::s, and SecToRead_Read().

167 {
168  p->s.Read = SecToRead_Read;
169 }
static SRes SecToRead_Read(void *pp, void *buf, size_t *size)
Definition: 7zStream.cc:160
ISeqInStream s
Definition: Types.h:214
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:139
static SRes SecToRead_Read ( void *  pp,
void *  buf,
size_t *  size 
)
static

Definition at line 160 of file 7zStream.cc.

References AlCaHLTBitMon_ParallelJobs::p, ILookInStream::Read, and CSecToRead::realStream.

Referenced by SecToRead_CreateVTable().

161 {
162  CSecToRead *p = (CSecToRead *)pp;
163  return p->realStream->Read(p->realStream, buf, size);
164 }
size
Write out results.
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:178
ILookInStream * realStream
Definition: Types.h:215
SRes SeqInStream_Read ( ISeqInStream stream,
void *  buf,
size_t  size 
)

Definition at line 22 of file 7zStream.cc.

References SeqInStream_Read2(), and SZ_ERROR_INPUT_EOF.

Referenced by LzmaFile::Open().

23 {
24  return SeqInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF);
25 }
size
Write out results.
#define SZ_ERROR_INPUT_EOF
Definition: Types.h:32
SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType)
Definition: 7zStream.cc:8
SRes SeqInStream_Read2 ( ISeqInStream stream,
void *  buf,
size_t  size,
SRes  errorType 
)

Definition at line 8 of file 7zStream.cc.

References ISeqInStream::Read, RINOK, findQualityFiles::size, and SZ_OK.

Referenced by SeqInStream_Read().

9 {
10  while (size != 0)
11  {
12  size_t processed = size;
13  RINOK(stream->Read(stream, buf, &processed));
14  if (processed == 0)
15  return errorType;
16  buf = (void *)((Byte *)buf + processed);
17  size -= processed;
18  }
19  return SZ_OK;
20 }
size
Write out results.
#define RINOK(x)
Definition: Types.h:52
#define SZ_OK
Definition: Types.h:25
unsigned char Byte
Definition: Types.h:55
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:139
SRes SeqInStream_ReadByte ( ISeqInStream stream,
Byte buf 
)

Definition at line 27 of file 7zStream.cc.

References ISeqInStream::Read, RINOK, SZ_ERROR_INPUT_EOF, and SZ_OK.

28 {
29  size_t processed = 1;
30  RINOK(stream->Read(stream, buf, &processed));
31  return (processed == 1) ? SZ_OK : SZ_ERROR_INPUT_EOF;
32 }
#define SZ_ERROR_INPUT_EOF
Definition: Types.h:32
#define RINOK(x)
Definition: Types.h:52
#define SZ_OK
Definition: Types.h:25
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:139