yumapro  23.10T-7
YumaPro SDK
Loading...
Searching...
No Matches
subsystem.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
3 * Copyright (c) 2012 - 2021, YumaWorks, Inc., All Rights Reserved.
4 *
5 * Unless required by applicable law or agreed to in writing,
6 * software distributed under the License is distributed on an
7 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 * KIND, either express or implied. See the License for the
9 * specific language governing permissions and limitations
10 * under the License.
11 */
12#ifndef _H_subsystem
13#define _H_subsystem
14
15/* FILE: subsystem.h
16*********************************************************************
17* *
18* P U R P O S E *
19* *
20*********************************************************************/
21
28/*********************************************************************
29* *
30* C H A N G E H I S T O R Y *
31* *
32*********************************************************************
33
34date init comment
35----------------------------------------------------------------------
3606-oct-12 abb Begun; split from netconf_subsystem.c
37
38*/
39
40#ifndef _H_status_enum
41#include "status_enum.h"
42#endif
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/* group header only */
49
73/********************************************************************
74* *
75* C O N S T A N T S *
76* *
77*********************************************************************/
78
80#define SUBSYS_BUFFLEN 32000
81
83#define SUBSYS_TRACE1(cb, fmt, ...) if (cb->traceLevel && cb->errfile) \
84 { \
85 fprintf(cb->errfile, fmt, ##__VA_ARGS__); \
86 fflush(cb->errfile); \
87 }
88
90#define SUBSYS_TRACE2(cb, fmt, ...) if (cb->traceLevel > 1 && cb->errfile) \
91 { \
92 fprintf(cb->errfile, fmt, ##__VA_ARGS__); \
93 fflush(cb->errfile); \
94 }
95
97#define SUBSYS_TRACE3(cb, fmt, ...) if (cb->traceLevel > 2 && cb->errfile) \
98 { \
99 fprintf(cb->errfile, fmt, ##__VA_ARGS__); \
100 fflush(cb->errfile); \
101 }
102
106#define XML_START_MSG ((const xmlChar *)\
107 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
108
109
110/********************************************************************
111* *
112* T Y P E S *
113* *
114*********************************************************************/
115
117typedef enum proto_id_t_ {
120
123
126
127 /* ypshell */
128 PROTO_ID_CLI,
129
132
135
139
140
148typedef status_t
149 (*subsys_stdout_fn_t)(const char *buff,
150 size_t bufflen);
151
152
161typedef ssize_t
162 (*subsys_stdin_fn_t)(char *buff,
163 size_t bufflen);
164
165
166/********************************************************************
167* *
168* F U N C T I O N S *
169* *
170*********************************************************************/
171
172
186extern int run_subsystem (proto_id_t protocol_id,
187 int trace_level,
188 int argc,
189 char **argv);
190
191
212extern int
213 run_subsystem_ex (proto_id_t protocol_id,
214 int trace_level,
215 int argc,
216 char **argv,
217 char **envp,
218 subsys_stdin_fn_t stdin_fn,
219 subsys_stdout_fn_t stdout_fn,
220 int32 stdin_len);
221
222
223
245extern int
246 run_subsystem_full (proto_id_t protocol_id,
247 int trace_level,
248 int argc,
249 char **argv,
250 char **envp,
251 subsys_stdin_fn_t stdin_fn,
252 subsys_stdout_fn_t stdout_fn,
253 int32 stdin_len);
254
255
271extern status_t
272 init_subsystem_ycontrol (int trace_level,
273 const char *subsys_id);
274
275
294extern status_t
295 init_subsystem_ycontrol_ha (int trace_level,
296 const char *subsys_id,
297 const char *server_id,
298 const char *server_addr,
299 uint16 server_port);
300
301
309extern status_t
310 connect_subsystem_ycontrol (int *retfd);
311
322extern status_t
323 connect_subsystem_srid (const char *server_root,
324 int *retfd);
325
326
332extern status_t
333 check_subsystem_io (void);
334
335
341extern void
343
344
348#ifdef __cplusplus
349} /* end extern 'C' */
350#endif
351
352#endif /* _H_subsystem */
status_t
global error return code
Definition: status_enum.h:210
status_t init_subsystem_ycontrol_ha(int trace_level, const char *subsys_id, const char *server_id, const char *server_addr, uint16 server_port)
@
Definition: subsystem.c:1297
int run_subsystem_full(proto_id_t protocol_id, int trace_level, int argc, char **argv, char **envp, subsys_stdin_fn_t stdin_fn, subsys_stdout_fn_t stdout_fn, int32 stdin_len)
Run the subsystem : entry point (full)
Definition: subsystem.c:1187
status_t check_subsystem_io(void)
Check if any input ready to transfer.
Definition: subsystem.c:1404
status_t connect_subsystem_ycontrol(int *retfd)
Connect the subsystem for YControl.
Definition: subsystem.c:1343
proto_id_t
the type of protocol starting the subsystem
Definition: subsystem.h:117
int run_subsystem(proto_id_t protocol_id, int trace_level, int argc, char **argv)
Run the subsystem : entry point.
Definition: subsystem.c:1117
status_t connect_subsystem_srid(const char *server_root, int *retfd)
Connect the subsystem for YControl using a server root.
Definition: subsystem.c:1365
void cleanup_subsystem_ycontrol(status_t res)
Cleanup the subsystem variables.
Definition: subsystem.c:1424
int run_subsystem_ex(proto_id_t protocol_id, int trace_level, int argc, char **argv, char **envp, subsys_stdin_fn_t stdin_fn, subsys_stdout_fn_t stdout_fn, int32 stdin_len)
Run the subsystem : entry point (extended)
Definition: subsystem.c:1149
status_t(* subsys_stdout_fn_t)(const char *buff, size_t bufflen)
STDOUT FUNCTION TEMPLATE subsys_stdout_fn_t.
Definition: subsystem.h:149
ssize_t(* subsys_stdin_fn_t)(char *buff, size_t bufflen)
STDIN FUNCTION TEMPLATE subsys_stdin_fn_t.
Definition: subsystem.h:162
status_t init_subsystem_ycontrol(int trace_level, const char *subsys_id)
@
Definition: subsystem.c:1269
@ PROTO_ID_NONE
not set
Definition: subsystem.h:119
@ PROTO_ID_WEBUI
WebUI.
Definition: subsystem.h:131
@ PROTO_ID_NETCONF
NETCONF.
Definition: subsystem.h:122
@ PROTO_ID_RESTCONF
RESTCONF.
Definition: subsystem.h:137
@ PROTO_ID_YANGAPI
YANG-API.
Definition: subsystem.h:125
@ PROTO_ID_YCONTROL
YControl subsystem.
Definition: subsystem.h:134
global error status code enumerations