~ubuntu-branches/ubuntu/intrepid/raidutils/intrepid

« back to all changes in this revision

Viewing changes to raidutil/log_core.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Barak Pearlmutter
  • Date: 2004-05-18 11:33:42 UTC
  • Revision ID: james.westby@ubuntu.com-20040518113342-tyqavmso5q351xi2
Tags: upstream-0.0.4
ImportĀ upstreamĀ versionĀ 0.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 1996-2004, Adaptec Corporation
 
2
 * All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions are met:
 
6
 *
 
7
 * - Redistributions of source code must retain the above copyright notice, this
 
8
 *   list of conditions and the following disclaimer.
 
9
 * - Redistributions in binary form must reproduce the above copyright notice,
 
10
 *   this list of conditions and the following disclaimer in the documentation
 
11
 *   and/or other materials provided with the distribution.
 
12
 * - Neither the name of the Adaptec Corporation nor the names of its
 
13
 *   contributors may be used to endorse or promote products derived from this
 
14
 *   software without specific prior written permission.
 
15
 *
 
16
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
17
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
18
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
19
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 
20
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
21
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
22
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
23
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
24
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
25
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
26
 * POSSIBILITY OF SUCH DAMAGE.
 
27
 */
 
28
 
 
29
#ifndef __LOG_CORE_HPP
 
30
#define __LOG_CORE_HPP
 
31
 
 
32
//File - LOG_CORE.HPP
 
33
//***************************************************************************
 
34
//
 
35
//Description: some of the most common things for the logger
 
36
//
 
37
//
 
38
//Author: Bill Smith
 
39
//Date: 10/3/95
 
40
//
 
41
//Editors:
 
42
//
 
43
//Remarks:
 
44
//
 
45
//
 
46
//***************************************************************************
 
47
 
 
48
 
 
49
//Include Files -------------------------------------------------------------
 
50
 
 
51
#include "eng_std.h"
 
52
#include "osd_util.h"
 
53
 
 
54
// SNMP trap event info
 
55
#include "trapdef.h"
 
56
 
 
57
#ifdef _DPT_NETWARE
 
58
#include <conio.h>
 
59
#endif
 
60
 
 
61
#ifdef __UNIX__
 
62
#include "funcs.h"
 
63
#endif
 
64
 
 
65
//Definitions - Defines & Constants -----------------------------------------
 
66
 
 
67
#define TRUE 1
 
68
#define FALSE 0
 
69
#if !defined __MWERKS__
 
70
#if !defined false
 
71
#define false FALSE
 
72
#endif
 
73
#if !defined true
 
74
#define true TRUE
 
75
# endif
 
76
#endif
 
77
 
 
78
// ini file string constants
 
79
 
 
80
// name of the ini file
 
81
#define INI_NAME "dptelog.ini"
 
82
 
 
83
#define GLOBAL_GROUP_STR "Global Group"
 
84
 
 
85
// max length of a filename
 
86
const uSHORT MAX_FILENAME_LEN = 129;
 
87
 
 
88
// the size of the to engine buffers
 
89
const uLONG TO_ENG_BUFF_SIZE = 0x4000;
 
90
 
 
91
// size of the global engine buffer, this is the max size
 
92
// we should ever try to use, its big...  16k
 
93
const uLONG GLOB_ENG_BUFF_SIZE = 0x4000;
 
94
 
 
95
//
 
96
// Logger_C types
 
97
//
 
98
 
 
99
const uLONG MGR_TYPE =                  0x80000000;
 
100
 
 
101
// event logging object types
 
102
const uLONG LOGGER_TYPE_EVENT = 0x00000000;
 
103
 
 
104
// event logger mgr
 
105
const uLONG LOGGER_TYPE_EVENT_MGR = LOGGER_TYPE_EVENT | MGR_TYPE;
 
106
 
 
107
// stats logger
 
108
const uLONG LOGGER_TYPE_STATS = 0x00000001;
 
109
 
 
110
// stats mgr
 
111
const uLONG LOGGER_TYPE_STATS_MGR = LOGGER_TYPE_STATS | MGR_TYPE;
 
112
 
 
113
// heart bet logger
 
114
const uLONG LOGGER_TYPE_HB = 0x00000002;
 
115
 
 
116
// heartbeat log mgr
 
117
const uLONG LOGGER_TYPE_HB_MGR =  LOGGER_TYPE_HB | MGR_TYPE;
 
118
 
 
119
// unknown logger type
 
120
const uLONG LOGGER_TYPE_UNKNOWN = 0xffffffff;
 
121
 
 
122
 
 
123
 
 
124
// broadcaster types
 
125
 
 
126
// debug broadcaster
 
127
const uLONG BROADCASTER_TYPE_DEBUG =            0x0000000A;
 
128
// debug broadcaster MGR
 
129
const uLONG BROADCASTER_TYPE_DEBUG_MGR =        BROADCASTER_TYPE_DEBUG | MGR_TYPE;
 
130
 
 
131
// sys log broadcasters
 
132
const uLONG BROADCASTER_TYPE_SYSLOG =           0x0000000B;
 
133
const uLONG BROADCASTER_TYPE_SYSLOG_MGR = BROADCASTER_TYPE_SYSLOG | MGR_TYPE;
 
134
 
 
135
// window broadcasters
 
136
const uLONG BROADCASTER_TYPE_WINDOW =           0x0000000C;
 
137
const uLONG BROADCASTER_TYPE_WINDOW_MGR = BROADCASTER_TYPE_WINDOW | MGR_TYPE;
 
138
 
 
139
// a broadcast module interface opject
 
140
const uLONG BROADCAST_TYPE_MODULE =                     0x0000000D;
 
141
 
 
142
// the NT event viewer broadcaster
 
143
const uLONG BROADCASTER_TYPE_NT_EVENT = 0x0000000E;
 
144
const uLONG BROADCASTER_TYPE_NT_EVENT_MGR = BROADCASTER_TYPE_NT_EVENT | MGR_TYPE;
 
145
 
 
146
// the nt message broadcaster
 
147
const uLONG BROADCASTER_TYPE_NT_MSG     =       0x0000000F;
 
148
const uLONG BROADCASTER_TYPE_NT_MSG_MGR = BROADCASTER_TYPE_NT_MSG | MGR_TYPE;
 
149
 
 
150
// the netware message broadcaster
 
151
const uLONG BROADCASTER_TYPE_NW_MSG     =       0x00000010;
 
152
const uLONG BROADCASTER_TYPE_NW_MSG_MGR = BROADCASTER_TYPE_NW_MSG | MGR_TYPE;
 
153
 
 
154
// the nw console printf mananger
 
155
const uLONG BROADCASTER_TYPE_CONSOLE    =       0x00000011;
 
156
const uLONG BROADCASTER_TYPE_CONSOLE_MGR = BROADCASTER_TYPE_CONSOLE | MGR_TYPE;
 
157
 
 
158
// the mail broadcaster
 
159
const uLONG BROADCASTER_TYPE_MAIL       =       0x00000012;
 
160
const uLONG BROADCASTER_TYPE_MAIL_MGR   =  BROADCASTER_TYPE_MAIL | MGR_TYPE;
 
161
 
 
162
// the mail broadcaster
 
163
const uLONG BROADCASTER_TYPE_DEVICE_WRITE       =       0x00000013;
 
164
const uLONG BROADCASTER_TYPE_DEVICE_WRITE_MGR   =  BROADCASTER_TYPE_DEVICE_WRITE | MGR_TYPE;
 
165
 
 
166
// the mail broadcaster
 
167
const uLONG BROADCASTER_TYPE_USER_WRITE         =       0x00000014;
 
168
const uLONG BROADCASTER_TYPE_USER_WRITE_MGR   =  BROADCASTER_TYPE_USER_WRITE | MGR_TYPE;
 
169
 
 
170
// the MAPI broadcaster
 
171
const uLONG BROADCASTER_TYPE_MAPI       =       0x00000015;
 
172
const uLONG BROADCASTER_TYPE_MAPI_MGR   =  BROADCASTER_TYPE_MAPI | MGR_TYPE;
 
173
 
 
174
// the SNMP broadcaster
 
175
const uLONG BROADCASTER_TYPE_SNMP       =       0x00000016;
 
176
const uLONG BROADCASTER_TYPE_SNMP_MGR   =  BROADCASTER_TYPE_SNMP | MGR_TYPE;
 
177
 
 
178
// the AIX log file broadcaster
 
179
const uLONG BROADCASTER_TYPE_AIXLOG     =       0x00000017;
 
180
const uLONG BROADCASTER_TYPE_AIXLOG_MGR = BROADCASTER_TYPE_AIXLOG | MGR_TYPE;
 
181
 
 
182
// the NT audio file broadcaster
 
183
const uLONG BROADCASTER_TYPE_AUDIO      =       0x00000018;
 
184
const uLONG BROADCASTER_TYPE_AUDIO_MGR = BROADCASTER_TYPE_AUDIO | MGR_TYPE;
 
185
 
 
186
// the MAPI broadcaster
 
187
const uLONG BROADCASTER_TYPE_TAPI       =       0x00000019;
 
188
const uLONG BROADCASTER_TYPE_TAPI_MGR   =  BROADCASTER_TYPE_TAPI | MGR_TYPE;
 
189
 
 
190
// the XMT_EVT broadcaster
 
191
const uLONG BROADCASTER_TYPE_XMT_EVT    =       0x0000001b;
 
192
const uLONG BROADCASTER_TYPE_XMT_EVT_MGR   =  BROADCASTER_TYPE_XMT_EVT | MGR_TYPE;
 
193
//
 
194
// errors
 
195
//
 
196
 
 
197
// error creating an object
 
198
const uLONG ERR_LOGGER_MEM =                    0x00000001;
 
199
 
 
200
// error opening a log file
 
201
const uLONG ERR_OPEN_LOG_FILE =         0x00000002;
 
202
 
 
203
// required deivce for this log mgr to operate properly does
 
204
// not exists
 
205
const uLONG ERR_REQUIRED_DEVICE =       0x00000004;
 
206
 
 
207
// errors initializing the engine
 
208
 
 
209
// incompatablie
 
210
const uLONG ERR_NOT_COMPAT =                    0x00000008;
 
211
 
 
212
// can't open, ie find
 
213
const uLONG ERR_OPEN_ENGINE =                   0x00000010;
 
214
 
 
215
// modules didn't load
 
216
const uLONG ERR_LOADING_MODULE =                0x00000020;
 
217
 
 
218
// the FW in the hba was less that what is required for stats logging
 
219
const uLONG ERR_SLOG_FW_VERSION =       0x00000040;
 
220
 
 
221
// there was an error creating a semaphore
 
222
const uLONG ERR_SEM_CREATE      =   0x00000080;
 
223
 
 
224
// could not create the AIX error template
 
225
const uLONG ERR_AIX_LOGGER      =   0x00000100;
 
226
 
 
227
 
 
228
//
 
229
// broadcaster specialty flags
 
230
const uLONG SPFLG_OS2_WININTIALIZE = 0x00000001;
 
231
 
 
232
// the number of possible machines/users we will broadcast to
 
233
#define MAX_NUM_BROADCAST_USERS 10
 
234
#define MAX_USERNAME_LEN 50
 
235
 
 
236
//Definitions - Structure & Typedef -----------------------------------------
 
237
 
 
238
//struct - LoggerID_S - start
 
239
//===========================================================================
 
240
//
 
241
//Description: this is the Logger ID structure
 
242
//
 
243
//
 
244
//
 
245
//---------------------------------------------------------------------------
 
246
struct LoggerID_S
 
247
{
 
248
        // tag and a type similar to dptID_S
 
249
        uLONG tag, type;
 
250
};
 
251
// - end
 
252
 
 
253
//class - LogError_C - start
 
254
//===========================================================================
 
255
//
 
256
//Description: goes the error handling
 
257
//
 
258
//
 
259
//
 
260
//---------------------------------------------------------------------------
 
261
class LogError_C
 
262
{
 
263
        public:
 
264
 
 
265
                LogError_C()
 
266
                        { errorFlags = 0; };
 
267
 
 
268
                virtual ~LogError_C() {};
 
269
 
 
270
                // get errors
 
271
                uLONG GetError()
 
272
                        { return(errorFlags); };
 
273
 
 
274
                // set the error flag
 
275
                void SetError(uLONG x)
 
276
                        { errorFlags |= x; }
 
277
 
 
278
        private:
 
279
 
 
280
                // error flags
 
281
                uLONG errorFlags;
 
282
};
 
283
// - end
 
284
 
 
285
//class - LoggerCore_C - start
 
286
//===========================================================================
 
287
//
 
288
//Description: used to have logger tags and logger types
 
289
//
 
290
//
 
291
//
 
292
//---------------------------------------------------------------------------
 
293
class LoggerCore_C : public LogError_C
 
294
{
 
295
        public:
 
296
 
 
297
                // used to assign the logger type
 
298
                LoggerCore_C(uLONG newType)
 
299
                {
 
300
                        // assign the tag and increment it
 
301
                        id.tag = nextTag++;
 
302
 
 
303
                        //assign the type
 
304
                        id.type = newType;
 
305
                }
 
306
 
 
307
                // returns the tag assigned by the logger
 
308
                DPT_TAG_T GetLoggerTag()
 
309
                        { return(id.tag); };
 
310
 
 
311
                // return the logger type
 
312
                uLONG GetLoggerType()
 
313
                        { return(id.type); };
 
314
 
 
315
                // return the id
 
316
                LoggerID_S * GetID()                    // possibly pass in engine buffer or memcpy passed
 
317
                        { return(&id); };               // in pointer
 
318
 
 
319
        private:
 
320
 
 
321
                // logger id structure
 
322
                LoggerID_S id;
 
323
 
 
324
                // the number of the next tag to be assigned
 
325
                static DPT_TAG_T nextTag;
 
326
};
 
327
 
 
328
//struct - AdditionEventInfo_S - start
 
329
//===========================================================================
 
330
//
 
331
//Description: this is additional event info sent to the broadcaster that needs
 
332
//                                      to be filled in before they get it
 
333
//
 
334
//
 
335
//
 
336
//---------------------------------------------------------------------------
 
337
struct AdditionalEventInfo_S
 
338
{
 
339
        // SNMP trap info for both the actual and resultant events
 
340
        snmpTrapVars_S actualTrap;
 
341
        snmpTrapVars_S resultantTrap;
 
342
 
 
343
};
 
344
// - end
 
345
 
 
346
 
 
347
 
 
348
 
 
349
//Variables - External ------------------------------------------------------
 
350
 
 
351
 
 
352
//Variables - Global --------------------------------------------------------
 
353
 
 
354
 
 
355
//Variables - File Scope ----------------------------------------------------
 
356
 
 
357
 
 
358
//Prototypes - function -----------------------------------------------------
 
359
 
 
360
 
 
361
#endif
 
362