/src/mozilla-central/netwerk/streamconv/converters/nsDirIndexParser.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
3 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | | |
6 | | #ifndef __NSDIRINDEX_H_ |
7 | | #define __NSDIRINDEX_H_ |
8 | | |
9 | | #include "nsString.h" |
10 | | #include "nsCOMPtr.h" |
11 | | #include "nsIDirIndexListener.h" |
12 | | #include "mozilla/RefPtr.h" |
13 | | |
14 | | class nsIDirIndex; |
15 | | class nsITextToSubURI; |
16 | | |
17 | | /* CID: {a0d6ad32-1dd1-11b2-aa55-a40187b54036} */ |
18 | | |
19 | | class nsDirIndexParser : public nsIDirIndexParser { |
20 | | |
21 | | private: |
22 | | virtual ~nsDirIndexParser(); |
23 | | |
24 | | nsDirIndexParser(); |
25 | | nsresult Init(); |
26 | | |
27 | | public: |
28 | | NS_DECL_ISUPPORTS |
29 | | NS_DECL_NSISTREAMLISTENER |
30 | | NS_DECL_NSIREQUESTOBSERVER |
31 | | NS_DECL_NSIDIRINDEXPARSER |
32 | | |
33 | | static already_AddRefed<nsIDirIndexParser> |
34 | | CreateInstance() |
35 | 0 | { |
36 | 0 | RefPtr<nsDirIndexParser> parser = new nsDirIndexParser(); |
37 | 0 | if (NS_FAILED(parser->Init())) { |
38 | 0 | return nullptr; |
39 | 0 | } |
40 | 0 | return parser.forget(); |
41 | 0 | } |
42 | | |
43 | | enum fieldType { |
44 | | FIELD_UNKNOWN = 0, // MUST be 0 |
45 | | FIELD_FILENAME, |
46 | | FIELD_DESCRIPTION, |
47 | | FIELD_CONTENTLENGTH, |
48 | | FIELD_LASTMODIFIED, |
49 | | FIELD_CONTENTTYPE, |
50 | | FIELD_FILETYPE |
51 | | }; |
52 | | |
53 | | protected: |
54 | | nsCOMPtr<nsIDirIndexListener> mListener; |
55 | | |
56 | | nsCString mEncoding; |
57 | | nsCString mComment; |
58 | | nsCString mBuf; |
59 | | int32_t mLineStart; |
60 | | bool mHasDescription; |
61 | | int mFormat[8]; |
62 | | |
63 | | nsresult ProcessData(nsIRequest *aRequest, nsISupports *aCtxt); |
64 | | nsresult ParseFormat(const char* buf); |
65 | | nsresult ParseData(nsIDirIndex* aIdx, char* aDataStr, int32_t lineLen); |
66 | | |
67 | | struct Field { |
68 | | const char *mName; |
69 | | fieldType mType; |
70 | | }; |
71 | | |
72 | | static Field gFieldTable[]; |
73 | | |
74 | | static nsrefcnt gRefCntParser; |
75 | | static nsITextToSubURI* gTextToSubURI; |
76 | | }; |
77 | | |
78 | | #endif |