• 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 SANDBOX_STR_IN_CFG "sandbox"
37 #define D_CAPS_STR_IN_CFG "d-caps"
38 #define APL_STR_IN_CFG "apl"
39 #define CPU_CORE_STR_IN_CFG "cpucore"
40 
41 #define MAX_SERVICES_CNT_IN_FILE 100
42 
43 typedef struct {
44     char *capStr;
45     unsigned int CapNum;
46 } CapStrCapNum;
47 
48 typedef struct {
49     int serviceCount;
50 } ServiceSpace;
51 
52 cJSON *GetArrayItem(const cJSON *fileRoot, int *arrSize, const char *arrName);
53 int ParseOneService(const cJSON *curItem, Service *service);
54 
55 void StartServiceByName(const char *serviceName);
56 void StopServiceByName(const char *serviceName);
57 void StopAllServices(int flags, const char **exclude, int size,
58     int (*filter)(const Service *service, const char **exclude, int size));
59 void ParseAllServices(const cJSON *fileRoot);
60 void ReleaseService(Service *service);
61 void LoadAccessTokenId(void);
62 Service *AddService(const char *name);
63 void DumpServiceHookExecute(const char *name, const char *info);
64 void ProcessControlFd(uint16_t type, const char *serviceCmd, const void *context);
65 int GetKillServiceSig(const char *name);
66 int WatchConsoleDevice(Service *service);
67 #ifdef __cplusplus
68 #if __cplusplus
69 }
70 #endif
71 #endif
72 
73 #endif // BASE_STARTUP_INITLITE_SERVICEMANAGER_H
74