summaryrefslogtreecommitdiffstats
path: root/ast/Ers.h
blob: a66fa82859cfad365ee20dc4dab1f13c350642d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#ifndef ERSINC
#define ERSINC
#ifdef __cplusplus
extern "C" {
#endif


/*			E r s . h

 *  Module name:
      Ers.h

 *  Function:
	Function header for the Ers routines

 *  Description:
     Should be included by all files using the Ers routines.

 *  Language:
      C

 *  Support: Tony Farrell, AAO

 *  Copyright (c) Anglo-Australian Telescope Board, 1995.
    Not to be used for commercial purposes without AATB permission.

 *     @(#) $Id: Ers.h,v 1.3 2005/05/17 22:21:19 rkackley Exp $


 *  History:
      04-Aug-1992 - TJF - Original version
      25-Sep-1992 - TJF - Update comments
      06-Oct-1992 - TJF - Rewrite for complete Ers package.
      04-Aug-1993 - TJF - maxsize argument to ErsSPrintf needs a type
      28-Sep-1993 - TJF - Use GNUC attribute to flag the ers calls
			  as printf style.  Use drama.h for configuration
			  stuff.

      29-Sep-1993 - TJF - Add Sccs id
      06-Mar-1994 - TJF - Add Task Id stuff.
      05-Feb-1995 - TJF - Add BROADCAST flag
      06-Aug-1996 - TJF - Add const to strings arguments of ErsVSPrintf
      30-May-2001 - TJF - Add ErsSetLogRoutine.
      15-Jun-2001 - TJF - Add ErsGetTaskId.
      {@change entry@}


 */

#ifdef ERS_STANDALONE
/*
 *  DRAMA macros and types used by Ers.  They are defined here when we
 *  are building ers standalone.
 */
#define DVOID void
#define DVOIDP void *
#define DPUBLIC extern
#define DPRIVATE static
#define DCONSTV const
#define DCONSTR const
#define STATUS__OK 0
#define DPROTOTYPES_OK
#define DFLOAT_OK
#define DCONST_I
typedef long int StatusType;
#define StatusOkP(_value_)  (*(_value_) == STATUS__OK)
#else
/*
 *  Include the drama.h file for configuration macros.
 */

#include "drama.h"

#include "status.h"		/* For StatusType etc	*/
#endif

/*
 *  Get around problems in Sparc include files, they are not ANSI compatible
 */
#if defined(__sparc__) && !defined(sparc)
#define sparc 1
#endif

/*
 *  Floating point stuff.  Only used in ErsVSPrintf.
 */
#ifdef DFLOAT_OK
/*
 *  These values taken from bsd floatio.h
 */
#    define ERS_MAXEXP 308
#    define ERS_MAXFRACT 39
#endif

/*
 *  Constants
 */

#define ERS_C_LEN 200		/* Maximum length of reported messages */
#define ERS_C_MAXMSG 30		/* Maximum number of reported messages */

#define ERS_M_NOFMT (1<<0)	/* Message flag masks		*/
#define ERS_M_HIGHLIGHT (1<<1)
#define ERS_M_BELL (1<<2)
#define ERS_M_ALARM (1<<3)
#define ERS_M_BROADCAST (1<<4)


/*
 *  This structure is used to store details of a message
 */
typedef struct {
	    StatusType mesStatus;	    /* Status of message    */
	    unsigned int context;	    /* Context message was written at */
	    int    flags;		    /* Message flags	    */
	    char   message[ERS_C_LEN];	    /* The formated message */
	    } ErsMessageType;

typedef DVOIDP ErsTaskIdType;

#ifdef DPROTOTYPES_OK
/*
 *  This type is that required for log routines - called on each call to
 *  ErsRep with details of a single message.
 *
 *  The argument "logArg" is a user value supplied when ErsStart is called.
 *  It enables the user to pass any appropriate value to the log routine.
 */
typedef DVOID (*ErsLogRoutineType)(
		    DVOIDP logArg,	    /* Supplied to ErsStart  */
		    DCONSTV ErsMessageType * message,/* The message  */
		    StatusType * status);
/*
 *  The type is that requried for the output routine - called to output
 *  the messages to the user.  An array of message may be output by one
 *  call, with count being the number of message to output.
 *
 *  The argument "outArg" is a user value supplied when ErsStart is called.
 *  It enables the user to pass any appropriate value to the log routine.
 */
typedef DVOID (*ErsOutRoutineType)(
		    DVOIDP outArg,	    /* Supplied to ErsStart */
		    unsigned int count,	    /* Number of messages   */
		    DCONSTV ErsMessageType messages[],/* Array of messages */
		    StatusType * status);


/*
 *  Function prototypes.
 *
 *
 *  We can't define these prorotype in the Ers main module unless we have
 *  stdarg.h.
 */
#if !defined(ERS_MAIN) || defined(DSTDARG__OK)
    DPUBLIC DVOID ErsRep(DCONSTV int flags, StatusType * status,
		       DCONSTV char * string , ...)
#ifdef __GNUC__
	__attribute__ ((format (printf, 3, 4)))
#endif
		;
    DPUBLIC DVOID ErsOut(DCONSTV int flags, StatusType * status,
		          DCONSTV char * string, ...)
#ifdef __GNUC__
	__attribute__ ((format (printf, 3, 4)))
#endif
		;
    DPUBLIC int  ErsSPrintf(DCONSTV int maxLength,
			char *string,
			DCONSTV char * fmt,...)
#ifdef __GNUC__
	__attribute__ ((format (printf, 3, 4)))
#endif
		;

#endif /* DSTDARG_OK */

DPUBLIC ErsTaskIdType ErsStart(
		ErsOutRoutineType outRoutine,
		DVOIDP outArg,
		ErsLogRoutineType logRoutine,
		DVOIDP logArg,
		StatusType * status);
DPUBLIC DVOID ErsStop(StatusType * status);
DPUBLIC DVOID ErsPush(void);
DPUBLIC DVOID ErsAnnul(StatusType * status);
DPUBLIC DVOID ErsFlush(StatusType * status);
DPUBLIC DVOID ErsClear(StatusType * status);
DPUBLIC DVOID ErsPop(void);
DPUBLIC DVOID ErsSetLogRoutine(
    ErsLogRoutineType logRoutine,
    DVOIDP logArg,
    ErsLogRoutineType *oldLogRoutine,
    DVOIDP *oldLogArg,
    StatusType * status);

DPUBLIC ErsTaskIdType ErsGetTaskId(StatusType *status);
DPUBLIC DVOID ErsEnableTask(ErsTaskIdType TaskId,
			    ErsTaskIdType * SavedTaskId);
DPUBLIC DVOID ErsRestoreTask(ErsTaskIdType TaskId);


#ifdef DSTDARG_OK
#   include <stdarg.h>
#else
#   include <varargs.h>
#endif
DPUBLIC int ErsVSPrintf(
		 int maxLength,
		 char *string ,
		 DCONSTV char * fmt0,
		 va_list ap);
#else
/* Don't use prorotypes */
typedef DVOID (*ErsLogRoutineType)();
typedef DVOID (*ErsOutRoutineType)();

DPUBLIC DVOID ErsRep();
DPUBLIC DVOID ErsOut();

DPUBLIC DVOID ErsStart();
DPUBLIC DVOID ErsStop();
DPUBLIC DVOID ErsPush();
DPUBLIC DVOID ErsPop();
DPUBLIC DVOID ErsAnnul();
DPUBLIC DVOID ErsFlush();
DPUBLIC DVOID ErsClear();
DPUBLIC DVOID ErsSetLogRoutine();
DPUBLIC ErsTaskIdType ErsGetTaskId();

DPUBLIC int ErsVSPrintf();
DPUBLIC int ErsSPrintf();

DPUBLIC DVOID ErsEnableTask();
DPUBLIC DVOID ErsRestoreTask();


#endif


#ifdef __cplusplus
}
#endif

#endif