# HG changeset patch # User John W. Eaton # Date 1465913852 14400 # Node ID 8fcc81df840c04d728e5d07ba0ef0cdaa93af7d2 # Parent 3ca0a5b1b3130e2ece0d8b8b5783de1a217a0da2 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 diff -r 3ca0a5b1b313 -r 8fcc81df840c liboctave/util/oct-base64.cc --- 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 -#include - #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 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) diff -r 3ca0a5b1b313 -r 8fcc81df840c liboctave/wrappers/base64-wrappers.c --- /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 +. + +*/ + +// 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); +} diff -r 3ca0a5b1b313 -r 8fcc81df840c liboctave/wrappers/base64-wrappers.h --- /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 +. + +*/ + +#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 diff -r 3ca0a5b1b313 -r 8fcc81df840c liboctave/wrappers/module.mk --- 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 \