Oppolzer - Informatik / Blog


Blog-Hauptseite      Neuester Artikel      Älterer Artikel      Neuerer Artikel      Älterer gleiche Kategorie      Neuerer gleiche Kategorie

PL1-L - Diskussion über PL/1-Interface für PCRE (Perl compatible Reg. Ex)

Subject:

Re: calling C from PL/I....

From:

Bernd Oppolzer <bernd.oppolzer@T-ONLINE.DE>

Reply-To:

PL1 (language) discussions <PL1-L@LISTSERV.DARTMOUTH.EDU>

Date:

2014.02.25 23:49:45


Hello D.,

one more comment:

it will be necessary to make available the other functions of the package to the
PL/1 callers, too, of course, like pcre_malloc, and pcre_free etc. The "exec"
function, too.

As I mentioned already: when making such "libraries" available to PL/1 callers,
I normally code only ONE (!) C function which has an interface that is OK for
PL/1 and get's a function code which specifies, which particular function is
desired (alloc, compile, exec, free). This function calls all other functions of
the library, depending on the function code.

Let me try to point out, how such a PL/1 glue function could look:

int pl1_pcre
    (int *funccode,    /* function code, pointer only to support BYADDR */
     char *pattern,    /* char pattern */
     int *option,      /* option, pointer only to support BYADDR */
     pcre **result,    /* result for COMPILE, used for ALLOC, FREE etc. as well */
     char **perror,    /* error text pointer */
     int *erroffset,   /* error offset in input message */
     char *table);     /* translation table ??? */

I guess you see what the glue function has to do:

there has to be a switch statement depending on *funccode; in the different
cases of the switch, you have to pass the parameters to the original pcre_...
functions.

The interface to pl1_pcre can be called from a very old PL/1 compiler without
problems, because you need to pass only pointers; if your version of the
compiler doesn't support NODESCRIPTOR, you pass the addresses of the char
strings by overlays of scalars etc.; the int which is returned is the return
code; you can set the return code after the pcre_compile depending on the
presence of an error or you can test if the pcre result pointer is NULL or not.

As I've told already to Z.A., I would like very much to help you with this
project and to test it, but unfortunately I'm very busy these days with other
projects. And: at my customers site, I have access to an EP PL/1 compiler V3.9
(which is not the newest one, but still in maintenance, until 2015); but I may
not use it for private projects ... so the only way to help you with this is by
answering your questions here. Sorry about that.

Kind regards

Bernd



Am 25.02.2014 23:24, schrieb Bernd Oppolzer:
> Hello D.,
>
> some comments below.
>
> Kind regards
>
> Bernd

Blog-Hauptseite      Neuester Artikel      Älterer Artikel      Neuerer Artikel      Älterer gleiche Kategorie      Neuerer gleiche Kategorie