问题描述
我正在尝试在IBM iseries上使用(来自AIX)。
应该可以使用。
I am trying to use the pcre library (from AIX) on IBM iseries.It should be possible using PASE.
我使用。
我试图在Cile来源中使用它,但我无法实现它。
示例:,
我找不到办法。
这是我到目前为止所做的。
I can't find the way to do it.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;
}
推荐答案
今天我尝试了相同的方法我可以使用CRTCMOD将编译为ILE。
Today I tried the same and I could compile pcre to ILE using CRTCMOD.
在zip中-pcre文件,您可以找到一个名为NON_AUTOTOOLS_BUILD的文件(如果我没有记错这个名字的话),其中包含编译该文件所需的所有信息。
In the zip-file of pcre you can find a file named NON_AUTOTOOLS_BUILD (if I remember the name correctly) with with all information needed to compile it.
实际上,您只需要:
- 编辑config.h以匹配您的环境(可用功能(例如memmove,pthreads,EBCDIC支持和NewLine = 37(x'25 '))
- 使用CRTBNDC DEFINE(HAVE_CONFIG_H)编译dftables.c ...
- 调用DFTABLES生成EBCDIC的字符表(此步骤有点棘手,因为它无法打开IFS文件进行输出。因此我将输出放入源成员中,并使用CPYTOSTMF将其放入IFS中)
- 编译所有.c文件都未使用CRTCMOD DEFINE(HAVE_CONFIG_H)...
- 从模块创建* SRVPGM
- 编写RPG原型
- edit config.h to match your environment (available functions 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 the character tables for EBCDIC (this step was a bit tricky, because it couldn't open the IFS-File for output. so I put the output in a source member and used CPYTOSTMF to get it in the IFS)
- compile the all the .c files unsing CRTCMOD DEFINE(HAVE_CONFIG_H) ...
- create a *SRVPGM from the modules
- write the Prototypes for RPG
它的工作原理很吸引人,除了一个小问题使用CCSID。我为CCSID 1141生成了图表,但是由于某些原因,PCRE期望输入为CCSID 37。
It works like a charm, except for a little problem with CCSIDs. I generated the chartables for CCSID 1141, but for some reason PCRE expects input to be CCSID 37.
还要注意,如果使用RPG编写原型,则 pcre_free 很特殊。此功能未在PCRE中实现(您可以编写自己的功能并根据需要插入),默认为 free 。您的原型应该看起来像
Also note that, if you write the prototypes in RPG, pcre_free is special. This function is not implemented in PCRE (you could write your own and plug it in if you want) and defaults to free. Your prototype should look like
Dpcre_free PR EXTPROC('free')
D * value
希望有帮助
这篇关于在ILE上使用PCRE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!