haiku/headers/private/kernel/boot/PathBlocklist.h
Murai Takashi 560961ee2a Bootloader: replace blacklist with blocklist
Various projects, both commercial and OSS, began to use inclusive
terminology. There is no reason to not do it.

In Haiku, bootloader uses Blacklist, which is recommended to replace
with Denylist or Blocklist. I think Blocklist is appropriate here,
since it's a list used to block offending driver at boot.

Some strings remain unchanged for compatibility with previous naming,
but this change prepares for later removal of these (once everyone has
updated their kernel and bootloader).

Change-Id: Id9105ff5e9fcb866000355089b5ef97bf63ee854
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3145
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-03-27 10:47:33 +00:00

73 lines
1.4 KiB
C++

/*
* Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef KERNEL_BOOT_PATH_BLOCKLIST_H
#define KERNEL_BOOT_PATH_BLOCKLIST_H
#include <string.h>
#include <util/SinglyLinkedList.h>
class BlockedPath : public SinglyLinkedListLinkImpl<BlockedPath> {
public:
BlockedPath();
~BlockedPath();
bool SetTo(const char* path);
bool Append(const char* component);
const char* Path() const
{ return fPath != NULL ? fPath : ""; }
size_t Length() const
{ return fLength; }
bool operator==(const char* path) const
{ return strcmp(Path(), path) == 0; }
private:
bool _Resize(size_t length, bool keepData);
private:
char* fPath;
size_t fLength;
size_t fCapacity;
};
class PathBlocklist {
public:
typedef SinglyLinkedList<BlockedPath>::Iterator Iterator;
public:
PathBlocklist();
~PathBlocklist();
bool Add(const char* path);
void Remove(const char* path);
bool Contains(const char* path) const;
void MakeEmpty();
bool IsEmpty() const
{ return fPaths.IsEmpty(); }
Iterator GetIterator() const
{ return fPaths.GetIterator(); }
private:
BlockedPath* _FindPath(const char* path) const;
private:
typedef SinglyLinkedList<BlockedPath> PathList;
private:
PathList fPaths;
};
#endif // KERNEL_BOOT_PATH_BLOCKLIST_H