btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / storage / mime / SnifferRules.h
blobeba6d3af87a26e9f51401edcb15863e58ae64b37
1 /*
2 * Copyright 2002-2007, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _MIME_SNIFFER_RULES_H
6 #define _MIME_SNIFFER_RULES_H
9 #include <SupportDefs.h>
11 #include <list>
12 #include <string>
14 class BFile;
15 class BString;
16 struct entry_ref;
19 namespace BPrivate {
20 namespace Storage {
22 namespace Sniffer {
23 class Rule;
26 namespace Mime {
29 class DatabaseLocation;
30 class MimeSniffer;
33 class SnifferRules {
34 public:
35 SnifferRules(DatabaseLocation* databaseLocation, MimeSniffer* mimeSniffer);
36 ~SnifferRules();
38 status_t GuessMimeType(const entry_ref *ref, BString *type);
39 status_t GuessMimeType(const void *buffer, int32 length, BString *type);
41 status_t SetSnifferRule(const char *type, const char *rule);
42 status_t DeleteSnifferRule(const char *type);
44 void PrintToStream() const;
46 struct sniffer_rule {
47 std::string type; // The mime type that own the rule
48 std::string rule_string; // The unparsed string version of the rule
49 BPrivate::Storage::Sniffer::Rule *rule; // The parsed rule
51 sniffer_rule(BPrivate::Storage::Sniffer::Rule *rule = NULL);
52 ~sniffer_rule();
53 };
54 private:
55 status_t BuildRuleList();
56 status_t GuessMimeType(BFile* file, const void *buffer, int32 length,
57 BString *type);
58 ssize_t MaxBytesNeeded();
59 status_t ProcessType(const char *type, ssize_t *bytesNeeded);
61 std::list<sniffer_rule> fRuleList;
63 private:
64 DatabaseLocation* fDatabaseLocation;
65 MimeSniffer* fMimeSniffer;
66 ssize_t fMaxBytesNeeded;
67 bool fHaveDoneFullBuild;
70 } // namespace Mime
71 } // namespace Storage
72 } // namespace BPrivate
74 #endif // _MIME_SNIFFER_H