aboutsummaryrefslogtreecommitdiffstats
path: root/shutdown.c
blob: 3ccdfd038255048405fbe93220d6db37a8a291a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* See LICENSE file for copyright and license details. */
#include "internal.h"


int
liberror_shutdown(int fd, int how)
{
	const char *desc;
	if (!shutdown(fd, how))
		return 0;
	switch (errno) {
	case EBADF:
		desc = fd < 0 ? "Negative file descriptor number specified" : "Unassigned file descriptor number specified";
		break;
	case EINVAL:
		desc = "Invalid value of second parameter";
		break;
	case ENOTCONN:
		desc = "The socket is not connected";
		break;
	case ENOTSOCK:
		desc = "The specified file is not a socket";
		break;
	case ENOBUFS:
		desc = "Insufficient resource available in the system to perform the operation";
		break;
	default:
		desc = "";
		break;
	}
	liberror_set_error_errno(desc, "shutdown", errno);
	return -1;
}