mirror of https://gerrit.osmocom.org/libtelnet
add ZMP send commands
This commit is contained in:
parent
94738a4b85
commit
e22b4771c7
33
libtelnet.c
33
libtelnet.c
|
@ -969,3 +969,36 @@ int telnet_printf2(telnet_t *telnet, const char *fmt, ...) {
|
|||
|
||||
return rs;
|
||||
}
|
||||
|
||||
/* send ZMP data */
|
||||
void telnet_send_zmp(telnet_t *telnet, size_t argc, const char **argv) {
|
||||
size_t i;
|
||||
|
||||
/* ZMP header */
|
||||
telnet_begin_sb(telnet, TELNET_TELOPT_ZMP);
|
||||
|
||||
/* send out each argument, including trailing NUL byte */
|
||||
for (i = 0; i != argc; ++i)
|
||||
telnet_send(telnet, argv[i], strlen(argv[i] + 1));
|
||||
|
||||
/* ZMP footer */
|
||||
telnet_finish_sb(telnet);
|
||||
}
|
||||
|
||||
/* send ZMP data using varargs */
|
||||
void telnet_send_zmpv(telnet_t *telnet, ...) {
|
||||
va_list va;
|
||||
const char* arg;
|
||||
|
||||
/* ZMP header */
|
||||
telnet_begin_sb(telnet, TELNET_TELOPT_ZMP);
|
||||
|
||||
/* send out each argument, including trailing NUL byte */
|
||||
va_start(va, telnet);
|
||||
while ((arg = va_arg(va, const char *)) != NULL)
|
||||
telnet_send(telnet, arg, strlen(arg) + 1);
|
||||
va_end(va);
|
||||
|
||||
/* ZMP footer */
|
||||
telnet_finish_sb(telnet);
|
||||
}
|
||||
|
|
26
libtelnet.h
26
libtelnet.h
|
@ -12,6 +12,15 @@
|
|||
#if !defined(LIBTELNET_INCLUDE)
|
||||
#define LIBTELNET_INCLUDE 1
|
||||
|
||||
/* printf type checking feature in GCC and some other compilers */
|
||||
#if __GNUC__
|
||||
# define TELNET_GNU_PRINTF(f,a) __attribute__((format(printf, f, a)))
|
||||
# define TELNET_GNU_SENTINEL __attribute__((sentinel))
|
||||
#else
|
||||
# define TELNET_GNU_PRINTF(f,a)
|
||||
# define TELNET_GNU_SENTINEL
|
||||
#endif
|
||||
|
||||
/* forward declarations */
|
||||
typedef struct telnet_t telnet_t;
|
||||
typedef struct telnet_event_t telnet_event_t;
|
||||
|
@ -235,17 +244,16 @@ extern void telnet_subnegotiation(telnet_t *telnet, unsigned char telopt,
|
|||
/* begin sending compressed data (server only) */
|
||||
extern void telnet_begin_compress2(telnet_t *telnet);
|
||||
|
||||
/* printf type checking feature in GCC and some other compilers */
|
||||
#if __GNUC__
|
||||
# define TELNET_GNU_PRINTF(f,a) __attribute__((printf(f, a)))
|
||||
#else
|
||||
# define TELNET_GNU_PRINTF(f,a)
|
||||
#endif
|
||||
|
||||
/* send formatted data with \r and \n translated, and IAC escaped */
|
||||
extern int telnet_printf(telnet_t *telnet, const char *fmt, ...);
|
||||
extern int telnet_printf(telnet_t *telnet, const char *fmt, ...)
|
||||
TELNET_GNU_PRINTF(2, 3);
|
||||
|
||||
/* send formatted data with just IAC escaped */
|
||||
extern int telnet_printf2(telnet_t *telnet, const char *fmt, ...);
|
||||
extern int telnet_printf2(telnet_t *telnet, const char *fmt, ...)
|
||||
TELNET_GNU_PRINTF(2, 3);
|
||||
|
||||
/* send ZMP commands */
|
||||
extern void telnet_send_zmp(telnet_t *telnet, size_t argc, const char **argv);
|
||||
extern void telnet_send_zmpv(telnet_t *telnet, ...) TELNET_GNU_SENTINEL;
|
||||
|
||||
#endif /* !defined(LIBTELNET_INCLUDE) */
|
||||
|
|
Loading…
Reference in New Issue