/* Simply initialize the header */
pkgCache::Header::Header()
{
- Signature = 0x98FE76DC;
-
+#define APT_HEADER_SET(X,Y) X = Y; static_assert(std::numeric_limits<decltype(X)>::max() > Y, "Size violation detected in pkgCache::Header")
+ APT_HEADER_SET(Signature, 0x98FE76DC);
+
/* Whenever the structures change the major version should be bumped,
whenever the generator changes the minor version should be bumped. */
- MajorVersion = 10;
- MinorVersion = 0;
- Dirty = false;
-
- HeaderSz = sizeof(pkgCache::Header);
- GroupSz = sizeof(pkgCache::Group);
- PackageSz = sizeof(pkgCache::Package);
- ReleaseFileSz = sizeof(pkgCache::ReleaseFile);
- PackageFileSz = sizeof(pkgCache::PackageFile);
- VersionSz = sizeof(pkgCache::Version);
- DescriptionSz = sizeof(pkgCache::Description);
- DependencySz = sizeof(pkgCache::Dependency);
- DependencyDataSz = sizeof(pkgCache::DependencyData);
- ProvidesSz = sizeof(pkgCache::Provides);
- VerFileSz = sizeof(pkgCache::VerFile);
- DescFileSz = sizeof(pkgCache::DescFile);
-
+ APT_HEADER_SET(MajorVersion, 10);
+ APT_HEADER_SET(MinorVersion, 0);
+ APT_HEADER_SET(Dirty, false);
+
+ APT_HEADER_SET(HeaderSz, sizeof(pkgCache::Header));
+ APT_HEADER_SET(GroupSz, sizeof(pkgCache::Group));
+ APT_HEADER_SET(PackageSz, sizeof(pkgCache::Package));
+ APT_HEADER_SET(ReleaseFileSz, sizeof(pkgCache::ReleaseFile));
+ APT_HEADER_SET(PackageFileSz, sizeof(pkgCache::PackageFile));
+ APT_HEADER_SET(VersionSz, sizeof(pkgCache::Version));
+ APT_HEADER_SET(DescriptionSz, sizeof(pkgCache::Description));
+ APT_HEADER_SET(DependencySz, sizeof(pkgCache::Dependency));
+ APT_HEADER_SET(DependencyDataSz, sizeof(pkgCache::DependencyData));
+ APT_HEADER_SET(ProvidesSz, sizeof(pkgCache::Provides));
+ APT_HEADER_SET(VerFileSz, sizeof(pkgCache::VerFile));
+ APT_HEADER_SET(DescFileSz, sizeof(pkgCache::DescFile));
+#undef APT_HEADER_SET
+
GroupCount = 0;
PackageCount = 0;
VersionCount = 0;
ProvidesCount = 0;
MaxVerFileSize = 0;
MaxDescFileSize = 0;
-
+
FileList = 0;
RlsFileList = 0;
VerSysName = 0;
typedef uint32_t map_pointer_t;
// same as the previous, but documented to be to a string item
typedef map_pointer_t map_stringitem_t;
+// we have only a small amount of flags for each item
+typedef uint8_t map_flags_t;
+typedef uint8_t map_number_t;
class pkgVersioningSystem;
class pkgCache /*{{{*/
This must contain the hex value 0x98FE76DC which is designed to
verify that the system loading the image has the same byte order
and byte size as the system saving the image */
- unsigned long Signature;
+ uint32_t Signature;
/** These contain the version of the cache file */
- short MajorVersion;
- short MinorVersion;
+ map_number_t MajorVersion;
+ map_number_t MinorVersion;
/** \brief indicates if the cache should be erased
Dirty is true if the cache file was opened for reading, the client
If any of the size values do not exactly match what the client expects
then the client should refuse the load the file. */
- unsigned short HeaderSz;
- unsigned short GroupSz;
- unsigned short PackageSz;
- unsigned short ReleaseFileSz;
- unsigned short PackageFileSz;
- unsigned short VersionSz;
- unsigned short DescriptionSz;
- unsigned short DependencySz;
- unsigned short DependencyDataSz;
- unsigned short ProvidesSz;
- unsigned short VerFileSz;
- unsigned short DescFileSz;
+ uint16_t HeaderSz;
+ map_number_t GroupSz;
+ map_number_t PackageSz;
+ map_number_t ReleaseFileSz;
+ map_number_t PackageFileSz;
+ map_number_t VersionSz;
+ map_number_t DescriptionSz;
+ map_number_t DependencySz;
+ map_number_t DependencyDataSz;
+ map_number_t ProvidesSz;
+ map_number_t VerFileSz;
+ map_number_t DescFileSz;
/** \brief Structure counts
In the PkgHashTable is it possible that multiple packages have the same name -
these packages are stored as a sequence in the list.
The size of both tables is the same. */
- unsigned int HashTableSize;
- unsigned int GetHashTableSize() const { return HashTableSize; }
+ uint32_t HashTableSize;
+ uint32_t GetHashTableSize() const { return HashTableSize; }
void SetHashTableSize(unsigned int const sz) { HashTableSize = sz; }
map_pointer_t GetArchitectures() const { return Architectures; }
void SetArchitectures(map_pointer_t const idx) { Architectures = idx; }
// Install/Remove/Purge etc
/** \brief state that the user wishes the package to be in */
- unsigned char SelectedState; // What
+ map_number_t SelectedState; // What
/** \brief installation state of the package
This should be "ok" but in case the installation failed
it will be different.
*/
- unsigned char InstState; // Flags
+ map_number_t InstState; // Flags
/** \brief indicates if the package is installed */
- unsigned char CurrentState; // State
+ map_number_t CurrentState; // State
/** \brief unique sequel ID
this to track which packages have been emitted already. */
map_id_t ID;
/** \brief some useful indicators of the package's state */
- unsigned long Flags;
+ map_flags_t Flags;
};
/*}}}*/
// Release File structure /*{{{*/
time_t mtime;
/** @TODO document PackageFile::Flags */
- unsigned long Flags;
+ map_flags_t Flags;
// Linked list
/** \brief Link to the next ReleaseFile in the Cache */
time_t mtime;
/** @TODO document PackageFile::Flags */
- unsigned long Flags;
+ map_flags_t Flags;
// Linked list
/** \brief Link to the next PackageFile in the Cache */
Flags used are defined in pkgCache::Version::VerMultiArch
*/
- unsigned char MultiArch;
+ map_number_t MultiArch;
/** \brief references all the PackageFile's that this version came from
/** \brief unique sequel ID */
map_id_t ID;
/** \brief parsed priority value */
- unsigned char Priority;
+ map_number_t Priority;
};
/*}}}*/
// Description structure /*{{{*/
map_pointer_t Package; // Package
/** \brief Dependency type - Depends, Recommends, Conflicts, etc */
- unsigned char Type;
+ map_number_t Type;
/** \brief comparison operator specified on the depends line
If the high bit is set then it is a logical OR with the previous record. */
- unsigned char CompareOp;
+ map_flags_t CompareOp;
map_pointer_t NextData;
};
// TagSection::FindFlag - Locate a yes/no type flag /*{{{*/
// ---------------------------------------------------------------------
/* The bits marked in Flag are masked on/off in Flags */
+bool pkgTagSection::FindFlag(const char * const Tag, uint8_t &Flags,
+ uint8_t const Flag) const
+{
+ const char *Start;
+ const char *Stop;
+ if (Find(Tag,Start,Stop) == false)
+ return true;
+ return FindFlag(Flags, Flag, Start, Stop);
+}
+bool pkgTagSection::FindFlag(uint8_t &Flags, uint8_t const Flag,
+ char const* const Start, char const* const Stop)
+{
+ switch (StringToBool(string(Start, Stop)))
+ {
+ case 0:
+ Flags &= ~Flag;
+ return true;
+
+ case 1:
+ Flags |= Flag;
+ return true;
+
+ default:
+ _error->Warning("Unknown flag value: %s",string(Start,Stop).c_str());
+ return true;
+ }
+ return true;
+}
bool pkgTagSection::FindFlag(const char *Tag,unsigned long &Flags,
unsigned long Flag) const
{