/usr/include/libopenmpt/libopenmpt_stream_callbacks_fd.h is in libopenmpt-dev 0.2.7386~beta20.3-3+deb9u3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 71 72 73 74 75 76 77 78 79 80 81 | /*
* libopenmpt_stream_callbacks_fd.h
* --------------------------------
* Purpose: libopenmpt public c interface
* Notes : (currently none)
* Authors: OpenMPT Devs
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
*/
#ifndef LIBOPENMPT_STREAM_CALLBACKS_FD_H
#define LIBOPENMPT_STREAM_CALLBACKS_FD_H
#include "libopenmpt.h"
#ifdef _MSC_VER
#include <io.h>
#endif
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#ifndef _MSC_VER
#include <unistd.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* This stuff has to be in a header file because of possibly different MSVC CRTs which cause problems for fd crossing CRT boundaries. */
static size_t openmpt_stream_fd_read_func( void * stream, void * dst, size_t bytes ) {
int fd = 0;
#if defined(_MSC_VER)
size_t retval = 0;
int to_read = 0;
int ret_read = 0;
#else
ssize_t retval = 0;
#endif
fd = (int)(uintptr_t)stream;
if ( fd < 0 ) {
return 0;
}
#if defined(_MSC_VER)
retval = 0;
while ( bytes > 0 ) {
to_read = 0;
if ( bytes < (size_t)INT_MAX ) {
to_read = (int)bytes;
} else {
to_read = INT_MAX;
}
ret_read = _read( fd, dst, to_read );
if ( ret_read <= 0 ) {
return retval;
}
bytes -= ret_read;
retval += ret_read;
}
#else
retval = read( fd, dst, bytes );
#endif
if ( retval <= 0 ) {
return 0;
}
return retval;
}
static openmpt_stream_callbacks openmpt_stream_get_fd_callbacks(void) {
openmpt_stream_callbacks retval;
memset( &retval, 0, sizeof( openmpt_stream_callbacks ) );
retval.read = openmpt_stream_fd_read_func;
return retval;
}
#ifdef __cplusplus
}
#endif
#endif /* LIBOPENMPT_STREAM_CALLBACKS_FD_H */
|