/* WARNING: This file was generated by dkct. Changes you make here will be lost if dkct is run again! You should modify the original source and run dkct on it. Original source: dk4fdrda.ctr */ /* Copyright (C) 2015-2017, Dirk Krause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above opyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** @file dk4fdrda.c The dk4fdrda module. */ #line 40 "dk4fdrda.ctr" #include "dk4fdrda.h" #include "dk4fdrde.h" #if DK4_HAVE_UNISTD_H #ifndef UNISTD_H_INCLUDED #include #define UNISTD_H_INCLUDED 1 #endif #endif #if DK4_HAVE_ERRNO_H #ifndef ERRNO_H_INCLUDED #include #define ERRNO_H_INCLUDED 1 #endif #endif #if DK4_HAVE_IO_H #ifndef IO_H_INCLUDED #include #define IO_H_INCLUDED 1 #endif #endif #line 68 "dk4fdrda.ctr" #ifdef RW_MAX #undef RW_MAX #endif #if DK4_ON_WINDOWS /** Maximum number of bytes for read or write operation. */ #define RW_MAX (INT_MAX) #else /** Maximum number of bytes for read or write operation. */ #define RW_MAX ((SIZE_MAX) / 2U) #endif int dk4fd_read_app( int fd, void *buffer, size_t *psz, const dkChar *fn, dk4_app_t *app ) { #if DK4_ON_WINDOWS int res; #else ssize_t res; #endif int back = 0; #line 98 "dk4fdrda.ctr" if ((-1 != fd) && (NULL != buffer) && (NULL != psz)) { if (0 < *psz) { if ((dk4_um_t)RW_MAX >= (dk4_um_t)(*psz)) { errno = 0; #if DK4_ON_WINDOWS res = _read(fd, buffer, (unsigned)(*psz)); #else res = read(fd, buffer, *psz); #endif if (0 <= res) { if (0 < res) { #line 109 "dk4fdrda.ctr" back = 1; *psz = (size_t)res; } else { #line 112 "dk4fdrda.ctr" back = 1; *psz = (size_t)0; } } else { #line 116 "dk4fdrda.ctr" dk4fd_read_error_msg(app, fn, errno); } } } else { #line 120 "dk4fdrda.ctr" } } else { #line 122 "dk4fdrda.ctr" } #line 123 "dk4fdrda.ctr" return back; }