FTAM/9000 Programmer's Guide

426 Chapter 10
Example Programs
Common Code Example
#include %</opt/ftam/include/map.h>
#include %</opt/ftam/include/mapftam.h>
#include %<stdio.h>
void exit();
/*
** error_handler
**
** DESCRIPTION:
** This routine is an example of handling failures experienced
** during the FTAM functions. This routine will display the
** error messages.
**
** PARAMETERS:
** INPUT:
** result : the MAP and HP error information
** diag : the ISO error information
**
*/
void
error_handler(result, diag)
Api_rc result;
struct Ft_diagnostic *diag;
{
Return_code res;
Api_rc outcome;
Octet *return_string;
Octet *vendor_string;
struct Ft_diagnostic *ft_diag = NULL;
/*
** Initialize variables.
*/
return_string = NULL;
vendor_string = NULL;
/*
** Call ft_gperror to get the printable strings for
** the return_code and vendor_code. Print the
** strings returned from ft_gperror.
*/
res = ft_gperror( & result, & return_string, & vendor_string, & outcome
);
if (res == SUCCESS) {
if (return_string != NULL) {
(void)printf(“FTAM failure: return_code = %s\n”, return_string);
res = ft_fdmemory(return_string, & outcome);
if (res != SUCCESS)
error_handler(outcome, ft_diag);
}
/*
** Print the vendor_code if it exists.
*/
if (vendor_string != NULL) {
(void)printf(“FTAM failure: vendor_code = %s\n”, vendor_string);
res = ft_fdmemory(vendor_string, & outcome);
if (res != SUCCESS)
error_handler(outcome, ft_diag);
}
}