• 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 "init_cmds.h"
21 #include "list.h"
22 
23 #ifdef __cplusplus
24 #if __cplusplus
25 extern "C" {
26 #endif
27 #endif
28 
29 #define UID_STR_IN_CFG "uid"
30 #define GID_STR_IN_CFG "gid"
31 #define ONCE_STR_IN_CFG "once"
32 #define IMPORTANT_STR_IN_CFG "importance"
33 #define BIN_SH_NOT_ALLOWED "/bin/sh"
34 #define CRITICAL_STR_IN_CFG "critical"
35 #define DISABLED_STR_IN_CFG "disabled"
36 #define CONSOLE_STR_IN_CFG "console"
37 #define SANDBOX_STR_IN_CFG "sandbox"
38 #define D_CAPS_STR_IN_CFG "d-caps"
39 #define APL_STR_IN_CFG "apl"
40 #define CPU_CORE_STR_IN_CFG "cpucore"
41 #define MODULE_UPDATE_STR_IN_CFG "module-update"
42 
43 #define MAX_SERVICES_CNT_IN_FILE 100
44 
45 typedef struct {
46     char *capStr;
47     unsigned int CapNum;
48 } CapStrCapNum;
49 
50 typedef struct {
51     int serviceCount;
52 } ServiceSpace;
53 
54 cJSON *GetArrayItem(const cJSON *fileRoot, int *arrSize, const char *arrName);
55 int ParseOneService(const cJSON *curItem, Service *service);
56 
57 void StartServiceByName(const char *serviceName);
58 void StopServiceByName(const char *serviceName);
59 void StopAllServices(int flags, const char **exclude, int size,
60     int (*filter)(const Service *service, const char **exclude, int size));
61 void ParseAllServices(const cJSON *fileRoot, const ConfigContext *context);
62 void ReleaseService(Service *service);
63 void LoadAccessTokenId(void);
64 Service *AddService(const char *name);
65 void DumpServiceHookExecute(const char *name, const char *info);
66 void ProcessControlFd(uint16_t type, const char *serviceCmd, const void *context);
67 int GetKillServiceSig(const char *name);
68 int WatchConsoleDevice(Service *service);
69 #ifdef __cplusplus
70 #if __cplusplus
71 }
72 #endif
73 #endif
74 
75 #endif // BASE_STARTUP_INITLITE_SERVICEMANAGER_H
76