Skip to main content

fswtch_sys/
fallback.rs

1use std::os::raw::{c_char, c_int, c_uint, c_void};
2
3pub type switch_size_t = usize;
4pub type switch_bool_t = c_uint;
5pub type switch_module_flag_t = u32;
6
7pub const SWITCH_FALSE: switch_bool_t = 0;
8pub const SWITCH_TRUE: switch_bool_t = 1;
9pub const SWITCH_API_VERSION: c_int = 5;
10
11#[repr(C)]
12#[derive(Debug, Copy, Clone, PartialEq, Eq)]
13pub enum switch_status_t {
14    SWITCH_STATUS_SUCCESS = 0,
15    SWITCH_STATUS_FALSE = 1,
16    SWITCH_STATUS_TIMEOUT = 2,
17    SWITCH_STATUS_RESTART = 3,
18    SWITCH_STATUS_INTR = 4,
19    SWITCH_STATUS_NOTIMPL = 5,
20    SWITCH_STATUS_MEMERR = 6,
21    SWITCH_STATUS_NOOP = 7,
22    SWITCH_STATUS_RESAMPLE = 8,
23    SWITCH_STATUS_GENERR = 9,
24    SWITCH_STATUS_INUSE = 10,
25    SWITCH_STATUS_BREAK = 11,
26    SWITCH_STATUS_SOCKERR = 12,
27    SWITCH_STATUS_MORE_DATA = 13,
28    SWITCH_STATUS_NOTFOUND = 14,
29    SWITCH_STATUS_UNLOAD = 15,
30    SWITCH_STATUS_NOUNLOAD = 16,
31    SWITCH_STATUS_IGNORE = 17,
32    SWITCH_STATUS_TOO_SMALL = 18,
33    SWITCH_STATUS_FOUND = 19,
34    SWITCH_STATUS_CONTINUE = 20,
35    SWITCH_STATUS_TERM = 21,
36    SWITCH_STATUS_NOT_INITALIZED = 22,
37    SWITCH_STATUS_TOO_LATE = 23,
38    SWITCH_STATUS_XBREAK = 35,
39    SWITCH_STATUS_WINBREAK = 730035,
40}
41
42#[repr(C)]
43#[derive(Debug, Copy, Clone, PartialEq, Eq)]
44pub enum switch_module_interface_name_t {
45    SWITCH_ENDPOINT_INTERFACE = 0,
46    SWITCH_TIMER_INTERFACE = 1,
47    SWITCH_DIALPLAN_INTERFACE = 2,
48    SWITCH_CODEC_INTERFACE = 3,
49    SWITCH_APPLICATION_INTERFACE = 4,
50    SWITCH_API_INTERFACE = 5,
51    SWITCH_FILE_INTERFACE = 6,
52    SWITCH_SPEECH_INTERFACE = 7,
53    SWITCH_DIRECTORY_INTERFACE = 8,
54    SWITCH_CHAT_INTERFACE = 9,
55    SWITCH_SAY_INTERFACE = 10,
56    SWITCH_ASR_INTERFACE = 11,
57    SWITCH_MANAGEMENT_INTERFACE = 12,
58    SWITCH_LIMIT_INTERFACE = 13,
59    SWITCH_CHAT_APPLICATION_INTERFACE = 14,
60    SWITCH_JSON_API_INTERFACE = 15,
61    SWITCH_DATABASE_INTERFACE = 16,
62}
63
64#[repr(C)]
65pub struct switch_memory_pool_t {
66    _private: [u8; 0],
67}
68
69#[repr(C)]
70pub struct switch_core_session_t {
71    _private: [u8; 0],
72}
73
74#[repr(C)]
75pub struct switch_event_t {
76    _private: [u8; 0],
77}
78
79#[repr(C)]
80pub struct switch_thread_rwlock_t {
81    _private: [u8; 0],
82}
83
84#[repr(C)]
85pub struct switch_mutex_t {
86    _private: [u8; 0],
87}
88
89pub type switch_stream_handle_read_function_t =
90    Option<unsafe extern "C" fn(handle: *mut switch_stream_handle_t, len: *mut c_int) -> *mut u8>;
91pub type switch_stream_handle_write_function_t = Option<
92    unsafe extern "C" fn(
93        handle: *mut switch_stream_handle_t,
94        fmt: *const c_char,
95        ...
96    ) -> switch_status_t,
97>;
98pub type switch_stream_handle_raw_write_function_t = Option<
99    unsafe extern "C" fn(
100        handle: *mut switch_stream_handle_t,
101        data: *mut u8,
102        datalen: switch_size_t,
103    ) -> switch_status_t,
104>;
105
106#[repr(C)]
107pub struct switch_stream_handle_t {
108    pub read_function: switch_stream_handle_read_function_t,
109    pub write_function: switch_stream_handle_write_function_t,
110    pub raw_write_function: switch_stream_handle_raw_write_function_t,
111    pub data: *mut c_void,
112    pub end: *mut c_void,
113    pub data_size: switch_size_t,
114    pub data_len: switch_size_t,
115    pub alloc_len: switch_size_t,
116    pub alloc_chunk: switch_size_t,
117    pub param_event: *mut switch_event_t,
118}
119
120pub type switch_api_function_t = Option<
121    unsafe extern "C" fn(
122        cmd: *const c_char,
123        session: *mut switch_core_session_t,
124        stream: *mut switch_stream_handle_t,
125    ) -> switch_status_t,
126>;
127
128pub type switch_module_load_t = Option<
129    unsafe extern "C" fn(
130        module_interface: *mut *mut switch_loadable_module_interface_t,
131        pool: *mut switch_memory_pool_t,
132    ) -> switch_status_t,
133>;
134pub type switch_module_runtime_t = Option<unsafe extern "C" fn() -> switch_status_t>;
135pub type switch_module_shutdown_t = Option<unsafe extern "C" fn() -> switch_status_t>;
136
137#[repr(C)]
138pub struct switch_loadable_module_function_table_t {
139    pub switch_api_version: c_int,
140    pub load: switch_module_load_t,
141    pub shutdown: switch_module_shutdown_t,
142    pub runtime: switch_module_runtime_t,
143    pub flags: switch_module_flag_t,
144}
145
146#[repr(C)]
147pub struct switch_loadable_module_interface_t {
148    pub module_name: *const c_char,
149    pub endpoint_interface: *mut c_void,
150    pub timer_interface: *mut c_void,
151    pub dialplan_interface: *mut c_void,
152    pub codec_interface: *mut c_void,
153    pub application_interface: *mut c_void,
154    pub chat_application_interface: *mut c_void,
155    pub api_interface: *mut switch_api_interface_t,
156    pub json_api_interface: *mut c_void,
157    pub file_interface: *mut c_void,
158    pub speech_interface: *mut c_void,
159    pub directory_interface: *mut c_void,
160    pub chat_interface: *mut c_void,
161    pub say_interface: *mut c_void,
162    pub asr_interface: *mut c_void,
163    pub management_interface: *mut c_void,
164    pub limit_interface: *mut c_void,
165    pub database_interface: *mut c_void,
166    pub rwlock: *mut switch_thread_rwlock_t,
167    pub refs: c_int,
168    pub pool: *mut switch_memory_pool_t,
169}
170
171#[repr(C)]
172pub struct switch_api_interface_t {
173    pub interface_name: *const c_char,
174    pub desc: *const c_char,
175    pub function: switch_api_function_t,
176    pub syntax: *const c_char,
177    pub rwlock: *mut switch_thread_rwlock_t,
178    pub refs: c_int,
179    pub reflock: *mut switch_mutex_t,
180    pub parent: *mut switch_loadable_module_interface_t,
181    pub next: *mut switch_api_interface_t,
182}
183
184unsafe extern "C" {
185    pub fn switch_loadable_module_create_module_interface(
186        pool: *mut switch_memory_pool_t,
187        name: *const c_char,
188    ) -> *mut switch_loadable_module_interface_t;
189
190    pub fn switch_loadable_module_create_interface(
191        module: *mut switch_loadable_module_interface_t,
192        iname: switch_module_interface_name_t,
193    ) -> *mut c_void;
194}