• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 APPSPAWN_SERVICE_H
17 #define APPSPAWN_SERVICE_H
18 
19 #include <unistd.h>
20 #include "appspawn_msg.h"
21 #include "appspawn_server.h"
22 #include "init_hashmap.h"
23 #include "loop_event.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #ifdef APPSPAWN_TEST
30 #define APPSPAWN_STATIC
31 #else
32 #define APPSPAWN_STATIC static
33 #endif
34 
35 #define APP_HASH_BUTT 32
36 #define FLAGS_ON_DEMAND 0x1
37 #define FLAGS_MODE_COLD 0x2
38 #define FLAGS_SANDBOX_PRIVATE 0x10
39 #define FLAGS_SANDBOX_APP 0x20
40 
41 #define START_INDEX 1
42 #define FD_INDEX 2
43 #define PARAM_INDEX 3
44 #define NULL_INDEX 4
45 #define PARAM_BUFFER_LEN 128
46 typedef struct {
47     AppSpawnClient client;
48     TaskHandle stream;
49     int32_t fd[2];  // 2 fd count
50     AppParameter property;
51     pid_t pid;
52 } AppSpawnClientExt;
53 
54 typedef struct {
55     HashNode node;
56     pid_t pid;
57     char name[0];
58 } AppInfo;
59 
60 typedef struct {
61     AppSpawnContent content;
62     uint32_t flags;
63     TaskHandle server;
64     SignalHandle sigHandler;
65     TimerHandle timer;
66     HashMapHandle appMap;  // save app pid and name
67 } AppSpawnContentExt;
68 
69 void SetContentFunction(AppSpawnContent *content);
70 void AppSpawnColdRun(AppSpawnContent *content, int argc, char *const argv[]);
71 int GetAppSpawnClientFromArg(int argc, char *const argv[], AppSpawnClientExt *client);
72 
73 #ifdef __cplusplus
74 }
75 #endif
76 #endif  // APPSPAWN_SERVICE_H
77