• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-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 #ifndef BASE_STARTUP_INITLITE_SERVICEMANAGER_H
16 #define BASE_STARTUP_INITLITE_SERVICEMANAGER_H
17 
18 #include "init_service.h"
19 #include "cJSON.h"
20 #include "list.h"
21 
22 #ifdef __cplusplus
23 #if __cplusplus
24 extern "C" {
25 #endif
26 #endif
27 
28 #define UID_STR_IN_CFG "uid"
29 #define GID_STR_IN_CFG "gid"
30 #define ONCE_STR_IN_CFG "once"
31 #define IMPORTANT_STR_IN_CFG "importance"
32 #define BIN_SH_NOT_ALLOWED "/bin/sh"
33 #define CRITICAL_STR_IN_CFG "critical"
34 #define DISABLED_STR_IN_CFG "disabled"
35 #define CONSOLE_STR_IN_CFG "console"
36 #define D_CAPS_STR_IN_CFG "d-caps"
37 #define APL_STR_IN_CFG "apl"
38 #define CPU_CORE_STR_IN_CFG "cpucore"
39 
40 #define MAX_SERVICES_CNT_IN_FILE 100
41 
42 typedef struct {
43     char *capStr;
44     unsigned int CapNum;
45 } CapStrCapNum;
46 
47 typedef struct {
48     int serviceCount;
49 } ServiceSpace;
50 
51 Service *GetServiceByPid(pid_t pid);
52 Service *GetServiceByName(const char *servName);
53 cJSON *GetArrayItem(const cJSON *fileRoot, int *arrSize, const char *arrName);
54 int ParseOneService(const cJSON *curItem, Service *service);
55 
56 void StartServiceByName(const char *serviceName, bool checkDynamic);
57 void StopServiceByName(const char *serviceName);
58 void StopAllServices(int flags, const char **exclude, int size,
59     int (*filter)(const Service *service, const char **exclude, int size));
60 void ParseAllServices(const cJSON *fileRoot);
61 void ReleaseService(Service *service);
62 void StartAllServices(int startMode);
63 void LoadAccessTokenId(void);
64 Service *AddService(const char *name);
65 
66 #ifdef OHOS_SERVICE_DUMP
67 void DumpAllServices();
68 #endif
69 #ifdef __cplusplus
70 #if __cplusplus
71 }
72 #endif
73 #endif
74 
75 #endif // BASE_STARTUP_INITLITE_SERVICEMANAGER_H
76