1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: ngc_ProfanityFilter.h 4 5 Copyright (C)2009-2012 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: 47308 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NN_NGC_CTR_PROFANITY_FILTER_H_ 17 #define NN_NGC_CTR_PROFANITY_FILTER_H_ 18 19 #include <nn/os.h> 20 21 #if !defined( NN_NGC_CTR_PROFANITY_FILTER_PATTERN_LIST_H_ ) || !defined( NN_NGC_CTR_PROFANITY_FILTER_BASE_H_ ) 22 # error include error 23 #endif 24 25 namespace nn 26 { 27 28 namespace fs 29 { 30 class FileInputStream; 31 } // namespace fs 32 33 namespace ngc 34 { 35 namespace CTR 36 { 37 38 /* Please see man pages for details 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 */ 57 #pragma diag_suppress 2530 58 class ProfanityFilter : public ProfanityFilterBase 59 { 60 public: 61 62 /* Please see man pages for details 63 64 65 66 */ 67 explicit ProfanityFilter(); 68 69 /* Please see man pages for details 70 71 72 73 74 */ 75 explicit ProfanityFilter( const nn::WithInitialize& ); 76 77 78 /* Please see man pages for details 79 80 81 82 83 84 85 86 87 88 89 */ ProfanityFilter(uptr pWorkMemory)90 explicit ProfanityFilter( uptr pWorkMemory ) { Initialize( pWorkMemory ); } 91 92 /* Please see man pages for details 93 94 95 96 */ ~ProfanityFilter()97 virtual ~ProfanityFilter(){ Finalize(); } 98 99 /* Please see man pages for details 100 101 102 103 104 */ 105 nn::Result Initialize(); 106 107 /* Please see man pages for details 108 109 110 111 112 113 114 115 116 117 118 119 120 */ 121 nn::Result Initialize( uptr pWorkMemory ); 122 123 void SkipAtSignCheck( bool bSkipChecking ); 124 125 /* Please see man pages for details 126 127 128 129 130 131 */ 132 nn::Result Finalize(); 133 134 /* Please see man pages for details 135 136 137 */ 138 virtual u32 GetContentVersion(); 139 140 /* Please see man pages for details 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 */ 170 virtual nn::Result CheckProfanityWords( bit32* pCheckResults, const wchar_t** ppWords, size_t nWordCount ); 171 172 /* Please see man pages for details 173 174 175 176 177 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 virtual nn::Result CheckProfanityWords( bit32* pCheckResults, ProfanityFilterPatternList nPatternCode, const wchar_t** ppWords, size_t nWordCount ); 203 204 /* Please see man pages for details 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 */ 237 virtual nn::Result CheckProfanityWords( bit32* pCheckResults, bool bCommunicateWithOtherRegions, const wchar_t** ppWords, size_t nWordCount ); 238 239 /* Please see man pages for details 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 */ 259 void SetMaskMode( bool bOverWrite ); 260 261 /* Please see man pages for details 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 */ 285 virtual nn::Result MaskProfanityWordsInText( int* pProfanityWordCount, wchar_t* pText ); 286 287 /* Please see man pages for details 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 */ 312 virtual nn::Result MaskProfanityWordsInText( int* pProfanityWordCount, ProfanityFilterPatternList nPatternCode, wchar_t* pText ); 313 314 /* Please see man pages for details 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 */ 337 virtual nn::Result MaskProfanityWordsInText( int* pProfanityWordCount, bool bCommunicateWithOtherRegions, wchar_t* pText ); 338 339 public: 340 /* Please see man pages for details 341 342 */ 343 enum 344 { 345 // 346 WORKMEMORY_SIZE = 64 * 1024 347 }; 348 349 private: 350 void CleanUpVariables(); 351 void SetupMemoryArea(); 352 nn::Result MountSharedContents(); 353 354 nn::Result CheckArguments_Word( const bit32* pCheckResults, const wchar_t** ppWords, size_t nWordCount ) const; 355 nn::Result CheckProfanityWords_Impl( bit32* pCheckResults, nn::fs::FileInputStream* pFileStream, const wchar_t** ppWords, size_t nWordCount ); 356 void CheckWords( bit32* pCheckResults, const wchar_t *pPattern, size_t nLength, wchar_t* const* ppConvertedWords, size_t nWordCount ); 357 358 nn::Result CheckArguments_Text( const wchar_t* pText ) const; 359 nn::Result MaskProfanityWordsInText_Impl( int* pProfanityWordCount, wchar_t* pUserInput, wchar_t* pConvertedUserInput, u8* pMapping, nn::fs::FileInputStream* pFileStream ); 360 void MaskText( int* pProfanityWordCount, wchar_t* pUserInput, wchar_t* pConvertedUserInput, u8* pMapping, const wchar_t* pPattern, bool bIgnoreSpace ); 361 362 private: 363 // 364 nn::os::MemoryBlock m_MemoryBlock; 365 366 // 367 bool m_bIsUsingMemoryBlock; 368 369 // 370 bool m_bContentMounted; 371 372 // 373 bool m_bSkipAtSignCheck; 374 375 // 376 ProfanityFilterPatternList m_nPatternList; 377 378 // 379 uptr m_pWorkingHead; 380 381 // 382 uptr m_pTempPoolHead; 383 384 // 385 uptr m_pPatternsHead; 386 387 // 388 uptr m_pMountWorkingArea; 389 390 // 391 uptr m_pUserArea; 392 393 // 394 bool m_bMaskOverWrite; 395 }; 396 #pragma diag_default 2530 397 398 } // namespace CTR 399 } // namespaec ngc 400 } // namespace nn 401 402 #endif // NN_NGC_CTR_PROFANITY_FILTER_H_ 403