1 /* 2 * Copyright (C) 2025-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ANONYMIZE_ADAPTER_H 17 #define ANONYMIZE_ADAPTER_H 18 19 #include <securec.h> 20 #include "antifraud_service.h" 21 #include "dia_config_c.h" 22 #include "dia_interface_c.h" 23 #include "dia_config_info.h" 24 #include "dia_error_code.h" 25 26 namespace OHOS { 27 namespace Telephony { 28 typedef int (*PfnInitConfig)(void **config); 29 typedef int (*PfnSetRule)(void *config, const DIA_String *key, const DIA_Rule *value); 30 typedef int (*PfnCreateAnonymize)(void *config, void **anonymize); 31 typedef int (*PfnIdentifyAnonymize)(void *anonymize, const DIA_String *input, DIA_String **output); 32 typedef int (*PfnReleaseConfig)(void **config); 33 typedef int (*PfnReleaseAonoymize)(void **anonymize); 34 typedef int (*PfnReleaseOutputData)(DIA_String **output); 35 class AnonymizeAdapter { 36 DECLARE_DELAYED_SINGLETON(AnonymizeAdapter) 37 38 public: 39 void *GetLibAnonymize(); 40 void ReleaseLibAnonymize(); 41 int InitConfig(void **config); 42 int SetRule(void *config, const DIA_String *key, const DIA_Rule *value); 43 int CreateAnonymize(void *config, void **anonymize); 44 int IdentifyAnonymize(void *anonymize, const DIA_String *input, DIA_String **output); 45 int ReleaseConfig(void **config); 46 int ReleaseAnonymize(void **anonymize); 47 int ReleaseOutputData(DIA_String **output); 48 49 private: 50 void *libAnonymize_ = nullptr; 51 }; 52 } 53 } 54 55 #endif /* ANONYMIZE_ADAPTER_H */ 56