1 /*\
2  *  Copyright (C) International Business Machines  Corp., 2005
3  *  Author(s): Anthony Liguori <aliguori@us.ibm.com>
4  *
5  *  Xen Console Daemon
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; under version 2 of the License.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; If not, see <http://www.gnu.org/licenses/>.
18 \*/
19 
20 #ifndef CONSOLED_UTILS_H
21 #define CONSOLED_UTILS_H
22 
23 #include <stdbool.h>
24 #include <syslog.h>
25 #include <stdio.h>
26 #define XC_WANT_COMPAT_MAP_FOREIGN_API
27 #include <xenctrl.h>
28 
29 #include <xenstore.h>
30 
31 void daemonize(const char *pidfile);
32 bool xen_setup(void);
33 
34 extern struct xs_handle *xs;
35 extern xc_interface *xc;
36 
37 #if 1
38 #define dolog(val, fmt, ...) do {				\
39 	if ((val) == LOG_ERR)					\
40 		fprintf(stderr, fmt "\n", ## __VA_ARGS__);	\
41 	syslog(val, fmt, ## __VA_ARGS__);			\
42 } while (/* CONSTCOND */0)
43 #else
44 #define dolog(val, fmt, ...) fprintf(stderr, fmt "\n", ## __VA_ARGS__)
45 #endif
46 
47 #endif
48