4 * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: YoungHun Kim <yh8004.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #ifndef __MUSE_CORE_H__
23 #define __MUSE_CORE_H__
33 #define MUSE_URI_MAX_LENGTH 4096
34 #define MUSE_MSG_MAX_LENGTH 4096
37 #define MUSE_SERVER_READY "/tmp/.muse_server_ready"
38 #define MUSE_DATA_HEAD 0xda1a6ead
39 #define MUSE_MSG_HEAD 0xda1a6eae
40 #define MUSE_PARAM_HANDLE "handle"
41 #define MUSE_PARAM_RETURN "ret"
42 #define MUSE_PARAM_EVENT "event"
44 typedef struct muse_module *muse_module_h;
55 } muse_core_msg_type_e;
58 MUSE_MSG_PARSE_ERROR_NONE,
59 MUSE_MSG_PARSE_ERROR_CONTINUE,
60 MUSE_MSG_PARSE_ERROR_OTHER,
61 MUSE_MSG_PARSE_ERROR_MAX
62 } muse_core_msg_parse_err_e;
65 MUSE_MODULE_COMMAND_INITIALIZE,
66 MUSE_MODULE_COMMAND_SHUTDOWN,
67 MUSE_MODULE_COMMAND_DEBUG_INFO_DUMP,
68 MUSE_MODULE_COMMAND_CREATE_SERVER_ACK,
69 MUSE_MODULE_COMMAND_RESOURCE_NOT_AVAILABLE,
70 MUSE_MODULE_COMMAND_EXTERNAL_STORAGE_STATE_CHANGED,
71 MUSE_MODULE_COMMAND_CREATE_CAUTION,
72 MUSE_MODULE_COMMAND_RESOURCE_MANAGER_SHUTDOWN,
73 MUSE_MODULE_COMMAND_MAX
74 } muse_module_command_e;
82 typedef struct muse_external_storage_info {
86 } muse_external_storage_info_t;
89 extern void __gcov_flush(void);
92 int muse_core_connection_close(int sock_fd);
93 int muse_core_set_nonblocking(int fd, bool value);
94 int muse_core_set_socket_timeout(int sock_fd, int timeout_sec);
95 bool muse_core_fd_is_valid(int fd);
96 void muse_core_fd_close(int fd);
99 int muse_core_msg_send(int sock_fd, const char *msg);
100 int muse_core_msg_recv(int sock_fd, char *msg, int msg_len);
101 int muse_core_msg_send_fd(int sock_fd, int *fds, const char *buf);
102 int muse_core_msg_recv_fd(int sock_fd, char *buf, int buf_len, int *out_fd);
103 char *muse_core_msg_new(int api, ...);
104 bool muse_core_msg_deserialize(const char *key, char *buf, int *parse_len,
105 muse_core_msg_parse_err_e *err, muse_core_msg_type_e m_type, void *data);
106 void muse_core_msg_free(char *msg);
107 void *muse_core_msg_object_new(char *str, int *parse_len, muse_core_msg_parse_err_e *err);
108 bool muse_core_msg_object_get_value(const char *key, void *jobj, muse_core_msg_type_e m_type, void *data);
109 void muse_core_msg_object_free(void *msg_obj);
111 void muse_core_dump_fd_state(int fd);
113 void muse_core_create_fd_table(void);
114 void muse_core_remove_all_fd_table(void);
115 void muse_core_destroy_fd_table(void);
116 void muse_core_log_process_thread_info(int pid);
117 void muse_core_log_process_opened_fds(int pid);
118 void muse_core_log_process_cpu_memory(int pid);
119 int muse_core_get_process_cpu_usage(int pid);
120 void muse_core_log_file_list(const char *path);
121 void muse_core_log_cmd_info(char *cmd);
122 void muse_core_remove_symlink(const char *path);
124 bool muse_server_is_ready(void);
129 #endif /*__MUSE_CORE_H__*/