headers/bsd: Add sys/queue.h.
[haiku.git] / src / system / boot / loader / package_support.h
blob3c38ede7760031802efb81c5d13d1ff4d2b6624d
1 /*
2 * Copyright 2014, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef PACKAGE_SUPPORT_H
6 #define PACKAGE_SUPPORT_H
9 #include <dirent.h>
11 #include <Referenceable.h>
12 #include <util/DoublyLinkedList.h>
15 class Directory;
18 class PackageVolumeState : public DoublyLinkedListLinkImpl<PackageVolumeState> {
19 public:
20 PackageVolumeState();
21 ~PackageVolumeState();
23 status_t SetTo(const char* stateName);
24 void Unset();
26 const char* Name() const
27 { return fName; }
28 const char* DisplayName() const;
30 const char* SystemPackage() const
31 { return fSystemPackage; }
32 status_t SetSystemPackage(const char* package);
34 void GetPackagePath(const char* name, char* path,
35 size_t pathSize);
37 static bool IsNewer(const PackageVolumeState* a,
38 const PackageVolumeState* b);
40 private:
41 char* fName;
42 char* fDisplayName;
43 char* fSystemPackage;
46 typedef DoublyLinkedList<PackageVolumeState> PackageVolumeStateList;
49 class PackageVolumeInfo : public BReferenceable {
50 public:
51 typedef PackageVolumeStateList StateList;
53 public:
54 PackageVolumeInfo();
55 ~PackageVolumeInfo();
57 status_t SetTo(Directory* baseDirectory,
58 const char* packagesPath);
60 const StateList& States() const
61 { return fStates; }
63 private:
64 PackageVolumeState* _AddState(const char* stateName);
65 status_t _InitState(Directory* packagesDirectory,
66 DIR* dir, PackageVolumeState* state);
67 status_t _ParseActivatedPackagesFile(
68 Directory* packagesDirectory,
69 PackageVolumeState* state,
70 char* packageName, size_t packageNameSize);
72 private:
73 StateList fStates;
77 #endif // PACKAGE_SUPPORT_H