From b9bfba20f25a0562d22bb57d611abc3918e1c147 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 19 Feb 2006 18:00:00 +0100 Subject: =?UTF-8?q?Version=201.3.43=20-=20Removed=20an=20unnecessary=20toF?= =?UTF-8?q?ile->SetReadAhead()=20from=20cutter.c=20(thanks=20to=20Artur=20?= =?UTF-8?q?=20=20Skawina).=20-=20The=20"Back"=20key=20now=20restores=20the?= =?UTF-8?q?=20original=20string=20when=20pressed=20while=20editing=20a=20?= =?UTF-8?q?=20=20string=20item=20(suggested=20by=20Markus=20Hahn).=20-=20N?= =?UTF-8?q?ow=20stopping=20scanning=20the=20video=20directory=20if=20there?= =?UTF-8?q?=20are=20too=20many=20levels=20of=20=20=20symbolic=20links,=20w?= =?UTF-8?q?hich=20might=20indicate=20a=20recursive=20link=20loop=20(based?= =?UTF-8?q?=20on=20a=20patch=20=20=20from=20Helmut=20Auer).=20-=20Improved?= =?UTF-8?q?=20OSD=20area=20handling=20in=20cDvbSpuDecoder=20(thanks=20to?= =?UTF-8?q?=20Marco=20Schl=C3=BC=C3=9Fler).=20-=20Now=20logging=20the=20de?= =?UTF-8?q?scription=20(if=20present)=20in=20case=20a=20thread=20is=20canc?= =?UTF-8?q?eled=20(suggested=20=20=20by=20Marco=20Schl=C3=BC=C3=9Fler).=20?= =?UTF-8?q?-=20cMenuText=20now=20uses=20the=20given=20font=20(thanks=20to?= =?UTF-8?q?=20Rolf=20Ahrenberg).=20-=20The=20ST:TNG=20skin=20now=20uses=20?= =?UTF-8?q?the=20fixed=20font=20if=20requested=20when=20displaying=20texts?= =?UTF-8?q?.=20-=20Fixed=20some=20typos=20in=20the=20CONTRIBUTORS=20file?= =?UTF-8?q?=20(thanks=20to=20Frank=20Kr=C3=B6mmelbein).=20-=20Changed=20of?= =?UTF-8?q?fset=20and=20size=20handling=20in=20'libsi'=20from=20'unsigned'?= =?UTF-8?q?=20to=20'signed',=20so=20that=20=20=20overflows=20can=20be=20be?= =?UTF-8?q?tter=20detected=20(thanks=20to=20Marcel=20Wiesweg).=20-=20Check?= =?UTF-8?q?ing=20data=20size=20in=20CaDescriptor::Parse()=20and=20LinkageD?= =?UTF-8?q?escriptor::Parse()=20of=20=20=20'libsi'=20to=20avoid=20crashes?= =?UTF-8?q?=20with=20invalid=20data=20(thanks=20to=20Marcel=20Wiesweg).=20?= =?UTF-8?q?-=20Made=20CharArray::DataOwnData::assign()=20in=20'libsi'=20mo?= =?UTF-8?q?re=20robust=20against=20invalid=20=20=20data=20(suggested=20by?= =?UTF-8?q?=20Oliver=20Endriss).=20Also=20changed=20CharArray::DataOwnData?= =?UTF-8?q?::Delete()=20=20=20so=20that=20it=20sets=20'size'=20and=20'data?= =?UTF-8?q?'=20to=200.=20-=20Now=20resetting=20the=20channel=20number=20if?= =?UTF-8?q?=20the=20number=20entered=20through=20the=20numeric=20keys=20?= =?UTF-8?q?=20=20exceeds=20the=20maximum=20channel=20number=20(thanks=20to?= =?UTF-8?q?=20Rolf=20Ahrenberg).=20-=20The=20language=20code=20in=20the=20?= =?UTF-8?q?'X'=20component=20records=20of=20EPG=20data=20can=20now=20consi?= =?UTF-8?q?st=20of=20=20=20two=20codes,=20separated=20by=20'+'.=20-=20If?= =?UTF-8?q?=20a=20recording=20starts=20and=20there=20is=20no=20EPG=20data?= =?UTF-8?q?=20available=20for=20the=20recorded=20channel,=20=20=20the=20'X?= =?UTF-8?q?'=20audio=20component=20records=20for=20the=20'info.vdr'=20file?= =?UTF-8?q?=20are=20now=20generated=20from=20the=20=20=20channel's=20PID?= =?UTF-8?q?=20data.=20-=20Externally=20provided=20EPG=20data=20(with=20tab?= =?UTF-8?q?le=20ID=200x00)=20now=20gets=20its=20component=20=20=20descript?= =?UTF-8?q?ors=20set=20from=20the=20broadcast=20data,=20so=20that=20langua?= =?UTF-8?q?ge=20codes=20and=20descriptions=20=20=20are=20available=20(sugg?= =?UTF-8?q?ested=20by=20Andreas=20Brugger).=20-=20When=20setting=20the=20a?= =?UTF-8?q?udio=20track=20descriptions,=20the=20language=20codes=20are=20n?= =?UTF-8?q?ow=20also=20set=20=20=20in=20case=20this=20is=20a=20replay=20se?= =?UTF-8?q?ssion=20(based=20on=20a=20patch=20from=20Rolf=20Ahrenberg).=20-?= =?UTF-8?q?=20If=20a=20recording=20starts=20and=20the=20channel's=20audio?= =?UTF-8?q?=20PID=20data=20has=20more=20language=20code=20=20=20informatio?= =?UTF-8?q?n=20than=20the=20EPG's=20component=20data,=20the=20code=20from?= =?UTF-8?q?=20the=20channel=20is=20taken.=20-=20Fixed=20handling=20DPID=20?= =?UTF-8?q?when=20deciding=20whether=20to=20switch=20to=20'Transfer=20Mode?= =?UTF-8?q?'=20(thanks=20=20=20to=20Marco=20Schl=C3=BC=C3=9Fler).=20-=20Fi?= =?UTF-8?q?xed=20replaying=20recordings=20of=20radio=20channels=20with=20m?= =?UTF-8?q?any=20audio=20tracks=20(thanks=20to=20=20=20Reinhard=20Nissl).?= =?UTF-8?q?=20-=20Added=20a=20comment=20to=20tChannelID::nid,=20explaining?= =?UTF-8?q?=20that=20is=20is=20actually=20the=20"original"=20=20=20network?= =?UTF-8?q?=20id.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libsi/descriptor.c | 44 +++++++++++++++++++++++++------------------- libsi/section.c | 30 +++++++++++++++--------------- libsi/si.c | 6 +++--- libsi/si.h | 10 +++++----- libsi/util.c | 18 +++++++++++------- libsi/util.h | 34 +++++++++++++++++----------------- 6 files changed, 76 insertions(+), 66 deletions(-) (limited to 'libsi') diff --git a/libsi/descriptor.c b/libsi/descriptor.c index cc3a016..6a3af9f 100644 --- a/libsi/descriptor.c +++ b/libsi/descriptor.c @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: descriptor.c 1.15 2005/09/03 15:16:49 kls Exp $ + * $Id: descriptor.c 1.17 2006/02/18 11:02:25 kls Exp $ * * ***************************************************************************/ @@ -16,7 +16,7 @@ namespace SI { void ShortEventDescriptor::Parse() { - unsigned int offset=0; + int offset=0; const descr_short_event *s; data.setPointerAndOffset(s, offset); languageCode[0]=s->lang_code1; @@ -38,7 +38,7 @@ int ExtendedEventDescriptor::getLastDescriptorNumber() { } void ExtendedEventDescriptor::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); languageCode[0]=s->lang_code1; languageCode[1]=s->lang_code2; @@ -51,7 +51,7 @@ void ExtendedEventDescriptor::Parse() { } void ExtendedEventDescriptor::Item::Parse() { - unsigned int offset=0; + int offset=0; const item_extended_event *first; data.setPointerAndOffset(first, offset); itemDescription.setDataAndOffset(data+offset, first->item_description_length, offset); @@ -327,9 +327,12 @@ int CaDescriptor::getCaPid() const { } void CaDescriptor::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); - privateData.assign(data.getData(offset), getLength()-offset); + if (checkSize(getLength()-offset)) + privateData.assign(data.getData(offset), getLength()-offset); + else + privateData.assign(NULL, 0); } int StreamIdentifierDescriptor::getComponentTag() const { @@ -477,7 +480,7 @@ int ServiceDescriptor::getServiceType() const { } void ServiceDescriptor::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); providerName.setDataAndOffset(data+offset, s->provider_name_length, offset); const descr_service_mid *mid; @@ -526,7 +529,7 @@ int ComponentDescriptor::getComponentTag() const { } void ComponentDescriptor::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); languageCode[0]=s->lang_code1; languageCode[1]=s->lang_code2; @@ -580,7 +583,7 @@ int FrequencyListDescriptor::getCodingType() const { } void FrequencyListDescriptor::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); frequencies.setData(data+offset, getLength()-offset); } @@ -594,7 +597,7 @@ void MultilingualNameDescriptor::Parse() { } void MultilingualNameDescriptor::Name::Parse() { - unsigned int offset=0; + int offset=0; const entry_multilingual_name *s; data.setPointerAndOffset(s, offset); languageCode[0]=s->lang_code1; @@ -609,7 +612,7 @@ int MultilingualComponentDescriptor::getComponentTag() const { } void MultilingualComponentDescriptor::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); nameLoop.setData(data+sizeof(descr_multilingual_component), getLength()-sizeof(descr_multilingual_component)); } @@ -619,7 +622,7 @@ void MultilingualServiceNameDescriptor::Parse() { } void MultilingualServiceNameDescriptor::Name::Parse() { - unsigned int offset=0; + int offset=0; const entry_multilingual_name *s; data.setPointerAndOffset(s, offset); languageCode[0]=s->lang_code1; @@ -633,9 +636,12 @@ void MultilingualServiceNameDescriptor::Name::Parse() { } void LinkageDescriptor::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); - privateData.assign(data.getData(offset), getLength()-offset); + if (checkSize(getLength()-offset)) + privateData.assign(data.getData(offset), getLength()-offset); + else + privateData.assign(NULL, 0); } int LinkageDescriptor::getTransportStreamId() const { @@ -682,7 +688,7 @@ AudioType ISO639LanguageDescriptor::Language::getAudioType() { } void PDCDescriptor::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); } @@ -731,7 +737,7 @@ int MHP_ApplicationDescriptor::getApplicationPriority() const { } void MHP_ApplicationDescriptor::Parse() { - unsigned int offset=0; + int offset=0; const descr_application *dapp; data.setPointerAndOffset(dapp, offset); profileLoop.setDataAndOffset(data+offset, dapp->application_profiles_length, offset); @@ -790,7 +796,7 @@ int MHP_TransportProtocolDescriptor::getComponentTag() const { } void MHP_TransportProtocolDescriptor::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); if (getProtocolId() == ObjectCarousel) { const transport_via_oc *oc; @@ -821,7 +827,7 @@ void MHP_DVBJApplicationDescriptor::ApplicationEntry::Parse() { } void MHP_DVBJApplicationLocationDescriptor::Parse() { - unsigned int offset=0; + int offset=0; const descr_dvbj_application_location *first; data.setPointerAndOffset(first, offset); baseDirectory.setDataAndOffset(data+offset, first->base_directory_length, offset); @@ -836,7 +842,7 @@ int MHP_ApplicationIconsDescriptor::getIconFlags() const { } void MHP_ApplicationIconsDescriptor::Parse() { - unsigned int offset=0; + int offset=0; const descr_application_icons_descriptor *first; data.setPointerAndOffset(first, offset); iconLocator.setDataAndOffset(data+offset, first->icon_locator_length, offset); diff --git a/libsi/section.c b/libsi/section.c index 2cac809..68af991 100644 --- a/libsi/section.c +++ b/libsi/section.c @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: section.c 1.3 2004/02/20 13:44:59 kls Exp $ + * $Id: section.c 1.4 2006/02/18 10:38:20 kls Exp $ * * ***************************************************************************/ @@ -18,7 +18,7 @@ namespace SI { /*********************** PAT ***********************/ void PAT::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); associationLoop.setData(data+offset, getLength()-offset-4); } @@ -48,7 +48,7 @@ void CAT::Parse() { /*********************** PMT ***********************/ void PMT::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); commonDescriptors.setDataAndOffset(data+offset, HILO(s->program_info_length), offset); streamLoop.setData(data+offset, getLength()-offset-4); @@ -71,7 +71,7 @@ int PMT::Stream::getStreamType() const { } void PMT::Stream::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); streamDescriptors.setData(data+offset, HILO(s->ES_info_length)); } @@ -79,7 +79,7 @@ void PMT::Stream::Parse() { /*********************** TSDT ***********************/ void TSDT::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); transportStreamDescriptors.setDataAndOffset(data+offset, getLength()-offset-4, offset); } @@ -91,7 +91,7 @@ int NIT::getNetworkId() const { } void NIT::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); commonDescriptors.setDataAndOffset(data+offset, HILO(s->network_descriptor_length), offset); const nit_mid *mid; @@ -108,7 +108,7 @@ int NIT::TransportStream::getOriginalNetworkId() const { } void NIT::TransportStream::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); transportStreamDescriptors.setData(data+offset, HILO(s->transport_descriptors_length)); } @@ -116,7 +116,7 @@ void NIT::TransportStream::Parse() { /*********************** SDT ***********************/ void SDT::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); serviceLoop.setData(data+offset, getLength()-offset-4); //4 is for CRC } @@ -150,7 +150,7 @@ int SDT::Service::getFreeCaMode() const { } void SDT::Service::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); serviceDescriptors.setData(data+offset, HILO(s->descriptors_loop_length)); } @@ -188,7 +188,7 @@ bool EIT::isActualTS() const { } void EIT::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); //printf("%d %d %d %d %d\n", getServiceId(), getTransportStreamId(), getOriginalNetworkId(), isPresentFollowing(), isActualTS()); eventLoop.setData(data+offset, getLength()-offset-4); //4 is for CRC @@ -243,7 +243,7 @@ int EIT::Event::getFreeCaMode() const { } void EIT::Event::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); //printf("%d %d %d\n", getStartTime(), getDuration(), getRunningStatus()); eventDescriptors.setData(data+offset, HILO(s->descriptors_loop_length)); @@ -266,7 +266,7 @@ time_t TOT::getTime() const { } void TOT::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); descriptorLoop.setData(data+offset, getLength()-offset-4); } @@ -274,7 +274,7 @@ void TOT::Parse() { /*********************** RST ***********************/ void RST::Parse() { - unsigned int offset=0; + int offset=0; const rst *s; data.setPointerAndOffset(s, offset); infoLoop.setData(data+offset, getLength()-offset); @@ -315,7 +315,7 @@ int AIT::getAITVersion() const { } void AIT::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(first, offset); commonDescriptors.setDataAndOffset(data+offset, HILO(first->common_descriptors_length), offset); const ait_mid *mid; @@ -336,7 +336,7 @@ int AIT::Application::getControlCode() const { } void AIT::Application::Parse() { - unsigned int offset=0; + int offset=0; data.setPointerAndOffset(s, offset); applicationDescriptors.setData(data+offset, HILO(s->application_descriptors_length)); } diff --git a/libsi/si.c b/libsi/si.c index 90d4030..bbd3f1a 100644 --- a/libsi/si.c +++ b/libsi/si.c @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: si.c 1.14 2005/05/28 14:11:16 kls Exp $ + * $Id: si.c 1.15 2006/02/18 10:38:20 kls Exp $ * * ***************************************************************************/ @@ -22,7 +22,7 @@ Object::Object() { Object::Object(CharArray &d) : data(d) { } -void Object::setData(const unsigned char*d, unsigned int size, bool doCopy) { +void Object::setData(const unsigned char*d, int size, bool doCopy) { data.assign(d, size, doCopy); } @@ -30,7 +30,7 @@ void Object::setData(CharArray &d) { data=d; } -bool Object::checkSize(unsigned int offset) { +bool Object::checkSize(int offset) { return data.checkSize(offset); } diff --git a/libsi/si.h b/libsi/si.h index 3836b2f..c8910ff 100644 --- a/libsi/si.h +++ b/libsi/si.h @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: si.h 1.12 2005/09/03 15:19:00 kls Exp $ + * $Id: si.h 1.13 2006/02/18 10:38:20 kls Exp $ * * ***************************************************************************/ @@ -184,7 +184,7 @@ public: Object(); Object(CharArray &d); //can only be called once since data is immutable - void setData(const unsigned char*data, unsigned int size, bool doCopy=true); + void setData(const unsigned char*data, int size, bool doCopy=true); CharArray getData() { return data; } //returns the valid flag which indicates if data is all right or errors have been encountered bool isValid() { return data.isValid(); } @@ -196,7 +196,7 @@ protected: void setData(CharArray &d); //returns whether the given offset fits within the limits of the actual data //The valid flag will be set accordingly - bool checkSize(unsigned int offset); + bool checkSize(int offset); }; class Section : public Object { @@ -242,7 +242,7 @@ public: //never forget to call this void setData(CharArray d, int l) { Object::setData(d); checkSize(l); length=l; } //convenience method - void setDataAndOffset(CharArray d, int l, unsigned int &offset) { Object::setData(d); checkSize(l); length=l; offset+=l; } + void setDataAndOffset(CharArray d, int l, int &offset) { Object::setData(d); checkSize(l); length=l; offset+=l; } virtual int getLength() { return length; } private: int length; @@ -384,7 +384,7 @@ typedef uint64_t SixtyFourBit; template class TypeLoop : public Loop { public: int getCount() { return getLength()/sizeof(T); } - T operator[](const unsigned int index) const + T operator[](const int index) const { switch (sizeof(T)) { case 1: diff --git a/libsi/util.c b/libsi/util.c index 3465794..b0db93e 100644 --- a/libsi/util.c +++ b/libsi/util.c @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: util.c 1.5 2005/05/28 14:15:29 kls Exp $ + * $Id: util.c 1.7 2006/02/18 11:17:50 kls Exp $ * * ***************************************************************************/ @@ -47,7 +47,7 @@ CharArray& CharArray::operator=(const CharArray &f) { return *this; } -void CharArray::assign(const unsigned char*data, unsigned int size, bool doCopy) { +void CharArray::assign(const unsigned char*data, int size, bool doCopy) { //immutable if (!data_) data_= doCopy ? (Data*)new DataOwnData() : (Data*)new DataForeignData(); @@ -76,13 +76,13 @@ bool CharArray::operator==(const CharArray &other) const { return false; //do _not_ use strcmp! Data is not necessarily null-terminated. - for (unsigned int i=0;isize;i++) + for (int i=0;isize;i++) if (data_->data[i] != other.data_->data[i]) return false; return true; } -CharArray CharArray::operator+(const unsigned int offset) const { +CharArray CharArray::operator+(const int offset) const { CharArray f(*this); f.off+=offset; return f; @@ -117,8 +117,10 @@ CharArray::DataOwnData::~DataOwnData() { Delete(); } -void CharArray::DataOwnData::assign(const unsigned char*d, unsigned int s) { +void CharArray::DataOwnData::assign(const unsigned char*d, int s) { Delete(); + if (!d || s > 100000 || s <= 0) // ultimate plausibility check + return; size=s; unsigned char *newdata=new unsigned char[size]; memcpy(newdata, d, size); @@ -127,13 +129,15 @@ void CharArray::DataOwnData::assign(const unsigned char*d, unsigned int s) { void CharArray::DataOwnData::Delete() { delete[] data; + size=0; + data=0; } CharArray::DataForeignData::~DataForeignData() { Delete(); } -void CharArray::DataForeignData::assign(const unsigned char*d, unsigned int s) { +void CharArray::DataForeignData::assign(const unsigned char*d, int s) { size=s; data=d; } @@ -143,7 +147,7 @@ void CharArray::DataForeignData::Delete() { } /* -void CharArray::Data::assign(unsigned int s) { +void CharArray::Data::assign(int s) { if (data) delete[] data; size=s; diff --git a/libsi/util.h b/libsi/util.h index da188ad..91a4c32 100644 --- a/libsi/util.h +++ b/libsi/util.h @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: util.h 1.5 2004/10/23 14:22:40 kls Exp $ + * $Id: util.h 1.6 2006/02/18 10:38:20 kls Exp $ * * ***************************************************************************/ @@ -37,14 +37,14 @@ public: ~CharArray(); //can be called exactly once - void assign(const unsigned char*data, unsigned int size, bool doCopy=true); + void assign(const unsigned char*data, int size, bool doCopy=true); //compares to a null-terminated string bool operator==(const char *string) const; //compares to another CharArray (data not necessarily null-terminated) bool operator==(const CharArray &other) const; //returns another CharArray with its offset incremented by offset - CharArray operator+(const unsigned int offset) const; + CharArray operator+(const int offset) const; //access and convenience methods const unsigned char* getData() const { return data_->data+off; } @@ -52,28 +52,28 @@ public: template const T* getData() const { return (T*)(data_->data+off); } template const T* getData(int offset) const { return (T*)(data_->data+offset+off); } //sets p to point to data+offset, increments offset - template void setPointerAndOffset(const T* &p, unsigned int &offset) const { p=(T*)getData(offset); offset+=sizeof(T); } - unsigned char operator[](const unsigned int index) const { return data_->data ? data_->data[off+index] : 0; } + template void setPointerAndOffset(const T* &p, int &offset) const { p=(T*)getData(offset); offset+=sizeof(T); } + unsigned char operator[](const int index) const { return data_->data ? data_->data[off+index] : 0; } int getLength() const { return data_->size; } - u_int16_t TwoBytes(const unsigned int index) const { return data_->data ? data_->TwoBytes(off+index) : 0; } - u_int32_t FourBytes(const unsigned int index) const { return data_->data ? data_->FourBytes(off+index) : 0; } + u_int16_t TwoBytes(const int index) const { return data_->data ? data_->TwoBytes(off+index) : 0; } + u_int32_t FourBytes(const int index) const { return data_->data ? data_->FourBytes(off+index) : 0; } bool isValid() const { return data_->valid; } - bool checkSize(unsigned int offset) { return (data_->valid && (data_->valid=(off+offset < data_->size))); } + bool checkSize(int offset) { return (data_->valid && offset>=0 && (data_->valid=(off+offset < data_->size))); } - void addOffset(unsigned int offset) { off+=offset; } + void addOffset(int offset) { off+=offset; } private: class Data { public: Data(); virtual ~Data(); - virtual void assign(const unsigned char*data, unsigned int size) = 0; + virtual void assign(const unsigned char*data, int size) = 0; virtual void Delete() = 0; - u_int16_t TwoBytes(const unsigned int index) const + u_int16_t TwoBytes(const int index) const { return (data[index] << 8) | data[index+1]; } - u_int32_t FourBytes(const unsigned int index) const + u_int32_t FourBytes(const int index) const { return (data[index] << 24) | (data[index+1] << 16) | (data[index+2] << 8) | data[index+3]; } /*#ifdef CHARARRAY_THREADSAFE void Lock(); @@ -83,11 +83,11 @@ private: void Unlock() {} #endif Data(const Data& d); - void assign(unsigned int size); + void assign(int size); */ const unsigned char*data; - unsigned int size; + int size; // count_ is the number of CharArray objects that point at this // count_ must be initialized to 1 by all constructors @@ -106,18 +106,18 @@ private: public: DataOwnData() {} virtual ~DataOwnData(); - virtual void assign(const unsigned char*data, unsigned int size); + virtual void assign(const unsigned char*data, int size); virtual void Delete(); }; class DataForeignData : public Data { public: DataForeignData() {} virtual ~DataForeignData(); - virtual void assign(const unsigned char*data, unsigned int size); + virtual void assign(const unsigned char*data, int size); virtual void Delete(); }; Data* data_; - unsigned int off; + int off; }; -- cgit v1.2.3