Skip to content

Commit

Permalink
messages: use const char* instead of char* for message string
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Feb 11, 2020
1 parent 75dc94a commit 4d4cfeb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion core/src/dird/dird.cc
Expand Up @@ -157,7 +157,9 @@ static void ReloadJobEndCb(JobControlRecord* jcr, void* ctx)
* access to the database. If the pointer is not defined (other daemons), then
* writing the database is disabled.
*/
static bool DirDbLogInsert(JobControlRecord* jcr, utime_t mtime, char* msg)
static bool DirDbLogInsert(JobControlRecord* jcr,
utime_t mtime,
const char* msg)
{
int length;
char ed1[50];
Expand Down
9 changes: 6 additions & 3 deletions core/src/lib/message.cc
Expand Up @@ -72,7 +72,7 @@ job_code_callback_t message_job_code_callback = NULL; // Only used by director
static MessagesResource* daemon_msgs; /* Global messages */
static char* catalog_db = NULL; /* Database type */
static const char* log_timestamp_format = "%d-%b %H:%M";
static void (*message_callback)(int type, char* msg) = NULL;
static void (*message_callback)(int type, const char* msg) = NULL;
static FILE* trace_fd = NULL;
#if defined(HAVE_WIN32)
static bool trace = true;
Expand Down Expand Up @@ -137,7 +137,7 @@ static void DeliveryError(const char* fmt, ...)
FreeMemory(pool_buf);
}

void RegisterMessageCallback(void msg_callback(int type, char* msg))
void RegisterMessageCallback(void msg_callback(int type, const char* msg))
{
message_callback = msg_callback;
}
Expand Down Expand Up @@ -621,7 +621,10 @@ static inline void SendToSyslog(int mode, const char* msg)
/*
* Handle sending the message to the appropriate place
*/
void DispatchMessage(JobControlRecord* jcr, int type, utime_t mtime, char* msg)
void DispatchMessage(JobControlRecord* jcr,
int type,
utime_t mtime,
const char* msg)
{
char dt[MAX_TIME_LENGTH];
POOLMEM* mcmd;
Expand Down
9 changes: 6 additions & 3 deletions core/src/lib/message.h
Expand Up @@ -54,7 +54,7 @@ void SetLogTimestampFormat(const char* format);

typedef bool (*db_log_insert_func)(JobControlRecord* jcr,
utime_t mtime,
char* msg);
const char* msg);
void SetDbLogInsertCallback(db_log_insert_func f);

class MessagesResource;
Expand All @@ -79,7 +79,10 @@ void InitMsg(JobControlRecord* jcr,
void TermMsg(void);
void CloseMsg(JobControlRecord* jcr);
void Jmsg(JobControlRecord* jcr, int type, utime_t mtime, const char* fmt, ...);
void DispatchMessage(JobControlRecord* jcr, int type, utime_t mtime, char* buf);
void DispatchMessage(JobControlRecord* jcr,
int type,
utime_t mtime,
const char* buf);
void InitConsoleMsg(const char* wd);
void DequeueMessages(JobControlRecord* jcr);
void SetTrace(int trace_flag);
Expand All @@ -89,6 +92,6 @@ bool GetHangup(void);
void SetTimestamp(int timestamp_flag);
bool GetTimestamp(void);
void SetDbType(const char* name);
void RegisterMessageCallback(void msg_callback(int type, char* msg));
void RegisterMessageCallback(void msg_callback(int type, const char* msg));

#endif /* BAREOS_LIB_MESSAGE_H_ */

0 comments on commit 4d4cfeb

Please sign in to comment.