1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     ngc_ProfanityFilter.h
4 
5   Copyright (C)2010 Nintendo Co., Ltd.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law. They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Rev: 33638 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_NGC_CTR_PROFANITY_FILTER_H_
17 #define NN_NGC_CTR_PROFANITY_FILTER_H_
18 
19 #if !defined( NN_NGC_CTR_PROFANITY_FILTER_PATTERN_LIST_H_ ) || !defined( NN_NGC_CTR_PROFANITY_FILTER_BASE_H_ )
20 #   error include error
21 #endif
22 
23 namespace nn
24 {
25 
26 namespace fs
27 {
28     class FileInputStream;
29 }   // namespace fs
30 
31 namespace ngc
32 {
33 namespace CTR
34 {
35 
36 /* Please see man pages for details
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47  */
48 class ProfanityFilter : public ProfanityFilterBase
49 {
50 public:
51 
52     /* Please see man pages for details
53 
54 
55 
56      */
57     ProfanityFilter();
58 
59     /* Please see man pages for details
60 
61 
62 
63 
64      */
ProfanityFilter(const nn::WithInitialize &)65     ProfanityFilter( const nn::WithInitialize& ) { Initialize(); }
66 
67 
68     /* Please see man pages for details
69 
70 
71 
72 
73 
74 
75 
76 
77      */
ProfanityFilter(uptr pWorkMemory)78     ProfanityFilter( uptr pWorkMemory ) { Initialize( pWorkMemory ); }
79 
80     /* Please see man pages for details
81 
82 
83 
84      */
~ProfanityFilter()85     virtual ~ProfanityFilter(){ Finalize(); }
86 
87     /* Please see man pages for details
88 
89 
90 
91 
92      */
93     nn::Result Initialize();
94 
95     /* Please see man pages for details
96 
97 
98 
99 
100 
101 
102 
103 
104 
105      */
106     nn::Result Initialize( uptr pWorkMemory );
107 
108     /* Please see man pages for details
109 
110 
111 
112 
113 
114      */
115     nn::Result Finalize();
116 
117     /* Please see man pages for details
118 
119 
120      */
121     virtual u32 GetContentVersion();
122 
123     /* Please see man pages for details
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
147      */
148     virtual nn::Result CheckProfanityWords( bit32* pCheckResults, const wchar_t** ppWords, size_t nWordCount );
149 
150     /* Please see man pages for details
151 
152 
153 
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 
168 
169 
170 
171 
172 
173 
174      */
175     virtual nn::Result CheckProfanityWords( bit32* pCheckResults, ProfanityFilterPatternList nPatternCode, const wchar_t** ppWords, size_t nWordCount );
176 
177     /* Please see man pages for details
178 
179 
180 
181 
182 
183 
184 
185 
186 
187 
188 
189 
190 
191 
192 
193 
194 
195 
196 
197 
198 
199 
200 
201 
202 
203 
204      */
205     virtual nn::Result CheckProfanityWords( bit32* pCheckResults, bool bCommunicateWithOtherRegions, const wchar_t** ppWords, size_t nWordCount );
206 
207 public:
208     /* Please see man pages for details
209 
210      */
211     enum
212     {
213         //
214         WORKMEMORY_SIZE = 64 * 1024
215     };
216 
217 private:
218     void SetupMemoryArea();
219     nn::Result MountSharedContents();
220     nn::Result CheckArguments( bit32* pCheckResults, const wchar_t** ppWords, size_t nWordCount );
221     nn::Result CheckProfanityWords_Impl( bit32* pCheckResults, nn::fs::FileInputStream* pFileStream, const wchar_t** ppWords, size_t nWordCount );
222     void CheckWords( const wchar_t *pPattern, size_t nLength );
223 
224 private:
225     //
226     nn::os::MemoryBlock m_MemoryBlock;
227 
228     //
229     bool m_bIsUsingMemoryBlock;
230 
231     //
232     bool m_bContentMounted;
233 
234     //
235     ProfanityFilterPatternList m_nPatternList;
236 
237     //
238     NN_PADDING1;
239 
240     //
241     uptr m_pWorkingHead;
242 
243     //
244     uptr m_pTempPoolHead;
245 
246     //
247     uptr m_pPatternsHead;
248 
249     //
250     uptr m_pMountWorkingArea;
251 
252     //
253     wchar_t* m_pConvertedWord;
254 
255     //
256     size_t m_nWordCount;
257 
258     //
259     u32* m_pCheckResults;
260 };
261 
262 }   // namespace CTR
263 }   // namespaec ngc
264 }   // namespace nn
265 
266 #endif // NN_NGC_CTR_PROFANITY_FILTER_H_
267