21.02.2013 Views

System i: Programming i5/OS PASE - IBM

System i: Programming i5/OS PASE - IBM

System i: Programming i5/OS PASE - IBM

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

}<br />

{<br />

printf("fopen(\"SHUPE/<strong>PASE</strong>DATA\", \"r\") failed, "<br />

"errno = %i\n", errno);<br />

result = 2;<br />

}<br />

else<br />

{<br />

char buf[25];<br />

char *string;<br />

errno = 0;<br />

string = fgets(buf, sizeof(buf), fp);<br />

if (!string)<br />

{<br />

printf("fgets() EOF or error, errno = %i\n", errno);<br />

buf[0] = 0; /* null-terminate empty buffer */<br />

}<br />

src = buf;<br />

srcLen = strlen(buf) + 1;<br />

tgt = arg2; /* iconv output to arg2 buffer */<br />

tgtLen = srcLen;<br />

iconv(cd, &src, &srcLen, &tgt, &tgtLen);<br />

fclose(fp);<br />

}<br />

result = 1;<br />

/*<br />

* Close the conversion descriptor, and return the<br />

* result value determined above<br />

*/<br />

iconv_close(cd);<br />

return result;<br />

Example 3: Compiler commands to create the programs<br />

When you compile your <strong>i5</strong>/<strong>OS</strong> <strong>PASE</strong> program, you must use compiler options -qalign=natural and<br />

-qldbl128 to force relative 16-byte alignment of type long double, which is used inside type ILEpointer.<br />

This alignment is required by ILE in <strong>i5</strong>/<strong>OS</strong>. For option -bI:, you should enter the path name in which<br />

you saved as400_libc.exp:<br />

xlc -o <strong>PASE</strong>toILE -qldbl128 -qalign=natural<br />

-bI:/afs/rich.xyz.com/usr1/shupe/<strong>PASE</strong>/as400_libc.exp<br />

<strong>PASE</strong>toILE.c<br />

When you compile your ILE C module and service program, compile them with the teraspace option.<br />

Otherwise, <strong>i5</strong>/<strong>OS</strong> <strong>PASE</strong> cannot interact with them:<br />

CRTCMOD MODULE(MYLIB/MYMODULE)<br />

SRCFILE(MYLIB/SRCPF)<br />

TERASPACE(*YES *TSIFC)<br />

CRTSRVPGM SRVPGM(MYLIB/MYSRVPGM)<br />

MODULE(MYLIB/MOMODULE)<br />

Finally, you must compile your DDS and propagate at least one record of data:<br />

CRTPF FILE(MYLIB/MYDATAFILE)<br />

SRCFILE(MYLIB/SRCDDSF)<br />

SRCMBR(MYMEMBERNAME)<br />

Calling <strong>i5</strong>/<strong>OS</strong> programs from <strong>i5</strong>/<strong>OS</strong> <strong>PASE</strong><br />

You can take advantage of existing <strong>i5</strong>/<strong>OS</strong> programs (*PGM objects) when you create your <strong>i5</strong>/<strong>OS</strong> <strong>PASE</strong><br />

applications. In addition, you can use the systemCL() function to run the CL CALL command.<br />

<strong>i5</strong>/<strong>OS</strong> <strong>PASE</strong> 37

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!