File: sendfile.h

package info (click to toggle)
minidlna 1.2.1+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,484 kB
  • ctags: 1,727
  • sloc: ansic: 19,900; sh: 284; makefile: 61
file content (70 lines) | stat: -rw-r--r-- 1,575 bytes parent folder | download | duplicates (5)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* MiniDLNA media server
 * Copyright (C) 2013  NETGEAR
 *
 * This file is part of MiniDLNA.
 *
 * MiniDLNA is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * MiniDLNA is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MiniDLNA. If not, see <http://www.gnu.org/licenses/>.
 */
#if defined(HAVE_LINUX_SENDFILE_API)

#include <sys/sendfile.h>

int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
{
	return sendfile(sock, sendfd, offset, len);
}

#elif defined(HAVE_DARWIN_SENDFILE_API)

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>

int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
{
	int ret;

	ret = sendfile(sendfd, sock, *offset, &len, NULL, 0);
	*offset += len;

	return ret;
}

#elif defined(HAVE_FREEBSD_SENDFILE_API)

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>

int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
{
	int ret;
	size_t nbytes = len;

	ret = sendfile(sendfd, sock, *offset, nbytes, NULL, &len, SF_MNOWAIT);
	*offset += len;

	return ret;
}

#else

#include <errno.h>

int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
{
	errno = EINVAL;
	return -1;
}

#endif