Jorge Lucangeli Obes | a6b034d | 2012-08-07 15:29:20 -0700 | [diff] [blame] | 1 | /* 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 Obes | bda833c | 2012-07-31 16:25:56 -0700 | [diff] [blame] | 29 | extern const char *log_syscalls[]; |
| 30 | extern const size_t log_syscalls_len; |
| 31 | |
Jorge Lucangeli Obes | a6b034d | 2012-08-07 15:29:20 -0700 | [diff] [blame] | 32 | int lookup_syscall(const char *name); |
| 33 | const char *lookup_syscall_name(int nr); |
| 34 | char *strip(char *s); |
Jorge Lucangeli Obes | 66cfc14 | 2012-11-30 15:42:52 -0800 | [diff] [blame] | 35 | char *tokenize(char **stringp, const char *delim); |
Jorge Lucangeli Obes | a6b034d | 2012-08-07 15:29:20 -0700 | [diff] [blame] | 36 | |
| 37 | #endif /* _UTIL_H_ */ |