Ejemplo n.º 1
0
/*-------------------------------------------------------------------------------------------------------------------------------------

FUNCTION:		ServerRoutine

INTERFACE:		void CALLBACK ServerRoutine(DWORD Error, DWORD BytesTransferred, LPWSAOVERLAPPED Overlapped, DWORD InFlags)

RETURNS:		void

NOTES:			Gets called when there is an I/O request on the socket. Checks for control information and EOF on the socket, and 
				normal packet data. Once data is received, it is written to a file for analysis

--------------------------------------------------------------------------------------------------------------------------------------*/
void CALLBACK ServerRoutine(DWORD Error, DWORD BytesTransferred, LPWSAOVERLAPPED Overlapped, DWORD InFlags)
{
	DWORD RecvBytes = 0, Index;
	DWORD Flags = 0;
	WSAEVENT			EventArray[1] = { 0 };
	WSAEVENT			acceptEvent;

	// Reference the WSAOVERLAPPED structure as a SOCKET_INFORMATION structure
	LPSOCKET_INFORMATION SI = (LPSOCKET_INFORMATION)Overlapped;
	initSockInfo(SI, SI->Buffer, DATA_BUFSIZE);

	if (Error != 0)
	{
		int i = WSAGetLastError();
		formatMessage("I/O operation failed");
	}
	if (checkControlFormat(SI))
	{
		formatMessage("Initial Packet Received");
		sscanf(SI->DataBuf.buf, "%*s %d %d", &fileInfo->sizeOfPackets, &fileInfo->numberOfPackets);
		QueryPerformanceFrequency(&fileInfo->frequency);
		QueryPerformanceCounter(&fileInfo->startTimeStamp);
	}
	if (checkEOFFormat(SI))
	{
		formatMessage("Final Packet Received");
		exitThread = true;
		QueryPerformanceCounter(&fileInfo->endTimeStamp);
		fileInfo->protocol = protocol;
		return;
	}

	initSockInfo(SI, SI->Buffer, fileInfo->sizeOfPackets);
	//UDP
	if (protocol == UDP)
	{
		if ((acceptEvent = WSACreateEvent()) == WSA_INVALID_EVENT)
		{
			formatMessage("WSACreateEvent() failed");
			ExitThread(1);
		}
		Index = WSAWaitForMultipleEvents(1, EventArray, FALSE, 2000, TRUE);

		if (Index == WSA_WAIT_TIMEOUT)
		{
			formatMessage("Timeout in UDP Server");
			exitThread = true;
			return;
		}
		receiveUDP(SI, serverUDP, BytesTransferred, Flags);
	}
	if (protocol == TCP)
		receiveTCP(SI, RecvBytes, Flags);

	//Gather data
	logCommStats(SI, fileInfo, BytesTransferred);
	fwrite(SI->DataBuf.buf, sizeof(char), SI->DataBuf.len, serverFP);

}
Ejemplo n.º 2
0
/*-------------------------------------------------------------------------------------------------------------------------------------

FUNCTION:		UDPWorkerThread

INTERFACE:		DWORD WINAPI UDPWorkerThread(LPVOID lpParameter)

RETURNS:		DWORD

NOTES:			Waits on the socket until there is data receieved. Once data is deteceted on the socket, the completion routine
				is called to handle the I/O on the socket.

--------------------------------------------------------------------------------------------------------------------------------------*/
DWORD WINAPI UDPWorkerThread(LPVOID lpParameter)
{

	DWORD					Flags = 0;
	LPSOCKET_INFORMATION	SocketInfo;
	WSAEVENT				EventArray[1];
	DWORD					Index;
	DWORD					RecvBytes = 0;
	WSAEVENT				UDPEvent;

	// Create a socket information structure to associate with the accepted socket.
	if ((SocketInfo = (LPSOCKET_INFORMATION)GlobalAlloc(GPTR, sizeof(SOCKET_INFORMATION))) == NULL)
	{
		formatMessage("GlobalAlloc() failed");
		return FALSE;
	}
	if ((UDPEvent = WSACreateEvent()) == WSA_INVALID_EVENT)
	{
		formatMessage("WSACreateEvent() failed");
		ExitThread(1);
	}

	// Save the accept event in the event array.
	EventArray[0] = UDPEvent;

	// Fill in the details of our accepted socket.
	SocketInfo->Socket = sd;
	initSockInfo(SocketInfo, SocketInfo->Buffer, DATA_BUFSIZE);

	receiveUDP(SocketInfo, serverUDP, RecvBytes, Flags);

	while (TRUE)
	{
		Index = WSAWaitForMultipleEvents(1, EventArray, FALSE, WSA_INFINITE, TRUE);

		if (Index == WSA_WAIT_FAILED)
		{
			formatMessage("WSAWaitForMultipleEvents failed");
			return FALSE;
		}
		if (Index != WAIT_IO_COMPLETION)
		{
			// An accept() call event is ready - break the wait loop
			//break;
		}
		if (Index == WAIT_IO_COMPLETION && exitThread == true)
		{
			formatMessage("Server Terminating");
			exitThread = false;
			closesocket(SocketInfo->Socket);
			logDataFile(fileInfo);
			free(fileInfo);
			fclose(serverFP);
			WSACleanup();
			return TRUE;
		}
	}	
}
Ejemplo n.º 3
0
/*-------------------------------------------------------------------------------------------------------------------------------------

	FUNCTION:		sendControlUDP

	INTERFACE:		void sendControlUDP(LPSOCKET_INFORMATION SI, struct	sockaddr_in server, char* message, int sizeOfPackets)

	RETURNS:		void

	NOTES:			Sends the control information to a UDP socket

--------------------------------------------------------------------------------------------------------------------------------------*/
void sendControlUDP(LPSOCKET_INFORMATION SI, struct	sockaddr_in server, char* message, int sizeOfPackets)
{
	initSockInfo(SI, message, strlen(message));

	//Send control data
	if (WSASendTo(SI->Socket, &(SI->DataBuf), 1, &SI->BytesSEND, 0, (struct sockaddr *)&server, sizeof(server), &(SI->Overlapped), NULL) == SOCKET_ERROR)
	{
		if (WSAGetLastError() != ERROR_IO_PENDING)
		{
			formatMessage("Sending control information failed");
			ExitThread(1);
		}
	}
	formatMessage("Sending Control Data to Server");
}
Ejemplo n.º 4
0
void WebSocket::send(char *message, size_t length, OpCode opCode, void (*callback)(WebSocket webSocket, void *data, bool cancelled), void *callbackData, size_t fakedLength)
{
    size_t reportedLength = length;
    if (fakedLength) {
        reportedLength = fakedLength;
    }

    if (length <= Server::SHORT_BUFFER_SIZE - 10) {
        SocketData *socketData = (SocketData *) p->data;
        char *sendBuffer = socketData->server->sendBuffer;
        write(sendBuffer, formatMessage(sendBuffer, message, length, opCode, reportedLength), false, callback, callbackData);
    } else {
        char *buffer = new char[sizeof(SocketData::Queue::Message) + length + 10] + sizeof(SocketData::Queue::Message);
        write(buffer, formatMessage(buffer, message, length, opCode, reportedLength), true, callback, callbackData);
    }
}
Ejemplo n.º 5
0
void SyncController::iterationFinished(const SyncState &ss)
{
    ++iterationsCount;

    if(iterationsCount<=iterationsToSend)
        return;

    iterationsCount = 1;

    QByteArray answer;
    answer = "Intermediate states "+ss.name.toUtf8()
            +" checked:"+QByteArray::number(ss.num)
            +" inserts:"+QByteArray::number(ss.numIns)
            +" insfail:"+QByteArray::number(ss.numInsFail)
            +" deletes:"+QByteArray::number(ss.numDel)
            +" delfail:"+QByteArray::number(ss.numDelFail)
            +" updates:"+QByteArray::number(ss.numUpd)
            +" updfail:"+QByteArray::number(ss.numUpdFail);

    if(saveLog)
    {
        log->write("\n"+answer);
        log->flush();
    }

    output.write(formatMessage(answer));
    output.flush();

}
Ejemplo n.º 6
0
		BdbBtreeWrapper(const BenchmarkOptions& benchmarkOptions, size_type instanceNumber)
		{
			const int openFlags = (benchmarkOptions.createNew_) ? (O_RDWR | O_CREAT | O_TRUNC) : (O_RDWR);
			BTREEINFO btreeInfo = {
				0,					// u_long	flags;
				0,					// u_int	cachesize;	/* bytes to cache */
				0,					// int		maxkeypage;	/* maximum keys per page */
				0,					// int		minkeypage;	/* minimum keys per page */
				0,					// u_int	psize;		/* page size */
				NULL,				// int		(*compare)	/* comparison function */
				//			__P((const DBT *, const DBT *));
				NULL,				// size_t	(*prefix)	/* prefix function */
				//			__P((const DBT *, const DBT *));
				0					// int	lorder;		/* byte order */
			};

			if (benchmarkOptions.pageSize_ != BenchmarkOptions::SIZE_VALUE_NOT_SET) {
				btreeInfo.psize = static_cast<u_int>(benchmarkOptions.pageSize_);
			}

			if (benchmarkOptions.cacheSize_ != BenchmarkOptions::SIZE_VALUE_NOT_SET) {
				btreeInfo.cachesize = static_cast<u_int>(benchmarkOptions.cacheSize_);
			}

			std::string databaseName = benchmarkOptions.databaseName_;
			if (instanceNumber != 0) {
				databaseName += formatMessage("_%u", instanceNumber);
			}

			db_ = dbopen(databaseName.c_str(), openFlags, 0644, DB_BTREE, &btreeInfo);
			if (db_ == NULL) {
				RAISE_BENCHMARK_EXCEPTION("unable to open \"%s\" with open flags=0x%08x: error=%u (try to use --new)", benchmarkOptions.databaseName_, openFlags, errno);
			}
		}
Ejemplo n.º 7
0
QString IrcMessageFormatter::formatMessage(IrcMessage* message)
{
    QString formatted;
    switch (message->type()) {
        case IrcMessage::Join:
            formatted = formatJoinMessage(static_cast<IrcJoinMessage*>(message));
            break;
        case IrcMessage::Mode:
            formatted = formatModeMessage(static_cast<IrcModeMessage*>(message));
            break;
        case IrcMessage::Names:
            formatted = formatNamesMessage(static_cast<IrcNamesMessage*>(message));
            break;
        case IrcMessage::Nick:
            formatted = formatNickMessage(static_cast<IrcNickMessage*>(message));
            break;
        case IrcMessage::Part:
            formatted = formatPartMessage(static_cast<IrcPartMessage*>(message));
            break;
        case IrcMessage::Private:
            formatted = formatPrivateMessage(static_cast<IrcPrivateMessage*>(message));
            break;
        case IrcMessage::Quit:
            formatted = formatQuitMessage(static_cast<IrcQuitMessage*>(message));
            break;
        default:
            break;
    }
    return formatMessage(formatted);
}
Ejemplo n.º 8
0
Archivo: submit.c Proyecto: juddy/edcde
int
submit_mail(const char * to,
	    const char * subject,
	    const char * body)
{
    char ** 	addrs;
    char **	ad;
    char *	msg;
    int		status;

    /* 
      Parse the address list so we can form a reasonable one
      for the user to see in the message.
      */
    addrs = arpaPhrase(to);

    msg = formatMessage(addrs, subject, body);

    status = deliver(addrs, msg);

    for (ad = addrs; *ad; ad++) {
	free(*ad);
    }
    free(addrs);

    free(msg);

    return(status);
}
Ejemplo n.º 9
0
void* ADM_LibWrapper::getSymbol(const char* name)
{
#ifdef __MINGW32__
    void* procAddr = (void*)GetProcAddress((HINSTANCE) hinstLib, name);

    if (procAddr == NULL)
    {
        char* lpMsg = formatMessage(GetLastError());

        printf("Unable to find symbol [%s]: %s\n", name, lpMsg);
        LocalFree(lpMsg);
    }

    return procAddr;
#else
    void* procAddr = dlsym(hinstLib, name);

    if (procAddr == NULL)
    {
        printf("Unable to find symbol [%s]: %s\n", name, dlerror());
    }

    return procAddr;
#endif
}
Ejemplo n.º 10
0
//
// FatalError::Reporter
//
void FatalError::Reporter::onFatalError (
    char const* message, char const* stackBacktrace, char const* filePath, int lineNumber)
{
    String formattedMessage = formatMessage (
        message, stackBacktrace, filePath, lineNumber);

    reportMessage (formattedMessage);
}
Ejemplo n.º 11
0
static QString getMessage(const QObject * const object)
{
	const MessageRenderInfo * const messageRenderInfo = qobject_cast<const MessageRenderInfo * const>(object);
	if (messageRenderInfo)
		return formatMessage(messageRenderInfo->htmlMessageContent());
	else
		return QString();
}
Ejemplo n.º 12
0
/*-------------------------------------------------------------------------------------------------------------------------------------

	FUNCTION:		sendDataTCP

	INTERFACE:		void sendDataTCP(LPSOCKET_INFORMATION SI, char* message, int sizeOfPackets, int numberOfPackets)

	RETURNS:		void

	NOTES:			Sends the data information to a TCP socket

--------------------------------------------------------------------------------------------------------------------------------------*/
void sendDataTCP(LPSOCKET_INFORMATION SI, char* message, int sizeOfPackets, int numberOfPackets)
{
	initSockInfo(SI, message, sizeOfPackets);

	for (int i = 0; i < numberOfPackets; i++)
	{
		if (WSASend(SI->Socket, &(SI->DataBuf), 1, &SI->BytesSEND, 0, &(SI->Overlapped), NULL) == SOCKET_ERROR)
		{
			if (WSAGetLastError() != ERROR_IO_PENDING)
			{
				formatMessage("Sending TCP data information failed");
				ExitThread(1);
			}
		}
		formatMessage("Sending Data to Server");
	}
}
Ejemplo n.º 13
0
string GetLastErrorString(DWORD errcode)
{
	string message = formatMessage(errcode);

	if (message.empty())
		return "GetLastError()=" + to_string(errcode) + " but no info from FormatMessage()";
	else
		return message;
}
Ejemplo n.º 14
0
void Exception::formatEntry(std::ostream &stream, size_t depth) const {
	LocaleUtils::CLocaleScope localeScope(stream);

	if (depth > maxDepth_) {
		return;
	}

	if (hasTypeName(depth)) {
		formatTypeName(stream, depth);
	}
	else {
		stream << "(Unknown exception)";
	}

	if (hasFileName(depth)) {
		stream << " ";
		formatFileName(stream, depth);
	}

	if (hasFunctionName(depth)) {
		stream << " ";
		formatFunctionName(stream, depth);
	}

	if (hasLineNumber(depth)) {
		stream << " line=" << getLineNumber(depth);
	}

	if (hasErrorCode(depth)) {
		stream << " [";

		if (!hasErrorCodeName(depth)) {
			stream << "Code:";
		}

		stream << getErrorCode(depth);

		if (hasErrorCodeName(depth)) {
			stream << ":";
			formatErrorCodeName(stream, depth);
		}

		stream << "]";
	}

	if (hasMessage(depth)) {
		stream << " " ;
		formatMessage(stream, depth);
	}
#ifdef UTIL_STACK_TRACE_ENABLED

	if (hasStackTrace(depth)) {
		stream << " : " ;
		formatStackTrace(stream, depth);
	}
#endif
}
Ejemplo n.º 15
0
void termination_handler (int signum)
/*--------------------------------------------
 * pulizia prima di uscire
 * libera la memoria condivisa
 * -----------------------------------------*/
{
	int i;
	int status;
	char writeBuffer[MSGLENGTH];
	int temp;
	

	if(getpid()==messagesPid)
	{
		formatMessage(writeBuffer,0,0,0,0,"SYSTEM STOPPING");
		write(logFileFd,writeBuffer,strlen(writeBuffer));
		close(logFileFd);
	}
	if(getpid()==mypid)		//sono il padre
	{
		my_printf("signal %d to %d\n",signum,getpid());
//		my_printf("ho ricevuto %d\n",signum);
		if(signum==SIGSEGV)
			my_printf("non bene, ho ricevuto sigsegv\n");

		killAllSystems();

		my_printf("freeing ai system nodes\n");
		free_system_nodes();

		msgctl(msg_alarm_id, IPC_RMID, 0);
		
		temp=NUMPANELS;
		NUMPANELS=0;
		for(i=0;i<temp;i++)
			free(panels[i]);
		if(panels)
			free(panels);
		panels=NULL;

		freeshm();

		my_printf("Fine\n");
		exit(0);
	}
	else
	{
		if(getpid()==serverPid)
		{
			for(i=0;i<MAXCONNECTIONS;i++)
				if(serverPids[i]>0)
					killPid(serverPids[i]);
//			exit(1);
		}
	}
}
Ejemplo n.º 16
0
QString Newswire::formatMessages(const QString& format/* = ""*/)
{
    QString useFormat = format;
    if(useFormat.isEmpty()) useFormat = mFormat.value(eErrFunc);

    QString msgs;
    foreach(const Message& msg, mMessages)
    {
        msgs.append(formatMessage(msg, useFormat) + "\n");
    }
Ejemplo n.º 17
0
QString MessageFormatter::formatMessage(IrcMessage* message, UserModel* userModel) const
{
    QString formatted;
    d.highlight = false;
    d.userModel = userModel;
    switch (message->type())
    {
    case IrcMessage::Invite:
        formatted = formatInviteMessage(static_cast<IrcInviteMessage*>(message));
        break;
    case IrcMessage::Join:
        if (message->isOwn())
            d.receivedCodes.clear();
        formatted = formatJoinMessage(static_cast<IrcJoinMessage*>(message));
        break;
    case IrcMessage::Kick:
        formatted = formatKickMessage(static_cast<IrcKickMessage*>(message));
        break;
    case IrcMessage::Mode:
        formatted = formatModeMessage(static_cast<IrcModeMessage*>(message));
        break;
    case IrcMessage::Nick:
        formatted = formatNickMessage(static_cast<IrcNickMessage*>(message));
        break;
    case IrcMessage::Notice:
        formatted = formatNoticeMessage(static_cast<IrcNoticeMessage*>(message));
        break;
    case IrcMessage::Numeric:
        formatted = formatNumericMessage(static_cast<IrcNumericMessage*>(message));
        break;
    case IrcMessage::Part:
        formatted = formatPartMessage(static_cast<IrcPartMessage*>(message));
        break;
    case IrcMessage::Pong:
        formatted = formatPongMessage(static_cast<IrcPongMessage*>(message));
        break;
    case IrcMessage::Private:
        formatted = formatPrivateMessage(static_cast<IrcPrivateMessage*>(message));
        break;
    case IrcMessage::Quit:
        formatted = formatQuitMessage(static_cast<IrcQuitMessage*>(message));
        break;
    case IrcMessage::Topic:
        formatted = formatTopicMessage(static_cast<IrcTopicMessage*>(message));
        break;
    case IrcMessage::Unknown:
        formatted = formatUnknownMessage(static_cast<IrcMessage*>(message));
        break;
    default:
        break;
    }

    return formatMessage(formatted);
}
Ejemplo n.º 18
0
            virtual void execute (Runtime& runtime)
            {
                // message
                int index = runtime[0].mInteger;
                runtime.pop();
                std::string message = runtime.getStringLiteral (index);

                // handle additional parameters
                std::string formattedMessage = formatMessage (message, runtime);

                runtime.getContext().report (formattedMessage);
            }
Ejemplo n.º 19
0
void CtrlrLog::handleAsyncUpdate()
{
	for (int i=0; i<pendingQueue.size(); i++)
	{
		if (pendingQueue[i].level == Error)
		{
			WARN(formatMessage(pendingQueue[i], true, true));
		}
		listeners.call (&CtrlrLog::Listener::messageLogged, pendingQueue[i]);
	}
	pendingQueue.clear();
}
Ejemplo n.º 20
0
/*------------------------------------------------------------------------------------------------------------------
-- FUNCTION: sendDataTCP
-- DATE:	14/04/16
-- REVISIONS:	(V1.0)
-- DESIGNER:	Martin Minkov
-- PROGRAMMER:  Martin Minkov
-- INTERFACE:	void sendDataTCP(SOCKET sd, const char* message)
--
--
-- RETURNS: VOID
-- NOTES: Sends the passed in message through the TCP socket.
----------------------------------------------------------------------------------------------------------------------*/
void sendDataTCP(SOCKET sd, const char* message)
{
    int check;
    if((check = send(sd, message, PACKET_LEN, 0)) == SOCKET_ERROR)
    {
       if (WSAGetLastError())
        {
            formatMessage("Sending TCP data information failed");
            return;
        }
    }
}
Ejemplo n.º 21
0
void SimpleLogger::logMessage(internal::LogLevel::Level level, const std::string& message, const internal::LogContext& context) {
  LogChannel& channel = useChannel(level);

  if (!channel.enabled()) {
    return;
  }

  std::ostringstream buf;
  formatMessage(buf, channel.getLevel(), message, context);

  channel.writeLine(buf.str());
}
Ejemplo n.º 22
0
void CtrlrLog::logMessage (const String &message, const LogLevel level)
{
	Logger::outputDebugString (message);

	CtrlrLogMessage m;
	m.level		= level;
	m.message	= message.trim();
	m.time		= Time::getCurrentTime();

	if (fileLogger)
	{
		fileLogger->logMessage(formatMessage(m).trim());
	}

	pendingQueue.add (m);
	triggerAsyncUpdate();
}
Ejemplo n.º 23
0
void PreferencesDialog::updatePreferencesWidget(const QModelIndex &pNewIndex,
                                                const QModelIndex &pOldIndex)
{
    Q_UNUSED(pOldIndex)

    // Check whether we are dealing with a plugin category

    QStandardItem *item = mModel->itemFromIndex(pNewIndex);
    bool isPluginCategory = mCategoryItems.values().contains(item);

    mResetButton->setEnabled(!isPluginCategory);

    if (isPluginCategory) {
        // We are dealing with a plugin category, so retrieve and set its name
        // and description

        mPluginCategoryWidget->setCategory(item->text());
        mPluginCategoryWidget->setDescription(tr("%1.").arg(formatMessage(pluginCategoryDescription(mItemCategories.value(item)))));

        mGui->stackedWidget->setCurrentWidget(mPluginCategoryWidget);
    } else {
        // We are dealing with our general or a plugin's preferences, so show
        // them

        mGui->stackedWidget->setCurrentWidget(mItemPreferencesWidgets.value(item));
    }

    // Make sure that the current widget has no layout margin (so that not only
    // we don't waste space, but also developers don't have to worry about the
    // layout margin of their preferences widget, assuming it has a layout)

    QLayout *widgetLayout = mGui->stackedWidget->currentWidget()->layout();

    if (widgetLayout != nullptr) {
        widgetLayout->setContentsMargins(QMargins());
    }

    // Make sure that we are big enough to show our contents

    adjustWidgetSize(this);
}
Ejemplo n.º 24
0
		BdbHashWrapper(const BenchmarkOptions& benchmarkOptions, size_type instanceNumber)
		{
			const int openFlags = (benchmarkOptions.createNew_) ? (O_RDWR | O_CREAT | O_TRUNC) : (O_RDWR);
			HASHINFO hashInfo = {
				0,					// u_int	bsize;		/* bucket size */ // default = 4K, Kerio default = 1K
				0,					// u_int	ffactor;	/* fill factor */ // 65536 = dynamic, 64 = 4K/avg size
				1,					// u_int	nelem;		/* number of elements */
				0,					// u_int	cachesize;	/* bytes to cache */
				NULL,				// u_int32_t		/* hash function */
									//		(*hash) __P((const void *, size_t));
				0					// int	lorder;		/* byte order */
			};


			if (benchmarkOptions.pageSize_ != BenchmarkOptions::SIZE_VALUE_NOT_SET) {
				hashInfo.bsize = static_cast<u_int>(benchmarkOptions.pageSize_);
			}

			if (benchmarkOptions.cacheSize_ != BenchmarkOptions::SIZE_VALUE_NOT_SET) {
				hashInfo.cachesize = static_cast<u_int>(benchmarkOptions.cacheSize_);
			}

			if (benchmarkOptions.initialBuckets_ != BenchmarkOptions::SIZE_VALUE_NOT_SET) {
				hashInfo.nelem = benchmarkOptions.initialBuckets_;
			}

			if (benchmarkOptions.bdbHashFfactor_ != BenchmarkOptions::SIZE_VALUE_NOT_SET) {
				hashInfo.ffactor = static_cast<u_int>(benchmarkOptions.bdbHashFfactor_);
			}

			std::string databaseName = benchmarkOptions.databaseName_;
			if (instanceNumber != 0) {
				databaseName += formatMessage("_%u", instanceNumber);
			}

			db_ = dbopen(databaseName.c_str(), openFlags, 0644, DB_HASH, &hashInfo);
			if (db_ == NULL) {
				RAISE_BENCHMARK_EXCEPTION("unable to open \"%s\" with open flags=0x%08x: error=%u (try to use --new)", benchmarkOptions.databaseName_, openFlags, errno);
			}
		}
Ejemplo n.º 25
0
void Exception::formatField(
		std::ostream &stream, FieldType fieldType, size_t depth) const {

	switch (fieldType) {
	case FIELD_ERROR_CODE:
		{
			LocaleUtils::CLocaleScope localeScope(stream);
			stream << getErrorCode(depth);
		}
		break;
	case FIELD_ERROR_CODE_NAME:
		formatErrorCodeName(stream, depth);
		break;
	case FIELD_MESSAGE:
		formatMessage(stream, depth);
		break;
	case FIELD_FILE_NAME:
		formatFileName(stream, depth);
		break;
	case FIELD_FUNCTION_NAME:
		formatFunctionName(stream, depth);
		break;
	case FIELD_LINE_NUMBER:
		{
			LocaleUtils::CLocaleScope localeScope(stream);
			stream << getLineNumber(depth);
		}
		break;
	case FIELD_STACK_TRACE:
		formatStackTrace(stream, depth);
		break;
	case FIELD_TYPE_NAME:
		formatTypeName(stream, depth);
		break;
	default:
		assert(false);
		break;
	}
}
Ejemplo n.º 26
0
bool ADM_LibWrapper::loadLibrary(const char* path)
{
#ifdef __MINGW32__
    hinstLib = LoadLibrary(path);

    if (hinstLib == NULL)
    {
        char* lpMsg = formatMessage(GetLastError());

        printf("Unable to load [%s]: %s\n", path, lpMsg);
        LocalFree(lpMsg);

        return false;
    }
    else
    {
        printf("Loaded library %s, handle = 0x%08x\n", path, hinstLib);

        return true;
    }
#else
    hinstLib = dlopen(path, RTLD_NOW);

    if (hinstLib == NULL)
    {
        printf("Unable to load [%s]: %s\n", path, dlerror());

        return false;
    }
    else
    {
        printf("Loaded library %s, handle = 0x%08x\n", path, hinstLib);

        return true;
    }
#endif
}
Ejemplo n.º 27
0
            virtual void execute (Runtime& runtime, unsigned int arg0)
            {
                // message
                int index = runtime[0].mInteger;
                runtime.pop();
                std::string message = runtime.getStringLiteral (index);

                // buttons
                std::vector<std::string> buttons;

                for (std::size_t i=0; i<arg0; ++i)
                {
                    int index = runtime[0].mInteger;
                    runtime.pop();
                    buttons.push_back (runtime.getStringLiteral (index));
                }

                std::reverse (buttons.begin(), buttons.end());

                // handle additional parameters
                std::string formattedMessage = formatMessage (message, runtime);

                runtime.getContext().messageBox (formattedMessage, buttons);
            }
Ejemplo n.º 28
0
BEGIN_NAMESPACE_MW


OpenGLException::OpenGLException(const std::string &message, GLenum error) :
    SimpleException(M_DISPLAY_MESSAGE_DOMAIN, "OpenGL", formatMessage(message, error))
{ }
Ejemplo n.º 29
0
string GetNTStatusString(DWORD nt_status)
{
	return formatMessage(nt_status, FORMAT_MESSAGE_FROM_HMODULE, Module::ntdll().handle());
}
void ChatManagerImplementation::handleChatRoomMessage(CreatureObject* sender, const UnicodeString& message, unsigned int roomID, unsigned int counter) {
	String name = sender->getFirstName();
	String fullName = "";

	if (sender->isPlayerCreature()) {
		ManagedReference<PlayerObject*> senderGhost = sender->getPlayerObject();

		if (senderGhost == NULL)
			return;

		if (senderGhost->isMuted()) {
			String reason = senderGhost->getMutedReason();

			if (reason != "")
				sender->sendSystemMessage("Your chat abilities are currently disabled by Customer Support for '" + reason + "'.");
			else
				sender->sendSystemMessage("Your chat abilities are currently disabled by Customer Support.");

			return;
		}

		fullName = getTaggedName(senderGhost, name);
	}

	ChatRoom* channel = getChatRoom(roomID);

	if (channel == NULL)
		return;

	if (!channel->hasPlayer(sender))
		return;

	Zone* zone = sender->getZone();
	if( zone == NULL ){
		return;
	}

	UnicodeString formattedMessage(formatMessage(message));

	ManagedReference<ChatRoom*> planetRoom = zone->getChatRoom();

	BaseMessage* msg = new ChatRoomMessage(fullName, formattedMessage, roomID);

	// Auction Chat, General Chat, and Planet Chat should adhere to player ignore list
	if( auctionRoom != NULL && auctionRoom->getRoomID() == roomID ) {
		channel->broadcastMessageCheckIgnore(msg, name);
	} else if (generalRoom != NULL && generalRoom->getRoomID() == roomID) {
		channel->broadcastMessageCheckIgnore(msg, name);
	} else if( planetRoom != NULL && planetRoom->getRoomID() == roomID ) {
		channel->broadcastMessageCheckIgnore(msg, name);
	} else {
		channel->broadcastMessage(msg);
	}

	BaseMessage* amsg = new ChatOnSendRoomMessage(counter);
	channel->broadcastMessage(amsg);

	/*Vector<Message*> messages;
	messages.add(msg);
	messages.add(amsg);

	channel->broadcastMessage(messages);*/
}