/usr/lib/swi-prolog/include/stub.c is in swi-prolog-nox 5.10.4-3ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | /* $Id$
Part of SWI-Prolog
Author: Jan Wielemaker
E-mail: J.Wielemaker@cs.vu.nl
WWW: http://www.swi-prolog.org
Copyright (C): 1985-2002, University of Amsterdam
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <SWI-Prolog.h>
#define READLINE 1 /* use readline interface */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
C-extensions can either be loaded through the foreign language interface
using load_foreign_library/[1,2] or they can be statically linked with
the Prolog kernel.
In the latter case, proceed as follows:
1) Make a copy of this file. In this copy:
2) Fill the table below for adding foreign functions as predicates
3) Replace the main() below with your own main(). You can pass
the main arguments or your own argument (using the systems
conventions). Make sure to pass the name of the program as
first argument.
4) Normally #undef READLINE (above), unless your embedded version
provided access to the Prolog toplevel for which you want to
use readline.
5) Use swipl-ld(1) to link this file, and possible Prolog sources to
a single executable:
swipl-ld -o myprog myprog.c myprog.pl
See man swipl-ld and/or the SWI-Prolog manuals for further details.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static const PL_extension predicates[] =
{
/*{ "name", arity, function, PL_FA_<flags> },*/
{ NULL, 0, NULL, 0 } /* terminating line */
};
#ifdef READLINE
static void
install_readline(int argc, char**argv)
{ PL_install_readline();
}
#endif
int
main(int argc, char **argv)
{
#ifdef READLINE
PL_initialise_hook(install_readline);
#endif
PL_register_extensions(predicates); /* This is the only PL_ call allowed */
/* before PL_initialise(). It */
/* ensures the foreign predicates */
/* are available before loading */
/* Prolog code */
if ( !PL_initialise(argc, argv) )
PL_halt(1);
PL_halt(PL_toplevel() ? 0 : 1);
return 0;
}
|