METAL C and REXX

C/C++ and Java for MVS & zOS.
Post Reply
enrico-sorichetti
Global Moderator
Global Moderator
Posts: 826
Joined: Wed Sep 11, 2013 3:57 pm

METAL C and REXX

Post by enrico-sorichetti »

here is a sample ( tested and working ) on how to write a REXX external function in METAL C

Code: Select all

#pragma csect(CODE, "CRXWTO$")
#pragma prolog(CRXWTO,"CCPROLOG")
#pragma epilog(CRXWTO,"CCEPILOG")

#include "metal.h"
#include "string.h"
#include "stdio.h"

#include "irxefpl.h"
#include "irxargtb.h"
#include "irxenvb.h"
#include "irxevalb.h"
#include "irxshvb.h"

__asm(" WTO TEXT=,MF=L " : "DS"(wtol));

struct WTO_TEXT {
    unsigned short l;
    char t[121];
} wto_text ;

int CRXWTO(struct efpl efpl)
{
    struct envblock *envp ;
    struct evalblock *evalp  ;

    struct argtable_entry *argp ;

    argp = ( struct argtable_entry * ) efpl.efplarg ;
    evalp = * ( struct evalblock * * ) efpl.efpleval ;

    /* arg(1) wto text */
    if ((int) argp->argtable_argstring_ptr == 0xffffffff)
    {
       sprintf(&evalp->evalblock_evdata, "%d", 4);
       evalp->evalblock_evlen = strlen(&evalp->evalblock_evdata);
       return(0) ;
    }


    if (argp->argtable_argstring_length > 120)
    {
       sprintf(&evalp->evalblock_evdata, "%d", 8);
       evalp->evalblock_evlen = strlen(&evalp->evalblock_evdata);
       return(0) ;
    }

    wto_text.l = argp->argtable_argstring_length;
    memcpy(wto_text.t, argp->argtable_argstring_ptr, wto_text.l);
    wto_text.t[wto_text.l] = 0;

    __asm(" WTO TEXT=,MF=L " : "DS"(wtob));
    wtob=wtol;
    __asm( " WTO text=(%0),MF=(E,(%1)) "
           : :
           "r"(&wto_text), "r"(&wtob));

    sprintf(&evalp->evalblock_evdata, "%d", 0);
    evalp->evalblock_evlen = strlen(&evalp->evalblock_evdata);
    return (0) ;
}


cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “C, C++ and Java for Mainframes.”