• 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 BEGET_UTILS_API_H
17 #define BEGET_UTILS_API_H
18 
19 #include <inttypes.h>
20 
21 #ifdef __cplusplus
22 #if __cplusplus
23 extern "C" {
24 #endif
25 #endif
26 
27 #define STARTUP_SERVICE_CTL "startup.service.ctl"
28 
29 typedef enum {
30     SERVICE_IDLE = 0, // service add
31     SERVICE_STARTING, // service start
32     SERVICE_STARTED, // 2 service ok running
33     SERVICE_READY, // 3 service ok running
34     SERVICE_STOPPING,
35     SERVICE_STOPPED, // 5
36     SERVICE_ERROR,
37     SERVICE_SUSPENDED,
38     SERVICE_FREEZED,
39     SERVICE_DISABLED,
40     SERVICE_CRITICAL
41 } ServiceStatus;
42 
43 enum ServiceAction {
44     START = 0,
45     STOP = 1,
46     RESTART = 2,
47 };
48 
49 int ServiceControlWithExtra(const char *serviceName, int action, const char *extArgv[], int extArgc);
50 int ServiceControl(const char *serviceName, int action);
51 int ServiceWaitForStatus(const char *serviceName, ServiceStatus status, int waitTimeout);
52 int ServiceSetReady(const char *serviceName);
53 int StartServiceByTimer(const char *serviceName, uint64_t timeout);
54 int StopServiceTimer(const char *serviceName);
55 #ifdef __cplusplus
56 #if __cplusplus
57 }
58 #endif
59 #endif
60 #endif
61