Arnaldo Carvalho de Melo | fd0db10 | 2016-04-04 13:32:20 -0300 | [diff] [blame^] | 1 | /* |
| 2 | * System call table mapper |
| 3 | * |
| 4 | * (C) 2016 Arnaldo Carvalho de Melo <acme@redhat.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms and conditions of the GNU General Public License, |
| 8 | * version 2, as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | */ |
| 15 | |
| 16 | #include "syscalltbl.h" |
| 17 | #include <string.h> |
| 18 | #include <libaudit.h> |
| 19 | |
| 20 | |
| 21 | struct syscalltbl *syscalltbl__new(void) |
| 22 | { |
| 23 | struct syscalltbl *tbl = malloc(sizeof(*tbl)); |
| 24 | if (tbl) { |
| 25 | tbl->audit_machine = audit_detect_machine(); |
| 26 | } |
| 27 | return tbl; |
| 28 | } |
| 29 | |
| 30 | void syscalltbl__delete(struct syscalltbl *tbl) |
| 31 | { |
| 32 | free(tbl); |
| 33 | } |
| 34 | |
| 35 | const char *syscalltbl__name(const struct syscalltbl *tbl, int id) |
| 36 | { |
| 37 | return audit_syscall_to_name(id, tbl->audit_machine); |
| 38 | } |
| 39 | |
| 40 | int syscalltbl__id(struct syscalltbl *tbl, const char *name) |
| 41 | { |
| 42 | return audit_name_to_syscall(name, tbl->audit_machine); |
| 43 | } |