| // Copyright 2015 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef NET_BASE_LOOKUP_STRING_IN_FIXED_SET_H_ |
| #define NET_BASE_LOOKUP_STRING_IN_FIXED_SET_H_ |
| |
| #include <stddef.h> |
| |
| #include "net/base/net_export.h" |
| |
| namespace net { |
| |
| enum { |
| kDafsaNotFound = -1, // key is not in set |
| kDafsaFound = 0, // key is in set |
| // The following return values are used by the implementation of |
| // GetDomainAndRegistry() and are probably not generally useful. |
| kDafsaExceptionRule = 1, // key excluded from set via exception |
| kDafsaWildcardRule = 2, // key matched a wildcard rule |
| kDafsaPrivateRule = 4, // key matched a private rule |
| }; |
| |
| // Looks up the string |key| with length |key_length| in a fixed set of |
| // strings. The set of strings must be known at compile time. It is converted to |
| // a graph structure named a DAFSA (Deterministic Acyclic Finite State |
| // Automaton) by the script make_dafsa.py during compilation. This permits |
| // efficient (in time and space) lookup. The graph generated by make_dafsa.py |
| // takes the form of a constant byte array which should be supplied via the |
| // |graph| and |length| parameters. The return value is kDafsaNotFound, |
| // kDafsaFound, or a bitmap consisting of one or more of kDafsaExceptionRule, |
| // kDafsaWildcardRule and kDafsaPrivateRule ORed together. |
| NET_EXPORT int LookupStringInFixedSet(const unsigned char* graph, |
| size_t length, |
| const char* key, |
| size_t key_length); |
| |
| } // namespace net |
| |
| #endif // NET_BASE_LOOKUP_STRING_IN_FIXED_SET_H_ |