#ifndef WA_H
#define WA_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: wa.h,v 1.5 1997/10/17 14:01:59 vltsccm Exp $"
*
* who       when      what
* --------  --------  ----------------------------------------------
* gfilippi  07/06/94  created
* gfilippi  27/08/95  do not use rtapClasses/rtTypes.h when CCS-Lite
*/

/************************************************************************
*  Example of Workstation application
*
*----------------------------------------------------------------------
*/

/*
 * System Headers required by all applications in this module
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>

/*
 * VLT Software
 */
 
#ifndef CCS_LIGHT
#include "rtapClasses/rtTypes.h"    /* RTAP */
#endif

#include "db.h"                     /* ccs */
#include "msg.h"
#include "tims.h"
#include "err.h"
#include "log.h"

/* 
 * Macros 
 */

/* 
 * to make the code more readable the following macros for error treatment 
 * are defined:
 *
 *    - CLEAN used when ccsInit has been performed
 *    - ABORT used when ccsInit has not yet been performed
 *
 * For each "XXXXX" macro a "xxxxx" label defines in the code the
 * appropriate actions needed for that specific error condition.
 * 
 * The macro PRINT_ERROR produces debugging information.
 */

#define PRINT_ERROR(reason) \
    {\
    printf("File %s line %d\n", __FILE__, __LINE__);     \
    printf("Failure: %s\n", reason);             \
    printf("Error structure\n");                         \
    printf("   EnvName    : %s\n", error.envName);       \
    printf("   StackId    : %x\n", error.stackId.id);    \
    printf("   SequenceNbr: %d\n", error.sequenceNumber);\
    printf("   ModuleId   : %s\n", error.moduleId);      \
    printf("   LocationId : %s\n", error.location);      \
    printf("   ErrorNumber: %d\n", error.errorNumber);   \
    printf("   Parameters : %s\n", error.runTimePar);    \
    errCloseStack(&error); \
    }

#define CLEAN(reason)   { PRINT_ERROR(reason); goto clean; }

#define ABORT(reason)   { PRINT_ERROR(reason); goto abort; }


/*
 * application log identifier
 */
#define WA_LOG_OFFSET  100    /* starting from 100 because appl-logs */

#define WA_LOG_START   (WA_LOG_OFFSET + 1)    /* process start */
#define WA_LOG_END     (WA_LOG_OFFSET + 2)    /* process end */


/*
 * error definition
 */
#include "waErrors.h"

#endif /*!WA_H*/

