|
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 |
|
13 class nsIDirIndex; |
|
14 class nsITextToSubURI; |
|
15 |
|
16 /* CID: {a0d6ad32-1dd1-11b2-aa55-a40187b54036} */ |
|
17 |
|
18 class nsDirIndexParser : public nsIDirIndexParser { |
|
19 public: |
|
20 NS_DECL_ISUPPORTS |
|
21 NS_DECL_NSISTREAMLISTENER |
|
22 NS_DECL_NSIREQUESTOBSERVER |
|
23 NS_DECL_NSIDIRINDEXPARSER |
|
24 |
|
25 nsDirIndexParser(); |
|
26 virtual ~nsDirIndexParser(); |
|
27 nsresult Init(); |
|
28 |
|
29 enum fieldType { |
|
30 FIELD_UNKNOWN = 0, // MUST be 0 |
|
31 FIELD_FILENAME, |
|
32 FIELD_DESCRIPTION, |
|
33 FIELD_CONTENTLENGTH, |
|
34 FIELD_LASTMODIFIED, |
|
35 FIELD_CONTENTTYPE, |
|
36 FIELD_FILETYPE |
|
37 }; |
|
38 |
|
39 protected: |
|
40 nsCOMPtr<nsIDirIndexListener> mListener; |
|
41 |
|
42 nsCString mEncoding; |
|
43 nsCString mComment; |
|
44 nsCString mBuf; |
|
45 int32_t mLineStart; |
|
46 bool mHasDescription; |
|
47 int* mFormat; |
|
48 |
|
49 nsresult ProcessData(nsIRequest *aRequest, nsISupports *aCtxt); |
|
50 nsresult ParseFormat(const char* buf); |
|
51 nsresult ParseData(nsIDirIndex* aIdx, char* aDataStr); |
|
52 |
|
53 struct Field { |
|
54 const char *mName; |
|
55 fieldType mType; |
|
56 }; |
|
57 |
|
58 static Field gFieldTable[]; |
|
59 |
|
60 static nsrefcnt gRefCntParser; |
|
61 static nsITextToSubURI* gTextToSubURI; |
|
62 }; |
|
63 |
|
64 #endif |