lib/roken: add fseeko()/ftello()
authorNicolas Williams <nico@twosigma.com>
Fri, 26 May 2017 20:44:42 +0000 (15:44 -0500)
committerViktor Dukhovni <viktor1ghub@dukhovni.org>
Sat, 27 May 2017 03:24:30 +0000 (23:24 -0400)
configure.ac
include/config.h.w32
lib/roken/Makefile.am
lib/roken/NTMakefile
lib/roken/fseeko.c [new file with mode: 0644]
lib/roken/ftello.c [new file with mode: 0644]
lib/roken/version-script.map

index fb3e22373f7ab1ac58b1709c70456bf36587998f..01bf32032bea71f664dda9d974c327a1a45e77bb 100644 (file)
@@ -465,6 +465,8 @@ AC_CHECK_FUNCS([                            \
        backtrace                               \
        fcntl                                   \
        fork                                    \
+       fseeko                                  \
+       ftello                                  \
        getpeereid                              \
        getpeerucred                            \
        getresgid                               \
index 993268def591db7abf5fed4cf72d1275f8513994..d52eb6b67d01186f643ebe245c79dd6aba337004 100644 (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 */
 
index 92b8903246bf7bca81a4d18c7cee68b93f2242bf..e6fd256917b9124c7b4fc7a43bd10824edfe04bb 100644 (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       \
index a14a7ee51d1c887cb90b91810e32fc448bac6903..c0f837ed02ee384746e0eac01a8fa73566ce0de3 100644 (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 \
diff --git a/lib/roken/fseeko.c b/lib/roken/fseeko.c
new file mode 100644 (file)
index 0000000..b6ffaa2
--- /dev/null
@@ -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
diff --git a/lib/roken/ftello.c b/lib/roken/ftello.c
new file mode 100644 (file)
index 0000000..cd3b84b
--- /dev/null
@@ -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
index 4cb0111188c3baa2d7a53a2bbb86c871e9a5722a..7c1a01735800750d01c1c4bf783418b1e0995901 100644 (file)
@@ -12,6 +12,8 @@ HEIMDAL_ROKEN_1.0 {
                err;
                errx;
                free_getarg_strings;
+               fseeko;
+               ftello;
                get_default_username;
                get_window_size;
                getarg;