Instrument Neutral Distributed Interface INDI  2.0.2
userio.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2021 by Pawel Soja <kernel32.pl@gmail.com>
3  2022 by Ludovic Pollet
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 #pragma once
20 
21 #include <stdarg.h>
22 #include <indimacros.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 typedef struct userio
29 {
30  ssize_t (*write)(void *user, const void * ptr, size_t count);
31  int (*vprintf)(void *user, const char * format, va_list arg);
32 
33  // join the given shared buffer as ancillary data. xml must be at least one char - optional
34  void (*joinbuff)(void * user, const char * xml, void * buffer, size_t bloblen);
36 
37 const struct userio *userio_file();
38 
39 ssize_t userio_printf(const struct userio *io, void *user, const char * format, ...);
40 ssize_t userio_vprintf(const struct userio *io, void *user, const char * format, va_list arg);
41 
42 ssize_t userio_write(const struct userio *io, void *user, const void * ptr, size_t count);
43 
44 ssize_t userio_putc(const struct userio *io, void *user, int ch);
45 
46 // extras
47 ssize_t userio_prints(const struct userio *io, void *user, const char *str);
48 size_t userio_xml_escape(const struct userio *io, void *user, const char *src);
49 void userio_xmlv1(const userio *io, void *user);
50 
51 #ifdef __cplusplus
52 }
53 #endif
std::vector< uint8_t > buffer
Definition: userio.h:29
void(* joinbuff)(void *user, const char *xml, void *buffer, size_t bloblen)
Definition: userio.h:34
int(* vprintf)(void *user, const char *format, va_list arg)
Definition: userio.h:31
ssize_t(* write)(void *user, const void *ptr, size_t count)
Definition: userio.h:30
ssize_t userio_prints(const struct userio *io, void *user, const char *str)
Definition: userio.c:64
ssize_t userio_vprintf(const struct userio *io, void *user, const char *format, va_list arg)
Definition: userio.c:54
ssize_t userio_write(const struct userio *io, void *user, const void *ptr, size_t count)
Definition: userio.c:59
ssize_t userio_printf(const struct userio *io, void *user, const char *format,...)
Definition: userio.c:44
size_t userio_xml_escape(const struct userio *io, void *user, const char *src)
Definition: userio.c:75
ssize_t userio_putc(const struct userio *io, void *user, int ch)
Definition: userio.c:69
const struct userio * userio_file()
Definition: userio.c:39
void userio_xmlv1(const userio *io, void *user)
Definition: userio.c:104
struct userio userio