init_service_manager.h 2.3 KB
Newer Older
W
wenjun 已提交
1
/*
2
 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
W
wenjun 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef BASE_STARTUP_INITLITE_SERVICEMANAGER_H
#define BASE_STARTUP_INITLITE_SERVICEMANAGER_H

#include "init_service.h"
Z
zhong_ning 已提交
19
#include "cJSON.h"
20
#include "list.h"
W
wenjun 已提交
21 22 23 24 25 26 27

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif

28 29 30 31 32 33 34 35
#define UID_STR_IN_CFG "uid"
#define GID_STR_IN_CFG "gid"
#define ONCE_STR_IN_CFG "once"
#define IMPORTANT_STR_IN_CFG "importance"
#define BIN_SH_NOT_ALLOWED "/bin/sh"
#define CRITICAL_STR_IN_CFG "critical"
#define DISABLED_STR_IN_CFG "disabled"
#define CONSOLE_STR_IN_CFG "console"
X
xionglei6 已提交
36
#define SANDBOX_STR_IN_CFG "sandbox"
X
xionglei6 已提交
37 38
#define D_CAPS_STR_IN_CFG "d-caps"
#define APL_STR_IN_CFG "apl"
39
#define CPU_CORE_STR_IN_CFG "cpucore"
Z
zhong_ning 已提交
40 41 42

#define MAX_SERVICES_CNT_IN_FILE 100

43 44 45 46 47 48 49 50 51 52 53 54
typedef struct {
    char *capStr;
    unsigned int CapNum;
} CapStrCapNum;

typedef struct {
    int serviceCount;
} ServiceSpace;

Service *GetServiceByPid(pid_t pid);
Service *GetServiceByName(const char *servName);
cJSON *GetArrayItem(const cJSON *fileRoot, int *arrSize, const char *arrName);
X
add ut  
xionglei6 已提交
55
int ParseOneService(const cJSON *curItem, Service *service);
X
xionglei6 已提交
56

X
xionglei6 已提交
57
void StartServiceByName(const char *serviceName);
S
sun_fan 已提交
58
void StopServiceByName(const char *serviceName);
X
xionglei6 已提交
59 60
void StopAllServices(int flags, const char **exclude, int size,
    int (*filter)(const Service *service, const char **exclude, int size));
S
sun_fan 已提交
61
void ParseAllServices(const cJSON *fileRoot);
X
add ut  
xionglei6 已提交
62
void ReleaseService(Service *service);
X
xionglei6 已提交
63
void StartAllServices(int startMode);
X
xionglei6 已提交
64
void LoadAccessTokenId(void);
X
xionglei6 已提交
65 66
Service *AddService(const char *name);

S
sun_fan 已提交
67
#ifdef OHOS_SERVICE_DUMP
68
void DumpAllServices();
M
Mupceet 已提交
69
void DumpOneService(const Service *service);
S
sun_fan 已提交
70
#endif
W
wenjun 已提交
71 72 73 74 75 76 77
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif

#endif // BASE_STARTUP_INITLITE_SERVICEMANAGER_H