1 /* 2 * Copyright (c) 2022 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 BASE_STARTUP_BOOT_RUNNING_HOOKS_H 17 #define BASE_STARTUP_BOOT_RUNNING_HOOKS_H 18 19 #ifdef __cplusplus 20 #if __cplusplus 21 extern "C" { 22 #endif 23 #endif 24 25 /** 26 * @brief Running hook stage definition for init 27 */ 28 /* Hook stage for setting parameters */ 29 #define INIT_PARAM_SET_HOOK_STAGE 0 30 31 /** 32 * @brief parameter setting context information 33 */ 34 typedef struct tagPARAM_SET_CTX { 35 const char *name; /* Parameter name */ 36 const char *value; /* Parameter value */ 37 38 /* Skip setting parameter if true 39 * When setting parameters, parameter service will save the the value by default 40 * If set skipParamSet in the hook, parameter service will not save 41 */ 42 int skipParamSet; 43 } PARAM_SET_CTX; 44 45 /** 46 * @brief set parameter hook function prototype 47 * 48 * @param paramSetCtx parameter setting context information 49 * @return None 50 */ 51 typedef void (*ParamSetHook)(PARAM_SET_CTX *paramSetCtx); 52 53 /** 54 * @brief Register a hook for setting parameters 55 * 56 * @param hook parameter setting hook 57 * in the hook, we can match the parameters with special patterns to do extra controls. 58 * For example, ohos.ctl.start will control services besides the normal parameter saving. 59 * @return return 0 if succeed; other values if failed. 60 */ 61 int ParamSetHookAdd(ParamSetHook hook); 62 63 #ifdef __cplusplus 64 #if __cplusplus 65 } 66 #endif 67 #endif 68 #endif 69