
#include <lclib.h> void btrace(void (*fp)(const char *));
btrace generates a library traceback similar to the traceback
generated when an ABEND occurs. btrace is useful for debugging or
diagnosing error conditions.
fp may be NULL or a pointer to a function. If it is NULL,
then btrace writes the traceback to stderr (the standard error
file). If fp is not NULL, then btrace calls the function
for each line of the traceback. One traceback line, in the form of a
string, is passed to the function. (The traceback line does not terminate in
a newline character.)
btrace has no return value.
#include <lclib.h>
#include <stdio.h>
static void btrace_out(const char *line)
{
static FILE *tbf;
/* If first call, open traceback file. */
if (tbf == NULL) {
tbf = fopen("TRACBACK", "w");
if (tbf == NULL) exit(12);
}
/* Write one line of traceback information. */
fputs(line, tbf);
putc('n', tbf);
}
/* Define a function to send a message */
/* to stderr and then call btrace(). */
void genbtrac(char *msg)
{
fputs(msg, stderr);
btrace(&btrace_out);
fputs("Traceback generated.n", stderr);
exit(12);
}
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.