/* Bacula common configuration defines */
+#define HAVE_VA_COPY
+
#undef TRUE
#undef FALSE
#define TRUE 1
#endif
#if defined(HAVE_DARWIN_OS) || defined(HAVE_OSF1_OS)
+#undef HAVE_VA_COPY
/* Apparently someone forgot to wrap getdomainname as a C function */
extern "C" int getdomainname(char *name, int len);
#endif
-#ifdef HAVE_OSF1_OS
-extern "C" int mknod ( const char *path, int mode, dev_t device );
-#endif
#if defined(HAVE_WIN32)
#ifdef HAVE_HPUX_OS
# undef h_errno
+#undef HAVE_VA_COPY
extern int h_errno;
/* the {get,set}domainname() functions exist in HPUX's libc.
* the configure script detects that correctly.
#ifdef HAVE_OSF1_OS
-#undef HAVE_CHFLAGS /* chflags is incorrectly detected */
+#undef HAVE_VA_COPY
extern "C" int fchdir(int filedes);
extern "C" long gethostid(void);
+extern "C" int mknod ( const char *path, int mode, dev_t device );
#endif
ua->UA_sock->msg = check_pool_memory_size(ua->UA_sock->msg, mlen+1);
strcpy(ua->UA_sock->msg, msg);
ua->UA_sock->msglen = mlen;
- bnet_send(ua->UA_sock);
+ ua->UA_sock->send();
do_truncate = true;
}
if (do_truncate) {
if (console_msg_pending) {
do_messages(ua, cmd);
} else {
- bnet_fsend(ua->UA_sock, _("You have no messages.\n"));
+ ua->UA_sock->fsend(_("You have no messages.\n"));
}
return 1;
}
{
UAContext *ua = (UAContext *)ctx;
- bnet_fsend(ua->UA_sock, "%s", msg);
+ ua->UA_sock->fsend("%s", msg);
}
/*
* agent, so we are being called from Bacula core. In
* that case direct the messages to the Job.
*/
+#ifdef HAVE_VA_COPY
void bmsg(UAContext *ua, const char *fmt, va_list arg_ptr)
{
BSOCK *bs = ua->UA_sock;
int maxlen, len;
POOLMEM *msg = NULL;
+ va_list ap;
if (bs) {
msg = bs->msg;
again:
maxlen = sizeof_pool_memory(msg) - 1;
- len = bvsnprintf(msg, maxlen, fmt, arg_ptr);
+ va_copy(ap, arg_ptr);
+ len = bvsnprintf(msg, maxlen, fmt, ap);
+ va_end(ap);
if (len < 0 || len >= maxlen) {
msg = realloc_pool_memory(msg, maxlen + maxlen/2);
goto again;
if (bs) {
bs->msg = msg;
bs->msglen = len;
- bnet_send(bs);
+ bs->send();
} else { /* No UA, send to Job */
Jmsg(ua->jcr, M_INFO, 0, "%s", msg);
free_pool_memory(msg);
}
}
+
+#else /* no va_copy() -- brain damaged version of variable arguments */
+
+void bmsg(UAContext *ua, const char *fmt, va_list arg_ptr)
+{
+ BSOCK *bs = ua->UA_sock;
+ int maxlen, len;
+ POOLMEM *msg = NULL;
+
+ if (bs) {
+ msg = bs->msg;
+ }
+ if (!msg) {
+ msg = get_pool_memory(5000);
+ }
+
+ maxlen = sizeof_pool_memory(msg) - 1;
+ if (maxlen < 4999) {
+ msg = realloc_pool_memory(msg, 5000);
+ maxlen = 4999;
+ }
+ len = bvsnprintf(msg, maxlen, fmt, arg_ptr);
+ if (len < 0 || len >= maxlen) {
+ pm_strcpy(msg, _("Message too long to display.\n"));
+ len = strlen(msg);
+ }
+
+ if (bs) {
+ bs->msg = msg;
+ bs->msglen = len;
+ bs->send();
+ } else { /* No UA, send to Job */
+ Jmsg(ua->jcr, M_INFO, 0, "%s", msg);
+ free_pool_memory(msg);
+ }
+
+}
+#endif
void bsendmsg(void *ctx, const char *fmt, ...)
{
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2005-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2005-2007 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
#include "bacula.h"
#define FP_OUTPUT 1 /* Bacula uses floating point */
+
/* Define the following if you want all the features of
* normal printf, but with all the security problems.
* For Bacula we turn this off, and it silently ignores