1 | #ifndef EVIDENCE_H_SEEN
|
---|
2 | #define EVIDENCE_H_SEEN
|
---|
3 |
|
---|
4 | #include <stdio.h>
|
---|
5 | #include <stdarg.h>
|
---|
6 | #include <string>
|
---|
7 | #include <errno.h>
|
---|
8 | #include <vector>
|
---|
9 | #include <exception>
|
---|
10 | #include <cxxabi.h>
|
---|
11 |
|
---|
12 | #include "dis.hxx"
|
---|
13 | #include "dic.hxx"
|
---|
14 |
|
---|
15 | #define NO_LINK (char *) "__&DIM&NOLINK&__" // Data if no link available
|
---|
16 | #define STATUS_SIZE 1000 // Bytes for status service string
|
---|
17 | #define EVIDENCE_REVISION "$Revision: 209 $"
|
---|
18 |
|
---|
19 | // Class declation of Evidence server
|
---|
20 | class EvidenceServer: public DimServer {
|
---|
21 | private:
|
---|
22 | // This class will contain in LastModifyTime always
|
---|
23 | // the unix time of the last config file update
|
---|
24 | class ConfigUpdate: public DimClient {
|
---|
25 | DimInfo *ModifyInfo;
|
---|
26 |
|
---|
27 | public:
|
---|
28 | ConfigUpdate() {
|
---|
29 | LastModifyTime = 0;
|
---|
30 | ModifyInfo = new DimInfo("Config/ModifyTime", NO_LINK, this);
|
---|
31 | }
|
---|
32 | ~ConfigUpdate() {
|
---|
33 | delete ModifyInfo;
|
---|
34 | }
|
---|
35 | void infoHandler(){
|
---|
36 | if (EvidenceServer::ServiceOK(getInfo())) LastModifyTime = getInfo()->getInt();
|
---|
37 | }
|
---|
38 | int LastModifyTime;
|
---|
39 | };
|
---|
40 |
|
---|
41 | struct ConfigItem {
|
---|
42 | std::string Name;
|
---|
43 | char *Value;
|
---|
44 | int Time;
|
---|
45 | };
|
---|
46 | std::vector<struct ConfigItem> ConfigList;
|
---|
47 |
|
---|
48 | std::string ServerName;
|
---|
49 | DimService *Status, *StdOut;
|
---|
50 | class ConfigUpdate *ModifyInfo;
|
---|
51 |
|
---|
52 | char InitMsg[STATUS_SIZE];
|
---|
53 | int LastModifyTime;
|
---|
54 | char *StdOutText;
|
---|
55 |
|
---|
56 | static void SignalHandler(int); // static for signal()
|
---|
57 | static void Terminate(); // static for set_terminate()
|
---|
58 | void errorHandler(int, int, char *);
|
---|
59 | void exitHandler(int);
|
---|
60 |
|
---|
61 | public:
|
---|
62 | EvidenceServer(const char *);
|
---|
63 | ~EvidenceServer();
|
---|
64 |
|
---|
65 | enum StateType {INFO=0, WARN=1, ERROR=2, FATAL=3};
|
---|
66 |
|
---|
67 | void State(StateType, const char *, ...);
|
---|
68 | void SetStdOut(char *);
|
---|
69 | char* GetConfig(std::string, const char * = NULL);
|
---|
70 | static char* ToString(DimInfo *);
|
---|
71 | static bool ServiceOK(DimInfo *);
|
---|
72 | static bool ServiceOK(DimRpcInfo *);
|
---|
73 |
|
---|
74 | bool ExitRequest;
|
---|
75 | };
|
---|
76 |
|
---|
77 | class EvidenceHistory: public DimClient {
|
---|
78 |
|
---|
79 | static const int WrapMark[];
|
---|
80 | static const int EndMark[];
|
---|
81 |
|
---|
82 | std::string Name;
|
---|
83 | char *Buffer;
|
---|
84 | int BufferSize;
|
---|
85 | int Offset;
|
---|
86 |
|
---|
87 | public:
|
---|
88 | EvidenceHistory(std::string);
|
---|
89 | ~EvidenceHistory();
|
---|
90 |
|
---|
91 | bool GetHistory();
|
---|
92 | bool Next(int &, int &, void *&);
|
---|
93 | };
|
---|
94 | #endif
|
---|