[comp.protocols.ibm] Passing by Reference in CPI-C

pjw@hpcuhc.cup.hp.com (Pam Williams) (05/07/91)

Can anyone tell me the type for parameters to CPI-C calls in 'C'.  Specifically, 
when passing integer values to a call.


For example, the SAA CPI-C Manual specifies:

Set_Deallocate_Type:

   cmdsdt( conv_id, deallocate_type, return_code)

   conv_id (input)
   deallocate_type(input)
   return_code(output)

And the C Pseudonym File specifies:

   CM_ENTRY cmsdt (unsigned char CM_PTR, CM_INT32 CM_PTR, CM_INT32 CM_PTR)

   where CM_ENTRY is extern void
   and  CM_PTR is *.



I assume my call should then be for example:


   u_char *conv_id;
   int dealloc_type = CM_DEALLOCATE_CONFIRM;
   int rc;

   cmsdt ( conv_id, &dealloc_type, &rc);



Bottom Line:  Is my logic correct in that pointers are required?
              If so, Why was it designed to require passing the address for integer parameters.
              It seems much more obvious to do: cmsdt (conv_id, CM_DEALLOCATE_CONFIRM, &rc);


Thanks for the advice,

Pam Williams
Hewlett-Packard Co
pjw@cup.hp.com

pjw@hpcuhc.cup.hp.com (Pam Williams) (05/16/91)

Following is a reply I received -- pjw

I'm replying to your question in the protocols.ibm (?) newsgroup about
why you need to pass a pointer to an input only integer in CPI-C.

The reason behind this is that the CPI-C interface was intended to
be the same from all languages.  The CPI-C implementation code would
not have to know from which language a call came from.  So, for some
languages which only support call by reference (do Fortran or COBOL
fall in this category?  are there any?) CPI-C requires everything
to be passed as a pointer (C's version of call by reference).

I'll admit that for C, this is very counter-intuitive and can end
up being downright ugly coding style.

Feel free to post this to the newsgroup if you would like.

By the way, do anyone contact you about CPI-C test cases?

Peter J. Schwaller
APPC Market Enablement
IBM Corp.

As usual, my opinions are my own and not necessarily shared by my employer.