"Fossies" - the Fresh Open Source Software Archive

Member "minidlna-1.3.0/sendfile.h" (24 Nov 2020, 1566 Bytes) of package /linux/privat/minidlna-1.3.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "sendfile.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.2.1_vs_1.3.0.

    1 /* MiniDLNA media server
    2  * Copyright (C) 2013  NETGEAR
    3  *
    4  * This file is part of MiniDLNA.
    5  *
    6  * MiniDLNA is free software; you can redistribute it and/or modify
    7  * it under the terms of the GNU General Public License version 2 as
    8  * published by the Free Software Foundation.
    9  *
   10  * MiniDLNA is distributed in the hope that it will be useful,
   11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13  * GNU General Public License for more details.
   14  *
   15  * You should have received a copy of the GNU General Public License
   16  * along with MiniDLNA. If not, see <http://www.gnu.org/licenses/>.
   17  */
   18 #if defined(HAVE_LINUX_SENDFILE_API)
   19 
   20 #include <sys/sendfile.h>
   21 
   22 int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
   23 {
   24     return sendfile(sock, sendfd, offset, len);
   25 }
   26 
   27 #elif defined(HAVE_DARWIN_SENDFILE_API)
   28 
   29 #include <sys/types.h>
   30 #include <sys/socket.h>
   31 #include <sys/uio.h>
   32 
   33 int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
   34 {
   35     int ret;
   36 
   37     ret = sendfile(sendfd, sock, *offset, &len, NULL, 0);
   38     *offset += len;
   39 
   40     return ret;
   41 }
   42 
   43 #elif defined(HAVE_FREEBSD_SENDFILE_API)
   44 
   45 #include <sys/types.h>
   46 #include <sys/socket.h>
   47 #include <sys/uio.h>
   48 
   49 int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
   50 {
   51     int ret;
   52     size_t nbytes = len;
   53 
   54     ret = sendfile(sendfd, sock, *offset, nbytes, NULL, &len, 0);
   55     *offset += len;
   56 
   57     return ret;
   58 }
   59 
   60 #else
   61 
   62 #include <errno.h>
   63 
   64 int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
   65 {
   66     errno = EINVAL;
   67     return -1;
   68 }
   69 
   70 #endif