coblongjmp

With the cobsetjmp function, provides the capability of a non-local GO TO, for use in error or exception handling.

Syntax:
#include "cobsetjmp.h"

void coblongjmp(struct cobjmp_buf *buf);
Parameters:
buf A buffer in which the current execution environment is saved.
Comments:

The cobsetjmp() function saves the environment of the current COBOL program and C function in the buffer pointed to by buf. It calls the C library function setjmp(), which immediately returns a value of 0.

A subsequent call to coblongjmp() either from elsewhere in the C function that called cobsetjmp(), or from one of its C or COBOL subprograms, causes execution to be resumed at the point immediately after the call to cobsetjmp().

After calling coblongjmp(), cobsetjmp() returns a non-zero value, thus enabling the value to be tested after the cobsetjmp() call.

The following restrictions apply when using the coblongjmp() and cobsetjmp() functions:

Equivalent COBOL Syntax:

None.

Example:

The following shows how to use the coblongjmp() and cobsetjmp() functions:

void
some_c_func(void)
{
    struct cobjmp_buf buf;

    if (cobsetjmp(&buf) != 0)
    {
        cobprintf("Returned from coblongjmp\n");
        return;
    }
  
    /* Valid code here - for example can call COBOL */

    coblongjmp(&cobjmp_buf);
}