BYTE* test_progressive_load_bitmap(char* path, char* file, UINT32* size, int quarter) { int status; BYTE* buffer; wImage* image; char* filename; filename = GetCombinedPath(path, file); if (!filename) return NULL; image = winpr_image_new(); if (!image) return NULL; status = winpr_image_read(image, filename); if (status < 0) return NULL; buffer = image->data; *size = image->height * image->scanline; test_fill_image_alpha_channel(image->data, image->width, image->height, 0xFF); test_image_fill_unused_quarters(image->data, image->scanline, image->width, image->height, quarter, 0xFF000000); winpr_image_free(image, FALSE); free(filename); return buffer; }
BYTE* test_progressive_load_file(char* path, char* file, UINT32* size) { FILE* fp; BYTE* buffer; char* filename; filename = GetCombinedPath(path, file); fp = fopen(filename, "r"); if (!fp) return NULL; fseek(fp, 0, SEEK_END); *size = ftell(fp); fseek(fp, 0, SEEK_SET); buffer = (BYTE*) malloc(*size); if (!buffer) return NULL; if (fread(buffer, *size, 1, fp) != 1) return NULL; free(filename); fclose(fp); return buffer; }
char* WLog_Message_GetOutputFileName(int id, const char* ext) { DWORD ProcessId; char* FilePath; char* FileName; char* FullFileName; ProcessId = GetCurrentProcessId(); FilePath = GetKnownSubPath(KNOWN_PATH_TEMP, "wlog"); if (!PathFileExistsA(FilePath)) CreateDirectoryA(FilePath, NULL); FileName = (char*) malloc(256); if (id >= 0) sprintf_s(FileName, 256, "%u-%d.%s", (unsigned int) ProcessId, id, ext); else sprintf_s(FileName, 256, "%u.%s", (unsigned int) ProcessId, ext); FullFileName = GetCombinedPath(FilePath, FileName); free(FileName); free(FilePath); return FullFileName; }
int WLog_FileAppender_Open(wLog* log, wLogFileAppender* appender) { DWORD ProcessId; ProcessId = GetCurrentProcessId(); if (!appender->FilePath) { appender->FilePath = GetKnownSubPath(KNOWN_PATH_TEMP, "wlog"); } if (!PathFileExistsA(appender->FilePath)) { CreateDirectoryA(appender->FilePath, 0); UnixChangeFileMode(appender->FilePath, 0xFFFF); } if (!appender->FileName) { appender->FileName = (char*) malloc(256); sprintf_s(appender->FileName, 256, "%u.log", (unsigned int) ProcessId); } if (!appender->FullFileName) { appender->FullFileName = GetCombinedPath(appender->FilePath, appender->FileName); } appender->FileDescriptor = fopen(appender->FullFileName, "a+"); if (!appender->FileDescriptor) return -1; return 0; }
int freerds_generate_certificate(rdpSettings* settings) { char* config_home; char* server_file_path; MAKECERT_CONTEXT* context; config_home = GetKnownPath(KNOWN_PATH_XDG_CONFIG_HOME); if (!PathFileExistsA(config_home)) CreateDirectoryA(config_home, 0); free(config_home); if (!PathFileExistsA(settings->ConfigPath)) CreateDirectoryA(settings->ConfigPath, 0); server_file_path = GetCombinedPath(settings->ConfigPath, "server"); if (!PathFileExistsA(server_file_path)) CreateDirectoryA(server_file_path, 0); settings->CertificateFile = GetCombinedPath(server_file_path, "server.crt"); settings->PrivateKeyFile = GetCombinedPath(server_file_path, "server.key"); if ((!PathFileExistsA(settings->CertificateFile)) || (!PathFileExistsA(settings->PrivateKeyFile))) { context = makecert_context_new(); makecert_context_process(context, makecert_argc, (char**) makecert_argv); makecert_context_set_output_file_name(context, "server"); if (!PathFileExistsA(settings->CertificateFile)) makecert_context_output_certificate_file(context, server_file_path); if (!PathFileExistsA(settings->PrivateKeyFile)) makecert_context_output_private_key_file(context, server_file_path); makecert_context_free(context); } free(server_file_path); return 0; }
char* GetNamedPipeUnixDomainSocketBaseFilePathA() { char* lpTempPath; char* lpPipePath; lpTempPath = GetKnownPath(KNOWN_PATH_TEMP); lpPipePath = GetCombinedPath(lpTempPath, ".pipe"); free(lpTempPath); return lpPipePath; }
static void InitializeWtsApiStubs_FreeRDS() { wIniFile* ini; const char* prefix; const char* libdir; if (g_WtsApi) return; ini = IniFile_New(); if (IniFile_ReadFile(ini, "/var/run/freerds.instance") < 0) { IniFile_Free(ini); WLog_ERR(TAG, "failed to parse freerds.instance"); LoadAndInitialize(FREERDS_LIBRARY_NAME); return; } prefix = IniFile_GetKeyValueString(ini, "FreeRDS", "prefix"); libdir = IniFile_GetKeyValueString(ini, "FreeRDS", "libdir"); WLog_INFO(TAG, "FreeRDS (prefix / libdir): %s / %s", prefix, libdir); if (prefix && libdir) { char* prefix_libdir; char* wtsapi_library; prefix_libdir = GetCombinedPath(prefix, libdir); wtsapi_library = GetCombinedPath(prefix_libdir, FREERDS_LIBRARY_NAME); if (wtsapi_library) { LoadAndInitialize(wtsapi_library); } free(prefix_libdir); free(wtsapi_library); } IniFile_Free(ini); }
char* GetKnownSubPath(int id, char* path) { char* subPath; char* knownPath; knownPath = GetKnownPath(id); subPath = GetCombinedPath(knownPath, path); free(knownPath); return subPath; }
char* GetNamedPipeUnixDomainSocketFilePathA(LPCSTR lpName) { char* lpPipePath; char* lpFileName; char* lpFilePath; lpPipePath = GetNamedPipeUnixDomainSocketBaseFilePathA(); lpFileName = GetNamedPipeNameWithoutPrefixA(lpName); lpFilePath = GetCombinedPath(lpPipePath, (char*) lpFileName); free(lpPipePath); free(lpFileName); return lpFilePath; }
static char* GetPath_XDG_CONFIG_HOME(void) { char* path = NULL; #if defined(WIN32) && !defined(_UWP) path = calloc(MAX_PATH, sizeof(char)); if (!path) return NULL; if (FAILED(SHGetFolderPathA(0, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, path))) { free(path); return NULL; } #elif defined(__IOS__) path = GetCombinedPath(GetPath_HOME(), ".freerdp"); #else char* home = NULL; /** * There is a single base directory relative to which user-specific configuration files should be written. * This directory is defined by the environment variable $XDG_CONFIG_HOME. * * $XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored. * If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used. */ path = GetEnvAlloc("XDG_CONFIG_HOME"); if (path) return path; home = GetPath_HOME(); if (!home) home = GetPath_TEMP(); if (!home) return NULL; path = (char*) malloc(strlen(home) + strlen("/.config") + 1); if (!path) { free(home); return NULL; } sprintf(path, "%s%s", home, "/.config"); free(home); #endif return path; }
char* GetEnvironmentSubPath(char* name, const char* path) { char* env; char* subpath; env = GetEnvironmentPath(name); if (!env) return NULL; subpath = GetCombinedPath(env, path); free(env); return subpath; }
void certificate_store_init(rdpCertificateStore* certificate_store) { rdpSettings* settings; settings = certificate_store->settings; if (!PathFileExistsA(settings->ConfigPath)) { CreateDirectoryA(settings->ConfigPath, 0); fprintf(stderr, "creating directory %s\n", settings->ConfigPath); } certificate_store->path = GetCombinedPath(settings->ConfigPath, (char*) certificate_store_dir); if (!PathFileExistsA(certificate_store->path)) { CreateDirectoryA(certificate_store->path, 0); fprintf(stderr, "creating directory %s\n", certificate_store->path); } certificate_store->file = GetCombinedPath(settings->ConfigPath, (char*) certificate_known_hosts_file); if (PathFileExistsA(certificate_store->file) == FALSE) { certificate_store->fp = fopen((char*) certificate_store->file, "w+"); if (certificate_store->fp == NULL) { fprintf(stderr, "certificate_store_open: error opening [%s] for writing\n", certificate_store->file); return; } fflush(certificate_store->fp); } else { certificate_store->fp = fopen((char*) certificate_store->file, "r+"); } }
char* GetKnownSubPath(int id, const char* path) { char* subPath; char* knownPath; knownPath = GetKnownPath(id); if (!knownPath) return NULL; subPath = GetCombinedPath(knownPath, path); free(knownPath); return subPath; }
static char* FindApplicationPath(char* application) { LPCSTR pathName = "PATH"; char* path; char* save; DWORD nSize; LPSTR lpSystemPath; char* filename = NULL; if (!application) return NULL; if (application[0] == '/') return _strdup(application); nSize = GetEnvironmentVariableA(pathName, NULL, 0); if (!nSize) return _strdup(application); lpSystemPath = (LPSTR) malloc(nSize); if (!lpSystemPath) return NULL; if (GetEnvironmentVariableA(pathName, lpSystemPath, nSize) != nSize - 1) { free(lpSystemPath); return NULL; } save = NULL; path = strtok_s(lpSystemPath, ":", &save); while (path) { filename = GetCombinedPath(path, application); if (PathFileExistsA(filename)) { break; } free(filename); filename = NULL; path = strtok_s(NULL, ":", &save); } free(lpSystemPath); return filename; }
char* GetDeviceFileUnixDomainSocketBaseFilePathA() { char* lpTempPath; char* lpPipePath; lpTempPath = GetKnownPath(KNOWN_PATH_TEMP); if (!lpTempPath) return NULL; lpPipePath = GetCombinedPath(lpTempPath, ".device"); free(lpTempPath); return lpPipePath; }
static char* GetPath_XDG_CACHE_HOME(void) { char* path = NULL; char* home = NULL; #if defined(WIN32) home = GetPath_XDG_RUNTIME_DIR(); if (home) { path = GetCombinedPath(home, "cache"); if (!PathFileExistsA(path)) if (!CreateDirectoryA(path, NULL)) path = NULL; } free(home); #else /** * There is a single base directory relative to which user-specific non-essential (cached) data should be written. * This directory is defined by the environment variable $XDG_CACHE_HOME. * * $XDG_CACHE_HOME defines the base directory relative to which user specific non-essential data files should be stored. * If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used. */ path = GetEnvAlloc("XDG_CACHE_HOME"); if (path) return path; home = GetPath_HOME(); if (!home) return NULL; path = (char*) malloc(strlen(home) + strlen("/.cache") + 1); if (!path) { free(home); return NULL; } sprintf(path, "%s%s", home, "/.cache"); free(home); #endif return path; }
static BOOL WLog_BinaryAppender_Open(wLog* log, wLogAppender* appender) { wLogBinaryAppender* binaryAppender; if (!log || !appender) return FALSE; binaryAppender = (wLogBinaryAppender *)appender; if (!binaryAppender->FileName) { binaryAppender->FileName = (char*) malloc(MAX_PATH); if (!binaryAppender->FileName) return FALSE; sprintf_s(binaryAppender->FileName, MAX_PATH, "%"PRIu32".wlog", GetCurrentProcessId()); } if (!binaryAppender->FilePath) { binaryAppender->FilePath = GetKnownSubPath(KNOWN_PATH_TEMP, "wlog"); if (!binaryAppender->FilePath) return FALSE; } if (!binaryAppender->FullFileName) { binaryAppender->FullFileName = GetCombinedPath(binaryAppender->FilePath, binaryAppender->FileName); if (!binaryAppender->FullFileName) return FALSE; } if (!PathFileExistsA(binaryAppender->FilePath)) { if (!PathMakePathA(binaryAppender->FilePath, 0)) return FALSE; UnixChangeFileMode(binaryAppender->FilePath, 0xFFFF); } binaryAppender->FileDescriptor = fopen(binaryAppender->FullFileName, "a+"); if (!binaryAppender->FileDescriptor) return FALSE; return TRUE; }
BOOL WLog_FileAppender_Open(wLog* log, wLogFileAppender* appender) { if (!log || !appender) return FALSE; if (!appender->FilePath) { appender->FilePath = GetKnownSubPath(KNOWN_PATH_TEMP, "wlog"); if (!appender->FilePath) return FALSE; } if (!appender->FileName) { appender->FileName = (char*) malloc(MAX_PATH); if (!appender->FileName) return FALSE; sprintf_s(appender->FileName, MAX_PATH, "%u.log", (unsigned int) GetCurrentProcessId()); } if (!appender->FullFileName) { appender->FullFileName = GetCombinedPath(appender->FilePath, appender->FileName); if (!appender->FullFileName) return FALSE; } if (!PathFileExistsA(appender->FilePath)) { if (!PathMakePathA(appender->FilePath, 0)) return FALSE; UnixChangeFileMode(appender->FilePath, 0xFFFF); } appender->FileDescriptor = fopen(appender->FullFileName, "a+"); if (!appender->FileDescriptor) return FALSE; return TRUE; }
static BYTE* test_progressive_load_file(char* path, char* file, size_t* size) { FILE* fp; BYTE* buffer; char* filename; filename = GetCombinedPath(path, file); if (!filename) return NULL; fp = fopen(filename, "r"); free(filename); if (!fp) return NULL; _fseeki64(fp, 0, SEEK_END); *size = _ftelli64(fp); _fseeki64(fp, 0, SEEK_SET); buffer = (BYTE*) malloc(*size); if (!buffer) { fclose(fp); return NULL; } if (fread(buffer, *size, 1, fp) != 1) { free(buffer); fclose(fp); return NULL; } fclose(fp); return buffer; }
static int testSuccess(int port) { int rc; STARTUPINFO si; PROCESS_INFORMATION process; char arg1[] = "/v:127.0.0.1:XXXXX"; char* clientArgs[] = { "test", "/v:127.0.0.1:XXXXX", "/cert-ignore", "/rfx", NULL }; char* commandLine; int commandLineLen; int argc = 4; char* path = TESTING_OUTPUT_DIRECTORY; char* wpath = TESTING_SRC_DIRECTORY; char* exe = GetCombinedPath(path, "server"); char* wexe = GetCombinedPath(wpath, "server"); snprintf(arg1, 18, "/v:127.0.0.1:%d", port); clientArgs[1] = arg1; if (!exe || !wexe) { free(exe); free(wexe); return -2; } path = GetCombinedPath(exe, "Sample"); wpath = GetCombinedPath(wexe, "Sample"); free(exe); free(wexe); if (!path || !wpath) { free(path); free(wpath); return -2; } exe = GetCombinedPath(path, "sfreerdp-server"); if (!exe) { free(path); free(wpath); return -2; } printf("Sample Server: %s\n", exe); printf("Workspace: %s\n", wpath); if (!PathFileExistsA(exe)) { free(path); free(wpath); free(exe); return -2; } // Start sample server locally. commandLineLen = strlen(exe) + strlen(" --port=XXXXX") + 1; commandLine = malloc(commandLineLen); if (!commandLine) { free(path); free(wpath); free(exe); return -2; } snprintf(commandLine, commandLineLen, "%s --port=%d", exe, port); memset(&si, 0, sizeof(si)); si.cb = sizeof(si); if (!CreateProcessA(exe, commandLine, NULL, NULL, FALSE, 0, NULL, wpath, &si, &process)) { free(exe); free(path); free(wpath); return -2; } free(exe); free(path); free(wpath); free(commandLine); Sleep(1 * 1000); /* let the server start */ rc = runInstance(argc, clientArgs, NULL); if (!TerminateProcess(process.hProcess, 0)) return -2; WaitForSingleObject(process.hProcess, INFINITE); CloseHandle(process.hProcess); CloseHandle(process.hThread); printf("%s: returned %d!\n", __FUNCTION__, rc); if (rc) return -1; printf("%s: Success!\n", __FUNCTION__); return 0; }
rdtkFont* rdtk_font_new(rdtkEngine* engine, const char* path, const char* file) { int status; int length; rdtkFont* font; char* fontBaseFile; char* fontImageFile; char* fontDescriptorFile; fontBaseFile = GetCombinedPath(path, file); if (!fontBaseFile) return NULL; length = strlen(fontBaseFile); fontImageFile = (char*) malloc(length + 8); if (!fontImageFile) return NULL; strcpy(fontImageFile, fontBaseFile); strcpy(&fontImageFile[length], ".png"); fontDescriptorFile = (char*) malloc(length + 8); if (!fontImageFile) return NULL; strcpy(fontDescriptorFile, fontBaseFile); strcpy(&fontDescriptorFile[length], ".xml"); free(fontBaseFile); if (!PathFileExistsA(fontImageFile)) return NULL; if (!PathFileExistsA(fontDescriptorFile)) return NULL; font = (rdtkFont*) calloc(1, sizeof(rdtkFont)); if (!font) return NULL; font->engine = engine; font->image = winpr_image_new(); if (!font->image) return NULL; status = winpr_image_read(font->image, fontImageFile); if (status < 0) return NULL; status = rdtk_font_load_descriptor(font, fontDescriptorFile); free(fontImageFile); free(fontDescriptorFile); return font; }
int TestPathMakePath(int argc, char* argv[]) { int x; size_t baseLen; BOOL success; char tmp[64]; char* path; char* cur; char delim = PathGetSeparatorA(0); char* base = GetKnownPath(KNOWN_PATH_TEMP); if (!base) { fprintf(stderr, "Failed to get temporary directory!\n"); return -1; } baseLen = strlen(base); srand(time(NULL)); for (x = 0; x < 5; x++) { sprintf_s(tmp, ARRAYSIZE(tmp), "%08X", rand()); path = GetCombinedPath(base, tmp); free(base); if (!path) { fprintf(stderr, "GetCombinedPath failed!\n"); return -1; } base = path; } printf("Creating path %s\n", path); success = PathMakePathA(path, NULL); if (!success) { fprintf(stderr, "MakePath failed!\n"); free(path); return -1; } success = PathFileExistsA(path); if (!success) { fprintf(stderr, "MakePath lied about success!\n"); free(path); return -1; } while (strlen(path) > baseLen) { if (!RemoveDirectoryA(path)) { fprintf(stderr, "RemoveDirectoryA %s failed!\n", path); free(path); return -1; } cur = strrchr(path, delim); if (cur) *cur = '\0'; } free(path); printf("%s success!\n", __FUNCTION__); return 0; }
rdpSettings* freerdp_settings_new(DWORD flags) { char* base; rdpSettings* settings; settings = (rdpSettings*) calloc(1, sizeof(rdpSettings)); if (!settings) return NULL; settings->ServerMode = (flags & FREERDP_SETTINGS_SERVER_MODE) ? TRUE : FALSE; settings->WaitForOutputBufferFlush = TRUE; settings->DesktopWidth = 1024; settings->DesktopHeight = 768; settings->Workarea = FALSE; settings->Fullscreen = FALSE; settings->GrabKeyboard = TRUE; settings->Decorations = TRUE; settings->RdpVersion = 7; settings->ColorDepth = 16; settings->ExtSecurity = FALSE; settings->NlaSecurity = TRUE; settings->TlsSecurity = TRUE; settings->RdpSecurity = TRUE; settings->NegotiateSecurityLayer = TRUE; settings->RestrictedAdminModeRequired = FALSE; settings->MstscCookieMode = FALSE; settings->CookieMaxLength = DEFAULT_COOKIE_MAX_LENGTH; settings->ClientBuild = 2600; settings->KeyboardType = 4; settings->KeyboardSubType = 0; settings->KeyboardFunctionKey = 12; settings->KeyboardLayout = 0; settings->UseRdpSecurityLayer = FALSE; settings->SaltedChecksum = TRUE; settings->ServerPort = 3389; settings->GatewayPort = 443; settings->DesktopResize = TRUE; settings->ToggleFullscreen = TRUE; settings->DesktopPosX = 0; settings->DesktopPosY = 0; settings->PerformanceFlags = PERF_FLAG_NONE; settings->AllowFontSmoothing = FALSE; settings->AllowDesktopComposition = FALSE; settings->DisableWallpaper = TRUE; settings->DisableFullWindowDrag = TRUE; settings->DisableMenuAnims = TRUE; settings->DisableThemes = FALSE; settings->ConnectionType = CONNECTION_TYPE_LAN; settings->EncryptionMethods = ENCRYPTION_METHOD_NONE; settings->EncryptionLevel = ENCRYPTION_LEVEL_NONE; settings->CompressionEnabled = TRUE; if (settings->ServerMode) settings->CompressionLevel = PACKET_COMPR_TYPE_RDP61; else settings->CompressionLevel = PACKET_COMPR_TYPE_RDP61; settings->Authentication = TRUE; settings->AuthenticationOnly = FALSE; settings->CredentialsFromStdin = FALSE; settings->DisableCredentialsDelegation = FALSE; settings->AuthenticationLevel = 2; settings->ChannelCount = 0; settings->ChannelDefArraySize = 32; settings->ChannelDefArray = (CHANNEL_DEF*) calloc(settings->ChannelDefArraySize, sizeof(CHANNEL_DEF)); if (!settings->ChannelDefArray) goto out_fail; settings->MonitorCount = 0; settings->MonitorDefArraySize = 32; settings->MonitorDefArray = (rdpMonitor*) calloc(settings->MonitorDefArraySize, sizeof(rdpMonitor)); if (!settings->MonitorDefArray) goto out_fail; settings->MonitorLocalShiftX = 0; settings->MonitorLocalShiftY = 0; settings->MonitorIds = (UINT32*) calloc(16, sizeof(UINT32)); if(!settings->MonitorIds) goto out_fail; if (!settings_get_computer_name(settings)) goto out_fail; settings->ReceivedCapabilities = calloc(1, 32); if (!settings->ReceivedCapabilities) goto out_fail; settings->OrderSupport = calloc(1, 32); if (!settings->OrderSupport) goto out_fail; settings->OrderSupport[NEG_DSTBLT_INDEX] = TRUE; settings->OrderSupport[NEG_PATBLT_INDEX] = TRUE; settings->OrderSupport[NEG_SCRBLT_INDEX] = TRUE; settings->OrderSupport[NEG_OPAQUE_RECT_INDEX] = TRUE; settings->OrderSupport[NEG_DRAWNINEGRID_INDEX] = TRUE; settings->OrderSupport[NEG_MULTIDSTBLT_INDEX] = TRUE; settings->OrderSupport[NEG_MULTIPATBLT_INDEX] = TRUE; settings->OrderSupport[NEG_MULTISCRBLT_INDEX] = TRUE; settings->OrderSupport[NEG_MULTIOPAQUERECT_INDEX] = TRUE; settings->OrderSupport[NEG_MULTI_DRAWNINEGRID_INDEX] = TRUE; settings->OrderSupport[NEG_LINETO_INDEX] = TRUE; settings->OrderSupport[NEG_POLYLINE_INDEX] = TRUE; settings->OrderSupport[NEG_MEMBLT_INDEX] = TRUE; settings->OrderSupport[NEG_MEM3BLT_INDEX] = TRUE; settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = TRUE; settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = TRUE; settings->OrderSupport[NEG_FAST_INDEX_INDEX] = TRUE; settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = TRUE; settings->OrderSupport[NEG_POLYGON_SC_INDEX] = TRUE; settings->OrderSupport[NEG_POLYGON_CB_INDEX] = TRUE; settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = TRUE; settings->OrderSupport[NEG_ELLIPSE_CB_INDEX] = TRUE; settings->ClientProductId = calloc(1, 32); if (!settings->ClientProductId) goto out_fail; settings->ClientHostname = calloc(1, 32); if (!settings->ClientHostname) goto out_fail; gethostname(settings->ClientHostname, 31); settings->ClientHostname[31] = 0; settings->ColorPointerFlag = TRUE; settings->LargePointerFlag = TRUE; settings->PointerCacheSize = 20; settings->SoundBeepsEnabled = TRUE; settings->DrawGdiPlusEnabled = FALSE; settings->DrawAllowSkipAlpha = TRUE; settings->DrawAllowColorSubsampling = FALSE; settings->DrawAllowDynamicColorFidelity = FALSE; settings->FrameMarkerCommandEnabled = TRUE; settings->SurfaceFrameMarkerEnabled = TRUE; settings->BitmapCacheV3Enabled = FALSE; settings->BitmapCacheEnabled = TRUE; settings->BitmapCachePersistEnabled = FALSE; settings->AllowCacheWaitingList = TRUE; settings->BitmapCacheV2NumCells = 5; settings->BitmapCacheV2CellInfo = (BITMAP_CACHE_V2_CELL_INFO*) malloc(sizeof(BITMAP_CACHE_V2_CELL_INFO) * 6); if (!settings->BitmapCacheV2CellInfo) goto out_fail; settings->BitmapCacheV2CellInfo[0].numEntries = 600; settings->BitmapCacheV2CellInfo[0].persistent = FALSE; settings->BitmapCacheV2CellInfo[1].numEntries = 600; settings->BitmapCacheV2CellInfo[1].persistent = FALSE; settings->BitmapCacheV2CellInfo[2].numEntries = 2048; settings->BitmapCacheV2CellInfo[2].persistent = FALSE; settings->BitmapCacheV2CellInfo[3].numEntries = 4096; settings->BitmapCacheV2CellInfo[3].persistent = FALSE; settings->BitmapCacheV2CellInfo[4].numEntries = 2048; settings->BitmapCacheV2CellInfo[4].persistent = FALSE; settings->NoBitmapCompressionHeader = TRUE; settings->RefreshRect = TRUE; settings->SuppressOutput = TRUE; settings->GlyphSupportLevel = GLYPH_SUPPORT_FULL; settings->GlyphCache = malloc(sizeof(GLYPH_CACHE_DEFINITION) * 10); if(!settings->GlyphCache) goto out_fail; settings->FragCache = malloc(sizeof(GLYPH_CACHE_DEFINITION)); if(!settings->FragCache) goto out_fail; settings->GlyphCache[0].cacheEntries = 254; settings->GlyphCache[0].cacheMaximumCellSize = 4; settings->GlyphCache[1].cacheEntries = 254; settings->GlyphCache[1].cacheMaximumCellSize = 4; settings->GlyphCache[2].cacheEntries = 254; settings->GlyphCache[2].cacheMaximumCellSize = 8; settings->GlyphCache[3].cacheEntries = 254; settings->GlyphCache[3].cacheMaximumCellSize = 8; settings->GlyphCache[4].cacheEntries = 254; settings->GlyphCache[4].cacheMaximumCellSize = 16; settings->GlyphCache[5].cacheEntries = 254; settings->GlyphCache[5].cacheMaximumCellSize = 32; settings->GlyphCache[6].cacheEntries = 254; settings->GlyphCache[6].cacheMaximumCellSize = 64; settings->GlyphCache[7].cacheEntries = 254; settings->GlyphCache[7].cacheMaximumCellSize = 128; settings->GlyphCache[8].cacheEntries = 254; settings->GlyphCache[8].cacheMaximumCellSize = 256; settings->GlyphCache[9].cacheEntries = 64; settings->GlyphCache[9].cacheMaximumCellSize = 256; settings->FragCache->cacheEntries = 256; settings->FragCache->cacheMaximumCellSize = 256; settings->OffscreenSupportLevel = TRUE; settings->OffscreenCacheSize = 7680; settings->OffscreenCacheEntries = 2000; settings->DrawNineGridCacheSize = 2560; settings->DrawNineGridCacheEntries = 256; settings->ClientDir = _strdup(client_dll); if (!settings->ClientDir) goto out_fail; settings->RemoteAppNumIconCaches = 3; settings->RemoteAppNumIconCacheEntries = 12; settings->VirtualChannelChunkSize = CHANNEL_CHUNK_LENGTH; settings->MultifragMaxRequestSize = 0xFFFF; settings->GatewayUseSameCredentials = FALSE; settings->GatewayBypassLocal = FALSE; settings->GatewayRpcTransport = TRUE; settings->GatewayHttpTransport = TRUE; settings->GatewayUdpTransport = TRUE; settings->FastPathInput = TRUE; settings->FastPathOutput = TRUE; settings->FrameAcknowledge = 2; settings->MouseMotion = TRUE; settings->NSCodecColorLossLevel = 3; settings->NSCodecAllowSubsampling = TRUE; settings->NSCodecAllowDynamicColorFidelity = TRUE; settings->AutoReconnectionEnabled = FALSE; settings->AutoReconnectMaxRetries = 20; settings->GfxThinClient = TRUE; settings->GfxSmallCache = FALSE; settings->GfxProgressive = FALSE; settings->GfxProgressiveV2 = FALSE; settings->GfxH264 = FALSE; settings->ClientAutoReconnectCookie = (ARC_CS_PRIVATE_PACKET*) calloc(1, sizeof(ARC_CS_PRIVATE_PACKET)); if (!settings->ClientAutoReconnectCookie) goto out_fail; settings->ServerAutoReconnectCookie = (ARC_SC_PRIVATE_PACKET*) calloc(1, sizeof(ARC_SC_PRIVATE_PACKET)); if (!settings->ServerAutoReconnectCookie) goto out_fail; settings->ClientTimeZone = (TIME_ZONE_INFO*) calloc(1,sizeof(TIME_ZONE_INFO)); if (!settings->ClientTimeZone) goto out_fail; settings->DeviceArraySize = 16; settings->DeviceArray = (RDPDR_DEVICE**) calloc(1, sizeof(RDPDR_DEVICE*) * settings->DeviceArraySize); if (!settings->DeviceArray) goto out_fail; settings->StaticChannelArraySize = 16; settings->StaticChannelArray = (ADDIN_ARGV**) calloc(1, sizeof(ADDIN_ARGV*) * settings->StaticChannelArraySize); if (!settings->StaticChannelArray) goto out_fail; settings->DynamicChannelArraySize = 16; settings->DynamicChannelArray = (ADDIN_ARGV**) calloc(1, sizeof(ADDIN_ARGV*) * settings->DynamicChannelArraySize); if(!settings->DynamicChannelArray) goto out_fail; settings->HomePath = GetKnownPath(KNOWN_PATH_HOME); if (!settings->HomePath) goto out_fail; /* For default FreeRDP continue using same config directory * as in old releases. * Custom builds use <Vendor>/<Product> as config folder. */ if (_stricmp(FREERDP_VENDOR_STRING, FREERDP_PRODUCT_STRING)) { base = GetKnownSubPath(KNOWN_PATH_XDG_CONFIG_HOME, FREERDP_VENDOR_STRING); if (base) { settings->ConfigPath = GetCombinedPath( base, FREERDP_PRODUCT_STRING); } free (base); } else { int i; char product[sizeof(FREERDP_PRODUCT_STRING)]; memset(product, 0, sizeof(product)); for (i=0; i<sizeof(product); i++) product[i] = tolower(FREERDP_PRODUCT_STRING[i]); settings->ConfigPath = GetKnownSubPath( KNOWN_PATH_XDG_CONFIG_HOME, product); } if (!settings->ConfigPath) goto out_fail; settings_load_hkey_local_machine(settings); settings->SettingsModified = (BYTE*) calloc(1, sizeof(rdpSettings) / 8 ); if(!settings->SettingsModified) goto out_fail; return settings; out_fail: free(settings->HomePath); free(settings->ConfigPath); free(settings->DynamicChannelArray); free(settings->StaticChannelArray); free(settings->DeviceArray); free(settings->ClientTimeZone); free(settings->ServerAutoReconnectCookie); free(settings->ClientAutoReconnectCookie); free(settings->ClientDir); free(settings->FragCache); free(settings->GlyphCache); free(settings->BitmapCacheV2CellInfo); free(settings->ClientProductId); free(settings->ClientHostname); free(settings->OrderSupport); free(settings->ReceivedCapabilities); free(settings->ComputerName); free(settings->MonitorIds); free(settings->MonitorDefArray); free(settings->ChannelDefArray); free(settings); return NULL; }
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; }