Using PCRE on ILE

I am trying to use the pcre library (from AIX) on an IBM iseries. This should be possible with PASE .

I installed the pcre library with rpm provided by yips . I tried to use it in the source, but I could not achieve this. Examples: yips , ibm , ibm redbook

I can not find a way to do this. Here is what I have done so far.

#include <stdio.h> #include <qp2shell2.h> #include <qp2user.h> #define JOB_CCSID 0 int main(int argc, char *argv[]) { int rc; QP2_ptr64_t id; void *getpid_pase; const QP2_arg_type_t signature[] = { QP2_ARG_END }; QP2_word_t result; /* * Call QP2SHELL2 to run the OS/400 PASE program * /usr/lib/start32, which starts OS/400 PASE in * 32-bit mode (and leaves it active on return) */ QP2SHELL2("/usr/lib/start32"); /* * Qp2dlopen opens the global name space (rather than * loading a new shared executable) when the first * argument is a null pointer. Qp2dlsym locates the * function descriptor for the OS/400 PASE getpid * subroutine (exported by shared library libc.a) */ id = Qp2dlopen("/usr/lib/libpcre.a", QP2_RTLD_NOW, JOB_CCSID); getpid_pase = Qp2dlsym(id, "pcrecpp::RE", JOB_CCSID, NULL); //id = Qp2dlopen(NULL, QP2_RTLD_NOW, JOB_CCSID); //getpid_pase = Qp2dlsym(id, "getpid", JOB_CCSID, NULL); /* * Call Qp2CallPase to run the OS/400 PASE getpid * function, and print the result. Use Qp2errnop * to find and print the OS/400 PASE errno if the * function result was -1 */ rc = Qp2CallPase(getpid_pase, NULL, // no argument list signature, QP2_RESULT_WORD, &result); printf("OS/400 PASE getpid() = %i\n", result); if (result == -1) printf("OS/400 errno = %i\n", *Qp2errnop()); /* * Close the Qp2dlopen instance, and then call * Qp2EndPase to end OS/400 PASE in this job */ Qp2dlclose(id); Qp2EndPase(); return 0; } 
+2
source share
1 answer

Today I tried the same thing and I could compile pcre in ILE using CRTCMOD.

In the pcre zip file, you can find a file called NON_AUTOTOOLS_BUILD (if I remember the name correctly) with all the information needed to compile it.

In fact, you only need:

  • edit config.h to suit your environment (available features like memmove, features like pthreads, EBCDIC support and NewLine = 37 (x'25 '))
  • compile dftables.c using CRTBNDC DEFINE (HAVE_CONFIG_H) ...
  • CALL DFTABLES to generate character tables for EBCDIC (this step was a bit complicated because it wasn’t able to open the IFS file for output. So I put the output in the source element and used CPYTOSTMF to get it in IFS)
  • compile all .c files that do not support CRTCMOD DEFINE (HAVE_CONFIG_H) ...
  • create * SRVPGM from modules
  • write prototypes for RPG

It works like a charm, except for a slight problem with CCSID. I created diagrams for CCSID 1141, but for some reason PCRE expects input to be CCSID 37.

Also note that if you are writing prototypes in RPGs, pcre_free is special. This feature is not implemented in PCRE (you can write your own and connect if you want) and is free by default. Your prototype should look like

  Dpcre_free PR EXTPROC ('free')
 D * value

* white spaces are inaccurate

Hope that helps

+1
source

Source: https://habr.com/ru/post/1498614/


All Articles