示例#1
0
int TestWLogCallback(int argc, char* argv[])
{
	wLog* root;
	wLog* logA;
	wLog* logB;
	wLogLayout* layout;
	wLogAppender* appender;
	wLogCallbacks callbacks;

	function = __FUNCTION__;
	WLog_Init();

	root = WLog_GetRoot();

	WLog_SetLogAppenderType(root, WLOG_APPENDER_CALLBACK);

	appender = WLog_GetLogAppender(root);

	callbacks.data = CallbackAppenderData;
	callbacks.image = CallbackAppenderImage;
	callbacks.message = CallbackAppenderMessage;
	callbacks.package = CallbackAppenderPackage;

	if (!WLog_ConfigureAppender(appender, "callbacks", (void *)&callbacks))
		return -1;

	layout = WLog_GetLogLayout(root);
	WLog_Layout_SetPrefixFormat(root, layout, "%mn");

	WLog_OpenAppender(root);

	logA = WLog_Get(channels[0]);
	logB = WLog_Get(channels[1]);

	WLog_SetLogLevel(logA, WLOG_TRACE);
	WLog_SetLogLevel(logB, WLOG_TRACE);

	WLog_Print(logA, messages[0].level, messages[0].msg);
	WLog_Print(logB, messages[1].level, messages[1].msg);
	WLog_Print(logA, messages[2].level, messages[2].msg, 2, "test");
	WLog_Print(logB, messages[3].level, messages[3].msg, 2, "time");
	WLog_Print(logA, messages[4].level, messages[4].msg);
	WLog_Print(logB, messages[5].level, messages[5].msg);
	WLog_Print(logA, messages[6].level, messages[6].msg);
	WLog_Print(logB, messages[7].level, messages[7].msg);

	WLog_CloseAppender(root);

	WLog_Uninit();

	return success ? 0 : -1;
}
示例#2
0
int TestWLog(int argc, char* argv[])
{
	wLog* log;
	wLogLayout* layout;
	wLogAppender* appender;

	log = WLog_New("CONSOLE_LOG_TEST");

	WLog_SetLogLevel(log, WLOG_INFO);

	WLog_SetLogAppenderType(log, WLOG_APPENDER_CONSOLE);
	appender = WLog_GetLogAppender(log);

	layout = WLog_GetLogLayout(log);
	WLog_Layout_SetPrefixFormat(log, layout, "[%lv:%mn] [%fl|%fn|%ln] - ");

	WLog_ConsoleAppender_SetOutputStream(log, (wLogConsoleAppender*) appender, WLOG_CONSOLE_STDERR);
	WLog_OpenAppender(log);

	WLog_Print(log, WLOG_INFO, "this is a test");
	WLog_Print(log, WLOG_WARN, "this is a %dnd %s", 2, "test");
	WLog_Print(log, WLOG_ERROR, "this is an error");
	WLog_Print(log, WLOG_TRACE, "this is a trace output");

	WLog_CloseAppender(log);
	WLog_Free(log);

	log = WLog_New("FILE_LOG_TEST");

	WLog_SetLogLevel(log, WLOG_WARN);

	WLog_SetLogAppenderType(log, WLOG_APPENDER_FILE);
	appender = WLog_GetLogAppender(log);

	layout = WLog_GetLogLayout(log);
	WLog_Layout_SetPrefixFormat(log, layout, "[%lv:%mn] [%fl|%fn|%ln] - ");

	WLog_FileAppender_SetOutputFileName(log, (wLogFileAppender*) appender, "/tmp/wlog_test.log");
	WLog_OpenAppender(log);

	WLog_Print(log, WLOG_INFO, "this is a test");
	WLog_Print(log, WLOG_WARN, "this is a %dnd %s", 2, "test");
	WLog_Print(log, WLOG_ERROR, "this is an error");
	WLog_Print(log, WLOG_TRACE, "this is a trace output");

	WLog_CloseAppender(log);
	WLog_Free(log);

	return 0;
}
示例#3
0
BOOL WLog_SetStringLogLevel(wLog* log, LPCSTR level)
{
	int lvl;

	if (!log || !level)
		return FALSE;

	lvl = WLog_ParseLogLevel(level);

	if (lvl < 0)
		return FALSE;

	return WLog_SetLogLevel(log, lvl);
}
示例#4
0
rdpRedirection* redirection_new()
{
	rdpRedirection* redirection;
	redirection = (rdpRedirection*) calloc(1, sizeof(rdpRedirection));

	if (redirection)
	{
		WLog_Init();
		redirection->log = WLog_Get("com.freerdp.core.redirection");
#ifdef WITH_DEBUG_REDIR
		WLog_SetLogLevel(redirection->log, WLOG_TRACE);
#endif
	}

	return redirection;
}
示例#5
0
RDS_MODULE_COMMON* rdp_rds_module_new(void)
{
	rdsModuleRdp* rdp;

	WLog_Init();

	rdp = (rdsModuleRdp*) malloc(sizeof(rdsModuleRdp));

	rdp->log = WLog_Get("com.freerds.module.rdp");
	WLog_OpenAppender(rdp->log);

	WLog_SetLogLevel(rdp->log, WLOG_DEBUG);

	WLog_Print(rdp->log, WLOG_DEBUG, "RdsModuleNew");

	return (RDS_MODULE_COMMON*) rdp;
}
示例#6
0
int cef_rds_module_new(rdsModule* module)
{
	rdsModuleCef* cef;

	WLog_Init();

	cef = (rdsModuleCef*) module;

	cef->log = WLog_Get("com.freerds.module.cef.connector");
	WLog_OpenAppender(cef->log);

	WLog_SetLogLevel(cef->log, WLOG_DEBUG);

	WLog_Print(cef->log, WLOG_DEBUG, "RdsModuleNew");

	return 0;
}
示例#7
0
RpcEngine::RpcEngine() :
		mPacktLength(0), mHeaderRead(0), mPayloadRead(0) {
	mhStopEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
	WLog_SetLogLevel(logger_RPCEngine, WLOG_ERROR);
}
示例#8
0
文件: rfx.c 项目: C4rt/FreeRDP
RFX_CONTEXT* rfx_context_new(BOOL encoder)
{
	HKEY hKey;
	LONG status;
	DWORD dwType;
	DWORD dwSize;
	DWORD dwValue;
	SYSTEM_INFO sysinfo;
	RFX_CONTEXT* context;
	wObject *pool;
	RFX_CONTEXT_PRIV *priv;

	context = (RFX_CONTEXT*)calloc(1, sizeof(RFX_CONTEXT));
	if (!context)
		return NULL;

	context->encoder = encoder;
	context->priv = priv = (RFX_CONTEXT_PRIV *)calloc(1, sizeof(RFX_CONTEXT_PRIV) );
	if (!priv)
		goto error_priv;

	WLog_Init();

	priv->log = WLog_Get("com.freerdp.codec.rfx");
	WLog_OpenAppender(priv->log);

#ifdef WITH_DEBUG_RFX
	WLog_SetLogLevel(priv->log, WLOG_DEBUG);
#endif

	priv->TilePool = ObjectPool_New(TRUE);
	if (!priv->TilePool)
		goto error_tilePool;
	pool = ObjectPool_Object(priv->TilePool);
	pool->fnObjectInit = (OBJECT_INIT_FN) rfx_tile_init;

	if (context->encoder)
	{
		pool->fnObjectNew = (OBJECT_NEW_FN) rfx_encoder_tile_new;
		pool->fnObjectFree = (OBJECT_FREE_FN) rfx_encoder_tile_free;
	}
	else
	{
		pool->fnObjectNew = (OBJECT_NEW_FN) rfx_decoder_tile_new;
		pool->fnObjectFree = (OBJECT_FREE_FN) rfx_decoder_tile_free;
	}

	/*
	 * align buffers to 16 byte boundary (needed for SSE/NEON instructions)
	 *
	 * y_r_buffer, cb_g_buffer, cr_b_buffer: 64 * 64 * sizeof(INT16) = 8192 (0x2000)
	 * dwt_buffer: 32 * 32 * 2 * 2 * sizeof(INT16) = 8192, maximum sub-band width is 32
	 *
	 * Additionally we add 32 bytes (16 in front and 16 at the back of the buffer)
	 * in order to allow optimized functions (SEE, NEON) to read from positions 
	 * that are actually in front/beyond the buffer. Offset calculations are
	 * performed at the BufferPool_Take function calls in rfx_encode/decode.c.
	 *
	 * We then multiply by 3 to use a single, partioned buffer for all 3 channels.
	 */

	priv->BufferPool = BufferPool_New(TRUE, (8192 + 32) * 3, 16);
	if (!priv->BufferPool)
		goto error_BufferPool;

#ifdef _WIN32
	{
		BOOL isVistaOrLater;
		OSVERSIONINFOA verinfo;

		ZeroMemory(&verinfo, sizeof(OSVERSIONINFOA));
		verinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);

		GetVersionExA(&verinfo);
		isVistaOrLater = ((verinfo.dwMajorVersion >= 6) && (verinfo.dwMinorVersion >= 0)) ? TRUE : FALSE;

		priv->UseThreads = isVistaOrLater;
	}
#else
	priv->UseThreads = TRUE;
#endif

	GetNativeSystemInfo(&sysinfo);

	priv->MinThreadCount = sysinfo.dwNumberOfProcessors;
	priv->MaxThreadCount = 0;

	status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\FreeRDP\\RemoteFX"), 0, KEY_READ | KEY_WOW64_64KEY, &hKey);

	if (status == ERROR_SUCCESS)
	{
		dwSize = sizeof(dwValue);

		if (RegQueryValueEx(hKey, _T("UseThreads"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS)
			priv->UseThreads = dwValue ? 1 : 0;

		if (RegQueryValueEx(hKey, _T("MinThreadCount"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS)
			priv->MinThreadCount = dwValue;

		if (RegQueryValueEx(hKey, _T("MaxThreadCount"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS)
			priv->MaxThreadCount = dwValue;

		RegCloseKey(hKey);
	}

	if (priv->UseThreads)
	{
		/* Call primitives_get here in order to avoid race conditions when using primitives_get */
		/* from multiple threads. This call will initialize all function pointers correctly     */
		/* before any decoding threads are started */
		primitives_get();

		priv->ThreadPool = CreateThreadpool(NULL);
		if (!priv->ThreadPool)
			goto error_threadPool;
		InitializeThreadpoolEnvironment(&priv->ThreadPoolEnv);
		SetThreadpoolCallbackPool(&priv->ThreadPoolEnv, priv->ThreadPool);

		if (priv->MinThreadCount)
			if (!SetThreadpoolThreadMinimum(priv->ThreadPool, priv->MinThreadCount))
				goto error_threadPool_minimum;

		if (priv->MaxThreadCount)
			SetThreadpoolThreadMaximum(priv->ThreadPool, priv->MaxThreadCount);
	}

	/* initialize the default pixel format */
	rfx_context_set_pixel_format(context, RDP_PIXEL_FORMAT_B8G8R8A8);

	/* create profilers for default decoding routines */
	rfx_profiler_create(context);
	
	/* set up default routines */
	context->quantization_decode = rfx_quantization_decode;	
	context->quantization_encode = rfx_quantization_encode;	
	context->dwt_2d_decode = rfx_dwt_2d_decode;
	context->dwt_2d_encode = rfx_dwt_2d_encode;

	RFX_INIT_SIMD(context);
	
	context->state = RFX_STATE_SEND_HEADERS;
	return context;

error_threadPool_minimum:
	CloseThreadpool(priv->ThreadPool);
error_threadPool:
	BufferPool_Free(priv->BufferPool);
error_BufferPool:
	ObjectPool_Free(priv->TilePool);
error_tilePool:
	free(priv);
error_priv:
	free(context);
	return NULL;
}
示例#9
0
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
	char* name;
	char* path;
	int length, ck;
	RDPDR_SMARTCARD* device;
	SMARTCARD_DEVICE* smartcard;

	device = (RDPDR_SMARTCARD*) pEntryPoints->device;

	name = device->Name;
	path = device->Path;

	smartcard = (SMARTCARD_DEVICE*) calloc(1, sizeof(SMARTCARD_DEVICE));

	if (!smartcard)
		return -1;

	smartcard->device.type = RDPDR_DTYP_SMARTCARD;
	smartcard->device.name = "SCARD";
	smartcard->device.IRPRequest = smartcard_irp_request;
	smartcard->device.Init = smartcard_init;
	smartcard->device.Free = smartcard_free;

	length = strlen(smartcard->device.name);
	smartcard->device.data = Stream_New(NULL, length + 1);

	Stream_Write(smartcard->device.data, "SCARD", 6);

	smartcard->name = NULL;
	smartcard->path = NULL;

	if (path)
	{
		smartcard->path = path;
		smartcard->name = name;
	}
	else if (name)
	{
		if (1 == sscanf(name, "%d", &ck))
			smartcard->path = name;
		else
			smartcard->name = name;
	}

	smartcard->log = WLog_Get("com.freerdp.channel.smartcard.client");

	WLog_SetLogLevel(smartcard->log, WLOG_DEBUG);

	smartcard->IrpQueue = MessageQueue_New(NULL);
	smartcard->rgSCardContextList = ListDictionary_New(TRUE);
	smartcard->rgOutstandingMessages = ListDictionary_New(TRUE);
	smartcard->CompletedIrpQueue = Queue_New(TRUE, -1, -1);

	smartcard->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) smartcard_thread_func,
			smartcard, CREATE_SUSPENDED, NULL);

	pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) smartcard);

	ResumeThread(smartcard->thread);

	return 0;
}
示例#10
0
文件: TestWLog.c 项目: DavBfr/FreeRDP
int TestWLog(int argc, char* argv[])
{
	wLog* root;
	wLog* logA;
	wLog* logB;
	wLogLayout* layout;
	wLogAppender* appender;
	char* tmp_path;
	char* wlog_file;

        if (!(tmp_path = GetKnownPath(KNOWN_PATH_TEMP)))
        {
                fprintf(stderr, "Failed to get temporary directory!\n");
                return -1;
        }

	WLog_Init();

	root = WLog_GetRoot();

	WLog_SetLogAppenderType(root, WLOG_APPENDER_BINARY);

	appender = WLog_GetLogAppender(root);
	if(!WLog_ConfigureAppender(appender, "outputfilename", "test_w.log"))
		return 1;
	if(!WLog_ConfigureAppender(appender, "outputfilepath", tmp_path))
		return 1;

	layout = WLog_GetLogLayout(root);
	WLog_Layout_SetPrefixFormat(root, layout, "[%lv:%mn] [%fl|%fn|%ln] - ");

	WLog_OpenAppender(root);

	logA = WLog_Get("com.test.ChannelA");
	logB = WLog_Get("com.test.ChannelB");

	WLog_SetLogLevel(logA, WLOG_INFO);
	WLog_SetLogLevel(logB, WLOG_ERROR);

	WLog_Print(logA, WLOG_INFO, "this is a test");
	WLog_Print(logA, WLOG_WARN, "this is a %dnd %s", 2, "test");
	WLog_Print(logA, WLOG_ERROR, "this is an error");
	WLog_Print(logA, WLOG_TRACE, "this is a trace output");

	WLog_Print(logB, WLOG_INFO, "just some info");
	WLog_Print(logB, WLOG_WARN, "we're warning a %dnd %s", 2, "time");
	WLog_Print(logB, WLOG_ERROR, "we've got an error");
	WLog_Print(logB, WLOG_TRACE, "leaving a trace behind");

	WLog_CloseAppender(root);

	WLog_Uninit();

	if ((wlog_file = GetCombinedPath(tmp_path, "test_w.log")))
	{
		DeleteFileA(wlog_file);
		free(wlog_file);
	}

	return 0;
}