示例: 从 ILE C 调用 ILE API

下图显示了包含对 ILE API 的调用的 func1() 的 ILE C 源代码。 API 用于确定 func1()中声明的字符串参数的字符串类型,长度和最大长度。 typeCharZtypeCharV2 的值可在 ILE API 头文件 <leod.h> 中找到。
图 1。 ILE C 用于确定函数中的字符串参数的源
#include <string.h>
#include <stdio.h>
#include <leawi.h>
#include <leod.h>
#include "oper_desc.h"
int func1(char a[5], char b[5], char *c)
{
   int        posn      = 1;
   int        datatype;
   int        currlen;
   int        maxlen;
   _FEEDBACK  fc;
   char      *string1;
   /* Call to ILE API CEEGSI to determine string type, length    */
   /* and the maximum length.                                    */
   CEEGSI(&posn, &datatype, &currlen, &maxlen, &fc);
   switch(datatype)
   {
     case typeCharZ:
        string1 = a;
        break;
     case typeCharV2:
        string1 = a + 2;
        break;
   }
   /* Use string1.                                               */
   if (!memcmp(string1, "stuv", currlen))
      printf("First 4 characters are the same.\n");
   else
      printf("First 4 characters are not the same.\n");
}