changeset 21892:8fcc81df840c

hide gnulib base64 function header * liboctave/wrappers/base64-wrappers.c, liboctave/wrappers/base64-wrappers.h: New files. * liboctave/wrappers/module.mk: Update. * oct-base64.cc: Use wrapper functions
author John W. Eaton <jwe@octave.org>
date Tue, 14 Jun 2016 10:17:32 -0400
parents 3ca0a5b1b313
children 0a6f387d18d3
files liboctave/util/oct-base64.cc liboctave/wrappers/base64-wrappers.c liboctave/wrappers/base64-wrappers.h liboctave/wrappers/module.mk
diffstat 4 files changed, 94 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/util/oct-base64.cc	Mon Jun 13 20:06:51 2016 -0400
+++ b/liboctave/util/oct-base64.cc	Tue Jun 14 10:17:32 2016 -0400
@@ -26,9 +26,8 @@
 
 #include <algorithm>
 
-#include <base64.h>
-
 #include "Array.h"
+#include "base64-wrappers.h"
 #include "oct-base64.h"
 
 bool
@@ -36,7 +35,7 @@
 {
   bool ret = false;
 
-  size_t outlen = base64_encode_alloc (inc, inlen, out);
+  size_t outlen = octave_base64_encode_alloc_wrapper (inc, inlen, out);
 
   if (! out)
     {
@@ -58,12 +57,11 @@
 {
   Array<double> retval;
 
-  const char *inc = &(str[0]);
-
   char *out;
   size_t outlen;
 
-  bool ok = base64_decode_alloc (inc, str.length (), &out, &outlen);
+  bool ok = octave_base64_decode_alloc_wrapper (str.data (), str.length (),
+                                                &out, &outlen);
 
   if (! ok)
     (*current_liboctave_error_handler)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/wrappers/base64-wrappers.c	Tue Jun 14 10:17:32 2016 -0400
@@ -0,0 +1,47 @@
+/*
+
+Copyright (C) 2016 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+// The base64 functions are provided by gnulib.  We don't include gnulib
+// headers directly in Octave's C++ source files to avoid problems that
+// may be caused by the way that gnulib overrides standard library
+// functions.
+
+#if defined (HAVE_CONFIG_H)
+#  include "config.h"
+#endif
+
+#include "base64.h"
+
+#include "base64-wrappers.h"
+
+size_t
+octave_base64_encode_alloc_wrapper (const char *in, size_t inlen, char **out)
+{
+  return base64_encode_alloc (in, inlen, out);
+}
+
+bool
+octave_base64_decode_alloc_wrapper (const char *in, size_t inlen,
+                                    char **out, size_t *outlen)
+{
+  return base64_decode_alloc (in, inlen, out, outlen);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/wrappers/base64-wrappers.h	Tue Jun 14 10:17:32 2016 -0400
@@ -0,0 +1,41 @@
+/*
+
+Copyright (C) 2016 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+#if ! defined (octave_base64_wrappers_h)
+#define octave_base64_wrappers_h 1
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+extern size_t
+octave_base64_encode_alloc_wrapper (const char *in, size_t inlen, char **out);
+
+extern bool
+octave_base64_decode_alloc_wrapper (const char *in, size_t inlen,
+                                    char **out, size_t *outlen);
+
+#if defined __cplusplus
+}
+#endif
+
+#endif
--- a/liboctave/wrappers/module.mk	Mon Jun 13 20:06:51 2016 -0400
+++ b/liboctave/wrappers/module.mk	Tue Jun 14 10:17:32 2016 -0400
@@ -1,4 +1,5 @@
 NOINSTALL_WRAPPERS_INC = \
+  liboctave/wrappers/base64-wrappers.h \
   liboctave/wrappers/canonicalize-file-name-wrapper.h \
   liboctave/wrappers/gen-tempname-wrapper.h \
   liboctave/wrappers/hash-wrappers.h \
@@ -13,6 +14,7 @@
   liboctave/wrappers/vasprintf-wrapper.h
 
 WRAPPERS_SRC = \
+  liboctave/wrappers/base64-wrappers.c \
   liboctave/wrappers/canonicalize-file-name-wrapper.c \
   liboctave/wrappers/gen-tempname-wrapper.c \
   liboctave/wrappers/hash-wrappers.c \