]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/message.h
9Nov06
[bacula/bacula] / bacula / src / lib / message.h
1 /*
2  * Define Message Types for Bacula
3  *    Kern Sibbald, 2000
4  *
5  *   Version $Id$
6  */
7 /*
8    Copyright (C) 2000-2006 Kern Sibbald
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License
12    version 2 as amended with additional clauses defined in the
13    file LICENSE in the main source directory.
14
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
18    the file LICENSE for additional details.
19
20  */
21
22 #include "bits.h"
23
24 #undef  M_DEBUG
25 #undef  M_ABORT
26 #undef  M_FATAL
27 #undef  M_ERROR
28 #undef  M_WARNING
29 #undef  M_INFO
30 #undef  M_MOUNT
31 #undef  M_ERROR_TERM
32 #undef  M_TERM
33 #undef  M_RESTORED
34 #undef  M_SECURITY
35 #undef  M_ALERT
36 #undef  M_VOLMGMT
37
38 /*
39  * Most of these message levels are more or less obvious.
40  * They have evolved somewhat during the development of Bacula,
41  * and here are some of the details of where I am trying to
42  * head (in the process of changing the code) as of 15 June 2002.
43  *
44  *  M_ABORT       Bacula immediately aborts and tries to produce a traceback
45  *                  This is for really serious errors like segmentation fault.
46  *  M_ERROR_TERM  Bacula immediately terminates but no dump. This is for
47  *                  "obvious" serious errors like daemon already running or
48  *                   cannot open critical file, ... where a dump is not wanted.
49  *  M_TERM        Bacula daemon shutting down because of request (SIGTERM).
50  *
51  * The remaining apply to Jobs rather than the daemon.
52  *
53  *  M_FATAL       Bacula detected a fatal Job error. The Job will be killed,
54  *                  but Bacula continues running.
55  *  M_ERROR       Bacula detected a Job error. The Job will continue running
56  *                  but the termination status will be error.
57  *  M_WARNING     Job warning message.
58  *  M_INFO        Job information message.
59  *
60  *  M_RESTORED    An ls -l of each restored file.
61  *
62  *  M_SECURITY    For security viloations. This is equivalent to FATAL.
63  *                (note, this is currently being implemented in 1.33).
64  *
65  *  M_ALERT       For Tape Alert messages.
66  *
67  *  M_VOLMGMT     Volume Management message
68  */
69
70 enum {
71    /* Keep M_ABORT=1 for dlist.h */
72    M_ABORT = 1,                       /* MUST abort immediately */
73    M_DEBUG,                           /* debug message */
74    M_FATAL,                           /* Fatal error, stopping job */
75    M_ERROR,                           /* Error, but recoverable */
76    M_WARNING,                         /* Warning message */
77    M_INFO,                            /* Informational message */
78    M_SAVED,                           /* Info on saved file */
79    M_NOTSAVED,                        /* Info on notsaved file */
80    M_SKIPPED,                         /* File skipped during backup by option setting */
81    M_MOUNT,                           /* Mount requests */
82    M_ERROR_TERM,                      /* Error termination request (no dump) */
83    M_TERM,                            /* Terminating daemon normally */
84    M_RESTORED,                        /* ls -l of restored files */
85    M_SECURITY,                        /* security violation */
86    M_ALERT,                           /* tape alert messages */
87    M_VOLMGMT                          /* Volume management messages */
88 };
89
90 #define M_MAX      M_VOLMGMT          /* keep this updated ! */
91
92 /* Define message destination structure */
93 /* *** FIXME **** where should be extended to handle multiple values */
94 typedef struct s_dest {
95    struct s_dest *next;
96    int dest_code;                     /* destination (one of the MD_ codes) */
97    int max_len;                       /* max mail line length */
98    FILE *fd;                          /* file descriptor */
99    char msg_types[nbytes_for_bits(M_MAX+1)]; /* message type mask */
100    char *where;                       /* filename/program name */
101    char *mail_cmd;                    /* mail command */
102    POOLMEM *mail_filename;            /* unique mail filename */
103 } DEST;
104
105 /* Message Destination values for dest field of DEST */
106 enum {
107    MD_SYSLOG = 1,                     /* send msg to syslog */
108    MD_MAIL,                           /* email group of messages */
109    MD_FILE,                           /* write messages to a file */
110    MD_APPEND,                         /* append messages to a file */
111    MD_STDOUT,                         /* print messages */
112    MD_STDERR,                         /* print messages to stderr */
113    MD_DIRECTOR,                       /* send message to the Director */
114    MD_OPERATOR,                       /* email a single message to the operator */
115    MD_CONSOLE,                        /* send msg to UserAgent or console */
116    MD_MAIL_ON_ERROR,                  /* email messages if job errors */
117    MD_MAIL_ON_SUCCESS,                /* email messages if job succeeds */
118    MD_CATALOG                         /* sent to catalog Log table */
119 };
120
121 /* Queued message item */
122 struct MQUEUE_ITEM {
123    dlink link;
124    int type;
125    time_t mtime;
126    char msg[1];
127 };
128
129  
130 void d_msg(const char *file, int line, int level, const char *fmt,...);
131 void e_msg(const char *file, int line, int type, int level, const char *fmt,...);
132 void Jmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...);
133 void Qmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...);
134 bool get_trace(void);
135
136 typedef void (*sql_query)(JCR *jcr, const char *cmd);
137 typedef void (*sql_escape)(char *snew, char *old, int len);
138
139 extern DLL_IMP_EXP sql_query     p_sql_query;
140 extern DLL_IMP_EXP sql_escape    p_sql_escape;
141
142 extern DLL_IMP_EXP int           debug_level;
143 extern DLL_IMP_EXP int           verbose;
144 extern DLL_IMP_EXP char          my_name[];
145 extern DLL_IMP_EXP const char *  working_directory;
146 extern DLL_IMP_EXP time_t        daemon_start_time;
147
148 extern DLL_IMP_EXP int           console_msg_pending;
149 extern DLL_IMP_EXP FILE *        con_fd;                 /* Console file descriptor */
150 extern DLL_IMP_EXP brwlock_t     con_lock;               /* Console lock structure */