]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/message.h
const char * additions
[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, 2001, 2002 Kern Sibbald and John Walker
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 as
12    published by the Free Software Foundation; either version 2 of
13    the License, or (at your option) any later version.
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 GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public
21    License along with this program; if not, write to the Free
22    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
23    MA 02111-1307, USA.
24
25  */
26
27 #include "bits.h"
28
29 #undef  M_DEBUG
30 #undef  M_ABORT
31 #undef  M_FATAL
32 #undef  M_ERROR
33 #undef  M_WARNING
34 #undef  M_INFO
35 #undef  M_MOUNT
36 #undef  M_ERROR_TERM
37 #undef  M_TERM
38 #undef  M_RESTORED
39 #undef  M_SECURITY
40
41 /*
42  * Most of these message levels are more or less obvious. 
43  * They have evolved somewhat during the development of Bacula,
44  * and here are some of the details of where I am trying to
45  * head (in the process of changing the code) as of 15 June 2002.
46  *
47  *  M_ABORT       Bacula immediately aborts and tries to produce a traceback
48  *                  This is for really serious errors like segmentation fault.
49  *  M_ERROR_TERM  Bacula immediately terminates but no dump. This is for
50  *                  "obvious" serious errors like daemon already running or
51  *                   cannot open critical file, ... where a dump is not wanted.
52  *  M_TERM        Bacula daemon shutting down because of request (SIGTERM).
53  *
54  * The remaining apply to Jobs rather than the daemon.
55  *
56  *  M_FATAL       Bacula detected a fatal Job error. The Job will be killed,
57  *                  but Bacula continues running.
58  *  M_ERROR       Bacula detected a Job error. The Job will continue running
59  *                  but the termination status will be error. 
60  *  M_WARNING     Job warning message.
61  *  M_INFO        Job information message.
62  *
63  *  M_RESTORED    An ls -l of each restored file.
64  *
65  *  M_SECURITY    For security viloations. This is equivalent to FATAL.
66  *                (note, this is currently being implemented in 1.33).
67  *
68  */
69
70 enum {
71    M_DEBUG = 1,                       /* debug message */
72    M_ABORT,                           /* MUST abort immediately */
73    M_FATAL,                           /* Fatal error, stopping job */
74    M_ERROR,                           /* Error, but recoverable */
75    M_WARNING,                         /* Warning message */
76    M_INFO,                            /* Informational message */
77    M_SAVED,                           /* Info on saved file */
78    M_NOTSAVED,                        /* Info on notsaved file */
79    M_SKIPPED,                         /* File skipped during backup by option setting */
80    M_MOUNT,                           /* Mount requests */
81    M_ERROR_TERM,                      /* Error termination request (no dump) */
82    M_TERM,                            /* Terminating daemon normally */
83    M_RESTORED,                        /* ls -l of restored files */
84    M_SECURITY,                        /* security violation */
85 };
86
87 #define M_MAX      M_SECURITY         /* keep this updated ! */
88
89 /* Define message destination structure */
90 /* *** FIXME **** where should be extended to handle multiple values */
91 typedef struct s_dest {
92    struct s_dest *next;
93    int dest_code;                     /* destination (one of the MD_ codes) */
94    int max_len;                       /* max mail line length */
95    FILE *fd;                          /* file descriptor */
96    char msg_types[nbytes_for_bits(M_MAX+1)]; /* message type mask */
97    char *where;                       /* filename/program name */
98    char *mail_cmd;                    /* mail command */
99    POOLMEM *mail_filename;            /* unique mail filename */
100 } DEST;
101
102 /* Message Destination values for dest field of DEST */
103 #define MD_SYSLOG    1                /* send msg to syslog */
104 #define MD_MAIL      2                /* email group of messages */
105 #define MD_FILE      3                /* write messages to a file */
106 #define MD_APPEND    4                /* append messages to a file */
107 #define MD_STDOUT    5                /* print messages */
108 #define MD_STDERR    6                /* print messages to stderr */
109 #define MD_DIRECTOR  7                /* send message to the Director */
110 #define MD_OPERATOR  8                /* email a single message to the operator */
111 #define MD_CONSOLE   9                /* send msg to UserAgent or console */
112 #define MD_MAIL_ON_ERROR 10           /* email messages if job errors */
113
114 /* Queued message item */
115 struct MQUEUE_ITEM {
116    dlink link;
117    int type;
118    int level;
119    char msg[1];
120 };
121
122
123 void d_msg(const char *file, int line, int level, const char *fmt,...);
124 void e_msg(const char *file, int line, int type, int level, const char *fmt,...);
125 void Jmsg(JCR *jcr, int type, int level, const char *fmt,...);
126
127 extern int debug_level;
128 extern int verbose;
129 extern char my_name[];
130 extern char *working_directory;
131 extern time_t daemon_start_time;
132 extern char catalog_db[];