From Joerg.Herrmann@dfki.de  Thu Nov  9 14:00:13 2000
Received: from corp-200.dfki.uni-sb.de (corp-200.dfki.uni-sb.de [134.96.188.10])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id OAA28608
	for <prolog@swi.psy.uva.nl>; Thu, 9 Nov 2000 14:00:13 +0100 (MET)
Organization: DFKI Saarbruecken GmbH, D 66123 Saarbruecken
Received: from dfki.de (barzdins.dfki.uni-sb.de [134.96.184.63])
	by corp-200.dfki.uni-sb.de (8.8.8/8.8.8) with ESMTP id OAA13297;
	Thu, 9 Nov 2000 14:00:16 +0100 (MET)
Message-ID: <3A0AA0F3.B521FB10@dfki.de>
Date: Thu, 09 Nov 2000 14:04:51 +0100
From: Joerg Herrmann <Joerg.Herrmann@dfki.de>
X-Mailer: Mozilla 4.6 [en] (Win98; I)
X-Accept-Language: ru,en
MIME-Version: 1.0
To: prolog@swi.psy.uva.nl
Subject: Creating a DLL, parameter problem
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Hello,

I want to create a DLL from a SWI-Prolog source file hello.pl
As far as I understand your manual, the only way is to write a
C-Wrapper that calls the intended prolog predicates.
Below you will find such a wrapper.
I assume, one has to call plld -share -o <dll-output> pl.c hello.pl
for creating the dll or a share object under Linux.

If so, I like to know, how to adjust pl.c attached so that hello/2
accepts a second argument.
So far hello/2 gets only the first command line parameter in the case:

        plld -o test hello.pl pl.c
        ...
        test abc def

Thanks for your help!

Jörg Herrmann





     #include <stdio.h>
     #include <SWI-Prolog.h>

     #define TOPLEVEL_PREDICATE "hello"
     #define TOPLEVEL_PREDICATE_ARITY 2

     int
     main(int argc, char **argv)
     { 
       /* initialise Prolog */

       if ( !PL_initialise(
               TOPLEVEL_PREDICATE_ARITY,
               argv
               ) )
         PL_halt(1);

       /* Lookup TOPLEVEL_PREDICATE/TOPLEVEL_PREDICATE_ARITY: make the
arguments and call */

       {
         term_t pl_args = PL_new_term_refs(TOPLEVEL_PREDICATE_ARITY);
         PL_put_atom_chars(
           pl_args,
           argv[1]
           );
         PL_halt(
           PL_call_predicate(
             NULL, PL_Q_NORMAL,
             PL_predicate(
               TOPLEVEL_PREDICATE,
               TOPLEVEL_PREDICATE_ARITY,
               "user"
               ),
             pl_args
             ) ? 0 : 1);
       }

       return 0;
     }

