Instrument Neutral Distributed Interface INDI 2.2.5
userio.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 by Pawel Soja <[email protected]>
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
25extern "C" {
26#endif
27
28typedef 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
37const struct userio *userio_file();
38
39ssize_t userio_printf(const struct userio *io, void *user, const char * format, ...);
40ssize_t userio_vprintf(const struct userio *io, void *user, const char * format, va_list arg);
41
42ssize_t userio_write(const struct userio *io, void *user, const void * ptr, size_t count);
43
44ssize_t userio_putc(const struct userio *io, void *user, int ch);
45
46// extras
47ssize_t userio_prints(const struct userio *io, void *user, const char *str);
48size_t userio_xml_escape(const struct userio *io, void *user, const char *src);
49void userio_xmlv1(const userio *io, void *user);
50
51#ifdef __cplusplus
52}
53#endif
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
void userio_xmlv1(const userio *io, void *user)
Definition userio.c:104
const struct userio * userio_file()
Definition userio.c:39