/*
Copyright (C) 2017 Markus Mützel
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 (HAVE_CONFIG_H)
# include "config.h"
#endif
#include
#include "defun-dld.h"
#include "error.h"
#include "oct-shlib.h"
#include "ovl.h"
DEFUN_DLD (check_lib_fcn, args, ,
"-*- texinfo -*-\
@deftypefn {} {@var{info} =} check_lib_fcn (@var{libname}, @var{fcnname})\
Return true if function @var{fcnname} exists in library @var{libname}.\
\
@end deftypefn */")
{
if (args.length () != 2)
print_usage ();
std::string libname = args(0).xstring_value ("check_lib_fcn: LIBNAME must be a string");
std::string fcnname = args(1).xstring_value ("check_lib_fcn: FCNNAME must be a string");
octave::dynamic_library lib (libname);
if (! lib)
error ("unable to load library %s", libname.c_str ());
void * fcn = lib.search (fcnname);
bool result = fcn != nullptr;
return ovl (result);
}