On 8/13/2014 7:12 AM, Frank Kolmann wrote:
Yep its a doozy. Particularly with the bits IBM manages to deeply hide in
the documentation.
Anyhow I am close to converting the RPG program to C so soon I will post it
to the wiki.
However I am not sure how its best to pass back the extracted data.
Also there is such a vast amount of different data that can be extracted.
(some of the attributes I still cant get)
With the RPG is used a MODS.
Any suggestion?

Let me explain the framework for my reply. When I use an API like this,
it's almost always because I'm trying to do something specific. That
is, I can't remember a time when the consumer, the caller of the API
ever needs to use everything possibly available. Or even most of what's
available. If I'm making my own DFU, I might want the field name,
length, decimals, edit code and text. All the rest of the stuff the API
can tell me isn't useful for my immediate needs. In this situation, I
use a callback.

Let's say you want to pass the list of record format names back to the
caller. It'll look something like this (pseudocode):

#include <stdio.h>
#include <string.h>

typedef struct BIGFD {
char recfm[10];
} BIGFD_t;

/* this is the proc that handles each detail line */
void detail(BIGFD_t *big)
{
fprintf(stdout, "called with %s\n", big->recfm);
}

void main()
{
/* prototype */
void (*callback)(void *);

/* assign the real proc to be called */
callback = (void*)detail;

/* set up test of 3 'record format names' */
BIGFD_t rtvfd[3];
strcpy(rtvfd[0].recfm, "MYREC 1");
strcpy(rtvfd[1].recfm, "MYREC 2");
strcpy(rtvfd[2].recfm, "MYREC 3");

/* Call the QDFRTVFD API */
/* loop through the list of record formats */
for (int i=0; i<3; i++) {
callback(&rtvfd[i]);
}
return;
}

--buck

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2021 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.