2 * Copyright 2002-2007, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 #ifndef _MIME_SNIFFER_RULES_H
6 #define _MIME_SNIFFER_RULES_H
9 #include <SupportDefs.h>
29 class DatabaseLocation
;
35 SnifferRules(DatabaseLocation
* databaseLocation
, MimeSniffer
* mimeSniffer
);
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;
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
);
55 status_t
BuildRuleList();
56 status_t
GuessMimeType(BFile
* file
, const void *buffer
, int32 length
,
58 ssize_t
MaxBytesNeeded();
59 status_t
ProcessType(const char *type
, ssize_t
*bytesNeeded
);
61 std::list
<sniffer_rule
> fRuleList
;
64 DatabaseLocation
* fDatabaseLocation
;
65 MimeSniffer
* fMimeSniffer
;
66 ssize_t fMaxBytesNeeded
;
67 bool fHaveDoneFullBuild
;
71 } // namespace Storage
72 } // namespace BPrivate
74 #endif // _MIME_SNIFFER_H