【问题标题】:Using PCRE on ILE在 ILE 上使用 PCRE
【发布时间】:2013-09-06 10:47:27
【问题描述】:

我正在尝试在 IBM iseries 上使用 pcre library(来自 AIX)。 应该可以使用PASE

我用yips提供的rpm安装了pcre库。 我试图在 c ile 源代码中使用它,但我无法实现它。 示例:yipsibmibm redbook

我找不到办法。 这是我到目前为止所做的。

#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;
}

【问题讨论】:

    标签: regex ibm-midrange aix


    【解决方案1】:

    今天我尝试了同样的方法,我可以使用 CRTCMOD 将 pcre 编译为 ILE。

    在 pcre 的 zip 文件中,您可以找到一个名为 NON_AUTOTOOLS_BUILD 的文件(如果我没记错的话),其中包含编译它所需的所有信息。

    其实你只需要:

    • 编辑 config.h 以匹配您的环境(memmove 等可用功能、pthread 等功能、EBCDIC 支持和 NewLine=37 (x'25'))
    • 使用 CRTBNDC DEFINE(HAVE_CONFIG_H) 编译 dftables.c ...
    • CALL DFTABLES 为 EBCDIC 生成字符表(这一步有点棘手,因为它无法打开 IFS 文件进行输出。所以我将输出放在源成员中并使用 CPYTOSTMF 将其放入国际金融服务协会)
    • 编译所有 .c 文件 unsing CRTCMOD DEFINE(HAVE_CONFIG_H) ...
    • 从模块创建 *SRVPGM
    • 为 RPG 编写原型

    它就像一个魅力,除了 CCSID 的一个小问题。我为 CCSID 1141 生成了图表,但出于某种原因,PCRE 期望输入为 CCSID 37。

    还要注意,如果你在 RPG 中编写原型,pcre_free 是特殊的。此功能在 PCRE 中未实现(您可以自己编写并根据需要插入),默认为 free。你的原型应该是这样的

    dpcre_free PR EXTPROC('free') D * 值

    *空格不准确

    希望有帮助

    【讨论】:

      猜你喜欢
      • 2015-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-07
      • 1970-01-01
      • 2022-04-20
      • 2020-01-27
      • 1970-01-01
      相关资源
      最近更新 更多