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