The examples illustrated in this topic show an ILE program that calls an i5/OS™ PASE program, and the i5/OS PASE program that is called by the ILE program.
The following ILE program calls an i5/OS PASE program. Following this example is an example of the i5/OS PASE code that this program calls.
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> /* include file for QP2RunPase(). */ #include <qp2user.h> /****************************************** Sample: A simple ILE C program to invoke an i5/OS PASE program using QP2RunPase() and passing one string parameter. Example compilation: CRTCMOD MODULE(MYLIB/SAMPLEILE) SRCFILE(MYLIB/QCSRC) CRTPGM PGM(MYLIB/SAMPLEILE) ******************************************/ void main(int argc, char*argv[]) { /* Path name of PASE program */ char *PasePath = "/home/samplePASE"; /* Return code from QP2RunPase() */ int rc; /* The parameter to be passed to the i5/OS PASE program */ char *PASE_parm = "My Parm"; /* Argument list for i5/OS PASE program, which is a pointer to a list of pointers */ char **arg_list; /* allocate the argument list */ arg_list =(char**)malloc(3 * sizeof(*arg_list)); /* set program name as first element. This is a UNIX convention */ arg_list[0] = PasePath; /* set parameter as first element */ arg_list[1] = PASE_parm; /* last element of argument list must always be null */ arg_list[2] = 0; /* Call i5/OS PASE program. */ rc = Qp2RunPase(PasePath, /* Path name */ NULL, /* Symbol for calling to ILE, not used in this sample */ NULL, /* Symbol data for ILE call, not used here */ 0, /* Symbol data length for ILE call, not used here */ 819, /* ASCII CCSID for i5/OS PASE */ arg_list, /* Arguments for i5/OS PASE program */ NULL); /* Environment variable list, not used in this sample */ }
The following i5/OS PASE program is called by the above ILE program.
#include <stdio.h> /****************************************** Sample: A simple i5/OS PASE Program called from ILE using QP2RunPase() and accepting one string parameter. The ILE sample program expects this to be located at /home/samplePASE. Compile on AIX, then ftp to i5/OS. To ftp use the commands: > binary > site namefmt 1 > put samplePASE /home/samplePASE ******************************************/ int main(int argc, char *argv[]) { /* Print out a greeting and the parameter passed in. Note argv[0] is the program name, so, argv[1] is the parameter */ printf("Hello from i5/OS PASE program %s. Parameter value is \"%s\".\n", argv[0], argv[1]); return 0; }