Oppolzer - Informatik / Blog


Blog-Hauptseite      Neuester Artikel      Älterer Artikel      Neuerer Artikel      Älterer gleiche Kategorie      Neuerer gleiche Kategorie

IBM-MAIN - Mischen von XPLINK- und Non-XPLINK-Modulen (Codebeispiel)

Subject:

Re: COBOL "LINK" without Assembler?

From:

Bernd Oppolzer <bernd.oppolzer@T-ONLINE.DE>

Reply-To:

IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU>

Date:

2014.09.24 08:45:38


That is the same method I used when I had the similar problem: calling a given
XPLINK C routine from PL1.

I wrote a NON-XPLINK C function which called the XPLINK function via fetch (). I
was able to call the NON-XPLINK function from PL/1.

excerpt from the "glue" function:



/**********************************************************/
/*                                                        */
/*   Funktionspointer-Typedef fuer externe Funktion       */
/*                                                        */
/**********************************************************/

typedef int (*funcptr) (char *is,
                        int *ilg,
                        char *os,
                        int *olg,
                        char *key,
                        int *klg);



// in the main function ...


    static funcptr pfunc = NULL;

    if (pfunc == NULL)
    {
       printf ("fetch module\n");
       pfunc = (funcptr) fetch ("NWPDDRDE");

       if (pfunc == NULL)
       {
          printf("ERROR: fetch failed\n");
       }
    }

    rc = (*pfunc) (pein -> ibuffer,
                   &(pein -> ilaenge),
                   pein -> obuffer,
                   &(pein -> olaenge),
                   pein -> key,
                   &(pein -> klaenge));



Kind regards

Bernd





Am 22.09.2014 23:21, schrieb S.S.:
> Let me know if it works.
>
> On Mon, Sep 22, 2014 at 12:14 PM, K.W. wrote:
>
>> S.,
>>
>> This is a really good suggestion.... I have used fetch() from non-XPLINK C
>> before to call XPLINK C in a separate enclave, so I know that that works.
>> It may be more COBOL than I can handle, though... :-)
>>
>> K.W.
>>
>> On Mon, Sep 22, 2014 at 10:32 AM, S.S: wrote:
>>
>>> To obtain the address of an XPLINK C/C++ routine which can be called from a
>>> NON-XPLINK program, look at the fetch() function in the C/C++ run time
>>> library reference.
>>>
>>> When calling "fetch()" from COBOL, the COBOL code will have to use the
>>> RETURNING facility of the CALL statement to get the address of the C/C++
>>> program.  The variable populated by RETURNING facility will need to be a
>>> FUNCTION POINTER or a redefinition of a FUNCTION POINTER.
>>>
>>> The COBOL code will then need to call the "returned program" via the
>>> FUNCTION POINTER variable.  See COBOL language reference and COBOL program
>>> guide for additional details.
>>>
>>>

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to listserv@listserv.ua.edu with the message: INFO IBM-MAIN

Blog-Hauptseite      Neuester Artikel      Älterer Artikel      Neuerer Artikel      Älterer gleiche Kategorie      Neuerer gleiche Kategorie