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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

(char**)&arg_list,<br />

NULL);<br />

/* open a shared library */<br />

QP2_ptr64_t openlib(char * libname) {<br />

QP2_ptr64_t id;<br />

int * paseErrno;<br />

}<br />

/* Qp2dlopen dynamically loads the specified library returning an<br />

* id value that can be used in calls to Qp2dlsym and Qp2dlcose */<br />

id = Qp2dlopen(libname,<br />

(QP2_RTLD_NOW |<br />

QP2_RTLD_MEMBER ),<br />

JOB_CCSID);<br />

if (id == 0) {<br />

printf("Qp2dlopen failed. ILE errno=%i\n", errno);<br />

if ((paseErrno=Qp2errnop()) != NULL)<br />

printf("Qp2dlopen failed. <strong>i5</strong>/<strong>OS</strong> <strong>PASE</strong> errno=%i\n", *paseErrno);<br />

printf("Qp2dlopen failed. Qp2dlerror = %s\n", Qp2dlerror());<br />

}<br />

return(id);<br />

/* find an exported symbol */<br />

void * findsym(const QP2_ptr64_t id, const char * functionname) {<br />

void * symbol;<br />

int * paseErrno;<br />

}<br />

/* Qp2dlsym locates the function descriptor for the<br />

* specified function */<br />

symbol = Qp2dlsym(id, functionname, JOB_CCSID, NULL);<br />

if (symbol == NULL) {<br />

printf("Qp2dlsym failed. ILE errno = %i\n", errno);<br />

if ((paseErrno=Qp2errnop()) != NULL)<br />

printf("Qp2dlsym failed. <strong>i5</strong>/<strong>OS</strong> <strong>PASE</strong> errno=%i\n", *paseErrno);<br />

printf("Qp2dlsym failed. Qp2dlerror = %s\n", Qp2dlerror());<br />

}<br />

return(symbol);<br />

/* call <strong>i5</strong>/<strong>OS</strong> <strong>PASE</strong> procedure */<br />

int call<strong>PASE</strong>(const void * functionsymbol,<br />

const void * arglist,<br />

const QP2_arg_type_t * signature,<br />

const QP2_result_type_t result_type,<br />

void * buf,<br />

const short buflen) {<br />

int * paseErrno;<br />

int rc;<br />

/* Call Qp2CallPase2 to run the unction function */<br />

rc = Qp2CallPase2(functionsymbol,<br />

arglist,<br />

signature,<br />

result_type,<br />

buf,<br />

buflen);<br />

if (rc != 0) {<br />

printf("Qp2CallPase failed. rc=%i, ILE errno=%i\n", rc, errno);<br />

if ((paseErrno=Qp2errnop()) != NULL)<br />

printf("Qp2CallPase failed. <strong>i5</strong>/<strong>OS</strong> <strong>PASE</strong> errno=%i\n", *paseErrno);<br />

printf("Qp2CallPase failed. Qp2dlerror=%s\n", Qp2dlerror());<br />

<strong>i5</strong>/<strong>OS</strong> <strong>PASE</strong> 25

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

Saved successfully!

Ooh no, something went wrong!