• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_PARAM_PERSIST_H
17 #define BASE_STARTUP_PARAM_PERSIST_H
18 #include <stdint.h>
19 #include <sys/types.h>
20 
21 #include "param_osadp.h"
22 
23 #ifdef __cplusplus
24 #if __cplusplus
25 extern "C" {
26 #endif
27 #endif
28 
29 typedef int (*PersistParamGetPtr)(const char *name, const char *value, void *context);
30 typedef void *PERSIST_SAVE_HANDLE;
31 typedef struct {
32     void *context;
33     PersistParamGetPtr persistParamGet;
34 } PersistAdpContext;
35 
36 typedef struct {
37     int (*load)(void);
38     int (*save)(const char *name, const char *value);
39     int (*batchSaveBegin)(PERSIST_SAVE_HANDLE *handle);
40     int (*batchSave)(PERSIST_SAVE_HANDLE handle, const char *name, const char *value);
41     void (*batchSaveEnd)(PERSIST_SAVE_HANDLE handle);
42 } PersistParamOps;
43 
44 int RegisterPersistParamOps(PersistParamOps *ops);
45 
46 #ifndef STARTUP_INIT_TEST
47 #define PARAM_MUST_SAVE_PARAM_DIFF 1 // 1s
48 #else
49 #define PARAM_MUST_SAVE_PARAM_DIFF 1
50 void TimerCallbackForSave(ParamTaskPtr timer, void *context);
51 #endif
52 
53 void CheckAndSavePersistParam(void);
54 
55 #ifdef __cplusplus
56 #if __cplusplus
57 }
58 #endif
59 #endif
60 #endif