Re: [xml] libxml2 on OpenVMS 8



On Dec 7, 2009, at 11:25 AM, Lopez, Jesus wrote:

Hi all,
I’m facing some trouble with the use of libxml2 with COBOL on OpenVMS v8. We want to process some XML calls (SOA) from Cobol, but I’d need some clues. I’ve compiled libxml on OpenVMS with apparent success, but I don’t know how to use them with my COBOL program.

There are a number of ways to skin this cat. Pretty much all of them involve some basic knowledge of the OpenVMS calling standard, documented in, of all places, the HP OpenVMS Calling Standard reference manual at:

<http://h71000.www7.hp.com/doc/82final/5973/5973pro.html>

And you'll want to be familiar with the section in your COBOL user manual entitled, "Using HP COBOL in the Alpha, I64, or VAX Common Language Environment":

<http://h71000.www7.hp.com/doc/82final/6297/6297pro_095.html#com_lang_env_chap >

though this latter is not as helpful as it might be for your specific situation of calling C libraries from COBOL.

But the gist of it is that you can call anything from anything as long as you specify the correct argument passing mechanisms and make sure the data you are passing comply with the requirements of the language you are calling, such as counted strings for Pascal, null-terminated strings for C, etc.

So then you have to ask yourself whether you really want to be moving a null byte to the end of every string before passing it to a C function (or whether every one of your COBOL programmers will do that correctly and consistently), and whether there isn't a way to create a set of wrapper routines with a translated and possibly simplified version of the API that is more COBOL-friendly. There is an excellent blog article on one way to do that here:

<http://www.eight-cubed.com/blog/archives/001147.html>

That post proposes using string descriptors, which is a tried-and-true method for passing strings around in VMS (and the same method you'd use for calling system routines). A somewhat less elegant method that might be slightly more COBOL-friendly would be creating an extra argument with the string length for each string argument. Sort of ugly but might be easier to grasp for the average COBOL programmer (though I haven't done any COBOL in 16-18 years so take this comment with a huge grain of salt).

What the best solution is depends highly on your environment, e.g., COBOL programmers calling C, C programmers maintaining COBOL, etc.

________________________________________
Craig A. Berry
mailto:craigberry mac com

"... getting out of a sonnet is much more
 difficult than getting in."
                 Brad Leithauser




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]