1 /*
2  * The Spread Toolkit.
3  *
4  * The contents of this file are subject to the Spread Open-Source
5  * License, Version 1.0 (the ``License''); you may not use
6  * this file except in compliance with the License.  You may obtain a
7  * copy of the License at:
8  *
9  * http://www.spread.org/license/
10  *
11  * or in the file ``license.txt'' found in this distribution.
12  *
13  * Software distributed under the License is distributed on an AS IS basis,
14  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
15  * for the specific language governing rights and limitations under the
16  * License.
17  *
18  * The Creators of Spread are:
19  *  Yair Amir, Michal Miskin-Amir, Jonathan Stanton, John Schultz.
20  *
21  *  Copyright (C) 1993-2009 Spread Concepts LLC <info@spreadconcepts.com>
22  *
23  *  All Rights Reserved.
24  *
25  * Major Contributor(s):
26  * ---------------
27  *    Ryan Caudy           rcaudy@gmail.com - contributions to process groups.
28  *    Claudiu Danilov      claudiu@acm.org - scalable wide area support.
29  *    Cristina Nita-Rotaru crisn@cs.purdue.edu - group communication security.
30  *    Theo Schlossnagle    jesus@omniti.com - Perl, autoconf, old skiplist.
31  *    Dan Schoenblum       dansch@cnds.jhu.edu - Java interface.
32  *
33  */
34 
35 
36 #ifndef INC_ALARM
37 #define INC_ALARM
38 
39 #include <stdio.h>
40 #include "spu_system.h"
41 
42 /* Type for Alarm realtime handler functions */
43 typedef int (alarm_realtime_handler)( int16, int32, char *, size_t, char *, size_t);
44 
45 
46 /* This includes the custom types for each project */
47 #include "spu_alarm_types.h"
48 
49 /* These are always defined for any project using Alarm */
50 #define		ALL		0xffffffff
51 #define		NONE		0x00000000
52 
53 /* Priority levels */
54 #define         SPLOG_DEBUG     0x0001       /* Program information that is only useful for debugging.
55                                                 Will normally be turned off in operation. */
56 #define         SPLOG_INFO      0x0002       /* Program reports information that may be useful for
57                                                 performance tuning, analysis, or operational checks. */
58 #define         SPLOG_WARNING   0x0003       /* Program encountered a situation that is not erroneous,
59                                                 but is uncommon and may indicate an error. */
60 #define         SPLOG_ERROR     0x0004       /* Program encountered an error that can be recovered from. */
61 #define         SPLOG_CRITICAL  0x0005       /* Program will not exit, but has only temporarily recovered
62                                                 and without help may soon fail. */
63 #define         SPLOG_FATAL     0x0006       /* Program will exit() or abort(). */
64 
65 #define         SPLOG_PRINT     0x0007       /* Program should always print this information */
66 
67 #define         SPLOG_PRIORITY_FIELDS 0x000f
68 
69 /* Feature Flags for Priority field */
70 #define         SPLOG_NODATE    0x0010       /* Program should omit the datestamp at the beginning of the message. */
71 #define         SPLOG_REALTIME  0x0020       /* This message should be disseminated through the realtime handler if possible.
72                                                 This is used for alerts you want sent now and not just logged (they are also logged). */
73 #define         SPLOG_PRIORITY_FLAGS 0x00f0
74 
75 #ifdef  HAVE_GOOD_VARGS
76 void Alarmp( int16 priority, int32 type, char *message, ...);
77 void Alarm( int32 type, char *message, ...);
78 
79 #else
80 void Alarm();
81 #endif
82 
83 void Alarm_set_output(char *filename);
84 
85 void Alarm_enable_timestamp(const char *format);
86 void Alarm_enable_timestamp_high_res(const char *format);
87 void Alarm_disable_timestamp(void);
88 
89 void Alarm_set_types(int32 mask);
90 void Alarm_clear_types(int32 mask);
91 int32 Alarm_get_types(void);
92 
93 void Alarm_set_priority(int16 priority);
94 int16 Alarm_get_priority(void);
95 
96 void Alarm_set_realtime_print_handler( alarm_realtime_handler *output_message_function );
97 
98 void Alarm_set_interactive(void);
99 int  Alarm_get_interactive(void);
100 
101 #define IPF "%d.%d.%d.%d"
102 
103 #define IP1(address)  ( (int) ( ( (address) >> 24 ) & 0xFF ) )
104 #define IP2(address)  ( (int) ( ( (address) >> 16 ) & 0xFF ) )
105 #define IP3(address)  ( (int) ( ( (address) >>  8 ) & 0xFF ) )
106 #define IP4(address)  ( (int) ( ( (address) >>  0 ) & 0xFF ) )
107 
108 #define IP(address) IP1(address), IP2(address), IP3(address), IP4(address)
109 
110 #define IP1_NET(address)  ( (int) ( (unsigned char*) &(address) )[0] )
111 #define IP2_NET(address)  ( (int) ( (unsigned char*) &(address) )[1] )
112 #define IP3_NET(address)  ( (int) ( (unsigned char*) &(address) )[2] )
113 #define IP4_NET(address)  ( (int) ( (unsigned char*) &(address) )[3] )
114 
115 #define IP_NET(address) IP1_NET(address), IP2_NET(address), IP3_NET(address), IP4_NET(address)
116 
117 #endif	/* INC_ALARM */
118