2.12.1.1 Coding Switch Element Routines

Presumably an application that is defining new buffer types is doing so because of a special processing need. For example, let’s assume the application has a recurring need to compress data before sending a buffer to the next process. The application could write a presend routine. The declaration for the presend routine is shown in the following listing.

Listing Semantics of the Presend Switch Element

long
presend(ptr, dlen, mdlen)
char *ptr;

long dlen, mdlen;
  • ptr is a pointer to the application data buffer.
  • dlen is the length of the data as passed into the routine.
  • mdlen is the size of the buffer in which the data resides.

The data compression that takes place within your presend routine is the responsibility of the system programmer for your application.

On completion the routine should return the new, hopefully shorter length of the data to be sent (in the same buffer), or a -1 to indicate failure.

The name given to your version of the presend routine can be any identifier accepted by the C compiler. For example, suppose we name it _mypresend.

If you use our _mypresend compression routine, you will probably also need a corresponding _mypostrecv routine to decompress the data at the receiving end. Follow the template shown in the buffer(3c) entry in the Oracle Tuxedo C Function Reference.