Exemplo n.º 1
0
/*
 * Format a scanner error message
 */
static void s_err(const char *file, int line, LEX *lc, const char *msg, ...)
{
   va_list ap;
   int len, maxlen;
   POOL_MEM buf(PM_NAME);
   JCR *jcr = (JCR *)(lc->caller_ctx);

   while (1) {
      maxlen = buf.size() - 1;
      va_start(ap, msg);
      len = bvsnprintf(buf.c_str(), maxlen, msg, ap);
      va_end(ap);

      if (len < 0 || len >= (maxlen - 5)) {
         buf.realloc_pm(maxlen + maxlen / 2);
         continue;
      }

      break;
   }

   if (jcr) {
      Jmsg(jcr, M_FATAL, 0, _("Bootstrap file error: %s\n"
                              "            : Line %d, col %d of file %s\n%s\n"),
           buf.c_str(), lc->line_no, lc->col_no, lc->fname, lc->line);
   } else {
      e_msg(file, line, M_FATAL, 0, _("Bootstrap file error: %s\n"
                                      "            : Line %d, col %d of file %s\n%s\n"),
            buf.c_str(), lc->line_no, lc->col_no, lc->fname, lc->line);
   }
}
Exemplo n.º 2
0
void ClientHandler::HandleEvent(EventWho& event, ClientInfo & client) {

	Cli::writeDebugMsg("Handling Who event");
	std::lock_guard<std::mutex> lock(mtx);

	auto itrRqClient = m_ClientToRoomMap.find( (void*)&client ); // Find iterator for requesting client
	if(itrRqClient == m_ClientToRoomMap.end()) { // Make sure it returned something
		Cli::writeLogMsg(Cli::LOGTYPE_ERROR, "Unable find client in map");
		client.Disconnect();
		return;
	}

	try {
		std::string clients_str("Room " + itrRqClient->second.room_ptr->getName() + " contains: ");

		// Iterate through the list clients in the room and add names to the string:
		for(auto itList = itrRqClient->second.room_ptr->clients_.begin(); itList != itrRqClient->second.room_ptr->clients_.end(); itList++) {
			auto itrClientN = m_ClientToRoomMap.find( (void*)(*itList).get() ); // Find iterator to client n in the room.
			clients_str.append(*itrClientN->second.name_ptr);
			clients_str.append(",");
		}

		// Send message event with the result:
		EventMsg e_msg("Server", clients_str);
		EventVariant eventOut = e_msg;
		itrRqClient->second.client_ptr->Send(eventOut);
	} catch (...) {
		Cli::writeLogMsg(Cli::LOGTYPE_ERROR, "Exception: Creating or transmitting who response");
	}
}
Exemplo n.º 3
0
/*
 * Format a scanner error message
 */
static void s_err(const char *file, int line, LEX *lc, const char *msg, ...)
{
   ConfigFile *ini = (ConfigFile *)(lc->caller_ctx);
   va_list arg_ptr;
   char buf[MAXSTRING];

   va_start(arg_ptr, msg);
   bvsnprintf(buf, sizeof(buf), msg, arg_ptr);
   va_end(arg_ptr);

#ifdef TEST_PROGRAM
   printf("ERROR: Config file error: %s\n"
          "            : Line %d, col %d of file %s\n%s\n",
      buf, lc->line_no, lc->col_no, lc->fname, lc->line);
#endif

   if (ini->jcr) {              /* called from core */
      Jmsg(ini->jcr, M_ERROR, 0, _("Config file error: %s\n"
                              "            : Line %d, col %d of file %s\n%s\n"),
         buf, lc->line_no, lc->col_no, lc->fname, lc->line);

//   } else if (ini->ctx) {       /* called from plugin */
//      ini->bfuncs->JobMessage(ini->ctx, __FILE__, __LINE__, M_FATAL, 0,
//                    _("Config file error: %s\n"
//                      "            : Line %d, col %d of file %s\n%s\n"),
//                            buf, lc->line_no, lc->col_no, lc->fname, lc->line);
//
   } else {                     /* called from ??? */
      e_msg(file, line, M_ERROR, 0,
            _("Config file error: %s\n"
              "            : Line %d, col %d of file %s\n%s\n"),
            buf, lc->line_no, lc->col_no, lc->fname, lc->line);
   }
}
Exemplo n.º 4
0
/*
 * Format a scanner error message
 */
static void s_err(const char *file, int line, LEX *lc, const char *msg, ...)
{
   va_list ap;
   int len, maxlen;
   POOL_MEM buf(PM_NAME),
            more(PM_NAME);

   while (1) {
      maxlen = buf.size() - 1;
      va_start(ap, msg);
      len = bvsnprintf(buf.c_str(), maxlen, msg, ap);
      va_end(ap);

      if (len < 0 || len >= (maxlen - 5)) {
         buf.realloc_pm(maxlen + maxlen / 2);
         continue;
      }

      break;
   }

   if (lc->err_type == 0) {     /* M_ERROR_TERM by default */
      lc->err_type = M_ERROR_TERM;
   }

   if (lc->line_no > lc->begin_line_no) {
      Mmsg(more, _("Problem probably begins at line %d.\n"), lc->begin_line_no);
   } else {
      pm_strcpy(more, "");
   }

   if (lc->line_no > 0) {
      e_msg(file, line, lc->err_type, 0, _("Config error: %s\n"
                                           "            : line %d, col %d of file %s\n%s\n%s"),
            buf.c_str(), lc->line_no, lc->col_no, lc->fname, lc->line, more.c_str());
   } else {
      e_msg(file, line, lc->err_type, 0, _("Config error: %s\n"), buf.c_str());
   }
}
Exemplo n.º 5
0
void *sm_realloc(const char *fname, int lineno, void *ptr, unsigned int size)
{
   unsigned osize;
   void *buf;
   char *cp = (char *) ptr;

   Dmsg4(DT_MEMORY|50, "sm_realloc %s:%d %p %d\n", get_basename(fname), (uint32_t)lineno, ptr, size);
   if (size <= 0) {
      e_msg(fname, lineno, M_ABORT, 0, _("sm_realloc size: %d\n"), size);
   }

   /*  If  the  old  block  pointer  is  NULL, treat realloc() as a
      malloc().  SVID is silent  on  this,  but  many  C  libraries
      permit this.  */
   if (ptr == NULL) {
      return sm_malloc(fname, lineno, size);
   }

   /* If the old and new sizes are the same, be a nice guy and just
      return the buffer passed in.  */
   cp -= HEAD_SIZE;
   struct abufhead *head = (struct abufhead *)cp;
   osize = head->ablen - (HEAD_SIZE + 1);
   if (size == osize) {
      return ptr;
   }

   /* Sizes differ.  Allocate a new buffer of the  requested  size.
      If  we  can't  obtain  such a buffer, act as defined in SVID:
      return NULL from  realloc()  and  leave  the  buffer  in  PTR
      intact.  */

// sm_buffers--;
// sm_bytes -= head->ablen;

   if ((buf = smalloc(fname, lineno, size)) != NULL) {
      memcpy(buf, ptr, (int)sm_min(size, osize));
      /* If the new buffer is larger than the old, fill the balance
         of it with "designer garbage". */
      if (size > osize) {
         memset(((char *) buf) + osize, 0x55, (int) (size - osize));
      }

      /* All done.  Free and dechain the original buffer. */
      sm_free(fname, lineno, ptr);
   }
   Dmsg4(DT_MEMORY|60, _("sm_realloc %d at %p from %s:%d\n"), size, buf, get_basename(fname), (uint32_t)lineno);
   return buf;
}
Exemplo n.º 6
0
Arquivo: bsys.c Projeto: pstray/bareos
void *b_malloc(const char *file, int line, size_t size)
{
  void *buf;

#ifdef SMARTALLOC
  buf = sm_malloc(file, line, size);
#else
  buf = malloc(size);
#endif
  if (buf == NULL) {
     berrno be;
     e_msg(file, line, M_ABORT, 0, _("Out of memory: ERR=%s\n"), be.bstrerror());
  }
  return buf;
}
Exemplo n.º 7
0
void send_messages_mt_impl(unsigned int id)
{
  char chan[1] = { char(65 + id) };

  message_type t_msg( chan, 1, level::trace,   "This is a trace-log!"  , 21  );
  message_type d_msg( chan, 1, level::debug,   "This is a debug-log!"  , 21  );
  message_type i_msg( chan, 1, level::info,    "This is an info-log!"  , 21  );
  message_type w_msg( chan, 1, level::warn,    "This is a warning-log!", 23  );
  message_type e_msg( chan, 1, level::error,   "This is an error-log!" , 22  );
  distributor_type::instance().log(t_msg);
  distributor_type::instance().log(d_msg);
  distributor_type::instance().log(i_msg);
  distributor_type::instance().log(w_msg);
  distributor_type::instance().log(e_msg);
}
Exemplo n.º 8
0
void send_messages()
{
  benchmark::steady_timer t(time_vector);

  char chan[1] = { char(65) };

  message_type t_msg( chan, 1, level::trace,   "This is a trace-log!"  , 21  );
  message_type d_msg( chan, 1, level::debug,   "This is a debug-log!"  , 21  );
  message_type i_msg( chan, 1, level::info,    "This is an info-log!"  , 21  );
  message_type w_msg( chan, 1, level::warn,    "This is a warning-log!", 23  );
  message_type e_msg( chan, 1, level::error,   "This is an error-log!" , 22  );
  distributor_type::instance().log(t_msg);
  distributor_type::instance().log(d_msg);
  distributor_type::instance().log(i_msg);
  distributor_type::instance().log(w_msg);
  distributor_type::instance().log(e_msg);
}
Exemplo n.º 9
0
void ClientHandler::HandleEvent(EventMsg& event, ClientInfo & client) {
	Cli::writeDebugMsg("Handling Msg event");
	std::lock_guard<std::mutex> lock(mtx);

	auto itr = m_ClientToRoomMap.find( (void*)&client );
	if(itr != m_ClientToRoomMap.end()) {
		try {
			EventMsg e_msg(*itr->second.name_ptr, event.getMessage());
			itr->second.room_ptr->broadcastMsg(e_msg);
		} catch (...) {
			Cli::writeLogMsg(Cli::LOGTYPE_ERROR, "Failed to create msg event for broadcast");
			return;
		}
	} else {
		Cli::writeLogMsg(Cli::LOGTYPE_ERROR, "Unable to find client in map");
		client.Disconnect();
	}
}
Exemplo n.º 10
0
/*
 * Format a scanner error message
 */
static void s_err(const char *file, int line, LEX *lc, const char *msg, ...)
{
   JCR *jcr = (JCR *)(lc->caller_ctx);
   va_list arg_ptr;
   char buf[MAXSTRING];

   va_start(arg_ptr, msg);
   bvsnprintf(buf, sizeof(buf), msg, arg_ptr);
   va_end(arg_ptr);

   if (jcr) {
      Jmsg(jcr, M_FATAL, 0, _("Bootstrap file error: %s\n"
"            : Line %d, col %d of file %s\n%s\n"),
         buf, lc->line_no, lc->col_no, lc->fname, lc->line);
   } else {
      e_msg(file, line, M_FATAL, 0, _("Bootstrap file error: %s\n"
"            : Line %d, col %d of file %s\n%s\n"),
         buf, lc->line_no, lc->col_no, lc->fname, lc->line);
   }
}
Exemplo n.º 11
0
Arquivo: ini.c Projeto: dl5rcw/bareos
/*
 * Format a scanner error message
 */
static void s_err(const char *file, int line, LEX *lc, const char *msg, ...)
{
   va_list ap;
   int len, maxlen;
   ConfigFile *ini;
   POOL_MEM buf(PM_MESSAGE);

   while (1) {
      maxlen = buf.size() - 1;
      va_start(ap, msg);
      len = bvsnprintf(buf.c_str(), maxlen, msg, ap);
      va_end(ap);

      if (len < 0 || len >= (maxlen - 5)) {
         buf.realloc_pm(maxlen + maxlen / 2);
         continue;
      }

      break;
   }

   ini = (ConfigFile *)(lc->caller_ctx);
   if (ini->jcr) {              /* called from core */
      Jmsg(ini->jcr, M_ERROR, 0, _("Config file error: %s\n"
                              "            : Line %d, col %d of file %s\n%s\n"),
         buf.c_str(), lc->line_no, lc->col_no, lc->fname, lc->line);

//   } else if (ini->ctx) {       /* called from plugin */
//      ini->bfuncs->JobMessage(ini->ctx, __FILE__, __LINE__, M_FATAL, 0,
//                    _("Config file error: %s\n"
//                      "            : Line %d, col %d of file %s\n%s\n"),
//                            buf.c_str(), lc->line_no, lc->col_no, lc->fname, lc->line);
//
   } else {                     /* called from ??? */
      e_msg(file, line, M_ERROR, 0,
            _("Config file error: %s\n"
              "            : Line %d, col %d of file %s\n%s\n"),
            buf.c_str(), lc->line_no, lc->col_no, lc->fname, lc->line);
   }
}
Exemplo n.º 12
0
int main( int argc, const char* argv[] )
{
	try
	{
		angie::test::BitfieldTests bitfield_tests;

		std::vector<const angie::test::unit> container_set;
		container_set.push_back(bitfield_tests);

		angie::test::result container_result = angie::test::suite("Container Tests",container_set);
		angie::output( container_result._message );
	}
	catch( std::exception& e )
	{
		std::string e_msg("!!! EXCEPTION COUGHT !!!\n");
		e_msg.append(e.what());
		
		angie::output(e_msg);
		std::abort();
	}

	std::exit(EXIT_SUCCESS);
}