lib/roken: add fseeko()/ftello()

This commit is contained in:
Nicolas Williams
2017-05-26 15:44:42 -05:00
committed by Viktor Dukhovni
parent 3fb30ff0a6
commit 123f702001
7 changed files with 118 additions and 2 deletions

View File

@@ -465,6 +465,8 @@ AC_CHECK_FUNCS([ \
backtrace \
fcntl \
fork \
fseeko \
ftello \
getpeereid \
getpeerucred \
getresgid \

View File

@@ -1,5 +1,5 @@
/***********************************************************************
* Copyright (c) 2009-2016, Secure Endpoints Inc.
* Copyright (c) 2009-2017, Secure Endpoints Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -355,6 +355,18 @@ static const char *const rcsid[] = { (const char *)rcsid, "@(#)" msg }
/* Define to 1 if you have the <fnmatch.h> header file. */
/* #undef HAVE_FNMATCH_H */
/* Define if you have the function `fseeko'. */
/* #undef HAVE_FSEEKO */
/* Define if you have the function `ftello'. */
/* #undef HAVE_FTELLO */
/* Define if you have the function `_fseeki64'. */
#define HAVE__FSEEKI64 1
/* Define if you have the function `_ftelli64'. */
#define HAVE__FTELLI64 1
/* Define if el_init takes four arguments. */
/* #undef HAVE_FOUR_VALUED_EL_INIT */

View File

@@ -89,6 +89,8 @@ libroken_la_SOURCES = \
eread.c \
esetenv.c \
ewrite.c \
fseeko.c \
ftello.c \
getaddrinfo_hostspec.c \
get_default_username.c \
get_window_size.c \

View File

@@ -1,6 +1,6 @@
########################################################################
#
# Copyright (c) 2009, Secure Endpoints Inc.
# Copyright (c) 2009 - 2017, Secure Endpoints Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -55,6 +55,8 @@ libroken_la_OBJS = \
$(OBJ)\ewrite.obj \
$(OBJ)\flock.obj \
$(OBJ)\fnmatch.obj \
$(OBJ)\fseeko.obj \
$(OBJ)\ftello.obj \
$(OBJ)\getauxval.obj \
$(OBJ)\getaddrinfo_hostspec.obj \
$(OBJ)\get_default_username.obj \

48
lib/roken/fseeko.c Normal file
View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 2017 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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.
*/
#include <config.h>
#include "roken.h"
#ifndef HAVE_FSEEKO
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
fseeko(FILE *f, off_t o, int w)
{
#ifdef HAVE__FSEEKI64
return _fseeki64(f, o, w);
#else
return fseek(f, o, w);
#endif
}
#endif

48
lib/roken/ftello.c Normal file
View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 2017 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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.
*/
#include <config.h>
#include "roken.h"
#ifndef HAVE_FTELLO
ROKEN_LIB_FUNCTION off_t ROKEN_LIB_CALL
ftello(FILE *f)
{
#ifdef HAVE__FTELLI64
return _ftelli64(f);
#else
return ftell(f);
#endif
}
#endif

View File

@@ -12,6 +12,8 @@ HEIMDAL_ROKEN_1.0 {
err;
errx;
free_getarg_strings;
fseeko;
ftello;
get_default_username;
get_window_size;
getarg;