Upload packaging folder
[platform/upstream/iotjs.git] / tools / src / iotjs_env.h
1 /* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
2  *
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 IOTJS_ENV_H
17 #define IOTJS_ENV_H
18
19 #include "uv.h"
20
21
22 typedef struct {
23   bool memstat;
24   bool show_opcode;
25 } Config;
26
27 typedef enum {
28   kInitializing,
29   kRunningMain,
30   kRunningLoop,
31   kExiting,
32 } State;
33
34
35 typedef struct {
36   // Number of application arguments including 'iotjs' and app name.
37   int argc;
38
39   // Application arguments list including 'iotjs' and app name.
40   char** argv;
41
42   // I/O event loop.
43   uv_loop_t* loop;
44
45   // Running state.
46   State state;
47
48   // Run config
49   Config config;
50 } IOTJS_VALIDATED_STRUCT(iotjs_environment_t);
51
52
53 const iotjs_environment_t* iotjs_environment_get();
54 void iotjs_environment_release();
55
56 bool iotjs_environment_parse_command_line_arguments(iotjs_environment_t* env,
57                                                     int argc, char** argv);
58
59 int iotjs_environment_argc(const iotjs_environment_t* env);
60 const char* iotjs_environment_argv(const iotjs_environment_t* env, int idx);
61
62 uv_loop_t* iotjs_environment_loop(const iotjs_environment_t* env);
63 void iotjs_environment_set_loop(iotjs_environment_t* env, uv_loop_t* loop);
64
65 const Config* iotjs_environment_config(const iotjs_environment_t* env);
66
67 void iotjs_environment_go_state_running_main(iotjs_environment_t* env);
68 void iotjs_environment_go_state_running_loop(iotjs_environment_t* env);
69 void iotjs_environment_go_state_exiting(iotjs_environment_t* env);
70
71
72 #endif /* IOTJS_ENV_H */