コード例 #1
0
ファイル: vid_dll.c プロジェクト: jitspoe/starviewer
void VID_Printf (int print_level, char *fmt, ...)
{
	va_list		argptr;
	char		msg[MAXPRINTMSG];
	static qboolean	inupdate;
	
	va_start(argptr, fmt);
	_vsnprintf(msg, sizeof(msg), fmt, argptr); // jitsecurity -- prevent buffer overruns
	va_end(argptr);
	NULLTERMINATE(msg); // jitsecurity -- make sure string is null terminated.

	if (print_level == PRINT_ALL)
	{
		Com_Printf("%s", msg);
	}
	else if (print_level == PRINT_DEVELOPER)
	{
		Com_DPrintf("%s", msg);
	}
	else if (print_level == PRINT_ALERT)
	{
		MessageBox(0, msg, "PRINT_ALERT", MB_ICONWARNING);
		OutputDebugString(msg);
	}
}
コード例 #2
0
ファイル: common.c プロジェクト: jitspoe/starviewer
/*
=============
Com_Printf

Both client and server can use this, and it will output
to the apropriate place.
=============
*/
void Com_Printf (char *fmt, ...)
{
	va_list		argptr;
	char		msg[MAXPRINTMSG];
	static qboolean printstamp = true; // jittimestamp

	va_start(argptr, fmt);
	_vsnprintf(msg, sizeof(msg), fmt, argptr); // jitsecurity -- prevent buffer overruns
	va_end(argptr);
	NULLTERMINATE(msg); // jitsecurity -- make sure string is null terminated.

	if (rd_target)
	{
		if ((strlen(msg) + strlen(rd_buffer)) > (rd_buffersize - 1))
		{
			rd_flush(rd_target, rd_buffer);
			*rd_buffer = 0;
		}

		strcat(rd_buffer, msg);
		return;
	}

	Con_Print(msg);

	// ===
	// jittimestamp
	if (printstamp && timestamp_console && timestamp_console->value)
	{	// don't tag timestamps on if it's not a new line
		time_t now;
		char timestamp[256];
		struct tm *nowtime;
		static int lastday = -1;

		time(&now);
		nowtime = localtime(&now);
		
		if (nowtime->tm_mday != lastday)
		{
			Com_sprintf(timestamp, sizeof(timestamp), "[********] Date: %04d-%02d-%02d\n",
				nowtime->tm_year + 1900, nowtime->tm_mon + 1, nowtime->tm_mday);
			Sys_ConsoleOutput(timestamp);
			ConsoleLogfile(timestamp);
			lastday = nowtime->tm_mday;
		}

		strftime(timestamp, sizeof(timestamp), "[%H:%M:%S] ", nowtime);
		Sys_ConsoleOutput(timestamp);
		ConsoleLogfile(timestamp);
	}
	
	Sys_ConsoleOutput(msg);
	printstamp = (strchr(msg, '\n') != NULL); // so we only print timestamps after a newline.
	ConsoleLogfile(msg);
	// jittimestamp
	// ===
}
コード例 #3
0
ファイル: common.c プロジェクト: jitspoe/starviewer
/*
================
Com_DPrintf

A Com_Printf that only shows up if the "developer" cvar is set
================
*/
void Com_DPrintf (char *fmt, ...)
{
	va_list		argptr;
	char		msg[MAXPRINTMSG];

	if (!developer || !developer->value)
		return;			// don't confuse non-developers with techie stuff...

	va_start(argptr,fmt);
	_vsnprintf(msg, sizeof(msg), fmt, argptr); // jitsecurity -- prevent buffer overruns
	va_end(argptr);
	NULLTERMINATE(msg); // jitsecurity -- make sure string is null terminated.
	Com_Printf("%s", msg);
}
コード例 #4
0
ファイル: common.c プロジェクト: jitspoe/starviewer
/*
=============
Com_Error

Both client and server can use this, and it will
do the apropriate things.
=============
*/
void Com_Error (int code, char *fmt, ...)
{
	va_list argptr;
	static char msg[MAXPRINTMSG];
	static qboolean recursive;

//	assert(Q_streq(fmt, "Disconnected from server")); // jitdebug

	if (recursive)
		Sys_Error("Recursive error after: %s", msg);

	recursive = true;
	va_start(argptr,fmt);
	_vsnprintf(msg, sizeof(msg), fmt, argptr); // jitsecurity -- prevent buffer overruns
	va_end(argptr);
	NULLTERMINATE(msg); // jitsecurity -- make sure string is null terminated.

	switch (code) // jiterror
	{
	case ERR_BENIGN: // jiterror - don't close the app.  Just print the error to the console.
		Com_Printf("*** ERROR: %s\n", msg);
		recursive = false;
		return;
	case ERR_DISCONNECT:
		CL_Drop();
		recursive = false;
		longjmp(abortframe, -1);
		break;
	case ERR_DROP:
		Com_Printf("********************\nERROR: %s\n********************\n", msg);
		SV_Shutdown(va("Server crashed: %s\n", msg), false);
		CL_Drop();
		recursive = false;
		longjmp(abortframe, -1);
		break;
	case ERR_FATAL:
	default:
		SV_Shutdown(va("Server fatal crashed: %s\n", msg), false);
		CL_Shutdown();
	}

	if (logfile)
	{
		fclose(logfile);
		logfile = NULL;
	}

	Sys_Error("%s", msg);
}
コード例 #5
0
ファイル: vfp2cmarshal.c プロジェクト: akrisiun/VfpProj
void _fastcall AMemBlocks(ParamBlk *parm)
{
	char *pArrayName;
	Locator lArrayLoc;
	int nErrorNo;
	PROCESS_HEAP_ENTRY pEntry;
	INTEGER(vAddress);
	INTEGER(vSize);
	INTEGER(vOverhead);
	DWORD nLastError;

	if (!fpHeapWalk)
		RAISEERROR(E_NOENTRYPOINT);

	if (!NULLTERMINATE(p1))
		RAISEERROR(E_INSUFMEMORY);

	LOCKHAND(p1);	
	pArrayName = HANDTOPTR(p1);

	if (nErrorNo = DimensionEx(pArrayName,&lArrayLoc,1,3))
		goto ErrorOut;

	pEntry.lpData = NULL;

	if (!fpHeapWalk(ghHeap,&pEntry))
	{
		nLastError = GetLastError();
		UNLOCKHAND(p1);
		if (nLastError == ERROR_NO_MORE_ITEMS)
		{
			RET_INTEGER(0);
			return;
		}
		else
		{
			SAVEWIN32ERROR(HeapWalk,nLastError);
			RET_INTEGER(-1);
		}
	}

	do 
	{
		AROW(lArrayLoc)++;

		if ((nErrorNo = Dimension(pArrayName,AROW(lArrayLoc),3)))
			break;

		ADIM(lArrayLoc) = 1;
		vAddress.ev_long = (long)pEntry.lpData;
		if (nErrorNo = STORE(lArrayLoc,vAddress))
			break;

		ADIM(lArrayLoc) = 2;
		vSize.ev_long = pEntry.cbData;
		if (nErrorNo = STORE(lArrayLoc,vSize))
			break;

		ADIM(lArrayLoc) = 3;
		vOverhead.ev_long = pEntry.cbOverhead;
		if (nErrorNo = STORE(lArrayLoc,vOverhead))
			break;

	} while (fpHeapWalk(ghHeap,&pEntry));
	
	nLastError = GetLastError();

	if (nErrorNo)
		goto ErrorOut;

	UNLOCKHAND(p1);

    if (nLastError == ERROR_NO_MORE_ITEMS)
	{
		RET_AROWS(lArrayLoc);
		return;
	}
	else
	{
		SAVEWIN32ERROR(HeapWalk,nLastError);
		RET_INTEGER(-1);
		return;
	}

	ErrorOut:
		UNLOCKHAND(p1);
		RAISEERROR(nErrorNo);
}
コード例 #6
0
ファイル: vfp2cmarshal.c プロジェクト: akrisiun/VfpProj
void _fastcall AMemLeaks(ParamBlk *parm)
{
	char *pArrayName;
	Locator lArrayLoc;
	int nErrorNo;
	INTEGER(vMem);
	STRING(vMemInfo);
	char *pMemInfo;
	LPDBGALLOCINFO pDbg = gpDbgInfo;

	if (!pDbg)
	{
		RET_INTEGER(0);
		return;
	}

	if (!NULLTERMINATE(p1))
		RAISEERROR(E_INSUFMEMORY);

	LOCKHAND(p1);	
	pArrayName = HANDTOPTR(p1);

	if (!ALLOCHAND(vMemInfo,VFP2C_ERROR_MESSAGE_LEN))
	{
		nErrorNo = E_INSUFMEMORY;
		goto ErrorOut;
	}
	LOCKHAND(vMemInfo);
	pMemInfo = HANDTOPTR(vMemInfo);

	if (nErrorNo = DimensionEx(pArrayName,&lArrayLoc,1,4))
		goto ErrorOut;

	while (pDbg)
	{
		if (nErrorNo = Dimension(pArrayName,++AROW(lArrayLoc),4))
			goto ErrorOut;

		vMem.ev_long = (int)pDbg->pPointer;
		ADIM(lArrayLoc) = 1;
		if (nErrorNo = STORE(lArrayLoc,vMem))
			goto ErrorOut;

		vMem.ev_long = pDbg->nSize;
        ADIM(lArrayLoc) = 2;
		if (nErrorNo = STORE(lArrayLoc,vMem))
			goto ErrorOut;

		if (pDbg->pProgInfo)
			vMemInfo.ev_length = strncpyex(pMemInfo,pDbg->pProgInfo,VFP2C_ERROR_MESSAGE_LEN);
		else
			vMemInfo.ev_length = 0;
		ADIM(lArrayLoc) = 3;
		if (nErrorNo = STORE(lArrayLoc,vMemInfo))
			goto ErrorOut;

		vMemInfo.ev_length = min(pDbg->nSize,VFP2C_ERROR_MESSAGE_LEN);
		memcpy(pMemInfo,pDbg->pPointer,vMemInfo.ev_length);
		ADIM(lArrayLoc) = 4;
		if (nErrorNo = STORE(lArrayLoc,vMemInfo))
			goto ErrorOut;

		pDbg = pDbg->next;
	}

	UNLOCKHAND(p1);
	UNLOCKHAND(vMemInfo);
	FREEHAND(vMemInfo);
	RET_AROWS(lArrayLoc);
	return;
	
	ErrorOut:
		UNLOCKHAND(p1);
		if (VALIDHAND(vMemInfo))
		{
			UNLOCKHAND(vMemInfo);
			FREEHAND(vMemInfo);
		}
		RAISEERROR(nErrorNo);
}