Instrument Neutral Distributed Interface INDI 2.2.5
Utils.hpp
Go to the documentation of this file.
1/* INDI Server for protocol version 1.7.
2 * Copyright (C) 2007 Elwood C. Downey <[email protected]>
3 2013 Jasem Mutlaq <[email protected]>
4 2022 Ludovic Pollet
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 "lilxml.h"
22
23#include <string>
24#include <vector>
25#include <unordered_map>
26
27void log(const std::string &log);
28/* Turn a printf format into std::string */
29std::string fmt(const char * fmt, ...) __attribute__ ((format (printf, 1, 0)));
30
31char *indi_tstamp(char *s);
32void logStartup(int ac, char *av[]);
33void noSIGPIPE(void);
34char *indi_tstamp(char *s);
35void logDMsg(XMLEle *root, const char *dev);
36void Bye(void);
37std::vector<XMLEle *> findBlobElements(XMLEle * root);
38int readFdError(int
39 fd); /* Read a pending error condition on the given fd. Return errno value or 0 if none */
40void * attachSharedBuffer(int fd, size_t &size);
41void dettachSharedBuffer(int fd, void * ptr, size_t size);
42bool parseBlobSize(XMLEle * blobWithAttachedBuffer, ssize_t &size);
43XMLEle * cloneXMLEleWithReplacementMap(XMLEle * root, const std::unordered_map<XMLEle*, XMLEle*> &replacement);
44
45#define STRINGIFY_TOK(x) #x
46#define TO_STRING(x) STRINGIFY_TOK(x)
void log(const std::string &log)
Definition Utils.cpp:161
void logDMsg(XMLEle *root, const char *dev)
Definition Utils.cpp:78
XMLEle * cloneXMLEleWithReplacementMap(XMLEle *root, const std::unordered_map< XMLEle *, XMLEle * > &replacement)
Definition Utils.cpp:143
bool parseBlobSize(XMLEle *blobWithAttachedBuffer, ssize_t &size)
Definition Utils.cpp:114
std::string char * indi_tstamp(char *s)
Definition Utils.cpp:62
std::vector< XMLEle * > findBlobElements(XMLEle *root)
Definition Utils.cpp:148
void dettachSharedBuffer(int fd, void *ptr, size_t size)
Definition Utils.cpp:231
int readFdError(int fd)
Definition Utils.cpp:167
std::string fmt(const char *fmt,...) __attribute__((format(printf
void Bye(void)
Definition Utils.cpp:108
void logStartup(int ac, char *av[])
Definition Utils.cpp:33
void * attachSharedBuffer(int fd, size_t &size)
Definition Utils.cpp:211
void noSIGPIPE(void)
Definition Utils.cpp:48
__attribute__((__format__(__printf__, 2, 0))) void CelestronDriver
int fd
A little DOM-style library to handle parsing and processing an XML file.