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: 38722 $ 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 78 79 */ ProfanityFilter(uptr pWorkMemory)80 ProfanityFilter( uptr pWorkMemory ) { Initialize( pWorkMemory ); } 81 82 /* Please see man pages for details 83 84 85 86 */ ~ProfanityFilter()87 virtual ~ProfanityFilter(){ Finalize(); } 88 89 /* Please see man pages for details 90 91 92 93 94 */ 95 nn::Result Initialize(); 96 97 /* Please see man pages for details 98 99 100 101 102 103 104 105 106 107 108 109 110 */ 111 nn::Result Initialize( uptr pWorkMemory ); 112 113 /* Please see man pages for details 114 115 116 117 118 119 */ 120 nn::Result Finalize(); 121 122 /* Please see man pages for details 123 124 125 */ 126 virtual u32 GetContentVersion(); 127 128 /* Please see man pages for details 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 */ 153 virtual nn::Result CheckProfanityWords( bit32* pCheckResults, const wchar_t** ppWords, size_t nWordCount ); 154 155 /* Please see man pages for details 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 */ 180 virtual nn::Result CheckProfanityWords( bit32* pCheckResults, ProfanityFilterPatternList nPatternCode, const wchar_t** ppWords, size_t nWordCount ); 181 182 /* Please see man pages for details 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 */ 210 virtual nn::Result CheckProfanityWords( bit32* pCheckResults, bool bCommunicateWithOtherRegions, const wchar_t** ppWords, size_t nWordCount ); 211 212 public: 213 /* Please see man pages for details 214 215 */ 216 enum 217 { 218 // 219 WORKMEMORY_SIZE = 64 * 1024 220 }; 221 222 private: 223 void SetupMemoryArea(); 224 nn::Result MountSharedContents(); 225 nn::Result CheckArguments( bit32* pCheckResults, const wchar_t** ppWords, size_t nWordCount ); 226 nn::Result CheckProfanityWords_Impl( bit32* pCheckResults, nn::fs::FileInputStream* pFileStream, const wchar_t** ppWords, size_t nWordCount ); 227 void CheckWords( const wchar_t *pPattern, size_t nLength ); 228 229 private: 230 // 231 nn::os::MemoryBlock m_MemoryBlock; 232 233 // 234 bool m_bIsUsingMemoryBlock; 235 236 // 237 bool m_bContentMounted; 238 239 // 240 ProfanityFilterPatternList m_nPatternList; 241 242 // 243 NN_PADDING1; 244 245 // 246 uptr m_pWorkingHead; 247 248 // 249 uptr m_pTempPoolHead; 250 251 // 252 uptr m_pPatternsHead; 253 254 // 255 uptr m_pMountWorkingArea; 256 257 // 258 wchar_t* m_pConvertedWord; 259 260 // 261 size_t m_nWordCount; 262 263 // 264 u32* m_pCheckResults; 265 }; 266 267 } // namespace CTR 268 } // namespaec ngc 269 } // namespace nn 270 271 #endif // NN_NGC_CTR_PROFANITY_FILTER_H_ 272