• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #ifdef __cplusplus
21 #if __cplusplus
22 extern "C" {
23 #endif
24 #endif
25 
26 typedef int (*PersistParamGetPtr)(const char *name, const char *value, void *context);
27 
28 typedef void *PERSIST_SAVE_HANDLE;
29 typedef struct {
30     int (*load)(PersistParamGetPtr persistParamGet, void *context);
31     int (*save)(const char *name, const char *value);
32     int (*batchSaveBegin)(PERSIST_SAVE_HANDLE *handle);
33     int (*batchSave)(PERSIST_SAVE_HANDLE handle, const char *name, const char *value);
34     void (*batchSaveEnd)(PERSIST_SAVE_HANDLE handle);
35 } PersistParamOps;
36 
37 #ifndef PARAM_SUPPORT_SAVE_PERSIST
38 #define PARAM_SUPPORT_SAVE_PERSIST 1 // default
39 #endif
40 
41 #ifdef PARAM_SUPPORT_SAVE_PERSIST
42 int RegisterPersistParamOps(PersistParamOps *ops);
43 #endif
44 
45 #ifndef STARTUP_INIT_TEST
46 #define PARAM_MUST_SAVE_PARAM_DIFF 10 // 10s
47 #else
48 #define PARAM_MUST_SAVE_PARAM_DIFF 1
49 #endif
50 
51 #ifdef __cplusplus
52 #if __cplusplus
53 }
54 #endif
55 #endif
56 #endif