diff options
author | Mattias Andrée <maandree@kth.se> | 2019-11-01 22:06:40 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2019-11-01 22:06:40 +0100 |
commit | c57844b08bced71778f38f2346464c3e0836287c (patch) | |
tree | e3733b4c99818ee6c77ed3d4d37becf30f92268f /sockatmark.c | |
parent | Use installed liberror (diff) | |
download | liberror-libc-c57844b08bced71778f38f2346464c3e0836287c.tar.gz liberror-libc-c57844b08bced71778f38f2346464c3e0836287c.tar.bz2 liberror-libc-c57844b08bced71778f38f2346464c3e0836287c.tar.xz |
Add some functions and add functions with _failed suffix
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'sockatmark.c')
-rw-r--r-- | sockatmark.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sockatmark.c b/sockatmark.c new file mode 100644 index 0000000..aa5a20e --- /dev/null +++ b/sockatmark.c @@ -0,0 +1,37 @@ +/* See LICENSE file for copyright and license details. */ +#include "internal.h" + + +void +liberror_sockatmark_failed(int fd, const char *fname) +{ + const char *desc; + switch (errno) { + case EBADF: + if (fd < 0) + desc = "Negative file descriptor number specified"; + else + desc = "Unassigned file descriptor number specified"; + break; + case ENOTSOCK: + case ENOTTY: + case EINVAL: + desc = "Operation not supported by specified file"; + break; + default: + desc = ""; + break; + } + liberror_libc_set_error_one_file(desc, "sockatmark", "Socket file", fd, fname); +} + + +int +liberror_sockatmark(int fd, const char *fname) +{ + if (!sockatmark(fd)) + return 0; + liberror_save_backtrace(NULL); + liberror_sockatmark_failed(fd, fname); + return -1; +} |