blob: 09a67dc0b8c47f58911425e24492871b8afe76aa [file] [log] [blame]
Jorge Lucangeli Obesa6b034d2012-08-07 15:29:20 -07001/* util.h
2 * Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 *
6 * Logging and other utility functions.
7 */
8
9#ifndef _UTIL_H_
10#define _UTIL_H_
11
12#include <stdlib.h>
13#include <syslog.h>
14
15#define die(_msg, ...) do { \
16 syslog(LOG_ERR, "libminijail: " _msg, ## __VA_ARGS__); \
17 abort(); \
18} while (0)
19
20#define pdie(_msg, ...) \
21 die(_msg ": %s", ## __VA_ARGS__, strerror(errno))
22
23#define warn(_msg, ...) \
24 syslog(LOG_WARNING, "libminijail: " _msg, ## __VA_ARGS__)
25
26#define info(_msg, ...) \
27 syslog(LOG_INFO, "libminijail: " _msg, ## __VA_ARGS__)
28
Jorge Lucangeli Obesbda833c2012-07-31 16:25:56 -070029extern const char *log_syscalls[];
30extern const size_t log_syscalls_len;
31
Jorge Lucangeli Obesa6b034d2012-08-07 15:29:20 -070032int lookup_syscall(const char *name);
33const char *lookup_syscall_name(int nr);
34char *strip(char *s);
35
36#endif /* _UTIL_H_ */