static void dieLastError (int statusPipe, const char* message)
{
	char	msgBuf[256];
	int		lastErr	= errno;
	deSprintf(msgBuf, sizeof(msgBuf), "%s, error %d: %s", message, lastErr, strerror(lastErr));
	die(statusPipe, msgBuf);
}
static deBool deProcess_setErrorFromErrno (deProcess* process, const char* message)
{
	char	msgBuf[256];
	int		lastErr		= errno;
	deSprintf(msgBuf, sizeof(msgBuf), "%s, error %d: %s", message, lastErr, strerror(lastErr));
	return deProcess_setError(process, message);
}
static deBool deProcess_setErrorFromWin32 (deProcess* process, const char* msg)
{
	DWORD		error	= GetLastError();
	LPSTR		msgBuf;
	char		errBuf[256];

#if defined(UNICODE)
#	error Unicode not supported.
#endif

	if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
					  NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&msgBuf, 0, DE_NULL) > 0)
	{
		deSprintf(errBuf, sizeof(errBuf), "%s, error %d: %s", msg, error, msgBuf);
		LocalFree(msgBuf);
		return deProcess_setError(process, errBuf);
	}
	else
	{
		/* Failed to get error str. */
		deSprintf(errBuf, sizeof(errBuf), "%s, error %d", msg, error);
		return deProcess_setError(process, errBuf);
	}
}
Exemple #4
0
DE_INLINE void doubleToString (double value, char* buf, size_t bufSize)
{
	deSprintf(buf, bufSize, "%f", value);
}
Exemple #5
0
DE_INLINE void floatToString (float value, char* buf, size_t bufSize)
{
	deSprintf(buf, bufSize, "%f", value);
}
Exemple #6
0
DE_INLINE void int64ToString (deInt64 val, char buf[32])
{
	deSprintf(&buf[0], 32, "%lld", (long long int)val);
}
Exemple #7
0
DE_INLINE void int32ToString (int val, char buf[32])
{
	deSprintf(&buf[0], 32, "%d", val);
}
static void NamedSemaphore_getName (const NamedSemaphore* sem, char* buf, int bufSize)
{
	deSprintf(buf, bufSize, "/desem-%d-%p", getpid(), (void*)sem);
}