Re: Calling RPGILE program from C
Alan Campin <[email protected]>
| Newsgroups | gmane.comp.lang.as400.c |
|---|---|
| Message-ID | <CADVQcshZpAyrTBNhTDPsiXjEZ3VhmjZ1Wqe4RC7htYc6zqe+nw@mail.gmail.com> |
If the purpose of this is to provide re-entrant capabilities on a trigger,
there is a much easier way as detailed in my trigger mediator. Just make
the C and RPG logic modules and the C module only needs to be a few lines.
#include <stdio.h>
#include <stdlib.h>
void MediateTriggerCall(char *);
main(int argc, char **argv)
{
// Call RPG/ILE function to mediate call.
MediateTriggerCall(argv[1]); // Pass pointer to trigger buffer.
}
RPG
d MediateTriggerCall...
d pr ExtProc('MediateTriggerCall')
d PR_InPtrTriggerBuffer...
d * Value
p MediateTriggerCall...
p b Export
d pi
d InPtrTriggerBuffer...
d * Value
My bind instructions.
*_> CRTPGM PGM(@5/@4) MODULE(TG_MED_M01 TG_MED_M02 TG_MED_M03) +
*_> TEXT('Trigger Mediator.') +
*_> BNDDIR(QC2LE) BNDSRVPGM(XVDYNL XVERRH) +
*_> ACTGRP(QILE)
You don't need the service programs and probably only two modules.
On Tue, Oct 28, 2014 at 3:23 PM, Jon Paris <[email protected]> wrote:
> Yup - I was going to suggest the same thing if he needed flexibility. Or
> just do it “direct” if not.
>
>
> Jon Paris
>
> www.partner400.com
> www.SystemiDeveloper.com
>
> On Oct 28, 2014, at 4:44 PM, Jon Paris <[email protected]> wrote:
>
> > Not being funny Tony - but if you are calling an RPG program to do the
> work then why bother with the C at all?
> >
> >
> > Jon Paris
> >
> > www.partner400.com
> > www.SystemiDeveloper.com
> >
> > On Oct 28, 2014, at 4:02 PM, Tony Cate <[email protected]> wrote:
> >
> >> First the code:
> >>
> >> *#include <stdio.h>*
> >> *#include <string.h>*
> >>
> >> *#include <decimal.h>
> >> #include <stdlib.h>
> >>
> >> typedef void RGTRIGCNTL(char[80], decimal(10,0));
> >>
> >> #pragma linkage(RGTRIGCNTL,fetchable)
> >>
> >> int main(int argc, char *argv[])
> >> {
> >> char *triggerInfo;
> >> decimal (10,0) triggerLen;
> >>
> >> triggerInfo = argv[1];
> >> triggerLen = argv[2];
> >>
> >> RGTRIGCNTL(triggerInfo, &triggerLen);
> >> }*
> >>
> >> *What's going on: trying to write a small C program to attach to file
> triggers.*
> >>
> >> Problems:
> >>
> >> pragma linkage won't allow 'OS' for a parameter. Everything I've read
> >> indicates that's what I want. The only "ID' compiler didn't barf on is
> >> 'fetchable', which is why its there.
> >>
> >> It compiles, but nothing happens when I try to step into RGTRIGCNTL.
> >>
> >> The Dev box is V5R4 (long story).
> >>
> >> The questions:
> >>
> >> Why can't I use 'OS' in linkage? Why isn't my program getting called?
> >>
> >> The last time I wrote a C program was in college, a looong time ago.
> >> --
> >> *Tony Cate* | Senior Programmer/Analyst | 704.872.2458 x 126
> >> [image: Auction Edge, Inc.] <http://www.auctionedge.com/>
> >> *AUCTION EDGE, INC.* | *Powering Independent Auctions*
> >> STATESVILLE, NC | 704.872.2458
> >> --
> >> This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L)
> mailing list
> >> To post a message email: [email protected]
> >> To subscribe, unsubscribe, or change list options,
> >> visit: http://lists.midrange.com/mailman/listinfo/c400-l
> >> or email: [email protected]
> >> Before posting, please take a moment to review the archives
> >> at http://archive.midrange.com/c400-l.
> >>
> >
>
> --
> This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L)
> mailing list
> To post a message email: [email protected]
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/c400-l
> or email: [email protected]
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/c400-l.
>
>
--
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/c400-l
or email: [email protected]
Before posting, please take a moment to review the archives
at http://archive.midrange.com/c400-l.