diff --git a/CMakeLists.txt b/CMakeLists.txt index a50723f86..6c98e76f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -649,7 +649,9 @@ if(${CMAKE_VERSION} VERSION_GREATER "2.8.10") set(FREERDP_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/FreeRDP") set(FREERDP_INCLUDE_DIR "include") - set(FREERDP_MONOLITHIC_BUILD ${MONOLITHIC_BUILD}) + + # keep for legacy builds + set(FREERDP_MONOLITHIC_BUILD OFF) configure_package_config_file(FreeRDPConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FreeRDPConfig.cmake INSTALL_DESTINATION ${FREERDP_CMAKE_INSTALL_DIR} @@ -681,28 +683,11 @@ endif() include(${CMAKE_CPACK_INCLUDE_FILE}) -if(MONOLITHIC_BUILD) - set(FREERDP_PC_LIBS "-lfreerdp -lfreerdp-client") - set(WINPR_PC_LIBS "-lwinpr") - if (WITH_SERVER) - set(FREERDP_PC_LIBS "${FREERDP_PC_LIBS} -lfreerdp-server") - endif() -else(MONOLITHIC_BUILD) - # freerdp exports - get_property(MEXPORTS GLOBAL PROPERTY "freerdp_EXPORTS") - foreach(EXPORT_MODULE ${MEXPORTS}) - list(APPEND FREERDP_PC_LIBS "-lfreerdp-${EXPORT_MODULE}") - endforeach() - string(REPLACE ";" " " FREERDP_PC_LIBS "${FREERDP_PC_LIBS}") - - # winpr exports - get_property(MEXPORTS GLOBAL PROPERTY "winpr_EXPORTS") - foreach(EXPORT_MODULE ${MEXPORTS}) - list(APPEND WINPR_PC_LIBS "-lwinpr-${EXPORT_MODULE}") - endforeach() - list(APPEND WINPR_PC_LIBS "-lwinpr") - string(REPLACE ";" " " WINPR_PC_LIBS "${WINPR_PC_LIBS}") -endif(MONOLITHIC_BUILD) +set(FREERDP_PC_LIBS "-lfreerdp -lfreerdp-client") +set(WINPR_PC_LIBS "-lwinpr") +if (WITH_SERVER) + set(FREERDP_PC_LIBS "${FREERDP_PC_LIBS} -lfreerdp-server") +endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp.pc.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp.pc @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/winpr.pc.in ${CMAKE_CURRENT_BINARY_DIR}/winpr.pc @ONLY) diff --git a/channels/audin/client/CMakeLists.txt b/channels/audin/client/CMakeLists.txt index e126eab0d..52b73e12e 100644 --- a/channels/audin/client/CMakeLists.txt +++ b/channels/audin/client/CMakeLists.txt @@ -27,12 +27,7 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} TRUE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-common freerdp-utils) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/audin/client/alsa/CMakeLists.txt b/channels/audin/client/alsa/CMakeLists.txt index e5d1dfaf1..892a263d2 100644 --- a/channels/audin/client/alsa/CMakeLists.txt +++ b/channels/audin/client/alsa/CMakeLists.txt @@ -27,12 +27,7 @@ add_channel_client_subsystem_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_N set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-codec freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${ALSA_LIBRARIES}) +set(${MODULE_PREFIX}_LIBS freerdp ${ALSA_LIBRARIES}) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/channels/audin/client/alsa/audin_alsa.c b/channels/audin/client/alsa/audin_alsa.c index 1b7c3b3e9..d75435407 100644 --- a/channels/audin/client/alsa/audin_alsa.c +++ b/channels/audin/client/alsa/audin_alsa.c @@ -72,8 +72,8 @@ static BOOL audin_alsa_set_params(AudinALSADevice* alsa, snd_pcm_t* capture_hand if ((error = snd_pcm_hw_params_malloc(&hw_params)) < 0) { - CLOG_ERR("snd_pcm_hw_params_malloc (%s)", - snd_strerror(error)); + WLog_ERR(TAG, "snd_pcm_hw_params_malloc (%s)", + snd_strerror(error)); return FALSE; } @@ -206,7 +206,7 @@ static void* audin_alsa_thread_func(void* arg) { if ((error = snd_pcm_open(&capture_handle, alsa->device_name, SND_PCM_STREAM_CAPTURE, 0)) < 0) { - CLOG_ERR("snd_pcm_open (%s)", snd_strerror(error)); + WLog_ERR(TAG, "snd_pcm_open (%s)", snd_strerror(error)); break; } @@ -226,7 +226,7 @@ static void* audin_alsa_thread_func(void* arg) } else if (error < 0) { - CLOG_ERR("snd_pcm_readi (%s)", snd_strerror(error)); + WLog_ERR(TAG, "snd_pcm_readi (%s)", snd_strerror(error)); break; } diff --git a/channels/audin/client/audin_main.c b/channels/audin/client/audin_main.c index c2b366a4d..15ee80d33 100644 --- a/channels/audin/client/audin_main.c +++ b/channels/audin/client/audin_main.c @@ -133,7 +133,7 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w DEBUG_DVC("NumFormats %d", NumFormats); if ((NumFormats < 1) || (NumFormats > 1000)) { - CLOG_ERR("bad NumFormats %d", NumFormats); + WLog_ERR(TAG, "bad NumFormats %d", NumFormats); return 1; } Stream_Seek_UINT32(s); /* cbSizeFormatsPacket */ @@ -262,8 +262,8 @@ static int audin_process_open(IWTSVirtualChannelCallback* pChannelCallback, wStr if (initialFormat >= (UINT32) callback->formats_count) { - CLOG_ERR("invalid format index %d (total %d)", - initialFormat, callback->formats_count); + WLog_ERR(TAG, "invalid format index %d (total %d)", + initialFormat, callback->formats_count); return 1; } @@ -293,8 +293,8 @@ static int audin_process_format_change(IWTSVirtualChannelCallback* pChannelCallb if (NewFormat >= (UINT32) callback->formats_count) { - CLOG_ERR("invalid format index %d (total %d)", - NewFormat, callback->formats_count); + WLog_ERR(TAG, "invalid format index %d (total %d)", + NewFormat, callback->formats_count); return 1; } @@ -340,7 +340,7 @@ static int audin_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, break; default: - CLOG_ERR("unknown MessageId=0x%x", MessageId); + WLog_ERR(TAG, "unknown MessageId=0x%x", MessageId); error = 1; break; } @@ -429,7 +429,7 @@ static void audin_register_device_plugin(IWTSPlugin* pPlugin, IAudinDevice* devi if (audin->device) { - CLOG_ERR("existing device, abort."); + WLog_ERR(TAG, "existing device, abort."); return; } @@ -454,7 +454,7 @@ static BOOL audin_load_device_plugin(IWTSPlugin* pPlugin, const char* name, ADDI if (entry(&entryPoints) != 0) { - CLOG_ERR("%s entry returns error.", name); + WLog_ERR(TAG, "%s entry returns error.", name); return FALSE; } @@ -613,7 +613,7 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) if (audin->device == NULL) { - CLOG_ERR("no sound device."); + WLog_ERR(TAG, "no sound device."); } return error; diff --git a/channels/audin/client/audin_main.h b/channels/audin/client/audin_main.h index 53c82b289..05dd637a0 100644 --- a/channels/audin/client/audin_main.h +++ b/channels/audin/client/audin_main.h @@ -30,10 +30,12 @@ #include #include +#define TAG CHANNELS_TAG("audin.client") + #ifdef WITH_DEBUG_DVC -#define DEBUG_DVC(fmt, ...) CLOG_CLASS(DVC, fmt, ## __VA_ARGS__) +#define DEBUG_DVC(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_DVC(fmt, ...) CLOG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_DVC(fmt, ...) do { } while (0) #endif #endif /* FREERDP_AUDIN_CLIENT_MAIN_H */ diff --git a/channels/audin/client/opensles/CMakeLists.txt b/channels/audin/client/opensles/CMakeLists.txt index ff872e69d..cd34e712b 100644 --- a/channels/audin/client/opensles/CMakeLists.txt +++ b/channels/audin/client/opensles/CMakeLists.txt @@ -28,14 +28,7 @@ add_channel_client_subsystem_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_N set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-codec freerdp-utils - ${OPENSLES_LIBRARIES} - ) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${OPENSLES_LIBRARIES}) +set(${MODULE_PREFIX}_LIBS freerdp ${OPENSLES_LIBRARIES}) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/channels/audin/client/opensles/audin_opensl_es.c b/channels/audin/client/opensles/audin_opensl_es.c index 936e453f8..54d601d20 100644 --- a/channels/audin/client/opensles/audin_opensl_es.c +++ b/channels/audin/client/opensles/audin_opensl_es.c @@ -96,7 +96,7 @@ static void* audin_opensles_thread_func(void* arg) int rc = android_RecIn(opensles->stream, buffer.s, raw_size); if (rc < 0) { - CLOG_ERR("android_RecIn %d", rc); + WLog_ERR(TAG, "android_RecIn %d", rc); continue; } @@ -250,9 +250,9 @@ static void audin_opensles_set_format(IAudinDevice* device, break; default: - CLOG_ERR("Encoding '%d' [%08X] not supported", - (format->wFormatTag), - format->wFormatTag); + WLog_ERR(TAG, "Encoding '%d' [%08X] not supported", + (format->wFormatTag), + format->wFormatTag); return; } @@ -309,7 +309,7 @@ static void audin_opensles_close(IAudinDevice* device) * ignore duplicate requests. */ if (!opensles->stopEvent) { - CLOG_ERR("[ERROR] function called without matching open."); + WLog_ERR(TAG, "[ERROR] function called without matching open."); return; } diff --git a/channels/audin/client/opensles/opensl_io.c b/channels/audin/client/opensles/opensl_io.c index 970ee8265..5b650be87 100644 --- a/channels/audin/client/opensles/opensl_io.c +++ b/channels/audin/client/opensles/opensl_io.c @@ -362,7 +362,7 @@ int android_RecIn(OPENSL_STREAM *p,short *buffer,int size) e = Queue_Dequeue(p->queue); if (!e) { - CLOG_ERR("[ERROR] got e=%p from queue", e); + WLog_ERR(TAG, "[ERROR] got e=%p from queue", e); return -1; } diff --git a/channels/audin/client/pulse/CMakeLists.txt b/channels/audin/client/pulse/CMakeLists.txt index f0ddd34a2..bdbaa5b5f 100644 --- a/channels/audin/client/pulse/CMakeLists.txt +++ b/channels/audin/client/pulse/CMakeLists.txt @@ -27,12 +27,7 @@ add_channel_client_subsystem_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_N set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-codec freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${PULSE_LIBRARY}) +set(${MODULE_PREFIX}_LIBS freerdp ${PULSE_LIBRARY}) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/channels/audin/client/pulse/audin_pulse.c b/channels/audin/client/pulse/audin_pulse.c index 6642b4701..90e9cdb7c 100644 --- a/channels/audin/client/pulse/audin_pulse.c +++ b/channels/audin/client/pulse/audin_pulse.c @@ -94,16 +94,16 @@ static BOOL audin_pulse_connect(IAudinDevice* device) if (pa_context_connect(pulse->context, NULL, 0, NULL)) { - CLOG_ERR("pa_context_connect failed (%d)", - pa_context_errno(pulse->context)); + WLog_ERR(TAG, "pa_context_connect failed (%d)", + pa_context_errno(pulse->context)); return FALSE; } pa_threaded_mainloop_lock(pulse->mainloop); if (pa_threaded_mainloop_start(pulse->mainloop) < 0) { pa_threaded_mainloop_unlock(pulse->mainloop); - CLOG_ERR("pa_threaded_mainloop_start failed (%d)", - pa_context_errno(pulse->context)); + WLog_ERR(TAG, "pa_threaded_mainloop_start failed (%d)", + pa_context_errno(pulse->context)); return FALSE; } for (;;) @@ -113,8 +113,8 @@ static BOOL audin_pulse_connect(IAudinDevice* device) break; if (!PA_CONTEXT_IS_GOOD(state)) { - CLOG_ERR("bad context state (%d)", - pa_context_errno(pulse->context)); + WLog_ERR(TAG, "bad context state (%d)", + pa_context_errno(pulse->context)); break; } pa_threaded_mainloop_wait(pulse->mainloop); @@ -297,7 +297,7 @@ static void audin_pulse_stream_request_callback(pa_stream* stream, size_t length */ if (pulse->buffer == NULL) { - /* CLOG_ERR( "%s: ignoring input, pulse buffer not ready.\n", __func__); */ + /* WLog_ERR(TAG, "%s: ignoring input, pulse buffer not ready.\n", __func__); */ return; } @@ -415,8 +415,8 @@ static void audin_pulse_open(IAudinDevice* device, AudinReceive receive, void* u &buffer_attr, PA_STREAM_ADJUST_LATENCY) < 0) { pa_threaded_mainloop_unlock(pulse->mainloop); - CLOG_ERR("pa_stream_connect_playback failed (%d)", - pa_context_errno(pulse->context)); + WLog_ERR(TAG, "pa_stream_connect_playback failed (%d)", + pa_context_errno(pulse->context)); return; } @@ -427,8 +427,8 @@ static void audin_pulse_open(IAudinDevice* device, AudinReceive receive, void* u break; if (!PA_STREAM_IS_GOOD(state)) { - CLOG_ERR("bad stream state (%d)", - pa_context_errno(pulse->context)); + WLog_ERR(TAG, "bad stream state (%d)", + pa_context_errno(pulse->context)); break; } pa_threaded_mainloop_wait(pulse->mainloop); @@ -512,7 +512,7 @@ int freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEnt if (!pulse->mainloop) { - CLOG_ERR("pa_threaded_mainloop_new failed"); + WLog_ERR(TAG, "pa_threaded_mainloop_new failed"); audin_pulse_free((IAudinDevice*) pulse); return 1; } @@ -521,7 +521,7 @@ int freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEnt if (!pulse->context) { - CLOG_ERR("pa_context_new failed"); + WLog_ERR(TAG, "pa_context_new failed"); audin_pulse_free((IAudinDevice*) pulse); return 1; } diff --git a/channels/audin/client/winmm/CMakeLists.txt b/channels/audin/client/winmm/CMakeLists.txt index 10db102ad..f4adaddc7 100644 --- a/channels/audin/client/winmm/CMakeLists.txt +++ b/channels/audin/client/winmm/CMakeLists.txt @@ -26,12 +26,7 @@ add_channel_client_subsystem_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_N set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winmm.lib) +set(${MODULE_PREFIX}_LIBS freerdp winmm.lib) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/channels/audin/server/CMakeLists.txt b/channels/audin/server/CMakeLists.txt index e23d33192..c093ec538 100644 --- a/channels/audin/server/CMakeLists.txt +++ b/channels/audin/server/CMakeLists.txt @@ -24,12 +24,7 @@ add_channel_server_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-codec freerdp-utils) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/audin/server/audin.c b/channels/audin/server/audin.c index 67f2e4c8f..3f6e1ab0c 100644 --- a/channels/audin/server/audin.c +++ b/channels/audin/server/audin.c @@ -36,6 +36,7 @@ #include #include +#define TAG CHANNELS_TAG("audin.server") #define MSG_SNDIN_VERSION 0x01 #define MSG_SNDIN_FORMATS 0x02 #define MSG_SNDIN_OPEN 0x03 @@ -386,7 +387,7 @@ static void* audin_server_thread_func(void* arg) break; default: - CLOG_ERR( "audin_server_thread_func: unknown MessageId %d\n", MessageId); + WLog_ERR(TAG, "audin_server_thread_func: unknown MessageId %d\n", MessageId); break; } } diff --git a/channels/client/CMakeLists.txt b/channels/client/CMakeLists.txt index 6b8aaf2c3..049bc7b0c 100644 --- a/channels/client/CMakeLists.txt +++ b/channels/client/CMakeLists.txt @@ -96,13 +96,7 @@ set(CLIENT_STATIC_ADDIN_TABLE "${CLIENT_STATIC_ADDIN_TABLE}\n\t{ NULL, NULL, NUL configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tables.c.in ${CMAKE_CURRENT_BINARY_DIR}/tables.c) -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp winpr) set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} PARENT_SCOPE) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) diff --git a/channels/cliprdr/client/CMakeLists.txt b/channels/cliprdr/client/CMakeLists.txt index f2f3c32ea..e23861515 100644 --- a/channels/cliprdr/client/CMakeLists.txt +++ b/channels/cliprdr/client/CMakeLists.txt @@ -27,12 +27,7 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) +set(${MODULE_PREFIX}_LIBS freerdp winpr) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/cliprdr/client/cliprdr_format.c b/channels/cliprdr/client/cliprdr_format.c index 1453f1cda..495bfa9d7 100644 --- a/channels/cliprdr/client/cliprdr_format.c +++ b/channels/cliprdr/client/cliprdr_format.c @@ -140,7 +140,7 @@ void cliprdr_process_short_format_names(cliprdrPlugin* cliprdr, wStream* s, UINT } if (num_formats * 36 != length) - CLOG_ERR("dataLen %d not divided by 36!", length); + WLog_ERR(TAG, "dataLen %d not divided by 36!", length); ascii = (flags & CB_ASCII_NAMES) ? TRUE : FALSE; diff --git a/channels/cliprdr/client/cliprdr_main.c b/channels/cliprdr/client/cliprdr_main.c index b612289cc..3642c7ddd 100644 --- a/channels/cliprdr/client/cliprdr_main.c +++ b/channels/cliprdr/client/cliprdr_main.c @@ -30,15 +30,12 @@ #include #include -#include #include #include #include "cliprdr_main.h" #include "cliprdr_format.h" -#define TAG CHANNELS_TAG("cliprdr.client") - #ifdef WITH_DEBUG_CLIPRDR static const char* const CB_MSG_TYPE_STRINGS[] = { @@ -86,7 +83,7 @@ void cliprdr_packet_send(cliprdrPlugin* cliprdr, wStream* s) Stream_Write_UINT32(s, dataLen); Stream_SetPosition(s, pos); #ifdef WITH_DEBUG_CLIPRDR - CLOG_DBG("Cliprdr Sending (%d bytes)\n", dataLen + 8); + WLog_DBG(TAG, "Cliprdr Sending (%d bytes)", dataLen + 8); winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), dataLen + 8); #endif svc_plugin_send((rdpSvcPlugin*) cliprdr, s); @@ -99,21 +96,21 @@ static void cliprdr_process_connect(rdpSvcPlugin* plugin) void cliprdr_print_general_capability_flags(UINT32 flags) { - CLOG_ERR("generalFlags (0x%08X) {\n", flags); + WLog_INFO(TAG, "generalFlags (0x%08X) {", flags); if (flags & CB_USE_LONG_FORMAT_NAMES) - CLOG_ERR("\tCB_USE_LONG_FORMAT_NAMES\n"); + WLog_INFO(TAG, "\tCB_USE_LONG_FORMAT_NAMES"); if (flags & CB_STREAM_FILECLIP_ENABLED) - CLOG_ERR("\tCB_STREAM_FILECLIP_ENABLED\n"); + WLog_INFO(TAG, "\tCB_STREAM_FILECLIP_ENABLED"); if (flags & CB_FILECLIP_NO_FILE_PATHS) - CLOG_ERR("\tCB_FILECLIP_NO_FILE_PATHS\n"); + WLog_INFO(TAG, "\tCB_FILECLIP_NO_FILE_PATHS"); if (flags & CB_CAN_LOCK_CLIPDATA) - CLOG_ERR("\tCB_CAN_LOCK_CLIPDATA\n"); + WLog_INFO(TAG, "\tCB_CAN_LOCK_CLIPDATA"); - CLOG_ERR("}\n"); + WLog_INFO(TAG, "}"); } static void cliprdr_process_general_capability(cliprdrPlugin* cliprdr, wStream* s) @@ -187,7 +184,7 @@ static void cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s, UINT16 cliprdr_process_general_capability(cliprdr, s); break; default: - CLOG_ERR("unknown cliprdr capability set: %d", capabilitySetType); + WLog_ERR(TAG, "unknown cliprdr capability set: %d", capabilitySetType); break; } } @@ -338,7 +335,7 @@ static void cliprdr_process_receive(rdpSvcPlugin* plugin, wStream* s) cliprdr_process_unlock_clipdata(cliprdr, s, dataLen, msgFlags); break; default: - CLOG_ERR("unknown msgType %d", msgType); + WLog_ERR(TAG, "unknown msgType %d", msgType); break; } } @@ -433,7 +430,7 @@ static void cliprdr_process_event(rdpSvcPlugin* plugin, wMessage* event) cliprdr_process_tempdir_event((cliprdrPlugin*) plugin, (RDP_CB_TEMPDIR_EVENT*) event); break; default: - CLOG_ERR("unknown event type %d", GetMessageType(event->id)); + WLog_ERR(TAG, "unknown event type %d", GetMessageType(event->id)); break; } diff --git a/channels/cliprdr/client/cliprdr_main.h b/channels/cliprdr/client/cliprdr_main.h index 29cc9b08d..4a8d60ae2 100644 --- a/channels/cliprdr/client/cliprdr_main.h +++ b/channels/cliprdr/client/cliprdr_main.h @@ -26,6 +26,8 @@ #include #include +#define TAG CHANNELS_TAG("cliprdr.client") + struct cliprdr_plugin { rdpSvcPlugin plugin; @@ -45,9 +47,9 @@ void cliprdr_packet_send(cliprdrPlugin* cliprdr, wStream* data_out); CliprdrClientContext* cliprdr_get_client_interface(cliprdrPlugin* cliprdr); #ifdef WITH_DEBUG_CLIPRDR -#define DEBUG_CLIPRDR(fmt, ...) CLOG_CLASS(CLIPRDR, fmt, ## __VA_ARGS__) +#define DEBUG_CLIPRDR(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_CLIPRDR(fmt, ...) CLOG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_CLIPRDR(fmt, ...) do { } while (0) #endif #endif /* __CLIPRDR_MAIN_H */ diff --git a/channels/cliprdr/server/CMakeLists.txt b/channels/cliprdr/server/CMakeLists.txt index 5abc3d511..0375f6d53 100644 --- a/channels/cliprdr/server/CMakeLists.txt +++ b/channels/cliprdr/server/CMakeLists.txt @@ -25,12 +25,7 @@ add_channel_server_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/cliprdr/server/cliprdr_main.c b/channels/cliprdr/server/cliprdr_main.c index a72f014a4..4d20e4ada 100644 --- a/channels/cliprdr/server/cliprdr_main.c +++ b/channels/cliprdr/server/cliprdr_main.c @@ -70,9 +70,7 @@ static int cliprdr_server_send_capabilities(CliprdrServerContext* context) UINT32 generalFlags; CLIPRDR_HEADER header; ULONG written; - - CLOG_DBG("CliprdrServerSendCapabilities\n"); - + WLog_DBG(TAG, "CliprdrServerSendCapabilities"); header.msgType = CB_CLIP_CAPS; header.msgFlags = 0; header.dataLen = 16; @@ -111,9 +109,7 @@ static int cliprdr_server_send_monitor_ready(CliprdrServerContext* context) BOOL status; CLIPRDR_HEADER header; ULONG written; - - CLOG_DBG("CliprdrServerSendMonitorReady\n"); - + WLog_DBG(TAG, "CliprdrServerSendMonitorReady"); header.msgType = CB_MONITOR_READY; header.msgFlags = 0; header.dataLen = 0; @@ -139,9 +135,7 @@ static int cliprdr_server_send_format_list_response(CliprdrServerContext* contex BOOL status; CLIPRDR_HEADER header; ULONG written; - - CLOG_DBG("CliprdrServerSendFormatListResponse\n"); - + WLog_DBG(TAG, "CliprdrServerSendFormatListResponse"); header.msgType = CB_FORMAT_LIST_RESPONSE; header.msgFlags = CB_RESPONSE_OK; header.dataLen = 0; @@ -206,10 +200,8 @@ static int cliprdr_server_receive_temporary_directory(CliprdrServerContext* cont return -1; ConvertFromUnicode(CP_UTF8, 0, wszTempDir, -1, - &(context->priv->ClientTemporaryDirectory), 0, NULL, NULL); - - CLOG_DBG("ClientTemporaryDirectory: %s\n", context->priv->ClientTemporaryDirectory); - + &(context->priv->ClientTemporaryDirectory), 0, NULL, NULL); + WLog_DBG(TAG, "ClientTemporaryDirectory: %s", context->priv->ClientTemporaryDirectory); return 0; } @@ -252,9 +244,7 @@ static int cliprdr_server_receive_long_format_list(CliprdrServerContext* context WCHAR* end; int length; int position; - - CLOG_DBG("%s\n", __FUNCTION__); - + WLog_DBG(TAG, ""); position = Stream_GetPosition(s); Stream_SetPosition(s, Stream_Length(s)); end = (WCHAR*) Stream_Pointer(s); @@ -306,10 +296,10 @@ static int cliprdr_server_receive_long_format_list(CliprdrServerContext* context for (i = 0; i < context->priv->ClientFormatNameCount; i++) { - CLOG_DBG("Format %d: Id: 0x%04X Name: %s Length: %d\n", i, - context->priv->ClientFormatNames[i].id, - context->priv->ClientFormatNames[i].name, - context->priv->ClientFormatNames[i].length); + WLog_DBG(TAG, "Format %d: Id: 0x%04X Name: %s Length: %d", i, + context->priv->ClientFormatNames[i].id, + context->priv->ClientFormatNames[i].name, + context->priv->ClientFormatNames[i].length); } return 0; @@ -317,7 +307,7 @@ static int cliprdr_server_receive_long_format_list(CliprdrServerContext* context static int cliprdr_server_receive_short_format_list(CliprdrServerContext* context, wStream* s, CLIPRDR_HEADER* header) { - CLOG_DBG("%s: unimplemented\n", __FUNCTION__); + WLog_ERR(TAG, "%s: unimplemented"); return 0; } @@ -341,8 +331,8 @@ static int cliprdr_server_receive_format_list(CliprdrServerContext* context, wSt static int cliprdr_server_receive_pdu(CliprdrServerContext* context, wStream* s, CLIPRDR_HEADER* header) { - CLOG_DBG("CliprdrServerReceivePdu: msgType: %d msgFlags: 0x%08X dataLen: %d\n", - header->msgType, header->msgFlags, header->dataLen); + WLog_DBG(TAG, "CliprdrServerReceivePdu: msgType: %d msgFlags: 0x%08X dataLen: %d", + header->msgType, header->msgFlags, header->dataLen); switch (header->msgType) { @@ -380,7 +370,7 @@ static int cliprdr_server_receive_pdu(CliprdrServerContext* context, wStream* s, break; default: - CLOG_DBG("Unexpected clipboard PDU type: %d\n", header->msgType); + WLog_DBG(TAG, "Unexpected clipboard PDU type: %d", header->msgType); break; } diff --git a/channels/cliprdr/server/cliprdr_main.h b/channels/cliprdr/server/cliprdr_main.h index 71165045b..fd026336b 100644 --- a/channels/cliprdr/server/cliprdr_main.h +++ b/channels/cliprdr/server/cliprdr_main.h @@ -25,7 +25,9 @@ #include #include +#include +#define TAG CHANNELS_TAG("cliprdr.server") #define CLIPRDR_HEADER_LENGTH 8 struct _cliprdr_server_private diff --git a/channels/disp/client/CMakeLists.txt b/channels/disp/client/CMakeLists.txt index 377e65153..328dc3cb6 100644 --- a/channels/disp/client/CMakeLists.txt +++ b/channels/disp/client/CMakeLists.txt @@ -27,12 +27,7 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} TRUE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-common freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/channels/disp/client/disp_main.c b/channels/disp/client/disp_main.c index 283ef4b9d..0c7fac4da 100644 --- a/channels/disp/client/disp_main.c +++ b/channels/disp/client/disp_main.c @@ -101,7 +101,7 @@ int disp_send_display_control_monitor_layout_pdu(DISP_CHANNEL_CALLBACK* callback Stream_Write_UINT32(s, NumMonitors); /* NumMonitors (4 bytes) */ - //CLOG_ERR( "NumMonitors: %d\n", NumMonitors); + //WLog_ERR(TAG, "NumMonitors: %d\n", NumMonitors); for (index = 0; index < NumMonitors; index++) { @@ -125,14 +125,14 @@ int disp_send_display_control_monitor_layout_pdu(DISP_CHANNEL_CALLBACK* callback Stream_Write_UINT32(s, Monitors[index].DeviceScaleFactor); /* DeviceScaleFactor (4 bytes) */ #if 0 - CLOG_ERR( "\t: Flags: 0x%04X\n", Monitors[index].Flags); - CLOG_ERR( "\t: Left: %d\n", Monitors[index].Left); - CLOG_ERR( "\t: Top: %d\n", Monitors[index].Top); - CLOG_ERR( "\t: Width: %d\n", Monitors[index].Width); - CLOG_ERR( "\t: Height: %d\n", Monitors[index].Height); - CLOG_ERR( "\t: PhysicalWidth: %d\n", Monitors[index].PhysicalWidth); - CLOG_ERR( "\t: PhysicalHeight: %d\n", Monitors[index].PhysicalHeight); - CLOG_ERR( "\t: Orientation: %d\n", Monitors[index].Orientation); + WLog_DBG(TAG, "\t: Flags: 0x%04X\n", Monitors[index].Flags); + WLog_DBG(TAG, "\t: Left: %d\n", Monitors[index].Left); + WLog_DBG(TAG, "\t: Top: %d\n", Monitors[index].Top); + WLog_DBG(TAG, "\t: Width: %d\n", Monitors[index].Width); + WLog_DBG(TAG, "\t: Height: %d\n", Monitors[index].Height); + WLog_DBG(TAG, "\t: PhysicalWidth: %d\n", Monitors[index].PhysicalWidth); + WLog_DBG(TAG, "\t: PhysicalHeight: %d\n", Monitors[index].PhysicalHeight); + WLog_DBG(TAG, "\t: Orientation: %d\n", Monitors[index].Orientation); #endif } @@ -157,8 +157,7 @@ int disp_recv_display_control_caps_pdu(DISP_CHANNEL_CALLBACK* callback, wStream* Stream_Read_UINT32(s, disp->MaxNumMonitors); /* MaxNumMonitors (4 bytes) */ Stream_Read_UINT32(s, disp->MaxMonitorAreaFactorA); /* MaxMonitorAreaFactorA (4 bytes) */ Stream_Read_UINT32(s, disp->MaxMonitorAreaFactorB); /* MaxMonitorAreaFactorB (4 bytes) */ - - //CLOG_ERR( "DisplayControlCapsPdu: MaxNumMonitors: %d MaxMonitorWidth: %d MaxMonitorHeight: %d\n", + //WLog_ERR(TAG, "DisplayControlCapsPdu: MaxNumMonitors: %d MaxMonitorWidth: %d MaxMonitorHeight: %d\n", // disp->MaxNumMonitors, disp->MaxMonitorWidth, disp->MaxMonitorHeight); return 0; @@ -175,7 +174,7 @@ int disp_recv_pdu(DISP_CHANNEL_CALLBACK* callback, wStream* s) Stream_Read_UINT32(s, type); /* Type (4 bytes) */ Stream_Read_UINT32(s, length); /* Length (4 bytes) */ - //CLOG_ERR( "Type: %d Length: %d\n", type, length); + //WLog_ERR(TAG, "Type: %d Length: %d\n", type, length); switch (type) { diff --git a/channels/drdynvc/client/CMakeLists.txt b/channels/drdynvc/client/CMakeLists.txt index d8e3d02cd..27e45a547 100644 --- a/channels/drdynvc/client/CMakeLists.txt +++ b/channels/drdynvc/client/CMakeLists.txt @@ -28,13 +28,6 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client") diff --git a/channels/drdynvc/client/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c index 3b885097d..2662f8be7 100644 --- a/channels/drdynvc/client/drdynvc_main.c +++ b/channels/drdynvc/client/drdynvc_main.c @@ -130,7 +130,7 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, BYTE* data, UIN if (status != CHANNEL_RC_OK) { drdynvc->channel_error = status; - CLOG_ERR("VirtualChannelWrite failed %d", status); + WLog_ERR(TAG, "VirtualChannelWrite failed %d", status); return 1; } @@ -145,7 +145,7 @@ int drdynvc_push_event(drdynvcPlugin* drdynvc, wMessage* event) if (status != CHANNEL_RC_OK) { - CLOG_ERR("pVirtualChannelEventPush failed %d", status); + WLog_ERR(TAG, "pVirtualChannelEventPush failed %d", status); return 1; } @@ -165,7 +165,7 @@ static int drdynvc_send_capability_response(drdynvcPlugin* drdynvc) if (status != CHANNEL_RC_OK) { - CLOG_ERR("VirtualChannelWrite failed %d", status); + WLog_ERR(TAG, "VirtualChannelWrite failed %d", status); return 1; } @@ -270,7 +270,7 @@ static int drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cb if (status != CHANNEL_RC_OK) { - CLOG_ERR("VirtualChannelWrite failed %d", status); + WLog_ERR(TAG, "VirtualChannelWrite failed %d", status); return 1; } @@ -329,7 +329,7 @@ static int drdynvc_process_close_request(drdynvcPlugin* drdynvc, int Sp, int cbC if (error != CHANNEL_RC_OK) { - CLOG_ERR("VirtualChannelWrite failed %d", error); + WLog_ERR(TAG, "VirtualChannelWrite failed %d", error); return 1; } @@ -376,7 +376,7 @@ static void drdynvc_process_receive(rdpSvcPlugin* plugin, wStream* s) break; default: - CLOG_ERR("unknown drdynvc cmd 0x%x", Cmd); + WLog_ERR(TAG, "unknown drdynvc cmd 0x%x", Cmd); break; } } diff --git a/channels/drdynvc/client/drdynvc_types.h b/channels/drdynvc/client/drdynvc_types.h index 2010cab65..3160b8f35 100644 --- a/channels/drdynvc/client/drdynvc_types.h +++ b/channels/drdynvc/client/drdynvc_types.h @@ -28,10 +28,11 @@ #include #include +#define TAG CHANNELS_TAG("dvcman.client") #ifdef WITH_DEBUG_DVC -#define DEBUG_DVC(fmt, ...) CLOG_CLASS(DVC, fmt, ## __VA_ARGS__) +#define DEBUG_DVC(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_DVC(fmt, ...) CLOG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_DVC(fmt, ...) do { } while (0) #endif #endif diff --git a/channels/drdynvc/client/dvcman.c b/channels/drdynvc/client/dvcman.c index f9e4873b8..bef066be7 100644 --- a/channels/drdynvc/client/dvcman.c +++ b/channels/drdynvc/client/dvcman.c @@ -71,7 +71,7 @@ static int dvcman_create_listener(IWTSVirtualChannelManager* pChannelMgr, } else { - CLOG_ERR("Maximum DVC listener number reached."); + WLog_WARN(TAG, "Maximum DVC listener number reached."); return 1; } } @@ -89,7 +89,7 @@ static int dvcman_push_event(IWTSVirtualChannelManager* pChannelMgr, wMessage* p } else { - CLOG_ERR("event_type %d push failed.", GetMessageType(pEvent->id)); + WLog_ERR(TAG, "event_type %d push failed.", GetMessageType(pEvent->id)); } return status; @@ -108,7 +108,7 @@ static int dvcman_register_plugin(IDRDYNVC_ENTRY_POINTS* pEntryPoints, const cha } else { - CLOG_ERR("Maximum DVC plugin number reached."); + WLog_WARN(TAG, "Maximum DVC plugin number reached."); return 1; } } @@ -217,9 +217,7 @@ int dvcman_load_addin(IWTSVirtualChannelManager* pChannelMgr, ADDIN_ARGV* args, { DVCMAN_ENTRY_POINTS entryPoints; PDVC_PLUGIN_ENTRY pDVCPluginEntry = NULL; - - CLOG_ERR( "Loading Dynamic Virtual Channel %s\n", args->argv[0]); - + WLog_INFO(TAG, "Loading Dynamic Virtual Channel %s", args->argv[0]); pDVCPluginEntry = (PDVC_PLUGIN_ENTRY) freerdp_load_channel_addin_entry(args->argv[0], NULL, NULL, FREERDP_ADDIN_CHANNEL_DYNAMIC); @@ -388,8 +386,7 @@ int dvcman_create_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 Channel } else { - CLOG_ERR("channel rejected by plugin"); - + WLog_ERR(TAG, "channel rejected by plugin"); free(channel); return 1; } @@ -409,7 +406,7 @@ int dvcman_open_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelId if (!channel) { - CLOG_ERR("ChannelId %d not found!", ChannelId); + WLog_ERR(TAG, "ChannelId %d not found!", ChannelId); return 1; } @@ -434,7 +431,7 @@ int dvcman_close_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelI if (!channel) { - CLOG_ERR("ChannelId %d not found!", ChannelId); + WLog_ERR(TAG, "ChannelId %d not found!", ChannelId); return 1; } @@ -468,7 +465,7 @@ int dvcman_receive_channel_data_first(IWTSVirtualChannelManager* pChannelMgr, UI if (!channel) { - CLOG_ERR("ChannelId %d not found!", ChannelId); + WLog_ERR(TAG, "ChannelId %d not found!", ChannelId); return 1; } @@ -491,7 +488,7 @@ int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 C if (!channel) { - CLOG_ERR("ChannelId %d not found!", ChannelId); + WLog_ERR(TAG, "ChannelId %d not found!", ChannelId); return 1; } @@ -500,7 +497,7 @@ int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 C /* Fragmented data */ if (Stream_GetPosition(channel->dvc_data) + dataSize > (UINT32) Stream_Capacity(channel->dvc_data)) { - CLOG_ERR("data exceeding declared length!"); + WLog_ERR(TAG, "data exceeding declared length!"); Stream_Release(channel->dvc_data); channel->dvc_data = NULL; return 1; diff --git a/channels/drdynvc/server/CMakeLists.txt b/channels/drdynvc/server/CMakeLists.txt index f31e55815..4e09ba49d 100644 --- a/channels/drdynvc/server/CMakeLists.txt +++ b/channels/drdynvc/server/CMakeLists.txt @@ -25,12 +25,7 @@ add_channel_server_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/drive/client/CMakeLists.txt b/channels/drive/client/CMakeLists.txt index 82bbc70f7..eb09d1a91 100644 --- a/channels/drive/client/CMakeLists.txt +++ b/channels/drive/client/CMakeLists.txt @@ -33,14 +33,7 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} TRUE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} winpr freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/echo/client/CMakeLists.txt b/channels/echo/client/CMakeLists.txt index 54417f093..47ac1bf8d 100644 --- a/channels/echo/client/CMakeLists.txt +++ b/channels/echo/client/CMakeLists.txt @@ -27,12 +27,7 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} TRUE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-common freerdp-utils) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/echo/client/echo_main.h b/channels/echo/client/echo_main.h index fc7d88de6..1ce6a1f1d 100644 --- a/channels/echo/client/echo_main.h +++ b/channels/echo/client/echo_main.h @@ -29,10 +29,11 @@ #include #include +#define DVC_TAG CHANNELS_TAG("echo.client") #ifdef WITH_DEBUG_DVC -#define DEBUG_DVC(fmt, ...) CLOG_CLASS(DVC, fmt, ## __VA_ARGS__) +#define DEBUG_DVC(fmt, ...) WLog_DBG(DVC_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_DVC(fmt, ...) CLOG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_DVC(fmt, ...) do { } while (0) #endif #endif /* __ECHO_MAIN_H */ diff --git a/channels/echo/server/CMakeLists.txt b/channels/echo/server/CMakeLists.txt index 47fb633e6..8a90d903a 100644 --- a/channels/echo/server/CMakeLists.txt +++ b/channels/echo/server/CMakeLists.txt @@ -24,12 +24,7 @@ add_channel_server_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils freerdp-core) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/encomsp/client/encomsp_main.c b/channels/encomsp/client/encomsp_main.c index 4752c028d..cb5d67c6b 100644 --- a/channels/encomsp/client/encomsp_main.c +++ b/channels/encomsp/client/encomsp_main.c @@ -83,7 +83,7 @@ int encomsp_virtual_channel_write(encomspPlugin* encomsp, wStream* s) return -1; #if 0 - printf("EncomspWrite (%d)\n", Stream_Length(s)); + WLog_INFO(TAG, "EncomspWrite (%d)", Stream_Length(s)); winpr_HexDump(Stream_Buffer(s), Stream_Length(s)); #endif @@ -92,7 +92,7 @@ int encomsp_virtual_channel_write(encomspPlugin* encomsp, wStream* s) if (status != CHANNEL_RC_OK) { - fprintf(stderr, "encomsp_virtual_channel_write: VirtualChannelWrite failed %d\n", status); + WLog_ERR(TAG, "encomsp_virtual_channel_write: VirtualChannelWrite failed %d", status); return -1; } @@ -591,7 +591,7 @@ static int encomsp_process_receive(encomspPlugin* encomsp, wStream* s) if (encomsp_read_header(s, &header) < 0) return -1; - //CLOG_DBG("EncomspReceive: Type: %d Length: %d\n", header.Type, header.Length); + //WLog_DBG(TAG, "EncomspReceive: Type: %d Length: %d", header.Type, header.Length); switch (header.Type) { @@ -723,7 +723,7 @@ int encomsp_send(encomspPlugin* encomsp, wStream* s) if (status != CHANNEL_RC_OK) { Stream_Free(s, TRUE); - CLOG_ERR( "encomsp_send: VirtualChannelWrite failed %d\n", status); + WLog_ERR(TAG, "encomsp_send: VirtualChannelWrite failed %d", status); } return status; @@ -755,7 +755,7 @@ static void encomsp_virtual_channel_event_data_received(encomspPlugin* encomsp, { if (Stream_Capacity(data_in) != Stream_GetPosition(data_in)) { - CLOG_ERR( "encomsp_plugin_process_received: read error\n"); + WLog_ERR(TAG, "encomsp_plugin_process_received: read error"); } encomsp->data_in = NULL; @@ -775,7 +775,7 @@ static VOID VCAPITYPE encomsp_virtual_channel_open_event(DWORD openHandle, UINT if (!encomsp) { - CLOG_ERR( "encomsp_virtual_channel_open_event: error no match\n"); + WLog_ERR(TAG, "encomsp_virtual_channel_open_event: error no match"); return; } @@ -835,7 +835,7 @@ static void encomsp_virtual_channel_event_connected(encomspPlugin* encomsp, LPVO if (status != CHANNEL_RC_OK) { - CLOG_ERR( "encomsp_virtual_channel_event_connected: open failed: status: %d\n", status); + WLog_ERR(TAG, "encomsp_virtual_channel_event_connected: open failed: status: %d", status); return; } @@ -873,7 +873,7 @@ static VOID VCAPITYPE encomsp_virtual_channel_init_event(LPVOID pInitHandle, UIN if (!encomsp) { - CLOG_ERR( "encomsp_virtual_channel_init_event: error no match\n"); + WLog_ERR(TAG, "encomsp_virtual_channel_init_event: error no match"); return; } diff --git a/channels/encomsp/client/encomsp_main.h b/channels/encomsp/client/encomsp_main.h index d67c92fac..3da59b883 100644 --- a/channels/encomsp/client/encomsp_main.h +++ b/channels/encomsp/client/encomsp_main.h @@ -27,11 +27,14 @@ #include #include +#include #include #include #include +#define TAG CHANNELS_TAG("encomsp.client") + struct encomsp_plugin { CHANNEL_DEF channelDef; diff --git a/channels/encomsp/server/encomsp_main.c b/channels/encomsp/server/encomsp_main.c index 18e8c44bf..b3689f598 100644 --- a/channels/encomsp/server/encomsp_main.c +++ b/channels/encomsp/server/encomsp_main.c @@ -25,8 +25,12 @@ #include #include +#include + #include "encomsp_main.h" +#define TAG CHANNELS_TAG("encomsp.server") + static int encomsp_read_header(wStream* s, ENCOMSP_ORDER_HEADER* header) { if (Stream_GetRemainingLength(s) < ENCOMSP_ORDER_HEADER_SIZE) @@ -116,7 +120,7 @@ static int encomsp_server_receive_pdu(EncomspServerContext* context, wStream* s) if (encomsp_read_header(s, &header) < 0) return -1; - printf("EncomspReceive: Type: %d Length: %d\n", header.Type, header.Length); + WLog_INFO(TAG, "EncomspReceive: Type: %d Length: %d", header.Type, header.Length); switch (header.Type) { diff --git a/channels/parallel/client/CMakeLists.txt b/channels/parallel/client/CMakeLists.txt index 84af28326..91f649a0b 100644 --- a/channels/parallel/client/CMakeLists.txt +++ b/channels/parallel/client/CMakeLists.txt @@ -24,14 +24,7 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} TRUE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} freerdp winpr) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/printer/client/CMakeLists.txt b/channels/printer/client/CMakeLists.txt index 5b055b667..f8bee2e36 100644 --- a/channels/printer/client/CMakeLists.txt +++ b/channels/printer/client/CMakeLists.txt @@ -40,12 +40,7 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} TRUE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp) if(WITH_CUPS) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${CUPS_LIBRARIES}) diff --git a/channels/printer/client/printer_win.h b/channels/printer/client/printer_win.h index 68c9e7995..7f0660af5 100644 --- a/channels/printer/client/printer_win.h +++ b/channels/printer/client/printer_win.h @@ -20,17 +20,20 @@ #ifndef __PRINTER_WIN_H #define __PRINTER_WIN_H +#include + rdpPrinterDriver* printer_win_get_driver(void); +#define PRINTER_TAG CHANNELS_TAG("printer.client") #ifdef WITH_DEBUG_WINPR -#define DEBUG_WINPR(fmt, ...) CLOG_CLASS(WINPR, fmt, ## __VA_ARGS__) +#define DEBUG_WINPR(fmt, ...) WLog_DBG(PRINTER_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_WINPR(fmt, ...) CLOG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_WINPR(fmt, ...) do { } while (0) #endif #endif #ifdef WIN32 #define snprintf _snprintf -#endif +#endif diff --git a/channels/rail/client/CMakeLists.txt b/channels/rail/client/CMakeLists.txt index b44ce1614..e6b1bc4f8 100644 --- a/channels/rail/client/CMakeLists.txt +++ b/channels/rail/client/CMakeLists.txt @@ -29,12 +29,7 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/rail/client/rail_orders.c b/channels/rail/client/rail_orders.c index 6e5e0428c..eb3b371c5 100644 --- a/channels/rail/client/rail_orders.c +++ b/channels/rail/client/rail_orders.c @@ -523,7 +523,7 @@ BOOL rail_order_recv(railPlugin* rail, wStream* s) } default: - CLOG_ERR( "Unknown RAIL PDU order reveived."); + WLog_ERR(TAG, "Unknown RAIL PDU order reveived."); break; } diff --git a/channels/rail/client/rail_orders.h b/channels/rail/client/rail_orders.h index 217c967d4..78e6a0762 100644 --- a/channels/rail/client/rail_orders.h +++ b/channels/rail/client/rail_orders.h @@ -21,8 +21,11 @@ #ifndef __RAIL_ORDERS_H #define __RAIL_ORDERS_H +#include #include "rail_main.h" +#define TAG CHANNELS_TAG("rail.client") + BOOL rail_read_server_exec_result_order(wStream* s, RAIL_EXEC_RESULT_ORDER* exec_result); BOOL rail_read_server_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam); BOOL rail_read_server_minmaxinfo_order(wStream* s, RAIL_MINMAXINFO_ORDER* minmaxinfo); diff --git a/channels/rdpdr/client/CMakeLists.txt b/channels/rdpdr/client/CMakeLists.txt index d96a0eb5d..39e05a505 100644 --- a/channels/rdpdr/client/CMakeLists.txt +++ b/channels/rdpdr/client/CMakeLists.txt @@ -31,14 +31,7 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} winpr freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/rdpdr/client/devman.c b/channels/rdpdr/client/devman.c index 784117499..35fb742b9 100644 --- a/channels/rdpdr/client/devman.c +++ b/channels/rdpdr/client/devman.c @@ -123,7 +123,7 @@ BOOL devman_load_device_service(DEVMAN* devman, RDPDR_DEVICE* device) if (!ServiceName) return FALSE; - CLOG_ERR( "Loading device service %s (static)\n", ServiceName); + WLog_INFO(TAG, "Loading device service %s (static)", ServiceName); entry = (PDEVICE_SERVICE_ENTRY) freerdp_load_channel_addin_entry(ServiceName, NULL, "DeviceServiceEntry", 0); if (!entry) diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index 4d053c14e..14ee6d78f 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -452,7 +452,7 @@ static void* drive_hotplug_thread_func(void* arg) if (mfd < 0) { - CLOG_ERR( "ERROR: Unable to open /proc/mounts."); + WLog_ERR(TAG, "ERROR: Unable to open /proc/mounts."); return NULL; } @@ -662,9 +662,8 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use Stream_Write(s, Stream_Buffer(device->data), data_len); count++; - - CLOG_ERR( "registered device #%d: %s (type=%d id=%d)\n", - count, device->name, device->type, device->id); + WLog_INFO(TAG, "registered device #%d: %s (type=%d id=%d)\n", + count, device->name, device->type, device->id); } } @@ -846,7 +845,7 @@ int rdpdr_send(rdpdrPlugin* rdpdr, wStream* s) if (status != CHANNEL_RC_OK) { Stream_Free(s, TRUE); - CLOG_ERR( "rdpdr_send: VirtualChannelWrite failed %d\n", status); + WLog_ERR(TAG, "rdpdr_send: VirtualChannelWrite failed %d\n", status); } return status; @@ -884,7 +883,7 @@ static void rdpdr_virtual_channel_event_data_received(rdpdrPlugin* rdpdr, { if (Stream_Capacity(data_in) != Stream_GetPosition(data_in)) { - CLOG_ERR( "svc_plugin_process_received: read error\n"); + WLog_ERR(TAG, "svc_plugin_process_received: read error\n"); } rdpdr->data_in = NULL; @@ -904,7 +903,7 @@ static VOID VCAPITYPE rdpdr_virtual_channel_open_event(DWORD openHandle, UINT ev if (!rdpdr) { - CLOG_ERR( "rdpdr_virtual_channel_open_event: error no match\n"); + WLog_ERR(TAG, "rdpdr_virtual_channel_open_event: error no match\n"); return; } @@ -964,7 +963,7 @@ static void rdpdr_virtual_channel_event_connected(rdpdrPlugin* rdpdr, LPVOID pDa if (status != CHANNEL_RC_OK) { - CLOG_ERR( "rdpdr_virtual_channel_event_connected: open failed: status: %d\n", status); + WLog_ERR(TAG, "rdpdr_virtual_channel_event_connected: open failed: status: %d\n", status); return; } @@ -1010,7 +1009,7 @@ static VOID VCAPITYPE rdpdr_virtual_channel_init_event(LPVOID pInitHandle, UINT if (!rdpdr) { - CLOG_ERR( "rdpdr_virtual_channel_init_event: error no match\n"); + WLog_ERR(TAG, "rdpdr_virtual_channel_init_event: error no match\n"); return; } diff --git a/channels/rdpdr/client/rdpdr_main.h b/channels/rdpdr/client/rdpdr_main.h index c29846c80..f74a135f4 100644 --- a/channels/rdpdr/client/rdpdr_main.h +++ b/channels/rdpdr/client/rdpdr_main.h @@ -32,6 +32,9 @@ #include #include +#include + +#define TAG CHANNELS_TAG("rdprd.client") typedef struct rdpdr_plugin rdpdrPlugin; diff --git a/channels/rdpdr/server/CMakeLists.txt b/channels/rdpdr/server/CMakeLists.txt index 17a18967e..32529e5bf 100644 --- a/channels/rdpdr/server/CMakeLists.txt +++ b/channels/rdpdr/server/CMakeLists.txt @@ -25,12 +25,7 @@ add_channel_server_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/rdpdr/server/rdpdr_main.c b/channels/rdpdr/server/rdpdr_main.c index 9c342fa08..71aab4f75 100644 --- a/channels/rdpdr/server/rdpdr_main.c +++ b/channels/rdpdr/server/rdpdr_main.c @@ -38,7 +38,7 @@ static int rdpdr_server_send_announce_request(RdpdrServerContext* context) BOOL status; RDPDR_HEADER header; ULONG written; - CLOG_DBG("RdpdrServerSendAnnounceRequest\n"); + WLog_DBG(TAG, "RdpdrServerSendAnnounceRequest"); header.Component = RDPDR_CTYP_CORE; header.PacketId = PAKID_CORE_SERVER_ANNOUNCE; s = Stream_New(NULL, RDPDR_HEADER_LENGTH + 8); @@ -61,7 +61,7 @@ static int rdpdr_server_receive_announce_response(RdpdrServerContext* context, w Stream_Read_UINT16(s, VersionMajor); /* VersionMajor (2 bytes) */ Stream_Read_UINT16(s, VersionMinor); /* VersionMinor (2 bytes) */ Stream_Read_UINT32(s, ClientId); /* ClientId (4 bytes) */ - CLOG_DBG("Client Announce Response: VersionMajor: 0x%04X VersionMinor: 0x%04X ClientId: 0x%04X\n", + WLog_DBG(TAG, "Client Announce Response: VersionMajor: 0x%04X VersionMinor: 0x%04X ClientId: 0x%04X", VersionMajor, VersionMinor, ClientId); context->priv->ClientId = ClientId; return 0; @@ -97,7 +97,7 @@ static int rdpdr_server_receive_client_name_request(RdpdrServerContext* context, } Stream_Seek(s, ComputerNameLen); - CLOG_DBG("ClientComputerName: %s\n", context->priv->ClientComputerName); + WLog_DBG(TAG, "ClientComputerName: %s", context->priv->ClientComputerName); return 0; } @@ -262,7 +262,7 @@ static int rdpdr_server_send_core_capability_request(RdpdrServerContext* context RDPDR_HEADER header; UINT16 numCapabilities; ULONG written; - CLOG_DBG("RdpdrServerSendCoreCapabilityRequest\n"); + WLog_DBG(TAG, "RdpdrServerSendCoreCapabilityRequest"); header.Component = RDPDR_CTYP_CORE; header.PacketId = PAKID_CORE_SERVER_CAPABILITY; numCapabilities = 5; @@ -317,7 +317,7 @@ static int rdpdr_server_receive_core_capability_response(RdpdrServerContext* con break; default: - CLOG_DBG("Unknown capabilityType %d\n", capabilityHeader.CapabilityType); + WLog_DBG(TAG, "Unknown capabilityType %d", capabilityHeader.CapabilityType); Stream_Seek(s, capabilityHeader.CapabilityLength - RDPDR_CAPABILITY_HEADER_LENGTH); break; } @@ -332,7 +332,7 @@ static int rdpdr_server_send_client_id_confirm(RdpdrServerContext* context) BOOL status; RDPDR_HEADER header; ULONG written; - CLOG_DBG("RdpdrServerSendClientIdConfirm\n"); + WLog_DBG(TAG, "RdpdrServerSendClientIdConfirm"); header.Component = RDPDR_CTYP_CORE; header.PacketId = PAKID_CORE_CLIENTID_CONFIRM; s = Stream_New(NULL, RDPDR_HEADER_LENGTH + 8); @@ -357,7 +357,7 @@ static int rdpdr_server_receive_device_list_announce_request(RdpdrServerContext* UINT32 DeviceDataLength; PreferredDosName[8] = 0; Stream_Read_UINT32(s, DeviceCount); /* DeviceCount (4 bytes) */ - CLOG_DBG("%s: DeviceCount: %d\n", __FUNCTION__, DeviceCount); + WLog_DBG(TAG, "DeviceCount: %d", DeviceCount); for (i = 0; i < DeviceCount; i++) { @@ -365,7 +365,7 @@ static int rdpdr_server_receive_device_list_announce_request(RdpdrServerContext* Stream_Read_UINT32(s, DeviceId); /* DeviceId (4 bytes) */ Stream_Read(s, PreferredDosName, 8); /* PreferredDosName (8 bytes) */ Stream_Read_UINT32(s, DeviceDataLength); /* DeviceDataLength (4 bytes) */ - CLOG_DBG("Device %d Name: %s Id: 0x%04X DataLength: %d\n", + WLog_DBG(TAG, "Device %d Name: %s Id: 0x%04X DataLength: %d", i, PreferredDosName, DeviceId, DeviceDataLength); switch (DeviceId) @@ -401,7 +401,7 @@ static int rdpdr_server_send_user_logged_on(RdpdrServerContext* context) BOOL status; RDPDR_HEADER header; ULONG written; - CLOG_DBG("%s\n", __FUNCTION__); + WLog_DBG(TAG, "%s"); header.Component = RDPDR_CTYP_CORE; header.PacketId = PAKID_CORE_USER_LOGGEDON; s = Stream_New(NULL, RDPDR_HEADER_LENGTH); @@ -415,7 +415,7 @@ static int rdpdr_server_send_user_logged_on(RdpdrServerContext* context) static int rdpdr_server_receive_pdu(RdpdrServerContext* context, wStream* s, RDPDR_HEADER* header) { - CLOG_DBG("RdpdrServerReceivePdu: Component: 0x%04X PacketId: 0x%04X\n", + WLog_DBG(TAG, "RdpdrServerReceivePdu: Component: 0x%04X PacketId: 0x%04X", header->Component, header->PacketId); winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), Stream_Length(s)); @@ -477,7 +477,7 @@ static int rdpdr_server_receive_pdu(RdpdrServerContext* context, wStream* s, RDP } else { - CLOG_DBG("Unknown RDPDR_HEADER.Component: 0x%04X\n", header->Component); + WLog_WARN(TAG, "Unknown RDPDR_HEADER.Component: 0x%04X", header->Component); return -1; } diff --git a/channels/rdpei/client/CMakeLists.txt b/channels/rdpei/client/CMakeLists.txt index e248d5f58..c792e3716 100644 --- a/channels/rdpei/client/CMakeLists.txt +++ b/channels/rdpei/client/CMakeLists.txt @@ -29,14 +29,7 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} TRUE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-common freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} winpr freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index 46729f028..fff7353c5 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -201,8 +201,8 @@ int rdpei_send_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s, UINT16 eventId, status = callback->channel->Write(callback->channel, (UINT32) Stream_Length(s), Stream_Buffer(s), NULL); #ifdef WITH_DEBUG_RDPEI - CLOG_ERR( "rdpei_send_pdu: eventId: %d (%s) length: %d status: %d\n", - eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength, status); + WLog_DBG(TAG, "rdpei_send_pdu: eventId: %d (%s) length: %d status: %d", + eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength, status); #endif return status; @@ -239,17 +239,22 @@ int rdpei_send_cs_ready_pdu(RDPEI_CHANNEL_CALLBACK* callback) void rdpei_print_contact_flags(UINT32 contactFlags) { if (contactFlags & CONTACT_FLAG_DOWN) - CLOG_DBG(" CONTACT_FLAG_DOWN"); + WLog_DBG(TAG, " CONTACT_FLAG_DOWN"); + if (contactFlags & CONTACT_FLAG_UPDATE) - CLOG_DBG(" CONTACT_FLAG_UPDATE"); + WLog_DBG(TAG, " CONTACT_FLAG_UPDATE"); + if (contactFlags & CONTACT_FLAG_UP) - CLOG_DBG(" CONTACT_FLAG_UP"); + WLog_DBG(TAG, " CONTACT_FLAG_UP"); + if (contactFlags & CONTACT_FLAG_INRANGE) - CLOG_DBG(" CONTACT_FLAG_INRANGE"); + WLog_DBG(TAG, " CONTACT_FLAG_INRANGE"); + if (contactFlags & CONTACT_FLAG_INCONTACT) - CLOG_DBG(" CONTACT_FLAG_INCONTACT"); + WLog_DBG(TAG, " CONTACT_FLAG_INCONTACT"); + if (contactFlags & CONTACT_FLAG_CANCELED) - CLOG_DBG(" CONTACT_FLAG_CANCELED"); + WLog_DBG(TAG, " CONTACT_FLAG_CANCELED"); } int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) @@ -259,8 +264,8 @@ int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) RDPINPUT_CONTACT_DATA* contact; #ifdef WITH_DEBUG_RDPEI - CLOG_DBG("contactCount: %d\n", frame->contactCount); - CLOG_DBG("frameOffset: 0x%08X\n", (UINT32) frame->frameOffset); + WLog_DBG(TAG, "contactCount: %d", frame->contactCount); + WLog_DBG(TAG, "frameOffset: 0x%08X", (UINT32) frame->frameOffset); #endif rdpei_write_2byte_unsigned(s, frame->contactCount); /* contactCount (TWO_BYTE_UNSIGNED_INTEGER) */ @@ -284,13 +289,12 @@ int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) contact->contactRectBottom = contact->y + rectSize; #ifdef WITH_DEBUG_RDPEI - CLOG_DBG("contact[%d].contactId: %d\n", index, contact->contactId); - CLOG_DBG("contact[%d].fieldsPresent: %d\n", index, contact->fieldsPresent); - CLOG_DBG("contact[%d].x: %d\n", index, contact->x); - CLOG_DBG("contact[%d].y: %d\n", index, contact->y); - CLOG_DBG("contact[%d].contactFlags: 0x%04X", index, contact->contactFlags); + WLog_DBG(TAG, "contact[%d].contactId: %d", index, contact->contactId); + WLog_DBG(TAG, "contact[%d].fieldsPresent: %d", index, contact->fieldsPresent); + WLog_DBG(TAG, "contact[%d].x: %d", index, contact->x); + WLog_DBG(TAG, "contact[%d].y: %d", index, contact->y); + WLog_DBG(TAG, "contact[%d].contactFlags: 0x%04X", index, contact->contactFlags); rdpei_print_contact_flags(contact->contactFlags); - CLOG_DBG("\n"); #endif Stream_Write_UINT8(s, contact->contactId); /* contactId (1 byte) */ @@ -371,7 +375,7 @@ int rdpei_recv_sc_ready_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s) #if 0 if (protocolVersion != RDPINPUT_PROTOCOL_V10) { - CLOG_ERR( "Unknown [MS-RDPEI] protocolVersion: 0x%08X\n", protocolVersion); + WLog_ERR(TAG, "Unknown [MS-RDPEI] protocolVersion: 0x%08X", protocolVersion); return -1; } #endif @@ -408,8 +412,8 @@ int rdpei_recv_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s) Stream_Read_UINT32(s, pduLength); /* pduLength (4 bytes) */ #ifdef WITH_DEBUG_RDPEI - CLOG_ERR( "rdpei_recv_pdu: eventId: %d (%s) length: %d\n", - eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength); + WLog_DBG(TAG, "rdpei_recv_pdu: eventId: %d (%s) length: %d", + eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength); #endif switch (eventId) diff --git a/channels/rdpei/client/rdpei_main.h b/channels/rdpei/client/rdpei_main.h index 509517bb6..4da19ee84 100644 --- a/channels/rdpei/client/rdpei_main.h +++ b/channels/rdpei/client/rdpei_main.h @@ -31,6 +31,8 @@ #include +#define TAG CHANNELS_TAG("rdpei.client") + #define RDPINPUT_HEADER_LENGTH 6 /* Protocol Version */ @@ -100,9 +102,9 @@ struct _RDPINPUT_CONTACT_POINT typedef struct _RDPINPUT_CONTACT_POINT RDPINPUT_CONTACT_POINT; #ifdef WITH_DEBUG_DVC -#define DEBUG_DVC(fmt, ...) CLOG_CLASS(DVC, fmt, ## __VA_ARGS__) +#define DEBUG_DVC(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_DVC(fmt, ...) CLOG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_DVC(fmt, ...) do { } while (0) #endif #endif /* FREERDP_CHANNEL_RDPEI_CLIENT_MAIN_H */ diff --git a/channels/rdpgfx/client/CMakeLists.txt b/channels/rdpgfx/client/CMakeLists.txt index abd8352df..06fe351ec 100644 --- a/channels/rdpgfx/client/CMakeLists.txt +++ b/channels/rdpgfx/client/CMakeLists.txt @@ -31,14 +31,7 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} TRUE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-common freerdp-codec freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} winpr freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/rdpgfx/client/rdpgfx_codec.c b/channels/rdpgfx/client/rdpgfx_codec.c index d621eea42..cc02f3b4a 100644 --- a/channels/rdpgfx/client/rdpgfx_codec.c +++ b/channels/rdpgfx/client/rdpgfx_codec.c @@ -23,11 +23,14 @@ #include #include +#include #include "rdpgfx_common.h" #include "rdpgfx_codec.h" +#define TAG CHANNELS_TAG("rdpgfx.client") + int rdpgfx_decode_uncompressed(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd) { return 1; @@ -72,19 +75,14 @@ int rdpgfx_read_h264_metablock(RDPGFX_PLUGIN* gfx, wStream* s, RDPGFX_H264_METAB if (!meta->quantQualityVals) return -1; -#if 0 - printf("H264_METABLOCK: numRegionRects: %d\n", (int) meta->numRegionRects); -#endif + WLog_DBG(TAG, "H264_METABLOCK: numRegionRects: %d", (int) meta->numRegionRects); for (index = 0; index < meta->numRegionRects; index++) { regionRect = &(meta->regionRects[index]); rdpgfx_read_rect16(s, regionRect); - -#if 0 - printf("regionRects[%d]: left: %d top: %d right: %d bottom: %d\n", - index, regionRect->left, regionRect->top, regionRect->right, regionRect->bottom); -#endif + WLog_DBG(TAG, "regionRects[%d]: left: %d top: %d right: %d bottom: %d", + index, regionRect->left, regionRect->top, regionRect->right, regionRect->bottom); } if (Stream_GetRemainingLength(s) < (meta->numRegionRects * 2)) @@ -99,11 +97,8 @@ int rdpgfx_read_h264_metablock(RDPGFX_PLUGIN* gfx, wStream* s, RDPGFX_H264_METAB quantQualityVal->qp = quantQualityVal->qpVal & 0x3F; quantQualityVal->r = (quantQualityVal->qpVal >> 6) & 1; quantQualityVal->p = (quantQualityVal->qpVal >> 7) & 1; - -#if 0 - printf("quantQualityVals[%d]: qp: %d r: %d p: %d qualityVal: %d\n", - index, quantQualityVal->qp, quantQualityVal->r, quantQualityVal->p, quantQualityVal->qualityVal); -#endif + WLog_DBG(TAG, "quantQualityVals[%d]: qp: %d r: %d p: %d qualityVal: %d", + index, quantQualityVal->qp, quantQualityVal->r, quantQualityVal->p, quantQualityVal->qualityVal); } return 1; diff --git a/channels/rdpgfx/client/rdpgfx_main.c b/channels/rdpgfx/client/rdpgfx_main.c index 3b75fa789..7e0c518c8 100644 --- a/channels/rdpgfx/client/rdpgfx_main.c +++ b/channels/rdpgfx/client/rdpgfx_main.c @@ -816,8 +816,8 @@ int rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) if (status < 0) { - CLOG_ERR( "Error while parsing GFX cmdId: %s (0x%04X)\n", - rdpgfx_get_cmd_id_string(header.cmdId), header.cmdId); + WLog_ERR(TAG, "Error while parsing GFX cmdId: %s (0x%04X)", + rdpgfx_get_cmd_id_string(header.cmdId), header.cmdId); return -1; } @@ -825,9 +825,8 @@ int rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) if (end != (beg + header.pduLength)) { - CLOG_ERR( "Unexpected gfx pdu end: Actual: %d, Expected: %d\n", - end, (beg + header.pduLength)); - + WLog_ERR(TAG, "Unexpected gfx pdu end: Actual: %d, Expected: %d", + end, (beg + header.pduLength)); Stream_SetPosition(s, (beg + header.pduLength)); } @@ -847,7 +846,7 @@ static int rdpgfx_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, if (status < 0) { - CLOG_DBG("zgfx_decompress failure! status: %d\n", status); + WLog_DBG(TAG, "zgfx_decompress failure! status: %d", status); return 0; } @@ -1065,11 +1064,7 @@ int rdpgfx_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) if (!gfx) return -1; - gfx->log = WLog_Get("com.freerdp.gfx.client"); -#if 0 - WLog_SetLogLevel(gfx->log, WLOG_DEBUG); -#endif - + gfx->log = WLog_Get(TAG); gfx->settings = (rdpSettings*) pEntryPoints->GetRdpSettings(pEntryPoints); gfx->iface.Initialize = rdpgfx_plugin_initialize; diff --git a/channels/rdpgfx/client/rdpgfx_main.h b/channels/rdpgfx/client/rdpgfx_main.h index db897c93e..96d91b4b9 100644 --- a/channels/rdpgfx/client/rdpgfx_main.h +++ b/channels/rdpgfx/client/rdpgfx_main.h @@ -28,9 +28,11 @@ #include #include - +#include #include +#define TAG CHANNELS_TAG("rdpgfx.client") + struct _RDPGFX_CHANNEL_CALLBACK { IWTSVirtualChannelCallback iface; diff --git a/channels/rdpsnd/client/CMakeLists.txt b/channels/rdpsnd/client/CMakeLists.txt index 68b442fce..53d16e832 100644 --- a/channels/rdpsnd/client/CMakeLists.txt +++ b/channels/rdpsnd/client/CMakeLists.txt @@ -25,14 +25,7 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-codec freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} winpr freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/rdpsnd/client/alsa/CMakeLists.txt b/channels/rdpsnd/client/alsa/CMakeLists.txt index cbe2ca20a..411ca642c 100644 --- a/channels/rdpsnd/client/alsa/CMakeLists.txt +++ b/channels/rdpsnd/client/alsa/CMakeLists.txt @@ -27,12 +27,7 @@ add_channel_client_subsystem_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_N set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-codec freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${ALSA_LIBRARIES}) diff --git a/channels/rdpsnd/client/alsa/rdpsnd_alsa.c b/channels/rdpsnd/client/alsa/rdpsnd_alsa.c index 70ad41c76..569822349 100644 --- a/channels/rdpsnd/client/alsa/rdpsnd_alsa.c +++ b/channels/rdpsnd/client/alsa/rdpsnd_alsa.c @@ -68,7 +68,7 @@ struct rdpsnd_alsa_plugin #define SND_PCM_CHECK(_func, _status) \ if (_status < 0) \ { \ - CLOG_ERR( "%s: %d\n", _func, _status); \ + WLog_ERR(TAG, "%s: %d\n", _func, _status); \ return -1; \ } @@ -106,8 +106,8 @@ static int rdpsnd_alsa_set_hw_params(rdpsndAlsaPlugin* alsa) if (alsa->buffer_size > buffer_size_max) { - CLOG_ERR( "Warning: requested sound buffer size %d, got %d instead\n", - (int) alsa->buffer_size, (int) buffer_size_max); + WLog_ERR(TAG, "Warning: requested sound buffer size %d, got %d instead\n", + (int) alsa->buffer_size, (int) buffer_size_max); alsa->buffer_size = buffer_size_max; } @@ -262,7 +262,7 @@ static void rdpsnd_alsa_open_mixer(rdpsndAlsaPlugin* alsa) if (status < 0) { - CLOG_ERR("snd_mixer_open failed"); + WLog_ERR(TAG, "snd_mixer_open failed"); return; } @@ -270,7 +270,7 @@ static void rdpsnd_alsa_open_mixer(rdpsndAlsaPlugin* alsa) if (status < 0) { - CLOG_ERR("snd_mixer_attach failed"); + WLog_ERR(TAG, "snd_mixer_attach failed"); snd_mixer_close(alsa->mixer_handle); return; } @@ -279,7 +279,7 @@ static void rdpsnd_alsa_open_mixer(rdpsndAlsaPlugin* alsa) if (status < 0) { - CLOG_ERR("snd_mixer_selem_register failed"); + WLog_ERR(TAG, "snd_mixer_selem_register failed"); snd_mixer_close(alsa->mixer_handle); return; } @@ -288,7 +288,7 @@ static void rdpsnd_alsa_open_mixer(rdpsndAlsaPlugin* alsa) if (status < 0) { - CLOG_ERR("snd_mixer_load failed"); + WLog_ERR(TAG, "snd_mixer_load failed"); snd_mixer_close(alsa->mixer_handle); return; } @@ -310,7 +310,7 @@ static void rdpsnd_alsa_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, i if (status < 0) { - CLOG_ERR("snd_pcm_open failed"); + WLog_ERR(TAG, "snd_pcm_open failed"); } else { @@ -579,7 +579,7 @@ static void rdpsnd_alsa_wave_play(rdpsndDevicePlugin* device, RDPSND_WAVE* wave) } else if (status < 0) { - CLOG_ERR( "status: %d\n", status); + WLog_ERR(TAG, "status: %d\n", status); snd_pcm_close(alsa->pcm_handle); alsa->pcm_handle = NULL; rdpsnd_alsa_open((rdpsndDevicePlugin*) alsa, NULL, alsa->latency); @@ -599,8 +599,7 @@ static void rdpsnd_alsa_wave_play(rdpsndDevicePlugin* device, RDPSND_WAVE* wave) wave->wLocalTimeB += wave->wPlaybackDelay; wave->wLatency = (UINT16) (wave->wLocalTimeB - wave->wLocalTimeA); wave->wTimeStampB = wave->wTimeStampA + wave->wLatency; - - //CLOG_ERR( "wTimeStampA: %d wTimeStampB: %d wLatency: %d\n", wave->wTimeStampA, wave->wTimeStampB, wave->wLatency); + //WLog_ERR(TAG, "wTimeStampA: %d wTimeStampB: %d wLatency: %d\n", wave->wTimeStampA, wave->wTimeStampB, wave->wLatency); } static COMMAND_LINE_ARGUMENT_A rdpsnd_alsa_args[] = diff --git a/channels/rdpsnd/client/ios/CMakeLists.txt b/channels/rdpsnd/client/ios/CMakeLists.txt index 673a4f99c..0190a6b7a 100644 --- a/channels/rdpsnd/client/ios/CMakeLists.txt +++ b/channels/rdpsnd/client/ios/CMakeLists.txt @@ -33,16 +33,13 @@ add_channel_client_subsystem_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_N set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${AUDIO_TOOL} ${CORE_AUDIO} ${CORE_FOUNDATION}) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp} + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/rdpsnd/client/ios/TPCircularBuffer.c b/channels/rdpsnd/client/ios/TPCircularBuffer.c index 44949e2e8..137ec789f 100644 --- a/channels/rdpsnd/client/ios/TPCircularBuffer.c +++ b/channels/rdpsnd/client/ios/TPCircularBuffer.c @@ -37,7 +37,7 @@ #define reportResult(result,operation) (_reportResult((result),(operation),__FILE__,__LINE__)) static inline bool _reportResult(kern_return_t result, const char *operation, const char* file, int line) { if ( result != ERR_SUCCESS ) { - CLOG_DBG("%s:%d: %s: %s\n", file, line, operation, mach_error_string(result)); + WLog_DBG(TAG, "%s:%d: %s: %s\n", file, line, operation, mach_error_string(result)); return false; } return true; @@ -108,7 +108,7 @@ bool TPCircularBufferInit(TPCircularBuffer *buffer, int length) { if ( virtualAddress != bufferAddress+buffer->length ) { // If the memory is not contiguous, clean up both allocated buffers and try again if ( retries-- == 0 ) { - CLOG_DBG("Couldn't map buffer memory to end of buffer\n"); + WLog_DBG(TAG, "Couldn't map buffer memory to end of buffer"); return false; } diff --git a/channels/rdpsnd/client/mac/CMakeLists.txt b/channels/rdpsnd/client/mac/CMakeLists.txt index 8a6f93cb8..103c40665 100644 --- a/channels/rdpsnd/client/mac/CMakeLists.txt +++ b/channels/rdpsnd/client/mac/CMakeLists.txt @@ -33,16 +33,13 @@ add_channel_client_subsystem_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_N set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${AUDIO_TOOL} ${CORE_AUDIO} ${CORE_FOUNDATION}) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp) + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/rdpsnd/client/mac/rdpsnd_mac.c b/channels/rdpsnd/client/mac/rdpsnd_mac.c index 8bff23b0f..cfcfa51ad 100644 --- a/channels/rdpsnd/client/mac/rdpsnd_mac.c +++ b/channels/rdpsnd/client/mac/rdpsnd_mac.c @@ -121,7 +121,7 @@ static void rdpsnd_mac_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, in if (status != 0) { - CLOG_ERR( "AudioQueueNewOutput failure\n"); + WLog_ERR(TAG, "AudioQueueNewOutput failure\n"); return; } @@ -135,7 +135,7 @@ static void rdpsnd_mac_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, in if (status != 0) { - CLOG_DBG("AudioQueueGetProperty failure: kAudioQueueProperty_DecodeBufferSizeFrames\n"); + WLog_DBG(TAG, "AudioQueueGetProperty failure: kAudioQueueProperty_DecodeBufferSizeFrames\n"); } for (index = 0; index < MAC_AUDIO_QUEUE_NUM_BUFFERS; index++) @@ -144,7 +144,7 @@ static void rdpsnd_mac_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, in if (status != 0) { - CLOG_ERR( "AudioQueueAllocateBuffer failed\n"); + WLog_ERR(TAG, "AudioQueueAllocateBuffer failed\n"); } } @@ -219,7 +219,7 @@ static void rdpsnd_mac_set_volume(rdpsndDevicePlugin* device, UINT32 value) if (status != 0) { - CLOG_ERR( "AudioQueueSetParameter kAudioQueueParam_Volume failed: %f\n", fVolume); + WLog_ERR(TAG, "AudioQueueSetParameter kAudioQueueParam_Volume failed: %f\n", fVolume); } } @@ -238,7 +238,7 @@ static void rdpsnd_mac_start(rdpsndDevicePlugin* device) if (status != 0) { - CLOG_ERR( "AudioQueueStart failed\n"); + WLog_ERR(TAG, "AudioQueueStart failed\n"); } mac->isPlaying = TRUE; diff --git a/channels/rdpsnd/client/opensles/CMakeLists.txt b/channels/rdpsnd/client/opensles/CMakeLists.txt index dc5465a8e..9060761bf 100644 --- a/channels/rdpsnd/client/opensles/CMakeLists.txt +++ b/channels/rdpsnd/client/opensles/CMakeLists.txt @@ -28,13 +28,7 @@ add_channel_client_subsystem_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_N set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-codec freerdp-utils - ${OPENSLES_LIBRARIES}) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${OPENSLES_LIBRARIES}) +set(${MODULE_PREFIX}_LIBS freerdp ${OPENSLES_LIBRARIES}) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/channels/rdpsnd/client/opensles/rdpsnd_opensles.c b/channels/rdpsnd/client/opensles/rdpsnd_opensles.c index 7047e46e2..b709ad8f1 100644 --- a/channels/rdpsnd/client/opensles/rdpsnd_opensles.c +++ b/channels/rdpsnd/client/opensles/rdpsnd_opensles.c @@ -187,7 +187,7 @@ static void rdpsnd_opensles_open(rdpsndDevicePlugin* device, assert(opensles->stream); if (!opensles->stream) - CLOG_ERR("android_OpenAudioDevice failed"); + WLog_ERR(TAG, "android_OpenAudioDevice failed"); else rdpsnd_opensles_set_volume(device, opensles->volume); @@ -364,7 +364,7 @@ static void rdpsnd_opensles_play(rdpsndDevicePlugin* device, ret = android_AudioOut(opensles->stream, src.s, size / 2); if (ret < 0) - CLOG_ERR("android_AudioOut failed (%d)", ret); + WLog_ERR(TAG, "android_AudioOut failed (%d)", ret); } static void rdpsnd_opensles_start(rdpsndDevicePlugin* device) diff --git a/channels/rdpsnd/client/pulse/CMakeLists.txt b/channels/rdpsnd/client/pulse/CMakeLists.txt index 6b6de1ecc..46d525749 100644 --- a/channels/rdpsnd/client/pulse/CMakeLists.txt +++ b/channels/rdpsnd/client/pulse/CMakeLists.txt @@ -27,12 +27,8 @@ add_channel_client_subsystem_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_N set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-codec freerdp-utils) - list(APPEND ${MODULE_PREFIX}_LIBS ${PULSE_LIBRARY}) +list(APPEND ${MODULE_PREFIX}_LIBS freerdp) if(GSM_FOUND) list(APPEND ${MODULE_PREFIX}_LIBS ${GSM_LIBRARIES}) diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index b7e9eaef5..06c7bde74 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -195,13 +195,12 @@ void rdpsnd_select_supported_audio_formats(rdpsndPlugin* rdpsnd) } #if 0 - CLOG_ERR( "Server "); + WLog_ERR(TAG, "Server "); rdpsnd_print_audio_formats(rdpsnd->ServerFormats, rdpsnd->NumberOfServerFormats); - CLOG_ERR( "\n"); - - CLOG_ERR( "Client "); + WLog_ERR(TAG, "\n"); + WLog_ERR(TAG, "Client "); rdpsnd_print_audio_formats(rdpsnd->ClientFormats, rdpsnd->NumberOfClientFormats); - CLOG_ERR( "\n"); + WLog_ERR(TAG, "\n"); #endif } @@ -544,7 +543,7 @@ static void rdpsnd_recv_pdu(rdpsndPlugin* rdpsnd, wStream* s) Stream_Seek_UINT8(s); /* bPad */ Stream_Read_UINT16(s, BodySize); - //CLOG_ERR( "msgType %d BodySize %d\n", msgType, BodySize); + //WLog_ERR(TAG, "msgType %d BodySize %d\n", msgType, BodySize); switch (msgType) { @@ -569,7 +568,7 @@ static void rdpsnd_recv_pdu(rdpsndPlugin* rdpsnd, wStream* s) break; default: - CLOG_ERR("unknown msgType %d", msgType); + WLog_ERR(TAG, "unknown msgType %d", msgType); break; } @@ -580,7 +579,7 @@ static void rdpsnd_register_device_plugin(rdpsndPlugin* rdpsnd, rdpsndDevicePlug { if (rdpsnd->device) { - CLOG_ERR("existing device, abort."); + WLog_ERR(TAG, "existing device, abort."); return; } @@ -606,7 +605,7 @@ static BOOL rdpsnd_load_device_plugin(rdpsndPlugin* rdpsnd, const char* name, AD if (entry(&entryPoints) != 0) { - CLOG_ERR("%s entry returns error.", name); + WLog_ERR(TAG, "%s entry returns error.", name); return FALSE; } @@ -795,7 +794,7 @@ static void rdpsnd_process_connect(rdpsndPlugin* rdpsnd) if (!rdpsnd->device) { - CLOG_ERR("no sound device."); + WLog_ERR(TAG, "no sound device."); return; } @@ -875,7 +874,7 @@ int rdpsnd_virtual_channel_write(rdpsndPlugin* rdpsnd, wStream* s) if (status != CHANNEL_RC_OK) { Stream_Free(s, TRUE); - CLOG_ERR( "rdpdr_virtual_channel_write: VirtualChannelWrite failed %d\n", status); + WLog_ERR(TAG, "rdpdr_virtual_channel_write: VirtualChannelWrite failed %d\n", status); } return status; @@ -907,7 +906,7 @@ static void rdpsnd_virtual_channel_event_data_received(rdpsndPlugin* plugin, { if (Stream_Capacity(s) != Stream_GetPosition(s)) { - CLOG_ERR( "rdpsnd_virtual_channel_event_data_received: read error\n"); + WLog_ERR(TAG, "rdpsnd_virtual_channel_event_data_received: read error\n"); } plugin->data_in = NULL; @@ -927,7 +926,7 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_open_event(DWORD openHandle, UINT e if (!plugin) { - CLOG_ERR( "rdpsnd_virtual_channel_open_event: error no match\n"); + WLog_ERR(TAG, "rdpsnd_virtual_channel_open_event: error no match\n"); return; } @@ -987,7 +986,7 @@ static void rdpsnd_virtual_channel_event_connected(rdpsndPlugin* plugin, LPVOID if (status != CHANNEL_RC_OK) { - CLOG_ERR( "rdpsnd_virtual_channel_event_connected: open failed: status: %d\n", status); + WLog_ERR(TAG, "rdpsnd_virtual_channel_event_connected: open failed: status: %d\n", status); return; } @@ -1040,7 +1039,7 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_init_event(LPVOID pInitHandle, UINT if (!plugin) { - CLOG_ERR( "rdpsnd_virtual_channel_init_event: error no match\n"); + WLog_ERR(TAG, "rdpsnd_virtual_channel_init_event: error no match\n"); return; } diff --git a/channels/rdpsnd/client/rdpsnd_main.h b/channels/rdpsnd/client/rdpsnd_main.h index 4b7cb472c..5b9c41358 100644 --- a/channels/rdpsnd/client/rdpsnd_main.h +++ b/channels/rdpsnd/client/rdpsnd_main.h @@ -25,9 +25,12 @@ #include #include #include +#include + +#define TAG CHANNELS_TAG("rdpsnd.client") #if defined(WITH_DEBUG_SND) -#define DEBUG_SND(fmt, ...) CLOG_CLASS("rdpsnd", fmt, ## __VA_ARGS__) +#define DEBUG_SND(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__) #else #define DEBUG_SND(fmt, ...) do { } while (0) #endif diff --git a/channels/rdpsnd/client/winmm/CMakeLists.txt b/channels/rdpsnd/client/winmm/CMakeLists.txt index 99aaae53f..2c670c3ba 100644 --- a/channels/rdpsnd/client/winmm/CMakeLists.txt +++ b/channels/rdpsnd/client/winmm/CMakeLists.txt @@ -26,14 +26,9 @@ add_channel_client_subsystem_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_N set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winmm.lib) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/channels/rdpsnd/client/winmm/rdpsnd_winmm.c b/channels/rdpsnd/client/winmm/rdpsnd_winmm.c index cb69098c8..cbae34e72 100644 --- a/channels/rdpsnd/client/winmm/rdpsnd_winmm.c +++ b/channels/rdpsnd/client/winmm/rdpsnd_winmm.c @@ -102,11 +102,11 @@ static void CALLBACK rdpsnd_winmm_callback_function(HWAVEOUT hwo, UINT uMsg, DWO switch (uMsg) { case MM_WOM_OPEN: - CLOG_ERR( "MM_WOM_OPEN\n"); + WLog_ERR(TAG, "MM_WOM_OPEN\n"); break; case MM_WOM_CLOSE: - CLOG_ERR( "MM_WOM_CLOSE\n"); + WLog_ERR(TAG, "MM_WOM_CLOSE\n"); break; case MM_WOM_DONE: @@ -122,9 +122,8 @@ static void CALLBACK rdpsnd_winmm_callback_function(HWAVEOUT hwo, UINT uMsg, DWO if (!wave) return; - CLOG_ERR( "MM_WOM_DONE: dwBufferLength: %d cBlockNo: %d\n", - lpWaveHdr->dwBufferLength, wave->cBlockNo); - + WLog_ERR(TAG, "MM_WOM_DONE: dwBufferLength: %d cBlockNo: %d\n", + lpWaveHdr->dwBufferLength, wave->cBlockNo); wave->wLocalTimeB = GetTickCount(); wTimeDelta = wave->wLocalTimeB - wave->wLocalTimeA; wave->wTimeStampB = wave->wTimeStampA + wTimeDelta; @@ -156,7 +155,7 @@ static void rdpsnd_winmm_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, if (mmResult != MMSYSERR_NOERROR) { - CLOG_ERR( "waveOutOpen failed: %d\n", mmResult); + WLog_ERR(TAG, "waveOutOpen failed: %d\n", mmResult); } } @@ -173,7 +172,7 @@ static void rdpsnd_winmm_close(rdpsndDevicePlugin* device) if (mmResult != MMSYSERR_NOERROR) { - CLOG_ERR( "waveOutClose failure: %d\n", mmResult); + WLog_ERR(TAG, "waveOutClose failure: %d\n", mmResult); } winmm->hWaveOut = NULL; @@ -300,7 +299,7 @@ void rdpsnd_winmm_wave_play(rdpsndDevicePlugin* device, RDPSND_WAVE* wave) if (mmResult != MMSYSERR_NOERROR) { - CLOG_ERR( "waveOutPrepareHeader failure: %d\n", mmResult); + WLog_ERR(TAG, "waveOutPrepareHeader failure: %d\n", mmResult); return; } @@ -308,7 +307,7 @@ void rdpsnd_winmm_wave_play(rdpsndDevicePlugin* device, RDPSND_WAVE* wave) if (mmResult != MMSYSERR_NOERROR) { - CLOG_ERR( "waveOutWrite failure: %d\n", mmResult); + WLog_ERR(TAG, "waveOutWrite failure: %d\n", mmResult); waveOutUnprepareHeader(winmm->hWaveOut, lpWaveHdr, sizeof(WAVEHDR)); return; } diff --git a/channels/rdpsnd/server/CMakeLists.txt b/channels/rdpsnd/server/CMakeLists.txt index 9cb5c1d6f..09fef66e3 100644 --- a/channels/rdpsnd/server/CMakeLists.txt +++ b/channels/rdpsnd/server/CMakeLists.txt @@ -25,12 +25,7 @@ add_channel_server_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-codec freerdp-utils) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/rdpsnd/server/rdpsnd_main.c b/channels/rdpsnd/server/rdpsnd_main.c index 820d8654d..372e06f4a 100644 --- a/channels/rdpsnd/server/rdpsnd_main.c +++ b/channels/rdpsnd/server/rdpsnd_main.c @@ -109,8 +109,7 @@ static BOOL rdpsnd_server_recv_quality_mode(RdpsndServerContext* context, wStrea Stream_Read_UINT16(s, quality); Stream_Seek_UINT16(s); // reserved - - CLOG_ERR( "Client requested sound quality: %#0X\n", quality); + WLog_ERR(TAG, "Client requested sound quality: %#0X\n", quality); return TRUE; } @@ -139,7 +138,7 @@ static BOOL rdpsnd_server_recv_formats(RdpsndServerContext* context, wStream* s) if (!context->num_client_formats) { - CLOG_ERR( "%s: client doesn't support any format!\n", __FUNCTION__); + WLog_ERR(TAG, "%s: client doesn't support any format!\n", __FUNCTION__); return FALSE; } @@ -176,7 +175,7 @@ static BOOL rdpsnd_server_recv_formats(RdpsndServerContext* context, wStream* s) if (!context->num_client_formats) { - CLOG_ERR( "%s: client doesn't support any known format!\n", __FUNCTION__); + WLog_ERR(TAG, "%s: client doesn't support any known format!\n", __FUNCTION__); goto out_free; } @@ -232,7 +231,7 @@ static BOOL rdpsnd_server_select_format(RdpsndServerContext* context, int client if (client_format_index < 0 || client_format_index >= context->num_client_formats) { - CLOG_ERR( "%s: index %d is not correct.\n", __FUNCTION__, client_format_index); + WLog_ERR(TAG, "%s: index %d is not correct.\n", __FUNCTION__, client_format_index); return FALSE; } @@ -244,7 +243,7 @@ static BOOL rdpsnd_server_select_format(RdpsndServerContext* context, int client if (format->nSamplesPerSec == 0) { - CLOG_ERR( "%s: invalid Client Sound Format!!\n", __FUNCTION__); + WLog_ERR(TAG, "%s: invalid Client Sound Format!!\n", __FUNCTION__); return FALSE; } @@ -477,8 +476,9 @@ static int rdpsnd_server_start(RdpsndServerContext* context) if (!WTSVirtualChannelQuery(priv->ChannelHandle, WTSVirtualEventHandle, &buffer, &bytesReturned) || (bytesReturned != sizeof(HANDLE))) { - CLOG_ERR( "%s: error during WTSVirtualChannelQuery(WTSVirtualEventHandle) or invalid returned size(%d)\n", - __FUNCTION__, bytesReturned); + WLog_ERR(TAG, "%s: error during WTSVirtualChannelQuery(WTSVirtualEventHandle) or invalid returned size(%d)\n", + __FUNCTION__, bytesReturned); + if (buffer) WTSFreeMemory(buffer); goto out_close; @@ -642,7 +642,7 @@ int rdpsnd_server_handle_messages(RdpsndServerContext *context) if (GetLastError() == ERROR_NO_DATA) return -1; - CLOG_ERR( "%s: channel connection closed\n", __FUNCTION__); + WLog_ERR(TAG, "%s: channel connection closed\n", __FUNCTION__); return 0; } priv->expectedBytes -= bytesReturned; @@ -671,7 +671,7 @@ int rdpsnd_server_handle_messages(RdpsndServerContext *context) /* when here we have the header + the body */ #ifdef WITH_DEBUG_SND - CLOG_ERR( "%s: message type %d\n", __FUNCTION__, priv->msgType); + WLog_DBG(TAG, "message type %d", priv->msgType); #endif priv->expectedBytes = 4; priv->waitingHeader = TRUE; @@ -699,7 +699,7 @@ int rdpsnd_server_handle_messages(RdpsndServerContext *context) break; default: - CLOG_ERR( "%s: UNKOWN MESSAGE TYPE!! (%#0X)\n\n", __FUNCTION__, priv->msgType); + WLog_ERR(TAG, "%s: UNKOWN MESSAGE TYPE!! (%#0X)\n\n", __FUNCTION__, priv->msgType); ret = FALSE; break; } diff --git a/channels/rdpsnd/server/rdpsnd_main.h b/channels/rdpsnd/server/rdpsnd_main.h index 667c211ee..20ed42d80 100644 --- a/channels/rdpsnd/server/rdpsnd_main.h +++ b/channels/rdpsnd/server/rdpsnd_main.h @@ -27,8 +27,11 @@ #include #include +#include #include +#define TAG CHANNELS_TAG("rdpsnd.server") + struct _rdpsnd_server_private { BOOL ownThread; diff --git a/channels/remdesk/client/CMakeLists.txt b/channels/remdesk/client/CMakeLists.txt index a3ab1cfd5..ed90b2948 100644 --- a/channels/remdesk/client/CMakeLists.txt +++ b/channels/remdesk/client/CMakeLists.txt @@ -25,12 +25,7 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-common) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/remdesk/client/remdesk_main.c b/channels/remdesk/client/remdesk_main.c index c81e6eaaf..2ad69243d 100644 --- a/channels/remdesk/client/remdesk_main.c +++ b/channels/remdesk/client/remdesk_main.c @@ -50,7 +50,7 @@ int remdesk_virtual_channel_write(remdeskPlugin* remdesk, wStream* s) if (status != CHANNEL_RC_OK) { - CLOG_ERR( "remdesk_virtual_channel_write: VirtualChannelWrite failed %d\n", status); + WLog_ERR(TAG, "VirtualChannelWrite failed %d", status); return -1; } @@ -225,9 +225,7 @@ static int remdesk_recv_ctl_result_pdu(remdeskPlugin* remdesk, wStream* s, REMDE Stream_Read_UINT32(s, result); /* result (4 bytes) */ *pResult = result; - - //CLOG_DBG("RemdeskRecvResult: 0x%04X\n", result); - + //WLog_DBG(TAG, "RemdeskRecvResult: 0x%04X", result); return 1; } @@ -397,7 +395,7 @@ static int remdesk_recv_ctl_pdu(remdeskPlugin* remdesk, wStream* s, REMDESK_CHAN Stream_Read_UINT32(s, msgType); /* msgType (4 bytes) */ - //CLOG_DBG("msgType: %d\n", msgType); + //WLog_DBG(TAG, "msgType: %d", msgType); switch (msgType) { @@ -462,7 +460,7 @@ static int remdesk_recv_ctl_pdu(remdeskPlugin* remdesk, wStream* s, REMDESK_CHAN break; default: - CLOG_ERR( "remdesk_recv_control_pdu: unknown msgType: %d\n", msgType); + WLog_ERR(TAG, "unknown msgType: %d", msgType); status = -1; break; } @@ -476,7 +474,7 @@ static int remdesk_process_receive(remdeskPlugin* remdesk, wStream* s) REMDESK_CHANNEL_HEADER header; #if 0 - CLOG_DBG("RemdeskReceive: %d\n", Stream_GetRemainingLength(s)); + WLog_DBG(TAG, "RemdeskReceive: %d", Stream_GetRemainingLength(s)); winpr_HexDump(Stream_Pointer(s), Stream_GetRemainingLength(s)); #endif @@ -586,7 +584,7 @@ int remdesk_send(remdeskPlugin* remdesk, wStream* s) if (status != CHANNEL_RC_OK) { Stream_Free(s, TRUE); - CLOG_ERR( "remdesk_send: VirtualChannelWrite failed %d\n", status); + WLog_ERR(TAG, "VirtualChannelWrite failed %d", status); } return status; @@ -618,7 +616,7 @@ static void remdesk_virtual_channel_event_data_received(remdeskPlugin* remdesk, { if (Stream_Capacity(data_in) != Stream_GetPosition(data_in)) { - CLOG_ERR( "remdesk_plugin_process_received: read error\n"); + WLog_ERR(TAG, "read error"); } remdesk->data_in = NULL; @@ -638,7 +636,7 @@ static VOID VCAPITYPE remdesk_virtual_channel_open_event(DWORD openHandle, UINT if (!remdesk) { - CLOG_ERR( "remdesk_virtual_channel_open_event: error no match\n"); + WLog_ERR(TAG, "error no match"); return; } @@ -698,7 +696,7 @@ static void remdesk_virtual_channel_event_connected(remdeskPlugin* remdesk, LPVO if (status != CHANNEL_RC_OK) { - CLOG_ERR( "remdesk_virtual_channel_event_connected: open failed: status: %d\n", status); + WLog_ERR(TAG, "open failed: status: %d", status); return; } @@ -736,7 +734,7 @@ static VOID VCAPITYPE remdesk_virtual_channel_init_event(LPVOID pInitHandle, UIN if (!remdesk) { - CLOG_ERR( "remdesk_virtual_channel_init_event: error no match\n"); + WLog_ERR(TAG, "error no match"); return; } diff --git a/channels/remdesk/client/remdesk_main.h b/channels/remdesk/client/remdesk_main.h index 031353be5..e47773f57 100644 --- a/channels/remdesk/client/remdesk_main.h +++ b/channels/remdesk/client/remdesk_main.h @@ -33,6 +33,9 @@ #include +#include +#define TAG CHANNELS_TAG("remdesk.client") + struct remdesk_plugin { CHANNEL_DEF channelDef; diff --git a/channels/remdesk/server/remdesk_main.c b/channels/remdesk/server/remdesk_main.c index 8c193e0fc..4a7670ebd 100644 --- a/channels/remdesk/server/remdesk_main.c +++ b/channels/remdesk/server/remdesk_main.c @@ -209,9 +209,8 @@ static int remdesk_recv_ctl_remote_control_desktop_pdu(RemdeskServerContext* con if (status <= 0) return -1; - printf("RaConnectionString: %s\n", - pdu.raConnectionString); - + WLog_INFO(TAG, "RaConnectionString: %s", + pdu.raConnectionString); free(pdu.raConnectionString); remdesk_send_ctl_result_pdu(context, 0); @@ -281,9 +280,8 @@ static int remdesk_recv_ctl_authenticate_pdu(RemdeskServerContext* context, wStr if (status <= 0) return -1; - printf("RaConnectionString: %s ExpertBlob: %s\n", - pdu.raConnectionString, pdu.expertBlob); - + WLog_INFO(TAG, "RaConnectionString: %s ExpertBlob: %s", + pdu.raConnectionString, pdu.expertBlob); free(pdu.raConnectionString); free(pdu.expertBlob); @@ -305,9 +303,7 @@ static int remdesk_recv_ctl_verify_password_pdu(RemdeskServerContext* context, w cbExpertBlobW = header->DataLength - 4; status = ConvertFromUnicode(CP_UTF8, 0, expertBlobW, cbExpertBlobW / 2, &pdu.expertBlob, 0, NULL, NULL); - - printf("ExpertBlob: %s\n", pdu.expertBlob); - + WLog_INFO(TAG, "ExpertBlob: %s", pdu.expertBlob); remdesk_send_ctl_result_pdu(context, 0); return 1; @@ -322,8 +318,7 @@ static int remdesk_recv_ctl_pdu(RemdeskServerContext* context, wStream* s, REMDE return -1; Stream_Read_UINT32(s, msgType); /* msgType (4 bytes) */ - - printf("msgType: %d\n", msgType); + WLog_INFO(TAG, "msgType: %d", msgType); switch (msgType) { @@ -362,7 +357,7 @@ static int remdesk_recv_ctl_pdu(RemdeskServerContext* context, wStream* s, REMDE break; default: - fprintf(stderr, "remdesk_recv_control_pdu: unknown msgType: %d\n", msgType); + WLog_ERR(TAG, "remdesk_recv_control_pdu: unknown msgType: %d", msgType); status = -1; break; } @@ -376,7 +371,7 @@ static int remdesk_server_receive_pdu(RemdeskServerContext* context, wStream* s) REMDESK_CHANNEL_HEADER header; #if 0 - printf("RemdeskReceive: %d\n", Stream_GetRemainingLength(s)); + WLog_INFO(TAG, "RemdeskReceive: %d", Stream_GetRemainingLength(s)); winpr_HexDump(Stream_Pointer(s), Stream_GetRemainingLength(s)); #endif diff --git a/channels/remdesk/server/remdesk_main.h b/channels/remdesk/server/remdesk_main.h index 94184aeb9..3c35b45a6 100644 --- a/channels/remdesk/server/remdesk_main.h +++ b/channels/remdesk/server/remdesk_main.h @@ -25,6 +25,9 @@ #include #include +#include + +#define TAG CHANNELS_TAG("remdesk.server") struct _remdesk_server_private { diff --git a/channels/serial/client/CMakeLists.txt b/channels/serial/client/CMakeLists.txt index 8f2532473..1a40d472a 100644 --- a/channels/serial/client/CMakeLists.txt +++ b/channels/serial/client/CMakeLists.txt @@ -24,14 +24,7 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} TRUE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} winpr freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/server/CMakeLists.txt b/channels/server/CMakeLists.txt index 63e0f3dc6..4723368cb 100644 --- a/channels/server/CMakeLists.txt +++ b/channels/server/CMakeLists.txt @@ -35,13 +35,7 @@ if (WITH_LIBRARY_VERSIONING) endif() set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "lib") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-codec freerdp-utils) - - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp) set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} PARENT_SCOPE) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) diff --git a/channels/smartcard/client/CMakeLists.txt b/channels/smartcard/client/CMakeLists.txt index a3e263aee..b38464cc0 100644 --- a/channels/smartcard/client/CMakeLists.txt +++ b/channels/smartcard/client/CMakeLists.txt @@ -28,14 +28,7 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} winpr freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/smartcard/client/smartcard_main.c b/channels/smartcard/client/smartcard_main.c index 9baf16355..f501d7717 100644 --- a/channels/smartcard/client/smartcard_main.c +++ b/channels/smartcard/client/smartcard_main.c @@ -372,9 +372,8 @@ void smartcard_process_irp(SMARTCARD_DEVICE* smartcard, IRP* irp) } else { - CLOG_ERR( "Unexpected SmartCard IRP: MajorFunction 0x%08X MinorFunction: 0x%08X", - irp->MajorFunction, irp->MinorFunction); - + WLog_ERR(TAG, "Unexpected SmartCard IRP: MajorFunction 0x%08X MinorFunction: 0x%08X", + irp->MajorFunction, irp->MinorFunction); irp->IoStatus = STATUS_NOT_SUPPORTED; Queue_Enqueue(smartcard->CompletedIrpQueue, (void*) irp); diff --git a/channels/smartcard/client/smartcard_main.h b/channels/smartcard/client/smartcard_main.h index c2ef362f8..d9123cda5 100644 --- a/channels/smartcard/client/smartcard_main.h +++ b/channels/smartcard/client/smartcard_main.h @@ -30,6 +30,8 @@ #include #include +#define TAG CHANNELS_TAG("smartcard.client") + #define RDP_SCARD_CTL_CODE(code) CTL_CODE(FILE_DEVICE_FILE_SYSTEM, (code), METHOD_BUFFERED, FILE_ANY_ACCESS) #define SCARD_IOCTL_ESTABLISHCONTEXT RDP_SCARD_CTL_CODE(5) /* SCardEstablishContext */ diff --git a/channels/smartcard/client/smartcard_operations.c b/channels/smartcard/client/smartcard_operations.c index 979b9a59d..643ba97fb 100644 --- a/channels/smartcard/client/smartcard_operations.c +++ b/channels/smartcard/client/smartcard_operations.c @@ -38,8 +38,6 @@ #include "smartcard_main.h" -#define TAG "smartcard.client" - const char* smartcard_get_ioctl_string(UINT32 ioControlCode, BOOL funcName) { switch (ioControlCode) @@ -1070,7 +1068,7 @@ UINT32 smartcard_irp_device_control_decode(SMARTCARD_DEVICE* smartcard, SMARTCAR WLog_Print(smartcard->log, WLOG_DEBUG, "%s (0x%08X) FileId: %d CompletionId: %d", smartcard_get_ioctl_string(ioControlCode, TRUE), ioControlCode, irp->FileId, irp->CompletionId); #if 0 - CLOG_DBG("%s (0x%08X) FileId: %d CompletionId: %d\n", + WLog_DBG(TAG, "%s (0x%08X) FileId: %d CompletionId: %d\n", smartcard_get_ioctl_string(ioControlCode, TRUE), ioControlCode, irp->FileId, irp->CompletionId); #endif diff --git a/channels/tsmf/client/CMakeLists.txt b/channels/tsmf/client/CMakeLists.txt index 87e6dea8c..8febf15c8 100644 --- a/channels/tsmf/client/CMakeLists.txt +++ b/channels/tsmf/client/CMakeLists.txt @@ -40,12 +40,7 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} TRUE set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils freerdp-common) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) @@ -62,7 +57,7 @@ if(WITH_GSTREAMER_0_10 OR WITH_GSTREAMER_1_0) find_feature(XRandR ${XRANDR_FEATURE_TYPE} ${XRANDR_FEATURE_PURPOSE} ${XRANDR_FEATURE_DESCRIPTION}) if (WITH_XRANDR) add_channel_client_subsystem(${MODULE_PREFIX} ${CHANNEL_NAME} "gstreamer" "decoder") - else() + else() message(WARNING "Disabling tsmf gstreamer because XRandR wasn't found") endif() endif() diff --git a/channels/tsmf/client/alsa/CMakeLists.txt b/channels/tsmf/client/alsa/CMakeLists.txt index 8e1fbde13..143a69be9 100644 --- a/channels/tsmf/client/alsa/CMakeLists.txt +++ b/channels/tsmf/client/alsa/CMakeLists.txt @@ -27,13 +27,6 @@ add_channel_client_subsystem_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_N set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-codec freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${ALSA_LIBRARIES}) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} freerdp ${ALSA_LIBRARIES}) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/tsmf/client/alsa/tsmf_alsa.c b/channels/tsmf/client/alsa/tsmf_alsa.c index 8c95b337c..dec1e3443 100644 --- a/channels/tsmf/client/alsa/tsmf_alsa.c +++ b/channels/tsmf/client/alsa/tsmf_alsa.c @@ -56,7 +56,7 @@ static BOOL tsmf_alsa_open_device(TSMFAlsaAudioDevice *alsa) error = snd_pcm_open(&alsa->out_handle, alsa->device, SND_PCM_STREAM_PLAYBACK, 0); if(error < 0) { - CLOG_ERR("failed to open device %s", alsa->device); + WLog_ERR(TAG, "failed to open device %s", alsa->device); return FALSE; } DEBUG_TSMF("open device %s", alsa->device); @@ -95,7 +95,7 @@ static BOOL tsmf_alsa_set_format(ITSMFAudioDevice *audio, error = snd_pcm_hw_params_malloc(&hw_params); if(error < 0) { - CLOG_ERR("snd_pcm_hw_params_malloc failed"); + WLog_ERR(TAG, "snd_pcm_hw_params_malloc failed"); return FALSE; } snd_pcm_hw_params_any(alsa->out_handle, hw_params); @@ -115,7 +115,7 @@ static BOOL tsmf_alsa_set_format(ITSMFAudioDevice *audio, error = snd_pcm_sw_params_malloc(&sw_params); if(error < 0) { - CLOG_ERR("snd_pcm_sw_params_malloc"); + WLog_ERR(TAG, "snd_pcm_sw_params_malloc"); return FALSE; } snd_pcm_sw_params_current(alsa->out_handle, sw_params); diff --git a/channels/tsmf/client/ffmpeg/CMakeLists.txt b/channels/tsmf/client/ffmpeg/CMakeLists.txt index c321d7013..d381cd97b 100644 --- a/channels/tsmf/client/ffmpeg/CMakeLists.txt +++ b/channels/tsmf/client/ffmpeg/CMakeLists.txt @@ -27,18 +27,13 @@ add_channel_client_subsystem_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_N set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - if(APPLE) # For this to work on apple, we need to add some frameworks FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation) FIND_LIBRARY(COREVIDEO_LIBRARY CoreVideo) FIND_LIBRARY(COREVIDEODECODE_LIBRARY VideoDecodeAcceleration) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${FFMPEG_LIBRARIES} ${COREFOUNDATION_LIBRARY} ${COREVIDEO_LIBRARY} ${COREVIDEODECODE_LIBRARY}) - target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS} freerdp) else() set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${FFMPEG_LIBRARIES}) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c index 428ceaa97..657ac29c7 100644 --- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c +++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c @@ -89,7 +89,7 @@ static BOOL tsmf_ffmpeg_init_context(ITSMFDecoder *decoder) mdecoder->codec_context = avcodec_alloc_context3(NULL); if(!mdecoder->codec_context) { - CLOG_ERR("avcodec_alloc_context failed."); + WLog_ERR(TAG, "avcodec_alloc_context failed."); return FALSE; } return TRUE; @@ -143,7 +143,7 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder *decoder, const TS_AM_MEDIA_TYP mdecoder->codec = avcodec_find_decoder(mdecoder->codec_id); if(!mdecoder->codec) { - CLOG_ERR("avcodec_find_decoder failed."); + WLog_ERR(TAG, "avcodec_find_decoder failed."); return FALSE; } mdecoder->codec_context->codec_id = mdecoder->codec_id; @@ -205,7 +205,7 @@ static BOOL tsmf_ffmpeg_prepare(ITSMFDecoder *decoder) TSMFFFmpegDecoder *mdecoder = (TSMFFFmpegDecoder *) decoder; if(avcodec_open2(mdecoder->codec_context, mdecoder->codec, NULL) < 0) { - CLOG_ERR("avcodec_open2 failed."); + WLog_ERR(TAG, "avcodec_open2 failed."); return FALSE; } mdecoder->prepared = 1; @@ -301,36 +301,36 @@ static BOOL tsmf_ffmpeg_decode_video(ITSMFDecoder *decoder, const BYTE *data, UI #endif if(len < 0) { - CLOG_ERR("data_size %d, avcodec_decode_video failed (%d)", data_size, len); + WLog_ERR(TAG, "data_size %d, avcodec_decode_video failed (%d)", data_size, len); + ret = FALSE; + } + else if (!decoded) + { + WLog_ERR(TAG, "data_size %d, no frame is decoded.", data_size); ret = FALSE; } else - if(!decoded) - { - CLOG_ERR("data_size %d, no frame is decoded.", data_size); - ret = FALSE; - } - else - { - DEBUG_TSMF("linesize[0] %d linesize[1] %d linesize[2] %d linesize[3] %d " - "pix_fmt %d width %d height %d", - mdecoder->frame->linesize[0], mdecoder->frame->linesize[1], - mdecoder->frame->linesize[2], mdecoder->frame->linesize[3], + { + DEBUG_TSMF("linesize[0] %d linesize[1] %d linesize[2] %d linesize[3] %d " + "pix_fmt %d width %d height %d", + mdecoder->frame->linesize[0], mdecoder->frame->linesize[1], + mdecoder->frame->linesize[2], mdecoder->frame->linesize[3], + mdecoder->codec_context->pix_fmt, + mdecoder->codec_context->width, mdecoder->codec_context->height); + mdecoder->decoded_size = avpicture_get_size(mdecoder->codec_context->pix_fmt, + mdecoder->codec_context->width, mdecoder->codec_context->height); + mdecoder->decoded_data = malloc(mdecoder->decoded_size); + ZeroMemory(mdecoder->decoded_data, mdecoder->decoded_size); + frame = avcodec_alloc_frame(); + avpicture_fill((AVPicture*) frame, mdecoder->decoded_data, mdecoder->codec_context->pix_fmt, mdecoder->codec_context->width, mdecoder->codec_context->height); - mdecoder->decoded_size = avpicture_get_size(mdecoder->codec_context->pix_fmt, - mdecoder->codec_context->width, mdecoder->codec_context->height); - mdecoder->decoded_data = malloc(mdecoder->decoded_size); - ZeroMemory(mdecoder->decoded_data, mdecoder->decoded_size); - frame = avcodec_alloc_frame(); - avpicture_fill((AVPicture *) frame, mdecoder->decoded_data, - mdecoder->codec_context->pix_fmt, - mdecoder->codec_context->width, mdecoder->codec_context->height); - av_picture_copy((AVPicture *) frame, (AVPicture *) mdecoder->frame, - mdecoder->codec_context->pix_fmt, - mdecoder->codec_context->width, mdecoder->codec_context->height); - av_free(frame); - } + av_picture_copy((AVPicture*) frame, (AVPicture*) mdecoder->frame, + mdecoder->codec_context->pix_fmt, + mdecoder->codec_context->width, mdecoder->codec_context->height); + av_free(frame); + } + return ret; } @@ -344,15 +344,14 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder *decoder, const BYTE *data, UI BYTE *dst; int dst_offset; #if 0 - LLOGLN(0, ("tsmf_ffmpeg_decode_audio: data_size %d", data_size)); + WLog_DBG(TAG, ("tsmf_ffmpeg_decode_audio: data_size %d", data_size)); int i; for(i = 0; i < data_size; i++) { - LLOG(0, ("%02X ", data[i])); + WLog_DBG(TAG, ("%02X ", data[i])); if(i % 16 == 15) - LLOG(0, ("\n")); + WLog_DBG(TAG, ("\n")); } - LLOG(0, ("\n")); #endif if(mdecoder->decoded_size_max == 0) mdecoder->decoded_size_max = MAX_AUDIO_FRAME_SIZE + 16; @@ -403,7 +402,7 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder *decoder, const BYTE *data, UI #endif if(len <= 0 || frame_size <= 0) { - CLOG_ERR("error decoding"); + WLog_ERR(TAG, "error decoding"); break; } src += len; @@ -443,7 +442,7 @@ static BOOL tsmf_ffmpeg_decode(ITSMFDecoder *decoder, const BYTE *data, UINT32 d case AVMEDIA_TYPE_AUDIO: return tsmf_ffmpeg_decode_audio(decoder, data, data_size, extensions); default: - CLOG_ERR("unknown media type."); + WLog_ERR(TAG, "unknown media type."); return FALSE; } } @@ -467,8 +466,8 @@ static UINT32 tsmf_ffmpeg_get_decoded_format(ITSMFDecoder *decoder) case PIX_FMT_YUV420P: return RDP_PIXFMT_I420; default: - CLOG_ERR("unsupported pixel format %u", - mdecoder->codec_context->pix_fmt); + WLog_ERR(TAG, "unsupported pixel format %u", + mdecoder->codec_context->pix_fmt); return (UINT32) -1; } } @@ -509,10 +508,10 @@ static void tsmf_ffmpeg_free(ITSMFDecoder *decoder) static BOOL initialized = FALSE; #ifdef STATIC_CHANNELS -#define freerdp_tsmf_client_decoder_subsystem_entry ffmpeg_freerdp_tsmf_client_decoder_subsystem_entry +#define freerdp_tsmf_client_subsystem_entry ffmpeg_freerdp_tsmf_client_decoder_subsystem_entry #endif -ITSMFDecoder *freerdp_tsmf_client_decoder_subsystem_entry(void) +ITSMFDecoder *freerdp_tsmf_client_subsystem_entry(void) { TSMFFFmpegDecoder *decoder; if(!initialized) @@ -520,8 +519,9 @@ ITSMFDecoder *freerdp_tsmf_client_decoder_subsystem_entry(void) avcodec_register_all(); initialized = TRUE; } - CLOG_ERR( "TSMFDecoderEntry FFMPEG\n"); - decoder = (TSMFFFmpegDecoder *) malloc(sizeof(TSMFFFmpegDecoder)); + + WLog_DBG(TAG, "TSMFDecoderEntry FFMPEG"); + decoder = (TSMFFFmpegDecoder*) malloc(sizeof(TSMFFFmpegDecoder)); ZeroMemory(decoder, sizeof(TSMFFFmpegDecoder)); decoder->iface.SetFormat = tsmf_ffmpeg_set_format; decoder->iface.Decode = tsmf_ffmpeg_decode; diff --git a/channels/tsmf/client/gstreamer/CMakeLists.txt b/channels/tsmf/client/gstreamer/CMakeLists.txt index 3415da717..ee07c947c 100644 --- a/channels/tsmf/client/gstreamer/CMakeLists.txt +++ b/channels/tsmf/client/gstreamer/CMakeLists.txt @@ -64,14 +64,6 @@ add_channel_client_subsystem_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_N set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} - ${LIBS}) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} ${LIBS} freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/tsmf/client/gstreamer/tsmf_X11.c b/channels/tsmf/client/gstreamer/tsmf_X11.c index 8db874b12..1bfc11e51 100644 --- a/channels/tsmf/client/gstreamer/tsmf_X11.c +++ b/channels/tsmf/client/gstreamer/tsmf_X11.c @@ -87,7 +87,7 @@ int tsmf_platform_create(TSMFGstreamerDecoder *decoder) if (!hdl) { - CLOG_ERR("%s: Could not allocate handle.", __func__); + WLog_ERR(TAG, "Could not allocate handle."); return -1; } @@ -97,8 +97,7 @@ int tsmf_platform_create(TSMFGstreamerDecoder *decoder) if (hdl->shmid < 0) { - CLOG_ERR("%s: failed to get access to shared memory - shmget()", - __func__); + WLog_ERR(TAG, "failed to get access to shared memory - shmget()"); return -2; } else @@ -106,7 +105,7 @@ int tsmf_platform_create(TSMFGstreamerDecoder *decoder) if (hdl->xfwin == (int *)-1) { - CLOG_ERR("%s: shmat failed!", __func__); + WLog_ERR(TAG, "shmat failed!"); return -3; } @@ -114,7 +113,7 @@ int tsmf_platform_create(TSMFGstreamerDecoder *decoder) if (!hdl->disp) { - CLOG_ERR("Failed to open display"); + WLog_ERR(TAG, "Failed to open display"); return -4; } @@ -140,7 +139,7 @@ int tsmf_platform_register_handler(TSMFGstreamerDecoder *decoder) if (!bus) { - CLOG_ERR("gst_pipeline_get_bus failed!"); + WLog_ERR(TAG, "gst_pipeline_get_bus failed!"); return 1; } @@ -193,7 +192,7 @@ int tsmf_window_create(TSMFGstreamerDecoder *decoder) if (!hdl->subwin) { - CLOG_ERR("Could not create subwindow!"); + WLog_ERR(TAG, "Could not create subwindow!"); } XMapWindow(hdl->disp, hdl->subwin); @@ -238,14 +237,14 @@ int tsmf_window_resize(TSMFGstreamerDecoder *decoder, int x, int y, int width, if (!gst_video_overlay_set_render_rectangle(overlay, 0, 0, width, height)) { - CLOG_ERR("Could not resize overlay!"); + WLog_ERR(TAG, "Could not resize overlay!"); } gst_video_overlay_expose(overlay); #else if (!gst_x_overlay_set_render_rectangle(overlay, 0, 0, width, height)) { - CLOG_ERR("Could not resize overlay!"); + WLog_ERR(TAG, "Could not resize overlay!"); } gst_x_overlay_expose(overlay); diff --git a/channels/tsmf/client/gstreamer/tsmf_gstreamer.c b/channels/tsmf/client/gstreamer/tsmf_gstreamer.c index b4c8635d2..0139b8996 100644 --- a/channels/tsmf/client/gstreamer/tsmf_gstreamer.c +++ b/channels/tsmf/client/gstreamer/tsmf_gstreamer.c @@ -120,10 +120,10 @@ int tsmf_gstreamer_pipeline_set_state(TSMFGstreamerDecoder *mdecoder, GstState d state_change = gst_element_set_state(mdecoder->pipe, desired_state); if (state_change == GST_STATE_CHANGE_FAILURE) - CLOG_ERR("%s: (%s) GST_STATE_CHANGE_FAILURE.", sname, name); + WLog_ERR(TAG, "%s: (%s) GST_STATE_CHANGE_FAILURE.", sname, name); else if (state_change == GST_STATE_CHANGE_ASYNC) { - CLOG_ERR("%s: (%s) GST_STATE_CHANGE_ASYNC.", sname, name); + WLog_ERR(TAG, "%s: (%s) GST_STATE_CHANGE_ASYNC.", sname, name); mdecoder->state = desired_state; } else @@ -142,7 +142,7 @@ static GstBuffer *tsmf_get_buffer_from_data(const void *raw_data, gsize size) if (!data) { - CLOG_ERR("Could not allocate %"G_GSIZE_FORMAT" bytes of data.", size); + WLog_ERR(TAG, "Could not allocate %"G_GSIZE_FORMAT" bytes of data.", size); return NULL; } @@ -154,7 +154,7 @@ static GstBuffer *tsmf_get_buffer_from_data(const void *raw_data, gsize size) if (!buffer) { - CLOG_ERR("Could not create GstBuffer"); + WLog_ERR(TAG, "Could not create GstBuffer"); free(data); return NULL; } @@ -191,10 +191,10 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m { case TSMF_SUB_TYPE_WVC1: mdecoder->gst_caps = gst_caps_new_simple("video/x-wmv", - "bitrate", G_TYPE_UINT, media_type->BitRate, "width", G_TYPE_INT, media_type->Width, "height", G_TYPE_INT, media_type->Height, "wmvversion", G_TYPE_INT, 3, + "format", G_TYPE_STRING, "WVC1", NULL); break; case TSMF_SUB_TYPE_MP4S: @@ -346,7 +346,7 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m NULL); break; default: - CLOG_ERR("unknown format:(%d).", media_type->SubType); + WLog_ERR(TAG, "unknown format:(%d).", media_type->SubType); return FALSE; } @@ -358,7 +358,7 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m if (!buffer) { - CLOG_ERR("could not allocate GstBuffer!"); + WLog_ERR(TAG, "could not allocate GstBuffer!"); return FALSE; } @@ -375,7 +375,7 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m return TRUE; } -void tsmf_gstreamer_clean_up(TSMFGstreamerDecoder *mdecoder) +void tsmf_gstreamer_clean_up(TSMFGstreamerDecoder* mdecoder) { //Cleaning up elements if (!mdecoder || !mdecoder->pipe) @@ -416,7 +416,7 @@ BOOL tsmf_gstreamer_pipeline_build(TSMFGstreamerDecoder *mdecoder) if (!mdecoder->pipe) { - CLOG_ERR("Failed to create new pipe"); + WLog_ERR(TAG, "Failed to create new pipe"); return FALSE; } @@ -424,7 +424,7 @@ BOOL tsmf_gstreamer_pipeline_build(TSMFGstreamerDecoder *mdecoder) if (!mdecoder->src) { - CLOG_ERR("Failed to get appsrc"); + WLog_ERR(TAG, "Failed to get appsrc"); return FALSE; } @@ -432,7 +432,7 @@ BOOL tsmf_gstreamer_pipeline_build(TSMFGstreamerDecoder *mdecoder) if (!mdecoder->outsink) { - CLOG_ERR("Failed to get sink"); + WLog_ERR(TAG, "Failed to get sink"); return FALSE; } @@ -442,7 +442,7 @@ BOOL tsmf_gstreamer_pipeline_build(TSMFGstreamerDecoder *mdecoder) if (!mdecoder->volume) { - CLOG_ERR("Failed to get volume"); + WLog_ERR(TAG, "Failed to get volume"); return FALSE; } } @@ -482,7 +482,7 @@ static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder *decoder, const BYTE *data, UIN if (!mdecoder) { - CLOG_ERR("Decoder not initialized!"); + WLog_ERR(TAG, "Decoder not initialized!"); return FALSE; } @@ -498,13 +498,13 @@ static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder *decoder, const BYTE *data, UIN if (mdecoder->gst_caps == NULL) { - CLOG_ERR("tsmf_gstreamer_set_format not called or invalid format."); + WLog_ERR(TAG, "tsmf_gstreamer_set_format not called or invalid format."); return FALSE; } if (!mdecoder->src) { - CLOG_ERR("failed to construct pipeline correctly. Unable to push buffer to source element."); + WLog_ERR(TAG, "failed to construct pipeline correctly. Unable to push buffer to source element."); return FALSE; } @@ -512,7 +512,7 @@ static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder *decoder, const BYTE *data, UIN if (gst_buf == NULL) { - CLOG_ERR("tsmf_get_buffer_from_data(%p, %d) failed.", data, data_size); + WLog_ERR(TAG, "tsmf_get_buffer_from_data(%p, %d) failed.", data, data_size); return FALSE; } @@ -534,7 +534,7 @@ static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder *decoder, const BYTE *data, UIN GST_SEEK_TYPE_SET, sample_time, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)) { - CLOG_ERR("seek failed"); + WLog_ERR(TAG, "seek failed"); } mdecoder->pipeline_start_time_valid = 0; @@ -608,7 +608,7 @@ static void tsmf_gstreamer_control(ITSMFDecoder *decoder, ITSMFControlMsg contro if (mdecoder->paused) { - CLOG_ERR("%s: Ignoring control PAUSE, already received!", get_type(mdecoder)); + WLog_ERR(TAG, "%s: Ignoring control PAUSE, already received!", get_type(mdecoder)); return; } @@ -624,7 +624,7 @@ static void tsmf_gstreamer_control(ITSMFDecoder *decoder, ITSMFControlMsg contro if (!mdecoder->paused && !mdecoder->shutdown) { - CLOG_ERR("%s: Ignoring control RESUME, already received!", get_type(mdecoder)); + WLog_ERR(TAG, "%s: Ignoring control RESUME, already received!", get_type(mdecoder)); return; } @@ -642,7 +642,7 @@ static void tsmf_gstreamer_control(ITSMFDecoder *decoder, ITSMFControlMsg contro if (mdecoder->shutdown) { - CLOG_ERR("%s: Ignoring control STOP, already received!", get_type(mdecoder)); + WLog_ERR(TAG, "%s: Ignoring control STOP, already received!", get_type(mdecoder)); return; } @@ -656,7 +656,7 @@ static void tsmf_gstreamer_control(ITSMFDecoder *decoder, ITSMFControlMsg contro gst_app_src_end_of_stream((GstAppSrc *)mdecoder->src); } else - CLOG_ERR("Unknown control message %08x", control_msg); + WLog_ERR(TAG, "Unknown control message %08x", control_msg); } static BOOL tsmf_gstreamer_buffer_filled(ITSMFDecoder *decoder) @@ -748,10 +748,10 @@ BOOL tsmf_gstreamer_sync(ITSMFDecoder *decoder, void (*cb)(void *), void *stream } #ifdef STATIC_CHANNELS -#define freerdp_tsmf_client_decoder_subsystem_entry gstreamer_freerdp_tsmf_client_decoder_subsystem_entry +#define freerdp_tsmf_client_subsystem_entry gstreamer_freerdp_tsmf_client_decoder_subsystem_entry #endif -ITSMFDecoder *freerdp_tsmf_client_decoder_subsystem_entry(void) +ITSMFDecoder *freerdp_tsmf_client_subsystem_entry(void) { TSMFGstreamerDecoder *decoder; diff --git a/channels/tsmf/client/pulse/CMakeLists.txt b/channels/tsmf/client/pulse/CMakeLists.txt index cdfa7fe5a..f0cf8abd9 100644 --- a/channels/tsmf/client/pulse/CMakeLists.txt +++ b/channels/tsmf/client/pulse/CMakeLists.txt @@ -27,13 +27,6 @@ add_channel_client_subsystem_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_N set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-codec freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${PULSE_LIBRARY}) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} freerdp) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets) diff --git a/channels/tsmf/client/pulse/tsmf_pulse.c b/channels/tsmf/client/pulse/tsmf_pulse.c index c04c5b3ea..f35f24902 100644 --- a/channels/tsmf/client/pulse/tsmf_pulse.c +++ b/channels/tsmf/client/pulse/tsmf_pulse.c @@ -72,7 +72,7 @@ static BOOL tsmf_pulse_connect(TSMFPulseAudioDevice *pulse) return FALSE; if(pa_context_connect(pulse->context, NULL, 0, NULL)) { - CLOG_ERR("pa_context_connect failed (%d)", + WLog_ERR(TAG, "pa_context_connect failed (%d)", pa_context_errno(pulse->context)); return FALSE; } @@ -80,7 +80,7 @@ static BOOL tsmf_pulse_connect(TSMFPulseAudioDevice *pulse) if(pa_threaded_mainloop_start(pulse->mainloop) < 0) { pa_threaded_mainloop_unlock(pulse->mainloop); - CLOG_ERR("pa_threaded_mainloop_start failed (%d)", + WLog_ERR(TAG, "pa_threaded_mainloop_start failed (%d)", pa_context_errno(pulse->context)); return FALSE; } @@ -120,19 +120,19 @@ static BOOL tsmf_pulse_open(ITSMFAudioDevice *audio, const char *device) pulse->mainloop = pa_threaded_mainloop_new(); if(!pulse->mainloop) { - CLOG_ERR("pa_threaded_mainloop_new failed"); + WLog_ERR(TAG, "pa_threaded_mainloop_new failed"); return FALSE; } pulse->context = pa_context_new(pa_threaded_mainloop_get_api(pulse->mainloop), "freerdp"); if(!pulse->context) { - CLOG_ERR("pa_context_new failed"); + WLog_ERR(TAG, "pa_context_new failed"); return FALSE; } pa_context_set_state_callback(pulse->context, tsmf_pulse_context_state_callback, pulse); if(tsmf_pulse_connect(pulse)) { - CLOG_ERR("tsmf_pulse_connect failed"); + WLog_ERR(TAG, "tsmf_pulse_connect failed"); return FALSE; } DEBUG_TSMF("open device %s", pulse->device); @@ -214,7 +214,7 @@ static BOOL tsmf_pulse_open_stream(TSMFPulseAudioDevice *pulse) if(!pulse->stream) { pa_threaded_mainloop_unlock(pulse->mainloop); - CLOG_ERR("pa_stream_new failed (%d)", + WLog_ERR(TAG, "pa_stream_new failed (%d)", pa_context_errno(pulse->context)); return FALSE; } @@ -233,7 +233,7 @@ static BOOL tsmf_pulse_open_stream(TSMFPulseAudioDevice *pulse) NULL, NULL) < 0) { pa_threaded_mainloop_unlock(pulse->mainloop); - CLOG_ERR("pa_stream_connect_playback failed (%d)", + WLog_ERR(TAG, "pa_stream_connect_playback failed (%d)", pa_context_errno(pulse->context)); return FALSE; } @@ -244,7 +244,7 @@ static BOOL tsmf_pulse_open_stream(TSMFPulseAudioDevice *pulse) break; if(!PA_STREAM_IS_GOOD(state)) { - CLOG_ERR("bad stream state (%d)", + WLog_ERR(TAG, "bad stream state (%d)", pa_context_errno(pulse->context)); break; } diff --git a/channels/tsmf/client/tsmf_audio.c b/channels/tsmf/client/tsmf_audio.c index 4e43ba80f..d03ebbcef 100644 --- a/channels/tsmf/client/tsmf_audio.c +++ b/channels/tsmf/client/tsmf_audio.c @@ -41,7 +41,7 @@ static ITSMFAudioDevice* tsmf_load_audio_device_by_name(const char* name, const if (audio == NULL) { - CLOG_ERR("failed to call export function in %s", name); + WLog_ERR(TAG, "failed to call export function in %s", name); return NULL; } diff --git a/channels/tsmf/client/tsmf_codec.c b/channels/tsmf/client/tsmf_codec.c index cb6bd25b3..5657a8dd0 100644 --- a/channels/tsmf/client/tsmf_codec.c +++ b/channels/tsmf/client/tsmf_codec.c @@ -269,29 +269,27 @@ static void tsmf_print_guid(const BYTE* guid) int i; for (i = 3; i >= 0; i--) - CLOG_ERR("%02X", guid[i]); + WLog_INFO(TAG, "%02X", guid[i]); - CLOG_ERR("-"); + WLog_INFO(TAG, "-"); for (i = 5; i >= 4; i--) - CLOG_ERR("%02X", guid[i]); + WLog_INFO(TAG, "%02X", guid[i]); - CLOG_ERR("-"); + WLog_INFO(TAG, "-"); for (i = 7; i >= 6; i--) - CLOG_ERR("%02X", guid[i]); + WLog_INFO(TAG, "%02X", guid[i]); - CLOG_ERR("-"); + WLog_INFO(TAG, "-"); for (i = 8; i < 16; i++) { - CLOG_ERR("%02X", guid[i]); + WLog_INFO(TAG, "%02X", guid[i]); if (i == 9) - CLOG_ERR("-"); + WLog_INFO(TAG, "-"); } - - CLOG_ERR("\n"); #endif } diff --git a/channels/tsmf/client/tsmf_decoder.c b/channels/tsmf/client/tsmf_decoder.c index 59262508c..0067cd548 100644 --- a/channels/tsmf/client/tsmf_decoder.c +++ b/channels/tsmf/client/tsmf_decoder.c @@ -42,7 +42,7 @@ static ITSMFDecoder *tsmf_load_decoder_by_name(const char *name, TS_AM_MEDIA_TYP decoder = entry(); if(decoder == NULL) { - CLOG_ERR("failed to call export function in %s", name); + WLog_ERR(TAG, "failed to call export function in %s", name); return NULL; } if(!decoder->SetFormat(decoder, media_type)) diff --git a/channels/tsmf/client/tsmf_ifman.c b/channels/tsmf/client/tsmf_ifman.c index 6c2d99b9b..18c654b27 100644 --- a/channels/tsmf/client/tsmf_ifman.c +++ b/channels/tsmf/client/tsmf_ifman.c @@ -80,7 +80,7 @@ int tsmf_ifman_exchange_capability_request(TSMF_IFMAN *ifman) MMREDIR_CAPABILITY_PLATFORM_MF | MMREDIR_CAPABILITY_PLATFORM_DSHOW); break; default: - CLOG_ERR("unknown capability type %d", CapabilityType); + WLog_ERR(TAG, "unknown capability type %d", CapabilityType); break; } Stream_SetPosition(ifman->output, pos + cbCapabilityLength); @@ -236,7 +236,7 @@ int tsmf_ifman_shutdown_presentation(TSMF_IFMAN *ifman) if(presentation) tsmf_presentation_free(presentation); else - CLOG_ERR("unknown presentation id"); + WLog_ERR(TAG, "unknown presentation id"); Stream_EnsureRemainingCapacity(ifman->output, 4); Stream_Write_UINT32(ifman->output, 0); /* Result */ ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB; @@ -261,7 +261,7 @@ int tsmf_ifman_on_stream_volume(TSMF_IFMAN *ifman) } else { - CLOG_ERR("unknown presentation id"); + WLog_ERR(TAG, "unknown presentation id"); } ifman->output_pending = TRUE; return 0; @@ -393,13 +393,13 @@ int tsmf_ifman_on_sample(TSMF_IFMAN *ifman) presentation = tsmf_presentation_find_by_id(ifman->presentation_id); if(presentation == NULL) { - CLOG_ERR("unknown presentation id"); + WLog_ERR(TAG, "unknown presentation id"); return 1; } stream = tsmf_stream_find_by_id(presentation, StreamId); if(stream == NULL) { - CLOG_ERR("unknown stream id"); + WLog_ERR(TAG, "unknown stream id"); return 1; } tsmf_stream_push_sample(stream, ifman->channel_callback, @@ -420,7 +420,7 @@ int tsmf_ifman_on_flush(TSMF_IFMAN *ifman) presentation = tsmf_presentation_find_by_id(ifman->presentation_id); if(presentation == NULL) { - CLOG_ERR("unknown presentation id"); + WLog_ERR(TAG, "unknown presentation id"); return 1; } tsmf_presentation_flush(presentation); @@ -460,7 +460,7 @@ int tsmf_ifman_on_playback_started(TSMF_IFMAN *ifman) if(presentation) tsmf_presentation_start(presentation); else - CLOG_ERR("unknown presentation id"); + WLog_ERR(TAG, "unknown presentation id"); Stream_EnsureRemainingCapacity(ifman->output, 16); Stream_Write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ Stream_Write_UINT32(ifman->output, 0); /* StreamId */ @@ -480,7 +480,7 @@ int tsmf_ifman_on_playback_paused(TSMF_IFMAN *ifman) if(presentation) tsmf_presentation_paused(presentation); else - CLOG_ERR("unknown presentation id"); + WLog_ERR(TAG, "unknown presentation id"); return 0; } @@ -494,7 +494,7 @@ int tsmf_ifman_on_playback_restarted(TSMF_IFMAN *ifman) if(presentation) tsmf_presentation_restarted(presentation); else - CLOG_ERR("unknown presentation id"); + WLog_ERR(TAG, "unknown presentation id"); return 0; } @@ -506,7 +506,7 @@ int tsmf_ifman_on_playback_stopped(TSMF_IFMAN *ifman) if(presentation) tsmf_presentation_stop(presentation); else - CLOG_ERR("unknown presentation id"); + WLog_ERR(TAG, "unknown presentation id"); Stream_EnsureRemainingCapacity(ifman->output, 16); Stream_Write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ Stream_Write_UINT32(ifman->output, 0); /* StreamId */ diff --git a/channels/tsmf/client/tsmf_main.c b/channels/tsmf/client/tsmf_main.c index 76b0a7c32..65ce35b4c 100644 --- a/channels/tsmf/client/tsmf_main.c +++ b/channels/tsmf/client/tsmf_main.c @@ -89,14 +89,14 @@ void tsmf_playback_ack(IWTSVirtualChannelCallback *pChannelCallback, Stream_Write_UINT64(s, data_size); /* cbData */ DEBUG_TSMF("response size %d", (int) Stream_GetPosition(s)); if(!callback || !callback->channel || !callback->channel->Write) - CLOG_ERR("callback=%p, channel=%p, write=%p", callback, + WLog_ERR(TAG, "callback=%p, channel=%p, write=%p", callback, callback->channel, callback->channel->Write); else status = callback->channel->Write(callback->channel, Stream_GetPosition(s), Stream_Buffer(s), NULL); if(status) { - CLOG_ERR("response error %d", status); + WLog_ERR(TAG, "response error %d", status); } Stream_Free(s, TRUE); } @@ -108,7 +108,7 @@ BOOL tsmf_push_event(IWTSVirtualChannelCallback *pChannelCallback, wMessage *eve status = callback->channel_mgr->PushEvent(callback->channel_mgr, event); if(status) { - CLOG_ERR("response error %d", status); + WLog_ERR(TAG, "response error %d", status); return FALSE; } return TRUE; @@ -130,7 +130,7 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, w /* 2.2.1 Shared Message Header (SHARED_MSG_HEADER) */ if(cbSize < 12) { - CLOG_ERR("invalid size. cbSize=%d", cbSize); + WLog_ERR(TAG, "invalid size. cbSize=%d", cbSize); return 1; } @@ -272,7 +272,7 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, w } if(status == -1) { - CLOG_ERR("InterfaceId 0x%X FunctionId 0x%X not processed.", + WLog_ERR(TAG, "InterfaceId 0x%X FunctionId 0x%X not processed.", InterfaceId, FunctionId); /* When a request is not implemented we return empty response indicating error */ } @@ -289,7 +289,7 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, w status = callback->channel->Write(callback->channel, length, Stream_Buffer(output), NULL); if(status) { - CLOG_ERR("response error %d", status); + WLog_ERR(TAG, "response error %d", status); } } Stream_Free(output, TRUE); diff --git a/channels/tsmf/client/tsmf_media.c b/channels/tsmf/client/tsmf_media.c index 611f80365..6538983f6 100644 --- a/channels/tsmf/client/tsmf_media.c +++ b/channels/tsmf/client/tsmf_media.c @@ -271,7 +271,7 @@ TSMF_PRESENTATION *tsmf_presentation_new(const BYTE *guid, IWTSVirtualChannelCal if (!presentation) { - CLOG_ERR("calloc failed"); + WLog_ERR(TAG, "calloc failed"); return NULL; } @@ -320,7 +320,7 @@ TSMF_PRESENTATION *tsmf_presentation_find_by_id(const BYTE *guid) ArrayList_Unlock(presentation_list); if (!found) - CLOG_ERR("presentation id %s not found", guid_to_string(guid, guid_str, sizeof(guid_str))); + WLog_WARN(TAG, "presentation id %s not found", guid_to_string(guid, guid_str, sizeof(guid_str))); return (found) ? presentation : NULL; } @@ -902,7 +902,7 @@ TSMF_STREAM *tsmf_stream_new(TSMF_PRESENTATION *presentation, UINT32 stream_id) if (stream) { - CLOG_ERR("duplicated stream id %d!", stream_id); + WLog_ERR(TAG, "duplicated stream id %d!", stream_id); return NULL; } @@ -910,7 +910,7 @@ TSMF_STREAM *tsmf_stream_new(TSMF_PRESENTATION *presentation, UINT32 stream_id) if (!stream) { - CLOG_ERR("Calloc failed"); + WLog_ERR(TAG, "Calloc failed"); return NULL; } @@ -966,7 +966,7 @@ void tsmf_stream_set_format(TSMF_STREAM *stream, const char *name, wStream *s) if (stream->decoder) { - CLOG_ERR("duplicated call"); + WLog_ERR(TAG, "duplicated call"); return; } @@ -1071,7 +1071,7 @@ void tsmf_stream_push_sample(TSMF_STREAM *stream, IWTSVirtualChannelCallback *pC if (!sample) { - CLOG_ERR("calloc failed!"); + WLog_ERR(TAG, "calloc failed!"); return; } @@ -1087,7 +1087,7 @@ void tsmf_stream_push_sample(TSMF_STREAM *stream, IWTSVirtualChannelCallback *pC if (!sample->data) { - CLOG_ERR("calloc failed!"); + WLog_ERR(TAG, "calloc failed!"); free(sample); return; } diff --git a/channels/tsmf/client/tsmf_types.h b/channels/tsmf/client/tsmf_types.h index 4afbd1434..07cd999fc 100644 --- a/channels/tsmf/client/tsmf_types.h +++ b/channels/tsmf/client/tsmf_types.h @@ -28,10 +28,12 @@ #include #include +#define TAG CHANNELS_TAG("tsmf.client") + #ifdef WITH_DEBUG_TSMF -#define DEBUG_TSMF(fmt, ...) CLOG_CLASS(TSMF, fmt, ## __VA_ARGS__) +#define DEBUG_TSMF(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_TSMF(fmt, ...) CLOG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_TSMF(fmt, ...) do { } while (0) #endif typedef struct _TS_AM_MEDIA_TYPE diff --git a/channels/urbdrc/client/CMakeLists.txt b/channels/urbdrc/client/CMakeLists.txt index 1dd4ab54c..4d5069f93 100644 --- a/channels/urbdrc/client/CMakeLists.txt +++ b/channels/urbdrc/client/CMakeLists.txt @@ -42,12 +42,7 @@ set(${MODULE_PREFIX}_LIBS ${UDEV_LIBRARIES} ${UUID_LIBRARIES}) -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-common freerdp-utils) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/channels/urbdrc/client/data_transfer.c b/channels/urbdrc/client/data_transfer.c index dec8e547e..b0a37fd25 100644 --- a/channels/urbdrc/client/data_transfer.c +++ b/channels/urbdrc/client/data_transfer.c @@ -100,7 +100,7 @@ static int func_check_isochronous_fds(IUDEVICE* pdev) ret = isoch_queue->unregister_data(isoch_queue, isoch); if (!ret) - LLOGLN(0, ("isoch_queue_unregister_data: Not found isoch data!!\n")); + WLog_DBG(TAG, "isoch_queue_unregister_data: Not found isoch data!!"); pthread_mutex_unlock(&isoch_queue->isoch_loading); @@ -124,7 +124,7 @@ static int urbdrc_process_register_request_callback(URBDRC_CHANNEL_CALLBACK* cal UINT32 NumRequestCompletion = 0; UINT32 RequestCompletion = 0; - LLOGLN(urbdrc_debug, ("urbdrc_process_register_request_callback")); + WLog_DBG(TAG, "urbdrc_process_register_request_callback"); pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); @@ -165,7 +165,7 @@ static int urbdrc_process_cancel_request(BYTE* data, UINT32 data_sizem, IUDEVMAN data_read_UINT32(data + 0, CancelId); /** RequestId */ - LLOGLN(urbdrc_debug, ("urbdrc_process_cancel_request: id 0x%x", CancelId)); + WLog_DBG(TAG, "urbdrc_process_cancel_request: id 0x%x", CancelId); pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); @@ -180,19 +180,19 @@ static int urbdrc_process_cancel_request(BYTE* data, UINT32 data_sizem, IUDEVMAN static int urbdrc_process_retract_device_request(BYTE* data, UINT32 data_sizem, IUDEVMAN* udevman, UINT32 UsbDevice) { UINT32 Reason; - LLOGLN(urbdrc_debug, ("urbdrc_process_retract_device_request")); + WLog_DBG(TAG, "urbdrc_process_retract_device_request"); data_read_UINT32(data + 0, Reason); /** Reason */ switch (Reason) { case UsbRetractReason_BlockedByPolicy: - LLOGLN(urbdrc_debug, ("UsbRetractReason_BlockedByPolicy: now it is not support")); + WLog_DBG(TAG, "UsbRetractReason_BlockedByPolicy: now it is not support"); return -1; break; default: - LLOGLN(urbdrc_debug, ("urbdrc_process_retract_device_request: Unknown Reason %d", Reason)); + WLog_DBG(TAG, "urbdrc_process_retract_device_request: Unknown Reason %d", Reason); return -1; break; } @@ -215,7 +215,7 @@ static int urbdrc_process_io_control(URBDRC_CHANNEL_CALLBACK* callback, BYTE* da BYTE* out_data; int i, offset, success = 0; - LLOGLN(urbdrc_debug, ("urbdrc_process__io_control")); + WLog_DBG(TAG, "urbdrc_process__io_control"); data_read_UINT32(data + 0, IoControlCode); data_read_UINT32(data + 4, InputBufferSize); @@ -236,16 +236,16 @@ static int urbdrc_process_io_control(URBDRC_CHANNEL_CALLBACK* callback, BYTE* da switch (IoControlCode) { case IOCTL_INTERNAL_USB_SUBMIT_URB: /** 0x00220003 */ - LLOGLN(urbdrc_debug, ("ioctl: IOCTL_INTERNAL_USB_SUBMIT_URB")); - CLOG_ERR( " Function IOCTL_INTERNAL_USB_SUBMIT_URB: Unchecked\n"); + WLog_DBG(TAG, "ioctl: IOCTL_INTERNAL_USB_SUBMIT_URB"); + WLog_ERR(TAG, " Function IOCTL_INTERNAL_USB_SUBMIT_URB: Unchecked"); break; case IOCTL_INTERNAL_USB_RESET_PORT: /** 0x00220007 */ - LLOGLN(urbdrc_debug, ("ioctl: IOCTL_INTERNAL_USB_RESET_PORT")); + WLog_DBG(TAG, "ioctl: IOCTL_INTERNAL_USB_RESET_PORT"); break; case IOCTL_INTERNAL_USB_GET_PORT_STATUS: /** 0x00220013 */ - LLOGLN(urbdrc_debug, ("ioctl: IOCTL_INTERNAL_USB_GET_PORT_STATUS")); + WLog_DBG(TAG, "ioctl: IOCTL_INTERNAL_USB_GET_PORT_STATUS"); success = pdev->query_device_port_status(pdev, &usbd_status, &OutputBufferSize, OutputBuffer); @@ -261,24 +261,24 @@ static int urbdrc_process_io_control(URBDRC_CHANNEL_CALLBACK* callback, BYTE* da OutputBufferSize = 4; } - LLOGLN(urbdrc_debug, ("PORT STATUS(fake!):0x%02x%02x%02x%02x", - OutputBuffer[3], OutputBuffer[2], OutputBuffer[1], OutputBuffer[0])); + WLog_DBG(TAG, "PORT STATUS(fake!):0x%02x%02x%02x%02x", + OutputBuffer[3], OutputBuffer[2], OutputBuffer[1], OutputBuffer[0]); } break; case IOCTL_INTERNAL_USB_CYCLE_PORT: /** 0x0022001F */ - LLOGLN(urbdrc_debug, ("ioctl: IOCTL_INTERNAL_USB_CYCLE_PORT")); - CLOG_ERR( " Function IOCTL_INTERNAL_USB_CYCLE_PORT: Unchecked\n"); + WLog_DBG(TAG, "ioctl: IOCTL_INTERNAL_USB_CYCLE_PORT"); + WLog_ERR(TAG, " Function IOCTL_INTERNAL_USB_CYCLE_PORT: Unchecked"); break; case IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION: /** 0x00220027 */ - LLOGLN(urbdrc_debug, ("ioctl: IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION")); - CLOG_ERR( " Function IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION: Unchecked\n"); + WLog_DBG(TAG, "ioctl: IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION"); + WLog_ERR(TAG, " Function IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION: Unchecked"); break; default: - LLOGLN(urbdrc_debug, ("urbdrc_process_io_control: unknown IoControlCode 0x%X", IoControlCode)); + WLog_DBG(TAG, "urbdrc_process_io_control: unknown IoControlCode 0x%X", IoControlCode); zfree(OutputBuffer); return -1; break; @@ -321,7 +321,7 @@ static int urbdrc_process_internal_io_control(URBDRC_CHANNEL_CALLBACK* callback, data_read_UINT32(data + 0, IoControlCode); - LLOGLN(urbdrc_debug, ("urbdrc_process_internal_io_control:0x%x", IoControlCode)); + WLog_DBG(TAG, "urbdrc_process_internal_io_control:0x%x", IoControlCode); data_read_UINT32(data + 4, InputBufferSize); data_read_UINT32(data + 8, OutputBufferSize); @@ -370,7 +370,7 @@ static int urbdrc_process_query_device_text(URBDRC_CHANNEL_CALLBACK* callback, B BYTE DeviceDescription[bufferSize]; int out_offset; - LLOGLN(urbdrc_debug, ("urbdrc_process_query_device_text")); + WLog_DBG(TAG, "urbdrc_process_query_device_text"); data_read_UINT32(data + 0, TextType); data_read_UINT32(data + 4, LocaleId); @@ -448,7 +448,7 @@ static int urb_select_configuration(URBDRC_CHANNEL_CALLBACK* callback, BYTE* dat if (transferDir == 0) { - CLOG_ERR( "urb_select_configuration: not support transfer out\n"); + WLog_ERR(TAG, "urb_select_configuration: not support transfer out"); return -1; } @@ -540,7 +540,7 @@ static int urb_select_interface(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data, U if (transferDir == 0) { - CLOG_ERR( "urb_select_interface: not support transfer out\n"); + WLog_ERR(TAG, "urb_select_interface: not support transfer out"); return -1; } @@ -648,7 +648,7 @@ static int urb_control_transfer(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data, if (length != OutputBufferSize) { - LLOGLN(urbdrc_debug, ("urb_control_transfer ERROR: buf != length")); + WLog_ERR(TAG, "urb_control_transfer ERROR: buf != length"); return -1; } @@ -675,7 +675,7 @@ static int urb_control_transfer(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data, Timeout); if (ret < 0){ - LLOGLN(urbdrc_debug, ("control_transfer: error num %d!!\n", ret)); + WLog_DBG(TAG, "control_transfer: error num %d!!", ret); OutputBufferSize = 0; } @@ -866,12 +866,12 @@ static int urb_isoch_transfer(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data, break; } - LLOGLN(urbdrc_debug, ("urb_isoch_transfer: EndpointAddress: 0x%x, " + WLog_DBG(TAG, "urb_isoch_transfer: EndpointAddress: 0x%x, " "TransferFlags: 0x%x, " "StartFrame: 0x%x, " "NumberOfPackets: 0x%x, " "OutputBufferSize: 0x%x " "RequestId: 0x%x", EndpointAddress, TransferFlags, StartFrame, - NumberOfPackets, OutputBufferSize, RequestId)); + NumberOfPackets, OutputBufferSize, RequestId); #if ISOCH_FIFO ISOCH_CALLBACK_QUEUE * isoch_queue = NULL; @@ -1010,7 +1010,7 @@ static int urb_control_descriptor_request(URBDRC_CHANNEL_CALLBACK* callback, memcpy(buffer, data + offset, OutputBufferSize); break; default: - LLOGLN(urbdrc_debug, ("%s: get error transferDir", __func__)); + WLog_DBG(TAG, "get error transferDir"); OutputBufferSize = 0; usbd_status = USBD_STATUS_STALL_PID; break; @@ -1030,7 +1030,7 @@ static int urb_control_descriptor_request(URBDRC_CHANNEL_CALLBACK* callback, if (ret < 0) { - LLOGLN(urbdrc_debug, ("%s:get_descriptor: error num %d", __func__, ret)); + WLog_DBG(TAG, "get_descriptor: error num %d", ret); OutputBufferSize = 0; } @@ -1073,7 +1073,7 @@ static int urb_control_get_status_request(URBDRC_CHANNEL_CALLBACK * callback, BY int offset, ret; if (transferDir == 0){ - LLOGLN(urbdrc_debug, ("urb_control_get_status_request: not support transfer out\n")); + WLog_DBG(TAG, "urb_control_get_status_request: not support transfer out"); return -1; } @@ -1105,7 +1105,7 @@ static int urb_control_get_status_request(URBDRC_CHANNEL_CALLBACK * callback, BY 1000); if (ret < 0){ - LLOGLN(urbdrc_debug, ("%s:control_transfer: error num %d!!\n", __func__, ret)); + WLog_DBG(TAG, "control_transfer: error num %d!!", ret); OutputBufferSize = 0; usbd_status = USBD_STATUS_STALL_PID; } @@ -1198,11 +1198,11 @@ static int urb_control_vendor_or_class_request(URBDRC_CHANNEL_CALLBACK * callbac if (TransferFlags & USBD_TRANSFER_DIRECTION) bmRequestType |= 0x80; - LLOGLN(urbdrc_debug, ("urb_control_vendor_or_class_request: " + WLog_DBG(TAG, "urb_control_vendor_or_class_request: " "RequestId 0x%x TransferFlags: 0x%x ReqTypeReservedBits: 0x%x " "Request:0x%x Value: 0x%x Index: 0x%x OutputBufferSize: 0x%x bmRequestType: 0x%x!!", RequestId, TransferFlags, ReqTypeReservedBits, Request, Value, - Index, OutputBufferSize, bmRequestType)); + Index, OutputBufferSize, bmRequestType); ret = pdev->control_transfer( pdev, RequestId, 0, 0, bmRequestType, @@ -1215,7 +1215,7 @@ static int urb_control_vendor_or_class_request(URBDRC_CHANNEL_CALLBACK * callbac 2000); if (ret < 0){ - LLOGLN(urbdrc_debug, ("%s:control_transfer: error num %d!!", __func__, ret)); + WLog_DBG(TAG, "control_transfer: error num %d!!", ret); OutputBufferSize = 0; usbd_status = USBD_STATUS_STALL_PID; } @@ -1297,18 +1297,18 @@ static int urb_os_feature_descriptor_request(URBDRC_CHANNEL_CALLBACK * callback, switch (transferDir) { case USBD_TRANSFER_DIRECTION_OUT: - CLOG_ERR( "Function urb_os_feature_descriptor_request: OUT Unchecked\n"); + WLog_ERR(TAG, "Function urb_os_feature_descriptor_request: OUT Unchecked"); memcpy(buffer, data + offset, OutputBufferSize); break; case USBD_TRANSFER_DIRECTION_IN: break; } - LLOGLN(urbdrc_debug, ("Ms descriptor arg: Recipient:0x%x, " + WLog_DBG(TAG, "Ms descriptor arg: Recipient:0x%x, " "InterfaceNumber:0x%x, Ms_PageIndex:0x%x, " "Ms_featureDescIndex:0x%x, OutputBufferSize:0x%x", Recipient, InterfaceNumber, Ms_PageIndex, - Ms_featureDescIndex, OutputBufferSize)); + Ms_featureDescIndex, OutputBufferSize); /** get ms string */ ret = pdev->os_feature_descriptor_request( pdev, RequestId, Recipient, @@ -1321,7 +1321,7 @@ static int urb_os_feature_descriptor_request(URBDRC_CHANNEL_CALLBACK * callback, 1000); if (ret < 0) - LLOGLN(urbdrc_debug, ("os_feature_descriptor_request: error num %d", ret)); + WLog_DBG(TAG, "os_feature_descriptor_request: error num %d", ret); offset = 36; out_size = offset + OutputBufferSize; @@ -1367,7 +1367,7 @@ static int urb_pipe_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data, int out_offset, ret; if (transferDir == 0){ - LLOGLN(urbdrc_debug, ("urb_pipe_request: not support transfer out\n")); + WLog_DBG(TAG, "urb_pipe_request: not support transfer out"); return -1; } @@ -1386,7 +1386,7 @@ static int urb_pipe_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data, switch (action){ case PIPE_CANCEL: - LLOGLN(urbdrc_debug, ("urb_pipe_request: PIPE_CANCEL 0x%x ", EndpointAddress)); + WLog_DBG(TAG, "urb_pipe_request: PIPE_CANCEL 0x%x ", EndpointAddress); ret = pdev->control_pipe_request( pdev, RequestId, EndpointAddress, @@ -1394,13 +1394,13 @@ static int urb_pipe_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data, PIPE_CANCEL); if (ret < 0) { - LLOGLN(urbdrc_debug, ("PIPE SET HALT: error num %d", ret)); + WLog_DBG(TAG, "PIPE SET HALT: error num %d", ret); } break; case PIPE_RESET: - LLOGLN(urbdrc_debug, ("urb_pipe_request: PIPE_RESET ep 0x%x ", EndpointAddress)); + WLog_DBG(TAG, "urb_pipe_request: PIPE_RESET ep 0x%x ", EndpointAddress); ret = pdev->control_pipe_request( pdev, RequestId, EndpointAddress, @@ -1408,11 +1408,11 @@ static int urb_pipe_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data, PIPE_RESET); if (ret < 0) - LLOGLN(urbdrc_debug, ("PIPE RESET: error num %d!!\n", ret)); + WLog_DBG(TAG, "PIPE RESET: error num %d!!", ret); break; default: - LLOGLN(urbdrc_debug, ("urb_pipe_request action: %d is not support!\n", action)); + WLog_DBG(TAG, "urb_pipe_request action: %d is not support!", action); break; } @@ -1459,7 +1459,7 @@ static int urb_get_current_frame_number(URBDRC_CHANNEL_CALLBACK* callback, BYTE* out_data; if (transferDir == 0){ - LLOGLN(urbdrc_debug, ("urb_get_current_frame_number: not support transfer out\n")); + WLog_DBG(TAG, "urb_get_current_frame_number: not support transfer out"); //exit(1); return -1; } @@ -1519,8 +1519,8 @@ static int urb_control_get_configuration_request(URBDRC_CHANNEL_CALLBACK* callba if (transferDir == 0) { - LLOGLN(urbdrc_debug, ("urb_control_get_configuration_request:" - " not support transfer out\n")); + WLog_DBG(TAG, "urb_control_get_configuration_request:" + " not support transfer out"); return -1; } @@ -1551,7 +1551,7 @@ static int urb_control_get_configuration_request(URBDRC_CHANNEL_CALLBACK* callba 1000); if (ret < 0){ - LLOGLN(urbdrc_debug, ("%s:control_transfer: error num %d\n", __func__, ret)); + WLog_DBG(TAG, "control_transfer: error num %d", ret); OutputBufferSize = 0; } @@ -1600,7 +1600,7 @@ static int urb_control_get_interface_request(URBDRC_CHANNEL_CALLBACK* callback, int ret, offset; if (transferDir == 0){ - LLOGLN(urbdrc_debug, ("urb_control_get_interface_request: not support transfer out\n")); + WLog_DBG(TAG, "urb_control_get_interface_request: not support transfer out"); return -1; } @@ -1629,7 +1629,7 @@ static int urb_control_get_interface_request(URBDRC_CHANNEL_CALLBACK* callback, 1000); if (ret < 0){ - LLOGLN(urbdrc_debug, ("%s:control_transfer: error num %d\n", __func__, ret)); + WLog_DBG(TAG, "control_transfer: error num %d", ret); OutputBufferSize = 0; } @@ -1700,7 +1700,7 @@ static int urb_control_feature_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE switch (transferDir) { case USBD_TRANSFER_DIRECTION_OUT: - CLOG_ERR( "Function urb_control_feature_request: OUT Unchecked\n"); + WLog_ERR(TAG, "Function urb_control_feature_request: OUT Unchecked"); memcpy(buffer, data + offset, OutputBufferSize); bmRequestType |= 0x00; break; @@ -1718,7 +1718,7 @@ static int urb_control_feature_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE bmRequest = 0x01; /* REQUEST_CLEAR_FEATURE */ break; default: - CLOG_ERR( "urb_control_feature_request: Error Command %x\n", command); + WLog_ERR(TAG, "urb_control_feature_request: Error Command %x", command); zfree(out_data); return -1; } @@ -1733,7 +1733,7 @@ static int urb_control_feature_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE 1000); if (ret < 0){ - LLOGLN(urbdrc_debug, ("feature control transfer: error num %d", ret)); + WLog_DBG(TAG, "feature control transfer: error num %d", ret); OutputBufferSize = 0; } @@ -1790,7 +1790,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B switch (URB_Function) { case URB_FUNCTION_SELECT_CONFIGURATION: /** 0x0000 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SELECT_CONFIGURATION")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SELECT_CONFIGURATION"); error = urb_select_configuration( callback, data + 8, data_sizem - 8, @@ -1800,7 +1800,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_SELECT_INTERFACE: /** 0x0001 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SELECT_INTERFACE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SELECT_INTERFACE"); error = urb_select_interface( callback, data + 8, data_sizem - 8, @@ -1810,7 +1810,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_ABORT_PIPE: /** 0x0002 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_ABORT_PIPE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_ABORT_PIPE"); error = urb_pipe_request( callback, data + 8, data_sizem - 8, MessageId, @@ -1820,31 +1820,31 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B PIPE_CANCEL); break; case URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL: /** 0x0003 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL"); error = -1; /** This URB function is obsolete in Windows 2000 * and later operating systems * and is not supported by Microsoft. */ break; case URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL: /** 0x0004 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL"); error = -1; /** This URB function is obsolete in Windows 2000 * and later operating systems * and is not supported by Microsoft. */ break; case URB_FUNCTION_GET_FRAME_LENGTH: /** 0x0005 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_FRAME_LENGTH")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_FRAME_LENGTH"); error = -1; /** This URB function is obsolete in Windows 2000 * and later operating systems * and is not supported by Microsoft. */ break; case URB_FUNCTION_SET_FRAME_LENGTH: /** 0x0006 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SET_FRAME_LENGTH")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SET_FRAME_LENGTH"); error = -1; /** This URB function is obsolete in Windows 2000 * and later operating systems * and is not supported by Microsoft. */ break; case URB_FUNCTION_GET_CURRENT_FRAME_NUMBER: /** 0x0007 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_CURRENT_FRAME_NUMBER")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_CURRENT_FRAME_NUMBER"); error = urb_get_current_frame_number( callback, data + 8, data_sizem - 8, @@ -1854,7 +1854,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_CONTROL_TRANSFER: /** 0x0008 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CONTROL_TRANSFER")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CONTROL_TRANSFER"); error = urb_control_transfer( callback, data + 8, data_sizem - 8, @@ -1865,7 +1865,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B URB_CONTROL_TRANSFER_NONEXTERNAL); break; case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER: /** 0x0009 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER"); error = urb_bulk_or_interrupt_transfer( callback, data + 8, data_sizem - 8, @@ -1875,7 +1875,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_ISOCH_TRANSFER: /** 0x000A */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_ISOCH_TRANSFER")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_ISOCH_TRANSFER"); error = urb_isoch_transfer( callback, data + 8, data_sizem - 8, MessageId, @@ -1884,7 +1884,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE: /** 0x000B */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE"); error = urb_control_descriptor_request( callback, data + 8, data_sizem - 8, @@ -1895,7 +1895,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE: /** 0x000C */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE"); error = urb_control_descriptor_request( callback, data + 8, data_sizem - 8, @@ -1906,7 +1906,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_SET_FEATURE_TO_DEVICE: /** 0x000D */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SET_FEATURE_TO_DEVICE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SET_FEATURE_TO_DEVICE"); error = urb_control_feature_request(callback, data + 8, data_sizem - 8, @@ -1918,7 +1918,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_SET_FEATURE_TO_INTERFACE: /** 0x000E */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SET_FEATURE_TO_INTERFACE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SET_FEATURE_TO_INTERFACE"); error = urb_control_feature_request( callback, data + 8, data_sizem - 8, @@ -1930,7 +1930,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_SET_FEATURE_TO_ENDPOINT: /** 0x000F */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SET_FEATURE_TO_ENDPOINT")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SET_FEATURE_TO_ENDPOINT"); error = urb_control_feature_request( callback, data + 8, data_sizem - 8, @@ -1942,7 +1942,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE: /** 0x0010 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE"); error = urb_control_feature_request( callback, data + 8, data_sizem - 8, @@ -1954,7 +1954,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE: /** 0x0011 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE"); error = urb_control_feature_request( callback, data + 8, data_sizem - 8, @@ -1966,7 +1966,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT: /** 0x0012 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT"); error = urb_control_feature_request( callback, data + 8, data_sizem - 8, @@ -1978,7 +1978,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_GET_STATUS_FROM_DEVICE: /** 0x0013 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_STATUS_FROM_DEVICE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_STATUS_FROM_DEVICE"); error = urb_control_get_status_request( callback, data + 8, data_sizem - 8, @@ -1989,7 +1989,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_GET_STATUS_FROM_INTERFACE: /** 0x0014 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_STATUS_FROM_INTERFACE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_STATUS_FROM_INTERFACE"); error = urb_control_get_status_request( callback, data + 8, data_sizem - 8, @@ -2000,7 +2000,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_GET_STATUS_FROM_ENDPOINT: /** 0x0015 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_STATUS_FROM_ENDPOINT")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_STATUS_FROM_ENDPOINT"); error = urb_control_get_status_request( callback, data + 8, data_sizem - 8, @@ -2011,11 +2011,11 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_RESERVED_0X0016: /** 0x0016 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_RESERVED_0X0016")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_RESERVED_0X0016"); error = -1; break; case URB_FUNCTION_VENDOR_DEVICE: /** 0x0017 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_VENDOR_DEVICE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_VENDOR_DEVICE"); error = urb_control_vendor_or_class_request( callback, data + 8, data_sizem - 8, @@ -2027,7 +2027,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_VENDOR_INTERFACE: /** 0x0018 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_VENDOR_INTERFACE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_VENDOR_INTERFACE"); error = urb_control_vendor_or_class_request( callback, data + 8, data_sizem - 8, @@ -2039,7 +2039,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_VENDOR_ENDPOINT: /** 0x0019 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_VENDOR_ENDPOINT")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_VENDOR_ENDPOINT"); error = urb_control_vendor_or_class_request( callback, data + 8, data_sizem - 8, @@ -2051,7 +2051,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_CLASS_DEVICE: /** 0x001A */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CLASS_DEVICE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CLASS_DEVICE"); error = urb_control_vendor_or_class_request( callback, data + 8, data_sizem - 8, @@ -2063,7 +2063,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_CLASS_INTERFACE: /** 0x001B */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CLASS_INTERFACE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CLASS_INTERFACE"); error = urb_control_vendor_or_class_request( callback, data + 8, data_sizem - 8, @@ -2075,7 +2075,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_CLASS_ENDPOINT: /** 0x001C */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CLASS_ENDPOINT")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CLASS_ENDPOINT"); error = urb_control_vendor_or_class_request( callback, data + 8, data_sizem - 8, @@ -2087,11 +2087,11 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_RESERVE_0X001D: /** 0x001D */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_RESERVE_0X001D")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_RESERVE_0X001D"); error = -1; break; case URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL: /** 0x001E */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL"); error = urb_pipe_request( callback, data + 8, data_sizem - 8, MessageId, @@ -2101,7 +2101,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B PIPE_RESET); break; case URB_FUNCTION_CLASS_OTHER: /** 0x001F */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CLASS_OTHER")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CLASS_OTHER"); error = urb_control_vendor_or_class_request( callback, data + 8, data_sizem - 8, @@ -2113,7 +2113,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_VENDOR_OTHER: /** 0x0020 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_VENDOR_OTHER")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_VENDOR_OTHER"); error = urb_control_vendor_or_class_request( callback, data + 8, data_sizem - 8, @@ -2125,7 +2125,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_GET_STATUS_FROM_OTHER: /** 0x0021 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_STATUS_FROM_OTHER")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_STATUS_FROM_OTHER"); error = urb_control_get_status_request( callback, data + 8, data_sizem - 8, @@ -2136,7 +2136,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_CLEAR_FEATURE_TO_OTHER: /** 0x0022 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CLEAR_FEATURE_TO_OTHER")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CLEAR_FEATURE_TO_OTHER"); error = urb_control_feature_request( callback, data + 8, data_sizem - 8, @@ -2148,7 +2148,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_SET_FEATURE_TO_OTHER: /** 0x0023 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SET_FEATURE_TO_OTHER")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SET_FEATURE_TO_OTHER"); error = urb_control_feature_request( callback, data + 8, data_sizem - 8, @@ -2160,7 +2160,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT: /** 0x0024 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT"); error = urb_control_descriptor_request( callback, data + 8, data_sizem - 8, @@ -2171,7 +2171,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT: /** 0x0025 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT"); error = urb_control_descriptor_request( callback, data + 8, data_sizem - 8, @@ -2182,7 +2182,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_GET_CONFIGURATION: /** 0x0026 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_CONFIGURATION")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_CONFIGURATION"); error = urb_control_get_configuration_request( callback, data + 8, data_sizem - 8, @@ -2192,7 +2192,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_GET_INTERFACE: /** 0x0027 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_INTERFACE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_INTERFACE"); error = urb_control_get_interface_request( callback, data + 8, data_sizem - 8, @@ -2202,7 +2202,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE: /** 0x0028 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE"); error = urb_control_descriptor_request( callback, data + 8, data_sizem - 8, @@ -2213,7 +2213,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE: /** 0x0029 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE"); error = urb_control_descriptor_request( callback, data + 8, data_sizem - 8, @@ -2224,7 +2224,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR: /** 0x002A */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR"); error = urb_os_feature_descriptor_request( callback, data + 8, data_sizem - 8, @@ -2234,28 +2234,28 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B transferDir); break; case URB_FUNCTION_RESERVE_0X002B: /** 0x002B */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_RESERVE_0X002B")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_RESERVE_0X002B"); error = -1; break; case URB_FUNCTION_RESERVE_0X002C: /** 0x002C */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_RESERVE_0X002C")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_RESERVE_0X002C"); error = -1; break; case URB_FUNCTION_RESERVE_0X002D: /** 0x002D */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_RESERVE_0X002D")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_RESERVE_0X002D"); error = -1; break; case URB_FUNCTION_RESERVE_0X002E: /** 0x002E */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_RESERVE_0X002E")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_RESERVE_0X002E"); error = -1; break; case URB_FUNCTION_RESERVE_0X002F: /** 0x002F */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_RESERVE_0X002F")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_RESERVE_0X002F"); error = -1; break; /** USB 2.0 calls start at 0x0030 */ case URB_FUNCTION_SYNC_RESET_PIPE: /** 0x0030 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SYNC_RESET_PIPE")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SYNC_RESET_PIPE"); error = urb_pipe_request( callback, data + 8, data_sizem - 8, @@ -2267,7 +2267,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B error = -9; /** function not support */ break; case URB_FUNCTION_SYNC_CLEAR_STALL: /** 0x0031 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SYNC_CLEAR_STALL")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SYNC_CLEAR_STALL"); error = urb_pipe_request( callback, data + 8, data_sizem - 8, @@ -2279,7 +2279,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B error = -9; break; case URB_FUNCTION_CONTROL_TRANSFER_EX: /** 0x0032 */ - LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CONTROL_TRANSFER_EX")); + WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CONTROL_TRANSFER_EX"); error = urb_control_transfer( callback, data + 8, data_sizem - 8, @@ -2290,7 +2290,7 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B URB_CONTROL_TRANSFER_EXTERNAL); break; default: - LLOGLN(urbdrc_debug, ("URB_Func: %x is not found!", URB_Function)); + WLog_DBG(TAG, "URB_Func: %x is not found!", URB_Function); break; } @@ -2331,8 +2331,8 @@ void* urbdrc_process_udev_data_transfer(void* arg) switch (FunctionId) { case CANCEL_REQUEST: - LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" - " >>CANCEL_REQUEST<<0x%X", FunctionId)); + WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:" + " >>CANCEL_REQUEST<<0x%X", FunctionId); error = urbdrc_process_cancel_request( pBuffer + 8, cbSize - 8, @@ -2340,8 +2340,8 @@ void* urbdrc_process_udev_data_transfer(void* arg) UsbDevice); break; case REGISTER_REQUEST_CALLBACK: - LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" - " >>REGISTER_REQUEST_CALLBACK<<0x%X", FunctionId)); + WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:" + " >>REGISTER_REQUEST_CALLBACK<<0x%X", FunctionId); error = urbdrc_process_register_request_callback( callback, pBuffer + 8, @@ -2350,8 +2350,8 @@ void* urbdrc_process_udev_data_transfer(void* arg) UsbDevice); break; case IO_CONTROL: - LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" - " >>IO_CONTROL<<0x%X", FunctionId)); + WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:" + " >>IO_CONTROL<<0x%X", FunctionId); error = urbdrc_process_io_control( callback, pBuffer + 8, @@ -2360,8 +2360,8 @@ void* urbdrc_process_udev_data_transfer(void* arg) udevman, UsbDevice); break; case INTERNAL_IO_CONTROL: - LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" - " >>INTERNAL_IO_CONTROL<<0x%X", FunctionId)); + WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:" + " >>INTERNAL_IO_CONTROL<<0x%X", FunctionId); error = urbdrc_process_internal_io_control( callback, pBuffer + 8, @@ -2370,8 +2370,8 @@ void* urbdrc_process_udev_data_transfer(void* arg) udevman, UsbDevice); break; case QUERY_DEVICE_TEXT: - LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" - " >>QUERY_DEVICE_TEXT<<0x%X", FunctionId)); + WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:" + " >>QUERY_DEVICE_TEXT<<0x%X", FunctionId); error = urbdrc_process_query_device_text( callback, pBuffer + 8, @@ -2381,8 +2381,8 @@ void* urbdrc_process_udev_data_transfer(void* arg) UsbDevice); break; case TRANSFER_IN_REQUEST: - LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" - " >>TRANSFER_IN_REQUEST<<0x%X", FunctionId)); + WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:" + " >>TRANSFER_IN_REQUEST<<0x%X", FunctionId); error = urbdrc_process_transfer_request( callback, pBuffer + 8, @@ -2393,8 +2393,8 @@ void* urbdrc_process_udev_data_transfer(void* arg) USBD_TRANSFER_DIRECTION_IN); break; case TRANSFER_OUT_REQUEST: - LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" - " >>TRANSFER_OUT_REQUEST<<0x%X", FunctionId)); + WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:" + " >>TRANSFER_OUT_REQUEST<<0x%X", FunctionId); error = urbdrc_process_transfer_request( callback, pBuffer + 8, @@ -2405,8 +2405,8 @@ void* urbdrc_process_udev_data_transfer(void* arg) USBD_TRANSFER_DIRECTION_OUT); break; case RETRACT_DEVICE: - LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" - " >>RETRACT_DEVICE<<0x%X", FunctionId)); + WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:" + " >>RETRACT_DEVICE<<0x%X", FunctionId); error = urbdrc_process_retract_device_request( pBuffer + 8, cbSize - 8, @@ -2414,8 +2414,8 @@ void* urbdrc_process_udev_data_transfer(void* arg) UsbDevice); break; default: - LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" - " unknown FunctionId 0x%X", FunctionId)); + WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:" + " unknown FunctionId 0x%X", FunctionId); error = -1; break; } diff --git a/channels/urbdrc/client/libusb/libusb_udevice.c b/channels/urbdrc/client/libusb/libusb_udevice.c index bb1ead0ca..d7cf55ff1 100644 --- a/channels/urbdrc/client/libusb/libusb_udevice.c +++ b/channels/urbdrc/client/libusb/libusb_udevice.c @@ -118,7 +118,7 @@ retry: if (completed == NULL || !*completed) { /* we obtained the event lock: do our own event handling */ - LLOGLN(10, ("doing our own event handling")); + WLog_DBG(TAG,"doing our own event handling"); r = libusb_handle_events_locked(ctx, &tv); } @@ -139,11 +139,11 @@ retry: /* we hit a race: whoever was event handling earlier finished in the * time it took us to reach this point. try the cycle again. */ libusb_unlock_event_waiters(ctx); - LLOGLN(10, ("event handler was active but went away, retrying")); + WLog_DBG(TAG,"event handler was active but went away, retrying"); goto retry; } - LLOGLN(10, ("another thread is doing event handling")); + WLog_DBG(TAG,"another thread is doing event handling"); r = libusb_wait_for_event(ctx, &poll_timeout); already_done: @@ -201,7 +201,7 @@ static void func_iso_callback(struct libusb_transfer *transfer) } else { - //CLOG_ERR( "actual length %d \n", act_len); + //WLog_ERR(TAG, "actual length %d ", act_len); //exit(EXIT_FAILURE); } } @@ -273,7 +273,7 @@ static int func_set_usbd_status(UDEVICE* pdev, UINT32* status, int err_result) case LIBUSB_ERROR_IO: *status = USBD_STATUS_STALL_PID; - LLOGLN(10, ("urb_status: LIBUSB_ERROR_IO!!\n")); + WLog_ERR(TAG,"LIBUSB_ERROR_IO!!"); break; case LIBUSB_ERROR_INVALID_PARAM: @@ -291,7 +291,7 @@ static int func_set_usbd_status(UDEVICE* pdev, UINT32* status, int err_result) if (!(pdev->status & URBDRC_DEVICE_NOT_FOUND)) { pdev->status |= URBDRC_DEVICE_NOT_FOUND; - LLOGLN(libusb_debug, ("urb_status: LIBUSB_ERROR_NO_DEVICE!!\n")); + WLog_WARN(TAG,"LIBUSB_ERROR_NO_DEVICE!!"); } } break; @@ -362,7 +362,7 @@ static int func_config_release_all_interface(LIBUSB_DEVICE_HANDLE* libusb_handle if (ret < 0) { - CLOG_ERR( "config_release_all_interface: error num %d\n", ret); + WLog_ERR(TAG, "config_release_all_interface: error num %d", ret); return -1; } } @@ -380,7 +380,7 @@ static int func_claim_all_interface(LIBUSB_DEVICE_HANDLE* libusb_handle, int Num if (ret < 0) { - CLOG_ERR( "claim_all_interface: error num %d\n", ret); + WLog_ERR(TAG, "claim_all_interface: error num %d", ret); return -1; } } @@ -394,28 +394,28 @@ static void* print_transfer_status(enum libusb_transfer_status status) switch (status) { case LIBUSB_TRANSFER_COMPLETED: - //CLOG_ERR( "Transfer Status: LIBUSB_TRANSFER_COMPLETED\n"); + //WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_COMPLETED"); break; case LIBUSB_TRANSFER_ERROR: - CLOG_ERR( "Transfer Status: LIBUSB_TRANSFER_ERROR\n"); + WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_ERROR"); break; case LIBUSB_TRANSFER_TIMED_OUT: - CLOG_ERR( "Transfer Status: LIBUSB_TRANSFER_TIMED_OUT\n"); + WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_TIMED_OUT"); break; case LIBUSB_TRANSFER_CANCELLED: - CLOG_ERR( "Transfer Status: LIBUSB_TRANSFER_CANCELLED\n"); + WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_CANCELLED"); break; case LIBUSB_TRANSFER_STALL: - CLOG_ERR( "Transfer Status: LIBUSB_TRANSFER_STALL\n"); + WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_STALL"); break; case LIBUSB_TRANSFER_NO_DEVICE: - CLOG_ERR( "Transfer Status: LIBUSB_TRANSFER_NO_DEVICE\n"); + WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_NO_DEVICE"); break; case LIBUSB_TRANSFER_OVERFLOW: - CLOG_ERR( "Transfer Status: LIBUSB_TRANSFER_OVERFLOW\n"); + WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_OVERFLOW"); break; default: - CLOG_ERR( "Transfer Status: Get unknow error num %d (0x%x)\n", + WLog_ERR(TAG, "Transfer Status: Get unknow error num %d (0x%x)", status, status); } return 0; @@ -426,28 +426,28 @@ static void print_status(enum libusb_transfer_status status) switch (status) { case LIBUSB_TRANSFER_COMPLETED: - CLOG_ERR( "Transfer status: LIBUSB_TRANSFER_COMPLETED\n"); + WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_COMPLETED"); break; case LIBUSB_TRANSFER_ERROR: - CLOG_ERR( "Transfer status: LIBUSB_TRANSFER_ERROR\n"); + WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_ERROR"); break; case LIBUSB_TRANSFER_TIMED_OUT: - CLOG_ERR( "Transfer status: LIBUSB_TRANSFER_TIMED_OUT\n"); + WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_TIMED_OUT"); break; case LIBUSB_TRANSFER_CANCELLED: - CLOG_ERR( "Transfer status: LIBUSB_TRANSFER_CANCELLED\n"); + WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_CANCELLED"); break; case LIBUSB_TRANSFER_STALL: - CLOG_ERR( "Transfer status: LIBUSB_TRANSFER_STALL\n"); + WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_STALL"); break; case LIBUSB_TRANSFER_NO_DEVICE: - CLOG_ERR( "Transfer status: LIBUSB_TRANSFER_NO_DEVICE\n"); + WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_NO_DEVICE"); break; case LIBUSB_TRANSFER_OVERFLOW: - CLOG_ERR( "Transfer status: LIBUSB_TRANSFER_OVERFLOW\n"); + WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_OVERFLOW"); break; default: - CLOG_ERR( "Transfer status: unknow status %d(0x%x)\n", status, status); + WLog_ERR(TAG, "Transfer status: unknow status %d(0x%x)", status, status); break; } } @@ -484,7 +484,7 @@ static LIBUSB_DEVICE_DESCRIPTOR* udev_new_descript(LIBUSB_DEVICE* libusb_dev) if (ret < 0) { - CLOG_ERR( "libusb_get_device_descriptor: ERROR!!\n"); + WLog_ERR(TAG, "libusb_get_device_descriptor: ERROR!!"); free(descriptor); return NULL; } @@ -510,7 +510,7 @@ static int udev_get_hub_handle(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_numb if (!udev) { - LLOGLN(0, ("%s: Can't create udev", __func__)); + WLog_ERR(TAG, "Can't create udev"); return -1; } @@ -563,7 +563,7 @@ static int udev_get_hub_handle(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_numb } pdev->port_number = atoi(p2); - LLOGLN(libusb_debug, (" Port: %d", pdev->port_number)); + WLog_DBG(TAG, " Port: %d", pdev->port_number); /* get device path */ p1 = (char*) sysfs_path; @@ -577,7 +577,7 @@ static int udev_get_hub_handle(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_numb memset(pdev->path, 0, 17); strcpy(pdev->path, p2); - LLOGLN(libusb_debug, (" DevPath: %s", pdev->path)); + WLog_DBG(TAG," DevPath: %s", pdev->path); /* query parent hub info */ dev = udev_device_get_parent(dev); @@ -587,7 +587,7 @@ static int udev_get_hub_handle(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_numb hub_found = 1; hub_bus = atoi(udev_device_get_property_value(dev,"BUSNUM")); hub_dev = atoi(udev_device_get_property_value(dev,"DEVNUM")); - LLOGLN(libusb_debug, (" Hub BUS/DEV: %d %d", hub_bus, hub_dev)); + WLog_DBG(TAG, " Hub BUS/DEV: %d %d", hub_bus, hub_dev); } udev_device_unref(dev); @@ -601,7 +601,7 @@ static int udev_get_hub_handle(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_numb if (!hub_found) { - LLOGLN(0, ("%s: hub was not found!", __func__)); + WLog_WARN(TAG,"hub was not found!"); return -1; } @@ -610,7 +610,7 @@ static int udev_get_hub_handle(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_numb if (libusb_dev == NULL) { - LLOGLN(0, ("%s: get hub libusb_dev fail!", __func__)); + WLog_DBG(TAG,"get hub libusb_dev fail!"); return -1; } @@ -618,11 +618,11 @@ static int udev_get_hub_handle(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_numb if (error < 0) { - LLOGLN(0, ("%s: libusb_open error!", __func__)); + WLog_DBG(TAG,"libusb_open error!"); return -1; } - LLOGLN(libusb_debug, ("%s: libusb_open success!", __func__)); + WLog_DBG(TAG,"libusb_open success!"); /* Success! */ return 0; @@ -654,8 +654,8 @@ static int libusb_udev_select_interface(IUDEVICE* idev, BYTE InterfaceNumber, BY if (error < 0) { - CLOG_ERR( "%s: Set interface altsetting get error num %d\n", - __func__, error); + WLog_ERR(TAG, "Set interface altsetting get error num %d", + error); } } @@ -681,8 +681,8 @@ static MSUSB_CONFIG_DESCRIPTOR* libusb_udev_complete_msconfig_setup(IUDEVICE* id LibusbConfig = pdev->LibusbConfig; if (LibusbConfig->bNumInterfaces != MsConfig->NumInterfaces) { - CLOG_ERR( "Select Configuration: Libusb NumberInterfaces(%d) is different " - "with MsConfig NumberInterfaces(%d)\n", + WLog_ERR(TAG, "Select Configuration: Libusb NumberInterfaces(%d) is different " + "with MsConfig NumberInterfaces(%d)", LibusbConfig->bNumInterfaces, MsConfig->NumInterfaces); } @@ -827,7 +827,7 @@ static int libusb_udev_select_configuration(IUDEVICE* idev, UINT32 bConfiguratio ret = libusb_set_configuration(libusb_handle, bConfigurationValue); if (ret < 0){ - CLOG_ERR( "libusb_set_configuration: ERROR number %d!!\n", ret); + WLog_ERR(TAG, "libusb_set_configuration: ERROR number %d!!", ret); func_claim_all_interface(libusb_handle, (*LibusbConfig)->bNumInterfaces); return -1; } @@ -835,7 +835,7 @@ static int libusb_udev_select_configuration(IUDEVICE* idev, UINT32 bConfiguratio { ret = libusb_get_active_config_descriptor (libusb_dev, LibusbConfig); if (ret < 0){ - CLOG_ERR( "libusb_get_config_descriptor_by_value: ERROR number %d!!\n", ret); + WLog_ERR(TAG, "libusb_get_config_descriptor_by_value: ERROR number %d!!", ret); func_claim_all_interface(libusb_handle, (*LibusbConfig)->bNumInterfaces); return -1; } @@ -885,7 +885,7 @@ static int libusb_udev_control_pipe_request(IUDEVICE* idev, UINT32 RequestId, *UsbdStatus = 0; /* if(pdev->request_queue->unregister_request(pdev->request_queue, RequestId)) - CLOG_ERR( "request_queue_unregister_request: not fount request 0x%x\n", RequestId); + WLog_ERR(TAG, "request_queue_unregister_request: not fount request 0x%x", RequestId); */ return error; } @@ -918,8 +918,8 @@ static int libusb_udev_control_query_device_text(IUDEVICE* idev, UINT32 TextType ret -= 2; if (ret <= 0 || ret < 4){ - LLOGLN(libusb_debug, ("libusb_get_string_descriptor: " - "ERROR num %d, iProduct: %d!", ret, devDescriptor->iProduct)); + WLog_DBG(TAG,"libusb_get_string_descriptor: " + "ERROR num %d, iProduct: %d!", ret, devDescriptor->iProduct); memcpy(Buffer, strDesc, strlen(strDesc)); Buffer[strlen(strDesc)] = '\0'; *BufferSize = (strlen((char *)Buffer)) * 2; @@ -947,7 +947,7 @@ static int libusb_udev_control_query_device_text(IUDEVICE* idev, UINT32 TextType *BufferSize = (i*2); break; default: - LLOGLN(0, ("Query Text: unknown TextType %d", TextType)); + WLog_DBG(TAG,"Query Text: unknown TextType %d", TextType); break; } @@ -980,12 +980,12 @@ static int libusb_udev_os_feature_descriptor_request(IUDEVICE* idev, UINT32 Requ ms_string_desc, 0x12, Timeout); - //CLOG_ERR( "Get ms string: result number %d", error); + //WLog_ERR(TAG, "Get ms string: result number %d", error); if (error > 0) { BYTE bMS_Vendorcode; data_read_BYTE(ms_string_desc + 16, bMS_Vendorcode); - //CLOG_ERR( "bMS_Vendorcode:0x%x", bMS_Vendorcode); + //WLog_ERR(TAG, "bMS_Vendorcode:0x%x", bMS_Vendorcode); /** get os descriptor */ error = libusb_control_transfer(pdev->libusb_handle, LIBUSB_ENDPOINT_IN |LIBUSB_REQUEST_TYPE_VENDOR | Recipient, @@ -1004,7 +1004,7 @@ static int libusb_udev_os_feature_descriptor_request(IUDEVICE* idev, UINT32 Requ *UsbdStatus = USBD_STATUS_SUCCESS; /* if(pdev->request_queue->unregister_request(pdev->request_queue, RequestId)) - CLOG_ERR( "request_queue_unregister_request: not fount request 0x%x\n", RequestId); + WLog_ERR(TAG, "request_queue_unregister_request: not fount request 0x%x", RequestId); */ return error; } @@ -1059,10 +1059,10 @@ static void libusb_udev_detach_kernel_driver(IUDEVICE* idev) for (i = 0; i < pdev->LibusbConfig->bNumInterfaces; i++) { err = libusb_kernel_driver_active(pdev->libusb_handle , i); - LLOGLN(libusb_debug, ("libusb_kernel_driver_active = %d\n", err)); + WLog_DBG(TAG,"libusb_kernel_driver_active = %d", err); if (err){ err = libusb_detach_kernel_driver(pdev->libusb_handle , i); - LLOGLN(libusb_debug, ("libusb_detach_kernel_driver = %d\n", err)); + WLog_DBG(TAG,"libusb_detach_kernel_driver = %d", err); } } @@ -1079,12 +1079,12 @@ static void libusb_udev_attach_kernel_driver(IUDEVICE* idev) { err = libusb_release_interface (pdev->libusb_handle, i); if (err < 0){ - LLOGLN(libusb_debug, ("libusb_release_interface: error num %d = %d", i, err)); + WLog_DBG(TAG,"libusb_release_interface: error num %d = %d", i, err); } if (err != LIBUSB_ERROR_NO_DEVICE) { err = libusb_attach_kernel_driver (pdev->libusb_handle , i); - LLOGLN(libusb_debug, ("libusb_attach_kernel_driver if%d = %d", i, err)); + WLog_DBG(TAG,"libusb_attach_kernel_driver if%d = %d", i, err); } } } @@ -1222,13 +1222,13 @@ static int libusb_udev_query_device_port_status(IUDEVICE* idev, UINT32* UsbdStat if (ret < 0) { - LLOGLN(libusb_debug, ("libusb_control_transfer: error num %d", ret)); + WLog_DBG(TAG,"libusb_control_transfer: error num %d", ret); *BufferSize = 0; } else { - LLOGLN(libusb_debug, ("PORT STATUS:0x%02x%02x%02x%02x", - Buffer[3], Buffer[2], Buffer[1], Buffer[0])); + WLog_DBG(TAG,"PORT STATUS:0x%02x%02x%02x%02x", + Buffer[3], Buffer[2], Buffer[1], Buffer[0]); success = 1; } } @@ -1263,7 +1263,7 @@ static int libusb_udev_isoch_transfer(IUDEVICE* idev, UINT32 RequestId, UINT32 E if (iso_transfer == NULL) { - CLOG_ERR( "Error: libusb_alloc_transfer.\n"); + WLog_ERR(TAG, "Error: libusb_alloc_transfer."); status = -1; } @@ -1288,7 +1288,7 @@ static int libusb_udev_isoch_transfer(IUDEVICE* idev, UINT32 RequestId, UINT32 E if (submit < 0) { - LLOGLN(libusb_debug, ("Error: Failed to submit transfer (ret = %d).", submit)); + WLog_DBG(TAG,"Error: Failed to submit transfer (ret = %d).", submit); status = -1; func_set_usbd_status(pdev, UrbdStatus, ret); } @@ -1309,7 +1309,7 @@ static int libusb_udev_isoch_transfer(IUDEVICE* idev, UINT32 RequestId, UINT32 E } ret = handle_events_completed(NULL, &iso_user_data.completed); if (ret < 0) { - LLOGLN(libusb_debug, ("Error: libusb_handle_events (ret = %d).", ret)); + WLog_DBG(TAG,"Error: libusb_handle_events (ret = %d).", ret); status = -1; break; } @@ -1368,14 +1368,14 @@ static int libusb_udev_bulk_or_interrupt_transfer(IUDEVICE* idev, UINT32 Request if (!ep_desc) { - CLOG_ERR( "func_get_ep_desc: endpoint 0x%x is not found!!\n", EndpointAddress); + WLog_ERR(TAG, "func_get_ep_desc: endpoint 0x%x is not found!!", EndpointAddress); return -1; } transfer_type = (ep_desc->bmAttributes) & 0x3; - LLOGLN(libusb_debug, ("urb_bulk_or_interrupt_transfer: ep:0x%x " + WLog_DBG(TAG,"urb_bulk_or_interrupt_transfer: ep:0x%x " "transfer_type %d flag:%d OutputBufferSize:0x%x", - EndpointAddress, transfer_type, TransferFlags, *BufferSize)); + EndpointAddress, transfer_type, TransferFlags, *BufferSize); switch (transfer_type) { @@ -1391,9 +1391,9 @@ static int libusb_udev_bulk_or_interrupt_transfer(IUDEVICE* idev, UINT32 Request * request to wMaxPacketSize */ if (*BufferSize != (ep_desc->wMaxPacketSize)) { - LLOGLN(libusb_debug, ("Interrupt Transfer(%s): " + WLog_DBG(TAG,"Interrupt Transfer(%s): " "BufferSize is different than maxPacketsize(0x%x)", - ((transferDir)?"IN":"OUT"), ep_desc->wMaxPacketSize)); + ((transferDir)?"IN":"OUT"), ep_desc->wMaxPacketSize); if((*BufferSize) > (ep_desc->wMaxPacketSize) && transferDir == USBD_TRANSFER_DIRECTION_IN) (*BufferSize) = ep_desc->wMaxPacketSize; @@ -1402,8 +1402,8 @@ static int libusb_udev_bulk_or_interrupt_transfer(IUDEVICE* idev, UINT32 Request break; default: - LLOGLN(0, ("urb_bulk_or_interrupt_transfer:" - " other transfer type 0x%X", transfer_type)); + WLog_DBG(TAG,"urb_bulk_or_interrupt_transfer:" + " other transfer type 0x%X", transfer_type); return -1; break; } @@ -1418,7 +1418,7 @@ static int libusb_udev_bulk_or_interrupt_transfer(IUDEVICE* idev, UINT32 Request if (submit < 0) { - LLOGLN(libusb_debug, ("libusb_bulk_transfer: error num %d", status)); + WLog_DBG(TAG,"libusb_bulk_transfer: error num %d", status); func_set_usbd_status(pdev, UsbdStatus, status); *BufferSize = 0; } @@ -1489,12 +1489,12 @@ static int libusb_udev_bulk_or_interrupt_transfer(IUDEVICE* idev, UINT32 Request *BufferSize = transfer->actual_length; } - LLOGLN(libusb_debug, ("bulk or interrupt Transfer data size : 0x%x", *BufferSize)); + WLog_DBG(TAG,"bulk or interrupt Transfer data size : 0x%x", *BufferSize); if (request) { if(pdev->request_queue->unregister_request(pdev->request_queue, RequestId)) - CLOG_ERR( "request_queue_unregister_request: not fount request 0x%x\n", RequestId); + WLog_ERR(TAG, "request_queue_unregister_request: not fount request 0x%x", RequestId); } libusb_free_transfer(transfer); @@ -1528,7 +1528,7 @@ static void libusb_udev_cancel_all_transfer_request(IUDEVICE* idev) if (status < 0) { - LLOGLN(libusb_debug, ("libusb_cancel_transfer: error num %d!!\n", status)); + WLog_DBG(TAG,"libusb_cancel_transfer: error num %d!!", status); } else { @@ -1557,14 +1557,14 @@ static int func_cancel_xact_request(TRANSFER_REQUEST *request) if (status < 0) { - LLOGLN(0, ("libusb_cancel_transfer: error num %d!!", status)); + WLog_DBG(TAG,"libusb_cancel_transfer: error num %d!!", status); if (status == LIBUSB_ERROR_NOT_FOUND) return -1; } else { - LLOGLN(libusb_debug, ("libusb_cancel_transfer: Success num:0x%x!!", request->RequestId)); + WLog_DBG(TAG,"libusb_cancel_transfer: Success num:0x%x!!", request->RequestId); request->submit = -1; return 1; } @@ -1590,8 +1590,8 @@ cancel_retry: if (!request) continue; - LLOGLN(libusb_debug, ("%s: CancelId:0x%x RequestId:0x%x endpoint 0x%x!!", - __func__, RequestId, request->RequestId, request->endpoint)); + WLog_DBG(TAG,"CancelId:0x%x RequestId:0x%x endpoint 0x%x!!", + RequestId, request->RequestId, request->endpoint); if ((request && request->RequestId) == (RequestId && retry_times <= 10)) { @@ -1611,16 +1611,16 @@ cancel_retry: { retry_times++; usleep(100000); - LLOGLN(10, ("urbdrc_process_cancel_request: go retry!!")); + WLog_DBG(TAG,"urbdrc_process_cancel_request: go retry!!"); goto cancel_retry; } else if ((status < 0) || (retry_times >= 10)) { /** END */ - LLOGLN(libusb_debug, ("urbdrc_process_cancel_request: error go exit!!")); + WLog_DBG(TAG,"urbdrc_process_cancel_request: error go exit!!"); return -1; } - LLOGLN(libusb_debug, ("urbdrc_process_cancel_request: success!!")); + WLog_DBG(TAG,"urbdrc_process_cancel_request: success!!"); return 0; } @@ -1704,7 +1704,7 @@ static IUDEVICE* udev_init(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_number) if (status < 0) { - CLOG_ERR( "USB init: Error to get HUB handle!!\n"); + WLog_ERR(TAG, "USB init: Error to get HUB handle!!"); pdev->hub_handle = NULL; } @@ -1712,7 +1712,7 @@ static IUDEVICE* udev_init(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_number) if (!pdev->devDescriptor) { - CLOG_ERR( "USB init: Error to get device descriptor!!\n"); + WLog_ERR(TAG, "USB init: Error to get device descriptor!!"); zfree(pdev); return NULL; } @@ -1723,7 +1723,7 @@ static IUDEVICE* udev_init(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_number) if (status < 0) { - CLOG_ERR( "libusb_get_descriptor: ERROR!!ret:%d\n", status); + WLog_ERR(TAG, "libusb_get_descriptor: ERROR!!ret:%d", status); zfree(pdev); return NULL; } @@ -1732,11 +1732,11 @@ static IUDEVICE* udev_init(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_number) /* get the first interface and first altsetting */ interface_temp = config_temp->interface[0].altsetting[0]; - LLOGLN(0, ("Regist Device: Vid: 0x%04X Pid: 0x%04X" + WLog_DBG(TAG,"Regist Device: Vid: 0x%04X Pid: 0x%04X" " InterfaceClass = 0x%X", pdev->devDescriptor->idVendor, pdev->devDescriptor->idProduct, - interface_temp.bInterfaceClass)); + interface_temp.bInterfaceClass); /* Denied list */ switch(interface_temp.bInterfaceClass) @@ -1752,7 +1752,7 @@ static IUDEVICE* udev_init(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_number) case CLASS_CONTENT_SECURITY: //case CLASS_WIRELESS_CONTROLLER: //case CLASS_ELSE_DEVICE: - CLOG_ERR( " Device is not supported!!\n"); + WLog_ERR(TAG, " Device is not supported!!"); zfree(pdev); return NULL; default: @@ -1818,7 +1818,7 @@ int udev_new_by_id(UINT16 idVendor, UINT16 idProduct, IUDEVICE*** devArray) ssize_t total_device; int i, status, num = 0; - CLOG_ERR( "VID: 0x%04X PID: 0x%04X\n", idVendor, idProduct); + WLog_ERR(TAG, "VID: 0x%04X PID: 0x%04X", idVendor, idProduct); array = (UDEVICE**) malloc(16 * sizeof(UDEVICE*)); @@ -1839,7 +1839,7 @@ int udev_new_by_id(UINT16 idVendor, UINT16 idProduct, IUDEVICE*** devArray) if (status < 0) { - CLOG_ERR( "libusb_open: (by id) error: 0x%08X (%d)\n", status, status); + WLog_ERR(TAG, "libusb_open: (by id) error: 0x%08X (%d)", status, status); zfree(descriptor); zfree(array[num]); continue; @@ -1868,7 +1868,7 @@ IUDEVICE* udev_new_by_addr(int bus_number, int dev_number) int status; UDEVICE* pDev; - LLOGLN(10, ("bus:%d dev:%d\n", bus_number, dev_number)); + WLog_DBG(TAG,"bus:%d dev:%d", bus_number, dev_number); pDev = (PUDEVICE) malloc(sizeof(UDEVICE)); @@ -1876,7 +1876,7 @@ IUDEVICE* udev_new_by_addr(int bus_number, int dev_number) if (pDev->libusb_dev == NULL) { - CLOG_ERR( "libusb_device_new: ERROR!!\n"); + WLog_ERR(TAG, "libusb_device_new: ERROR!!"); zfree(pDev); return NULL; } @@ -1885,7 +1885,7 @@ IUDEVICE* udev_new_by_addr(int bus_number, int dev_number) if (status < 0) { - CLOG_ERR( "libusb_open: (by addr) ERROR!!\n"); + WLog_ERR(TAG, "libusb_open: (by addr) ERROR!!"); zfree(pDev); return NULL; } diff --git a/channels/urbdrc/client/libusb/libusb_udevman.c b/channels/urbdrc/client/libusb/libusb_udevman.c index c395b3c37..f8ce71503 100644 --- a/channels/urbdrc/client/libusb/libusb_udevman.c +++ b/channels/urbdrc/client/libusb/libusb_udevman.c @@ -116,9 +116,8 @@ static IUDEVICE* udevman_get_udevice_by_addr(IUDEVMAN* idevman, int bus_number, } idevman->loading_unlock(idevman); - LLOGLN(libusb_debug, ("%s: bus:%d dev:%d not exist in udevman", - __func__, bus_number, dev_number)); - + WLog_WARN(TAG, "bus:%d dev:%d not exist in udevman", + bus_number, dev_number); return NULL; } @@ -206,7 +205,7 @@ static int udevman_register_udevice(IUDEVMAN* idevman, int bus_number, int dev_n } else { - CLOG_ERR( "udevman_register_udevice: function error!!"); + WLog_ERR(TAG, "udevman_register_udevice: function error!!"); return 0; } @@ -270,9 +269,10 @@ static int udevman_unregister_udevice(IUDEVMAN* idevman, int bus_number, int dev if (err != LIBUSB_ERROR_NO_DEVICE) { ret = libusb_reset_device(dev->libusb_handle); - if (ret<0){ - LLOGLN(10, ("libusb_reset_device: ERROR!!ret:%d\n", ret)); - } + if (ret<0) + { + WLog_ERR(TAG, "libusb_reset_device: ERROR!!ret:%d", ret); + } } /* release all interface and attach kernel driver */ @@ -390,8 +390,7 @@ static IUDEVICE* udevman_get_udevice_by_UsbDevice(IUDEVMAN* idevman, UINT32 UsbD return (IUDEVICE*) pdev; } - LLOGLN(libusb_debug, ("udevman_get_udevice_by_UsbDevice: 0x%x ERROR!!\n", UsbDevice)); - + WLog_ERR(TAG, "0x%x ERROR!!", UsbDevice); return NULL; } @@ -550,7 +549,7 @@ static void urbdrc_udevman_parse_addin_args(UDEVMAN* udevman, ADDIN_ARGV* args) CommandLineSwitchCase(arg, "dbg") { - urbdrc_debug = 0; + WLog_SetLogLevel(WLog_Get(TAG), WLOG_TRACE); } CommandLineSwitchCase(arg, "dev") { diff --git a/channels/urbdrc/client/libusb/request_queue.c b/channels/urbdrc/client/libusb/request_queue.c index 5709faef2..86035f1e4 100644 --- a/channels/urbdrc/client/libusb/request_queue.c +++ b/channels/urbdrc/client/libusb/request_queue.c @@ -100,7 +100,7 @@ TRANSFER_REQUEST* request_queue_get_request_by_endpoint(REQUEST_QUEUE* queue, BY } } pthread_mutex_unlock(&queue->request_loading); - CLOG_ERR( "request_queue_get_request_by_id: ERROR!!\n"); + WLog_ERR(TAG, "request_queue_get_request_by_id: ERROR!!"); return NULL; } diff --git a/channels/urbdrc/client/searchman.c b/channels/urbdrc/client/searchman.c index bdf103890..e4b2b7d73 100644 --- a/channels/urbdrc/client/searchman.c +++ b/channels/urbdrc/client/searchman.c @@ -155,17 +155,17 @@ static void searchman_list_show(USB_SEARCHMAN* self) { int num = 0; USB_SEARCHDEV* usb; - - CLOG_ERR( "=========== Usb Search List ========= \n"); + WLog_DBG(TAG, "=========== Usb Search List ========="); self->rewind(self); while (self->has_next(self)) { usb = self->get_next(self); - CLOG_ERR( " USB %d: \n", num++); - CLOG_ERR( " idVendor: 0x%04X \n", usb->idVendor); - CLOG_ERR( " idProduct: 0x%04X \n", usb->idProduct); + WLog_DBG(TAG, " USB %d: ", num++); + WLog_DBG(TAG, " idVendor: 0x%04X", usb->idVendor); + WLog_DBG(TAG, " idProduct: 0x%04X", usb->idProduct); } - CLOG_ERR( "================= END =============== \n"); + + WLog_DBG(TAG, "================= END ==============="); } void searchman_free(USB_SEARCHMAN* self) @@ -202,7 +202,7 @@ USB_SEARCHMAN* searchman_new(void * urbdrc, UINT32 UsbDevice) if (ret != 0) { - CLOG_ERR( "searchman mutex initialization: searchman->mutex failed"); + WLog_ERR(TAG, "searchman mutex initialization: searchman->mutex failed"); exit(EXIT_FAILURE); } diff --git a/channels/urbdrc/client/urbdrc_main.c b/channels/urbdrc/client/urbdrc_main.c index 568d0d5c6..e87966932 100644 --- a/channels/urbdrc/client/urbdrc_main.c +++ b/channels/urbdrc/client/urbdrc_main.c @@ -39,9 +39,7 @@ #include "data_transfer.h" #include "searchman.h" -int urbdrc_debug = 0; - -static int func_hardware_id_format(IUDEVICE* pdev, char (*HardwareIds)[DEVICE_HARDWARE_ID_SIZE]) +static int func_hardware_id_format(IUDEVICE* pdev, char(*HardwareIds)[DEVICE_HARDWARE_ID_SIZE]) { char str[DEVICE_HARDWARE_ID_SIZE]; int idVendor, idProduct, bcdDevice; @@ -230,8 +228,7 @@ static int urbdrc_process_capability_request(URBDRC_CHANNEL_CALLBACK* callback, UINT32 Version; UINT32 out_size; char * out_data; - - LLOGLN(10, ("urbdrc_process_capability_request")); + WLog_VRB(TAG, ""); data_read_UINT32(data + 0, Version); InterfaceId = ((STREAM_ID_NONE<<30) | CAPABILITIES_NEGOTIATOR); @@ -257,8 +254,7 @@ static int urbdrc_process_channel_create(URBDRC_CHANNEL_CALLBACK* callback, char UINT32 MinorVersion; UINT32 Capabilities; char* out_data; - - LLOGLN(10, ("urbdrc_process_channel_create")); + WLog_VRB(TAG, ""); data_read_UINT32(data + 0, MajorVersion); data_read_UINT32(data + 4, MinorVersion); data_read_UINT32(data + 8, Capabilities); @@ -286,9 +282,7 @@ static int urdbrc_send_virtual_channel_add(IWTSVirtualChannel* channel, UINT32 M UINT32 out_size; UINT32 InterfaceId; char* out_data; - - LLOGLN(10, ("urdbrc_send_virtual_channel_add")); - + WLog_VRB(TAG, ""); assert(NULL != channel); assert(NULL != channel->Write); @@ -318,8 +312,7 @@ static int urdbrc_send_usb_device_add(URBDRC_CHANNEL_CALLBACK* callback, IUDEVIC char strInstanceId[DEVICE_INSTANCE_STR_SIZE]; char* composite_str = "USB\\COMPOSITE"; int size, out_offset, cchCompatIds, bcdUSB; - - LLOGLN(10, ("urdbrc_send_usb_device_add")); + WLog_VRB(TAG, ""); InterfaceId = ((STREAM_ID_PROXY<<30) | CLIENT_DEVICE_SINK); /* USB kernel driver detach!! */ @@ -433,7 +426,7 @@ static int urbdrc_exchange_capabilities(URBDRC_CHANNEL_CALLBACK* callback, char* break; default: - LLOGLN(10, ("urbdrc_exchange_capabilities: unknown FunctionId 0x%X", FunctionId)); + WLog_ERR(TAG, "unknown FunctionId 0x%X", FunctionId); error = 1; break; } @@ -455,9 +448,7 @@ static void* urbdrc_search_usb_device(void* arg) int numobj, timeout; int busnum, devnum; int success = 0, error, on_close = 0, found = 0; - - LLOGLN(10, ("urbdrc_search_usb_device: ")); - + WLog_VRB(TAG, ""); channel_mgr = urbdrc->listener_callback->channel_mgr; /* init usb monitor */ @@ -469,7 +460,7 @@ static void* urbdrc_search_usb_device(void* arg) if (!udev) { - CLOG_ERR( "Can't create udev\n"); + WLog_ERR(TAG, "Can't create udev"); return 0; } @@ -484,7 +475,7 @@ static void* urbdrc_search_usb_device(void* arg) while (1) { - LLOGLN(10, ("======= SEARCH ======= ")); + WLog_VRB(TAG, "======= SEARCH ======= "); busnum = 0; devnum = 0; sdev = NULL; @@ -541,8 +532,8 @@ static void* urbdrc_search_usb_device(void* arg) if (sdev->idVendor == idVendor && sdev->idProduct == idProduct) { - LLOGLN(10, ("Searchman Find Device: %04x:%04x ", - sdev->idVendor, sdev->idProduct)); + WLog_VRB(TAG, "Searchman Find Device: %04x:%04x ", + sdev->idVendor, sdev->idProduct); found = 1; break; } @@ -550,8 +541,8 @@ static void* urbdrc_search_usb_device(void* arg) if (!found && udevman->isAutoAdd(udevman)) { - LLOGLN(10, ("Auto Find Device: %04x:%04x ", - idVendor, idProduct)); + WLog_VRB(TAG, "Auto Find Device: %04x:%04x ", + idVendor, idProduct); found = 2; } @@ -611,7 +602,7 @@ static void* urbdrc_search_usb_device(void* arg) if (dvc_channel == NULL) { - LLOGLN(0, ("SEARCH: dvc_channel %d is NULL!!", pdev->get_channel_id(pdev))); + WLog_ERR(TAG, "SEARCH: dvc_channel %d is NULL!!", pdev->get_channel_id(pdev)); func_close_udevice(searchman, pdev); break; } @@ -653,7 +644,7 @@ static void* urbdrc_search_usb_device(void* arg) } else { - CLOG_ERR( "No Device from receive_device(). An error occured.\n"); + WLog_ERR(TAG, "No Device from receive_device(). An error occured."); } } } @@ -733,8 +724,8 @@ void* urbdrc_new_device_create(void* arg) break; default: - LLOGLN(0, ("urbdrc_new_device_create: vchannel_status unknown value %d", - urbdrc->vchannel_status)); + WLog_ERR(TAG, "vchannel_status unknown value %d", + urbdrc->vchannel_status); break; } @@ -758,7 +749,7 @@ static int urbdrc_process_channel_notification(URBDRC_CHANNEL_CALLBACK* callback break; case RIMCALL_RELEASE: - LLOGLN(10, ("urbdrc_process_channel_notification: recv RIMCALL_RELEASE")); + WLog_VRB(TAG, "recv RIMCALL_RELEASE"); pthread_t thread; TRANSFER_DATA* transfer_data; @@ -781,14 +772,14 @@ static int urbdrc_process_channel_notification(URBDRC_CHANNEL_CALLBACK* callback break; default: - LLOGLN(10, ("urbdrc_process_channel_notification: unknown FunctionId 0x%X", FunctionId)); + WLog_VRB(TAG, "unknown FunctionId 0x%X", FunctionId); error = 1; break; } return error; } -static int urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, UINT32 cbSize, BYTE* Buffer) +static int urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data) { URBDRC_CHANNEL_CALLBACK* callback = (URBDRC_CHANNEL_CALLBACK*) pChannelCallback; URBDRC_PLUGIN* urbdrc; @@ -797,7 +788,8 @@ static int urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, UINT32 InterfaceId; UINT32 Mask; int error = 0; - char* pBuffer = (char*) Buffer; + char* pBuffer = (char*)Stream_Pointer(data); + UINT32 cbSize = Stream_GetRemainingLength(data); if (callback == NULL) return 0; @@ -815,7 +807,7 @@ static int urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, data_read_UINT32(pBuffer + 0, InterfaceTemp); InterfaceId = (InterfaceTemp & 0x0fffffff); Mask = ((InterfaceTemp & 0xf0000000)>>30); - LLOGLN(10, ("urbdrc_on_data_received: Size=%d InterfaceId=0x%X Mask=0x%X", cbSize, InterfaceId, Mask)); + WLog_VRB(TAG, "Size=%d InterfaceId=0x%X Mask=0x%X", cbSize, InterfaceId, Mask); switch (InterfaceId) { @@ -828,7 +820,7 @@ static int urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, break; default: - LLOGLN(10, ("urbdrc_on_data_received: InterfaceId 0x%X Start matching devices list", InterfaceId)); + WLog_VRB(TAG, "InterfaceId 0x%X Start matching devices list", InterfaceId); pthread_t thread; TRANSFER_DATA* transfer_data; @@ -836,7 +828,7 @@ static int urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, if (transfer_data == NULL) { - CLOG_ERR( "transfer_data is NULL!!"); + WLog_ERR(TAG, "transfer_data is NULL!!"); return 0; } @@ -860,7 +852,7 @@ static int urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, error = pthread_create(&thread, 0, urbdrc_process_udev_data_transfer, transfer_data); if (error < 0) - LLOGLN(0, ("Create Data Transfer Thread got error = %d", error)); + WLog_ERR(TAG, "Create Data Transfer Thread got error = %d", error); else pthread_detach(thread); @@ -881,9 +873,7 @@ static int urbdrc_on_close(IWTSVirtualChannelCallback * pChannelCallback) int found = 0; ChannelId = callback->channel_mgr->GetChannelId(callback->channel); - - LLOGLN(0, ("urbdrc_on_close: channel id %d", ChannelId)); - + WLog_INFO(TAG, "urbdrc_on_close: channel id %d", ChannelId); udevman->loading_lock(udevman); udevman->rewind(udevman); @@ -907,9 +897,7 @@ static int urbdrc_on_close(IWTSVirtualChannelCallback * pChannelCallback) } zfree(callback); - - LLOGLN(urbdrc_debug, ("urbdrc_on_close: success")); - + WLog_DBG(TAG, "success"); return 0; } @@ -918,8 +906,7 @@ static int urbdrc_on_new_channel_connection(IWTSListenerCallback* pListenerCallb { URBDRC_LISTENER_CALLBACK* listener_callback = (URBDRC_LISTENER_CALLBACK*) pListenerCallback; URBDRC_CHANNEL_CALLBACK* callback; - - LLOGLN(10, ("urbdrc_on_new_channel_connection:")); + WLog_VRB(TAG, ""); callback = (URBDRC_CHANNEL_CALLBACK*) malloc(sizeof(URBDRC_CHANNEL_CALLBACK)); callback->iface.OnDataReceived = urbdrc_on_data_received; callback->iface.OnClose = urbdrc_on_close; @@ -936,8 +923,7 @@ static int urbdrc_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManag URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*) pPlugin; IUDEVMAN* udevman = NULL; USB_SEARCHMAN* searchman = NULL; - - LLOGLN(10, ("urbdrc_plugin_initialize:")); + WLog_VRB(TAG, ""); urbdrc->listener_callback = (URBDRC_LISTENER_CALLBACK*) malloc(sizeof(URBDRC_LISTENER_CALLBACK)); memset(urbdrc->listener_callback, 0, sizeof(URBDRC_LISTENER_CALLBACK)); @@ -959,8 +945,7 @@ static int urbdrc_plugin_terminated(IWTSPlugin* pPlugin) URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*) pPlugin; IUDEVMAN* udevman = urbdrc->udevman; USB_SEARCHMAN* searchman = urbdrc->searchman; - - LLOGLN(10, ("urbdrc_plugin_terminated:")); + WLog_VRB(TAG, ""); if (searchman) { @@ -1001,7 +986,7 @@ static void urbdrc_register_udevman_addin(IWTSPlugin* pPlugin, IUDEVMAN* udevman if (urbdrc->udevman) { - CLOG_ERR("existing device, abort."); + WLog_ERR(TAG, "existing device, abort."); return; } @@ -1026,7 +1011,7 @@ static int urbdrc_load_udevman_addin(IWTSPlugin* pPlugin, const char* name, ADDI if (entry(&entryPoints) != 0) { - CLOG_ERR("%s entry returns error.", name); + WLog_ERR(TAG, "%s entry returns error.", name); return FALSE; } @@ -1070,7 +1055,7 @@ static void urbdrc_process_addin_args(URBDRC_PLUGIN* urbdrc, ADDIN_ARGV* args) CommandLineSwitchCase(arg, "dbg") { - urbdrc_debug = 0; + WLog_SetLogLevel(WLog_Get(TAG), WLOG_TRACE); } CommandLineSwitchCase(arg, "sys") { @@ -1111,8 +1096,6 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) urbdrc->searchman = NULL; urbdrc->vchannel_status = INIT_CHANNEL_IN; - urbdrc_debug = 10; - status = pEntryPoints->RegisterPlugin(pEntryPoints, "urbdrc", (IWTSPlugin*) urbdrc); } diff --git a/channels/urbdrc/client/urbdrc_types.h b/channels/urbdrc/client/urbdrc_types.h index fc5a8b4c6..641478eea 100644 --- a/channels/urbdrc/client/urbdrc_types.h +++ b/channels/urbdrc/client/urbdrc_types.h @@ -36,10 +36,11 @@ #include +#define TAG CHANNELS_TAG("urbdrc.client") #ifdef WITH_DEBUG_DVC -#define DEBUG_DVC(fmt, ...) CLOG_CLASS(DVC, fmt, ## __VA_ARGS__) +#define DEBUG_DVC(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_DVC(fmt, ...) CLOG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_DVC(fmt, ...) do { } while (0) #endif #define CAPABILITIES_NEGOTIATOR 0x00000000 @@ -316,10 +317,6 @@ enum device_descriptor_table #define MAX_URB_REQUSET_NUM 0x80 #define LOG_LEVEL 1 -#define LLOG(_level, args) \ - do { if (_level < LOG_LEVEL) { CLOG_DBG args ; } } while (0) -#define LLOGLN(_level, args) \ - do { if (_level < LOG_LEVEL) { CLOG_DBG args ; } } while (0) #define dummy_wait_obj(void) do{ sleep(5); } while(0) #define dummy_wait_s_obj(_s) do{ sleep(_s); } while(0) @@ -333,6 +330,4 @@ enum device_descriptor_table _t = (_tp.tv_sec * 1000) + (_tp.tv_usec / 1000); \ } while (0) -extern int urbdrc_debug; - #endif /* __URBDRC_TYPES_H */ diff --git a/client/Android/FreeRDPCore/jni/CMakeLists.txt b/client/Android/FreeRDPCore/jni/CMakeLists.txt index d2ea3b839..2b704b79d 100644 --- a/client/Android/FreeRDPCore/jni/CMakeLists.txt +++ b/client/Android/FreeRDPCore/jni/CMakeLists.txt @@ -55,13 +55,7 @@ endif() add_library(${MODULE_NAME} SHARED ${${MODULE_PREFIX}_SRCS}) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client) - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-core freerdp-gdi freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} dl) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} log) diff --git a/client/Android/FreeRDPCore/jni/android_debug.h b/client/Android/FreeRDPCore/jni/android_debug.h index 3a0f34fc6..b48e7f469 100644 --- a/client/Android/FreeRDPCore/jni/android_debug.h +++ b/client/Android/FreeRDPCore/jni/android_debug.h @@ -16,12 +16,13 @@ #include "config.h" #endif -#include +#include +#define ANDROID_TAG CLIENT_TAG("android") #ifdef WITH_DEBUG_ANDROID_JNI -#define DEBUG_ANDROID(fmt, ...) DEBUG_CLASS(JNI, fmt, ## __VA_ARGS__) +#define DEBUG_ANDROID(fmt, ...) WLog_DBG(ANDROID_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_ANDROID(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_ANDROID(fmt, ...) do { } while (0) #endif diff --git a/client/Android/FreeRDPCore/jni/android_event.c b/client/Android/FreeRDPCore/jni/android_event.c index 952c5a415..15452fae9 100644 --- a/client/Android/FreeRDPCore/jni/android_event.c +++ b/client/Android/FreeRDPCore/jni/android_event.c @@ -20,6 +20,9 @@ #include #include #include +#include + +#define TAG CLIENT_TAG("android") #ifdef HAVE_UNISTD_H #include @@ -49,7 +52,7 @@ void android_set_event(ANDROID_EVENT_QUEUE * queue) length = write(queue->pipe_fd[1], "sig", 4); if (length != 4) - printf("android_set_event: error\n"); + WLog_ERR(TAG, "android_set_event: error"); } @@ -62,7 +65,7 @@ void android_clear_event(ANDROID_EVENT_QUEUE * queue) length = read(queue->pipe_fd[0], &length, 4); if (length != 4) - printf("android_clear_event: error\n"); + WLog_ERR(TAG, "android_clear_event: error"); } } @@ -306,7 +309,7 @@ void android_event_queue_init(freerdp * inst) aCtx->event_queue->events = (ANDROID_EVENT**) malloc(sizeof(ANDROID_EVENT*) * aCtx->event_queue->size); if (pipe(aCtx->event_queue->pipe_fd) < 0) - printf("android_pre_connect: pipe failed\n"); + WLog_ERR(TAG, "android_pre_connect: pipe failed"); } void android_event_queue_uninit(freerdp * inst) diff --git a/client/Android/FreeRDPCore/jni/android_jni_callback.c b/client/Android/FreeRDPCore/jni/android_jni_callback.c index eac97e5fa..b8fa5dc17 100644 --- a/client/Android/FreeRDPCore/jni/android_jni_callback.c +++ b/client/Android/FreeRDPCore/jni/android_jni_callback.c @@ -18,7 +18,10 @@ #include "android_debug.h" #include "android_freerdp_jni.h" -JavaVM *jVM; +#include +#define TAG CLIENT_TAG("android") + +JavaVM* jVM; jobject jLibFreeRDPObject; const char *jLibFreeRDPPath = JAVA_LIBFREERDP_CLASS; @@ -35,7 +38,7 @@ void jni_load_class(JNIEnv *env, const char *path, jobject *objptr) if (!class) { - DEBUG_WARN("jni_load_class: failed to find class %s", path); + WLog_ERR(TAG, "jni_load_class: failed to find class %s", path); goto finish; } @@ -43,7 +46,7 @@ void jni_load_class(JNIEnv *env, const char *path, jobject *objptr) if (!method) { - DEBUG_WARN("jni_load_class: failed to find class constructor of %s", path); + WLog_ERR(TAG, "jni_load_class: failed to find class constructor of %s", path); goto finish; } @@ -51,7 +54,7 @@ void jni_load_class(JNIEnv *env, const char *path, jobject *objptr) if (!object) { - DEBUG_WARN("jni_load_class: failed create new object of %s", path); + WLog_ERR(TAG, "jni_load_class: failed create new object of %s", path); goto finish; } @@ -66,7 +69,7 @@ jint init_callback_environment(JavaVM* vm) JNIEnv* env; if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4) != JNI_OK) { - DEBUG_WARN("JNI_OnLoad: failed to obtain current JNI environment"); + WLog_ERR(TAG, "JNI_OnLoad: failed to obtain current JNI environment"); return -1; } @@ -88,7 +91,7 @@ jboolean jni_attach_thread(JNIEnv** env) if ((*jVM)->GetEnv(jVM, (void**) env, JNI_VERSION_1_4) != JNI_OK) { - DEBUG_WARN("android_java_callback: failed to obtain current JNI environment"); + WLog_ERR(TAG, "android_java_callback: failed to obtain current JNI environment"); } return JNI_TRUE; @@ -117,15 +120,17 @@ void java_callback_void(jobject obj, const char * callback, const char* signatur jObjClass = (*env)->GetObjectClass(env, obj); - if (!jObjClass) { - DEBUG_WARN("android_java_callback: failed to get class reference"); + if (!jObjClass) + { + WLog_ERR(TAG, "android_java_callback: failed to get class reference"); goto finish; } jCallback = (*env)->GetStaticMethodID(env, jObjClass, callback, signature); - if (!jCallback) { - DEBUG_WARN("android_java_callback: failed to get method id"); + if (!jCallback) + { + WLog_ERR(TAG, "android_java_callback: failed to get method id"); goto finish; } @@ -151,15 +156,17 @@ jboolean java_callback_bool(jobject obj, const char * callback, const char* sign jObjClass = (*env)->GetObjectClass(env, obj); - if (!jObjClass) { - DEBUG_WARN("android_java_callback: failed to get class reference"); + if (!jObjClass) + { + WLog_ERR(TAG, "android_java_callback: failed to get class reference"); goto finish; } jCallback = (*env)->GetStaticMethodID(env, jObjClass, callback, signature); - if (!jCallback) { - DEBUG_WARN("android_java_callback: failed to get method id"); + if (!jCallback) + { + WLog_ERR(TAG, "android_java_callback: failed to get method id"); goto finish; } diff --git a/client/DirectFB/CMakeLists.txt b/client/DirectFB/CMakeLists.txt index 75eafc251..6cf7cead9 100644 --- a/client/DirectFB/CMakeLists.txt +++ b/client/DirectFB/CMakeLists.txt @@ -32,13 +32,7 @@ add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) set(${MODULE_PREFIX}_LIBS ${DIRECTFB_LIBRARIES}) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client) - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-core freerdp-gdi freerdp-locale freerdp-codec freerdp-primitives freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/client/DirectFB/dfreerdp.c b/client/DirectFB/dfreerdp.c index c231cd583..1d645c0a6 100644 --- a/client/DirectFB/dfreerdp.c +++ b/client/DirectFB/dfreerdp.c @@ -24,6 +24,7 @@ #include #include #include + #include #include #include @@ -37,6 +38,9 @@ #include "dfreerdp.h" +#include +#define TAG CLIENT_TAG("directFB") + static HANDLE g_sem; static int g_thread_count = 0; @@ -232,18 +236,17 @@ BOOL df_post_connect(freerdp* instance) BOOL df_verify_certificate(freerdp* instance, char* subject, char* issuer, char* fingerprint) { char answer; - - printf("Certificate details:\n"); - printf("\tSubject: %s\n", subject); - printf("\tIssuer: %s\n", issuer); - printf("\tThumbprint: %s\n", fingerprint); - printf("The above X.509 certificate could not be verified, possibly because you do not have " - "the CA certificate in your certificate store, or the certificate has expired. " - "Please look at the documentation on how to create local certificate store for a private CA.\n"); + WLog_INFO(TAG, "Certificate details:"); + WLog_INFO(TAG, "\tSubject: %s", subject); + WLog_INFO(TAG, "\tIssuer: %s", issuer); + WLog_INFO(TAG, "\tThumbprint: %s", fingerprint); + WLog_INFO(TAG, "The above X.509 certificate could not be verified, possibly because you do not have " + "the CA certificate in your certificate store, or the certificate has expired. " + "Please look at the documentation on how to create local certificate store for a private CA."); while (1) { - printf("Do you trust the above certificate? (Y/N) "); + WLog_INFO(TAG, "Do you trust the above certificate? (Y/N) "); answer = fgetc(stdin); if (answer == 'y' || answer == 'Y') @@ -259,7 +262,7 @@ BOOL df_verify_certificate(freerdp* instance, char* subject, char* issuer, char* return FALSE; } -static int df_receive_channel_data(freerdp* instance, int channelId, BYTE* data, int size, int flags, int total_size) +static int df_receive_channel_data(freerdp* instance, UINT16 channelId, BYTE* data, int size, int flags, int total_size) { return freerdp_channels_data(instance, channelId, data, size, flags, total_size); } @@ -292,7 +295,7 @@ static void df_process_channel_event(rdpChannels* channels, freerdp* instance) break; default: - DEBUG_WARN( "df_process_channel_event: unknown event type %d\n", GetMessageType(event->id)); + WLog_ERR(TAG, "df_process_channel_event: unknown event type %d", GetMessageType(event->id)); break; } @@ -339,17 +342,17 @@ int dfreerdp_run(freerdp* instance) if (freerdp_get_fds(instance, rfds, &rcount, wfds, &wcount) != TRUE) { - DEBUG_WARN( "Failed to get FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to get FreeRDP file descriptor"); break; } if (freerdp_channels_get_fds(channels, instance, rfds, &rcount, wfds, &wcount) != TRUE) { - DEBUG_WARN( "Failed to get channel manager file descriptor\n"); + WLog_ERR(TAG, "Failed to get channel manager file descriptor"); break; } if (df_get_fds(instance, rfds, &rcount, wfds, &wcount) != TRUE) { - DEBUG_WARN( "Failed to get dfreerdp file descriptor\n"); + WLog_ERR(TAG, "Failed to get dfreerdp file descriptor"); break; } @@ -378,24 +381,24 @@ int dfreerdp_run(freerdp* instance) (errno == EINPROGRESS) || (errno == EINTR))) /* signal occurred */ { - DEBUG_WARN( "dfreerdp_run: select failed\n"); + WLog_ERR(TAG, "dfreerdp_run: select failed"); break; } } if (freerdp_check_fds(instance) != TRUE) { - DEBUG_WARN( "Failed to check FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to check FreeRDP file descriptor"); break; } if (df_check_fds(instance, &rfds_set) != TRUE) { - DEBUG_WARN( "Failed to check dfreerdp file descriptor\n"); + WLog_ERR(TAG, "Failed to check dfreerdp file descriptor"); break; } if (freerdp_channels_check_fds(channels, instance) != TRUE) { - DEBUG_WARN( "Failed to check channel manager file descriptor\n"); + WLog_ERR(TAG, "Failed to check channel manager file descriptor"); break; } df_process_channel_event(channels, instance); diff --git a/client/Mac/CMakeLists.txt b/client/Mac/CMakeLists.txt index 91eb01bdb..863ec827a 100644 --- a/client/Mac/CMakeLists.txt +++ b/client/Mac/CMakeLists.txt @@ -79,12 +79,7 @@ set_target_properties(${MODULE_NAME} PROPERTIES BUILD_WITH_INSTALL_RPATH 1) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${EXTRA_LIBS} freerdp-client) - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-core freerdp-cache freerdp-gdi freerdp-codec freerdp-primitives freerdp-rail freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index dd47304ba..52452d74c 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -43,6 +43,9 @@ #import "freerdp/client/cliprdr.h" #import "freerdp/client/file.h" #import "freerdp/client/cmdline.h" +#import "freerdp/log.h" + +#define TAG CLIENT_TAG("mac") void mf_Pointer_New(rdpContext* context, rdpPointer* pointer); void mf_Pointer_Free(rdpContext* context, rdpPointer* pointer); @@ -617,7 +620,7 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type) vkcode &= 0xFF; #if 0 - DEBUG_WARN( "keyDown: keyCode: 0x%04X scancode: 0x%04X vkcode: 0x%04X keyFlags: %d name: %s\n", + WLog_ERR(TAG, "keyDown: keyCode: 0x%04X scancode: 0x%04X vkcode: 0x%04X keyFlags: %d name: %s", keyCode, scancode, vkcode, keyFlags, GetVirtualKeyName(vkcode)); #endif @@ -654,7 +657,7 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type) vkcode &= 0xFF; #if 0 - DEBUG_WARN( "keyUp: key: 0x%04X scancode: 0x%04X vkcode: 0x%04X keyFlags: %d name: %s\n", + WLog_DBG(TAG, "keyUp: key: 0x%04X scancode: 0x%04X vkcode: 0x%04X keyFlags: %d name: %s", keyCode, scancode, vkcode, keyFlags, GetVirtualKeyName(vkcode)); #endif @@ -683,29 +686,29 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type) vkcode &= 0xFF; #if 0 - DEBUG_WARN( "flagsChanged: key: 0x%04X scancode: 0x%04X vkcode: 0x%04X extended: %d name: %s modFlags: 0x%04X\n", + WLog_DBG(TAG, "flagsChanged: key: 0x%04X scancode: 0x%04X vkcode: 0x%04X extended: %d name: %s modFlags: 0x%04X", key - 8, scancode, vkcode, keyFlags, GetVirtualKeyName(vkcode), modFlags); if (modFlags & NSAlphaShiftKeyMask) - DEBUG_WARN( "NSAlphaShiftKeyMask\n"); + WLog_DBG(TAG, "NSAlphaShiftKeyMask"); if (modFlags & NSShiftKeyMask) - DEBUG_WARN( "NSShiftKeyMask\n"); + WLog_DBG(TAG, "NSShiftKeyMask"); if (modFlags & NSControlKeyMask) - DEBUG_WARN( "NSControlKeyMask\n"); + WLog_DBG(TAG, "NSControlKeyMask"); if (modFlags & NSAlternateKeyMask) - DEBUG_WARN( "NSAlternateKeyMask\n"); + WLog_DBG(TAG, "NSAlternateKeyMask"); if (modFlags & NSCommandKeyMask) - DEBUG_WARN( "NSCommandKeyMask\n"); + WLog_DBG(TAG, "NSCommandKeyMask"); if (modFlags & NSNumericPadKeyMask) - DEBUG_WARN( "NSNumericPadKeyMask\n"); + WLog_DBG(TAG, "NSNumericPadKeyMask"); if (modFlags & NSHelpKeyMask) - DEBUG_WARN( "NSHelpKeyMask\n"); + WLog_DBG(TAG, "NSHelpKeyMask"); #endif if ((modFlags & NSAlphaShiftKeyMask) && !(kbdModFlags & NSAlphaShiftKeyMask)) @@ -870,7 +873,7 @@ BOOL mac_pre_connect(freerdp* instance) if (!settings->ServerHostname) { - DEBUG_WARN( "error: server hostname was not specified with /v:[:port]\n"); + WLog_ERR(TAG, "error: server hostname was not specified with /v:[:port]"); [NSApp terminate:nil]; return -1; } @@ -1244,7 +1247,7 @@ static void update_activity_cb(freerdp* instance) } else { - DEBUG_WARN( "update_activity_cb: No queue!\n"); + WLog_ERR(TAG, "update_activity_cb: No queue!"); } } @@ -1269,7 +1272,7 @@ static void input_activity_cb(freerdp* instance) } else { - DEBUG_WARN( "input_activity_cb: No queue!\n"); + WLog_ERR(TAG, "input_activity_cb: No queue!"); } } @@ -1282,7 +1285,7 @@ static void channel_activity_cb(freerdp* instance) if (event) { - DEBUG_WARN( "channel_activity_cb: message %d\n", event->id); + WLog_DBG(TAG, "channel_activity_cb: message %d", event->id); switch (GetMessageClass(event->id)) { @@ -1406,7 +1409,7 @@ void cliprdr_process_cb_format_list_event(freerdp* instance, RDP_CB_FORMAT_LIST_ switch (event->formats[i]) { case CB_FORMAT_RAW: - printf("CB_FORMAT_RAW: not yet supported\n"); + WLog_ERR(TAG, "CB_FORMAT_RAW: not yet supported"); break; case CB_FORMAT_TEXT: @@ -1417,23 +1420,23 @@ void cliprdr_process_cb_format_list_event(freerdp* instance, RDP_CB_FORMAT_LIST_ break; case CB_FORMAT_DIB: - printf("CB_FORMAT_DIB: not yet supported\n"); + WLog_ERR(TAG, "CB_FORMAT_DIB: not yet supported"); break; case CB_FORMAT_HTML: - printf("CB_FORMAT_HTML\n"); + WLog_ERR(TAG, "CB_FORMAT_HTML"); break; case CB_FORMAT_PNG: - printf("CB_FORMAT_PNG: not yet supported\n"); + WLog_ERR(TAG, "CB_FORMAT_PNG: not yet supported"); break; case CB_FORMAT_JPEG: - printf("CB_FORMAT_JPEG: not yet supported\n"); + WLog_ERR(TAG, "CB_FORMAT_JPEG: not yet supported"); break; case CB_FORMAT_GIF: - printf("CB_FORMAT_GIF: not yet supported\n"); + WLog_ERR(TAG, "CB_FORMAT_GIF: not yet supported"); break; } } @@ -1484,7 +1487,7 @@ void process_cliprdr_event(freerdp* instance, wMessage* event) break; default: - printf("process_cliprdr_event: unknown event type %d\n", GetMessageType(event->id)); + WLog_ERR(TAG, "process_cliprdr_event: unknown event type %d", GetMessageType(event->id)); break; } } diff --git a/client/Sample/CMakeLists.txt b/client/Sample/CMakeLists.txt index c5070a7bd..f9506b315 100644 --- a/client/Sample/CMakeLists.txt +++ b/client/Sample/CMakeLists.txt @@ -24,14 +24,7 @@ set(${MODULE_PREFIX}_SRCS add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${CMAKE_DL_LIBS}) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client) - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-core freerdp-gdi freerdp-utils) - +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client freerdp) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Sample") diff --git a/client/Sample/freerdp.c b/client/Sample/freerdp.c index cedc3dc98..d426bbc85 100644 --- a/client/Sample/freerdp.c +++ b/client/Sample/freerdp.c @@ -46,6 +46,9 @@ #include #include +#include + +#define TAG CLIENT_TAG("sample") struct tf_info { @@ -127,7 +130,7 @@ void tf_process_channel_event(rdpChannels* channels, freerdp* instance) break; default: - printf("tf_process_channel_event: unknown event type %d\n", GetMessageType(event->id)); + WLog_ERR(TAG, "unknown event type %d", GetMessageType(event->id)); break; } @@ -219,12 +222,12 @@ int tfreerdp_run(freerdp* instance) ZeroMemory(wfds, sizeof(wfds)); if (freerdp_get_fds(instance, rfds, &rcount, wfds, &wcount) != TRUE) { - printf("Failed to get FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to get FreeRDP file descriptor"); break; } if (freerdp_channels_get_fds(channels, instance, rfds, &rcount, wfds, &wcount) != TRUE) { - printf("Failed to get channel manager file descriptor\n"); + WLog_ERR(TAG, "Failed to get channel manager file descriptor"); break; } @@ -253,19 +256,19 @@ int tfreerdp_run(freerdp* instance) (errno == EINPROGRESS) || (errno == EINTR))) /* signal occurred */ { - printf("tfreerdp_run: select failed\n"); + WLog_ERR(TAG, "tfreerdp_run: select failed"); break; } } if (freerdp_check_fds(instance) != TRUE) { - printf("Failed to check FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to check FreeRDP file descriptor"); break; } if (freerdp_channels_check_fds(channels, instance) != TRUE) { - printf("Failed to check channel manager file descriptor\n"); + WLog_ERR(TAG, "Failed to check channel manager file descriptor"); break; } tf_process_channel_event(channels, instance); diff --git a/client/Windows/CMakeLists.txt b/client/Windows/CMakeLists.txt index 8de892fb4..c208301c0 100644 --- a/client/Windows/CMakeLists.txt +++ b/client/Windows/CMakeLists.txt @@ -60,15 +60,7 @@ else() endif() set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client) - - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-core freerdp-gdi freerdp-codec freerdp-primitives freerdp-utils) - +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) if(WITH_CLIENT_INTERFACE) diff --git a/client/Windows/wf_client.c b/client/Windows/wf_client.c index 65527a636..ce93ad81d 100644 --- a/client/Windows/wf_client.c +++ b/client/Windows/wf_client.c @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -54,6 +55,8 @@ #include "resource.h" +#define TAG CLIENT_TAG("windows") + int wf_create_console(void) { if (!AllocConsole()) @@ -61,9 +64,7 @@ int wf_create_console(void) freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stderr); - - DEBUG_WARN( "Debug console created.\n"); - + WLog_INFO(TAG, "Debug console created."); return 0; } @@ -199,9 +200,7 @@ BOOL wf_pre_connect(freerdp* instance) } wfc->connectionRdpFile = freerdp_client_rdp_file_new(); - - DEBUG_WARN( "Using connection file: %s\n", settings->ConnectionFile); - + WLog_INFO(TAG, "Using connection file: %s", settings->ConnectionFile); freerdp_client_parse_rdp_file(wfc->connectionRdpFile, settings->ConnectionFile); freerdp_client_populate_settings_from_rdp_file(wfc->connectionRdpFile, settings); } @@ -289,7 +288,7 @@ BOOL wf_pre_connect(freerdp* instance) if ((settings->DesktopWidth < 64) || (settings->DesktopHeight < 64) || (settings->DesktopWidth > 4096) || (settings->DesktopHeight > 4096)) { - DEBUG_WARN( "wf_pre_connect: invalid dimensions %d %d\n", settings->DesktopWidth, settings->DesktopHeight); + WLog_ERR(TAG, "invalid dimensions %d %d", settings->DesktopWidth, settings->DesktopHeight); return 1; } @@ -492,7 +491,7 @@ BOOL wf_authenticate(freerdp* instance, char** username, char** password, char** if (status != NO_ERROR) { - DEBUG_WARN( "CredUIPromptForCredentials unexpected status: 0x%08X\n", status); + WLog_ERR(TAG, "CredUIPromptForCredentials unexpected status: 0x%08X", status); return FALSE; } @@ -500,9 +499,7 @@ BOOL wf_authenticate(freerdp* instance, char** username, char** password, char** ZeroMemory(Domain, sizeof(Domain)); status = CredUIParseUserNameA(UserName, User, sizeof(User), Domain, sizeof(Domain)); - - //DEBUG_WARN( "User: %s Domain: %s Password: %s\n", User, Domain, Password); - + //WLog_ERR(TAG, "User: %s Domain: %s Password: %s", User, Domain, Password); *username = _strdup(User); if (strlen(Domain) > 0) @@ -523,15 +520,13 @@ BOOL wf_verify_certificate(freerdp* instance, char* subject, char* issuer, char* TCHAR* read_buffer; HANDLE input_handle; #endif - - printf("Certificate details:\n"); - printf("\tSubject: %s\n", subject); - printf("\tIssuer: %s\n", issuer); - printf("\tThumbprint: %s\n", fingerprint); - printf("The above X.509 certificate could not be verified, possibly because you do not have " - "the CA certificate in your certificate store, or the certificate has expired. " - "Please look at the documentation on how to create local certificate store for a private CA.\n"); - + WLog_INFO(TAG, "Certificate details:"); + WLog_INFO(TAG, "\tSubject: %s", subject); + WLog_INFO(TAG, "\tIssuer: %s", issuer); + WLog_INFO(TAG, "\tThumbprint: %s", fingerprint); + WLog_INFO(TAG, "The above X.509 certificate could not be verified, possibly because you do not have " + "the CA certificate in your certificate store, or the certificate has expired. " + "Please look at the documentation on how to create local certificate store for a private CA."); /* TODO: ask for user validation */ #if 0 input_handle = GetStdHandle(STD_INPUT_HANDLE); @@ -595,7 +590,8 @@ static BOOL wf_auto_reconnect(freerdp* instance) return FALSE; /* A network disconnect was detected */ - DEBUG_WARN( "Network disconnect!\n"); + WLog_ERR(TAG, "Network disconnect!"); + if (!instance->settings->AutoReconnectionEnabled) { /* No auto-reconnect - just quit */ @@ -610,7 +606,8 @@ static BOOL wf_auto_reconnect(freerdp* instance) return FALSE; /* Attempt the next reconnect */ - DEBUG_WARN( "Attempting reconnect (%u of %u)\n", num_retries, max_retries); + WLog_INFO(TAG, "Attempting reconnect (%u of %u)", num_retries, max_retries); + if (freerdp_reconnect(instance)) { return TRUE; @@ -619,8 +616,7 @@ static BOOL wf_auto_reconnect(freerdp* instance) Sleep(5000); } - DEBUG_WARN( "Maximum reconnect retries exceeded\n"); - + WLog_ERR(TAG, "Maximum reconnect retries exceeded"); return FALSE; } @@ -746,13 +742,13 @@ DWORD WINAPI wf_client_thread(LPVOID lpParam) { if (freerdp_get_fds(instance, rfds, &rcount, wfds, &wcount) != TRUE) { - DEBUG_WARN( "Failed to get FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to get FreeRDP file descriptor"); break; } } if (wf_get_fds(instance, rfds, &rcount, wfds, &wcount) != TRUE) { - DEBUG_WARN( "Failed to get wfreerdp file descriptor\n"); + WLog_ERR(TAG, "Failed to get wfreerdp file descriptor"); break; } @@ -760,7 +756,7 @@ DWORD WINAPI wf_client_thread(LPVOID lpParam) { if (freerdp_channels_get_fds(channels, instance, rfds, &rcount, wfds, &wcount) != TRUE) { - DEBUG_WARN( "Failed to get channel manager file descriptor\n"); + WLog_ERR(TAG, "Failed to get channel manager file descriptor"); break; } } @@ -778,14 +774,14 @@ DWORD WINAPI wf_client_thread(LPVOID lpParam) /* exit if nothing to do */ if (fds_count == 0) { - DEBUG_WARN( "wfreerdp_run: fds_count is zero\n"); + WLog_ERR(TAG, "wfreerdp_run: fds_count is zero"); //break; } /* do the wait */ if (MsgWaitForMultipleObjects(fds_count, fds, FALSE, 1000, QS_ALLINPUT) == WAIT_FAILED) { - DEBUG_WARN( "wfreerdp_run: WaitForMultipleObjects failed: 0x%04X\n", GetLastError()); + WLog_ERR(TAG, "wfreerdp_run: WaitForMultipleObjects failed: 0x%04X", GetLastError()); break; } @@ -796,7 +792,7 @@ DWORD WINAPI wf_client_thread(LPVOID lpParam) if (wf_auto_reconnect(instance)) continue; - DEBUG_WARN( "Failed to check FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to check FreeRDP file descriptor"); break; } } @@ -806,7 +802,7 @@ DWORD WINAPI wf_client_thread(LPVOID lpParam) } if (wf_check_fds(instance) != TRUE) { - DEBUG_WARN( "Failed to check wfreerdp file descriptor\n"); + WLog_ERR(TAG, "Failed to check wfreerdp file descriptor"); break; } @@ -814,7 +810,7 @@ DWORD WINAPI wf_client_thread(LPVOID lpParam) { if (freerdp_channels_check_fds(channels, instance) != TRUE) { - DEBUG_WARN( "Failed to check channel manager file descriptor\n"); + WLog_ERR(TAG, "Failed to check channel manager file descriptor"); break; } @@ -885,9 +881,7 @@ DWORD WINAPI wf_client_thread(LPVOID lpParam) } freerdp_disconnect(instance); - - printf("Main thread exited.\n"); - + WLog_DBG(TAG, "Main thread exited."); ExitThread(0); return 0; @@ -911,7 +905,7 @@ DWORD WINAPI wf_keyboard_thread(LPVOID lpParam) { if (status == -1) { - DEBUG_WARN( "keyboard thread error getting message\n"); + WLog_ERR(TAG, "keyboard thread error getting message"); break; } else @@ -925,11 +919,10 @@ DWORD WINAPI wf_keyboard_thread(LPVOID lpParam) } else { - DEBUG_WARN( "failed to install keyboard hook\n"); + WLog_ERR(TAG, "failed to install keyboard hook"); } - printf("Keyboard thread exited.\n"); - + WLog_DBG(TAG, "Keyboard thread exited."); ExitThread(0); return (DWORD) NULL; } @@ -953,8 +946,8 @@ int freerdp_client_focus_out(wfContext* wfc) int freerdp_client_set_window_size(wfContext* wfc, int width, int height) { - DEBUG_WARN( "freerdp_client_set_window_size %d, %d", width, height); - + WLog_DBG(TAG, "freerdp_client_set_window_size %d, %d", width, height); + if ((width != wfc->client_width) || (height != wfc->client_height)) { PostThreadMessage(wfc->mainThreadId, WM_SIZE, SIZE_RESTORED, ((UINT) height << 16) | (UINT) width); @@ -977,8 +970,7 @@ int freerdp_client_load_settings_from_rdp_file(wfContext* wfc, char* filename) // free old settings file freerdp_client_rdp_file_free(wfc->connectionRdpFile); wfc->connectionRdpFile = freerdp_client_rdp_file_new(); - - DEBUG_WARN( "Using connection file: %s\n", settings->ConnectionFile); + WLog_INFO(TAG, "Using connection file: %s", settings->ConnectionFile); if (!freerdp_client_parse_rdp_file(wfc->connectionRdpFile, settings->ConnectionFile)) { @@ -1148,13 +1140,9 @@ int wfreerdp_client_new(freerdp* instance, rdpContext* context) void wfreerdp_client_free(freerdp* instance, rdpContext* context) { - wfContext* wfc = (wfContext*) context; - if (context->cache) cache_free(context->cache); - _aligned_free(wfc->bitmap_buffer); - freerdp_channels_free(context->channels); } diff --git a/client/Windows/wf_client.h b/client/Windows/wf_client.h index 05e56a073..2e36599b7 100644 --- a/client/Windows/wf_client.h +++ b/client/Windows/wf_client.h @@ -31,7 +31,7 @@ #include #include #include -#include + #include #include #include diff --git a/client/Windows/wf_cliprdr.c b/client/Windows/wf_cliprdr.c index d5e7aaeca..de035e425 100644 --- a/client/Windows/wf_cliprdr.c +++ b/client/Windows/wf_cliprdr.c @@ -28,11 +28,17 @@ #include #include +#include +#include +#include +#include #include #include "wf_cliprdr.h" +#define TAG CLIENT_TAG("windows") + extern BOOL WINAPI AddClipboardFormatListener(_In_ HWND hwnd); extern BOOL WINAPI RemoveClipboardFormatListener(_In_ HWND hwnd); @@ -572,7 +578,7 @@ void wf_cliprdr_init(wfContext* wfc, rdpChannels* channels) if (!wfc->instance->settings->RedirectClipboard) { wfc->cliprdr_context = NULL; - DEBUG_WARN( "clipboard is not redirected.\n"); + WLog_ERR(TAG, "clipboard is not redirected."); return; } @@ -665,7 +671,7 @@ static BOOL wf_cliprdr_get_file_contents(wchar_t *file_name, BYTE *buffer, int p if (file_name == NULL || buffer == NULL || puSize == NULL) { - DEBUG_WARN( "get file contents Invalid Arguments.\n"); + WLog_ERR(TAG, "get file contents Invalid Arguments."); return FALSE; } hFile = CreateFileW(file_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL); @@ -1182,7 +1188,7 @@ static void wf_cliprdr_process_cb_filecontents_request_event(wfContext *wfc, RDP hRet = OleGetClipboard(&pDataObj); if (!SUCCEEDED(hRet)) { - DEBUG_WARN( "filecontents: get ole clipboard failed.\n"); + WLog_ERR(TAG, "filecontents: get ole clipboard failed."); goto error; } @@ -1280,7 +1286,7 @@ static void wf_cliprdr_process_cb_filecontents_request_event(wfContext *wfc, RDP event->nPositionLow, event->nPositionHigh, event->cbRequested, &uSize); if (bRet == FALSE) { - DEBUG_WARN( "get file contents failed.\n"); + WLog_ERR(TAG, "get file contents failed."); uSize = 0; goto error; } @@ -1311,7 +1317,7 @@ error: IDataObject_Release(pDataObj); pDataObj = NULL; } - DEBUG_WARN( "filecontents: send failed response.\n"); + WLog_ERR(TAG, "filecontents: send failed response."); cliprdr_send_response_filecontents(cliprdr, event->streamId, 0, NULL); return; } diff --git a/client/Windows/wf_cliprdr.h b/client/Windows/wf_cliprdr.h index 3592fb9ae..aaa5b8ce7 100644 --- a/client/Windows/wf_cliprdr.h +++ b/client/Windows/wf_cliprdr.h @@ -26,11 +26,13 @@ #include #include "wf_client.h" +#include +#define TAG CLIENT_TAG(WIN_CLIPRDR_TAG) #ifdef WITH_DEBUG_CLIPRDR -#define DEBUG_CLIPRDR(fmt, ...) DEBUG_CLASS(WIN_CLIPRDR, fmt, ## __VA_ARGS__) +#define DEBUG_CLIPRDR(fmt, ...) WLog_DBG(WIN_CLIPRDR_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_CLIPRDR(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_CLIPRDR(fmt, ...) do { } while (0) #endif typedef struct format_mapping formatMapping; diff --git a/client/Windows/wf_event.h b/client/Windows/wf_event.h index 588046d57..7cd3c57d6 100644 --- a/client/Windows/wf_event.h +++ b/client/Windows/wf_event.h @@ -23,14 +23,16 @@ #define __WF_EVENT_H #include "wf_client.h" +#include LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); +#define KBD_TAG CLIENT_TAG("windows") #ifdef WITH_DEBUG_KBD -#define DEBUG_KBD(fmt, ...) DEBUG_CLASS(KBD, fmt, ## __VA_ARGS__) +#define DEBUG_KBD(fmt, ...) WLog_DBG(KBD_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_KBD(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_KBD(fmt, ...) do { } while (0) #endif #endif /* __WF_EVENT_H */ diff --git a/client/Windows/wf_gdi.c b/client/Windows/wf_gdi.c index 07cb52b03..e08d1fadb 100644 --- a/client/Windows/wf_gdi.c +++ b/client/Windows/wf_gdi.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -39,6 +40,8 @@ #include "wf_graphics.h" #include "wf_gdi.h" +#define TAG CLIENT_TAG("windows.gdi") + const BYTE wf_rop2_table[] = { R2_BLACK, /* 0 */ @@ -63,7 +66,7 @@ BOOL wf_set_rop2(HDC hdc, int rop2) { if ((rop2 < 0x01) || (rop2 > 0x10)) { - DEBUG_WARN( "Unsupported ROP2: %d\n", rop2); + WLog_ERR(TAG, "Unsupported ROP2: %d", rop2); return FALSE; } @@ -404,7 +407,7 @@ void wf_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate) freerdp_client_codecs_prepare(codecs, FREERDP_CODEC_INTERLEAVED); status = interleaved_decompress(codecs->interleaved, pSrcData, SrcSize, bitsPerPixel, - &pDstData, PIXEL_FORMAT_XRGB32, nWidth * 4, 0, 0, nWidth, nHeight); + &pDstData, PIXEL_FORMAT_XRGB32, nWidth * 4, 0, 0, nWidth, nHeight, NULL); } else { @@ -416,7 +419,7 @@ void wf_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate) if (status < 0) { - DEBUG_WARN("wf_gdi_bitmap_update: bitmap decompression failure\n"); + WLog_ERR(TAG, "bitmap decompression failure"); return; } @@ -742,7 +745,7 @@ void wf_gdi_surface_bits(wfContext* wfc, SURFACE_BITS_COMMAND* surface_bits_comm } else { - DEBUG_WARN( "Unsupported codecID %d\n", surface_bits_command->codecID); + WLog_ERR(TAG, "Unsupported codecID %d", surface_bits_command->codecID); } if (tile_bitmap != NULL) diff --git a/client/Windows/wf_graphics.c b/client/Windows/wf_graphics.c index 28cec4cad..ab3f3b5f6 100644 --- a/client/Windows/wf_graphics.c +++ b/client/Windows/wf_graphics.c @@ -24,10 +24,13 @@ #include #include +#include #include "wf_gdi.h" #include "wf_graphics.h" +#define TAG CLIENT_TAG("windows") + HBITMAP wf_create_dib(wfContext* wfc, int width, int height, int bpp, BYTE* data, BYTE** pdata) { HDC hdc; @@ -171,7 +174,7 @@ void wf_Bitmap_Decompress(wfContext* wfc, rdpBitmap* bitmap, freerdp_client_codecs_prepare(wfc->codecs, FREERDP_CODEC_INTERLEAVED); status = interleaved_decompress(wfc->codecs->interleaved, pSrcData, SrcSize, bpp, - &pDstData, PIXEL_FORMAT_XRGB32, width * 4, 0, 0, width, height); + &pDstData, PIXEL_FORMAT_XRGB32, width * 4, 0, 0, width, height, NULL); } else { @@ -183,7 +186,7 @@ void wf_Bitmap_Decompress(wfContext* wfc, rdpBitmap* bitmap, if (status < 0) { - DEBUG_WARN("wf_Bitmap_Decompress: Bitmap Decompression Failed\n"); + WLog_ERR(TAG, "Bitmap Decompression Failed"); return; } } @@ -192,7 +195,7 @@ void wf_Bitmap_Decompress(wfContext* wfc, rdpBitmap* bitmap, SrcFormat = gdi_get_pixel_format(bpp, TRUE); status = freerdp_image_copy(pDstData, PIXEL_FORMAT_XRGB32, width * 4, 0, 0, - width, height, pSrcData, SrcFormat, width * bytesPerPixel, 0, 0); + width, height, pSrcData, SrcFormat, width * bytesPerPixel, 0, 0, NULL); } bitmap->compressed = FALSE; diff --git a/client/X11/CMakeLists.txt b/client/X11/CMakeLists.txt index 35e3e932e..a6bd5b5cf 100644 --- a/client/X11/CMakeLists.txt +++ b/client/X11/CMakeLists.txt @@ -89,14 +89,7 @@ if(WITH_MANPAGES) add_executable(generate_argument_docbook generate_argument_docbook.c) set(GAD_LIBS freerdp-client) - - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - - set_complex_link_libraries(VARIABLE GAD_LIBS MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-core freerdp-utils) - - target_link_libraries(generate_argument_docbook ${GAD_LIBS}) + target_link_libraries(generate_argument_docbook ${GAD_LIBS} freerdp winpr) add_custom_command(OUTPUT xfreerdp.1 COMMAND generate_argument_docbook @@ -206,12 +199,7 @@ endif() include_directories(${CMAKE_SOURCE_DIR}/resources) -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client) - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-core freerdp-gdi freerdp-locale freerdp-primitives freerdp-rail freerdp-utils) - +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp freerdp-client) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) if(WITH_IPP) diff --git a/client/X11/generate_argument_docbook.c b/client/X11/generate_argument_docbook.c index c1a3035e7..22abed391 100644 --- a/client/X11/generate_argument_docbook.c +++ b/client/X11/generate_argument_docbook.c @@ -26,7 +26,7 @@ LPSTR tr_esc_str(LPCSTR arg) tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR)); if(NULL == tmp) { - DEBUG_WARN( "Could not allocate string buffer."); + WLog_ERR(TAG, "Could not allocate string buffer."); exit(-2); } /* Copy character for character and check, if it is necessary to escape. */ @@ -40,7 +40,7 @@ LPSTR tr_esc_str(LPCSTR arg) tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR)); if(NULL == tmp) { - DEBUG_WARN( "Could not reallocate string buffer."); + WLog_ERR(TAG, "Could not reallocate string buffer."); exit(-3); } tmp[cs++] = '&'; @@ -53,7 +53,7 @@ LPSTR tr_esc_str(LPCSTR arg) tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR)); if(NULL == tmp) { - DEBUG_WARN( "Could not reallocate string buffer."); + WLog_ERR(TAG, "Could not reallocate string buffer."); exit(-4); } tmp[cs++] = '&'; @@ -66,7 +66,7 @@ LPSTR tr_esc_str(LPCSTR arg) tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR)); if(NULL == tmp) { - DEBUG_WARN( "Could not reallocate string buffer."); + WLog_ERR(TAG, "Could not reallocate string buffer."); exit(-5); } tmp[cs++] = '&'; @@ -81,7 +81,7 @@ LPSTR tr_esc_str(LPCSTR arg) tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR)); if(NULL == tmp) { - DEBUG_WARN( "Could not reallocate string buffer."); + WLog_ERR(TAG, "Could not reallocate string buffer."); exit(-6); } tmp[cs++] = '&'; @@ -96,7 +96,7 @@ LPSTR tr_esc_str(LPCSTR arg) tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR)); if(NULL == tmp) { - DEBUG_WARN( "Could not reallocate string buffer."); + WLog_ERR(TAG, "Could not reallocate string buffer."); exit(-7); } tmp[cs++] = '&'; @@ -125,7 +125,7 @@ int main(int argc, char *argv[]) fp = fopen(fname, "w"); if(NULL == fp) { - DEBUG_WARN( "Could not open '%s' for writing.", fname); + WLog_ERR(TAG, "Could not open '%s' for writing.", fname); return -1; } /* The tag used as header in the manpage */ @@ -136,7 +136,7 @@ int main(int argc, char *argv[]) * compatible XML */ if(elements < 2) { - DEBUG_WARN( "The argument array 'args' is empty, writing an empty file."); + WLog_ERR(TAG, "The argument array 'args' is empty, writing an empty file."); elements = 1; } for(x=0; x +#define TAG CLIENT_TAG("x11") static long xv_port = 0; static const size_t password_size = 512; @@ -547,7 +549,7 @@ int xf_encomsp_participant_created(EncomspClientContext* context, ENCOMSP_PARTIC #if 0 xfContext* xfc = (xfContext*) context->custom; - printf("ParticipantCreated: ParticipantId: %d GroupId: %d Flags: 0x%04X xfc: %p\n", + WLog_INFO(TAG, "ParticipantCreated: ParticipantId: %d GroupId: %d Flags: 0x%04X xfc: %p", (int) participantCreated->ParticipantId, (int) participantCreated->GroupId, (int) participantCreated->Flags, xfc); #endif @@ -608,7 +610,7 @@ BOOL xf_get_pixmap_info(xfContext *xfc) pfs = XListPixmapFormats(xfc->display, &pf_count); if(pfs == NULL) { - DEBUG_WARN( "xf_get_pixmap_info: XListPixmapFormats failed\n"); + WLog_ERR(TAG, "XListPixmapFormats failed"); return 1; } for(i = 0; i < pf_count; i++) @@ -627,13 +629,13 @@ BOOL xf_get_pixmap_info(xfContext *xfc) template.screen = xfc->screen_number; if(XGetWindowAttributes(xfc->display, RootWindowOfScreen(xfc->screen), &window_attributes) == 0) { - DEBUG_WARN( "xf_get_pixmap_info: XGetWindowAttributes failed\n"); + WLog_ERR(TAG, "XGetWindowAttributes failed"); return FALSE; } vis = XGetVisualInfo(xfc->display, VisualClassMask | VisualScreenMask, &template, &vi_count); if(vis == NULL) { - DEBUG_WARN( "xf_get_pixmap_info: XGetVisualInfo failed\n"); + WLog_ERR(TAG, "XGetVisualInfo failed"); return FALSE; } vi = NULL; @@ -672,7 +674,7 @@ int xf_error_handler(Display *d, XErrorEvent *ev) char buf[256]; int do_abort = TRUE; XGetErrorText(d, ev->error_code, buf, sizeof(buf)); - DEBUG_WARN( "%s", buf); + WLog_ERR(TAG, "%s", buf); if(do_abort) abort(); _def_error_handler(d, ev); @@ -763,7 +765,7 @@ BOOL xf_pre_connect(freerdp* instance) { if(!XInitThreads()) { - DEBUG_WARN( "warning: XInitThreads() failure\n"); + WLog_WARN(TAG, "XInitThreads() failure"); xfc->UseXThreads = FALSE; } } @@ -772,14 +774,14 @@ BOOL xf_pre_connect(freerdp* instance) if (!xfc->display) { - DEBUG_WARN( "xf_pre_connect: failed to open display: %s\n", XDisplayName(NULL)); - DEBUG_WARN( "Please check that the $DISPLAY environment variable is properly set.\n"); + WLog_ERR(TAG, "failed to open display: %s", XDisplayName(NULL)); + WLog_ERR(TAG, "Please check that the $DISPLAY environment variable is properly set."); return FALSE; } if (xfc->debug) { - DEBUG_WARN( "Enabling X11 debug mode.\n"); + WLog_INFO(TAG, "Enabling X11 debug mode."); XSynchronize(xfc->display, TRUE); _def_error_handler = XSetErrorHandler(_xf_error_handler); } @@ -799,19 +801,17 @@ BOOL xf_pre_connect(freerdp* instance) /* Check --authonly has a username and password. */ if (!settings->Username) { - DEBUG_WARN( "--authonly, but no -u username. Please provide one.\n"); + WLog_INFO(TAG, "--authonly, but no -u username. Please provide one."); return FALSE; } if (!settings->Password) { - DEBUG_WARN( "--authonly, but no -p password. Please provide one.\n"); + WLog_INFO(TAG, "--authonly, but no -p password. Please provide one."); return FALSE; } - DEBUG_WARN("Authentication only. Don't connect to X.\n"); - /* Avoid XWindows initialization and configuration below. */ - return TRUE; + WLog_INFO(TAG, "Authentication only. Don't connect to X."); } xfc->_NET_WM_ICON = XInternAtom(xfc->display, "_NET_WM_ICON", False); @@ -1025,23 +1025,23 @@ BOOL xf_authenticate(freerdp *instance, char **username, char **password, char * BOOL xf_verify_certificate(freerdp *instance, char *subject, char *issuer, char *fingerprint) { char answer; - printf("Certificate details:\n"); - printf("\tSubject: %s\n", subject); - printf("\tIssuer: %s\n", issuer); - printf("\tThumbprint: %s\n", fingerprint); - printf("The above X.509 certificate could not be verified, possibly because you do not have " + WLog_INFO(TAG, "Certificate details:"); + WLog_INFO(TAG, "\tSubject: %s", subject); + WLog_INFO(TAG, "\tIssuer: %s", issuer); + WLog_INFO(TAG, "\tThumbprint: %s", fingerprint); + WLog_INFO(TAG, "The above X.509 certificate could not be verified, possibly because you do not have " "the CA certificate in your certificate store, or the certificate has expired. " - "Please look at the documentation on how to create local certificate store for a private CA.\n"); + "Please look at the documentation on how to create local certificate store for a private CA."); while(1) { - printf("Do you trust the above certificate? (Y/N) "); + WLog_INFO(TAG, "Do you trust the above certificate? (Y/N) "); answer = fgetc(stdin); if(feof(stdin)) { - printf("\nError: Could not read answer from stdin."); + WLog_INFO(TAG, "Error: Could not read answer from stdin."); if(instance->settings->CredentialsFromStdin) - printf(" - Run without parameter \"--from-stdin\" to set trust."); - printf("\n"); + WLog_INFO(TAG, " - Run without parameter \"--from-stdin\" to set trust."); + WLog_INFO(TAG, ""); return FALSE; } if(answer == 'y' || answer == 'Y') @@ -1053,7 +1053,7 @@ BOOL xf_verify_certificate(freerdp *instance, char *subject, char *issuer, char { break; } - printf("\n"); + WLog_INFO(TAG, ""); } return FALSE; } @@ -1246,7 +1246,7 @@ BOOL xf_auto_reconnect(freerdp *instance) if(freerdp_error_info(instance) != 0) return FALSE; /* A network disconnect was detected */ - DEBUG_WARN( "Network disconnect!\n"); + WLog_INFO(TAG, "Network disconnect!"); if(!instance->settings->AutoReconnectionEnabled) { /* No auto-reconnect - just quit */ @@ -1261,7 +1261,7 @@ BOOL xf_auto_reconnect(freerdp *instance) return FALSE; } /* Attempt the next reconnect */ - DEBUG_WARN( "Attempting reconnect (%u of %u)\n", num_retries, max_retries); + WLog_INFO(TAG, "Attempting reconnect (%u of %u)", num_retries, max_retries); if(freerdp_reconnect(instance)) { xfc->disconnect = FALSE; @@ -1269,7 +1269,7 @@ BOOL xf_auto_reconnect(freerdp *instance) } sleep(5); } - DEBUG_WARN( "Maximum reconnect retries exceeded\n"); + WLog_ERR(TAG, "Maximum reconnect retries exceeded"); return FALSE; } @@ -1320,7 +1320,7 @@ void *xf_thread(void *param) if(instance->settings->AuthenticationOnly) { freerdp_disconnect(instance); - DEBUG_WARN( "Authentication only, exit status %d\n", !status); + WLog_ERR(TAG, "Authentication only, exit status %d", !status); ExitThread(exit_code); } if(!status) @@ -1367,7 +1367,7 @@ void *xf_thread(void *param) { if(freerdp_get_fds(instance, rfds, &rcount, wfds, &wcount) != TRUE) { - DEBUG_WARN( "Failed to get FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to get FreeRDP file descriptor"); exit_code = XF_EXIT_CONN_FAILED; break; } @@ -1376,7 +1376,7 @@ void *xf_thread(void *param) { if(freerdp_channels_get_fds(channels, instance, rfds, &rcount, wfds, &wcount) != TRUE) { - DEBUG_WARN( "Failed to get channel manager file descriptor\n"); + WLog_ERR(TAG, "Failed to get channel manager file descriptor"); exit_code = XF_EXIT_CONN_FAILED; break; } @@ -1385,7 +1385,7 @@ void *xf_thread(void *param) { if(xf_get_fds(instance, rfds, &rcount, wfds, &wcount) != TRUE) { - DEBUG_WARN( "Failed to get xfreerdp file descriptor\n"); + WLog_ERR(TAG, "Failed to get xfreerdp file descriptor"); exit_code = XF_EXIT_CONN_FAILED; break; } @@ -1422,7 +1422,7 @@ void *xf_thread(void *param) if(!((errno == EAGAIN) || (errno == EWOULDBLOCK) || (errno == EINPROGRESS) || (errno == EINTR))) /* signal occurred */ { - DEBUG_WARN( "xfreerdp_run: select failed\n"); + WLog_ERR(TAG, "xfreerdp_run: select failed"); break; } } @@ -1432,7 +1432,7 @@ void *xf_thread(void *param) { if(xf_auto_reconnect(instance)) continue; - DEBUG_WARN( "Failed to check FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to check FreeRDP file descriptor"); break; } } @@ -1440,7 +1440,7 @@ void *xf_thread(void *param) { if(freerdp_channels_check_fds(channels, instance) != TRUE) { - DEBUG_WARN( "Failed to check channel manager file descriptor\n"); + WLog_ERR(TAG, "Failed to check channel manager file descriptor"); break; } xf_process_channel_event(channels, instance); @@ -1449,7 +1449,7 @@ void *xf_thread(void *param) { if(xf_process_x_events(instance) != TRUE) { - DEBUG_WARN( "Closed from X11\n"); + WLog_INFO(TAG, "Closed from X11"); break; } } @@ -1459,7 +1459,7 @@ void *xf_thread(void *param) { if(!freerdp_message_queue_process_pending_messages(instance, FREERDP_INPUT_MESSAGE_QUEUE)) { - DEBUG_WARN( "User Disconnect\n"); + WLog_INFO(TAG, "User Disconnect"); xfc->disconnect = TRUE; break; } @@ -1576,7 +1576,7 @@ static int xfreerdp_client_start(rdpContext *context) if (!settings->ServerHostname) { - DEBUG_WARN( "error: server hostname was not specified with /v:[:port]\n"); + WLog_ERR(TAG, "error: server hostname was not specified with /v:[:port]"); return -1; } xfc->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) xf_thread, diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index b37fa6f80..3deaebf9f 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -33,21 +33,23 @@ #include #include +#include #include #include #include "xf_cliprdr.h" +#define TAG CLIENT_TAG("x11") #ifdef WITH_DEBUG_X11 -#define DEBUG_X11(fmt, ...) DEBUG_CLASS(X11, fmt, ## __VA_ARGS__) +#define DEBUG_X11(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_X11(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_X11(fmt, ...) do { } while (0) #endif #ifdef WITH_DEBUG_X11_CLIPRDR -#define DEBUG_X11_CLIPRDR(fmt, ...) DEBUG_CLASS(X11_CLIPRDR, fmt, ## __VA_ARGS__) +#define DEBUG_X11_CLIPRDR(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_X11_CLIPRDR(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_X11_CLIPRDR(fmt, ...) do { } while (0) #endif typedef struct clipboard_format_mapping clipboardFormatMapping; @@ -118,7 +120,7 @@ void xf_cliprdr_init(xfContext* xfc, rdpChannels* channels) if (cb->clipboard_atom == None) { - DEBUG_WARN("unable to get CLIPBOARD atom"); + WLog_ERR(TAG, "unable to get CLIPBOARD atom"); } id = 1; @@ -143,15 +145,15 @@ void xf_cliprdr_init(xfContext* xfc, rdpChannels* channels) } else { - DEBUG_WARN( "%s: Error querying X Fixes extension version\n", __FUNCTION__); + WLog_ERR(TAG, "Error querying X Fixes extension version"); } } else { - DEBUG_WARN( "%s: Error loading X Fixes extension\n", __FUNCTION__); + WLog_ERR(TAG, "Error loading X Fixes extension"); } #else - DEBUG_WARN( "Warning: Using clipboard redirection without XFIXES extension is strongly discouraged!\n"); + WLog_ERR(TAG, "Warning: Using clipboard redirection without XFIXES extension is strongly discouraged!"); #endif n = 0; @@ -370,7 +372,7 @@ static void xf_cliprdr_send_raw_format_list(xfContext* xfc) if (result != Success) { - DEBUG_WARN("XGetWindowProperty failed"); + WLog_ERR(TAG, "XGetWindowProperty failed"); return; } DEBUG_X11_CLIPRDR("format=%d len=%d bytes_left=%d", format, (int) length, (int) bytes_left); @@ -970,7 +972,7 @@ static BOOL xf_cliprdr_process_dib(clipboardContext* cb, BYTE* data, int size) Stream_Read_UINT16(s, bpp); if ((bpp < 1) || (bpp > 32)) { - DEBUG_WARN( "%s: invalid bpp value %d", __FUNCTION__, bpp); + WLog_ERR(TAG, "invalid bpp value %d", bpp); return FALSE; } diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index e2c8bdfaf..5260fb832 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -25,6 +25,7 @@ #include #include +#include #include "xf_rail.h" #include "xf_window.h" @@ -35,6 +36,8 @@ #include "xf_event.h" #include "xf_input.h" +#define TAG CLIENT_TAG("x11") + #define CLAMP_COORDINATES(x, y) if (x < 0) x = 0; if (y < 0) y = 0 const char* const X11_EVENT_STRINGS[] = @@ -77,15 +80,15 @@ const char* const X11_EVENT_STRINGS[] = }; #ifdef WITH_DEBUG_X11 -#define DEBUG_X11(fmt, ...) DEBUG_CLASS(X11, fmt, ## __VA_ARGS__) +#define DEBUG_X11(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_X11(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_X11(fmt, ...) do { } while (0) #endif #ifdef WITH_DEBUG_X11_LOCAL_MOVESIZE -#define DEBUG_X11_LMS(fmt, ...) DEBUG_CLASS(X11_LMS, fmt, ## __VA_ARGS__) +#define DEBUG_X11_LMS(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_X11_LMS(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_X11_LMS(fmt, ...) do { } while (0) #endif int xf_event_action_script_init(xfContext* xfc) diff --git a/client/X11/xf_gdi.c b/client/X11/xf_gdi.c index 3cb43f2d3..fcf4db5e2 100644 --- a/client/X11/xf_gdi.c +++ b/client/X11/xf_gdi.c @@ -33,6 +33,9 @@ #include "xf_gdi.h" +#include +#define TAG CLIENT_TAG("x11") + static UINT8 GDI_BS_HATCHED_PATTERNS[] = { 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, /* HS_HORIZONTAL */ @@ -68,7 +71,7 @@ BOOL xf_set_rop2(xfContext* xfc, int rop2) { if ((rop2 < 0x01) || (rop2 > 0x10)) { - DEBUG_WARN( "Unsupported ROP2: %d\n", rop2); + WLog_ERR(TAG, "Unsupported ROP2: %d", rop2); return FALSE; } @@ -204,7 +207,7 @@ BOOL xf_set_rop3(xfContext* xfc, int rop3) if (function < 0) { - DEBUG_WARN( "Unsupported ROP3: 0x%08X\n", rop3); + WLog_ERR(TAG, "Unsupported ROP3: 0x%08X", rop3); XSetFunction(xfc->display, xfc->gc, GXclear); return FALSE; } @@ -347,7 +350,7 @@ void xf_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate) freerdp_client_codecs_prepare(codecs, FREERDP_CODEC_INTERLEAVED); status = interleaved_decompress(codecs->interleaved, pSrcData, SrcSize, bitsPerPixel, - &pDstData, xfc->format, -1, 0, 0, nWidth, nHeight); + &pDstData, xfc->format, -1, 0, 0, nWidth, nHeight, xfc->palette); } else { @@ -359,7 +362,7 @@ void xf_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate) if (status < 0) { - DEBUG_WARN("xf_gdi_bitmap_update: bitmap decompression failure\n"); + WLog_ERR(TAG, "bitmap decompression failure"); return; } @@ -370,7 +373,7 @@ void xf_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate) pDstData = xfc->bitmap_buffer; status = freerdp_image_copy(pDstData, xfc->format, -1, 0, 0, - nWidth, nHeight, pSrcData, SrcFormat, -1, 0, 0); + nWidth, nHeight, pSrcData, SrcFormat, -1, 0, 0, xfc->palette); pSrcData = xfc->bitmap_buffer; } @@ -398,12 +401,23 @@ void xf_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate) void xf_gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette) { + int index; + PALETTE_ENTRY* pe; + UINT32* palette32; xfContext* xfc = (xfContext*) context; xf_lock_x11(xfc, FALSE); CopyMemory(xfc->clrconv->palette, palette, sizeof(rdpPalette)); + palette32 = (UINT32*) xfc->palette; + + for (index = 0; index < palette->number; index++) + { + pe = &(palette->entries[index]); + palette32[index] = RGB32(pe->red, pe->green, pe->blue); + } + xf_unlock_x11(xfc, FALSE); } @@ -470,9 +484,9 @@ void xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) brush = &patblt->brush; xf_set_rop3(xfc, gdi_rop3_code(patblt->bRop)); - foreColor = freerdp_convert_gdi_order_color(patblt->foreColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32); + foreColor = freerdp_convert_gdi_order_color(patblt->foreColor, context->settings->ColorDepth, xfc->format, xfc->palette); foreColor = xf_gdi_get_color(xfc, foreColor); - backColor = freerdp_convert_gdi_order_color(patblt->backColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32); + backColor = freerdp_convert_gdi_order_color(patblt->backColor, context->settings->ColorDepth, xfc->format, xfc->palette); backColor = xf_gdi_get_color(xfc, backColor); if (brush->style == GDI_BS_SOLID) @@ -533,7 +547,7 @@ void xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) } else { - DEBUG_WARN( "unimplemented brush style:%d\n", brush->style); + WLog_ERR(TAG, "unimplemented brush style:%d", brush->style); } if (xfc->drawing == xfc->primary) @@ -592,7 +606,7 @@ void xf_gdi_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect) xf_lock_x11(xfc, FALSE); - color = freerdp_convert_gdi_order_color(opaque_rect->color, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32); + color = freerdp_convert_gdi_order_color(opaque_rect->color, context->settings->ColorDepth, xfc->format, xfc->palette); color = xf_gdi_get_color(xfc, color); XSetFunction(xfc->display, xfc->gc, GXcopy); @@ -628,7 +642,7 @@ void xf_gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* mult xf_lock_x11(xfc, FALSE); - color = freerdp_convert_gdi_order_color(multi_opaque_rect->color, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32); + color = freerdp_convert_gdi_order_color(multi_opaque_rect->color, context->settings->ColorDepth, xfc->format, xfc->palette); color = xf_gdi_get_color(xfc, color); XSetFunction(xfc->display, xfc->gc, GXcopy); @@ -660,7 +674,7 @@ void xf_gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* mult void xf_gdi_draw_nine_grid(rdpContext* context, DRAW_NINE_GRID_ORDER* draw_nine_grid) { - DEBUG_WARN( "DrawNineGrid\n"); + WLog_ERR(TAG, "DrawNineGrid"); } void xf_gdi_line_to(rdpContext* context, LINE_TO_ORDER* line_to) @@ -671,7 +685,7 @@ void xf_gdi_line_to(rdpContext* context, LINE_TO_ORDER* line_to) xf_lock_x11(xfc, FALSE); xf_set_rop2(xfc, line_to->bRop2); - color = freerdp_convert_gdi_order_color(line_to->penColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32); + color = freerdp_convert_gdi_order_color(line_to->penColor, context->settings->ColorDepth, xfc->format, xfc->palette); color = xf_gdi_get_color(xfc, color); XSetFillStyle(xfc->display, xfc->gc, FillSolid); @@ -722,7 +736,7 @@ void xf_gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline) xf_lock_x11(xfc, FALSE); xf_set_rop2(xfc, polyline->bRop2); - color = freerdp_convert_gdi_order_color(polyline->penColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32); + color = freerdp_convert_gdi_order_color(polyline->penColor, context->settings->ColorDepth, xfc->format, xfc->palette); color = xf_gdi_get_color(xfc, color); XSetFillStyle(xfc->display, xfc->gc, FillSolid); @@ -820,9 +834,9 @@ void xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt) brush = &mem3blt->brush; bitmap = (xfBitmap*) mem3blt->bitmap; xf_set_rop3(xfc, gdi_rop3_code(mem3blt->bRop)); - foreColor = freerdp_convert_gdi_order_color(mem3blt->foreColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32); + foreColor = freerdp_convert_gdi_order_color(mem3blt->foreColor, context->settings->ColorDepth, xfc->format, xfc->palette); foreColor = xf_gdi_get_color(xfc, foreColor); - backColor = freerdp_convert_gdi_order_color(mem3blt->backColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32); + backColor = freerdp_convert_gdi_order_color(mem3blt->backColor, context->settings->ColorDepth, xfc->format, xfc->palette); backColor = xf_gdi_get_color(xfc, backColor); if (brush->style == GDI_BS_PATTERN) @@ -856,7 +870,7 @@ void xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt) } else { - DEBUG_WARN( "Mem3Blt unimplemented brush style:%d\n", brush->style); + WLog_ERR(TAG, "Mem3Blt unimplemented brush style:%d", brush->style); } XCopyArea(xfc->display, bitmap->pixmap, xfc->drawing, xfc->gc, @@ -895,7 +909,7 @@ void xf_gdi_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc) xf_lock_x11(xfc, FALSE); xf_set_rop2(xfc, polygon_sc->bRop2); - brush_color = freerdp_convert_gdi_order_color(polygon_sc->brushColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32); + brush_color = freerdp_convert_gdi_order_color(polygon_sc->brushColor, context->settings->ColorDepth, xfc->format, xfc->palette); brush_color = xf_gdi_get_color(xfc, brush_color); npoints = polygon_sc->numPoints + 1; @@ -921,7 +935,7 @@ void xf_gdi_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc) break; default: - DEBUG_WARN( "PolygonSC unknown fillMode: %d\n", polygon_sc->fillMode); + WLog_ERR(TAG, "PolygonSC unknown fillMode: %d", polygon_sc->fillMode); break; } @@ -957,9 +971,9 @@ void xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb) brush = &(polygon_cb->brush); xf_set_rop2(xfc, polygon_cb->bRop2); - foreColor = freerdp_convert_gdi_order_color(polygon_cb->foreColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32); + foreColor = freerdp_convert_gdi_order_color(polygon_cb->foreColor, context->settings->ColorDepth, xfc->format, xfc->palette); foreColor = xf_gdi_get_color(xfc, foreColor); - backColor = freerdp_convert_gdi_order_color(polygon_cb->backColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32); + backColor = freerdp_convert_gdi_order_color(polygon_cb->backColor, context->settings->ColorDepth, xfc->format, xfc->palette); backColor = xf_gdi_get_color(xfc, backColor); npoints = polygon_cb->numPoints + 1; @@ -985,7 +999,7 @@ void xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb) break; default: - DEBUG_WARN( "PolygonCB unknown fillMode: %d\n", polygon_cb->fillMode); + WLog_ERR(TAG, "PolygonCB unknown fillMode: %d", polygon_cb->fillMode); break; } @@ -1043,7 +1057,7 @@ void xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb) } else { - DEBUG_WARN( "PolygonCB unimplemented brush style:%d\n", brush->style); + WLog_ERR(TAG, "PolygonCB unimplemented brush style:%d", brush->style); } XSetFunction(xfc->display, xfc->gc, GXcopy); @@ -1054,17 +1068,16 @@ void xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb) void xf_gdi_ellipse_sc(rdpContext* context, ELLIPSE_SC_ORDER* ellipse_sc) { - DEBUG_WARN( "EllipseSC\n"); + WLog_ERR(TAG, "EllipseSC"); } void xf_gdi_ellipse_cb(rdpContext* context, ELLIPSE_CB_ORDER* ellipse_cb) { - DEBUG_WARN( "EllipseCB\n"); + WLog_ERR(TAG, "EllipseCB"); } void xf_gdi_frame_marker(rdpContext* context, FRAME_MARKER_ORDER* frameMarker) { - } void xf_gdi_surface_frame_marker(rdpContext* context, SURFACE_FRAME_MARKER* surface_frame_marker) @@ -1178,7 +1191,7 @@ void xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* cmd) pDstData = xfc->bitmap_buffer; freerdp_image_copy(pDstData, xfc->format, -1, 0, 0, - 64, 64, pSrcData, PIXEL_FORMAT_XRGB32, -1, 0, 0); + 64, 64, pSrcData, PIXEL_FORMAT_XRGB32, -1, 0, 0, xfc->palette); } image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, @@ -1231,7 +1244,7 @@ void xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* cmd) pDstData = xfc->bitmap_buffer; freerdp_image_copy(pDstData, xfc->format, -1, 0, 0, - cmd->width, cmd->height, pSrcData, PIXEL_FORMAT_XRGB32_VF, -1, 0, 0); + cmd->width, cmd->height, pSrcData, PIXEL_FORMAT_XRGB32_VF, -1, 0, 0, xfc->palette); image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, (char*) pDstData, cmd->width, cmd->height, xfc->scanline_pad, 0); @@ -1270,7 +1283,7 @@ void xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* cmd) pDstData = xfc->bitmap_buffer; freerdp_image_copy(pDstData, xfc->format, -1, 0, 0, - cmd->width, cmd->height, pSrcData, PIXEL_FORMAT_XRGB32_VF, -1, 0, 0); + cmd->width, cmd->height, pSrcData, PIXEL_FORMAT_XRGB32_VF, -1, 0, 0, xfc->palette); image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, (char*) pDstData, cmd->width, cmd->height, xfc->scanline_pad, 0); @@ -1293,7 +1306,7 @@ void xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* cmd) } else { - DEBUG_WARN("Unsupported codecID %d\n", cmd->codecID); + WLog_ERR(TAG, "Unsupported codecID %d", cmd->codecID); } xf_unlock_x11(xfc, FALSE); diff --git a/client/X11/xf_gfx.c b/client/X11/xf_gfx.c index 02d09e052..2cbd1d4ff 100644 --- a/client/X11/xf_gfx.c +++ b/client/X11/xf_gfx.c @@ -21,8 +21,11 @@ #include "config.h" #endif +#include #include "xf_gfx.h" +#define TAG CLIENT_TAG("x11") + int xf_ResetGraphics(RdpgfxClientContext* context, RDPGFX_RESET_GRAPHICS_PDU* resetGraphics) { xfContext* xfc = (xfContext*) context->custom; @@ -78,10 +81,7 @@ int xf_OutputUpdate(xfContext* xfc) if (surface->stage) { freerdp_image_copy(surface->stage, xfc->format, surface->stageStep, 0, 0, - surface->width, surface->height, surface->data, surface->format, surface->scanline, 0, 0); - - //freerdp_image_copy(surface->stage, xfc->format, surface->stageStep, extents->left, extents->top, - // width, height, surface->data, surface->format, surface->scanline, extents->left, extents->top); + surface->width, surface->height, surface->data, surface->format, surface->scanline, 0, 0, NULL); } XPutImage(xfc->display, xfc->drawable, xfc->gc, surface->image, @@ -143,7 +143,7 @@ int xf_SurfaceCommand_Uncompressed(xfContext* xfc, RdpgfxClientContext* context, return -1; freerdp_image_copy(surface->data, surface->format, surface->scanline, cmd->left, cmd->top, - cmd->width, cmd->height, cmd->data, PIXEL_FORMAT_XRGB32, cmd->width * 4, 0, 0); + cmd->width, cmd->height, cmd->data, PIXEL_FORMAT_XRGB32, -1, 0, 0, NULL); invalidRect.left = cmd->left; invalidRect.top = cmd->top; @@ -223,7 +223,7 @@ int xf_SurfaceCommand_RemoteFX(xfContext* xfc, RdpgfxClientContext* context, RDP freerdp_image_copy(surface->data, surface->format, surface->scanline, nXDst, nYDst, nWidth, nHeight, - tile->data, PIXEL_FORMAT_XRGB32, 64 * 4, 0, 0); + tile->data, PIXEL_FORMAT_XRGB32, 64 * 4, 0, 0, NULL); region16_union_rect(&(xfc->invalidRegion), &(xfc->invalidRegion), &updateRects[j]); } @@ -260,7 +260,7 @@ int xf_SurfaceCommand_ClearCodec(xfContext* xfc, RdpgfxClientContext* context, R if (status < 0) { - printf("clear_decompress failure: %d\n", status); + WLog_ERR(TAG, "clear_decompress failure: %d\n", status); return -1; } @@ -342,7 +342,7 @@ int xf_SurfaceCommand_H264(xfContext* xfc, RdpgfxClientContext* context, RDPGFX_ if (status < 0) { - printf("h264_decompress failure: %d\n",status); + WLog_ERR(TAG, "h264_decompress failure: %d",status); return -1; } @@ -370,8 +370,7 @@ int xf_SurfaceCommand_Alpha(xfContext* xfc, RdpgfxClientContext* context, RDPGFX if (!surface) return -1; - printf("xf_SurfaceCommand_Alpha: status: %d\n", status); - + WLog_DBG(TAG, "xf_SurfaceCommand_Alpha: status: %d\n", status); /* fill with green for now to distinguish from the rest */ freerdp_image_fill(surface->data, PIXEL_FORMAT_XRGB32, surface->scanline, @@ -425,7 +424,7 @@ int xf_SurfaceCommand_Progressive(xfContext* xfc, RdpgfxClientContext* context, if (status < 0) { - printf("progressive_decompress failure: %d\n", status); + WLog_ERR(TAG, "progressive_decompress failure: %d", status); return -1; } @@ -470,7 +469,7 @@ int xf_SurfaceCommand_Progressive(xfContext* xfc, RdpgfxClientContext* context, freerdp_image_copy(surface->data, PIXEL_FORMAT_XRGB32, surface->scanline, nXDst, nYDst, nWidth, nHeight, - tile->data, PIXEL_FORMAT_XRGB32, 64 * 4, nXSrc, nYSrc); + tile->data, PIXEL_FORMAT_XRGB32, 64 * 4, nXSrc, nYSrc, NULL); region16_union_rect(&(xfc->invalidRegion), &(xfc->invalidRegion), &updateRects[j]); } @@ -701,7 +700,7 @@ int xf_SurfaceToSurface(RdpgfxClientContext* context, RDPGFX_SURFACE_TO_SURFACE_ { freerdp_image_copy(surfaceDst->data, surfaceDst->format, surfaceDst->scanline, destPt->x, destPt->y, nWidth, nHeight, surfaceSrc->data, surfaceSrc->format, - surfaceSrc->scanline, rectSrc->left, rectSrc->top); + surfaceSrc->scanline, rectSrc->left, rectSrc->top, NULL); } invalidRect.left = destPt->x; @@ -756,7 +755,7 @@ int xf_SurfaceToCache(RdpgfxClientContext* context, RDPGFX_SURFACE_TO_CACHE_PDU* freerdp_image_copy(cacheEntry->data, cacheEntry->format, cacheEntry->scanline, 0, 0, cacheEntry->width, cacheEntry->height, surface->data, - surface->format, surface->scanline, rect->left, rect->top); + surface->format, surface->scanline, rect->left, rect->top, NULL); context->SetCacheSlotData(context, surfaceToCache->cacheSlot, (void*) cacheEntry); @@ -784,7 +783,7 @@ int xf_CacheToSurface(RdpgfxClientContext* context, RDPGFX_CACHE_TO_SURFACE_PDU* freerdp_image_copy(surface->data, surface->format, surface->scanline, destPt->x, destPt->y, cacheEntry->width, cacheEntry->height, - cacheEntry->data, cacheEntry->format, cacheEntry->scanline, 0, 0); + cacheEntry->data, cacheEntry->format, cacheEntry->scanline, 0, 0, NULL); invalidRect.left = destPt->x; invalidRect.top = destPt->y; diff --git a/client/X11/xf_graphics.c b/client/X11/xf_graphics.c index c87368bf5..a1f8ffebb 100644 --- a/client/X11/xf_graphics.c +++ b/client/X11/xf_graphics.c @@ -36,6 +36,9 @@ #include "xf_graphics.h" +#include +#define TAG CLIENT_TAG("x11") + /* Bitmap Class */ void xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap) @@ -68,7 +71,7 @@ void xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap) SrcFormat = gdi_get_pixel_format(bitmap->bpp, TRUE); freerdp_image_copy(data, xfc->format, -1, 0, 0, - bitmap->width, bitmap->height, bitmap->data, SrcFormat, -1, 0, 0); + bitmap->width, bitmap->height, bitmap->data, SrcFormat, -1, 0, 0, xfc->palette); _aligned_free(bitmap->data); bitmap->data = data; @@ -156,7 +159,7 @@ void xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, freerdp_client_codecs_prepare(xfc->codecs, FREERDP_CODEC_INTERLEAVED); status = interleaved_decompress(xfc->codecs->interleaved, pSrcData, SrcSize, bpp, - &pDstData, xfc->format, -1, 0, 0, width, height); + &pDstData, xfc->format, -1, 0, 0, width, height, xfc->palette); } else { @@ -168,7 +171,7 @@ void xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, if (status < 0) { - DEBUG_WARN("xf_Bitmap_Decompress: Bitmap Decompression Failed\n"); + WLog_ERR(TAG, "Bitmap Decompression Failed"); return; } } @@ -177,7 +180,7 @@ void xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, SrcFormat = gdi_get_pixel_format(bpp, TRUE); status = freerdp_image_copy(pDstData, xfc->format, -1, 0, 0, - width, height, pSrcData, SrcFormat, -1, 0, 0); + width, height, pSrcData, SrcFormat, -1, 0, 0, xfc->palette); } bitmap->compressed = FALSE; @@ -377,8 +380,8 @@ void xf_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height { xfContext* xfc = (xfContext*) context; - bgcolor = freerdp_convert_gdi_order_color(bgcolor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32); - fgcolor = freerdp_convert_gdi_order_color(fgcolor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32); + bgcolor = freerdp_convert_gdi_order_color(bgcolor, context->settings->ColorDepth, xfc->format, xfc->palette); + fgcolor = freerdp_convert_gdi_order_color(fgcolor, context->settings->ColorDepth, xfc->format, xfc->palette); xf_lock_x11(xfc, FALSE); diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index 067c0e780..e01e6f528 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -37,6 +37,9 @@ #include "xf_event.h" #include "xf_input.h" +#include +#define TAG CLIENT_TAG("x11") + #ifdef WITH_XI #define MAX_CONTACTS 2 @@ -113,7 +116,7 @@ int xf_input_init(xfContext* xfc, Window window) if (!XQueryExtension(xfc->display, "XInputExtension", &opcode, &event, &error)) { - printf("XInput extension not available.\n"); + WLog_WARN(TAG, "XInput extension not available."); return -1; } @@ -123,7 +126,7 @@ int xf_input_init(xfContext* xfc, Window window) if (major * 1000 + minor < 2002) { - printf("Server does not support XI 2.2\n"); + WLog_WARN(TAG, "Server does not support XI 2.2"); return -1; } @@ -156,9 +159,9 @@ int xf_input_init(xfContext* xfc, Window window) if (xfc->settings->MultiTouchInput) { - printf("%s (%d) \"%s\" id: %d\n", - xf_input_get_class_string(class->type), - class->type, dev->name, dev->deviceid); + WLog_INFO(TAG, "%s (%d) \"%s\" id: %d", + xf_input_get_class_string(class->type), + class->type, dev->name, dev->deviceid); } evmasks[nmasks].mask = masks[nmasks]; @@ -171,9 +174,9 @@ int xf_input_init(xfContext* xfc, Window window) { if (xfc->settings->MultiTouchInput) { - printf("%s %s touch device (id: %d, mode: %d), supporting %d touches.\n", - dev->name, (t->mode == XIDirectTouch) ? "direct" : "dependent", - dev->deviceid, t->mode, t->num_touches); + WLog_INFO(TAG, "%s %s touch device (id: %d, mode: %d), supporting %d touches.", + dev->name, (t->mode == XIDirectTouch) ? "direct" : "dependent", + dev->deviceid, t->mode, t->num_touches); } XISetMask(masks[nmasks], XI_TouchBegin); @@ -186,9 +189,9 @@ int xf_input_init(xfContext* xfc, Window window) { if (!touch && (class->type == XIButtonClass) && strcmp(dev->name, "Virtual core pointer")) { - printf("%s button device (id: %d, mode: %d)\n", - dev->name, - dev->deviceid, t->mode); + WLog_INFO(TAG, "%s button device (id: %d, mode: %d)", + dev->name, + dev->deviceid, t->mode); XISetMask(masks[nmasks], XI_ButtonPress); XISetMask(masks[nmasks], XI_ButtonRelease); XISetMask(masks[nmasks], XI_Motion); @@ -494,7 +497,7 @@ void xf_input_touch_end(xfContext* xfc, XIDeviceEvent* event) contacts[i].count = 0; active_contacts--; - break;printf("TouchBegin\n"); + break; } } } @@ -528,7 +531,7 @@ int xf_input_handle_event_local(xfContext* xfc, XEvent* event) break; default: - printf("unhandled xi type= %d\n", cookie->evtype); + WLog_ERR(TAG, "unhandled xi type= %d", cookie->evtype); break; } } @@ -619,17 +622,17 @@ int xf_input_touch_remote(xfContext* xfc, XIDeviceEvent* event, int evtype) if (evtype == XI_TouchBegin) { - printf("TouchBegin: %d\n", touchId); + WLog_DBG(TAG, "TouchBegin: %d", touchId); contactId = rdpei->TouchBegin(rdpei, touchId, x, y); } else if (evtype == XI_TouchUpdate) { - DEBUG_MSG("TouchUpdate: %d\n", touchId); + WLog_DBG(TAG, "TouchUpdate: %d", touchId); contactId = rdpei->TouchUpdate(rdpei, touchId, x, y); } else if (evtype == XI_TouchEnd) { - printf("TouchEnd: %d\n", touchId); + WLog_DBG(TAG, "TouchEnd: %d", touchId); contactId = rdpei->TouchEnd(rdpei, touchId, x, y); } @@ -734,6 +737,6 @@ int xf_input_handle_event(xfContext* xfc, XEvent* event) return xf_input_handle_event_local(xfc, event); } #endif - + return 0; } diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c index 699cf7682..eeaaa253d 100644 --- a/client/X11/xf_keyboard.c +++ b/client/X11/xf_keyboard.c @@ -39,6 +39,9 @@ #include "xf_keyboard.h" +#include +#define TAG CLIENT_TAG("x11") + int xf_keyboard_action_script_init(xfContext* xfc) { int exitCode; @@ -191,7 +194,7 @@ void xf_keyboard_send_key(xfContext* xfc, BOOL down, BYTE keycode) if (rdp_scancode == RDP_SCANCODE_UNKNOWN) { - DEBUG_WARN( "Unknown key with X keycode 0x%02x\n", keycode); + WLog_ERR(TAG, "Unknown key with X keycode 0x%02x", keycode); } else if (rdp_scancode == RDP_SCANCODE_PAUSE && !xf_keyboard_key_pressed(xfc, XK_Control_L) && !xf_keyboard_key_pressed(xfc, XK_Control_R)) diff --git a/client/X11/xf_monitor.c b/client/X11/xf_monitor.c index e38918846..443a74088 100644 --- a/client/X11/xf_monitor.c +++ b/client/X11/xf_monitor.c @@ -29,6 +29,10 @@ #include +#include + +#define TAG CLIENT_TAG("x11") + #ifdef WITH_XINERAMA #include #endif @@ -55,10 +59,10 @@ int xf_list_monitors(xfContext* xfc) for (i = 0; i < nmonitors; i++) { - printf(" %s [%d] %dx%d\t+%d+%d\n", - (i == 0) ? "*" : " ", i, - screen[i].width, screen[i].height, - screen[i].x_org, screen[i].y_org); + WLog_DBG(TAG, " %s [%d] %dx%d\t+%d+%d", + (i == 0) ? "*" : " ", i, + screen[i].width, screen[i].height, + screen[i].x_org, screen[i].y_org); } XFree(screen); @@ -73,8 +77,7 @@ int xf_list_monitors(xfContext* xfc) display = XOpenDisplay(NULL); screen = ScreenOfDisplay(display, DefaultScreen(display)); - printf(" * [0] %dx%d\t+%d+%d\n", WidthOfScreen(screen), HeightOfScreen(screen), 0, 0); - + WLog_DBG(TAG, " * [0] %dx%d\t+%d+%d", WidthOfScreen(screen), HeightOfScreen(screen), 0, 0); XCloseDisplay(display); #endif diff --git a/client/X11/xf_rail.c b/client/X11/xf_rail.c index 95451278e..8e78c4a2f 100644 --- a/client/X11/xf_rail.c +++ b/client/X11/xf_rail.c @@ -26,6 +26,7 @@ #include #include + #include #include #include @@ -33,12 +34,12 @@ #include "xf_window.h" #include "xf_rail.h" -#define TAG "com.freerdp.client.X11" +#define TAG CLIENT_TAG("x11") #ifdef WITH_DEBUG_X11_LOCAL_MOVESIZE -#define DEBUG_X11_LMS(fmt, ...) DEBUG_CLASS(X11_LMS, fmt, ## __VA_ARGS__) +#define DEBUG_X11_LMS(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_X11_LMS(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_X11_LMS(fmt, ...) do { } while (0) #endif void xf_rail_enable_remoteapp_mode(xfContext* xfc) @@ -446,8 +447,8 @@ void xf_process_rail_exec_result_event(xfContext* xfc, rdpChannels* channels, wM if (exec_result->execResult != RAIL_EXEC_S_OK) { - DEBUG_WARN("RAIL exec error: execResult=%s NtError=0x%X\n", - error_code_names[exec_result->execResult], exec_result->rawResult); + WLog_ERR(TAG, "RAIL exec error: execResult=%s NtError=0x%X\n", + error_code_names[exec_result->execResult], exec_result->rawResult); xfc->disconnect = True; } else @@ -615,9 +616,9 @@ void xf_process_rail_appid_resp_event(xfContext* xfc, rdpChannels* channels, wMe { RAIL_GET_APPID_RESP_ORDER* appid_resp = (RAIL_GET_APPID_RESP_ORDER*) event->wParam; - DEBUG_WARN("Server Application ID Response PDU: windowId=0x%X " - "applicationId=(length=%d dump)\n", - appid_resp->windowId, 512); + WLog_ERR(TAG, "Server Application ID Response PDU: windowId=0x%X " + "applicationId=(length=%d dump)\n", + appid_resp->windowId, 512); winpr_HexDump(TAG, WLOG_ERROR, (BYTE*) &appid_resp->applicationId, 512); } @@ -625,8 +626,8 @@ void xf_process_rail_langbarinfo_event(xfContext* xfc, rdpChannels* channels, wM { RAIL_LANGBAR_INFO_ORDER* langbar = (RAIL_LANGBAR_INFO_ORDER*) event->wParam; - DEBUG_WARN("Language Bar Information PDU: languageBarStatus=0x%X\n", - langbar->languageBarStatus); + WLog_ERR(TAG, "Language Bar Information PDU: languageBarStatus=0x%X\n", + langbar->languageBarStatus); } void xf_process_rail_event(xfContext* xfc, rdpChannels* channels, wMessage* event) diff --git a/client/X11/xf_tsmf.c b/client/X11/xf_tsmf.c index 72acb48cb..62d322a8a 100644 --- a/client/X11/xf_tsmf.c +++ b/client/X11/xf_tsmf.c @@ -36,6 +36,7 @@ #include #include +#include #include #include "xf_tsmf.h" @@ -57,10 +58,11 @@ struct xf_xv_context UINT32* xv_pixfmts; }; +#define TAG CLIENT_TAG("x11") #ifdef WITH_DEBUG_XV -#define DEBUG_XV(fmt, ...) DEBUG_CLASS(XV, fmt, ## __VA_ARGS__) +#define DEBUG_XV(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_XV(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_XV(fmt, ...) do { } while (0) #endif void xf_tsmf_init(xfContext* xfc, long xv_port) @@ -140,7 +142,7 @@ void xf_tsmf_init(xfContext* xfc, long xv_port) XFree(attr); #ifdef WITH_DEBUG_XV - DEBUG_WARN( "xf_tsmf_init: pixel format "); + WLog_DBG(TAG, "xf_tsmf_init: pixel format "); #endif fo = XvListImageFormats(xfc->display, xv->xv_port, &ret); if (ret > 0) @@ -152,16 +154,13 @@ void xf_tsmf_init(xfContext* xfc, long xv_port) { xv->xv_pixfmts[i] = fo[i].id; #ifdef WITH_DEBUG_XV - DEBUG_WARN( "%c%c%c%c ", ((char*)(xv->xv_pixfmts + i))[0], ((char*)(xv->xv_pixfmts + i))[1], - ((char*)(xv->xv_pixfmts + i))[2], ((char*)(xv->xv_pixfmts + i))[3]); + WLog_DBG(TAG, "%c%c%c%c ", ((char*)(xv->xv_pixfmts + i))[0], ((char*)(xv->xv_pixfmts + i))[1], + ((char*)(xv->xv_pixfmts + i))[2], ((char*)(xv->xv_pixfmts + i))[3]); #endif } xv->xv_pixfmts[i] = 0; } XFree(fo); -#ifdef WITH_DEBUG_XV - DEBUG_WARN( "\n"); -#endif } void xf_tsmf_uninit(xfContext* xfc) @@ -228,6 +227,7 @@ static void xf_process_tsmf_video_frame_event(xfContext* xfc, RDP_VIDEO_FRAME_EV XSetFunction(xfc->display, xfc->gc, GXcopy); XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetForeground(xfc->display, xfc->gc, colorkey); + for (i = 0; i < vevent->num_visible_rects; i++) { XFillRectangle(xfc->display, xfc->window->handle, xfc->gc, diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index 51779905a..14751ac38 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -39,6 +39,7 @@ #include #include +#include #ifdef WITH_XEXT #include @@ -51,16 +52,18 @@ #include "xf_input.h" +#define TAG CLIENT_TAG("x11") + #ifdef WITH_DEBUG_X11 -#define DEBUG_X11(fmt, ...) DEBUG_CLASS(X11, fmt, ## __VA_ARGS__) +#define DEBUG_X11(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_X11(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_X11(fmt, ...) do { } while (0) #endif #ifdef WITH_DEBUG_X11_LOCAL_MOVESIZE -#define DEBUG_X11_LMS(fmt, ...) DEBUG_CLASS(X11_LMS, fmt, ## __VA_ARGS__) +#define DEBUG_X11_LMS(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_X11_LMS(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_X11_LMS(fmt, ...) do { } while (0) #endif #include "FreeRDP_Icon_256px.h" @@ -163,7 +166,7 @@ BOOL xf_GetWindowProperty(xfContext *xfc, Window window, Atom property, int leng return FALSE; if(actual_type == None) { - DEBUG_WARN("Property %lu does not exist", property); + WLog_ERR(TAG, "Property %lu does not exist", property); return FALSE; } return TRUE; @@ -258,24 +261,19 @@ void xf_SetWindowStyle(xfContext *xfc, xfWindow *window, UINT32 style, UINT32 ex * TOPMOST window that is not a toolwindow is treated like a regular window(ie. task manager). * Want to do this here, since the window may have type WS_POPUP */ + else if (ex_style & WS_EX_TOPMOST) + { + window_type = xfc->_NET_WM_WINDOW_TYPE_NORMAL; + } + else if (style & WS_POPUP) + { + /* this includes dialogs, popups, etc, that need to be full-fledged windows */ + window->is_transient = TRUE; + window_type = xfc->_NET_WM_WINDOW_TYPE_DIALOG; + xf_SetWindowUnlisted(xfc, window); + } else - if(ex_style & WS_EX_TOPMOST) - { - window_type = xfc->_NET_WM_WINDOW_TYPE_NORMAL; - } - else - if(style & WS_POPUP) - { - /* this includes dialogs, popups, etc, that need to be full-fledged windows */ - window->is_transient = TRUE; - window_type = xfc->_NET_WM_WINDOW_TYPE_DIALOG; - xf_SetWindowUnlisted(xfc, window); - } - else - { - window_type = xfc->_NET_WM_WINDOW_TYPE_NORMAL; - } - XChangeProperty(xfc->display, window->handle, xfc->_NET_WM_WINDOW_TYPE, + XChangeProperty(xfc->display, window->handle, xfc->_NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (BYTE *) &window_type, 1); } diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h index 349ae3bc5..efa24e6b9 100644 --- a/client/X11/xfreerdp.h +++ b/client/X11/xfreerdp.h @@ -113,6 +113,7 @@ struct xf_context HANDLE mutex; BOOL UseXThreads; BOOL cursorHidden; + BYTE palette[256 * 4]; HGDI_DC hdc; UINT32 bitmap_size; diff --git a/client/common/CMakeLists.txt b/client/common/CMakeLists.txt index 0a96bf541..5ac33ff2a 100644 --- a/client/common/CMakeLists.txt +++ b/client/common/CMakeLists.txt @@ -58,11 +58,7 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES}) -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-core) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 345e11cde..1646a2fff 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -32,12 +32,15 @@ #include #include -#include + #include #include #include "compatibility.h" +#include +#define TAG CLIENT_TAG("common.cmdline") + COMMAND_LINE_ARGUMENT_A args[] = { { "v", COMMAND_LINE_VALUE_REQUIRED, "[:port]", NULL, NULL, -1, NULL, "Server hostname" }, @@ -209,7 +212,7 @@ int freerdp_client_print_command_line_help(int argc, char** argv) if (arg->Format) { - length = (int) (strlen(arg->Name) + strlen(arg->Format) + 2); + length = (int)(strlen(arg->Name) + strlen(arg->Format) + 2); str = (char*) malloc(length + 1); sprintf_s(str, length + 1, "%s:%s", arg->Name, arg->Format); printf("%-20s", str); @@ -1087,6 +1090,9 @@ BOOL freerdp_client_detect_command_line(int argc, char** argv, DWORD* flags) *flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH; *flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE; + if (posix_cli_status <= COMMAND_LINE_STATUS_PRINT) + return compatibility; + if (windows_cli_count >= posix_cli_count) { *flags = COMMAND_LINE_SEPARATOR_COLON; @@ -1105,8 +1111,8 @@ BOOL freerdp_client_detect_command_line(int argc, char** argv, DWORD* flags) } } - //printf("windows: %d/%d posix: %d/%d compat: %d/%d\n", windows_cli_status, windows_cli_count, - // posix_cli_status, posix_cli_count, old_cli_status, old_cli_count); + WLog_DBG(TAG, "windows: %d/%d posix: %d/%d compat: %d/%d", windows_cli_status, windows_cli_count, + posix_cli_status, posix_cli_count, old_cli_status, old_cli_count); return compatibility; } @@ -1182,7 +1188,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings, if (compatibility) { - DEBUG_WARN( "WARNING: Using deprecated command-line interface!\n"); + WLog_WARN(TAG, "Using deprecated command-line interface!"); return freerdp_client_parse_old_command_line_arguments(argc, argv, settings); } else @@ -1374,7 +1380,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings, if (!id) { - DEBUG_WARN( "Could not identify keyboard layout: %s\n", arg->Value); + WLog_ERR(TAG, "Could not identify keyboard layout: %s", arg->Value); } } @@ -1733,7 +1739,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings, } else { - DEBUG_WARN( "unknown protocol security: %s\n", arg->Value); + WLog_ERR(TAG, "unknown protocol security: %s", arg->Value); } } CommandLineSwitchCase(arg, "sec-rdp") @@ -1879,8 +1885,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings, } else { - DEBUG_WARN( "reconnect-cookie: invalid base64 '%s'\n", - arg->Value); + WLog_ERR(TAG, "reconnect-cookie: invalid base64 '%s'", arg->Value); } } CommandLineSwitchCase(arg, "print-reconnect-cookie") @@ -1944,7 +1949,7 @@ int freerdp_client_load_static_channel_addin(rdpChannels* channels, rdpSettings* { if (freerdp_channels_client_load(channels, settings, entry, data) == 0) { - DEBUG_WARN( "loading channel %s\n", name); + WLog_INFO(TAG, "loading channel %s", name); return 0; } } diff --git a/client/common/compatibility.c b/client/common/compatibility.c index 1c68c3d7f..3a7d0dab9 100644 --- a/client/common/compatibility.c +++ b/client/common/compatibility.c @@ -27,13 +27,16 @@ #include #include #include -#include + #include #include +#include #include "compatibility.h" +#define TAG CLIENT_TAG("common.compatibility") + COMMAND_LINE_ARGUMENT_A old_args[] = { { "0", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "connect to console session" }, @@ -122,7 +125,7 @@ int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV* args) if (strcmp(args->argv[0], "cliprdr") == 0) { settings->RedirectClipboard = TRUE; - DEBUG_WARN( "--plugin cliprdr -> +clipboard\n"); + WLog_WARN(TAG, "--plugin cliprdr -> +clipboard"); } else if (strcmp(args->argv[0], "rdpdr") == 0) { @@ -438,37 +441,37 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe CommandLineSwitchCase(arg, "0") { settings->ConsoleSession = TRUE; - DEBUG_WARN( "-0 -> /admin\n"); + WLog_WARN(TAG, "-0 -> /admin"); } CommandLineSwitchCase(arg, "a") { settings->ColorDepth = atoi(arg->Value); - DEBUG_WARN( "-a %s -> /bpp:%s\n", arg->Value, arg->Value); + WLog_WARN(TAG, "-a %s -> /bpp:%s", arg->Value, arg->Value); } CommandLineSwitchCase(arg, "c") { settings->ShellWorkingDirectory = _strdup(arg->Value); - DEBUG_WARN( "-c %s -> /shell-dir:%s\n", arg->Value, arg->Value); + WLog_WARN(TAG, "-c %s -> /shell-dir:%s", arg->Value, arg->Value); } CommandLineSwitchCase(arg, "D") { settings->Decorations = FALSE; - DEBUG_WARN( "-D -> -decorations\n"); + WLog_WARN(TAG, "-D -> -decorations"); } CommandLineSwitchCase(arg, "T") { settings->WindowTitle = _strdup(arg->Value); - DEBUG_WARN( "-T %s -> /title:%s\n", arg->Value, arg->Value); + WLog_WARN(TAG, "-T %s -> /title:%s", arg->Value, arg->Value); } CommandLineSwitchCase(arg, "d") { settings->Domain = _strdup(arg->Value); - DEBUG_WARN( "-d %s -> /d:%s\n", arg->Value, arg->Value); + WLog_WARN(TAG, "-d %s -> /d:%s", arg->Value, arg->Value); } CommandLineSwitchCase(arg, "f") { settings->Fullscreen = TRUE; - DEBUG_WARN( "-f -> /f\n"); + WLog_WARN(TAG, "-f -> /f"); } CommandLineSwitchCase(arg, "g") { @@ -484,51 +487,50 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe } free(str); - - DEBUG_WARN( "-g %s -> /size:%s or /w:%d /h:%d\n", arg->Value, arg->Value, - settings->DesktopWidth, settings->DesktopHeight); + WLog_WARN(TAG, "-g %s -> /size:%s or /w:%d /h:%d", arg->Value, arg->Value, + settings->DesktopWidth, settings->DesktopHeight); } CommandLineSwitchCase(arg, "k") { sscanf(arg->Value, "%X", &(settings->KeyboardLayout)); - DEBUG_WARN( "-k %s -> /kbd:%s\n", arg->Value, arg->Value); + WLog_WARN(TAG, "-k %s -> /kbd:%s", arg->Value, arg->Value); } CommandLineSwitchCase(arg, "K") { settings->GrabKeyboard = FALSE; - DEBUG_WARN( "-K -> -grab-keyboard\n"); + WLog_WARN(TAG, "-K -> -grab-keyboard"); } CommandLineSwitchCase(arg, "n") { settings->ClientHostname = _strdup(arg->Value); - DEBUG_WARN( "-n -> /client-hostname:%s\n", arg->Value); + WLog_WARN(TAG, "-n -> /client-hostname:%s", arg->Value); } CommandLineSwitchCase(arg, "o") { settings->RemoteConsoleAudio = TRUE; - DEBUG_WARN( "-o -> /audio-mode:1\n"); + WLog_WARN(TAG, "-o -> /audio-mode:1"); } CommandLineSwitchCase(arg, "p") { settings->Password = _strdup(arg->Value); - DEBUG_WARN( "-p ****** -> /p:******\n"); + WLog_WARN(TAG, "-p ****** -> /p:******"); /* Hide the value from 'ps'. */ FillMemory(arg->Value, strlen(arg->Value), '*'); } CommandLineSwitchCase(arg, "s") { settings->AlternateShell = _strdup(arg->Value); - DEBUG_WARN( "-s %s -> /shell:%s\n", arg->Value, arg->Value); + WLog_WARN(TAG, "-s %s -> /shell:%s", arg->Value, arg->Value); } CommandLineSwitchCase(arg, "t") { settings->ServerPort = atoi(arg->Value); - DEBUG_WARN( "-t %s -> /port:%s\n", arg->Value, arg->Value); + WLog_WARN(TAG, "-t %s -> /port:%s", arg->Value, arg->Value); } CommandLineSwitchCase(arg, "u") { settings->Username = _strdup(arg->Value); - DEBUG_WARN( "-u %s -> /u:%s\n", arg->Value, arg->Value); + WLog_WARN(TAG, "-u %s -> /u:%s", arg->Value, arg->Value); } CommandLineSwitchCase(arg, "x") { @@ -556,31 +558,31 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe freerdp_performance_flags_split(settings); } - DEBUG_WARN( "-x %s -> /network:", arg->Value); + WLog_WARN(TAG, "-x %s -> /network:", arg->Value); if (type == CONNECTION_TYPE_MODEM) - DEBUG_WARN( "modem"); + WLog_WARN(TAG, "modem"); else if (CONNECTION_TYPE_BROADBAND_HIGH) - DEBUG_WARN( "broadband"); + WLog_WARN(TAG, "broadband"); else if (CONNECTION_TYPE_LAN) - DEBUG_WARN( "lan"); + WLog_WARN(TAG, "lan"); - DEBUG_WARN( "\n"); + WLog_WARN(TAG, ""); } CommandLineSwitchCase(arg, "X") { settings->ParentWindowId = strtol(arg->Value, NULL, 0); - DEBUG_WARN( "-X %s -> /parent-window:%s\n", arg->Value, arg->Value); + WLog_WARN(TAG, "-X %s -> /parent-window:%s", arg->Value, arg->Value); } CommandLineSwitchCase(arg, "z") { settings->CompressionEnabled = TRUE; - DEBUG_WARN( "-z -> /compression\n"); + WLog_WARN(TAG, "-z -> /compression"); } CommandLineSwitchCase(arg, "app") { settings->RemoteApplicationMode = TRUE; - DEBUG_WARN( "--app -> /app: + program name or alias\n"); + WLog_WARN(TAG, "--app -> /app: + program name or alias"); } CommandLineSwitchCase(arg, "ext") { @@ -589,7 +591,7 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe CommandLineSwitchCase(arg, "no-auth") { settings->Authentication = FALSE; - DEBUG_WARN( "--no-auth -> -authentication\n"); + WLog_WARN(TAG, "--no-auth -> -authentication"); } CommandLineSwitchCase(arg, "authonly") { @@ -603,12 +605,12 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe { settings->FastPathInput = FALSE; settings->FastPathOutput = FALSE; - DEBUG_WARN( "--no-fastpath -> -fast-path\n"); + WLog_WARN(TAG, "--no-fastpath -> -fast-path"); } CommandLineSwitchCase(arg, "no-motion") { settings->MouseMotion = FALSE; - DEBUG_WARN( "--no-motion -> -mouse-motion\n"); + WLog_WARN(TAG, "--no-motion -> -mouse-motion"); } CommandLineSwitchCase(arg, "gdi") { @@ -617,26 +619,26 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe else if (strcmp(arg->Value, "hw") == 0) settings->SoftwareGdi = FALSE; - DEBUG_WARN( "--gdi %s -> /gdi:%s\n", arg->Value, arg->Value); + WLog_WARN(TAG, "--gdi %s -> /gdi:%s", arg->Value, arg->Value); } CommandLineSwitchCase(arg, "no-osb") { settings->OffscreenSupportLevel = FALSE; - DEBUG_WARN( "--no-osb -> -offscreen-cache\n"); + WLog_WARN(TAG, "--no-osb -> -offscreen-cache"); } CommandLineSwitchCase(arg, "no-bmp-cache") { settings->BitmapCacheEnabled = FALSE; - DEBUG_WARN( "--no-bmp-cache -> -bitmap-cache\n"); + WLog_WARN(TAG, "--no-bmp-cache -> -bitmap-cache"); } CommandLineSwitchCase(arg, "plugin") { - DEBUG_WARN( "--plugin -> /a, /vc, /dvc and channel-specific options\n"); + WLog_WARN(TAG, "--plugin -> /a, /vc, /dvc and channel-specific options"); } CommandLineSwitchCase(arg, "rfx") { settings->RemoteFxCodec = TRUE; - DEBUG_WARN( "--rfx -> /rfx\n"); + WLog_WARN(TAG, "--rfx -> /rfx"); } CommandLineSwitchCase(arg, "rfx-mode") { @@ -645,37 +647,37 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe else if (arg->Value[0] == 'i') settings->RemoteFxCodecMode = 0x02; - DEBUG_WARN( "--rfx-mode -> /rfx-mode:%s\n", settings->RemoteFxCodecMode ? "image" : "video"); + WLog_WARN(TAG, "--rfx-mode -> /rfx-mode:%s", settings->RemoteFxCodecMode ? "image" : "video"); } CommandLineSwitchCase(arg, "nsc") { settings->NSCodec = TRUE; - DEBUG_WARN( "--nsc -> /nsc\n"); + WLog_WARN(TAG, "--nsc -> /nsc"); } CommandLineSwitchCase(arg, "disable-wallpaper") { settings->DisableWallpaper = TRUE; - DEBUG_WARN( "--disable-wallpaper -> -wallpaper\n"); + WLog_WARN(TAG, "--disable-wallpaper -> -wallpaper"); } CommandLineSwitchCase(arg, "composition") { settings->AllowDesktopComposition = TRUE; - DEBUG_WARN( "--composition -> +composition\n"); + WLog_WARN(TAG, "--composition -> +composition"); } CommandLineSwitchCase(arg, "disable-full-window-drag") { settings->DisableFullWindowDrag = TRUE; - DEBUG_WARN( "--disable-full-window-drag -> -window-drag\n"); + WLog_WARN(TAG, "--disable-full-window-drag -> -window-drag"); } CommandLineSwitchCase(arg, "disable-menu-animations") { settings->DisableMenuAnims = TRUE; - DEBUG_WARN( "--disable-menu-animations -> -menu-anims\n"); + WLog_WARN(TAG, "--disable-menu-animations -> -menu-anims"); } CommandLineSwitchCase(arg, "disable-theming") { settings->DisableThemes = TRUE; - DEBUG_WARN( "--disable-theming -> -themes\n"); + WLog_WARN(TAG, "--disable-theming -> -themes"); } CommandLineSwitchCase(arg, "ntlm") { @@ -684,7 +686,7 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe CommandLineSwitchCase(arg, "ignore-certificate") { settings->IgnoreCertificate = TRUE; - DEBUG_WARN( "--ignore-certificate -> /cert-ignore\n"); + WLog_WARN(TAG, "--ignore-certificate -> /cert-ignore"); } CommandLineSwitchCase(arg, "sec") { @@ -710,22 +712,22 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe settings->NlaSecurity = TRUE; } - DEBUG_WARN( "--sec %s -> /sec:%s\n", arg->Value, arg->Value); + WLog_WARN(TAG, "--sec %s -> /sec:%s", arg->Value, arg->Value); } CommandLineSwitchCase(arg, "no-rdp") { settings->RdpSecurity = FALSE; - DEBUG_WARN( "--no-rdp -> -sec-rdp\n"); + WLog_WARN(TAG, "--no-rdp -> -sec-rdp"); } CommandLineSwitchCase(arg, "no-tls") { settings->TlsSecurity = FALSE; - DEBUG_WARN( "--no-tls -> -sec-tls\n"); + WLog_WARN(TAG, "--no-tls -> -sec-tls"); } CommandLineSwitchCase(arg, "no-nla") { settings->NlaSecurity = FALSE; - DEBUG_WARN( "--no-nla -> -sec-nla\n"); + WLog_WARN(TAG, "--no-nla -> -sec-nla"); } CommandLineSwitchCase(arg, "secure-checksum") { @@ -740,12 +742,11 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL); - DEBUG_WARN( "%s -> /v:%s", settings->ServerHostname, settings->ServerHostname); + WLog_WARN(TAG, "%s -> /v:%s", settings->ServerHostname, settings->ServerHostname); if (settings->ServerPort != 3389) - DEBUG_WARN( " /port:%d", settings->ServerPort); - - DEBUG_WARN( "\n"); + WLog_WARN(TAG, " /port:%d", settings->ServerPort); + WLog_WARN(TAG, ""); return 1; } diff --git a/client/common/file.c b/client/common/file.c index 6a646d0d9..911593684 100644 --- a/client/common/file.c +++ b/client/common/file.c @@ -21,7 +21,7 @@ #include "config.h" #endif -#include + #include #include @@ -42,6 +42,8 @@ #endif #include +#include +#define TAG CLIENT_TAG("common") //#define DEBUG_CLIENT_FILE 1 @@ -55,7 +57,7 @@ BOOL freerdp_client_rdp_file_set_integer(rdpFile* file, const char* name, int va BOOL bStandard = TRUE; #ifdef DEBUG_CLIENT_FILE - DEBUG_WARN( "%s:i:%d\n", name, value); + WLog_DBG(TAG, "%s:i:%d", name, value); #endif if (_stricmp(name, "use multimon") == 0) @@ -241,7 +243,7 @@ BOOL freerdp_client_rdp_file_set_string(rdpFile* file, const char* name, const c BOOL bStandard = TRUE; #ifdef DEBUG_CLIENT_FILE - DEBUG_WARN( "%s:s:%s\n", name, value); + WLog_DBG(TAG, "%s:s:%s", name, value); #endif if (_stricmp(name, "username") == 0) @@ -666,7 +668,7 @@ BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL u if (length < 0) { - DEBUG_WARN( "freerdp_client_write_rdp_file: error determining buffer size.\n"); + WLog_ERR(TAG, "freerdp_client_write_rdp_file: error determining buffer size."); return FALSE; } @@ -674,7 +676,7 @@ BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL u if (freerdp_client_write_rdp_file_buffer(file, buffer, length + 1) != length) { - DEBUG_WARN( "freerdp_client_write_rdp_file: error writing to output buffer\n"); + WLog_ERR(TAG, "freerdp_client_write_rdp_file: error writing to output buffer"); free(buffer); return FALSE; } diff --git a/client/iOS/CMakeLists.txt b/client/iOS/CMakeLists.txt index 52bbc1739..ed14fecd2 100644 --- a/client/iOS/CMakeLists.txt +++ b/client/iOS/CMakeLists.txt @@ -125,11 +125,7 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${EXTRA_LIBS}) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client) -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-core freerdp-gdi freerdp-locale freerdp-primitives freerdp-cache freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/cmake/CheckCmakeCompat.cmake b/cmake/CheckCmakeCompat.cmake index 19710b2ad..6b9f9cc12 100644 --- a/cmake/CheckCmakeCompat.cmake +++ b/cmake/CheckCmakeCompat.cmake @@ -28,13 +28,6 @@ enable_cmake_compat(2.8.6) enable_cmake_compat(2.8.3) enable_cmake_compat(2.8.2) -# If MONOLITHIC_BUILD is used with cmake < 2.8.8 build fails -if (MONOLITHIC_BUILD) - if(${CMAKE_VERSION} VERSION_LESS 2.8.8) - message(FATAL_ERROR "CMAKE version >= 2.8.8 required for MONOLITHIC_BUILD") - endif() -endif(MONOLITHIC_BUILD) - # GetGitRevisionDescription requires FindGit which was added in version 2.8.2 # build won't fail but GIT_REVISION is set to n/a if(${CMAKE_VERSION} VERSION_LESS 2.8.2) diff --git a/cmake/ConfigOptions.cmake b/cmake/ConfigOptions.cmake index 2fcec230f..17af6d9cd 100644 --- a/cmake/ConfigOptions.cmake +++ b/cmake/ConfigOptions.cmake @@ -59,14 +59,6 @@ option(WITH_SMARTCARD_INSPECT "Enable SmartCard API Inspector" OFF) option(BUILD_TESTING "Build unit tests" OFF) option(WITH_SAMPLE "Build sample code" OFF) -if(${CMAKE_VERSION} VERSION_GREATER 2.8.8) - if(ANDROID) - option(MONOLITHIC_BUILD "Use monolithic build" ON) - else() - option(MONOLITHIC_BUILD "Use monolithic build" OFF) - endif() -endif() - option(WITH_CLIENT "Build client binaries" ON) option(WITH_SERVER "Build server binaries" OFF) diff --git a/include/freerdp/channels/log.h b/include/freerdp/channels/log.h index b301af658..51a653e70 100644 --- a/include/freerdp/channels/log.h +++ b/include/freerdp/channels/log.h @@ -25,19 +25,4 @@ #define CHANNELS_TAG(tag) FREERDP_TAG("channels.") tag -/* NOTE: Do not use these defines, they will be removed soon! */ -#define CLOG_NULL(fmt, ...) do { } while (0) -#define CLOG_CLASS(_dbg_class, fmt, ...) WLog_LVL(CHANNELS_TAG("legacy." #_dbg_class), \ - WLOG_ERROR, fmt, ## __VA_ARGS__) -#define CLOG_DBG(fmt, ...) WLog_LVL(CHANNELS_TAG("legacy"), \ - WLOG_DEBUG, fmt, ## __VA_ARGS__) -#define CLOG_INFO(fmt, ...) WLog_LVL(CHANNELS_TAG("legacy"), \ - WLOG_INFO, fmt, ## __VA_ARGS__) -#define CLOG_WARN(fmt, ...) WLog_LVL(CHANNELS_TAG("legacy"), \ - WLOG_WARN, fmt, ## __VA_ARGS__) -#define CLOG_ERR(fmt, ...) WLog_LVL(CHANNELS_TAG("legacy"), \ - WLOG_ERROR, fmt, ## __VA_ARGS__) -#define CLOG_FATAL(fmt, ...) WLog_LVL(CHANNELS_TAG("legacy"), \ - WLOG_FATAL, fmt, ## __VA_ARGS__) - #endif /* FREERDP_UTILS_DEBUG_H */ diff --git a/include/freerdp/codec/color.h b/include/freerdp/codec/color.h index c8b4397eb..60590e579 100644 --- a/include/freerdp/codec/color.h +++ b/include/freerdp/codec/color.h @@ -401,11 +401,8 @@ extern "C" { /* Supported Internal Buffer Formats */ #define CLRBUF_16BPP 8 -#define CLRBUF_24BPP 16 #define CLRBUF_32BPP 32 -#define CLRBUF_ABGR 64 /* ABGR order (as opposed to ARGB) */ - struct _CLRCONV { int alpha; @@ -447,13 +444,24 @@ FREERDP_API UINT32 freerdp_color_convert_rgb_bgr(UINT32 srcColor, int srcBpp, in FREERDP_API UINT32 freerdp_color_convert_bgr_rgb(UINT32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv); FREERDP_API UINT32 freerdp_color_convert_var_rgb(UINT32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv); FREERDP_API UINT32 freerdp_color_convert_var_bgr(UINT32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv); -FREERDP_API UINT32 freerdp_convert_gdi_order_color(UINT32 color, int bpp, UINT32 format); +FREERDP_API UINT32 freerdp_convert_gdi_order_color(UINT32 color, int bpp, UINT32 format, BYTE* palette); FREERDP_API HCLRCONV freerdp_clrconv_new(UINT32 flags); FREERDP_API void freerdp_clrconv_free(HCLRCONV clrconv); +FREERDP_API int freerdp_image8_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, + int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette); +FREERDP_API int freerdp_image15_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, + int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette); +FREERDP_API int freerdp_image16_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, + int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette); +FREERDP_API int freerdp_image24_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, + int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette); +FREERDP_API int freerdp_image32_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, + int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette); + FREERDP_API int freerdp_image_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, - int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc); + int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette); FREERDP_API int freerdp_image_move(BYTE* pData, DWORD Format, int nStep, int nXDst, int nYDst, int nWidth, int nHeight, int nXSrc, int nYSrc); FREERDP_API int freerdp_image_fill(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, diff --git a/include/freerdp/codec/interleaved.h b/include/freerdp/codec/interleaved.h index dfc0afb52..926610f9e 100644 --- a/include/freerdp/codec/interleaved.h +++ b/include/freerdp/codec/interleaved.h @@ -37,7 +37,7 @@ struct _BITMAP_INTERLEAVED_CONTEXT }; FREERDP_API int interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pSrcData, UINT32 SrcSize, int bpp, - BYTE** ppDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, int nWidth, int nHeight); + BYTE** ppDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, int nWidth, int nHeight, BYTE* palette); FREERDP_API int bitmap_interleaved_context_reset(BITMAP_INTERLEAVED_CONTEXT* interleaved); diff --git a/include/freerdp/gdi/gdi.h b/include/freerdp/gdi/gdi.h index 5333d4c41..6f1b60fb8 100644 --- a/include/freerdp/gdi/gdi.h +++ b/include/freerdp/gdi/gdi.h @@ -21,9 +21,9 @@ #define FREERDP_GDI_H #include +#include #include #include -#include #include #include @@ -284,7 +284,7 @@ struct rdp_gdi int bytesPerPixel; rdpCodecs* codecs; - BOOL abgr; + BOOL invert; HGDI_DC hdc; UINT32 format; HCLRCONV clrconv; @@ -294,6 +294,7 @@ struct rdp_gdi BYTE* bitmap_buffer; BYTE* primary_buffer; GDI_COLOR textColor; + BYTE palette[256 * 4]; gdiBitmap* tile; gdiBitmap* image; @@ -322,10 +323,11 @@ FREERDP_API void gdi_free(freerdp* instance); } #endif +#define GDI_TAG FREERDP_TAG("gdi") #ifdef WITH_DEBUG_GDI -#define DEBUG_GDI(fmt, ...) DEBUG_CLASS(GDI, fmt, ## __VA_ARGS__) +#define DEBUG_GDI(fmt, ...) WLog_DBG(GDI_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_GDI(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_GDI(fmt, ...) #endif #endif /* FREERDP_GDI_H */ diff --git a/include/freerdp/utils/debug.h b/include/freerdp/utils/debug.h deleted file mode 100644 index 2f2866721..000000000 --- a/include/freerdp/utils/debug.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * Debug Utils - * - * Copyright 2011 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FREERDP_UTILS_DEBUG_H -#define FREERDP_UTILS_DEBUG_H - -#include - -#define DEBUG_PRINT(level, file, fkt, line, dbg_str, fmt, ...) \ - do { \ - wLog *log = WLog_Get("com.freerdp.legacy"); \ - wLogMessage msg; \ - \ - msg.Type = WLOG_MESSAGE_TEXT; \ - msg.Level = level; \ - msg.FormatString = fmt; \ - msg.LineNumber = line; \ - msg.FileName = file; \ - msg.FunctionName = fkt; \ - WLog_PrintMessage(log, &msg, ##__VA_ARGS__); \ - } while (0 ) - -#define DEBUG_NULL(fmt, ...) do { } while (0) -#define DEBUG_CLASS(_dbg_class, fmt, ...) DEBUG_PRINT(WLOG_ERROR, __FILE__, \ - __FUNCTION__, __LINE__, #_dbg_class, fmt, ## __VA_ARGS__) -#define DEBUG_MSG(fmt, ...) DEBUG_PRINT(WLOG_DEBUG, __FILE__, __FUNCTION__, \ - __LINE__, "freerdp", fmt, ## __VA_ARGS__) -#define DEBUG_WARN(fmt, ...) DEBUG_PRINT(WLOG_ERROR, __FILE__, __FUNCTION__, \ - __LINE__, "freerdp", fmt, ## __VA_ARGS__) - -#endif /* FREERDP_UTILS_DEBUG_H */ diff --git a/include/freerdp/utils/svc_plugin.h b/include/freerdp/utils/svc_plugin.h index 82d55225a..61bd981e2 100644 --- a/include/freerdp/utils/svc_plugin.h +++ b/include/freerdp/utils/svc_plugin.h @@ -34,7 +34,7 @@ #include #include -#include +#include #include typedef struct rdp_svc_plugin rdpSvcPlugin; @@ -72,10 +72,11 @@ FREERDP_API int svc_plugin_send_event(rdpSvcPlugin* plugin, wMessage* event); } #endif +#define SVC_TAG FREERDP_TAG("svc") #ifdef WITH_DEBUG_SVC -#define DEBUG_SVC(fmt, ...) DEBUG_CLASS(SVC, fmt, ## __VA_ARGS__) +#define DEBUG_SVC(fmt, ...) WLog_DBG(SVC_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_SVC(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_SVC(fmt, ...) #endif #endif /* FREERDP_UTILS_SVC_PLUGIN_H */ diff --git a/libfreerdp/CMakeLists.txt b/libfreerdp/CMakeLists.txt index c11458f52..54bc042e1 100644 --- a/libfreerdp/CMakeLists.txt +++ b/libfreerdp/CMakeLists.txt @@ -18,55 +18,272 @@ set(MODULE_NAME "freerdp") set(MODULE_PREFIX "FREERDP") -if(MONOLITHIC_BUILD) - set(CMAKE_POSITION_INDEPENDENT_CODE ON) -endif() - # Create imported targets for Intel IPP libraries if(IPP_FOUND) foreach(ipp_lib ${IPP_LIBRARIES}) - add_library("${ipp_lib}_imported" STATIC IMPORTED) + add_library("${ipp_lib}_imported" STATIC IMPORTED) set_property(TARGET "${ipp_lib}_imported" PROPERTY IMPORTED_LOCATION "${IPP_LIBRARY_DIRS}/${ipp_lib}") endforeach() endif() +set(LIBFREERDP_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(LIBFREERDP_SRCS "") +set(LIBFREERDP_LIBS "") +set(LIBFREERDP_INCLUDES "") +set(LIBFREERDP_DEFINITIONS "") + +macro (freerdp_module_add) + file (RELATIVE_PATH _relPath "${LIBFREERDP_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") + foreach (_src ${ARGN}) + if (_relPath) + list (APPEND LIBFREERDP_SRCS "${_relPath}/${_src}") + else() + list (APPEND LIBFREERDP_SRCS "${_src}") + endif() + endforeach() + if (_relPath) + set (LIBFREERDP_SRCS ${LIBFREERDP_SRCS} PARENT_SCOPE) + endif() +endmacro() + +macro (freerdp_include_directory_add) + file (RELATIVE_PATH _relPath "${LIBFREERDP_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") + foreach (_inc ${ARGN}) + if (IS_ABSOLUTE ${_inc}) + list (APPEND LIBFREERDP_INCLUDES "${_inc}") + else() + if (_relPath) + list (APPEND LIBFREERDP_INCLUDES "${_relPath}/${_inc}") + else() + list (APPEND LIBFREERDP_INCLUDES "${_inc}") + endif() + endif() + endforeach() + if (_relPath) + set (LIBFREERDP_INCLUDES ${LIBFREERDP_INCLUDES} PARENT_SCOPE) + endif() +endmacro() + +macro (freerdp_library_add) + foreach (_lib ${ARGN}) + list (APPEND LIBFREERDP_LIBS "${_lib}") + endforeach() + set (LIBFREERDP_LIBS ${LIBFREERDP_LIBS} PARENT_SCOPE) +endmacro() + +macro (freerdp_definition_add) + foreach (_define ${ARGN}) + list (APPEND LIBFREERDP_DEFINITIONS "${_define}") + endforeach() + set (LIBFREERDP_DEFINITIONS ${LIBFREERDP_DEFINITIONS} PARENT_SCOPE) +endmacro() + set(${MODULE_PREFIX}_SUBMODULES utils common gdi rail cache - codec crypto locale - primitives core) foreach(${MODULE_PREFIX}_SUBMODULE ${${MODULE_PREFIX}_SUBMODULES}) add_subdirectory(${${MODULE_PREFIX}_SUBMODULE}) endforeach() -if(MONOLITHIC_BUILD) - foreach(${MODULE_PREFIX}_SUBMODULE ${${MODULE_PREFIX}_SUBMODULES}) - set(${MODULE_PREFIX}_OBJECTS ${${MODULE_PREFIX}_OBJECTS} "$") +## cmake source properties are only seen by targets in the same CMakeLists.txt +## therefore primitives and codecs need to be defined here + +# codec +set(CODEC_SRCS + codec/dsp.c + codec/color.c + codec/audio.c + codec/planar.c + codec/bitmap.c + codec/interleaved.c + codec/progressive.c + codec/rfx_bitstream.h + codec/rfx_constants.h + codec/rfx_decode.c + codec/rfx_decode.h + codec/rfx_differential.c + codec/rfx_differential.h + codec/rfx_dwt.c + codec/rfx_dwt.h + codec/rfx_encode.c + codec/rfx_encode.h + codec/rfx_quantization.c + codec/rfx_quantization.h + codec/rfx_rlgr.c + codec/rfx_rlgr.h + codec/rfx_types.h + codec/rfx.c + codec/region.c + codec/nsc.c + codec/nsc_encode.c + codec/nsc_encode.h + codec/nsc_types.h + codec/ncrush.c + codec/xcrush.c + codec/mppc.c + codec/zgfx.c + codec/clear.c + codec/jpeg.c + codec/h264.c) + +set(CODEC_SSE2_SRCS + codec/rfx_sse2.c + codec/rfx_sse2.h + codec/nsc_sse2.c + codec/nsc_sse2.h) + +set(CODEC_NEON_SRCS + codec/rfx_neon.c + codec/rfx_neon.h) + +if(WITH_SSE2) + set(CODEC_SRCS ${CODEC_SRCS} ${CODEC_SSE2_SRCS}) + + if(CMAKE_COMPILER_IS_GNUCC) + set_source_files_properties(${CODEC_SSE2_SRCS} PROPERTIES COMPILE_FLAGS "-msse2" ) + endif() + + if(MSVC) + set_source_files_properties(${CODEC_SSE2_SRCS} PROPERTIES COMPILE_FLAGS "/arch:SSE2" ) + endif() +endif() + +if(WITH_NEON) + set_source_files_properties(${CODEC_NEON_SRCS} PROPERTIES COMPILE_FLAGS "-mfpu=neon -mfloat-abi=${ARM_FP_ABI} -Wno-unused-variable" ) + set(CODEC_SRCS ${CODEC_SRCS} ${CODEC_NEON_SRCS}) +endif() + +if(WITH_JPEG) + freerdp_include_directory_add(${JPEG_INCLUDE_DIR}) + freerdp_library_add(${JPEG_LIBRARIES}) +endif() + +if(WITH_OPENH264) + freerdp_definition_add(-DWITH_OPENH264) + freerdp_include_directory_add(${OPENH264_INCLUDE_DIR}) + freerdp_library_add(${OPENH264_LIBRARIES}) +endif() + +if(WITH_LIBAVCODEC) + freerdp_definition_add(-DWITH_LIBAVCODEC) + find_library(LIBAVCODEC_LIB avcodec) + find_library(LIBAVUTIL_LIB avutil) + freerdp_library_add(${LIBAVCODEC_LIB} ${LIBAVUTIL_LIB}) +endif() + +freerdp_module_add(${CODEC_SRCS}) + +if(BUILD_TESTING) + add_subdirectory(codec/test) +endif() + +# /codec + +# primitives + +set(PRIMITIVES_SRCS + primitives/prim_16to32bpp.c + primitives/prim_add.c + primitives/prim_andor.c + primitives/prim_alphaComp.c + primitives/prim_colors.c + primitives/prim_copy.c + primitives/prim_set.c + primitives/prim_shift.c + primitives/prim_sign.c + primitives/prim_YUV.c + primitives/prim_YCoCg.c + primitives/primitives.c + primitives/prim_internal.h) + +set(PRIMITIVES_OPT_SRCS + primitives/prim_16to32bpp_opt.c + primitives/prim_add_opt.c + primitives/prim_andor_opt.c + primitives/prim_alphaComp_opt.c + primitives/prim_colors_opt.c + primitives/prim_set_opt.c + primitives/prim_shift_opt.c + primitives/prim_sign_opt.c + primitives/prim_YUV_opt.c + primitives/prim_YCoCg_opt.c) + +freerdp_definition_add(-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) + +### IPP Variable debugging +if(WITH_IPP) + if(CMAKE_COMPILER_IS_GNUCC) + foreach(INCLDIR ${IPP_INCLUDE_DIRS}) + set(OPTIMIZATION "${OPTIMIZATION} -I${INCLDIR}") + endforeach(INCLDIR) + endif() +endif() + +if(WITH_SSE2) + if(CMAKE_COMPILER_IS_GNUCC) + set(OPTIMIZATION "${OPTIMIZATION} -msse2 -mssse3 -O2 -Wdeclaration-after-statement") + endif() + + if(MSVC) + set(OPTIMIZATION "${OPTIMIZATION} /arch:SSE2") + endif() +elseif(WITH_NEON) + if(CMAKE_COMPILER_IS_GNUCC) + set(OPTIMIZATION "${OPTIMIZATION} -mfpu=neon -mfloat-abi=${ARM_FP_ABI}") + endif() + # TODO: Add MSVC equivalent +endif() + +if(DEFINED OPTIMIZATION) + set_source_files_properties(${PRIMITIVES_OPT_SRCS} PROPERTIES COMPILE_FLAGS ${OPTIMIZATION}) +endif() + + +# always compile with optimization +if(CMAKE_COMPILER_IS_GNUCC) + set_source_files_properties(${PRIMITIVES_SRCS} PROPERTIES COMPILE_FLAGS "-O2") +endif() + +set(PRIMITIVES_SRCS ${PRIMITIVES_SRCS} ${PRIMITIVES_OPT_SRCS}) + +freerdp_module_add(${PRIMITIVES_SRCS}) + +if(IPP_FOUND) + freerdp_include_directory_add(${IPP_INCLUDE_DIRS}) + foreach(ipp_lib ${IPP_LIBRARIES}) + freerdp_library_add("${ipp_lib}_imported") endforeach() +endif() - add_library(${MODULE_NAME} dummy.c - ${${MODULE_PREFIX}_OBJECTS}) +if(BUILD_TESTING AND NOT WIN32 AND NOT APPLE) + add_subdirectory(primitives/test) +endif() - set_target_properties(${MODULE_NAME} PROPERTIES LINKER_LANGUAGE C) - if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) - endif() - set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "lib") - list(APPEND FREERDP_LIBS ${PROFILER_LIBRARIES}) - list(REMOVE_DUPLICATES FREERDP_LIBS) +# /primitives - target_link_libraries(${MODULE_NAME} ${FREERDP_LIBS}) +list(REMOVE_DUPLICATES LIBFREERDP_DEFINITIONS) +list(REMOVE_DUPLICATES LIBFREERDP_LIBS) +list(REMOVE_DUPLICATES LIBFREERDP_INCLUDES) +include_directories(${LIBFREERDP_INCLUDES}) +add_library(${MODULE_NAME} ${LIBFREERDP_SRCS}) +add_definitions(${LIBFREERDP_DEFINITIONS}) - install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries EXPORT FreeRDPTargets) - - set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") -endif(MONOLITHIC_BUILD) +set_target_properties(${MODULE_NAME} PROPERTIES LINKER_LANGUAGE C) + +if (WITH_LIBRARY_VERSIONING) + set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) +endif() +set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "lib") + +target_link_libraries(${MODULE_NAME} ${LIBFREERDP_LIBS} winpr) +install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries EXPORT FreeRDPTargets) +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") diff --git a/libfreerdp/cache/CMakeLists.txt b/libfreerdp/cache/CMakeLists.txt index 5a52a048b..d1cf5b37e 100644 --- a/libfreerdp/cache/CMakeLists.txt +++ b/libfreerdp/cache/CMakeLists.txt @@ -18,7 +18,7 @@ set(MODULE_NAME "freerdp-cache") set(MODULE_PREFIX "FREERDP_CACHE") -set(${MODULE_PREFIX}_SRCS +freerdp_module_add( brush.c pointer.c bitmap.c @@ -28,26 +28,3 @@ set(${MODULE_PREFIX}_SRCS glyph.c cache.c) -add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT" - MONOLITHIC ${MONOLITHIC_BUILD} - SOURCES ${${MODULE_PREFIX}_SRCS} - EXPORT) - -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) -endif() -set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "lib") - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} INTERNAL - MODULE freerdp - MODULES freerdp-core freerdp-utils) - -if(MONOLITHIC_BUILD) - set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) -else() - target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) - install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets) -endif() - -set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") diff --git a/libfreerdp/cache/bitmap.c b/libfreerdp/cache/bitmap.c index 7b67b8dd5..6a62a3778 100644 --- a/libfreerdp/cache/bitmap.c +++ b/libfreerdp/cache/bitmap.c @@ -29,9 +29,11 @@ #include #include -#include +#include #include +#define TAG FREERDP_TAG("cache.bitmap") + void update_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt) { rdpBitmap* bitmap; @@ -41,9 +43,8 @@ void update_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt) bitmap = offscreen_cache_get(cache->offscreen, memblt->cacheIndex); else bitmap = bitmap_cache_get(cache->bitmap, (BYTE) memblt->cacheId, memblt->cacheIndex); - - if (!bitmap) - return; /* XP-SP2 servers sometimes ask for cached bitmaps they've never defined. */ + /* XP-SP2 servers sometimes ask for cached bitmaps they've never defined. */ + if (bitmap == NULL) return; memblt->bitmap = bitmap; IFCALL(cache->bitmap->MemBlt, context, memblt); @@ -61,8 +62,9 @@ void update_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt) else bitmap = bitmap_cache_get(cache->bitmap, (BYTE) mem3blt->cacheId, mem3blt->cacheIndex); + /* XP-SP2 servers sometimes ask for cached bitmaps they've never defined. */ if (!bitmap) - return; /* XP-SP2 servers sometimes ask for cached bitmaps they've never defined. */ + return; style = brush->style; @@ -96,7 +98,7 @@ void update_gdi_cache_bitmap(rdpContext* context, CACHE_BITMAP_ORDER* cacheBitma prevBitmap = bitmap_cache_get(cache->bitmap, cacheBitmap->cacheId, cacheBitmap->cacheIndex); - if (prevBitmap) + if (prevBitmap != NULL) Bitmap_Free(context, prevBitmap); bitmap_cache_put(cache->bitmap, cacheBitmap->cacheId, cacheBitmap->cacheIndex, bitmap); @@ -220,7 +222,7 @@ rdpBitmap* bitmap_cache_get(rdpBitmapCache* bitmapCache, UINT32 id, UINT32 index if (id > bitmapCache->maxCells) { - DEBUG_WARN( "get invalid bitmap cell id: %d\n", id); + WLog_ERR(TAG, "get invalid bitmap cell id: %d", id); return NULL; } @@ -230,7 +232,7 @@ rdpBitmap* bitmap_cache_get(rdpBitmapCache* bitmapCache, UINT32 id, UINT32 index } else if (index > bitmapCache->cells[id].number) { - DEBUG_WARN( "get invalid bitmap index %d in cell id: %d\n", index, id); + WLog_ERR(TAG, "get invalid bitmap index %d in cell id: %d", index, id); return NULL; } @@ -243,7 +245,7 @@ void bitmap_cache_put(rdpBitmapCache* bitmapCache, UINT32 id, UINT32 index, rdpB { if (id > bitmapCache->maxCells) { - DEBUG_WARN( "put invalid bitmap cell id: %d\n", id); + WLog_ERR(TAG, "put invalid bitmap cell id: %d", id); return; } @@ -253,7 +255,7 @@ void bitmap_cache_put(rdpBitmapCache* bitmapCache, UINT32 id, UINT32 index, rdpB } else if (index > bitmapCache->cells[id].number) { - DEBUG_WARN( "put invalid bitmap index %d in cell id: %d\n", index, id); + WLog_ERR(TAG, "put invalid bitmap index %d in cell id: %d", index, id); return; } diff --git a/libfreerdp/cache/brush.c b/libfreerdp/cache/brush.c index 13342cecf..6ede3085e 100644 --- a/libfreerdp/cache/brush.c +++ b/libfreerdp/cache/brush.c @@ -24,13 +24,16 @@ #include #include +#include #include #include #include -#include + #include +#define TAG FREERDP_TAG("cache.brush") + void update_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) { BYTE style; @@ -101,7 +104,7 @@ void* brush_cache_get(rdpBrushCache* brushCache, UINT32 index, UINT32* bpp) { if (index >= brushCache->maxMonoEntries) { - DEBUG_WARN( "invalid brush (%d bpp) index: 0x%04X\n", *bpp, index); + WLog_ERR(TAG, "invalid brush (%d bpp) index: 0x%04X", *bpp, index); return NULL; } @@ -112,7 +115,7 @@ void* brush_cache_get(rdpBrushCache* brushCache, UINT32 index, UINT32* bpp) { if (index >= brushCache->maxEntries) { - DEBUG_WARN( "invalid brush (%d bpp) index: 0x%04X\n", *bpp, index); + WLog_ERR(TAG, "invalid brush (%d bpp) index: 0x%04X", *bpp, index); return NULL; } @@ -122,7 +125,7 @@ void* brush_cache_get(rdpBrushCache* brushCache, UINT32 index, UINT32* bpp) if (entry == NULL) { - DEBUG_WARN( "invalid brush (%d bpp) at index: 0x%04X\n", *bpp, index); + WLog_ERR(TAG, "invalid brush (%d bpp) at index: 0x%04X", *bpp, index); return NULL; } @@ -137,7 +140,7 @@ void brush_cache_put(rdpBrushCache* brushCache, UINT32 index, void* entry, UINT3 { if (index >= brushCache->maxMonoEntries) { - DEBUG_WARN( "invalid brush (%d bpp) index: 0x%04X\n", bpp, index); + WLog_ERR(TAG, "invalid brush (%d bpp) index: 0x%04X", bpp, index); if (entry) free(entry); @@ -157,7 +160,7 @@ void brush_cache_put(rdpBrushCache* brushCache, UINT32 index, void* entry, UINT3 { if (index >= brushCache->maxEntries) { - DEBUG_WARN( "invalid brush (%d bpp) index: 0x%04X\n", bpp, index); + WLog_ERR(TAG, "invalid brush (%d bpp) index: 0x%04X", bpp, index); if (entry) free(entry); diff --git a/libfreerdp/cache/glyph.c b/libfreerdp/cache/glyph.c index 8bbd0b017..3dcb32a07 100644 --- a/libfreerdp/cache/glyph.c +++ b/libfreerdp/cache/glyph.c @@ -28,9 +28,11 @@ #include #include -#include +#include #include +#define TAG FREERDP_TAG("cache.glyph") + void update_process_glyph(rdpContext* context, BYTE* data, int* index, int* x, int* y, UINT32 cacheId, UINT32 ulCharInc, UINT32 flAccel) { @@ -368,20 +370,20 @@ rdpGlyph* glyph_cache_get(rdpGlyphCache* glyphCache, UINT32 id, UINT32 index) if (id > 9) { - DEBUG_WARN( "invalid glyph cache id: %d\n", id); + WLog_ERR(TAG, "invalid glyph cache id: %d", id); return NULL; } if (index > glyphCache->glyphCache[id].number) { - DEBUG_WARN( "index %d out of range for cache id: %d\n", index, id); + WLog_ERR(TAG, "index %d out of range for cache id: %d", index, id); return NULL; } glyph = glyphCache->glyphCache[id].entries[index]; if (!glyph) - DEBUG_WARN( "no glyph found at cache index: %d in cache id: %d\n", index, id); + WLog_ERR(TAG, "no glyph found at cache index: %d in cache id: %d", index, id); return glyph; } @@ -392,13 +394,13 @@ void glyph_cache_put(rdpGlyphCache* glyphCache, UINT32 id, UINT32 index, rdpGlyp if (id > 9) { - DEBUG_WARN( "invalid glyph cache id: %d\n", id); + WLog_ERR(TAG, "invalid glyph cache id: %d", id); return; } if (index > glyphCache->glyphCache[id].number) { - DEBUG_WARN( "invalid glyph cache index: %d in cache id: %d\n", index, id); + WLog_ERR(TAG, "invalid glyph cache index: %d in cache id: %d", index, id); return; } @@ -424,7 +426,7 @@ void* glyph_cache_fragment_get(rdpGlyphCache* glyphCache, UINT32 index, UINT32* if (index > 255) { - DEBUG_WARN( "invalid glyph cache fragment index: %d\n", index); + WLog_ERR(TAG, "invalid glyph cache fragment index: %d", index); return NULL; } @@ -434,7 +436,7 @@ void* glyph_cache_fragment_get(rdpGlyphCache* glyphCache, UINT32 index, UINT32* WLog_Print(glyphCache->log, WLOG_DEBUG, "GlyphCacheFragmentGet: index: %d size: %d", index, *size); if (!fragment) - DEBUG_WARN( "invalid glyph fragment at index:%d\n", index); + WLog_ERR(TAG, "invalid glyph fragment at index:%d", index); return fragment; } @@ -445,7 +447,7 @@ void glyph_cache_fragment_put(rdpGlyphCache* glyphCache, UINT32 index, UINT32 si if (index > 255) { - DEBUG_WARN( "invalid glyph cache fragment index: %d\n", index); + WLog_ERR(TAG, "invalid glyph cache fragment index: %d", index); return; } diff --git a/libfreerdp/cache/nine_grid.c b/libfreerdp/cache/nine_grid.c index ed2502f7a..a52cf15b9 100644 --- a/libfreerdp/cache/nine_grid.c +++ b/libfreerdp/cache/nine_grid.c @@ -25,13 +25,16 @@ #include +#include #include #include #include -#include + #include +#define TAG FREERDP_TAG("cache.nine_grid") + void update_gdi_draw_nine_grid(rdpContext* context, DRAW_NINE_GRID_ORDER* draw_nine_grid) { rdpCache* cache = context->cache; @@ -61,7 +64,7 @@ void* nine_grid_cache_get(rdpNineGridCache* nine_grid, UINT32 index) if (index >= nine_grid->maxEntries) { - DEBUG_WARN( "invalid NineGrid index: 0x%04X\n", index); + WLog_ERR(TAG, "invalid NineGrid index: 0x%04X", index); return NULL; } @@ -69,7 +72,7 @@ void* nine_grid_cache_get(rdpNineGridCache* nine_grid, UINT32 index) if (entry == NULL) { - DEBUG_WARN( "invalid NineGrid at index: 0x%04X\n", index); + WLog_ERR(TAG, "invalid NineGrid at index: 0x%04X", index); return NULL; } @@ -82,7 +85,7 @@ void nine_grid_cache_put(rdpNineGridCache* nine_grid, UINT32 index, void* entry) if (index >= nine_grid->maxEntries) { - DEBUG_WARN( "invalid NineGrid index: 0x%04X\n", index); + WLog_ERR(TAG, "invalid NineGrid index: 0x%04X", index); return; } diff --git a/libfreerdp/cache/offscreen.c b/libfreerdp/cache/offscreen.c index 3a2b18bb4..0dbbcdd96 100644 --- a/libfreerdp/cache/offscreen.c +++ b/libfreerdp/cache/offscreen.c @@ -27,9 +27,11 @@ #include -#include +#include #include +#define TAG FREERDP_TAG("cache.offscreen") + void update_gdi_create_offscreen_bitmap(rdpContext* context, CREATE_OFFSCREEN_BITMAP_ORDER* createOffscreenBitmap) { int i; @@ -81,7 +83,7 @@ rdpBitmap* offscreen_cache_get(rdpOffscreenCache* offscreenCache, UINT32 index) if (index >= offscreenCache->maxEntries) { - DEBUG_WARN( "invalid offscreen bitmap index: 0x%04X\n", index); + WLog_ERR(TAG, "invalid offscreen bitmap index: 0x%04X", index); return NULL; } @@ -89,7 +91,7 @@ rdpBitmap* offscreen_cache_get(rdpOffscreenCache* offscreenCache, UINT32 index) if (!bitmap) { - DEBUG_WARN( "invalid offscreen bitmap at index: 0x%04X\n", index); + WLog_ERR(TAG, "invalid offscreen bitmap at index: 0x%04X", index); return NULL; } @@ -100,7 +102,7 @@ void offscreen_cache_put(rdpOffscreenCache* offscreenCache, UINT32 index, rdpBit { if (index >= offscreenCache->maxEntries) { - DEBUG_WARN( "invalid offscreen bitmap index: 0x%04X\n", index); + WLog_ERR(TAG, "invalid offscreen bitmap index: 0x%04X", index); return; } @@ -114,7 +116,7 @@ void offscreen_cache_delete(rdpOffscreenCache* offscreenCache, UINT32 index) if (index >= offscreenCache->maxEntries) { - DEBUG_WARN( "invalid offscreen bitmap index (delete): 0x%04X\n", index); + WLog_ERR(TAG, "invalid offscreen bitmap index (delete): 0x%04X", index); return; } diff --git a/libfreerdp/cache/palette.c b/libfreerdp/cache/palette.c index e472aee1e..dc515835b 100644 --- a/libfreerdp/cache/palette.c +++ b/libfreerdp/cache/palette.c @@ -25,9 +25,11 @@ #include -#include +#include #include +#define TAG FREERDP_TAG("cache.palette") + static void update_gdi_cache_color_table(rdpContext* context, CACHE_COLOR_TABLE_ORDER* cacheColorTable) { UINT32* colorTable; @@ -45,7 +47,7 @@ void* palette_cache_get(rdpPaletteCache* paletteCache, UINT32 index) if (index >= paletteCache->maxEntries) { - DEBUG_WARN( "invalid color table index: 0x%04X\n", index); + WLog_ERR(TAG, "invalid color table index: 0x%04X", index); return NULL; } @@ -53,7 +55,7 @@ void* palette_cache_get(rdpPaletteCache* paletteCache, UINT32 index) if (!entry) { - DEBUG_WARN( "invalid color table at index: 0x%04X\n", index); + WLog_ERR(TAG, "invalid color table at index: 0x%04X", index); return NULL; } @@ -64,7 +66,7 @@ void palette_cache_put(rdpPaletteCache* paletteCache, UINT32 index, void* entry) { if (index >= paletteCache->maxEntries) { - DEBUG_WARN( "invalid color table index: 0x%04X\n", index); + WLog_ERR(TAG, "invalid color table index: 0x%04X", index); if (entry) free(entry); @@ -87,15 +89,13 @@ rdpPaletteCache* palette_cache_new(rdpSettings* settings) { rdpPaletteCache* paletteCache; - paletteCache = (rdpPaletteCache*) malloc(sizeof(rdpPaletteCache)); - ZeroMemory(paletteCache, sizeof(rdpPaletteCache)); + paletteCache = (rdpPaletteCache*) calloc(1, sizeof(rdpPaletteCache)); if (paletteCache) { paletteCache->settings = settings; paletteCache->maxEntries = 6; - paletteCache->entries = (PALETTE_TABLE_ENTRY*) malloc(sizeof(PALETTE_TABLE_ENTRY) * paletteCache->maxEntries); - ZeroMemory(paletteCache->entries, sizeof(PALETTE_TABLE_ENTRY) * paletteCache->maxEntries); + paletteCache->entries = (PALETTE_TABLE_ENTRY*) calloc(paletteCache->maxEntries, sizeof(PALETTE_TABLE_ENTRY)); } return paletteCache; diff --git a/libfreerdp/cache/pointer.c b/libfreerdp/cache/pointer.c index 227322d25..5af41121c 100644 --- a/libfreerdp/cache/pointer.c +++ b/libfreerdp/cache/pointer.c @@ -27,8 +27,11 @@ #include +#include #include -#include + + +#define TAG FREERDP_TAG("cache.pointer") void update_pointer_position(rdpContext* context, POINTER_POSITION_UPDATE* pointer_position) { @@ -48,7 +51,7 @@ void update_pointer_system(rdpContext* context, POINTER_SYSTEM_UPDATE* pointer_s break; default: - DEBUG_WARN( "Unknown system pointer type (0x%08X)\n", pointer_system->type); + WLog_ERR(TAG, "Unknown system pointer type (0x%08X)", pointer_system->type); break; } } @@ -141,7 +144,7 @@ rdpPointer* pointer_cache_get(rdpPointerCache* pointer_cache, UINT32 index) if (index >= pointer_cache->cacheSize) { - DEBUG_WARN( "invalid pointer index:%d\n", index); + WLog_ERR(TAG, "invalid pointer index:%d", index); return NULL; } @@ -156,7 +159,7 @@ void pointer_cache_put(rdpPointerCache* pointer_cache, UINT32 index, rdpPointer* if (index >= pointer_cache->cacheSize) { - DEBUG_WARN( "invalid pointer index:%d\n", index); + WLog_ERR(TAG, "invalid pointer index:%d", index); return; } diff --git a/libfreerdp/codec/CMakeLists.txt b/libfreerdp/codec/CMakeLists.txt deleted file mode 100644 index bab5714f6..000000000 --- a/libfreerdp/codec/CMakeLists.txt +++ /dev/null @@ -1,139 +0,0 @@ -# FreeRDP: A Remote Desktop Protocol Implementation -# libfreerdp-codec cmake build script -# -# Copyright 2012 Marc-Andre Moreau -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set(MODULE_NAME "freerdp-codec") -set(MODULE_PREFIX "FREERDP_CODEC") - -set(${MODULE_PREFIX}_SRCS - dsp.c - color.c - audio.c - planar.c - bitmap.c - interleaved.c - progressive.c - rfx_bitstream.h - rfx_constants.h - rfx_decode.c - rfx_decode.h - rfx_differential.c - rfx_differential.h - rfx_dwt.c - rfx_dwt.h - rfx_encode.c - rfx_encode.h - rfx_quantization.c - rfx_quantization.h - rfx_rlgr.c - rfx_rlgr.h - rfx_types.h - rfx.c - region.c - nsc.c - nsc_encode.c - nsc_encode.h - nsc_types.h - ncrush.c - xcrush.c - mppc.c - zgfx.c - clear.c - jpeg.c - h264.c) - -set(${MODULE_PREFIX}_SSE2_SRCS - rfx_sse2.c - rfx_sse2.h - nsc_sse2.c - nsc_sse2.h) - -set(${MODULE_PREFIX}_NEON_SRCS - rfx_neon.c - rfx_neon.h) - -if(WITH_SSE2) - set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_SSE2_SRCS}) - - if(CMAKE_COMPILER_IS_GNUCC) - set_source_files_properties(${${MODULE_PREFIX}_SSE2_SRCS} PROPERTIES COMPILE_FLAGS "-msse2") - endif() - - if(MSVC) - set_source_files_properties(${${MODULE_PREFIX}_SSE2_SRCS} PROPERTIES COMPILE_FLAGS "/arch:SSE2") - endif() -endif() - -if(WITH_NEON) - set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_NEON_SRCS}) - set_source_files_properties(${${MODULE_PREFIX}_NEON_SRCS} PROPERTIES COMPILE_FLAGS "-mfpu=neon -mfloat-abi=${ARM_FP_ABI} -Wno-unused-variable") -endif() - -if(WITH_JPEG) - include_directories(${JPEG_INCLUDE_DIR}) - set(FREERDP_JPEG_LIBS ${JPEG_LIBRARIES}) -endif() - -if(WITH_OPENH264) - add_definitions(-DWITH_OPENH264) - include_directories(${OPENH264_INCLUDE_DIR}) - set(FREERDP_OPENH264_LIBS ${OPENH264_LIBRARIES}) -endif() - -if(WITH_LIBAVCODEC) - add_definitions(-DWITH_LIBAVCODEC) - find_library(LIBAVCODEC_LIB avcodec) - find_library(LIBAVUTIL_LIB avutil) - set(FREERDP_LIBAVCODEC_LIBS ${LIBAVCODEC_LIB} ${LIBAVUTIL_LIB}) -endif() - - -add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT" - MONOLITHIC ${MONOLITHIC_BUILD} - SOURCES ${${MODULE_PREFIX}_SRCS} - EXPORT) - -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) -endif() -set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "lib") - -set(${MODULE_PREFIX}_LIBS - ${FREERDP_JPEG_LIBS} - ${FREERDP_OPENH264_LIBS} - ${FREERDP_LIBAVCODEC_LIBS}) - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} INTERNAL - MODULE freerdp - MODULES freerdp-primitives freerdp-utils) - - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -if(MONOLITHIC_BUILD) - set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) -else() - target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) - install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets) -endif() - -set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") - -if(BUILD_TESTING) - add_subdirectory(test) -endif() - diff --git a/libfreerdp/codec/audio.c b/libfreerdp/codec/audio.c index 06f96ae0d..6d96628a9 100644 --- a/libfreerdp/codec/audio.c +++ b/libfreerdp/codec/audio.c @@ -23,9 +23,11 @@ #include -#include +#include #include +#define TAG FREERDP_TAG("codec") + UINT32 rdpsnd_compute_audio_time_length(AUDIO_FORMAT* format, int size) { UINT32 mstime; @@ -58,12 +60,12 @@ UINT32 rdpsnd_compute_audio_time_length(AUDIO_FORMAT* format, int size) } else { - DEBUG_WARN( "rdpsnd_compute_audio_time_length: invalid WAVE_FORMAT_GSM610 format\n"); + WLog_ERR(TAG, "rdpsnd_compute_audio_time_length: invalid WAVE_FORMAT_GSM610 format"); } } else { - DEBUG_WARN( "rdpsnd_compute_audio_time_length: unknown format %d\n", format->wFormatTag); + WLog_ERR(TAG, "rdpsnd_compute_audio_time_length: unknown format %d", format->wFormatTag); } } @@ -110,11 +112,11 @@ char* rdpsnd_get_audio_tag_string(UINT16 wFormatTag) void rdpsnd_print_audio_format(AUDIO_FORMAT* format) { - DEBUG_WARN( "%s:\t wFormatTag: 0x%04X nChannels: %d nSamplesPerSec: %d nAvgBytesPerSec: %d " - "nBlockAlign: %d wBitsPerSample: %d cbSize: %d\n", - rdpsnd_get_audio_tag_string(format->wFormatTag), format->wFormatTag, - format->nChannels, format->nSamplesPerSec, format->nAvgBytesPerSec, - format->nBlockAlign, format->wBitsPerSample, format->cbSize); + WLog_INFO(TAG, "%s:\t wFormatTag: 0x%04X nChannels: %d nSamplesPerSec: %d nAvgBytesPerSec: %d " + "nBlockAlign: %d wBitsPerSample: %d cbSize: %d", + rdpsnd_get_audio_tag_string(format->wFormatTag), format->wFormatTag, + format->nChannels, format->nSamplesPerSec, format->nAvgBytesPerSec, + format->nBlockAlign, format->wBitsPerSample, format->cbSize); } void rdpsnd_print_audio_formats(AUDIO_FORMAT* formats, UINT16 count) @@ -124,17 +126,16 @@ void rdpsnd_print_audio_formats(AUDIO_FORMAT* formats, UINT16 count) if (formats) { - DEBUG_WARN( "AUDIO_FORMATS (%d) =\n{\n", count); + WLog_INFO(TAG, "AUDIO_FORMATS (%d) ={", count); for (index = 0; index < (int) count; index++) { format = &formats[index]; - - DEBUG_WARN( "\t"); + WLog_ERR(TAG, "\t"); rdpsnd_print_audio_format(format); } - DEBUG_WARN( "}\n"); + WLog_ERR(TAG, "}"); } } diff --git a/libfreerdp/codec/clear.c b/libfreerdp/codec/clear.c index dadd430c2..fd7935bbb 100644 --- a/libfreerdp/codec/clear.c +++ b/libfreerdp/codec/clear.c @@ -166,7 +166,7 @@ int clear_decompress(CLEAR_CONTEXT* clear, BYTE* pSrcData, UINT32 SrcSize, subcodecByteCount = *((UINT32*) &pSrcData[offset + 8]); offset += 12; - //DEBUG_MSG("residualByteCount: %d bandsByteCount: %d subcodecByteCount: %d\n", + //WLog_DBG(TAG, "residualByteCount: %d bandsByteCount: %d subcodecByteCount: %d\n", // residualByteCount, bandsByteCount, subcodecByteCount); if (residualByteCount > 0) @@ -551,7 +551,7 @@ int clear_decompress(CLEAR_CONTEXT* clear, BYTE* pSrcData, UINT32 SrcSize, subcodecId = subcodecs[suboffset + 12]; suboffset += 13; - //DEBUG_MSG("bitmapDataByteCount: %d subcodecByteCount: %d suboffset: %d subCodecId: %d\n", + //WLog_DBG(TAG, "bitmapDataByteCount: %d subcodecByteCount: %d suboffset: %d subCodecId: %d\n", // bitmapDataByteCount, subcodecByteCount, suboffset, subcodecId); if ((subcodecByteCount - suboffset) < bitmapDataByteCount) diff --git a/libfreerdp/codec/color.c b/libfreerdp/codec/color.c index 07d94c2f9..94bc7e23e 100644 --- a/libfreerdp/codec/color.c +++ b/libfreerdp/codec/color.c @@ -379,9 +379,11 @@ UINT32 freerdp_color_convert_var_bgr(UINT32 srcColor, int srcBpp, int dstBpp, HC return freerdp_color_convert_rgb_bgr(srcColor, srcBpp, dstBpp, clrconv); } -UINT32 freerdp_convert_gdi_order_color(UINT32 color, int bpp, UINT32 format) +UINT32 freerdp_convert_gdi_order_color(UINT32 color, int bpp, UINT32 format, BYTE* palette) { - UINT32 r, g, b; + UINT32 r = 0; + UINT32 g = 0; + UINT32 b = 0; switch (bpp) { @@ -405,9 +407,12 @@ UINT32 freerdp_convert_gdi_order_color(UINT32 color, int bpp, UINT32 format) case 8: color = (color >> 16) & (UINT32) 0xFF; - //r = clrconv->palette->entries[color].red; - //g = clrconv->palette->entries[color].green; - //b = clrconv->palette->entries[color].blue; + if (palette) + { + r = palette[(color * 4) + 2]; + g = palette[(color * 4) + 1]; + b = palette[(color * 4) + 0]; + } break; case 1: @@ -1304,8 +1309,353 @@ void freerdp_clrconv_free(HCLRCONV clrconv) } } +int freerdp_image8_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, + int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette) +{ + BYTE* pe; + int x, y; + int srcFlip; + int dstFlip; + int nSrcPad; + int nDstPad; + int srcBitsPerPixel; + int srcBytesPerPixel; + int dstBitsPerPixel; + int dstBytesPerPixel; + BOOL vFlip = FALSE; + BOOL invert = FALSE; + + if (!palette) + return -1; + + srcBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(SrcFormat); + srcBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(SrcFormat) / 8); + srcFlip = FREERDP_PIXEL_FORMAT_FLIP(SrcFormat); + + dstBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(DstFormat); + dstBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(DstFormat) / 8); + dstFlip = FREERDP_PIXEL_FORMAT_FLIP(DstFormat); + + if (nSrcStep < 0) + nSrcStep = srcBytesPerPixel * nWidth; + + if (nDstStep < 0) + nDstStep = dstBytesPerPixel * nWidth; + + nSrcPad = (nSrcStep - (nWidth * srcBytesPerPixel)); + nDstPad = (nDstStep - (nWidth * dstBytesPerPixel)); + + if (srcFlip != dstFlip) + vFlip = TRUE; + + invert = FREERDP_PIXEL_FORMAT_IS_ABGR(DstFormat) ? TRUE : FALSE; + + if (dstBytesPerPixel == 4) + { + if ((dstBitsPerPixel == 32) || (dstBitsPerPixel == 24)) + { + BYTE* pSrcPixel; + UINT32* pDstPixel; + + if (!invert) + { + if (!vFlip) + { + pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + nXSrc]; + pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)]; + + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + pe = &palette[*pSrcPixel * 4]; + *pDstPixel++ = RGB32(pe[2], pe[1], pe[0]); + pSrcPixel++; + } + + pSrcPixel = &pSrcPixel[nSrcPad]; + pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad]; + } + } + else + { + pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + nXSrc]; + pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)]; + + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + pe = &palette[*pSrcPixel * 4]; + *pDstPixel++ = RGB32(pe[2], pe[1], pe[0]); + pSrcPixel++; + } + + pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)]; + pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad]; + } + } + } + else + { + if (!vFlip) + { + pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + nXSrc]; + pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)]; + + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + pe = &palette[*pSrcPixel * 4]; + *pDstPixel++ = BGR32(pe[2], pe[1], pe[0]); + pSrcPixel++; + } + + pSrcPixel = &pSrcPixel[nSrcPad]; + pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad]; + } + } + else + { + pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + nXSrc]; + pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)]; + + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + pe = &palette[*pSrcPixel * 4]; + *pDstPixel++ = BGR32(pe[2], pe[1], pe[0]); + pSrcPixel++; + } + + pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)]; + pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad]; + } + } + } + + return 1; + } + } + else if (dstBytesPerPixel == 3) + { + + } + else if (dstBytesPerPixel == 2) + { + if (dstBitsPerPixel == 16) + { + BYTE* pSrcPixel; + UINT16* pDstPixel; + + if (!invert) + { + if (!vFlip) + { + pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + nXSrc]; + pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)]; + + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + pe = &palette[*pSrcPixel * 4]; + *pDstPixel++ = RGB16(pe[2], pe[1], pe[0]); + pSrcPixel++; + } + + pSrcPixel = &pSrcPixel[nSrcPad]; + pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad]; + } + } + else + { + pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + nXSrc]; + pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)]; + + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + pe = &palette[*pSrcPixel * 4]; + *pDstPixel++ = RGB16(pe[2], pe[1], pe[0]); + pSrcPixel++; + } + + pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)]; + pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad]; + } + } + } + else + { + if (!vFlip) + { + pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + nXSrc]; + pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)]; + + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + pe = &palette[*pSrcPixel * 4]; + *pDstPixel++ = BGR16(pe[2], pe[1], pe[0]); + pSrcPixel++; + } + + pSrcPixel = &pSrcPixel[nSrcPad]; + pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad]; + } + } + else + { + pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + nXSrc]; + pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)]; + + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + pe = &palette[*pSrcPixel * 4]; + *pDstPixel++ = BGR16(pe[2], pe[1], pe[0]); + pSrcPixel++; + } + + pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)]; + pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad]; + } + } + } + + return 1; + } + else if (dstBitsPerPixel == 15) + { + BYTE* pSrcPixel; + UINT16* pDstPixel; + + if (!invert) + { + if (!vFlip) + { + pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + nXSrc]; + pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)]; + + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + pe = &palette[*pSrcPixel * 4]; + *pDstPixel++ = RGB15(pe[2], pe[1], pe[0]); + pSrcPixel++; + } + + pSrcPixel = &pSrcPixel[nSrcPad]; + pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad]; + } + } + else + { + pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + nXSrc]; + pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)]; + + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + pe = &palette[*pSrcPixel * 4]; + *pDstPixel++ = RGB15(pe[2], pe[1], pe[0]); + pSrcPixel++; + } + + pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)]; + pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad]; + } + } + } + else + { + if (!vFlip) + { + pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + nXSrc]; + pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)]; + + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + pe = &palette[*pSrcPixel * 4]; + *pDstPixel++ = BGR15(pe[2], pe[1], pe[0]); + pSrcPixel++; + } + + pSrcPixel = &pSrcPixel[nSrcPad]; + pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad]; + } + } + else + { + pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + nXSrc]; + pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)]; + + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + pe = &palette[*pSrcPixel * 4]; + *pDstPixel++ = BGR15(pe[2], pe[1], pe[0]); + pSrcPixel++; + } + + pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)]; + pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad]; + } + } + } + + return 1; + } + } + else if (dstBytesPerPixel == 1) + { + BYTE* pSrcPixel; + BYTE* pDstPixel; + + if (!vFlip) + { + pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + nXSrc]; + pDstPixel = &pDstData[(nYDst * nDstStep) + nXDst]; + + for (y = 0; y < nHeight; y++) + { + CopyMemory(pDstPixel, pSrcPixel, nWidth); + pSrcPixel = &pSrcPixel[nSrcStep]; + pDstPixel = &pDstPixel[nDstStep]; + } + } + else + { + pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + nXSrc]; + pDstPixel = &pDstData[(nYDst * nDstStep) + nXDst]; + + for (y = 0; y < nHeight; y++) + { + CopyMemory(pDstPixel, pSrcPixel, nWidth); + pSrcPixel = &pSrcPixel[-nSrcStep]; + pDstPixel = &pDstPixel[nDstStep]; + } + } + + return 1; + } + + return -1; +} + int freerdp_image15_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, - int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc) + int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette) { int x, y; int srcFlip; @@ -1331,6 +1681,12 @@ int freerdp_image15_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDs dstFlip = FREERDP_PIXEL_FORMAT_FLIP(DstFormat); dstType = FREERDP_PIXEL_FORMAT_TYPE(DstFormat); + if (nSrcStep < 0) + nSrcStep = srcBytesPerPixel * nWidth; + + if (nDstStep < 0) + nDstStep = dstBytesPerPixel * nWidth; + nSrcPad = (nSrcStep - (nWidth * srcBytesPerPixel)); nDstPad = (nDstStep - (nWidth * dstBytesPerPixel)); @@ -1433,6 +1789,8 @@ int freerdp_image15_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDs } } } + + return 1; } } else if (dstBytesPerPixel == 2) @@ -1631,7 +1989,7 @@ int freerdp_image15_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDs } int freerdp_image16_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, - int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc) + int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette) { int x, y; int srcFlip; @@ -1657,6 +2015,12 @@ int freerdp_image16_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDs dstFlip = FREERDP_PIXEL_FORMAT_FLIP(DstFormat); dstType = FREERDP_PIXEL_FORMAT_TYPE(DstFormat); + if (nSrcStep < 0) + nSrcStep = srcBytesPerPixel * nWidth; + + if (nDstStep < 0) + nDstStep = dstBytesPerPixel * nWidth; + nSrcPad = (nSrcStep - (nWidth * srcBytesPerPixel)); nDstPad = (nDstStep - (nWidth * dstBytesPerPixel)); @@ -1943,7 +2307,7 @@ int freerdp_image16_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDs } int freerdp_image24_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, - int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc) + int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette) { int x, y; int srcFlip; @@ -1971,6 +2335,12 @@ int freerdp_image24_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDs nSrcPad = (nSrcStep - (nWidth * srcBytesPerPixel)); nDstPad = (nDstStep - (nWidth * dstBytesPerPixel)); + if (nSrcStep < 0) + nSrcStep = srcBytesPerPixel * nWidth; + + if (nDstStep < 0) + nDstStep = dstBytesPerPixel * nWidth; + if (srcFlip != dstFlip) vFlip = TRUE; @@ -2252,7 +2622,7 @@ int freerdp_image24_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDs } int freerdp_image32_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, - int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc) + int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette) { int x, y; int srcFlip; @@ -2278,6 +2648,12 @@ int freerdp_image32_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDs dstFlip = FREERDP_PIXEL_FORMAT_FLIP(DstFormat); dstType = FREERDP_PIXEL_FORMAT_TYPE(DstFormat); + if (nSrcStep < 0) + nSrcStep = srcBytesPerPixel * nWidth; + + if (nDstStep < 0) + nDstStep = dstBytesPerPixel * nWidth; + nSrcPad = (nSrcStep - (nWidth * srcBytesPerPixel)); nDstPad = (nDstStep - (nWidth * dstBytesPerPixel)); @@ -2503,52 +2879,52 @@ int freerdp_image32_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDs } int freerdp_image_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, - int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc) + int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette) { int status = -1; int srcBitsPerPixel; int srcBytesPerPixel; - int dstBitsPerPixel; - int dstBytesPerPixel; srcBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(SrcFormat); srcBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(SrcFormat) / 8); - if (nSrcStep < 0) - nSrcStep = srcBytesPerPixel * nWidth; - - dstBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(DstFormat); - dstBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(DstFormat) / 8); - - if (nDstStep < 0) - nDstStep = dstBytesPerPixel * nWidth; - if (srcBytesPerPixel == 4) { status = freerdp_image32_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, - nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc); + nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc, palette); } else if (srcBytesPerPixel == 3) { status = freerdp_image24_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, - nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc); + nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc, palette); } else if (srcBytesPerPixel == 2) { if (srcBitsPerPixel == 16) { status = freerdp_image16_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, - nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc); + nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc, palette); } else if (srcBitsPerPixel == 15) { status = freerdp_image15_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, - nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc); + nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc, palette); } } + else if (srcBytesPerPixel == 1) + { + status = freerdp_image8_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, + nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc, palette); + } if (status < 0) { + int dstBitsPerPixel; + int dstBytesPerPixel; + + dstBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(DstFormat); + dstBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(DstFormat) / 8); + fprintf(stderr, "freerdp_image_copy failure: src: %d/%d dst: %d/%d\n", srcBitsPerPixel, srcBytesPerPixel, dstBitsPerPixel, dstBytesPerPixel); } @@ -2562,18 +2938,24 @@ int freerdp_image_move(BYTE* pData, DWORD Format, int nStep, int nXDst, int nYDs BOOL overlap; BYTE* pSrcPixel; BYTE* pDstPixel; + int bytesPerPixel; + + bytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(Format) / 8); + + if (nStep < 0) + nStep = nWidth * bytesPerPixel; overlap = (((nXDst + nWidth) > nXSrc) && (nXDst < (nXSrc + nWidth)) && ((nYDst + nHeight) > nYSrc) && (nYDst < (nYSrc + nHeight))) ? TRUE : FALSE; if (!overlap) { - pSrcPixel = &pData[(nYSrc * nStep) + (nXSrc * 4)]; - pDstPixel = &pData[(nYDst * nStep) + (nXDst * 4)]; + pSrcPixel = &pData[(nYSrc * nStep) + (nXSrc * bytesPerPixel)]; + pDstPixel = &pData[(nYDst * nStep) + (nXDst * bytesPerPixel)]; for (y = 0; y < nHeight; y++) { - CopyMemory(pDstPixel, pSrcPixel, nWidth * 4); + CopyMemory(pDstPixel, pSrcPixel, nWidth * bytesPerPixel); pSrcPixel += nStep; pDstPixel += nStep; } @@ -2585,12 +2967,12 @@ int freerdp_image_move(BYTE* pData, DWORD Format, int nStep, int nXDst, int nYDs { /* copy down */ - pSrcPixel = &pData[((nYSrc + nHeight - 1) * nStep) + (nXSrc * 4)]; - pDstPixel = &pData[((nYDst + nHeight - 1) * nStep) + (nXDst * 4)]; + pSrcPixel = &pData[((nYSrc + nHeight - 1) * nStep) + (nXSrc * bytesPerPixel)]; + pDstPixel = &pData[((nYDst + nHeight - 1) * nStep) + (nXDst * bytesPerPixel)]; for (y = 0; y < nHeight; y++) { - CopyMemory(pDstPixel, pSrcPixel, nWidth * 4); + CopyMemory(pDstPixel, pSrcPixel, nWidth * bytesPerPixel); pSrcPixel -= nStep; pDstPixel -= nStep; } @@ -2599,12 +2981,12 @@ int freerdp_image_move(BYTE* pData, DWORD Format, int nStep, int nXDst, int nYDs { /* copy up */ - pSrcPixel = &pData[(nYSrc * nStep) + (nXSrc * 4)]; - pDstPixel = &pData[(nYDst * nStep) + (nXDst * 4)]; + pSrcPixel = &pData[(nYSrc * nStep) + (nXSrc * bytesPerPixel)]; + pDstPixel = &pData[(nYDst * nStep) + (nXDst * bytesPerPixel)]; for (y = 0; y < nHeight; y++) { - CopyMemory(pDstPixel, pSrcPixel, nWidth * 4); + CopyMemory(pDstPixel, pSrcPixel, nWidth * bytesPerPixel); pSrcPixel += nStep; pDstPixel += nStep; } @@ -2613,12 +2995,12 @@ int freerdp_image_move(BYTE* pData, DWORD Format, int nStep, int nXDst, int nYDs { /* copy left */ - pSrcPixel = &pData[(nYSrc * nStep) + (nXSrc * 4)]; - pDstPixel = &pData[(nYDst * nStep) + (nXDst * 4)]; + pSrcPixel = &pData[(nYSrc * nStep) + (nXSrc * bytesPerPixel)]; + pDstPixel = &pData[(nYDst * nStep) + (nXDst * bytesPerPixel)]; for (y = 0; y < nHeight; y++) { - MoveMemory(pDstPixel, pSrcPixel, nWidth * 4); + MoveMemory(pDstPixel, pSrcPixel, nWidth * bytesPerPixel); pSrcPixel += nStep; pDstPixel += nStep; } @@ -2627,12 +3009,12 @@ int freerdp_image_move(BYTE* pData, DWORD Format, int nStep, int nXDst, int nYDs { /* copy right */ - pSrcPixel = &pData[(nYSrc * nStep) + (nXSrc * 4)]; - pDstPixel = &pData[(nYDst * nStep) + (nXDst * 4)]; + pSrcPixel = &pData[(nYSrc * nStep) + (nXSrc * bytesPerPixel)]; + pDstPixel = &pData[(nYDst * nStep) + (nXDst * bytesPerPixel)]; for (y = 0; y < nHeight; y++) { - MoveMemory(pDstPixel, pSrcPixel, nWidth * 4); + MoveMemory(pDstPixel, pSrcPixel, nWidth * bytesPerPixel); pSrcPixel += nStep; pDstPixel += nStep; } diff --git a/libfreerdp/codec/h264.c b/libfreerdp/codec/h264.c index 5043a6678..d5504dc3a 100644 --- a/libfreerdp/codec/h264.c +++ b/libfreerdp/codec/h264.c @@ -27,6 +27,9 @@ #include #include +#include + +#define TAG FREERDP_TAG("codec") /** * Dummy subsystem @@ -74,7 +77,7 @@ static BOOL g_openh264_trace_enabled = FALSE; static void openh264_trace_callback(H264_CONTEXT* h264, int level, const char* message) { - printf("%d - %s\n", level, message); + WLog_INFO(TAG, "%d - %s", level, message); } static int openh264_decompress(H264_CONTEXT* h264, BYTE* pSrcData, UINT32 SrcSize) @@ -117,7 +120,7 @@ static int openh264_decompress(H264_CONTEXT* h264, BYTE* pSrcData, UINT32 SrcSiz pSystemBuffer = &sBufferInfo.UsrData.sSystemBuffer; #if 0 - printf("h264_decompress: state=%u, pYUVData=[%p,%p,%p], bufferStatus=%d, width=%d, height=%d, format=%d, stride=[%d,%d]\n", + WLog_INFO(TAG, "h264_decompress: state=%u, pYUVData=[%p,%p,%p], bufferStatus=%d, width=%d, height=%d, format=%d, stride=[%d,%d]", state, h264->pYUVData[0], h264->pYUVData[1], h264->pYUVData[2], sBufferInfo.iBufferStatus, pSystemBuffer->iWidth, pSystemBuffer->iHeight, pSystemBuffer->iFormat, pSystemBuffer->iStride[0], pSystemBuffer->iStride[1]); @@ -185,7 +188,7 @@ static BOOL openh264_init(H264_CONTEXT* h264) if (!sys->pDecoder) { - printf("Failed to create OpenH264 decoder\n"); + WLog_ERR(TAG, "Failed to create OpenH264 decoder"); goto EXCEPTION; } @@ -198,7 +201,7 @@ static BOOL openh264_init(H264_CONTEXT* h264) if (status != 0) { - printf("Failed to initialize OpenH264 decoder (status=%ld)\n", status); + WLog_ERR(TAG, "Failed to initialize OpenH264 decoder (status=%ld)", status); goto EXCEPTION; } @@ -206,7 +209,7 @@ static BOOL openh264_init(H264_CONTEXT* h264) if (status != 0) { - printf("Failed to set data format option on OpenH264 decoder (status=%ld)\n", status); + WLog_ERR(TAG, "Failed to set data format option on OpenH264 decoder (status=%ld)", status); } if (g_openh264_trace_enabled) @@ -215,21 +218,21 @@ static BOOL openh264_init(H264_CONTEXT* h264) if (status != 0) { - printf("Failed to set trace level option on OpenH264 decoder (status=%ld)\n", status); + WLog_ERR(TAG, "Failed to set trace level option on OpenH264 decoder (status=%ld)", status); } status = (*sys->pDecoder)->SetOption(sys->pDecoder, DECODER_OPTION_TRACE_CALLBACK, &traceCallback); if (status != 0) { - printf("Failed to set trace callback option on OpenH264 decoder (status=%ld)\n", status); + WLog_ERR(TAG, "Failed to set trace callback option on OpenH264 decoder (status=%ld)", status); } status = (*sys->pDecoder)->SetOption(sys->pDecoder, DECODER_OPTION_TRACE_CALLBACK_CONTEXT, &h264); if (status != 0) { - printf("Failed to set trace callback context option on OpenH264 decoder (status=%ld)\n", status); + WLog_ERR(TAG, "Failed to set trace callback context option on OpenH264 decoder (status=%ld)", status); } } @@ -285,12 +288,12 @@ static int libavcodec_decompress(H264_CONTEXT* h264, BYTE* pSrcData, UINT32 SrcS if (status < 0) { - printf("Failed to decode video frame (status=%d)\n", status); + WLog_ERR(TAG, "Failed to decode video frame (status=%d)", status); return -1; } #if 0 - printf("libavcodec_decompress: frame decoded (status=%d, gotFrame=%d, width=%d, height=%d, Y=[%p,%d], U=[%p,%d], V=[%p,%d])\n", + WLog_INFO(TAG, "libavcodec_decompress: frame decoded (status=%d, gotFrame=%d, width=%d, height=%d, Y=[%p,%d], U=[%p,%d], V=[%p,%d])", status, gotFrame, sys->videoFrame->width, sys->videoFrame->height, sys->videoFrame->data[0], sys->videoFrame->linesize[0], sys->videoFrame->data[1], sys->videoFrame->linesize[1], @@ -362,7 +365,7 @@ static BOOL libavcodec_init(H264_CONTEXT* h264) if (!sys->codec) { - printf("Failed to find libav H.264 codec\n"); + WLog_ERR(TAG, "Failed to find libav H.264 codec"); goto EXCEPTION; } @@ -370,7 +373,7 @@ static BOOL libavcodec_init(H264_CONTEXT* h264) if (!sys->codecContext) { - printf("Failed to allocate libav codec context\n"); + WLog_ERR(TAG, "Failed to allocate libav codec context"); goto EXCEPTION; } @@ -381,7 +384,7 @@ static BOOL libavcodec_init(H264_CONTEXT* h264) if (avcodec_open2(sys->codecContext, sys->codec, NULL) < 0) { - printf("Failed to open libav codec\n"); + WLog_ERR(TAG, "Failed to open libav codec"); goto EXCEPTION; } @@ -389,7 +392,7 @@ static BOOL libavcodec_init(H264_CONTEXT* h264) if (!sys->codecParser) { - printf("Failed to initialize libav parser\n"); + WLog_ERR(TAG, "Failed to initialize libav parser"); goto EXCEPTION; } @@ -397,7 +400,7 @@ static BOOL libavcodec_init(H264_CONTEXT* h264) if (!sys->videoFrame) { - printf("Failed to allocate libav frame\n"); + WLog_ERR(TAG, "Failed to allocate libav frame"); goto EXCEPTION; } @@ -439,7 +442,7 @@ int h264_decompress(H264_CONTEXT* h264, BYTE* pSrcData, UINT32 SrcSize, return -1; #if 0 - printf("h264_decompress: pSrcData=%p, SrcSize=%u, pDstData=%p, nDstStep=%d, nDstHeight=%d, numRegionRects=%d\n", + WLog_INFO(TAG, "h264_decompress: pSrcData=%p, SrcSize=%u, pDstData=%p, nDstStep=%d, nDstHeight=%d, numRegionRects=%d", pSrcData, SrcSize, *ppDstData, nDstStep, nDstHeight, numRegionRects); #endif @@ -471,7 +474,7 @@ int h264_decompress(H264_CONTEXT* h264, BYTE* pSrcData, UINT32 SrcSize, pYUVPoint[2] = pYUVData[2] + rect->top/2 * iStride[2] + rect->left/2; #if 0 - printf("regionRect: x: %d y: %d width: %d height: %d\n", + WLog_INFO(TAG, "regionRect: x: %d y: %d width: %d height: %d", rect->left, rect->top, width, height); #endif diff --git a/libfreerdp/codec/interleaved.c b/libfreerdp/codec/interleaved.c index af71b5658..ea335bc1b 100644 --- a/libfreerdp/codec/interleaved.c +++ b/libfreerdp/codec/interleaved.c @@ -236,7 +236,7 @@ static INLINE UINT32 ExtractRunLength(UINT32 code, BYTE* pbOrderHdr, UINT32* adv #include "include/bitmap.c" int interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pSrcData, UINT32 SrcSize, int bpp, - BYTE** ppDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, int nWidth, int nHeight) + BYTE** ppDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, int nWidth, int nHeight, BYTE* palette) { int status; BOOL vFlip; @@ -283,7 +283,7 @@ int interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pSrcDa RleDecompress24to24(pSrcData, SrcSize, interleaved->TempBuffer, scanline, nWidth, nHeight); status = freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, - nWidth, nHeight, interleaved->TempBuffer, SrcFormat, scanline, 0, 0); + nWidth, nHeight, interleaved->TempBuffer, SrcFormat, scanline, 0, 0, palette); } else if ((bpp == 16) || (bpp == 15)) { @@ -310,7 +310,7 @@ int interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pSrcDa RleDecompress16to16(pSrcData, SrcSize, interleaved->TempBuffer, scanline, nWidth, nHeight); status = freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, - nWidth, nHeight, interleaved->TempBuffer, SrcFormat, scanline, 0, 0); + nWidth, nHeight, interleaved->TempBuffer, SrcFormat, scanline, 0, 0, palette); } else if (bpp == 8) { @@ -337,7 +337,7 @@ int interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pSrcDa RleDecompress8to8(pSrcData, SrcSize, interleaved->TempBuffer, scanline, nWidth, nHeight); status = freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, - nWidth, nHeight, interleaved->TempBuffer, SrcFormat, scanline, 0, 0); + nWidth, nHeight, interleaved->TempBuffer, SrcFormat, scanline, 0, 0, palette); } else { diff --git a/libfreerdp/codec/mppc.c b/libfreerdp/codec/mppc.c index 89c18db42..f975b2303 100644 --- a/libfreerdp/codec/mppc.c +++ b/libfreerdp/codec/mppc.c @@ -28,6 +28,8 @@ #include +#define TAG FREERDP_TAG("codec.mppc") + #define MPPC_MATCH_INDEX(_sym1, _sym2, _sym3) \ ((((MPPC_MATCH_TABLE[_sym3] << 16) + (MPPC_MATCH_TABLE[_sym2] << 8) + MPPC_MATCH_TABLE[_sym1]) & 0x07FFF000) >> 12) @@ -413,7 +415,7 @@ int mppc_decompress(MPPC_CONTEXT* mppc, BYTE* pSrcData, UINT32 SrcSize, BYTE** p } #ifdef DEBUG_MPPC - DEBUG_MSG("<%d,%d>\n", (int) CopyOffset, (int) LengthOfMatch); + WLog_DBG(TAG, "<%d,%d>", (int) CopyOffset, (int) LengthOfMatch); #endif SrcPtr = HistoryPtr - CopyOffset; @@ -555,7 +557,7 @@ int mppc_compress(MPPC_CONTEXT* mppc, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppD accumulator = Sym1; #ifdef DEBUG_MPPC - DEBUG_MSG("%c", accumulator); + WLog_DBG(TAG, "%c", accumulator); #endif if (accumulator < 0x80) @@ -589,7 +591,7 @@ int mppc_compress(MPPC_CONTEXT* mppc, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppD } #ifdef DEBUG_MPPC - DEBUG_MSG("<%d,%d>", (int) CopyOffset, (int) LengthOfMatch); + WLog_DBG(TAG, "<%d,%d>", (int) CopyOffset, (int) LengthOfMatch); #endif /* Encode CopyOffset */ @@ -764,7 +766,7 @@ int mppc_compress(MPPC_CONTEXT* mppc, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppD accumulator = *pSrcPtr; #ifdef DEBUG_MPPC - DEBUG_MSG("%c", accumulator); + WLog_DBG(TAG, "%c", accumulator); #endif if (accumulator < 0x80) @@ -798,10 +800,6 @@ int mppc_compress(MPPC_CONTEXT* mppc, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppD mppc->HistoryPtr = HistoryPtr; mppc->HistoryOffset = HistoryPtr - HistoryBuffer; -#ifdef DEBUG_MPPC - DEBUG_MSG("\n"); -#endif - return 1; } diff --git a/libfreerdp/codec/ncrush.c b/libfreerdp/codec/ncrush.c index f8faab292..34ea35249 100644 --- a/libfreerdp/codec/ncrush.c +++ b/libfreerdp/codec/ncrush.c @@ -25,9 +25,11 @@ #include #include -#include +#include #include +#define TAG FREERDP_TAG("codec") + UINT16 HuffTableLEC[8192] = { 0x510B, 0x611F, 0x610D, 0x9027, 0x6000, 0x7105, 0x6117, 0xA068, 0x5111, 0x7007, 0x6113, 0x90C0, 0x6108, 0x8018, 0x611B, 0xA0B3, @@ -1848,8 +1850,8 @@ int ncrush_decompress(NCRUSH_CONTEXT* ncrush, BYTE* pSrcData, UINT32 SrcSize, BY if (HistoryPtr >= HistoryBufferEnd) { - DEBUG_WARN( "ncrush_decompress error: HistoryPtr (%p) >= HistoryBufferEnd (%p)\n", - HistoryPtr, HistoryBufferEnd); + WLog_ERR(TAG, "ncrush_decompress error: HistoryPtr (%p) >= HistoryBufferEnd (%p)", + HistoryPtr, HistoryBufferEnd); return -1003; } @@ -2022,7 +2024,7 @@ int ncrush_decompress(NCRUSH_CONTEXT* ncrush, BYTE* pSrcData, UINT32 SrcSize, BY if (ncrush->HistoryBufferFence != 0xABABABAB) { - DEBUG_WARN( "NCrushDecompress: history buffer fence was overwritten, potential buffer overflow detected!\n"); + WLog_ERR(TAG, "NCrushDecompress: history buffer fence was overwritten, potential buffer overflow detected!"); return -1007; } @@ -2696,7 +2698,7 @@ NCRUSH_CONTEXT* ncrush_context_new(BOOL Compressor) ncrush->HistoryPtr = &(ncrush->HistoryBuffer[ncrush->HistoryOffset]); if (ncrush_generate_tables(ncrush) < 0) - DEBUG_MSG("ncrush_context_new: failed to initialize tables\n"); + WLog_DBG(TAG, "ncrush_context_new: failed to initialize tables"); ncrush_context_reset(ncrush, FALSE); } diff --git a/libfreerdp/codec/nsc_types.h b/libfreerdp/codec/nsc_types.h index fe5cfd2f6..28553b8c0 100644 --- a/libfreerdp/codec/nsc_types.h +++ b/libfreerdp/codec/nsc_types.h @@ -29,7 +29,7 @@ #include #include -#include + #include #define ROUND_UP_TO(_b, _n) (_b + ((~(_b & (_n-1)) + 0x1) & (_n-1))) diff --git a/libfreerdp/codec/planar.c b/libfreerdp/codec/planar.c index 52b9d4086..31b618c4e 100644 --- a/libfreerdp/codec/planar.c +++ b/libfreerdp/codec/planar.c @@ -25,10 +25,12 @@ #include #include -#include +#include #include #include +#define TAG FREERDP_TAG("codec") + static int planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, int nWidth, int nHeight) { int x, y; @@ -124,7 +126,7 @@ static int planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, BYT if ((srcp - pSrcData) > SrcSize) { - DEBUG_WARN( "planar_decompress_plane_rle: error reading input buffer\n"); + WLog_ERR(TAG, "error reading input buffer"); return -1; } @@ -144,7 +146,7 @@ static int planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, BYT if (((dstp + (cRawBytes + nRunLength)) - currentScanline) > nWidth * 4) { - DEBUG_WARN( "planar_decompress_plane_rle: too many pixels in scanline\n"); + WLog_ERR(TAG, "too many pixels in scanline"); return -1; } @@ -347,7 +349,7 @@ int planar_decompress(BITMAP_PLANAR_CONTEXT* planar, BYTE* pSrcData, UINT32 SrcS rle = (FormatHeader & PLANAR_FORMAT_HEADER_RLE) ? TRUE : FALSE; alpha = (FormatHeader & PLANAR_FORMAT_HEADER_NA) ? FALSE : TRUE; - //printf("CLL: %d CS: %d RLE: %d ALPHA: %d\n", cll, cs, rle, alpha); + //WLog_INFO(TAG, "CLL: %d CS: %d RLE: %d ALPHA: %d", cll, cs, rle, alpha); if (!cll && cs) return -1; /* Chroma subsampling requires YCoCg */ @@ -536,7 +538,7 @@ int planar_decompress(BITMAP_PLANAR_CONTEXT* planar, BYTE* pSrcData, UINT32 SrcS { if (cs) { - fprintf(stderr, "Chroma subsampling unimplemented\n"); + WLog_ERR(TAG, "Chroma subsampling unimplemented"); return -1; } @@ -606,7 +608,7 @@ int planar_decompress(BITMAP_PLANAR_CONTEXT* planar, BYTE* pSrcData, UINT32 SrcS pDstData = *ppDstData; status = freerdp_image_copy(pDstData, DstFormat, -1, 0, 0, nWidth, nHeight, - planar->TempBuffer, PIXEL_FORMAT_XRGB32, -1, 0, 0); + planar->TempBuffer, PIXEL_FORMAT_XRGB32, -1, 0, 0, NULL); } return status; @@ -1036,8 +1038,7 @@ BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context, BYTE* data, context->rlePlanes[3] = &context->rlePlanesBuffer[offset]; offset += dstSizes[3]; - - //DEBUG_MSG("R: [%d/%d] G: [%d/%d] B: [%d/%d]\n", + //WLog_DBG(TAG, "R: [%d/%d] G: [%d/%d] B: [%d/%d]\n", // dstSizes[1], planeSize, dstSizes[2], planeSize, dstSizes[3], planeSize); } } diff --git a/libfreerdp/codec/progressive.c b/libfreerdp/codec/progressive.c index 1fd5a7d25..0704403f1 100644 --- a/libfreerdp/codec/progressive.c +++ b/libfreerdp/codec/progressive.c @@ -28,10 +28,13 @@ #include #include #include +#include #include "rfx_differential.h" #include "rfx_quantization.h" +#define TAG FREERDP_TAG("codec.progressive") + const char* progressive_get_block_type_string(UINT16 blockType) { switch (blockType) @@ -722,8 +725,8 @@ int progressive_decompress_tile_first(PROGRESSIVE_CONTEXT* progressive, RFX_PROG diff = tile->flags & RFX_TILE_DIFFERENCE; #if 0 - printf("ProgressiveTileFirst: quantIdx Y: %d Cb: %d Cr: %d xIdx: %d yIdx: %d flags: 0x%02X quality: %d yLen: %d cbLen: %d crLen: %d tailLen: %d\n", - tile->quantIdxY, tile->quantIdxCb, tile->quantIdxCr, tile->xIdx, tile->yIdx, tile->flags, tile->quality, tile->yLen, tile->cbLen, tile->crLen, tile->tailLen); + WLog_INFO(TAG, "ProgressiveTileFirst: quantIdx Y: %d Cb: %d Cr: %d xIdx: %d yIdx: %d flags: 0x%02X quality: %d yLen: %d cbLen: %d crLen: %d tailLen: %d", + tile->quantIdxY, tile->quantIdxCb, tile->quantIdxCr, tile->xIdx, tile->yIdx, tile->flags, tile->quality, tile->yLen, tile->cbLen, tile->crLen, tile->tailLen); #endif region = &(progressive->region); @@ -1077,7 +1080,7 @@ int progressive_rfx_upgrade_component(PROGRESSIVE_CONTEXT* progressive, RFX_COMP if (srlLen) pSrlLen = (int) ((((float) aSrlLen) / ((float) srlLen)) * 100.0f); - printf("RAW: %d/%d %d%% (%d/%d:%d)\tSRL: %d/%d %d%% (%d/%d:%d)\n", + WLog_INFO(TAG, "RAW: %d/%d %d%% (%d/%d:%d)\tSRL: %d/%d %d%% (%d/%d:%d)", aRawLen, rawLen, pRawLen, state.raw->position, rawLen * 8, (rawLen * 8) - state.raw->position, aSrlLen, srlLen, pSrlLen, state.srl->position, srlLen * 8, @@ -1129,7 +1132,7 @@ int progressive_decompress_tile_upgrade(PROGRESSIVE_CONTEXT* progressive, RFX_PR tile->pass++; #if 0 - printf("ProgressiveTileUpgrade: pass: %d quantIdx Y: %d Cb: %d Cr: %d xIdx: %d yIdx: %d quality: %d ySrlLen: %d yRawLen: %d cbSrlLen: %d cbRawLen: %d crSrlLen: %d crRawLen: %d\n", + WLog_INFO(TAG, "ProgressiveTileUpgrade: pass: %d quantIdx Y: %d Cb: %d Cr: %d xIdx: %d yIdx: %d quality: %d ySrlLen: %d yRawLen: %d cbSrlLen: %d cbRawLen: %d crSrlLen: %d crRawLen: %d", tile->pass, tile->quantIdxY, tile->quantIdxCb, tile->quantIdxCr, tile->xIdx, tile->yIdx, tile->quality, tile->ySrlLen, tile->yRawLen, tile->cbSrlLen, tile->cbRawLen, tile->crSrlLen, tile->crRawLen); #endif @@ -1167,11 +1170,11 @@ int progressive_decompress_tile_upgrade(PROGRESSIVE_CONTEXT* progressive, RFX_PR quantProgCr = &(quantProg->crQuantValues); if (!progressive_rfx_quant_cmp_equal(quantY, &(tile->yQuant))) - printf("warning: non-progressive quantY has changed!\n"); + WLog_WARN(TAG, "non-progressive quantY has changed!"); if (!progressive_rfx_quant_cmp_equal(quantCb, &(tile->cbQuant))) - printf("warning: non-progressive quantCb has changed!\n"); + WLog_WARN(TAG, "non-progressive quantCb has changed!"); if (!progressive_rfx_quant_cmp_equal(quantCr, &(tile->crQuant))) - printf("warning: non-progressive quantCr has changed!\n"); + WLog_WARN(TAG, "non-progressive quantCr has changed!"); progressive_rfx_quant_add(quantY, quantProgY, &yBitPos); progressive_rfx_quant_add(quantCb, quantProgCb, &cbBitPos); @@ -1275,7 +1278,7 @@ int progressive_process_tiles(PROGRESSIVE_CONTEXT* progressive, BYTE* blocks, UI blockLen = *((UINT32*) &block[boffset + 2]); /* blockLen (4 bytes) */ boffset += 6; - //printf("%s\n", progressive_get_block_type_string(blockType)); + //WLog_INFO(TAG, "%s", progressive_get_block_type_string(blockType)); if ((blocksLen - offset) < blockLen) return -1003; @@ -1567,8 +1570,7 @@ int progressive_decompress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UIN blockType = *((UINT16*) &block[boffset + 0]); /* blockType (2 bytes) */ blockLen = *((UINT32*) &block[boffset + 2]); /* blockLen (4 bytes) */ boffset += 6; - - //printf("%s\n", progressive_get_block_type_string(blockType)); + //WLog_INFO(TAG, "%s", progressive_get_block_type_string(blockType)); if ((blocksLen - offset) < blockLen) return -1003; @@ -1762,7 +1764,7 @@ int progressive_decompress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UIN if (!region->tiles) return -1; - //printf("numRects: %d numTiles: %d numQuant: %d numProgQuant: %d\n", + //WLog_INFO(TAG, "numRects: %d numTiles: %d numQuant: %d numProgQuant: %d", // region->numRects, region->numTiles, region->numQuant, region->numProgQuant); status = progressive_process_tiles(progressive, &block[boffset], region->tileDataSize, surface); @@ -1812,7 +1814,7 @@ PROGRESSIVE_CONTEXT* progressive_context_new(BOOL Compressor) { progressive->Compressor = Compressor; - progressive->log = WLog_Get("com.freerdp.codec.progressive"); + progressive->log = WLog_Get(TAG); progressive->bufferPool = BufferPool_New(TRUE, (8192 + 32) * 3, 16); diff --git a/libfreerdp/codec/region.c b/libfreerdp/codec/region.c index 2c01d265e..c1d433760 100644 --- a/libfreerdp/codec/region.c +++ b/libfreerdp/codec/region.c @@ -19,9 +19,11 @@ #include #include -#include +#include #include +#define TAG FREERDP_TAG("codec") + /* * The functions in this file implement the Region abstraction largely inspired from * pixman library. The following comment is taken from the pixman code. @@ -225,20 +227,18 @@ void region16_print(const REGION16 *region) int currentBandY = -1; rects = region16_rects(region, &nbRects); - DEBUG_WARN( "nrects=%d", nbRects); + WLog_DBG(TAG, "nrects=%d", nbRects); for (i = 0; i < nbRects; i++, rects++) { if (rects->top != currentBandY) { currentBandY = rects->top; - DEBUG_WARN( "\nband %d: ", currentBandY); + WLog_DBG(TAG, "\nband %d: ", currentBandY); } - DEBUG_WARN( "(%d,%d-%d,%d)", rects->left, rects->top, rects->right, rects->bottom); + WLog_DBG(TAG, "(%d,%d-%d,%d)", rects->left, rects->top, rects->right, rects->bottom); } - - DEBUG_WARN( "\n"); } void region16_copy_band_with_union(RECTANGLE_16 *dst, diff --git a/libfreerdp/codec/rfx.c b/libfreerdp/codec/rfx.c index 6a9743f35..38387302a 100644 --- a/libfreerdp/codec/rfx.c +++ b/libfreerdp/codec/rfx.c @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -52,6 +53,7 @@ #include "rfx_sse2.h" #include "rfx_neon.h" +#define TAG FREERDP_TAG("codec") #ifndef RFX_INIT_SIMD #define RFX_INIT_SIMD(_rfx_context) do { } while (0) @@ -376,7 +378,7 @@ void rfx_context_free(RFX_CONTEXT* context) free(priv->tileWorkParams); #ifdef WITH_PROFILER - DEBUG_WARN( "\nWARNING: Profiling results probably unusable with multithreaded RemoteFX codec!\n"); + WLog_VRB(TAG, "WARNING: Profiling results probably unusable with multithreaded RemoteFX codec!"); #endif } @@ -430,14 +432,14 @@ static BOOL rfx_process_message_sync(RFX_CONTEXT* context, wStream* s) /* RFX_SYNC */ if (Stream_GetRemainingLength(s) < 6) { - DEBUG_WARN("RfxSync packet too small"); + WLog_ERR(TAG, "RfxSync packet too small"); return FALSE; } Stream_Read_UINT32(s, magic); /* magic (4 bytes), 0xCACCACCA */ if (magic != WF_MAGIC) { - DEBUG_WARN("invalid magic number 0x%X", magic); + WLog_ERR(TAG, "invalid magic number 0x%X", magic); return FALSE; } @@ -445,7 +447,7 @@ static BOOL rfx_process_message_sync(RFX_CONTEXT* context, wStream* s) if (context->version != WF_VERSION_1_0) { - DEBUG_WARN("unknown version number 0x%X", context->version); + WLog_ERR(TAG, "unknown version number 0x%X", context->version); return FALSE; } @@ -460,20 +462,20 @@ static BOOL rfx_process_message_codec_versions(RFX_CONTEXT* context, wStream* s) if (Stream_GetRemainingLength(s) < 1) { - DEBUG_WARN("RfxCodecVersion packet too small"); + WLog_ERR(TAG, "RfxCodecVersion packet too small"); return FALSE; } Stream_Read_UINT8(s, numCodecs); /* numCodecs (1 byte), must be set to 0x01 */ if (numCodecs != 1) { - DEBUG_WARN("numCodecs: %d, expected:1", numCodecs); + WLog_ERR(TAG, "numCodecs: %d, expected:1", numCodecs); return FALSE; } if (Stream_GetRemainingLength(s) < (size_t) (2 * numCodecs)) { - DEBUG_WARN("RfxCodecVersion packet too small for numCodecs=%d", numCodecs); + WLog_ERR(TAG, "RfxCodecVersion packet too small for numCodecs=%d", numCodecs); return FALSE; } @@ -493,7 +495,7 @@ static BOOL rfx_process_message_channels(RFX_CONTEXT* context, wStream* s) if (Stream_GetRemainingLength(s) < 1) { - DEBUG_WARN("RfxMessageChannels packet too small"); + WLog_ERR(TAG, "RfxMessageChannels packet too small"); return FALSE; } @@ -504,13 +506,13 @@ static BOOL rfx_process_message_channels(RFX_CONTEXT* context, wStream* s) */ if (numChannels < 1) { - DEBUG_WARN("numChannels:%d, expected:1", numChannels); + WLog_ERR(TAG, "numChannels:%d, expected:1", numChannels); return TRUE; } if (Stream_GetRemainingLength(s) < (size_t) (numChannels * 5)) { - DEBUG_WARN("RfxMessageChannels packet too small for numChannels=%d", numChannels); + WLog_ERR(TAG, "RfxMessageChannels packet too small for numChannels=%d", numChannels); return FALSE; } @@ -536,7 +538,7 @@ static BOOL rfx_process_message_context(RFX_CONTEXT* context, wStream* s) if (Stream_GetRemainingLength(s) < 5) { - DEBUG_WARN("RfxMessageContext packet too small"); + WLog_ERR(TAG, "RfxMessageContext packet too small"); return FALSE; } @@ -572,7 +574,7 @@ static BOOL rfx_process_message_context(RFX_CONTEXT* context, wStream* s) break; default: - DEBUG_WARN("unknown RLGR algorithm."); + WLog_ERR(TAG, "unknown RLGR algorithm."); break; } @@ -586,7 +588,7 @@ static BOOL rfx_process_message_frame_begin(RFX_CONTEXT* context, RFX_MESSAGE* m if (Stream_GetRemainingLength(s) < 6) { - DEBUG_WARN("RfxMessageFrameBegin packet too small"); + WLog_ERR(TAG, "RfxMessageFrameBegin packet too small"); return FALSE; } @@ -609,7 +611,7 @@ static BOOL rfx_process_message_region(RFX_CONTEXT* context, RFX_MESSAGE* messag if (Stream_GetRemainingLength(s) < 3) { - DEBUG_WARN("RfxMessageRegion packet too small"); + WLog_ERR(TAG, "RfxMessageRegion packet too small"); return FALSE; } @@ -621,8 +623,7 @@ static BOOL rfx_process_message_region(RFX_CONTEXT* context, RFX_MESSAGE* messag /* Unfortunately, it isn't documented. It seems that server asks to clip whole session when numRects = 0. Issue: https://github.com/FreeRDP/FreeRDP/issues/1738 */ - - DEBUG_WARN("no rects. Clip whole session."); + WLog_ERR(TAG, "no rects. Clip whole session."); message->numRects = 1; message->rects = (RFX_RECT*) realloc(message->rects, message->numRects * sizeof(RFX_RECT)); if (!message->rects) @@ -637,7 +638,7 @@ static BOOL rfx_process_message_region(RFX_CONTEXT* context, RFX_MESSAGE* messag if (Stream_GetRemainingLength(s) < (size_t) (8 * message->numRects)) { - DEBUG_WARN("RfxMessageRegion packet too small for num_rects=%d", message->numRects); + WLog_ERR(TAG, "RfxMessageRegion packet too small for num_rects=%d", message->numRects); return FALSE; } @@ -692,7 +693,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa if (Stream_GetRemainingLength(s) < 14) { - DEBUG_WARN("RfxMessageTileSet packet too small"); + WLog_ERR(TAG, "RfxMessageTileSet packet too small"); return FALSE; } @@ -700,7 +701,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa if (subtype != CBT_TILESET) { - DEBUG_WARN("invalid subtype, expected CBT_TILESET."); + WLog_ERR(TAG, "invalid subtype, expected CBT_TILESET."); return FALSE; } @@ -712,7 +713,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa if (context->numQuant < 1) { - DEBUG_WARN("no quantization value."); + WLog_ERR(TAG, "no quantization value."); return TRUE; } @@ -720,7 +721,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa if (message->numTiles < 1) { - DEBUG_WARN("no tiles."); + WLog_ERR(TAG, "no tiles."); return TRUE; } @@ -733,7 +734,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa /* quantVals */ if (Stream_GetRemainingLength(s) < (size_t) (context->numQuant * 5)) { - DEBUG_WARN("RfxMessageTileSet packet too small for num_quants=%d", context->numQuant); + WLog_ERR(TAG, "RfxMessageTileSet packet too small for num_quants=%d", context->numQuant); return FALSE; } @@ -801,7 +802,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa /* RFX_TILE */ if (Stream_GetRemainingLength(s) < 6) { - DEBUG_WARN("RfxMessageTileSet packet too small to read tile %d/%d", i, message->numTiles); + WLog_ERR(TAG, "RfxMessageTileSet packet too small to read tile %d/%d", i, message->numTiles); rc = FALSE; break; } @@ -811,8 +812,8 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa if (Stream_GetRemainingLength(s) < blockLen - 6) { - DEBUG_WARN("RfxMessageTileSet not enough bytes to read tile %d/%d with blocklen=%d", - i, message->numTiles, blockLen); + WLog_ERR(TAG, "RfxMessageTileSet not enough bytes to read tile %d/%d with blocklen=%d", + i, message->numTiles, blockLen); rc = FALSE; break; } @@ -821,7 +822,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa if (blockType != CBT_TILE) { - DEBUG_WARN("unknown block type 0x%X, expected CBT_TILE (0xCAC3).", blockType); + WLog_ERR(TAG, "unknown block type 0x%X, expected CBT_TILE (0xCAC3).", blockType); break; } @@ -914,13 +915,13 @@ RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length if (blockLen == 0) { - DEBUG_WARN("zero blockLen"); + WLog_ERR(TAG, "zero blockLen"); break; } if (Stream_GetRemainingLength(s) < blockLen - 6) { - DEBUG_WARN("rfx_process_message: packet too small for blocklen=%d", blockLen); + WLog_ERR(TAG, "rfx_process_message: packet too small for blocklen=%d", blockLen); break; } @@ -934,7 +935,7 @@ RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length /* channelId (1 byte) must be set to 0x00 */ if (!Stream_SafeSeek(s, 2)) { - DEBUG_WARN("rfx_process_message: unable to skip RFX_CODEC_CHANNELT"); + WLog_ERR(TAG, "rfx_process_message: unable to skip RFX_CODEC_CHANNELT"); break; } } @@ -974,7 +975,7 @@ RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length break; default: - DEBUG_WARN("unknown blockType 0x%X", blockType); + WLog_ERR(TAG, "unknown blockType 0x%X", blockType); break; } @@ -1427,7 +1428,7 @@ out_clean_tiles: free(message->tiles); region16_uninit(&tilesRegion); out_free_message: - DEBUG_WARN( "remoteFx error\n"); + WLog_ERR(TAG, "remoteFx error"); region16_uninit(&rectsRegion); free(message); return 0; diff --git a/libfreerdp/codec/rfx_types.h b/libfreerdp/codec/rfx_types.h index 250c14964..3b93d83a5 100644 --- a/libfreerdp/codec/rfx_types.h +++ b/libfreerdp/codec/rfx_types.h @@ -29,13 +29,14 @@ #include #include -#include +#include #include +#define RFX_TAG FREERDP_TAG("codec.rfx") #ifdef WITH_DEBUG_RFX -#define DEBUG_RFX(fmt, ...) DEBUG_CLASS(RFX, fmt, ## __VA_ARGS__) +#define DEBUG_RFX(fmt, ...) WLog_DBG(RFX_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_RFX(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_RFX(fmt, ...) do { } while (0) #endif typedef struct _RFX_TILE_COMPOSE_WORK_PARAM RFX_TILE_COMPOSE_WORK_PARAM; diff --git a/libfreerdp/codec/test/CMakeLists.txt b/libfreerdp/codec/test/CMakeLists.txt index 6ce9c65c2..83574d8c2 100644 --- a/libfreerdp/codec/test/CMakeLists.txt +++ b/libfreerdp/codec/test/CMakeLists.txt @@ -21,12 +21,7 @@ create_test_sourcelist(${MODULE_PREFIX}_SRCS add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-codec) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} freerdp) set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}") diff --git a/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c b/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c index 765135b71..fe84a418c 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c @@ -910,7 +910,7 @@ int test_progressive_decode(PROGRESSIVE_CONTEXT* progressive, EGFX_SAMPLE_FILE f freerdp_image_copy(g_DstData, PIXEL_FORMAT_XRGB32, g_DstStep, nXDst, nYDst, nWidth, nHeight, tile->data, - PIXEL_FORMAT_XRGB32, 64 * 4, nXSrc, nYSrc); + PIXEL_FORMAT_XRGB32, 64 * 4, nXSrc, nYSrc, NULL); } size = bitmaps[pass].size; diff --git a/libfreerdp/codec/xcrush.c b/libfreerdp/codec/xcrush.c index cc7142d24..650ab3b30 100644 --- a/libfreerdp/codec/xcrush.c +++ b/libfreerdp/codec/xcrush.c @@ -25,8 +25,11 @@ #include #include +#include #include +#define TAG FREERDP_TAG("codec") + const char* xcrush_get_level_2_compression_flags_string(UINT32 flags) { flags &= 0xE0; @@ -990,7 +993,7 @@ int xcrush_compress(XCRUSH_CONTEXT* xcrush, BYTE* pSrcData, UINT32 SrcSize, BYTE OriginalData[1] = (BYTE) Level2ComprFlags; #if 0 - DEBUG_MSG("XCrushCompress: Level1ComprFlags: %s Level2ComprFlags: %s\n", + WLog_DBG(TAG, "XCrushCompress: Level1ComprFlags: %s Level2ComprFlags: %s", xcrush_get_level_1_compression_flags_string(Level1ComprFlags), xcrush_get_level_2_compression_flags_string(Level2ComprFlags)); #endif diff --git a/libfreerdp/common/CMakeLists.txt b/libfreerdp/common/CMakeLists.txt index 2bdca84a3..05cadf43c 100644 --- a/libfreerdp/common/CMakeLists.txt +++ b/libfreerdp/common/CMakeLists.txt @@ -23,32 +23,12 @@ set(${MODULE_PREFIX}_SRCS settings.c assistance.c) -add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT" - MONOLITHIC ${MONOLITHIC_BUILD} - SOURCES ${${MODULE_PREFIX}_SRCS} - EXPORT) +freerdp_module_add(${${MODULE_PREFIX}_SRCS}) -include_directories(${OPENSSL_INCLUDE_DIR}) -include_directories(${ZLIB_INCLUDE_DIRS}) +freerdp_include_directory_add(${OPENSSL_INCLUDE_DIR}) +freerdp_include_directory_add(${ZLIB_INCLUDE_DIRS}) -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION}) -endif() -set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "lib") - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} - ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES}) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -if(MONOLITHIC_BUILD) - set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) -else() - target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) - install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets) -endif() - -set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") +freerdp_library_add(${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES}) if(BUILD_TESTING) add_subdirectory(test) diff --git a/libfreerdp/common/assistance.c b/libfreerdp/common/assistance.c index 7f2e9566e..fa274b78a 100644 --- a/libfreerdp/common/assistance.c +++ b/libfreerdp/common/assistance.c @@ -34,12 +34,14 @@ #include #include -#include +#include #include #include #include +#define TAG FREERDP_TAG("common") + /** * Password encryption in establishing a remote assistance session of type 1: * http://blogs.msdn.com/b/openspecification/archive/2011/10/31/password-encryption-in-establishing-a-remote-assistance-session-of-type-1.aspx @@ -479,7 +481,7 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char* password, const char* pas int EncryptedSize; BYTE PasswordHash[16]; EVP_CIPHER_CTX rc4Ctx; - BYTE *pbIn, *pbOut; + BYTE* pbIn, *pbOut; int cbOut, cbIn, cbFinal; WCHAR* PasswordW = NULL; WCHAR* PassStubW = NULL; @@ -522,7 +524,7 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char* password, const char* pas if (!status) { - DEBUG_WARN( "EVP_CipherInit_ex failure\n"); + WLog_ERR(TAG, "EVP_CipherInit_ex failure"); return NULL; } @@ -530,7 +532,7 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char* password, const char* pas if (!status) { - DEBUG_WARN( "EVP_CipherInit_ex failure\n"); + WLog_ERR(TAG, "EVP_CipherInit_ex failure"); return NULL; } @@ -541,7 +543,7 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char* password, const char* pas if (!status) { - DEBUG_WARN( "EVP_CipherUpdate failure\n"); + WLog_ERR(TAG, "EVP_CipherUpdate failure"); return NULL; } @@ -549,7 +551,7 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char* password, const char* pas if (!status) { - DEBUG_WARN( "EVP_CipherFinal_ex failure\n"); + WLog_ERR(TAG, "EVP_CipherFinal_ex failure"); return NULL; } @@ -573,7 +575,7 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* file, const char* password) WCHAR* pbOutW = NULL; EVP_CIPHER_CTX aesDec; WCHAR* PasswordW = NULL; - BYTE *pbIn, *pbOut; + BYTE* pbIn, *pbOut; int cbOut, cbIn, cbFinal; BYTE DerivedKey[AES_BLOCK_SIZE]; BYTE InitializationVector[AES_BLOCK_SIZE]; @@ -591,7 +593,7 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* file, const char* password) SHA1_Final((void*) PasswordHash, &shaCtx); status = freerdp_assistance_crypt_derive_key_sha1(PasswordHash, sizeof(PasswordHash), - DerivedKey, sizeof(DerivedKey)); + DerivedKey, sizeof(DerivedKey)); if (status < 0) return -1; @@ -630,7 +632,7 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* file, const char* password) if (status != 1) { - DEBUG_WARN( "EVP_DecryptFinal_ex failure\n"); + WLog_ERR(TAG, "EVP_DecryptFinal_ex failure"); return -1; } @@ -652,9 +654,7 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* file, const char* password) free(pbOut); status = freerdp_assistance_parse_connection_string2(file); - - DEBUG_MSG("freerdp_assistance_parse_connection_string2: %d\n", status); - + WLog_DBG(TAG, "freerdp_assistance_parse_connection_string2: %d", status); return 1; } @@ -663,7 +663,7 @@ int freerdp_assistance_decrypt(rdpAssistanceFile* file, const char* password) int status = 1; file->EncryptedPassStub = freerdp_assistance_encrypt_pass_stub(password, - file->PassStub, &file->EncryptedPassStubLength); + file->PassStub, &file->EncryptedPassStubLength); if (!file->EncryptedPassStub) return -1; @@ -969,7 +969,7 @@ int freerdp_assistance_parse_file_buffer(rdpAssistanceFile* file, const char* bu if (status < 0) { - DEBUG_WARN( "freerdp_assistance_parse_connection_string1 failure: %d\n", status); + WLog_ERR(TAG, "freerdp_assistance_parse_connection_string1 failure: %d", status); return -1; } diff --git a/libfreerdp/common/settings.c b/libfreerdp/common/settings.c index 07956bee1..575ba2b9e 100644 --- a/libfreerdp/common/settings.c +++ b/libfreerdp/common/settings.c @@ -29,7 +29,9 @@ #include #include -#include +#include + +#define TAG FREERDP_TAG("common") int freerdp_addin_set_argument(ADDIN_ARGV* args, char* argument) { @@ -340,7 +342,7 @@ out_parallel_name_error: } - DEBUG_WARN( "%s: unknown device type %d\n", __FUNCTION__, device->Type); + WLog_ERR(TAG, "unknown device type %d", device->Type); return NULL; } @@ -1029,7 +1031,7 @@ BOOL freerdp_get_param_bool(rdpSettings* settings, int id) return settings->RedirectClipboard; default: - DEBUG_WARN( "freerdp_get_param_bool: unknown id: %d\n", id); + WLog_ERR(TAG, "freerdp_get_param_bool: unknown id: %d", id); return -1; } } @@ -1535,7 +1537,7 @@ int freerdp_set_param_bool(rdpSettings* settings, int id, BOOL param) break; default: - DEBUG_WARN( "freerdp_set_param_bool: unknown id %d (param = %d)\n", id, param); + WLog_ERR(TAG, "freerdp_set_param_bool: unknown id %d (param = %d)", id, param); return -1; } @@ -1556,7 +1558,7 @@ int freerdp_get_param_int(rdpSettings* settings, int id) return settings->YPan; default: - DEBUG_WARN( "freerdp_get_param_int: unknown id: %d\n", id); + WLog_ERR(TAG, "freerdp_get_param_int: unknown id: %d", id); return 0; } } @@ -1574,7 +1576,7 @@ int freerdp_set_param_int(rdpSettings* settings, int id, int param) break; default: - DEBUG_WARN( "freerdp_set_param_int: unknown id %d (param = %d)\n", id, param); + WLog_ERR(TAG, "freerdp_set_param_int: unknown id %d (param = %d)", id, param); return -1; } @@ -1820,7 +1822,7 @@ UINT32 freerdp_get_param_uint32(rdpSettings* settings, int id) return settings->DynamicChannelArraySize; default: - DEBUG_WARN( "freerdp_get_param_uint32: unknown id: %d\n", id); + WLog_ERR(TAG, "freerdp_get_param_uint32: unknown id: %d", id); return 0; } } @@ -2138,7 +2140,7 @@ int freerdp_set_param_uint32(rdpSettings* settings, int id, UINT32 param) break; default: - DEBUG_WARN( "freerdp_set_param_uint32: unknown id %d (param = %u)\n", id, param); + WLog_ERR(TAG, "freerdp_set_param_uint32: unknown id %d (param = %u)", id, param); return -1; } @@ -2156,7 +2158,7 @@ UINT64 freerdp_get_param_uint64(rdpSettings* settings, int id) return settings->ParentWindowId; default: - DEBUG_WARN( "freerdp_get_param_uint64: unknown id: %d\n", id); + WLog_ERR(TAG, "freerdp_get_param_uint64: unknown id: %d", id); return -1; } } @@ -2170,7 +2172,7 @@ int freerdp_set_param_uint64(rdpSettings* settings, int id, UINT64 param) break; default: - DEBUG_WARN( "freerdp_set_param_uint64: unknown id %d (param = %u)\n", id, (UINT32) param); + WLog_ERR(TAG, "freerdp_set_param_uint64: unknown id %d (param = %u)", id, (UINT32) param); return -1; } @@ -2320,7 +2322,7 @@ char* freerdp_get_param_string(rdpSettings* settings, int id) return settings->DrivesToRedirect; default: - DEBUG_WARN( "freerdp_get_param_string: unknown id: %d\n", id); + WLog_ERR(TAG, "freerdp_get_param_string: unknown id: %d", id); return NULL; } } @@ -2555,7 +2557,7 @@ int freerdp_set_param_string(rdpSettings* settings, int id, const char* param) break; default: - DEBUG_WARN( "freerdp_set_param_string: unknown id %d (param = %s)\n", id, param); + WLog_ERR(TAG, "unknown id %d (param = %s)", id, param); return -1; } @@ -2573,7 +2575,7 @@ double freerdp_get_param_double(rdpSettings* settings, int id) return settings->ScalingFactor; default: - DEBUG_WARN( "freerdp_get_param_double: unknown id: %d\n", id); + WLog_ERR(TAG, "unknown id: %d", id); return 0; } } diff --git a/libfreerdp/common/test/CMakeLists.txt b/libfreerdp/common/test/CMakeLists.txt index e8096b5df..3247101cc 100644 --- a/libfreerdp/common/test/CMakeLists.txt +++ b/libfreerdp/common/test/CMakeLists.txt @@ -13,12 +13,7 @@ create_test_sourcelist(${MODULE_PREFIX}_SRCS add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-common) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} freerdp) set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}") diff --git a/libfreerdp/core/CMakeLists.txt b/libfreerdp/core/CMakeLists.txt index 20961a213..0f020304a 100644 --- a/libfreerdp/core/CMakeLists.txt +++ b/libfreerdp/core/CMakeLists.txt @@ -18,10 +18,10 @@ set(MODULE_NAME "freerdp-core") set(MODULE_PREFIX "FREERDP_CORE") -add_definitions(-DEXT_PATH="${FREERDP_EXTENSION_PATH}") +freerdp_definition_add(-DEXT_PATH="${FREERDP_EXTENSION_PATH}") -include_directories(${OPENSSL_INCLUDE_DIR}) -include_directories(${ZLIB_INCLUDE_DIRS}) +freerdp_include_directory_add(${OPENSSL_INCLUDE_DIR}) +freerdp_include_directory_add(${ZLIB_INCLUDE_DIRS}) set(${MODULE_PREFIX}_GATEWAY_DIR "gateway") @@ -126,38 +126,13 @@ set(${MODULE_PREFIX}_SRCS set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_GATEWAY_SRCS}) -add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT" - MONOLITHIC ${MONOLITHIC_BUILD} - SOURCES ${${MODULE_PREFIX}_SRCS} - EXPORT) - -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) -endif() -set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "lib") +freerdp_module_add(${${MODULE_PREFIX}_SRCS}) if(WIN32) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ws2_32) + freerdp_library_add(ws2_32) else() - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${ZLIB_LIBRARIES}) + freerdp_library_add(${ZLIB_LIBRARIES}) endif() -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${OPENSSL_LIBRARIES}) - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} INTERNAL - MODULE freerdp - MODULES freerdp-crypto freerdp-codec freerdp-locale freerdp-common freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -if(MONOLITHIC_BUILD) - set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) -else() - target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) - install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets) -endif() - -set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") - - +freerdp_library_add(${OPENSSL_LIBRARIES}) diff --git a/libfreerdp/core/autodetect.h b/libfreerdp/core/autodetect.h index b5823c122..59886b39a 100644 --- a/libfreerdp/core/autodetect.h +++ b/libfreerdp/core/autodetect.h @@ -25,6 +25,7 @@ typedef struct rdp_autodetect rdpAutoDetect; #include "rdp.h" #include +#include #include #include @@ -49,10 +50,11 @@ int rdp_recv_autodetect_packet(rdpRdp* rdp, wStream* s); rdpAutoDetect* autodetect_new(void); void autodetect_free(rdpAutoDetect* autodetect); +#define AUTODETECT_TAG FREERDP_TAG("core.autodetect") #ifdef WITH_DEBUG_AUTODETECT -#define DEBUG_AUTODETECT(fmt, ...) DEBUG_CLASS(AUTODETECT, fmt, ## __VA_ARGS__) +#define DEBUG_AUTODETECT(fmt, ...) WLog_DBG(AUTODETECT_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_AUTODETECT(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_AUTODETECT(fmt, ...) do { } while (0) #endif #endif /* __AUTODETECT_H */ diff --git a/libfreerdp/core/bulk.c b/libfreerdp/core/bulk.c index cfd8b8ea4..0974d7cf6 100644 --- a/libfreerdp/core/bulk.c +++ b/libfreerdp/core/bulk.c @@ -81,23 +81,23 @@ int bulk_compress_validate(rdpBulk* bulk, BYTE* pSrcData, UINT32 SrcSize, BYTE** if (status < 0) { - DEBUG_MSG("compression/decompression failure\n"); + WLog_DBG(TAG, "compression/decompression failure"); return status; } if (_DstSize != SrcSize) { - DEBUG_MSG("compression/decompression size mismatch: Actual: %d, Expected: %d\n", _DstSize, SrcSize); + WLog_DBG(TAG, "compression/decompression size mismatch: Actual: %d, Expected: %d", _DstSize, SrcSize); return -1; } if (memcmp(_pDstData, pSrcData, SrcSize) != 0) { - DEBUG_MSG("compression/decompression input/output mismatch! flags: 0x%04X\n", _Flags); + WLog_DBG(TAG, "compression/decompression input/output mismatch! flags: 0x%04X", _Flags); #if 1 - DEBUG_MSG("Actual:\n"); + WLog_DBG(TAG, "Actual:"); winpr_HexDump(TAG, WLOG_DEBUG, _pDstData, SrcSize); - DEBUG_MSG("Expected:\n"); + WLog_DBG(TAG, "Expected:"); winpr_HexDump(TAG, WLOG_DEBUG, pSrcData, SrcSize); #endif return -1; @@ -159,17 +159,17 @@ int bulk_decompress(rdpBulk* bulk, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstD CompressionRatio = metrics_write_bytes(metrics, UncompressedBytes, CompressedBytes); #ifdef WITH_BULK_DEBUG { - DEBUG_MSG("Decompress Type: %d Flags: %s (0x%04X) Compression Ratio: %f (%d / %d), Total: %f (%u / %u)\n", - type, bulk_get_compression_flags_string(flags), flags, - CompressionRatio, CompressedBytes, UncompressedBytes, - metrics->TotalCompressionRatio, (UINT32) metrics->TotalCompressedBytes, - (UINT32) metrics->TotalUncompressedBytes); + WLog_DBG(TAG, "Decompress Type: %d Flags: %s (0x%04X) Compression Ratio: %f (%d / %d), Total: %f (%u / %u)", + type, bulk_get_compression_flags_string(flags), flags, + CompressionRatio, CompressedBytes, UncompressedBytes, + metrics->TotalCompressionRatio, (UINT32) metrics->TotalCompressedBytes, + (UINT32) metrics->TotalUncompressedBytes); } #endif } else { - DEBUG_WARN("Decompression failure!\n"); + WLog_ERR(TAG, "Decompression failure!"); } return status; @@ -222,11 +222,11 @@ int bulk_compress(rdpBulk* bulk, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstDat CompressionRatio = metrics_write_bytes(metrics, UncompressedBytes, CompressedBytes); #ifdef WITH_BULK_DEBUG { - DEBUG_MSG("Compress Type: %d Flags: %s (0x%04X) Compression Ratio: %f (%d / %d), Total: %f (%u / %u)\n", - bulk->CompressionLevel, bulk_get_compression_flags_string(*pFlags), *pFlags, - CompressionRatio, CompressedBytes, UncompressedBytes, - metrics->TotalCompressionRatio, (UINT32) metrics->TotalCompressedBytes, - (UINT32) metrics->TotalUncompressedBytes); + WLog_DBG(TAG, "Compress Type: %d Flags: %s (0x%04X) Compression Ratio: %f (%d / %d), Total: %f (%u / %u)", + bulk->CompressionLevel, bulk_get_compression_flags_string(*pFlags), *pFlags, + CompressionRatio, CompressedBytes, UncompressedBytes, + metrics->TotalCompressionRatio, (UINT32) metrics->TotalCompressedBytes, + (UINT32) metrics->TotalUncompressedBytes); } #endif } diff --git a/libfreerdp/core/capabilities.c b/libfreerdp/core/capabilities.c index 91bc8a931..2449ff7a2 100644 --- a/libfreerdp/core/capabilities.c +++ b/libfreerdp/core/capabilities.c @@ -27,6 +27,10 @@ #include #include +#include + +#define TAG FREERDP_TAG("core.capabilities") + #ifdef WITH_DEBUG_CAPABILITIES const char* const CAPSET_TYPE_STRINGS[] = @@ -262,8 +266,7 @@ BOOL rdp_print_general_capability_set(wStream* s, UINT16 length) if (length < 24) return FALSE; - DEBUG_WARN( "GeneralCapabilitySet (length %d):\n", length); - + WLog_INFO(TAG, "GeneralCapabilitySet (length %d):", length); Stream_Read_UINT16(s, osMajorType); /* osMajorType (2 bytes) */ Stream_Read_UINT16(s, osMinorType); /* osMinorType (2 bytes) */ Stream_Read_UINT16(s, protocolVersion); /* protocolVersion (2 bytes) */ @@ -275,19 +278,17 @@ BOOL rdp_print_general_capability_set(wStream* s, UINT16 length) Stream_Read_UINT16(s, generalCompressionLevel); /* generalCompressionLevel (2 bytes) */ Stream_Read_UINT8(s, refreshRectSupport); /* refreshRectSupport (1 byte) */ Stream_Read_UINT8(s, suppressOutputSupport); /* suppressOutputSupport (1 byte) */ - - DEBUG_WARN( "\tosMajorType: 0x%04X\n", osMajorType); - DEBUG_WARN( "\tosMinorType: 0x%04X\n", osMinorType); - DEBUG_WARN( "\tprotocolVersion: 0x%04X\n", protocolVersion); - DEBUG_WARN( "\tpad2OctetsA: 0x%04X\n", pad2OctetsA); - DEBUG_WARN( "\tgeneralCompressionTypes: 0x%04X\n", generalCompressionTypes); - DEBUG_WARN( "\textraFlags: 0x%04X\n", extraFlags); - DEBUG_WARN( "\tupdateCapabilityFlag: 0x%04X\n", updateCapabilityFlag); - DEBUG_WARN( "\tremoteUnshareFlag: 0x%04X\n", remoteUnshareFlag); - DEBUG_WARN( "\tgeneralCompressionLevel: 0x%04X\n", generalCompressionLevel); - DEBUG_WARN( "\trefreshRectSupport: 0x%02X\n", refreshRectSupport); - DEBUG_WARN( "\tsuppressOutputSupport: 0x%02X\n", suppressOutputSupport); - + WLog_INFO(TAG, "\tosMajorType: 0x%04X", osMajorType); + WLog_INFO(TAG, "\tosMinorType: 0x%04X", osMinorType); + WLog_INFO(TAG, "\tprotocolVersion: 0x%04X", protocolVersion); + WLog_INFO(TAG, "\tpad2OctetsA: 0x%04X", pad2OctetsA); + WLog_INFO(TAG, "\tgeneralCompressionTypes: 0x%04X", generalCompressionTypes); + WLog_INFO(TAG, "\textraFlags: 0x%04X", extraFlags); + WLog_INFO(TAG, "\tupdateCapabilityFlag: 0x%04X", updateCapabilityFlag); + WLog_INFO(TAG, "\tremoteUnshareFlag: 0x%04X", remoteUnshareFlag); + WLog_INFO(TAG, "\tgeneralCompressionLevel: 0x%04X", generalCompressionLevel); + WLog_INFO(TAG, "\trefreshRectSupport: 0x%02X", refreshRectSupport); + WLog_INFO(TAG, "\tsuppressOutputSupport: 0x%02X", suppressOutputSupport); return TRUE; } @@ -418,8 +419,7 @@ BOOL rdp_print_bitmap_capability_set(wStream* s, UINT16 length) BYTE drawingFlags; UINT16 multipleRectangleSupport; UINT16 pad2OctetsB; - - DEBUG_WARN( "BitmapCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "BitmapCapabilitySet (length %d):", length); if (length < 28) return FALSE; @@ -437,21 +437,19 @@ BOOL rdp_print_bitmap_capability_set(wStream* s, UINT16 length) Stream_Read_UINT8(s, drawingFlags); /* drawingFlags (1 byte) */ Stream_Read_UINT16(s, multipleRectangleSupport); /* multipleRectangleSupport (2 bytes) */ Stream_Read_UINT16(s, pad2OctetsB); /* pad2OctetsB (2 bytes) */ - - DEBUG_WARN( "\tpreferredBitsPerPixel: 0x%04X\n", preferredBitsPerPixel); - DEBUG_WARN( "\treceive1BitPerPixel: 0x%04X\n", receive1BitPerPixel); - DEBUG_WARN( "\treceive4BitsPerPixel: 0x%04X\n", receive4BitsPerPixel); - DEBUG_WARN( "\treceive8BitsPerPixel: 0x%04X\n", receive8BitsPerPixel); - DEBUG_WARN( "\tdesktopWidth: 0x%04X\n", desktopWidth); - DEBUG_WARN( "\tdesktopHeight: 0x%04X\n", desktopHeight); - DEBUG_WARN( "\tpad2Octets: 0x%04X\n", pad2Octets); - DEBUG_WARN( "\tdesktopResizeFlag: 0x%04X\n", desktopResizeFlag); - DEBUG_WARN( "\tbitmapCompressionFlag: 0x%04X\n", bitmapCompressionFlag); - DEBUG_WARN( "\thighColorFlags: 0x%02X\n", highColorFlags); - DEBUG_WARN( "\tdrawingFlags: 0x%02X\n", drawingFlags); - DEBUG_WARN( "\tmultipleRectangleSupport: 0x%04X\n", multipleRectangleSupport); - DEBUG_WARN( "\tpad2OctetsB: 0x%04X\n", pad2OctetsB); - + WLog_INFO(TAG, "\tpreferredBitsPerPixel: 0x%04X", preferredBitsPerPixel); + WLog_INFO(TAG, "\treceive1BitPerPixel: 0x%04X", receive1BitPerPixel); + WLog_INFO(TAG, "\treceive4BitsPerPixel: 0x%04X", receive4BitsPerPixel); + WLog_INFO(TAG, "\treceive8BitsPerPixel: 0x%04X", receive8BitsPerPixel); + WLog_INFO(TAG, "\tdesktopWidth: 0x%04X", desktopWidth); + WLog_INFO(TAG, "\tdesktopHeight: 0x%04X", desktopHeight); + WLog_INFO(TAG, "\tpad2Octets: 0x%04X", pad2Octets); + WLog_INFO(TAG, "\tdesktopResizeFlag: 0x%04X", desktopResizeFlag); + WLog_INFO(TAG, "\tbitmapCompressionFlag: 0x%04X", bitmapCompressionFlag); + WLog_INFO(TAG, "\thighColorFlags: 0x%02X", highColorFlags); + WLog_INFO(TAG, "\tdrawingFlags: 0x%02X", drawingFlags); + WLog_INFO(TAG, "\tmultipleRectangleSupport: 0x%04X", multipleRectangleSupport); + WLog_INFO(TAG, "\tpad2OctetsB: 0x%04X", pad2OctetsB); return TRUE; } @@ -595,8 +593,7 @@ BOOL rdp_print_order_capability_set(wStream* s, UINT16 length) UINT16 pad2OctetsD; UINT16 textANSICodePage; UINT16 pad2OctetsE; - - DEBUG_WARN( "OrderCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "OrderCapabilitySet (length %d):", length); if (length < 88) return FALSE; @@ -618,58 +615,54 @@ BOOL rdp_print_order_capability_set(wStream* s, UINT16 length) Stream_Read_UINT16(s, pad2OctetsD); /* pad2OctetsD (2 bytes) */ Stream_Read_UINT16(s, textANSICodePage); /* textANSICodePage (2 bytes) */ Stream_Read_UINT16(s, pad2OctetsE); /* pad2OctetsE (2 bytes) */ - - DEBUG_WARN( "\tpad4OctetsA: 0x%08X\n", pad4OctetsA); - DEBUG_WARN( "\tdesktopSaveXGranularity: 0x%04X\n", desktopSaveXGranularity); - DEBUG_WARN( "\tdesktopSaveYGranularity: 0x%04X\n", desktopSaveYGranularity); - DEBUG_WARN( "\tpad2OctetsA: 0x%04X\n", pad2OctetsA); - DEBUG_WARN( "\tmaximumOrderLevel: 0x%04X\n", maximumOrderLevel); - DEBUG_WARN( "\tnumberFonts: 0x%04X\n", numberFonts); - DEBUG_WARN( "\torderFlags: 0x%04X\n", orderFlags); - - DEBUG_WARN( "\torderSupport:\n"); - DEBUG_WARN( "\t\tDSTBLT: %d\n", orderSupport[NEG_DSTBLT_INDEX]); - DEBUG_WARN( "\t\tPATBLT: %d\n", orderSupport[NEG_PATBLT_INDEX]); - DEBUG_WARN( "\t\tSCRBLT: %d\n", orderSupport[NEG_SCRBLT_INDEX]); - DEBUG_WARN( "\t\tMEMBLT: %d\n", orderSupport[NEG_MEMBLT_INDEX]); - DEBUG_WARN( "\t\tMEM3BLT: %d\n", orderSupport[NEG_MEM3BLT_INDEX]); - DEBUG_WARN( "\t\tATEXTOUT: %d\n", orderSupport[NEG_ATEXTOUT_INDEX]); - DEBUG_WARN( "\t\tAEXTTEXTOUT: %d\n", orderSupport[NEG_AEXTTEXTOUT_INDEX]); - DEBUG_WARN( "\t\tDRAWNINEGRID: %d\n", orderSupport[NEG_DRAWNINEGRID_INDEX]); - DEBUG_WARN( "\t\tLINETO: %d\n", orderSupport[NEG_LINETO_INDEX]); - DEBUG_WARN( "\t\tMULTI_DRAWNINEGRID: %d\n", orderSupport[NEG_MULTI_DRAWNINEGRID_INDEX]); - DEBUG_WARN( "\t\tOPAQUE_RECT: %d\n", orderSupport[NEG_OPAQUE_RECT_INDEX]); - DEBUG_WARN( "\t\tSAVEBITMAP: %d\n", orderSupport[NEG_SAVEBITMAP_INDEX]); - DEBUG_WARN( "\t\tWTEXTOUT: %d\n", orderSupport[NEG_WTEXTOUT_INDEX]); - DEBUG_WARN( "\t\tMEMBLT_V2: %d\n", orderSupport[NEG_MEMBLT_V2_INDEX]); - DEBUG_WARN( "\t\tMEM3BLT_V2: %d\n", orderSupport[NEG_MEM3BLT_V2_INDEX]); - DEBUG_WARN( "\t\tMULTIDSTBLT: %d\n", orderSupport[NEG_MULTIDSTBLT_INDEX]); - DEBUG_WARN( "\t\tMULTIPATBLT: %d\n", orderSupport[NEG_MULTIPATBLT_INDEX]); - DEBUG_WARN( "\t\tMULTISCRBLT: %d\n", orderSupport[NEG_MULTISCRBLT_INDEX]); - DEBUG_WARN( "\t\tMULTIOPAQUERECT: %d\n", orderSupport[NEG_MULTIOPAQUERECT_INDEX]); - DEBUG_WARN( "\t\tFAST_INDEX: %d\n", orderSupport[NEG_FAST_INDEX_INDEX]); - DEBUG_WARN( "\t\tPOLYGON_SC: %d\n", orderSupport[NEG_POLYGON_SC_INDEX]); - DEBUG_WARN( "\t\tPOLYGON_CB: %d\n", orderSupport[NEG_POLYGON_CB_INDEX]); - DEBUG_WARN( "\t\tPOLYLINE: %d\n", orderSupport[NEG_POLYLINE_INDEX]); - DEBUG_WARN( "\t\tUNUSED23: %d\n", orderSupport[NEG_UNUSED23_INDEX]); - DEBUG_WARN( "\t\tFAST_GLYPH: %d\n", orderSupport[NEG_FAST_GLYPH_INDEX]); - DEBUG_WARN( "\t\tELLIPSE_SC: %d\n", orderSupport[NEG_ELLIPSE_SC_INDEX]); - DEBUG_WARN( "\t\tELLIPSE_CB: %d\n", orderSupport[NEG_ELLIPSE_CB_INDEX]); - DEBUG_WARN( "\t\tGLYPH_INDEX: %d\n", orderSupport[NEG_GLYPH_INDEX_INDEX]); - DEBUG_WARN( "\t\tGLYPH_WEXTTEXTOUT: %d\n", orderSupport[NEG_GLYPH_WEXTTEXTOUT_INDEX]); - DEBUG_WARN( "\t\tGLYPH_WLONGTEXTOUT: %d\n", orderSupport[NEG_GLYPH_WLONGTEXTOUT_INDEX]); - DEBUG_WARN( "\t\tGLYPH_WLONGEXTTEXTOUT: %d\n", orderSupport[NEG_GLYPH_WLONGEXTTEXTOUT_INDEX]); - DEBUG_WARN( "\t\tUNUSED31: %d\n", orderSupport[NEG_UNUSED31_INDEX]); - - DEBUG_WARN( "\ttextFlags: 0x%04X\n", textFlags); - DEBUG_WARN( "\torderSupportExFlags: 0x%04X\n", orderSupportExFlags); - DEBUG_WARN( "\tpad4OctetsB: 0x%08X\n", pad4OctetsB); - DEBUG_WARN( "\tdesktopSaveSize: 0x%08X\n", desktopSaveSize); - DEBUG_WARN( "\tpad2OctetsC: 0x%04X\n", pad2OctetsC); - DEBUG_WARN( "\tpad2OctetsD: 0x%04X\n", pad2OctetsD); - DEBUG_WARN( "\ttextANSICodePage: 0x%04X\n", textANSICodePage); - DEBUG_WARN( "\tpad2OctetsE: 0x%04X\n", pad2OctetsE); - + WLog_INFO(TAG, "\tpad4OctetsA: 0x%08X", pad4OctetsA); + WLog_INFO(TAG, "\tdesktopSaveXGranularity: 0x%04X", desktopSaveXGranularity); + WLog_INFO(TAG, "\tdesktopSaveYGranularity: 0x%04X", desktopSaveYGranularity); + WLog_INFO(TAG, "\tpad2OctetsA: 0x%04X", pad2OctetsA); + WLog_INFO(TAG, "\tmaximumOrderLevel: 0x%04X", maximumOrderLevel); + WLog_INFO(TAG, "\tnumberFonts: 0x%04X", numberFonts); + WLog_INFO(TAG, "\torderFlags: 0x%04X", orderFlags); + WLog_INFO(TAG, "\torderSupport:"); + WLog_INFO(TAG, "\t\tDSTBLT: %d", orderSupport[NEG_DSTBLT_INDEX]); + WLog_INFO(TAG, "\t\tPATBLT: %d", orderSupport[NEG_PATBLT_INDEX]); + WLog_INFO(TAG, "\t\tSCRBLT: %d", orderSupport[NEG_SCRBLT_INDEX]); + WLog_INFO(TAG, "\t\tMEMBLT: %d", orderSupport[NEG_MEMBLT_INDEX]); + WLog_INFO(TAG, "\t\tMEM3BLT: %d", orderSupport[NEG_MEM3BLT_INDEX]); + WLog_INFO(TAG, "\t\tATEXTOUT: %d", orderSupport[NEG_ATEXTOUT_INDEX]); + WLog_INFO(TAG, "\t\tAEXTTEXTOUT: %d", orderSupport[NEG_AEXTTEXTOUT_INDEX]); + WLog_INFO(TAG, "\t\tDRAWNINEGRID: %d", orderSupport[NEG_DRAWNINEGRID_INDEX]); + WLog_INFO(TAG, "\t\tLINETO: %d", orderSupport[NEG_LINETO_INDEX]); + WLog_INFO(TAG, "\t\tMULTI_DRAWNINEGRID: %d", orderSupport[NEG_MULTI_DRAWNINEGRID_INDEX]); + WLog_INFO(TAG, "\t\tOPAQUE_RECT: %d", orderSupport[NEG_OPAQUE_RECT_INDEX]); + WLog_INFO(TAG, "\t\tSAVEBITMAP: %d", orderSupport[NEG_SAVEBITMAP_INDEX]); + WLog_INFO(TAG, "\t\tWTEXTOUT: %d", orderSupport[NEG_WTEXTOUT_INDEX]); + WLog_INFO(TAG, "\t\tMEMBLT_V2: %d", orderSupport[NEG_MEMBLT_V2_INDEX]); + WLog_INFO(TAG, "\t\tMEM3BLT_V2: %d", orderSupport[NEG_MEM3BLT_V2_INDEX]); + WLog_INFO(TAG, "\t\tMULTIDSTBLT: %d", orderSupport[NEG_MULTIDSTBLT_INDEX]); + WLog_INFO(TAG, "\t\tMULTIPATBLT: %d", orderSupport[NEG_MULTIPATBLT_INDEX]); + WLog_INFO(TAG, "\t\tMULTISCRBLT: %d", orderSupport[NEG_MULTISCRBLT_INDEX]); + WLog_INFO(TAG, "\t\tMULTIOPAQUERECT: %d", orderSupport[NEG_MULTIOPAQUERECT_INDEX]); + WLog_INFO(TAG, "\t\tFAST_INDEX: %d", orderSupport[NEG_FAST_INDEX_INDEX]); + WLog_INFO(TAG, "\t\tPOLYGON_SC: %d", orderSupport[NEG_POLYGON_SC_INDEX]); + WLog_INFO(TAG, "\t\tPOLYGON_CB: %d", orderSupport[NEG_POLYGON_CB_INDEX]); + WLog_INFO(TAG, "\t\tPOLYLINE: %d", orderSupport[NEG_POLYLINE_INDEX]); + WLog_INFO(TAG, "\t\tUNUSED23: %d", orderSupport[NEG_UNUSED23_INDEX]); + WLog_INFO(TAG, "\t\tFAST_GLYPH: %d", orderSupport[NEG_FAST_GLYPH_INDEX]); + WLog_INFO(TAG, "\t\tELLIPSE_SC: %d", orderSupport[NEG_ELLIPSE_SC_INDEX]); + WLog_INFO(TAG, "\t\tELLIPSE_CB: %d", orderSupport[NEG_ELLIPSE_CB_INDEX]); + WLog_INFO(TAG, "\t\tGLYPH_INDEX: %d", orderSupport[NEG_GLYPH_INDEX_INDEX]); + WLog_INFO(TAG, "\t\tGLYPH_WEXTTEXTOUT: %d", orderSupport[NEG_GLYPH_WEXTTEXTOUT_INDEX]); + WLog_INFO(TAG, "\t\tGLYPH_WLONGTEXTOUT: %d", orderSupport[NEG_GLYPH_WLONGTEXTOUT_INDEX]); + WLog_INFO(TAG, "\t\tGLYPH_WLONGEXTTEXTOUT: %d", orderSupport[NEG_GLYPH_WLONGEXTTEXTOUT_INDEX]); + WLog_INFO(TAG, "\t\tUNUSED31: %d", orderSupport[NEG_UNUSED31_INDEX]); + WLog_INFO(TAG, "\ttextFlags: 0x%04X", textFlags); + WLog_INFO(TAG, "\torderSupportExFlags: 0x%04X", orderSupportExFlags); + WLog_INFO(TAG, "\tpad4OctetsB: 0x%08X", pad4OctetsB); + WLog_INFO(TAG, "\tdesktopSaveSize: 0x%08X", desktopSaveSize); + WLog_INFO(TAG, "\tpad2OctetsC: 0x%04X", pad2OctetsC); + WLog_INFO(TAG, "\tpad2OctetsD: 0x%04X", pad2OctetsD); + WLog_INFO(TAG, "\ttextANSICodePage: 0x%04X", textANSICodePage); + WLog_INFO(TAG, "\tpad2OctetsE: 0x%04X", pad2OctetsE); return TRUE; } @@ -753,8 +746,7 @@ BOOL rdp_print_bitmap_cache_capability_set(wStream* s, UINT16 length) UINT16 Cache1MaximumCellSize; UINT16 Cache2Entries; UINT16 Cache2MaximumCellSize; - - DEBUG_WARN( "BitmapCacheCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "BitmapCacheCapabilitySet (length %d):", length); if (length < 40) return FALSE; @@ -771,20 +763,18 @@ BOOL rdp_print_bitmap_cache_capability_set(wStream* s, UINT16 length) Stream_Read_UINT16(s, Cache1MaximumCellSize); /* Cache1MaximumCellSize (2 bytes) */ Stream_Read_UINT16(s, Cache2Entries); /* Cache2Entries (2 bytes) */ Stream_Read_UINT16(s, Cache2MaximumCellSize); /* Cache2MaximumCellSize (2 bytes) */ - - DEBUG_WARN( "\tpad1: 0x%08X\n", pad1); - DEBUG_WARN( "\tpad2: 0x%08X\n", pad2); - DEBUG_WARN( "\tpad3: 0x%08X\n", pad3); - DEBUG_WARN( "\tpad4: 0x%08X\n", pad4); - DEBUG_WARN( "\tpad5: 0x%08X\n", pad5); - DEBUG_WARN( "\tpad6: 0x%08X\n", pad6); - DEBUG_WARN( "\tCache0Entries: 0x%04X\n", Cache0Entries); - DEBUG_WARN( "\tCache0MaximumCellSize: 0x%04X\n", Cache0MaximumCellSize); - DEBUG_WARN( "\tCache1Entries: 0x%04X\n", Cache1Entries); - DEBUG_WARN( "\tCache1MaximumCellSize: 0x%04X\n", Cache1MaximumCellSize); - DEBUG_WARN( "\tCache2Entries: 0x%04X\n", Cache2Entries); - DEBUG_WARN( "\tCache2MaximumCellSize: 0x%04X\n", Cache2MaximumCellSize); - + WLog_INFO(TAG, "\tpad1: 0x%08X", pad1); + WLog_INFO(TAG, "\tpad2: 0x%08X", pad2); + WLog_INFO(TAG, "\tpad3: 0x%08X", pad3); + WLog_INFO(TAG, "\tpad4: 0x%08X", pad4); + WLog_INFO(TAG, "\tpad5: 0x%08X", pad5); + WLog_INFO(TAG, "\tpad6: 0x%08X", pad6); + WLog_INFO(TAG, "\tCache0Entries: 0x%04X", Cache0Entries); + WLog_INFO(TAG, "\tCache0MaximumCellSize: 0x%04X", Cache0MaximumCellSize); + WLog_INFO(TAG, "\tCache1Entries: 0x%04X", Cache1Entries); + WLog_INFO(TAG, "\tCache1MaximumCellSize: 0x%04X", Cache1MaximumCellSize); + WLog_INFO(TAG, "\tCache2Entries: 0x%04X", Cache2Entries); + WLog_INFO(TAG, "\tCache2MaximumCellSize: 0x%04X", Cache2MaximumCellSize); return TRUE; } @@ -838,8 +828,7 @@ BOOL rdp_print_control_capability_set(wStream* s, UINT16 length) UINT16 remoteDetachFlag; UINT16 controlInterest; UINT16 detachInterest; - - DEBUG_WARN( "ControlCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "ControlCapabilitySet (length %d):", length); if (length < 12) return FALSE; @@ -848,12 +837,10 @@ BOOL rdp_print_control_capability_set(wStream* s, UINT16 length) Stream_Read_UINT16(s, remoteDetachFlag); /* remoteDetachFlag (2 bytes) */ Stream_Read_UINT16(s, controlInterest); /* controlInterest (2 bytes) */ Stream_Read_UINT16(s, detachInterest); /* detachInterest (2 bytes) */ - - DEBUG_WARN( "\tcontrolFlags: 0x%04X\n", controlFlags); - DEBUG_WARN( "\tremoteDetachFlag: 0x%04X\n", remoteDetachFlag); - DEBUG_WARN( "\tcontrolInterest: 0x%04X\n", controlInterest); - DEBUG_WARN( "\tdetachInterest: 0x%04X\n", detachInterest); - + WLog_INFO(TAG, "\tcontrolFlags: 0x%04X", controlFlags); + WLog_INFO(TAG, "\tremoteDetachFlag: 0x%04X", remoteDetachFlag); + WLog_INFO(TAG, "\tcontrolInterest: 0x%04X", controlInterest); + WLog_INFO(TAG, "\tdetachInterest: 0x%04X", detachInterest); return TRUE; } @@ -907,8 +894,7 @@ BOOL rdp_print_window_activation_capability_set(wStream* s, UINT16 length) UINT16 helpKeyIndexFlag; UINT16 helpExtendedKeyFlag; UINT16 windowManagerKeyFlag; - - DEBUG_WARN( "WindowActivationCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "WindowActivationCapabilitySet (length %d):", length); if (length < 12) return FALSE; @@ -917,12 +903,10 @@ BOOL rdp_print_window_activation_capability_set(wStream* s, UINT16 length) Stream_Read_UINT16(s, helpKeyIndexFlag); /* helpKeyIndexFlag (2 bytes) */ Stream_Read_UINT16(s, helpExtendedKeyFlag); /* helpExtendedKeyFlag (2 bytes) */ Stream_Read_UINT16(s, windowManagerKeyFlag); /* windowManagerKeyFlag (2 bytes) */ - - DEBUG_WARN( "\thelpKeyFlag: 0x%04X\n", helpKeyFlag); - DEBUG_WARN( "\thelpKeyIndexFlag: 0x%04X\n", helpKeyIndexFlag); - DEBUG_WARN( "\thelpExtendedKeyFlag: 0x%04X\n", helpExtendedKeyFlag); - DEBUG_WARN( "\twindowManagerKeyFlag: 0x%04X\n", windowManagerKeyFlag); - + WLog_INFO(TAG, "\thelpKeyFlag: 0x%04X", helpKeyFlag); + WLog_INFO(TAG, "\thelpKeyIndexFlag: 0x%04X", helpKeyIndexFlag); + WLog_INFO(TAG, "\thelpExtendedKeyFlag: 0x%04X", helpExtendedKeyFlag); + WLog_INFO(TAG, "\twindowManagerKeyFlag: 0x%04X", windowManagerKeyFlag); return TRUE; } @@ -995,16 +979,13 @@ BOOL rdp_print_pointer_capability_set(wStream* s, UINT16 length) if (length < 10) return FALSE; - DEBUG_WARN( "PointerCapabilitySet (length %d):\n", length); - + WLog_INFO(TAG, "PointerCapabilitySet (length %d):", length); Stream_Read_UINT16(s, colorPointerFlag); /* colorPointerFlag (2 bytes) */ Stream_Read_UINT16(s, colorPointerCacheSize); /* colorPointerCacheSize (2 bytes) */ Stream_Read_UINT16(s, pointerCacheSize); /* pointerCacheSize (2 bytes) */ - - DEBUG_WARN( "\tcolorPointerFlag: 0x%04X\n", colorPointerFlag); - DEBUG_WARN( "\tcolorPointerCacheSize: 0x%04X\n", colorPointerCacheSize); - DEBUG_WARN( "\tpointerCacheSize: 0x%04X\n", pointerCacheSize); - + WLog_INFO(TAG, "\tcolorPointerFlag: 0x%04X", colorPointerFlag); + WLog_INFO(TAG, "\tcolorPointerCacheSize: 0x%04X", colorPointerCacheSize); + WLog_INFO(TAG, "\tpointerCacheSize: 0x%04X", pointerCacheSize); return TRUE; } @@ -1055,18 +1036,15 @@ BOOL rdp_print_share_capability_set(wStream* s, UINT16 length) { UINT16 nodeId; UINT16 pad2Octets; - - DEBUG_WARN( "ShareCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "ShareCapabilitySet (length %d):", length); if (length < 8) return FALSE; Stream_Read_UINT16(s, nodeId); /* nodeId (2 bytes) */ Stream_Read_UINT16(s, pad2Octets); /* pad2Octets (2 bytes) */ - - DEBUG_WARN( "\tnodeId: 0x%04X\n", nodeId); - DEBUG_WARN( "\tpad2Octets: 0x%04X\n", pad2Octets); - + WLog_INFO(TAG, "\tnodeId: 0x%04X", nodeId); + WLog_INFO(TAG, "\tpad2Octets: 0x%04X", pad2Octets); return TRUE; } @@ -1114,18 +1092,15 @@ BOOL rdp_print_color_cache_capability_set(wStream* s, UINT16 length) { UINT16 colorTableCacheSize; UINT16 pad2Octets; - - DEBUG_WARN( "ColorCacheCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "ColorCacheCapabilitySet (length %d):", length); if (length < 8) return FALSE; Stream_Read_UINT16(s, colorTableCacheSize); /* colorTableCacheSize (2 bytes) */ Stream_Read_UINT16(s, pad2Octets); /* pad2Octets (2 bytes) */ - - DEBUG_WARN( "\tcolorTableCacheSize: 0x%04X\n", colorTableCacheSize); - DEBUG_WARN( "\tpad2Octets: 0x%04X\n", pad2Octets); - + WLog_INFO(TAG, "\tcolorTableCacheSize: 0x%04X", colorTableCacheSize); + WLog_INFO(TAG, "\tpad2Octets: 0x%04X", pad2Octets); return TRUE; } @@ -1180,18 +1155,15 @@ BOOL rdp_print_sound_capability_set(wStream* s, UINT16 length) { UINT16 soundFlags; UINT16 pad2OctetsA; - - DEBUG_WARN( "SoundCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "SoundCapabilitySet (length %d):", length); if (length < 8) return FALSE; Stream_Read_UINT16(s, soundFlags); /* soundFlags (2 bytes) */ Stream_Read_UINT16(s, pad2OctetsA); /* pad2OctetsA (2 bytes) */ - - DEBUG_WARN( "\tsoundFlags: 0x%04X\n", soundFlags); - DEBUG_WARN( "\tpad2OctetsA: 0x%04X\n", pad2OctetsA); - + WLog_INFO(TAG, "\tsoundFlags: 0x%04X", soundFlags); + WLog_INFO(TAG, "\tpad2OctetsA: 0x%04X", pad2OctetsA); return TRUE; } @@ -1292,8 +1264,7 @@ BOOL rdp_print_input_capability_set(wStream* s, UINT16 length) UINT32 keyboardType; UINT32 keyboardSubType; UINT32 keyboardFunctionKey; - - DEBUG_WARN( "InputCapabilitySet (length %d)\n", length); + WLog_INFO(TAG, "InputCapabilitySet (length %d)", length); if (length < 88) return FALSE; @@ -1305,14 +1276,12 @@ BOOL rdp_print_input_capability_set(wStream* s, UINT16 length) Stream_Read_UINT32(s, keyboardSubType); /* keyboardSubType (4 bytes) */ Stream_Read_UINT32(s, keyboardFunctionKey); /* keyboardFunctionKeys (4 bytes) */ Stream_Seek(s, 64); /* imeFileName (64 bytes) */ - - DEBUG_WARN( "\tinputFlags: 0x%04X\n", inputFlags); - DEBUG_WARN( "\tpad2OctetsA: 0x%04X\n", pad2OctetsA); - DEBUG_WARN( "\tkeyboardLayout: 0x%08X\n", keyboardLayout); - DEBUG_WARN( "\tkeyboardType: 0x%08X\n", keyboardType); - DEBUG_WARN( "\tkeyboardSubType: 0x%08X\n", keyboardSubType); - DEBUG_WARN( "\tkeyboardFunctionKey: 0x%08X\n", keyboardFunctionKey); - + WLog_INFO(TAG, "\tinputFlags: 0x%04X", inputFlags); + WLog_INFO(TAG, "\tpad2OctetsA: 0x%04X", pad2OctetsA); + WLog_INFO(TAG, "\tkeyboardLayout: 0x%08X", keyboardLayout); + WLog_INFO(TAG, "\tkeyboardType: 0x%08X", keyboardType); + WLog_INFO(TAG, "\tkeyboardSubType: 0x%08X", keyboardSubType); + WLog_INFO(TAG, "\tkeyboardFunctionKey: 0x%08X", keyboardFunctionKey); return TRUE; } @@ -1360,8 +1329,7 @@ BOOL rdp_print_font_capability_set(wStream* s, UINT16 length) { UINT16 fontSupportFlags = 0; UINT16 pad2Octets = 0; - - DEBUG_WARN( "FontCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "FontCapabilitySet (length %d):", length); if (length > 4) Stream_Read_UINT16(s, fontSupportFlags); /* fontSupportFlags (2 bytes) */ @@ -1369,14 +1337,13 @@ BOOL rdp_print_font_capability_set(wStream* s, UINT16 length) if (length > 6) Stream_Read_UINT16(s, pad2Octets); /* pad2Octets (2 bytes) */ - DEBUG_WARN( "\tfontSupportFlags: 0x%04X\n", fontSupportFlags); - DEBUG_WARN( "\tpad2Octets: 0x%04X\n", pad2Octets); - + WLog_INFO(TAG, "\tfontSupportFlags: 0x%04X", fontSupportFlags); + WLog_INFO(TAG, "\tpad2Octets: 0x%04X", pad2Octets); return TRUE; } /** - * Read brush capability set.\n + * Read brush capability set. * @msdn{cc240564} * @param s stream * @param settings settings @@ -1416,16 +1383,13 @@ void rdp_write_brush_capability_set(wStream* s, rdpSettings* settings) BOOL rdp_print_brush_capability_set(wStream* s, UINT16 length) { UINT32 brushSupportLevel; - - DEBUG_WARN( "BrushCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "BrushCapabilitySet (length %d):", length); if (length < 8) return FALSE; Stream_Read_UINT32(s, brushSupportLevel); /* brushSupportLevel (4 bytes) */ - - DEBUG_WARN( "\tbrushSupportLevel: 0x%08X\n", brushSupportLevel); - + WLog_INFO(TAG, "\tbrushSupportLevel: 0x%08X", brushSupportLevel); return TRUE; } @@ -1525,8 +1489,7 @@ BOOL rdp_print_glyph_cache_capability_set(wStream* s, UINT16 length) GLYPH_CACHE_DEFINITION fragCache; UINT16 glyphSupportLevel; UINT16 pad2Octets; - - DEBUG_WARN( "GlyphCacheCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "GlyphCacheCapabilitySet (length %d):", length); if (length < 52) return FALSE; @@ -1546,21 +1509,19 @@ BOOL rdp_print_glyph_cache_capability_set(wStream* s, UINT16 length) Stream_Read_UINT16(s, glyphSupportLevel); /* glyphSupportLevel (2 bytes) */ Stream_Read_UINT16(s, pad2Octets); /* pad2Octets (2 bytes) */ - - DEBUG_WARN( "\tglyphCache0: Entries: %d MaximumCellSize: %d\n", glyphCache[0].cacheEntries, glyphCache[0].cacheMaximumCellSize); - DEBUG_WARN( "\tglyphCache1: Entries: %d MaximumCellSize: %d\n", glyphCache[1].cacheEntries, glyphCache[1].cacheMaximumCellSize); - DEBUG_WARN( "\tglyphCache2: Entries: %d MaximumCellSize: %d\n", glyphCache[2].cacheEntries, glyphCache[2].cacheMaximumCellSize); - DEBUG_WARN( "\tglyphCache3: Entries: %d MaximumCellSize: %d\n", glyphCache[3].cacheEntries, glyphCache[3].cacheMaximumCellSize); - DEBUG_WARN( "\tglyphCache4: Entries: %d MaximumCellSize: %d\n", glyphCache[4].cacheEntries, glyphCache[4].cacheMaximumCellSize); - DEBUG_WARN( "\tglyphCache5: Entries: %d MaximumCellSize: %d\n", glyphCache[5].cacheEntries, glyphCache[5].cacheMaximumCellSize); - DEBUG_WARN( "\tglyphCache6: Entries: %d MaximumCellSize: %d\n", glyphCache[6].cacheEntries, glyphCache[6].cacheMaximumCellSize); - DEBUG_WARN( "\tglyphCache7: Entries: %d MaximumCellSize: %d\n", glyphCache[7].cacheEntries, glyphCache[7].cacheMaximumCellSize); - DEBUG_WARN( "\tglyphCache8: Entries: %d MaximumCellSize: %d\n", glyphCache[8].cacheEntries, glyphCache[8].cacheMaximumCellSize); - DEBUG_WARN( "\tglyphCache9: Entries: %d MaximumCellSize: %d\n", glyphCache[9].cacheEntries, glyphCache[9].cacheMaximumCellSize); - DEBUG_WARN( "\tfragCache: Entries: %d MaximumCellSize: %d\n", fragCache.cacheEntries, fragCache.cacheMaximumCellSize); - DEBUG_WARN( "\tglyphSupportLevel: 0x%04X\n", glyphSupportLevel); - DEBUG_WARN( "\tpad2Octets: 0x%04X\n", pad2Octets); - + WLog_INFO(TAG, "\tglyphCache0: Entries: %d MaximumCellSize: %d", glyphCache[0].cacheEntries, glyphCache[0].cacheMaximumCellSize); + WLog_INFO(TAG, "\tglyphCache1: Entries: %d MaximumCellSize: %d", glyphCache[1].cacheEntries, glyphCache[1].cacheMaximumCellSize); + WLog_INFO(TAG, "\tglyphCache2: Entries: %d MaximumCellSize: %d", glyphCache[2].cacheEntries, glyphCache[2].cacheMaximumCellSize); + WLog_INFO(TAG, "\tglyphCache3: Entries: %d MaximumCellSize: %d", glyphCache[3].cacheEntries, glyphCache[3].cacheMaximumCellSize); + WLog_INFO(TAG, "\tglyphCache4: Entries: %d MaximumCellSize: %d", glyphCache[4].cacheEntries, glyphCache[4].cacheMaximumCellSize); + WLog_INFO(TAG, "\tglyphCache5: Entries: %d MaximumCellSize: %d", glyphCache[5].cacheEntries, glyphCache[5].cacheMaximumCellSize); + WLog_INFO(TAG, "\tglyphCache6: Entries: %d MaximumCellSize: %d", glyphCache[6].cacheEntries, glyphCache[6].cacheMaximumCellSize); + WLog_INFO(TAG, "\tglyphCache7: Entries: %d MaximumCellSize: %d", glyphCache[7].cacheEntries, glyphCache[7].cacheMaximumCellSize); + WLog_INFO(TAG, "\tglyphCache8: Entries: %d MaximumCellSize: %d", glyphCache[8].cacheEntries, glyphCache[8].cacheMaximumCellSize); + WLog_INFO(TAG, "\tglyphCache9: Entries: %d MaximumCellSize: %d", glyphCache[9].cacheEntries, glyphCache[9].cacheMaximumCellSize); + WLog_INFO(TAG, "\tfragCache: Entries: %d MaximumCellSize: %d", fragCache.cacheEntries, fragCache.cacheMaximumCellSize); + WLog_INFO(TAG, "\tglyphSupportLevel: 0x%04X", glyphSupportLevel); + WLog_INFO(TAG, "\tpad2Octets: 0x%04X", pad2Octets); return TRUE; } @@ -1620,8 +1581,7 @@ BOOL rdp_print_offscreen_bitmap_cache_capability_set(wStream* s, UINT16 length) UINT32 offscreenSupportLevel; UINT16 offscreenCacheSize; UINT16 offscreenCacheEntries; - - DEBUG_WARN( "OffscreenBitmapCacheCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "OffscreenBitmapCacheCapabilitySet (length %d):", length); if (length < 12) return FALSE; @@ -1629,11 +1589,9 @@ BOOL rdp_print_offscreen_bitmap_cache_capability_set(wStream* s, UINT16 length) Stream_Read_UINT32(s, offscreenSupportLevel); /* offscreenSupportLevel (4 bytes) */ Stream_Read_UINT16(s, offscreenCacheSize); /* offscreenCacheSize (2 bytes) */ Stream_Read_UINT16(s, offscreenCacheEntries); /* offscreenCacheEntries (2 bytes) */ - - DEBUG_WARN( "\toffscreenSupportLevel: 0x%08X\n", offscreenSupportLevel); - DEBUG_WARN( "\toffscreenCacheSize: 0x%04X\n", offscreenCacheSize); - DEBUG_WARN( "\toffscreenCacheEntries: 0x%04X\n", offscreenCacheEntries); - + WLog_INFO(TAG, "\toffscreenSupportLevel: 0x%08X", offscreenSupportLevel); + WLog_INFO(TAG, "\toffscreenCacheSize: 0x%04X", offscreenCacheSize); + WLog_INFO(TAG, "\toffscreenCacheEntries: 0x%04X", offscreenCacheEntries); return TRUE; } @@ -1689,8 +1647,7 @@ BOOL rdp_print_bitmap_cache_host_support_capability_set(wStream* s, UINT16 lengt BYTE cacheVersion; BYTE pad1; UINT16 pad2; - - DEBUG_WARN( "BitmapCacheHostSupportCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "BitmapCacheHostSupportCapabilitySet (length %d):", length); if (length < 8) return FALSE; @@ -1698,11 +1655,9 @@ BOOL rdp_print_bitmap_cache_host_support_capability_set(wStream* s, UINT16 lengt Stream_Read_UINT8(s, cacheVersion); /* cacheVersion (1 byte) */ Stream_Read_UINT8(s, pad1); /* pad1 (1 byte) */ Stream_Read_UINT16(s, pad2); /* pad2 (2 bytes) */ - - DEBUG_WARN( "\tcacheVersion: 0x%02X\n", cacheVersion); - DEBUG_WARN( "\tpad1: 0x%02X\n", pad1); - DEBUG_WARN( "\tpad2: 0x%04X\n", pad2); - + WLog_INFO(TAG, "\tcacheVersion: 0x%02X", cacheVersion); + WLog_INFO(TAG, "\tpad1: 0x%02X", pad1); + WLog_INFO(TAG, "\tpad2: 0x%04X", pad2); return TRUE; } @@ -1800,8 +1755,7 @@ BOOL rdp_print_bitmap_cache_v2_capability_set(wStream* s, UINT16 length) BYTE pad2; BYTE numCellCaches; BITMAP_CACHE_V2_CELL_INFO bitmapCacheV2CellInfo[5]; - - DEBUG_WARN( "BitmapCacheV2CapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "BitmapCacheV2CapabilitySet (length %d):", length); if (length < 40) return FALSE; @@ -1815,16 +1769,14 @@ BOOL rdp_print_bitmap_cache_v2_capability_set(wStream* s, UINT16 length) rdp_read_bitmap_cache_cell_info(s, &bitmapCacheV2CellInfo[3]); /* bitmapCache3CellInfo (4 bytes) */ rdp_read_bitmap_cache_cell_info(s, &bitmapCacheV2CellInfo[4]); /* bitmapCache4CellInfo (4 bytes) */ Stream_Seek(s, 12); /* pad3 (12 bytes) */ - - DEBUG_WARN( "\tcacheFlags: 0x%04X\n", cacheFlags); - DEBUG_WARN( "\tpad2: 0x%02X\n", pad2); - DEBUG_WARN( "\tnumCellCaches: 0x%02X\n", numCellCaches); - DEBUG_WARN( "\tbitmapCache0CellInfo: numEntries: %d persistent: %d\n", bitmapCacheV2CellInfo[0].numEntries, bitmapCacheV2CellInfo[0].persistent); - DEBUG_WARN( "\tbitmapCache1CellInfo: numEntries: %d persistent: %d\n", bitmapCacheV2CellInfo[1].numEntries, bitmapCacheV2CellInfo[1].persistent); - DEBUG_WARN( "\tbitmapCache2CellInfo: numEntries: %d persistent: %d\n", bitmapCacheV2CellInfo[2].numEntries, bitmapCacheV2CellInfo[2].persistent); - DEBUG_WARN( "\tbitmapCache3CellInfo: numEntries: %d persistent: %d\n", bitmapCacheV2CellInfo[3].numEntries, bitmapCacheV2CellInfo[3].persistent); - DEBUG_WARN( "\tbitmapCache4CellInfo: numEntries: %d persistent: %d\n", bitmapCacheV2CellInfo[4].numEntries, bitmapCacheV2CellInfo[4].persistent); - + WLog_INFO(TAG, "\tcacheFlags: 0x%04X", cacheFlags); + WLog_INFO(TAG, "\tpad2: 0x%02X", pad2); + WLog_INFO(TAG, "\tnumCellCaches: 0x%02X", numCellCaches); + WLog_INFO(TAG, "\tbitmapCache0CellInfo: numEntries: %d persistent: %d", bitmapCacheV2CellInfo[0].numEntries, bitmapCacheV2CellInfo[0].persistent); + WLog_INFO(TAG, "\tbitmapCache1CellInfo: numEntries: %d persistent: %d", bitmapCacheV2CellInfo[1].numEntries, bitmapCacheV2CellInfo[1].persistent); + WLog_INFO(TAG, "\tbitmapCache2CellInfo: numEntries: %d persistent: %d", bitmapCacheV2CellInfo[2].numEntries, bitmapCacheV2CellInfo[2].persistent); + WLog_INFO(TAG, "\tbitmapCache3CellInfo: numEntries: %d persistent: %d", bitmapCacheV2CellInfo[3].numEntries, bitmapCacheV2CellInfo[3].persistent); + WLog_INFO(TAG, "\tbitmapCache4CellInfo: numEntries: %d persistent: %d", bitmapCacheV2CellInfo[4].numEntries, bitmapCacheV2CellInfo[4].persistent); return TRUE; } @@ -1885,8 +1837,7 @@ BOOL rdp_print_virtual_channel_capability_set(wStream* s, UINT16 length) { UINT32 flags; UINT32 VCChunkSize; - - DEBUG_WARN( "VirtualChannelCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "VirtualChannelCapabilitySet (length %d):", length); if (length < 8) return FALSE; @@ -1898,9 +1849,8 @@ BOOL rdp_print_virtual_channel_capability_set(wStream* s, UINT16 length) else VCChunkSize = 1600; - DEBUG_WARN( "\tflags: 0x%08X\n", flags); - DEBUG_WARN( "\tVCChunkSize: 0x%08X\n", VCChunkSize); - + WLog_INFO(TAG, "\tflags: 0x%08X", flags); + WLog_INFO(TAG, "\tVCChunkSize: 0x%08X", VCChunkSize); return TRUE; } @@ -1984,8 +1934,7 @@ BOOL rdp_print_draw_nine_grid_cache_capability_set(wStream* s, UINT16 length) UINT32 drawNineGridSupportLevel; UINT16 DrawNineGridCacheSize; UINT16 DrawNineGridCacheEntries; - - DEBUG_WARN( "DrawNineGridCacheCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "DrawNineGridCacheCapabilitySet (length %d):", length); if (length < 12) return FALSE; @@ -2064,8 +2013,7 @@ BOOL rdp_print_draw_gdiplus_cache_capability_set(wStream* s, UINT16 length) UINT32 drawGdiPlusSupportLevel; UINT32 GdipVersion; UINT32 drawGdiplusCacheLevel; - - DEBUG_WARN( "DrawGdiPlusCacheCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "DrawGdiPlusCacheCapabilitySet (length %d):", length); if (length < 40) return FALSE; @@ -2137,16 +2085,13 @@ void rdp_write_remote_programs_capability_set(wStream* s, rdpSettings* settings) BOOL rdp_print_remote_programs_capability_set(wStream* s, UINT16 length) { UINT32 railSupportLevel; - - DEBUG_WARN( "RemoteProgramsCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "RemoteProgramsCapabilitySet (length %d):", length); if (length < 8) return FALSE; Stream_Read_UINT32(s, railSupportLevel); /* railSupportLevel (4 bytes) */ - - DEBUG_WARN( "\trailSupportLevel: 0x%08X\n", railSupportLevel); - + WLog_INFO(TAG, "\trailSupportLevel: 0x%08X", railSupportLevel); return TRUE; } @@ -2200,8 +2145,7 @@ BOOL rdp_print_window_list_capability_set(wStream* s, UINT16 length) UINT32 wndSupportLevel; BYTE numIconCaches; UINT16 numIconCacheEntries; - - DEBUG_WARN( "WindowListCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "WindowListCapabilitySet (length %d):", length); if (length < 11) return FALSE; @@ -2209,11 +2153,9 @@ BOOL rdp_print_window_list_capability_set(wStream* s, UINT16 length) Stream_Read_UINT32(s, wndSupportLevel); /* wndSupportLevel (4 bytes) */ Stream_Read_UINT8(s, numIconCaches); /* numIconCaches (1 byte) */ Stream_Read_UINT16(s, numIconCacheEntries); /* numIconCacheEntries (2 bytes) */ - - DEBUG_WARN( "\twndSupportLevel: 0x%08X\n", wndSupportLevel); - DEBUG_WARN( "\tnumIconCaches: 0x%02X\n", numIconCaches); - DEBUG_WARN( "\tnumIconCacheEntries: 0x%04X\n", numIconCacheEntries); - + WLog_INFO(TAG, "\twndSupportLevel: 0x%08X", wndSupportLevel); + WLog_INFO(TAG, "\tnumIconCaches: 0x%02X", numIconCaches); + WLog_INFO(TAG, "\tnumIconCacheEntries: 0x%04X", numIconCacheEntries); return TRUE; } @@ -2261,16 +2203,13 @@ void rdp_write_desktop_composition_capability_set(wStream* s, rdpSettings* setti BOOL rdp_print_desktop_composition_capability_set(wStream* s, UINT16 length) { UINT16 compDeskSupportLevel; - - DEBUG_WARN( "DesktopCompositionCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "DesktopCompositionCapabilitySet (length %d):", length); if (length < 6) return FALSE; Stream_Read_UINT16(s, compDeskSupportLevel); /* compDeskSupportLevel (2 bytes) */ - - DEBUG_WARN( "\tcompDeskSupportLevel: 0x%04X\n", compDeskSupportLevel); - + WLog_INFO(TAG, "\tcompDeskSupportLevel: 0x%04X", compDeskSupportLevel); return TRUE; } @@ -2390,16 +2329,13 @@ void rdp_write_multifragment_update_capability_set(wStream* s, rdpSettings* sett BOOL rdp_print_multifragment_update_capability_set(wStream* s, UINT16 length) { UINT32 maxRequestSize; - - DEBUG_WARN( "MultifragmentUpdateCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "MultifragmentUpdateCapabilitySet (length %d):", length); if (length < 8) return FALSE; Stream_Read_UINT32(s, maxRequestSize); /* maxRequestSize (4 bytes) */ - - DEBUG_WARN( "\tmaxRequestSize: 0x%04X\n", maxRequestSize); - + WLog_INFO(TAG, "\tmaxRequestSize: 0x%04X", maxRequestSize); return TRUE; } @@ -2451,16 +2387,13 @@ void rdp_write_large_pointer_capability_set(wStream* s, rdpSettings* settings) BOOL rdp_print_large_pointer_capability_set(wStream* s, UINT16 length) { UINT16 largePointerSupportFlags; - - DEBUG_WARN( "LargePointerCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "LargePointerCapabilitySet (length %d):", length); if (length < 6) return FALSE; Stream_Read_UINT16(s, largePointerSupportFlags); /* largePointerSupportFlags (2 bytes) */ - - DEBUG_WARN( "\tlargePointerSupportFlags: 0x%04X\n", largePointerSupportFlags); - + WLog_INFO(TAG, "\tlargePointerSupportFlags: 0x%04X", largePointerSupportFlags); return TRUE; } @@ -2518,18 +2451,15 @@ BOOL rdp_print_surface_commands_capability_set(wStream* s, UINT16 length) { UINT32 cmdFlags; UINT32 reserved; - - DEBUG_WARN( "SurfaceCommandsCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "SurfaceCommandsCapabilitySet (length %d):", length); if (length < 12) return FALSE; Stream_Read_UINT32(s, cmdFlags); /* cmdFlags (4 bytes) */ Stream_Read_UINT32(s, reserved); /* reserved (4 bytes) */ - - DEBUG_WARN( "\tcmdFlags: 0x%08X\n", cmdFlags); - DEBUG_WARN( "\treserved: 0x%08X\n", reserved); - + WLog_INFO(TAG, "\tcmdFlags: 0x%08X", cmdFlags); + WLog_INFO(TAG, "\treserved: 0x%08X", reserved); return TRUE; } @@ -2578,10 +2508,10 @@ void rdp_write_bitmap_codec_guid(wStream* s, GUID* guid) void rdp_print_bitmap_codec_guid(GUID* guid) { - DEBUG_WARN( "%08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X", - guid->Data1, guid->Data2, guid->Data3, - guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], - guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]); + WLog_INFO(TAG, "%08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X", + guid->Data1, guid->Data2, guid->Data3, + guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], + guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]); } char* rdp_get_bitmap_codec_guid_name(GUID* guid) @@ -2910,16 +2840,14 @@ BOOL rdp_print_bitmap_codecs_capability_set(wStream* s, UINT16 length) BYTE codecId; UINT16 codecPropertiesLength; UINT16 remainingLength; - - DEBUG_WARN( "BitmapCodecsCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "BitmapCodecsCapabilitySet (length %d):", length); if (length < 5) return FALSE; Stream_Read_UINT8(s, bitmapCodecCount); /* bitmapCodecCount (1 byte) */ remainingLength = length - 5; - - DEBUG_WARN( "\tbitmapCodecCount: %d\n", bitmapCodecCount); + WLog_INFO(TAG, "\tbitmapCodecCount: %d", bitmapCodecCount); while (bitmapCodecCount > 0) { @@ -2928,16 +2856,12 @@ BOOL rdp_print_bitmap_codecs_capability_set(wStream* s, UINT16 length) rdp_read_bitmap_codec_guid(s, &codecGuid); /* codecGuid (16 bytes) */ Stream_Read_UINT8(s, codecId); /* codecId (1 byte) */ - - DEBUG_WARN( "\tcodecGuid: 0x"); + WLog_INFO(TAG, "\tcodecGuid: 0x"); rdp_print_bitmap_codec_guid(&codecGuid); - DEBUG_WARN( " (%s)\n", rdp_get_bitmap_codec_guid_name(&codecGuid)); - - DEBUG_WARN( "\tcodecId: %d\n", codecId); - + WLog_INFO(TAG, " (%s)", rdp_get_bitmap_codec_guid_name(&codecGuid)); + WLog_INFO(TAG, "\tcodecId: %d", codecId); Stream_Read_UINT16(s, codecPropertiesLength); /* codecPropertiesLength (2 bytes) */ - DEBUG_WARN( "\tcodecPropertiesLength: %d\n", codecPropertiesLength); - + WLog_INFO(TAG, "\tcodecPropertiesLength: %d", codecPropertiesLength); remainingLength -= 19; if (remainingLength < codecPropertiesLength) @@ -2998,16 +2922,13 @@ void rdp_write_frame_acknowledge_capability_set(wStream* s, rdpSettings* setting BOOL rdp_print_frame_acknowledge_capability_set(wStream* s, UINT16 length) { UINT32 frameAcknowledge; - - DEBUG_WARN( "FrameAcknowledgeCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "FrameAcknowledgeCapabilitySet (length %d):", length); if (length < 8) return FALSE; Stream_Read_UINT32(s, frameAcknowledge); /* frameAcknowledge (4 bytes) */ - - DEBUG_WARN( "\tframeAcknowledge: 0x%08X\n", frameAcknowledge); - + WLog_INFO(TAG, "\tframeAcknowledge: 0x%08X", frameAcknowledge); return TRUE; } @@ -3038,16 +2959,13 @@ void rdp_write_bitmap_cache_v3_codec_id_capability_set(wStream* s, rdpSettings* BOOL rdp_print_bitmap_cache_v3_codec_id_capability_set(wStream* s, UINT16 length) { BYTE bitmapCacheV3CodecId; - - DEBUG_WARN( "BitmapCacheV3CodecIdCapabilitySet (length %d):\n", length); + WLog_INFO(TAG, "BitmapCacheV3CodecIdCapabilitySet (length %d):", length); if (length < 5) return FALSE; Stream_Read_UINT8(s, bitmapCacheV3CodecId); /* bitmapCacheV3CodecId (1 byte) */ - - DEBUG_WARN( "\tbitmapCacheV3CodecId: 0x%02X\n", bitmapCacheV3CodecId); - + WLog_INFO(TAG, "\tbitmapCacheV3CodecId: 0x%02X", bitmapCacheV3CodecId); return TRUE; } @@ -3062,14 +2980,12 @@ BOOL rdp_print_capability_sets(wStream* s, UINT16 numberCapabilities, BOOL recei Stream_GetPointer(s, bm); rdp_read_capability_set_header(s, &length, &type); - - DEBUG_WARN( "%s ", receiving ? "Receiving" : "Sending"); - + WLog_INFO(TAG, "%s ", receiving ? "Receiving" : "Sending"); em = bm + length; if (Stream_GetRemainingLength(s) < (size_t) (length - 4)) { - DEBUG_WARN( "error processing stream\n"); + WLog_ERR(TAG, "error processing stream"); return FALSE; } @@ -3221,14 +3137,14 @@ BOOL rdp_print_capability_sets(wStream* s, UINT16 numberCapabilities, BOOL recei break; default: - DEBUG_WARN( "unknown capability type %d\n", type); + WLog_ERR(TAG, "unknown capability type %d", type); break; } if (s->pointer != em) { - DEBUG_WARN( "incorrect offset, type:0x%02X actual:%d expected:%d\n", - type, (int) (s->pointer - bm), (int) (em - bm)); + WLog_ERR(TAG, "incorrect offset, type:0x%02X actual:%d expected:%d", + type, (int)(s->pointer - bm), (int)(em - bm)); } Stream_SetPointer(s, em); @@ -3261,14 +3177,14 @@ BOOL rdp_read_capability_sets(wStream* s, rdpSettings* settings, UINT16 numberCa } else { - DEBUG_WARN( "%s: not handling capability type %d yet\n", __FUNCTION__, type); + WLog_WARN(TAG, "not handling capability type %d yet", type); } em = bm + length; if (Stream_GetRemainingLength(s) < ((size_t) length - 4)) { - DEBUG_WARN( "error processing stream\n"); + WLog_ERR(TAG, "error processing stream"); return FALSE; } @@ -3420,14 +3336,14 @@ BOOL rdp_read_capability_sets(wStream* s, rdpSettings* settings, UINT16 numberCa break; default: - DEBUG_WARN( "unknown capability type %d\n", type); + WLog_ERR(TAG, "unknown capability type %d", type); break; } if (s->pointer != em) { - DEBUG_WARN( "incorrect offset, type:0x%02X actual:%d expected:%d\n", - type, (int) (s->pointer - bm), (int) (em - bm)); + WLog_ERR(TAG, "incorrect offset, type:0x%02X actual:%d expected:%d", + type, (int)(s->pointer - bm), (int)(em - bm)); } Stream_SetPointer(s, em); @@ -3436,8 +3352,8 @@ BOOL rdp_read_capability_sets(wStream* s, rdpSettings* settings, UINT16 numberCa if (numberCapabilities) { - DEBUG_WARN( "%s: strange we haven't read the number of announced capacity sets, read=%d expected=%d\n", - __FUNCTION__, count-numberCapabilities, count); + WLog_ERR(TAG, "strange we haven't read the number of announced capacity sets, read=%d expected=%d", + count-numberCapabilities, count); } #ifdef WITH_DEBUG_CAPABILITIES @@ -3471,7 +3387,7 @@ BOOL rdp_recv_get_active_header(rdpRdp* rdp, wStream* s, UINT16* pChannelId) { if (!rdp_decrypt(rdp, s, length - 4, securityFlags)) { - DEBUG_WARN( "rdp_decrypt failed\n"); + WLog_ERR(TAG, "rdp_decrypt failed"); return FALSE; } } @@ -3483,7 +3399,7 @@ BOOL rdp_recv_get_active_header(rdpRdp* rdp, wStream* s, UINT16* pChannelId) if ((mcsMessageChannelId == 0) || (*pChannelId != mcsMessageChannelId)) { - DEBUG_WARN( "unexpected MCS channel id %04x received\n", *pChannelId); + WLog_ERR(TAG, "unexpected MCS channel id %04x received", *pChannelId); return FALSE; } } @@ -3509,14 +3425,14 @@ BOOL rdp_recv_demand_active(rdpRdp* rdp, wStream* s) if (!rdp_read_share_control_header(s, &pduLength, &pduType, &pduSource)) { - DEBUG_WARN( "rdp_read_share_control_header failed\n"); + WLog_ERR(TAG, "rdp_read_share_control_header failed"); return FALSE; } if (pduType != PDU_TYPE_DEMAND_ACTIVE) { if (pduType != PDU_TYPE_SERVER_REDIRECTION) - DEBUG_WARN( "expected PDU_TYPE_DEMAND_ACTIVE %04x, got %04x\n", PDU_TYPE_DEMAND_ACTIVE, pduType); + WLog_ERR(TAG, "expected PDU_TYPE_DEMAND_ACTIVE %04x, got %04x", PDU_TYPE_DEMAND_ACTIVE, pduType); return FALSE; } @@ -3539,7 +3455,7 @@ BOOL rdp_recv_demand_active(rdpRdp* rdp, wStream* s) /* capabilitySets */ if (!rdp_read_capability_sets(s, rdp->settings, numberCapabilities)) { - DEBUG_WARN( "rdp_read_capability_sets failed\n"); + WLog_ERR(TAG, "rdp_read_capability_sets failed"); return FALSE; } diff --git a/libfreerdp/core/certificate.c b/libfreerdp/core/certificate.c index 8829c0cd9..d9aa8f9ad 100644 --- a/libfreerdp/core/certificate.c +++ b/libfreerdp/core/certificate.c @@ -298,7 +298,7 @@ error2: free(info->Modulus); info->Modulus = 0; error1: - DEBUG_WARN("error reading when reading certificate: part=%s error=%d\n", certificate_read_errors[error], error); + WLog_ERR(TAG, "error reading when reading certificate: part=%s error=%d", certificate_read_errors[error], error); Stream_Free(s, FALSE); return FALSE; } @@ -366,7 +366,7 @@ static BOOL certificate_process_server_public_key(rdpCertificate* certificate, w if (memcmp(magic, "RSA1", 4) != 0) { - DEBUG_WARN("%s: magic error\n", __FUNCTION__); + WLog_ERR(TAG, "magic error"); return FALSE; } @@ -415,7 +415,7 @@ static BOOL certificate_process_server_public_signature(rdpCertificate* certific if (sum != 0) { - DEBUG_WARN("%s: invalid signature\n", __FUNCTION__); + WLog_ERR(TAG, "invalid signature"); //return FALSE; } @@ -426,7 +426,7 @@ static BOOL certificate_process_server_public_signature(rdpCertificate* certific /* Verify signature. */ if (memcmp(md5hash, sig, sizeof(md5hash)) != 0) { - DEBUG_WARN("%s: invalid signature\n", __FUNCTION__); + WLog_ERR(TAG, "invalid signature"); //return FALSE; } @@ -442,7 +442,7 @@ static BOOL certificate_process_server_public_signature(rdpCertificate* certific if (sig[16] != 0x00 || sum != 0xFF * (62 - 17) || sig[62] != 0x01) { - DEBUG_WARN("%s: invalid signature\n", __FUNCTION__); + WLog_ERR(TAG, "invalid signature"); //return FALSE; } @@ -476,8 +476,8 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate if (!(dwSigAlgId == SIGNATURE_ALG_RSA && dwKeyAlgId == KEY_EXCHANGE_ALG_RSA)) { - DEBUG_WARN("%s: unsupported signature or key algorithm, dwSigAlgId=%d dwKeyAlgId=%d\n", - __FUNCTION__, dwSigAlgId, dwKeyAlgId); + WLog_ERR(TAG, "unsupported signature or key algorithm, dwSigAlgId=%d dwKeyAlgId=%d", + dwSigAlgId, dwKeyAlgId); return FALSE; } @@ -485,7 +485,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate if (wPublicKeyBlobType != BB_RSA_KEY_BLOB) { - DEBUG_WARN("%s: unsupported public key blob type %d\n", __FUNCTION__, wPublicKeyBlobType); + WLog_ERR(TAG, "unsupported public key blob type %d", wPublicKeyBlobType); return FALSE; } @@ -496,7 +496,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate if (!certificate_process_server_public_key(certificate, s, wPublicKeyBlobLen)) { - DEBUG_WARN("%s: error in server public key\n", __FUNCTION__); + WLog_ERR(TAG, "error in server public key"); return FALSE; } @@ -508,7 +508,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate if (wSignatureBlobType != BB_RSA_SIGNATURE_BLOB) { - DEBUG_WARN("%s: unsupported blob signature %d\n", __FUNCTION__, wSignatureBlobType); + WLog_ERR(TAG, "unsupported blob signature %d", wSignatureBlobType); return FALSE; } @@ -516,19 +516,19 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate if (Stream_GetRemainingLength(s) < wSignatureBlobLen) { - DEBUG_WARN("%s: not enought bytes for signature(len=%d)\n", __FUNCTION__, wSignatureBlobLen); + WLog_ERR(TAG, "not enought bytes for signature(len=%d)", wSignatureBlobLen); return FALSE; } if (wSignatureBlobLen != 72) { - DEBUG_WARN("%s: invalid signature length (got %d, expected %d)\n", __FUNCTION__, wSignatureBlobLen, 64); + WLog_ERR(TAG, "invalid signature length (got %d, expected %d)", wSignatureBlobLen, 64); return FALSE; } if (!certificate_process_server_public_signature(certificate, sigdata, sigdatalen, s, wSignatureBlobLen)) { - DEBUG_WARN("%s: unable to parse server public signature\n", __FUNCTION__); + WLog_ERR(TAG, "unable to parse server public signature"); return FALSE; } @@ -589,7 +589,7 @@ BOOL certificate_read_server_x509_certificate_chain(rdpCertificate* certificate, if (!ret) { - DEBUG_WARN("failed to read License Server, content follows:\n"); + WLog_ERR(TAG, "failed to read License Server, content follows:"); winpr_HexDump(TAG, WLOG_ERROR, certificate->x509_cert_chain->array[i].data, certificate->x509_cert_chain->array[i].length); return FALSE; } @@ -638,7 +638,7 @@ BOOL certificate_read_server_certificate(rdpCertificate* certificate, BYTE* serv break; default: - DEBUG_WARN("invalid certificate chain version:%d\n", dwVersion & CERT_CHAIN_VERSION_MASK); + WLog_ERR(TAG, "invalid certificate chain version:%d", dwVersion & CERT_CHAIN_VERSION_MASK); ret = FALSE; break; } @@ -661,7 +661,7 @@ rdpRsaKey* key_new(const char* keyfile) if (fp == NULL) { - DEBUG_WARN("%s: unable to open RSA key file %s: %s.", __FUNCTION__, keyfile, strerror(errno)); + WLog_ERR(TAG, "unable to open RSA key file %s: %s.", keyfile, strerror(errno)); goto out_free; } @@ -669,7 +669,7 @@ rdpRsaKey* key_new(const char* keyfile) if (rsa == NULL) { - DEBUG_WARN("%s: unable to load RSA key from %s: %s.", __FUNCTION__, keyfile, strerror(errno)); + WLog_ERR(TAG, "unable to load RSA key from %s: %s.", keyfile, strerror(errno)); ERR_print_errors_fp(stderr); fclose(fp); goto out_free; @@ -680,7 +680,7 @@ rdpRsaKey* key_new(const char* keyfile) switch (RSA_check_key(rsa)) { case 0: - DEBUG_WARN("%s: invalid RSA key in %s\n", __FUNCTION__, keyfile); + WLog_ERR(TAG, "invalid RSA key in %s", keyfile); goto out_free_rsa; case 1: @@ -688,14 +688,14 @@ rdpRsaKey* key_new(const char* keyfile) break; default: - DEBUG_WARN("%s: unexpected error when checking RSA key from %s: %s.", __FUNCTION__, keyfile, strerror(errno)); + WLog_ERR(TAG, "unexpected error when checking RSA key from %s: %s.", keyfile, strerror(errno)); ERR_print_errors_fp(stderr); goto out_free_rsa; } if (BN_num_bytes(rsa->e) > 4) { - DEBUG_WARN("%s: RSA public exponent too large in %s\n", __FUNCTION__, keyfile); + WLog_ERR(TAG, "RSA public exponent too large in %s", keyfile); goto out_free_rsa; } diff --git a/libfreerdp/core/certificate.h b/libfreerdp/core/certificate.h index 2d726cf8a..91cb3e6d0 100644 --- a/libfreerdp/core/certificate.h +++ b/libfreerdp/core/certificate.h @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -58,10 +59,11 @@ void certificate_free(rdpCertificate* certificate); rdpRsaKey* key_new(const char *keyfile); void key_free(rdpRsaKey* key); +#define CERTIFICATE_TAG FREERDP_TAG("core.certificate") #ifdef WITH_DEBUG_CERTIFICATE -#define DEBUG_CERTIFICATE(fmt, ...) DEBUG_CLASS(CERTIFICATE, fmt, ## __VA_ARGS__) +#define DEBUG_CERTIFICATE(fmt, ...) WLog_DBG(CERTIFICATE_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_CERTIFICATE(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_CERTIFICATE(fmt, ...) do { } while (0) #endif #endif /* __CERTIFICATE_H */ diff --git a/libfreerdp/core/channels.c b/libfreerdp/core/channels.c index 943b0e913..a482ac0f1 100644 --- a/libfreerdp/core/channels.c +++ b/libfreerdp/core/channels.c @@ -32,11 +32,12 @@ #include #include +#include #include #include #include #include -#include + #include #include #include @@ -46,6 +47,8 @@ #include "server.h" #include "channels.h" +#define TAG FREERDP_TAG("core.channels") + BOOL freerdp_channel_send(rdpRdp* rdp, UINT16 channelId, BYTE* data, int size) { DWORD i; @@ -67,7 +70,7 @@ BOOL freerdp_channel_send(rdpRdp* rdp, UINT16 channelId, BYTE* data, int size) if (!channel) { - DEBUG_WARN( "freerdp_channel_send: unknown channelId %d\n", channelId); + WLog_ERR(TAG, "freerdp_channel_send: unknown channelId %d", channelId); return FALSE; } diff --git a/libfreerdp/core/client.c b/libfreerdp/core/client.c index 87dee69d2..93d5292e6 100644 --- a/libfreerdp/core/client.c +++ b/libfreerdp/core/client.c @@ -21,10 +21,14 @@ #include "config.h" #endif +#include + #include "rdp.h" #include "client.h" +#define TAG FREERDP_TAG("core.client") + static void* g_pInterface; static CHANNEL_INIT_DATA g_ChannelInitData; @@ -715,7 +719,7 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v if (channels->clientDataCount + 1 >= CHANNEL_MAX_COUNT) { - DEBUG_WARN( "error: too many channels\n"); + WLog_ERR(TAG, "error: too many channels"); return 1; } @@ -754,7 +758,7 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v if (!status) { - DEBUG_WARN( "error: channel export function call failed\n"); + WLog_ERR(TAG, "error: channel export function call failed"); return 1; } diff --git a/libfreerdp/core/client.h b/libfreerdp/core/client.h index 532359033..3005b760b 100644 --- a/libfreerdp/core/client.h +++ b/libfreerdp/core/client.h @@ -30,7 +30,7 @@ #include #include #include -#include + #include #include #include diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index 52947636a..3939e78d8 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -30,36 +30,39 @@ #include +#include #include #include +#define TAG FREERDP_TAG("core.connection") + /** - * Connection Sequence\n - * client server\n - * | |\n - * |-----------------------X.224 Connection Request PDU--------------------->|\n - * |<----------------------X.224 Connection Confirm PDU----------------------|\n - * |-------MCS Connect-Initial PDU with GCC Conference Create Request------->|\n - * |<-----MCS Connect-Response PDU with GCC Conference Create Response-------|\n - * |------------------------MCS Erect Domain Request PDU-------------------->|\n - * |------------------------MCS Attach User Request PDU--------------------->|\n - * |<-----------------------MCS Attach User Confirm PDU----------------------|\n - * |------------------------MCS Channel Join Request PDU-------------------->|\n - * |<-----------------------MCS Channel Join Confirm PDU---------------------|\n - * |----------------------------Security Exchange PDU----------------------->|\n - * |-------------------------------Client Info PDU-------------------------->|\n - * |<---------------------License Error PDU - Valid Client-------------------|\n - * |<-----------------------------Demand Active PDU--------------------------|\n - * |------------------------------Confirm Active PDU------------------------>|\n - * |-------------------------------Synchronize PDU-------------------------->|\n - * |---------------------------Control PDU - Cooperate---------------------->|\n - * |------------------------Control PDU - Request Control------------------->|\n - * |--------------------------Persistent Key List PDU(s)-------------------->|\n - * |--------------------------------Font List PDU--------------------------->|\n - * |<------------------------------Synchronize PDU---------------------------|\n - * |<--------------------------Control PDU - Cooperate-----------------------|\n - * |<-----------------------Control PDU - Granted Control--------------------|\n - * |<-------------------------------Font Map PDU-----------------------------|\n + * Connection Sequence + * client server + * | | + * |-----------------------X.224 Connection Request PDU--------------------->| + * |<----------------------X.224 Connection Confirm PDU----------------------| + * |-------MCS Connect-Initial PDU with GCC Conference Create Request------->| + * |<-----MCS Connect-Response PDU with GCC Conference Create Response-------| + * |------------------------MCS Erect Domain Request PDU-------------------->| + * |------------------------MCS Attach User Request PDU--------------------->| + * |<-----------------------MCS Attach User Confirm PDU----------------------| + * |------------------------MCS Channel Join Request PDU-------------------->| + * |<-----------------------MCS Channel Join Confirm PDU---------------------| + * |----------------------------Security Exchange PDU----------------------->| + * |-------------------------------Client Info PDU-------------------------->| + * |<---------------------License Error PDU - Valid Client-------------------| + * |<-----------------------------Demand Active PDU--------------------------| + * |------------------------------Confirm Active PDU------------------------>| + * |-------------------------------Synchronize PDU-------------------------->| + * |---------------------------Control PDU - Cooperate---------------------->| + * |------------------------Control PDU - Request Control------------------->| + * |--------------------------Persistent Key List PDU(s)-------------------->| + * |--------------------------------Font List PDU--------------------------->| + * |<------------------------------Synchronize PDU---------------------------| + * |<--------------------------Control PDU - Cooperate-----------------------| + * |<-----------------------Control PDU - Granted Control--------------------| + * |<-------------------------------Font Map PDU-----------------------------| * */ @@ -266,7 +269,7 @@ BOOL rdp_client_connect(rdpRdp* rdp) freerdp_set_last_error(rdp->context, FREERDP_ERROR_SECURITY_NEGO_CONNECT_FAILED); } - DEBUG_WARN( "Error: protocol security negotiation or connection failure\n"); + WLog_ERR(TAG, "Error: protocol security negotiation or connection failure"); return FALSE; } @@ -294,7 +297,7 @@ BOOL rdp_client_connect(rdpRdp* rdp) freerdp_set_last_error(rdp->context, FREERDP_ERROR_MCS_CONNECT_INITIAL_ERROR); } - DEBUG_WARN( "Error: unable to send MCS Connect Initial\n"); + WLog_ERR(TAG, "Error: unable to send MCS Connect Initial"); return FALSE; } @@ -460,20 +463,20 @@ static BOOL rdp_client_establish_keys(rdpRdp* rdp) rdp->fips_encrypt = crypto_des3_encrypt_init(rdp->fips_encrypt_key, fips_ivec); if (!rdp->fips_encrypt) { - DEBUG_WARN( "%s: unable to allocate des3 encrypt key\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate des3 encrypt key"); goto end; } rdp->fips_decrypt = crypto_des3_decrypt_init(rdp->fips_decrypt_key, fips_ivec); if (!rdp->fips_decrypt) { - DEBUG_WARN( "%s: unable to allocate des3 decrypt key\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate des3 decrypt key"); goto end; } rdp->fips_hmac = crypto_hmac_new(); if (!rdp->fips_hmac) { - DEBUG_WARN( "%s: unable to allocate fips hmac\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate fips hmac"); goto end; } ret = TRUE; @@ -483,14 +486,14 @@ static BOOL rdp_client_establish_keys(rdpRdp* rdp) rdp->rc4_decrypt_key = crypto_rc4_init(rdp->decrypt_key, rdp->rc4_key_len); if (!rdp->rc4_decrypt_key) { - DEBUG_WARN( "%s: unable to allocate rc4 decrypt key\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate rc4 decrypt key"); goto end; } rdp->rc4_encrypt_key = crypto_rc4_init(rdp->encrypt_key, rdp->rc4_key_len); if (!rdp->rc4_encrypt_key) { - DEBUG_WARN( "%s: unable to allocate rc4 encrypt key\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate rc4 encrypt key"); goto end; } ret = TRUE; @@ -518,19 +521,19 @@ BOOL rdp_server_establish_keys(rdpRdp* rdp, wStream* s) if (!rdp_read_header(rdp, s, &length, &channel_id)) { - DEBUG_WARN( "%s: invalid RDP header\n", __FUNCTION__); + WLog_ERR(TAG, "invalid RDP header"); return FALSE; } if (!rdp_read_security_header(s, &sec_flags)) { - DEBUG_WARN( "%s: invalid security header\n", __FUNCTION__); + WLog_ERR(TAG, "invalid security header"); return FALSE; } if ((sec_flags & SEC_EXCHANGE_PKT) == 0) { - DEBUG_WARN( "%s: missing SEC_EXCHANGE_PKT in security header\n", __FUNCTION__); + WLog_ERR(TAG, "missing SEC_EXCHANGE_PKT in security header"); return FALSE; } @@ -550,7 +553,7 @@ BOOL rdp_server_establish_keys(rdpRdp* rdp, wStream* s) if (rand_len != key_len + 8) { - DEBUG_WARN( "%s: invalid encrypted client random length\n", __FUNCTION__); + WLog_ERR(TAG, "invalid encrypted client random length"); goto end2; } @@ -579,21 +582,21 @@ BOOL rdp_server_establish_keys(rdpRdp* rdp, wStream* s) rdp->fips_encrypt = crypto_des3_encrypt_init(rdp->fips_encrypt_key, fips_ivec); if (!rdp->fips_encrypt) { - DEBUG_WARN( "%s: unable to allocate des3 encrypt key\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate des3 encrypt key"); goto end; } rdp->fips_decrypt = crypto_des3_decrypt_init(rdp->fips_decrypt_key, fips_ivec); if (!rdp->fips_decrypt) { - DEBUG_WARN( "%s: unable to allocate des3 decrypt key\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate des3 decrypt key"); goto end; } rdp->fips_hmac = crypto_hmac_new(); if (!rdp->fips_hmac) { - DEBUG_WARN( "%s: unable to allocate fips hmac\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate fips hmac"); goto end; } ret = TRUE; @@ -603,14 +606,14 @@ BOOL rdp_server_establish_keys(rdpRdp* rdp, wStream* s) rdp->rc4_decrypt_key = crypto_rc4_init(rdp->decrypt_key, rdp->rc4_key_len); if (!rdp->rc4_decrypt_key) { - DEBUG_WARN( "%s: unable to allocate rc4 decrypt key\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate rc4 decrypt key"); goto end; } rdp->rc4_encrypt_key = crypto_rc4_init(rdp->encrypt_key, rdp->rc4_key_len); if (!rdp->rc4_encrypt_key) { - DEBUG_WARN( "%s: unable to allocate rc4 encrypt key\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate rc4 encrypt key"); goto end; } ret = TRUE; @@ -628,7 +631,7 @@ BOOL rdp_client_connect_mcs_connect_response(rdpRdp* rdp, wStream* s) { if (!mcs_recv_connect_response(rdp->mcs, s)) { - DEBUG_WARN( "rdp_client_connect_mcs_connect_response: mcs_recv_connect_response failed\n"); + WLog_ERR(TAG, "rdp_client_connect_mcs_connect_response: mcs_recv_connect_response failed"); return FALSE; } @@ -792,7 +795,7 @@ int rdp_client_connect_license(rdpRdp* rdp, wStream* s) if (rdp->license->state == LICENSE_STATE_ABORTED) { - DEBUG_WARN( "license connection sequence aborted.\n"); + WLog_ERR(TAG, "license connection sequence aborted."); return -1; } @@ -971,15 +974,13 @@ BOOL rdp_server_accept_nego(rdpRdp* rdp, wStream* s) return FALSE; nego->selected_protocol = 0; - - DEBUG_WARN( "Client Security: NLA:%d TLS:%d RDP:%d\n", - (nego->requested_protocols & PROTOCOL_NLA) ? 1 : 0, - (nego->requested_protocols & PROTOCOL_TLS) ? 1 : 0, - (nego->requested_protocols == PROTOCOL_RDP) ? 1 : 0 - ); - - DEBUG_WARN( "Server Security: NLA:%d TLS:%d RDP:%d\n", - settings->NlaSecurity, settings->TlsSecurity, settings->RdpSecurity); + WLog_INFO(TAG, "Client Security: NLA:%d TLS:%d RDP:%d", + (nego->requested_protocols & PROTOCOL_NLA) ? 1 : 0, + (nego->requested_protocols & PROTOCOL_TLS) ? 1 : 0, + (nego->requested_protocols == PROTOCOL_RDP) ? 1 : 0 + ); + WLog_INFO(TAG, "Server Security: NLA:%d TLS:%d RDP:%d", + settings->NlaSecurity, settings->TlsSecurity, settings->RdpSecurity); if ((settings->NlaSecurity) && (nego->requested_protocols & PROTOCOL_NLA)) { @@ -995,14 +996,14 @@ BOOL rdp_server_accept_nego(rdpRdp* rdp, wStream* s) } else { - DEBUG_WARN( "Protocol security negotiation failure\n"); + WLog_ERR(TAG, "Protocol security negotiation failure"); } - DEBUG_WARN( "Negotiated Security: NLA:%d TLS:%d RDP:%d\n", - (nego->selected_protocol & PROTOCOL_NLA) ? 1 : 0, - (nego->selected_protocol & PROTOCOL_TLS) ? 1 : 0, - (nego->selected_protocol == PROTOCOL_RDP) ? 1: 0 - ); + WLog_INFO(TAG, "Negotiated Security: NLA:%d TLS:%d RDP:%d", + (nego->selected_protocol & PROTOCOL_NLA) ? 1 : 0, + (nego->selected_protocol & PROTOCOL_TLS) ? 1 : 0, + (nego->selected_protocol == PROTOCOL_RDP) ? 1: 0 + ); if (!nego_send_negotiation_response(nego)) return FALSE; @@ -1034,14 +1035,13 @@ BOOL rdp_server_accept_mcs_connect_initial(rdpRdp* rdp, wStream* s) if (!mcs_recv_connect_initial(mcs, s)) return FALSE; - DEBUG_WARN( "Accepted client: %s\n", rdp->settings->ClientHostname); - DEBUG_WARN( "Accepted channels:"); + WLog_INFO(TAG, "Accepted client: %s", rdp->settings->ClientHostname); + WLog_INFO(TAG, "Accepted channels:"); for (i = 0; i < mcs->channelCount; i++) { - DEBUG_WARN( " %s", mcs->channels[i].Name); + WLog_INFO(TAG, " %s", mcs->channels[i].Name); } - DEBUG_WARN( "\n"); if (!mcs_send_connect_response(mcs)) return FALSE; diff --git a/libfreerdp/core/errinfo.c b/libfreerdp/core/errinfo.c index cb99558f2..0411ed067 100644 --- a/libfreerdp/core/errinfo.c +++ b/libfreerdp/core/errinfo.c @@ -23,10 +23,12 @@ #include -#include +#include #include "errinfo.h" +#define TAG FREERDP_TAG("core") + int connectErrorCode; /* Protocol-independent codes */ @@ -565,12 +567,12 @@ void rdp_print_errinfo(UINT32 code) { if (code == errInfo->code) { - DEBUG_WARN( "%s (0x%08X):\n%s\n", errInfo->name, code, errInfo->info); + WLog_ERR(TAG, "%s (0x%08X):%s", errInfo->name, code, errInfo->info); return; } errInfo++; } - DEBUG_WARN( "ERRINFO_UNKNOWN 0x%08X: Unknown error.\n", code); + WLog_ERR(TAG, "ERRINFO_UNKNOWN 0x%08X: Unknown error.", code); } diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index d3543ef88..300e31bf3 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -30,6 +30,7 @@ #include #include +#include #include #include "orders.h" @@ -38,6 +39,8 @@ #include "fastpath.h" #include "rdp.h" +#define TAG FREERDP_TAG("core.fastpath") + /** * Fast-Path packet format is defined in [MS-RDPBCGR] 2.2.9.1.2, which revises * server output packets from the first byte with the goal of improving @@ -271,7 +274,7 @@ static int fastpath_recv_update(rdpFastPath* fastpath, BYTE updateCode, UINT32 s case FASTPATH_UPDATETYPE_SYNCHRONIZE: if (!fastpath_recv_update_synchronize(fastpath, s)) - DEBUG_WARN( "fastpath_recv_update_synchronize failure but we continue\n"); + WLog_ERR(TAG, "fastpath_recv_update_synchronize failure but we continue"); else IFCALL(update->Synchronize, context); break; @@ -316,7 +319,7 @@ static int fastpath_recv_update(rdpFastPath* fastpath, BYTE updateCode, UINT32 s break; default: - DEBUG_WARN("unknown updateCode 0x%X", updateCode); + WLog_ERR(TAG, "unknown updateCode 0x%X", updateCode); break; } @@ -377,7 +380,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) if (bulkStatus < 0) { - DEBUG_WARN( "bulk_decompress() failed\n"); + WLog_ERR(TAG, "bulk_decompress() failed"); return -1; } @@ -398,7 +401,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) { if (fastpath->fragmentation != -1) { - DEBUG_WARN( "Unexpected FASTPATH_FRAGMENT_SINGLE\n"); + WLog_ERR(TAG, "Unexpected FASTPATH_FRAGMENT_SINGLE"); return -1; } @@ -414,7 +417,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) { if (fastpath->fragmentation != -1) { - DEBUG_WARN( "Unexpected FASTPATH_FRAGMENT_FIRST\n"); + WLog_ERR(TAG, "Unexpected FASTPATH_FRAGMENT_FIRST"); return -1; } @@ -424,8 +427,8 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) if (totalSize > transport->settings->MultifragMaxRequestSize) { - DEBUG_WARN( "Total size (%d) exceeds MultifragMaxRequestSize (%d)\n", - totalSize, transport->settings->MultifragMaxRequestSize); + WLog_ERR(TAG, "Total size (%d) exceeds MultifragMaxRequestSize (%d)", + totalSize, transport->settings->MultifragMaxRequestSize); return -1; } @@ -439,7 +442,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) if ((fastpath->fragmentation != FASTPATH_FRAGMENT_FIRST) && (fastpath->fragmentation != FASTPATH_FRAGMENT_NEXT)) { - DEBUG_WARN( "Unexpected FASTPATH_FRAGMENT_NEXT\n"); + WLog_ERR(TAG, "Unexpected FASTPATH_FRAGMENT_NEXT"); return -1; } @@ -449,8 +452,8 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) if (totalSize > transport->settings->MultifragMaxRequestSize) { - DEBUG_WARN( "Total size (%d) exceeds MultifragMaxRequestSize (%d)\n", - totalSize, transport->settings->MultifragMaxRequestSize); + WLog_ERR(TAG, "Total size (%d) exceeds MultifragMaxRequestSize (%d)", + totalSize, transport->settings->MultifragMaxRequestSize); return -1; } @@ -463,7 +466,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) if ((fastpath->fragmentation != FASTPATH_FRAGMENT_FIRST) && (fastpath->fragmentation != FASTPATH_FRAGMENT_NEXT)) { - DEBUG_WARN( "Unexpected FASTPATH_FRAGMENT_LAST\n"); + WLog_ERR(TAG, "Unexpected FASTPATH_FRAGMENT_LAST"); return -1; } @@ -473,8 +476,8 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) if (totalSize > transport->settings->MultifragMaxRequestSize) { - DEBUG_WARN( "Total size (%d) exceeds MultifragMaxRequestSize (%d)\n", - totalSize, transport->settings->MultifragMaxRequestSize); + WLog_ERR(TAG, "Total size (%d) exceeds MultifragMaxRequestSize (%d)", + totalSize, transport->settings->MultifragMaxRequestSize); return -1; } @@ -661,7 +664,7 @@ static BOOL fastpath_recv_input_event(rdpFastPath* fastpath, wStream* s) break; default: - DEBUG_WARN( "Unknown eventCode %d\n", eventCode); + WLog_ERR(TAG, "Unknown eventCode %d", eventCode); break; } @@ -768,7 +771,7 @@ BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, int iNu if (length >= (2 << 14)) { - DEBUG_WARN( "Maximum FastPath PDU length is 32767\n"); + WLog_ERR(TAG, "Maximum FastPath PDU length is 32767"); return FALSE; } diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 65a201e2b..196a6cd88 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -41,6 +41,9 @@ #include #include #include +#include + +#define TAG FREERDP_TAG("core") /* connectErrorCode is 'extern' in error.h. See comment there.*/ @@ -90,8 +93,7 @@ BOOL freerdp_connect(freerdp* instance) freerdp_set_last_error(instance->context, FREERDP_ERROR_PRE_CONNECT_FAILED); } - DEBUG_WARN( "freerdp_pre_connect failed\n"); - + WLog_ERR(TAG, "freerdp_pre_connect failed"); goto freerdp_connect_finally; } @@ -100,7 +102,7 @@ BOOL freerdp_connect(freerdp* instance) /* --authonly tests the connection without a UI */ if (instance->settings->AuthenticationOnly) { - DEBUG_WARN( "Authentication only, exit status %d\n", !status); + WLog_ERR(TAG, "Authentication only, exit status %d", !status); goto freerdp_connect_finally; } @@ -118,7 +120,7 @@ BOOL freerdp_connect(freerdp* instance) if (!status) { - DEBUG_WARN( "freerdp_post_connect failed\n"); + WLog_ERR(TAG, "freerdp_post_connect failed"); if (!connectErrorCode) { @@ -485,7 +487,7 @@ UINT32 freerdp_get_last_error(rdpContext* context) void freerdp_set_last_error(rdpContext* context, UINT32 lastError) { if (lastError) - DEBUG_WARN( "freerdp_set_last_error 0x%04X\n", lastError); + WLog_ERR(TAG, "freerdp_set_last_error 0x%04X", lastError); context->LastError = lastError; } diff --git a/libfreerdp/core/gateway/http.c b/libfreerdp/core/gateway/http.c index a362f79ee..4cef378c8 100644 --- a/libfreerdp/core/gateway/http.c +++ b/libfreerdp/core/gateway/http.c @@ -26,7 +26,7 @@ #include #include -#include + #ifdef HAVE_VALGRIND_MEMCHECK_H #include @@ -476,10 +476,8 @@ void http_response_print(HttpResponse* http_response) for (i = 0; i < http_response->count; i++) { - DEBUG_WARN("%s\n", http_response->lines[i]); + WLog_ERR(TAG, "%s", http_response->lines[i]); } - - DEBUG_WARN("\n"); } HttpResponse* http_response_recv(rdpTls* tls) @@ -534,7 +532,7 @@ HttpResponse* http_response_recv(rdpTls* tls) if (!header_end) { - DEBUG_WARN("%s: invalid response:\n", __FUNCTION__); + WLog_ERR(TAG, "invalid response:"); winpr_HexDump(TAG, WLOG_ERROR, buffer, status); goto out_error; } diff --git a/libfreerdp/core/gateway/ncacn_http.h b/libfreerdp/core/gateway/ncacn_http.h index 9c1d54ce1..e01a7d368 100644 --- a/libfreerdp/core/gateway/ncacn_http.h +++ b/libfreerdp/core/gateway/ncacn_http.h @@ -26,7 +26,7 @@ #include #include -#include + #include diff --git a/libfreerdp/core/gateway/ntlm.c b/libfreerdp/core/gateway/ntlm.c index 44f77a6b2..eeb2500f6 100644 --- a/libfreerdp/core/gateway/ntlm.c +++ b/libfreerdp/core/gateway/ntlm.c @@ -31,12 +31,15 @@ #include #include +#include #include #include "http.h" #include "ntlm.h" +#define TAG FREERDP_TAG("core.gateway.ntlm") + BOOL ntlm_client_init(rdpNtlm* ntlm, BOOL http, char* user, char* domain, char* password, SecPkgContext_Bindings* Bindings) { SECURITY_STATUS status; @@ -71,7 +74,7 @@ BOOL ntlm_client_init(rdpNtlm* ntlm, BOOL http, char* user, char* domain, char* if (status != SEC_E_OK) { - DEBUG_WARN( "QuerySecurityPackageInfo status: 0x%08X\n", status); + WLog_ERR(TAG, "QuerySecurityPackageInfo status: 0x%08X", status); return FALSE; } @@ -82,7 +85,7 @@ BOOL ntlm_client_init(rdpNtlm* ntlm, BOOL http, char* user, char* domain, char* if (status != SEC_E_OK) { - DEBUG_WARN( "AcquireCredentialsHandle status: 0x%08X\n", status); + WLog_ERR(TAG, "AcquireCredentialsHandle status: 0x%08X", status); return FALSE; } @@ -235,7 +238,7 @@ BOOL ntlm_authenticate(rdpNtlm* ntlm) if ((!ntlm) || (!ntlm->table)) { - DEBUG_WARN( "ntlm_authenticate: invalid ntlm context\n"); + WLog_ERR(TAG, "ntlm_authenticate: invalid ntlm context"); return FALSE; } @@ -254,7 +257,7 @@ BOOL ntlm_authenticate(rdpNtlm* ntlm) if (ntlm->table->QueryContextAttributes(&ntlm->context, SECPKG_ATTR_SIZES, &ntlm->ContextSizes) != SEC_E_OK) { - DEBUG_WARN( "QueryContextAttributes SECPKG_ATTR_SIZES failure\n"); + WLog_ERR(TAG, "QueryContextAttributes SECPKG_ATTR_SIZES failure"); return FALSE; } diff --git a/libfreerdp/core/gateway/ntlm.h b/libfreerdp/core/gateway/ntlm.h index 257e84b05..ebe8c8bc2 100644 --- a/libfreerdp/core/gateway/ntlm.h +++ b/libfreerdp/core/gateway/ntlm.h @@ -37,7 +37,7 @@ typedef struct rdp_ntlm_http rdpNtlmHttp; #include #include #include -#include + #include #include diff --git a/libfreerdp/core/gateway/rpc.c b/libfreerdp/core/gateway/rpc.c index 5bf19d4d9..0dbb4efd9 100644 --- a/libfreerdp/core/gateway/rpc.c +++ b/libfreerdp/core/gateway/rpc.c @@ -31,6 +31,7 @@ #include #include #include + #include #include @@ -49,7 +50,8 @@ #include "rpc.h" -#define TAG FREERDP_TAG("core.gateway") +#define TAG FREERDP_TAG("core.gateway.rpc") + /* Security Verification Trailer Signature */ rpc_sec_verification_trailer RPC_SEC_VERIFICATION_TRAILER = @@ -94,51 +96,51 @@ const RPC_SECURITY_PROVIDER_INFO RPC_SECURITY_PROVIDER_INFO_TABLE[] = void rpc_pdu_header_print(rpcconn_hdr_t* header) { - DEBUG_WARN("rpc_vers: %d\n", header->common.rpc_vers); - DEBUG_WARN("rpc_vers_minor: %d\n", header->common.rpc_vers_minor); + WLog_INFO(TAG, "rpc_vers: %d", header->common.rpc_vers); + WLog_INFO(TAG, "rpc_vers_minor: %d", header->common.rpc_vers_minor); if (header->common.ptype > PTYPE_RTS) - DEBUG_WARN("ptype: %s (%d)\n", "PTYPE_UNKNOWN", header->common.ptype); + WLog_INFO(TAG, "ptype: %s (%d)", "PTYPE_UNKNOWN", header->common.ptype); else - DEBUG_WARN("ptype: %s (%d)\n", PTYPE_STRINGS[header->common.ptype], header->common.ptype); + WLog_INFO(TAG, "ptype: %s (%d)", PTYPE_STRINGS[header->common.ptype], header->common.ptype); - DEBUG_WARN("pfc_flags (0x%02X) = {", header->common.pfc_flags); + WLog_INFO(TAG, "pfc_flags (0x%02X) = {", header->common.pfc_flags); if (header->common.pfc_flags & PFC_FIRST_FRAG) - DEBUG_WARN(" PFC_FIRST_FRAG"); + WLog_INFO(TAG, " PFC_FIRST_FRAG"); if (header->common.pfc_flags & PFC_LAST_FRAG) - DEBUG_WARN(" PFC_LAST_FRAG"); + WLog_INFO(TAG, " PFC_LAST_FRAG"); if (header->common.pfc_flags & PFC_PENDING_CANCEL) - DEBUG_WARN(" PFC_PENDING_CANCEL"); + WLog_INFO(TAG, " PFC_PENDING_CANCEL"); if (header->common.pfc_flags & PFC_RESERVED_1) - DEBUG_WARN(" PFC_RESERVED_1"); + WLog_INFO(TAG, " PFC_RESERVED_1"); if (header->common.pfc_flags & PFC_CONC_MPX) - DEBUG_WARN(" PFC_CONC_MPX"); + WLog_INFO(TAG, " PFC_CONC_MPX"); if (header->common.pfc_flags & PFC_DID_NOT_EXECUTE) - DEBUG_WARN(" PFC_DID_NOT_EXECUTE"); + WLog_INFO(TAG, " PFC_DID_NOT_EXECUTE"); if (header->common.pfc_flags & PFC_OBJECT_UUID) - DEBUG_WARN(" PFC_OBJECT_UUID"); + WLog_INFO(TAG, " PFC_OBJECT_UUID"); - DEBUG_WARN(" }\n"); - DEBUG_WARN("packed_drep[4]: %02X %02X %02X %02X\n", - header->common.packed_drep[0], header->common.packed_drep[1], - header->common.packed_drep[2], header->common.packed_drep[3]); - DEBUG_WARN("frag_length: %d\n", header->common.frag_length); - DEBUG_WARN("auth_length: %d\n", header->common.auth_length); - DEBUG_WARN("call_id: %d\n", header->common.call_id); + WLog_INFO(TAG, " }"); + WLog_INFO(TAG, "packed_drep[4]: %02X %02X %02X %02X", + header->common.packed_drep[0], header->common.packed_drep[1], + header->common.packed_drep[2], header->common.packed_drep[3]); + WLog_INFO(TAG, "frag_length: %d", header->common.frag_length); + WLog_INFO(TAG, "auth_length: %d", header->common.auth_length); + WLog_INFO(TAG, "call_id: %d", header->common.call_id); if (header->common.ptype == PTYPE_RESPONSE) { - DEBUG_WARN("alloc_hint: %d\n", header->response.alloc_hint); - DEBUG_WARN("p_cont_id: %d\n", header->response.p_cont_id); - DEBUG_WARN("cancel_count: %d\n", header->response.cancel_count); - DEBUG_WARN("reserved: %d\n", header->response.reserved); + WLog_INFO(TAG, "alloc_hint: %d", header->response.alloc_hint); + WLog_INFO(TAG, "p_cont_id: %d", header->response.p_cont_id); + WLog_INFO(TAG, "cancel_count: %d", header->response.cancel_count); + WLog_INFO(TAG, "reserved: %d", header->response.reserved); } } @@ -270,7 +272,7 @@ BOOL rpc_get_stub_data_info(rdpRpc* rpc, BYTE* buffer, UINT32* offset, UINT32* l *offset += 4; break; default: - DEBUG_WARN("%s: unknown ptype=0x%x\n", __FUNCTION__, header->common.ptype); + WLog_ERR(TAG, "unknown ptype=0x%x", header->common.ptype); return FALSE; } @@ -291,12 +293,12 @@ BOOL rpc_get_stub_data_info(rdpRpc* rpc, BYTE* buffer, UINT32* offset, UINT32* l sec_trailer = (rpc_sec_trailer*) &buffer[sec_trailer_offset]; auth_pad_length = sec_trailer->auth_pad_length; #if 0 - DEBUG_WARN("sec_trailer: type: %d level: %d pad_length: %d reserved: %d context_id: %d\n", - sec_trailer->auth_type, - sec_trailer->auth_level, - sec_trailer->auth_pad_length, - sec_trailer->auth_reserved, - sec_trailer->auth_context_id); + WLog_DBG(TAG, "sec_trailer: type: %d level: %d pad_length: %d reserved: %d context_id: %d", + sec_trailer->auth_type, + sec_trailer->auth_level, + sec_trailer->auth_pad_length, + sec_trailer->auth_reserved, + sec_trailer->auth_context_id); #endif /** @@ -307,8 +309,8 @@ BOOL rpc_get_stub_data_info(rdpRpc* rpc, BYTE* buffer, UINT32* offset, UINT32* l if ((frag_length - (sec_trailer_offset + 8)) != auth_length) { - DEBUG_WARN("invalid auth_length: actual: %d, expected: %d\n", auth_length, - (frag_length - (sec_trailer_offset + 8))); + WLog_ERR(TAG, "invalid auth_length: actual: %d, expected: %d", auth_length, + (frag_length - (sec_trailer_offset + 8))); } *length = frag_length - auth_length - 24 - 8 - auth_pad_length; @@ -345,10 +347,9 @@ int rpc_in_write(rdpRpc* rpc, const BYTE* data, int length) { int status; #ifdef WITH_DEBUG_TSG - DEBUG_WARN("Sending PDU (length: %d)\n", length); + WLog_DBG(TAG, "Sending PDU (length: %d)", length); rpc_pdu_header_print((rpcconn_hdr_t*) data); winpr_HexDump(TAG, WLOG_DEBUG, data, length); - DEBUG_WARN("\n"); #endif status = tls_write_all(rpc->TlsIn, data, length); return status; @@ -369,13 +370,13 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum) if (!ntlm || !ntlm->table) { - DEBUG_WARN("%s: invalid ntlm context\n", __FUNCTION__); + WLog_ERR(TAG, "invalid ntlm context"); return -1; } if (ntlm->table->QueryContextAttributes(&ntlm->context, SECPKG_ATTR_SIZES, &ntlm->ContextSizes) != SEC_E_OK) { - DEBUG_WARN("%s: QueryContextAttributes SECPKG_ATTR_SIZES failure\n", __FUNCTION__); + WLog_ERR(TAG, "QueryContextAttributes SECPKG_ATTR_SIZES failure"); return -1; } @@ -445,7 +446,7 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum) if (encrypt_status != SEC_E_OK) { - DEBUG_WARN("EncryptMessage status: 0x%08X\n", encrypt_status); + WLog_ERR(TAG, "EncryptMessage status: 0x%08X", encrypt_status); free(request_pdu); return -1; } @@ -473,7 +474,7 @@ BOOL rpc_connect(rdpRpc* rpc) if (!rts_connect(rpc)) { - DEBUG_WARN("rts_connect error!\n"); + WLog_ERR(TAG, "rts_connect error!"); return FALSE; } @@ -481,7 +482,7 @@ BOOL rpc_connect(rdpRpc* rpc) if (rpc_secure_bind(rpc) != 0) { - DEBUG_WARN("rpc_secure_bind error!\n"); + WLog_ERR(TAG, "rpc_secure_bind error!"); return FALSE; } diff --git a/libfreerdp/core/gateway/rpc.h b/libfreerdp/core/gateway/rpc.h index c86a8618f..f201aae73 100644 --- a/libfreerdp/core/gateway/rpc.h +++ b/libfreerdp/core/gateway/rpc.h @@ -26,6 +26,7 @@ #include #include #include +#include typedef struct rdp_rpc rdpRpc; @@ -76,7 +77,7 @@ typedef struct _RPC_PDU #include #include #include -#include + #include /** @@ -786,10 +787,11 @@ void rpc_free(rdpRpc* rpc); #define WITH_DEBUG_RPC #endif +#define RPC_TAG FREERDP_TAG("core.gateway.rpc") #ifdef WITH_DEBUG_RPC -#define DEBUG_RPC(fmt, ...) DEBUG_CLASS(RPC, fmt, ## __VA_ARGS__) +#define DEBUG_RPC(fmt, ...) WLog_DBG(RPC_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_RPC(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_RPC(fmt, ...) do { } while (0) #endif #endif /* FREERDP_CORE_RPC_H */ diff --git a/libfreerdp/core/gateway/rpc_bind.c b/libfreerdp/core/gateway/rpc_bind.c index b7674ee02..82745d859 100644 --- a/libfreerdp/core/gateway/rpc_bind.c +++ b/libfreerdp/core/gateway/rpc_bind.c @@ -26,11 +26,14 @@ #include #include +#include #include "rpc_client.h" #include "rpc_bind.h" +#define TAG FREERDP_TAG("core.gateway.rpc_bind") + /** * Connection-Oriented RPC Protocol Client Details: * http://msdn.microsoft.com/en-us/library/cc243724/ @@ -391,7 +394,7 @@ int rpc_secure_bind(rdpRpc* rpc) if (status <= 0) { - DEBUG_WARN( "rpc_secure_bind: error sending bind pdu!\n"); + WLog_ERR(TAG, "rpc_secure_bind: error sending bind pdu!"); return -1; } @@ -403,13 +406,13 @@ int rpc_secure_bind(rdpRpc* rpc) if (!pdu) { - DEBUG_WARN( "rpc_secure_bind: error receiving bind ack pdu!\n"); + WLog_ERR(TAG, "rpc_secure_bind: error receiving bind ack pdu!"); return -1; } if (rpc_recv_bind_ack_pdu(rpc, Stream_Buffer(pdu->s), Stream_Length(pdu->s)) <= 0) { - DEBUG_WARN( "rpc_secure_bind: error receiving bind ack pdu!\n"); + WLog_ERR(TAG, "rpc_secure_bind: error receiving bind ack pdu!"); return -1; } @@ -417,7 +420,7 @@ int rpc_secure_bind(rdpRpc* rpc) if (rpc_send_rpc_auth_3_pdu(rpc) <= 0) { - DEBUG_WARN( "rpc_secure_bind: error sending rpc_auth_3 pdu!\n"); + WLog_ERR(TAG, "rpc_secure_bind: error sending rpc_auth_3 pdu!"); return -1; } @@ -425,7 +428,7 @@ int rpc_secure_bind(rdpRpc* rpc) } else { - DEBUG_WARN( "rpc_secure_bind: invalid state: %d\n", rpc->State); + WLog_ERR(TAG, "rpc_secure_bind: invalid state: %d", rpc->State); return -1; } } diff --git a/libfreerdp/core/gateway/rpc_client.c b/libfreerdp/core/gateway/rpc_client.c index 1a44e75a6..9cedda0ec 100644 --- a/libfreerdp/core/gateway/rpc_client.c +++ b/libfreerdp/core/gateway/rpc_client.c @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -37,7 +38,7 @@ #include "rpc_client.h" #include "../rdp.h" -#define TAG "gateway" +#define TAG FREERDP_TAG("core.gateway") #define SYNCHRONOUS_TIMEOUT 5000 wStream* rpc_client_fragment_pool_take(rdpRpc* rpc) @@ -131,11 +132,11 @@ int rpc_client_on_fragment_received_event(rdpRpc* rpc) if (rpc->VirtualConnection->State < VIRTUAL_CONNECTION_STATE_OPENED) { - DEBUG_WARN("%s: warning: unhandled RTS PDU\n", __FUNCTION__); + WLog_ERR(TAG, "warning: unhandled RTS PDU"); return 0; } - DEBUG_WARN("%s: Receiving Out-of-Sequence RTS PDU\n", __FUNCTION__); + WLog_ERR(TAG, "Receiving Out-of-Sequence RTS PDU"); rts_recv_out_of_sequence_pdu(rpc, buffer, header->common.frag_length); rpc_client_fragment_pool_return(rpc, fragment); return 0; @@ -146,7 +147,7 @@ int rpc_client_on_fragment_received_event(rdpRpc* rpc) case PTYPE_RESPONSE: break; default: - DEBUG_WARN("%s: unexpected RPC PDU type %d\n", __FUNCTION__, header->common.ptype); + WLog_ERR(TAG, "unexpected RPC PDU type %d", header->common.ptype); Queue_Enqueue(rpc->client->ReceiveQueue, NULL); return -1; } @@ -156,15 +157,15 @@ int rpc_client_on_fragment_received_event(rdpRpc* rpc) if (!rpc_get_stub_data_info(rpc, buffer, &StubOffset, &StubLength)) { - DEBUG_WARN("%s: expected stub\n", __FUNCTION__); + WLog_ERR(TAG, "expected stub"); Queue_Enqueue(rpc->client->ReceiveQueue, NULL); return -1; } if (StubLength == 4) { - //DEBUG_WARN( "Ignoring TsProxySendToServer Response\n"); - //DEBUG_MSG("Got stub length 4 with flags %d and callid %d\n", header->common.pfc_flags, header->common.call_id); + //WLog_ERR(TAG, "Ignoring TsProxySendToServer Response"); + //WLog_DBG(TAG, "Got stub length 4 with flags %d and callid %d", header->common.pfc_flags, header->common.call_id); /* received a disconnect request from the server? */ if ((header->common.call_id == rpc->PipeCallId) && (header->common.pfc_flags & PFC_LAST_FRAG)) @@ -190,8 +191,8 @@ int rpc_client_on_fragment_received_event(rdpRpc* rpc) if (rpc->StubCallId != header->common.call_id) { - DEBUG_WARN("%s: invalid call_id: actual: %d, expected: %d, frag_count: %d\n", __FUNCTION__, - rpc->StubCallId, header->common.call_id, rpc->StubFragCount); + WLog_ERR(TAG, "invalid call_id: actual: %d, expected: %d, frag_count: %d", + rpc->StubCallId, header->common.call_id, rpc->StubFragCount); } Stream_Write(rpc->client->pdu->s, &buffer[StubOffset], StubLength); @@ -200,7 +201,7 @@ int rpc_client_on_fragment_received_event(rdpRpc* rpc) if (rpc->VirtualConnection->DefaultOutChannel->ReceiverAvailableWindow < (rpc->ReceiveWindow / 2)) { - //DEBUG_WARN( "Sending Flow Control Ack PDU\n"); + //WLog_ERR(TAG, "Sending Flow Control Ack PDU"); rts_send_flow_control_ack_pdu(rpc); } @@ -245,7 +246,7 @@ int rpc_client_on_read_event(rdpRpc* rpc) if (status < 0) { - DEBUG_WARN("rpc_client_frag_read: error reading header\n"); + WLog_ERR(TAG, "rpc_client_frag_read: error reading header"); return -1; } @@ -262,8 +263,8 @@ int rpc_client_on_read_event(rdpRpc* rpc) if (header->frag_length > rpc->max_recv_frag) { - DEBUG_WARN("rpc_client_frag_read: invalid fragment size: %d (max: %d)\n", - header->frag_length, rpc->max_recv_frag); + WLog_ERR(TAG, "rpc_client_frag_read: invalid fragment size: %d (max: %d)", + header->frag_length, rpc->max_recv_frag); winpr_HexDump(TAG, WLOG_ERROR, Stream_Buffer(rpc->client->RecvFrag), Stream_GetPosition(rpc->client->RecvFrag)); return -1; } @@ -275,7 +276,7 @@ int rpc_client_on_read_event(rdpRpc* rpc) if (status < 0) { - DEBUG_WARN("%s: error reading fragment body\n", __FUNCTION__); + WLog_ERR(TAG, "error reading fragment body"); return -1; } @@ -374,7 +375,7 @@ int rpc_send_enqueue_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length) if (status == WAIT_TIMEOUT) { - DEBUG_WARN("%s: timed out waiting for pdu sent event %p\n", __FUNCTION__, rpc->client->PduSentEvent); + WLog_ERR(TAG, "timed out waiting for pdu sent event %p", rpc->client->PduSentEvent); return -1; } @@ -441,7 +442,7 @@ RPC_PDU* rpc_recv_dequeue_pdu(rdpRpc* rpc) if (result == WAIT_TIMEOUT) { - DEBUG_WARN("%s: timed out waiting for receive event\n", __FUNCTION__); + WLog_ERR(TAG, "timed out waiting for receive event"); return NULL; } @@ -453,13 +454,12 @@ RPC_PDU* rpc_recv_dequeue_pdu(rdpRpc* rpc) if (pdu) { - DEBUG_WARN("Receiving PDU (length: %d, CallId: %d)\n", pdu->s->length, pdu->CallId); + WLog_DBG(TAG, "Receiving PDU (length: %d, CallId: %d)", pdu->s->length, pdu->CallId); winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(pdu->s), Stream_Length(pdu->s)); - DEBUG_WARN("\n"); } else { - DEBUG_WARN("Receiving a NULL PDU\n"); + WLog_DBG(TAG, "Receiving a NULL PDU"); } #endif @@ -502,7 +502,7 @@ static void* rpc_client_thread(void* arg) */ if (rpc_client_on_read_event(rpc) < 0) { - DEBUG_WARN("%s: an error occured when treating first packet\n", __FUNCTION__); + WLog_ERR(TAG, "an error occured when treating first packet"); goto out; } diff --git a/libfreerdp/core/gateway/rpc_fault.c b/libfreerdp/core/gateway/rpc_fault.c index a1cf9a44c..ca758befb 100644 --- a/libfreerdp/core/gateway/rpc_fault.c +++ b/libfreerdp/core/gateway/rpc_fault.c @@ -21,8 +21,12 @@ #include "config.h" #endif +#include + #include "rpc_fault.h" +#define TAG FREERDP_TAG("core.gateway.rpc") + extern const RPC_FAULT_CODE RPC_TSG_FAULT_CODES[]; const RPC_FAULT_CODE RPC_FAULT_CODES[] = @@ -314,16 +318,14 @@ int rpc_recv_fault_pdu(rpcconn_hdr_t* header) { int index; UINT32 code; - - DEBUG_WARN( "RPC Fault PDU:\n"); - + WLog_ERR(TAG, "RPC Fault PDU:"); code = rpc_map_status_code_to_win32_error_code(header->fault.status); for (index = 0; RPC_FAULT_CODES[index].name != NULL; index++) { if (RPC_FAULT_CODES[index].code == code) { - DEBUG_WARN( "status: %s (0x%08X)\n", RPC_FAULT_CODES[index].name, code); + WLog_ERR(TAG, "status: %s (0x%08X)", RPC_FAULT_CODES[index].name, code); return 0; } } @@ -332,12 +334,11 @@ int rpc_recv_fault_pdu(rpcconn_hdr_t* header) { if (RPC_TSG_FAULT_CODES[index].code == code) { - DEBUG_WARN( "status: %s (0x%08X)\n", RPC_TSG_FAULT_CODES[index].name, code); + WLog_ERR(TAG, "status: %s (0x%08X)", RPC_TSG_FAULT_CODES[index].name, code); return 0; } } - DEBUG_WARN( "status: %s (0x%08X)\n", "UNKNOWN", code); - + WLog_ERR(TAG, "status: %s (0x%08X)", "UNKNOWN", code); return 0; } diff --git a/libfreerdp/core/gateway/rts.c b/libfreerdp/core/gateway/rts.c index 29105558c..ca11fdb3f 100644 --- a/libfreerdp/core/gateway/rts.c +++ b/libfreerdp/core/gateway/rts.c @@ -24,11 +24,15 @@ #include #include +#include + #include "ncacn_http.h" #include "rpc_client.h" #include "rts.h" +#define TAG FREERDP_TAG("core.gateway.rts") + /** * [MS-RPCH]: Remote Procedure Call over HTTP Protocol Specification: * http://msdn.microsoft.com/en-us/library/cc243950/ @@ -93,25 +97,25 @@ BOOL rts_connect(rdpRpc* rpc) if (!rpc_ntlm_http_out_connect(rpc)) { - DEBUG_WARN( "%s: rpc_out_connect_http error!\n", __FUNCTION__); + WLog_ERR(TAG, "rpc_out_connect_http error!"); return FALSE; } if (rts_send_CONN_A1_pdu(rpc) != 0) { - DEBUG_WARN( "%s: rpc_send_CONN_A1_pdu error!\n", __FUNCTION__); + WLog_ERR(TAG, "rpc_send_CONN_A1_pdu error!"); return FALSE; } if (!rpc_ntlm_http_in_connect(rpc)) { - DEBUG_WARN( "%s: rpc_in_connect_http error!\n", __FUNCTION__); + WLog_ERR(TAG, "rpc_in_connect_http error!"); return FALSE; } if (rts_send_CONN_B1_pdu(rpc) < 0) { - DEBUG_WARN( "%s: rpc_send_CONN_B1_pdu error!\n", __FUNCTION__); + WLog_ERR(TAG, "rpc_send_CONN_B1_pdu error!"); return FALSE; } @@ -149,13 +153,13 @@ BOOL rts_connect(rdpRpc* rpc) http_response = http_response_recv(rpc->TlsOut); if (!http_response) { - DEBUG_WARN( "%s: unable to retrieve OUT Channel Response!\n", __FUNCTION__); + WLog_ERR(TAG, "unable to retrieve OUT Channel Response!"); return FALSE; } if (http_response->StatusCode != HTTP_STATUS_OK) { - DEBUG_WARN( "%s: error! Status Code: %d\n", __FUNCTION__, http_response->StatusCode); + WLog_ERR(TAG, "error! Status Code: %d", http_response->StatusCode); http_response_print(http_response); http_response_free(http_response); @@ -215,7 +219,7 @@ BOOL rts_connect(rdpRpc* rpc) if (!rts_match_pdu_signature(rpc, &RTS_PDU_CONN_A3_SIGNATURE, rts)) { - DEBUG_WARN( "%s: unexpected RTS PDU: Expected CONN/A3\n", __FUNCTION__); + WLog_ERR(TAG, "unexpected RTS PDU: Expected CONN/A3"); return FALSE; } @@ -255,7 +259,7 @@ BOOL rts_connect(rdpRpc* rpc) if (!rts_match_pdu_signature(rpc, &RTS_PDU_CONN_C2_SIGNATURE, rts)) { - DEBUG_WARN( "%s: unexpected RTS PDU: Expected CONN/C2\n", __FUNCTION__); + WLog_ERR(TAG, "unexpected RTS PDU: Expected CONN/C2"); return FALSE; } @@ -880,9 +884,9 @@ int rts_recv_flow_control_ack_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length) &BytesReceived, &AvailableWindow, (BYTE*) &ChannelCookie) + 4; #if 0 - DEBUG_WARN( "BytesReceived: %d AvailableWindow: %d\n", - BytesReceived, AvailableWindow); - DEBUG_WARN( "ChannelCookie: " RPC_UUID_FORMAT_STRING "\n", RPC_UUID_FORMAT_ARGUMENTS(ChannelCookie)); + WLog_ERR(TAG, "BytesReceived: %d AvailableWindow: %d", + BytesReceived, AvailableWindow); + WLog_ERR(TAG, "ChannelCookie: " RPC_UUID_FORMAT_STRING "", RPC_UUID_FORMAT_ARGUMENTS(ChannelCookie)); #endif rpc->VirtualConnection->DefaultInChannel->SenderAvailableWindow = @@ -921,9 +925,9 @@ int rts_recv_flow_control_ack_with_destination_pdu(rdpRpc* rpc, BYTE* buffer, UI &BytesReceived, &AvailableWindow, (BYTE*) &ChannelCookie) + 4; #if 0 - DEBUG_WARN( "Destination: %d BytesReceived: %d AvailableWindow: %d\n", - Destination, BytesReceived, AvailableWindow); - DEBUG_WARN( "ChannelCookie: " RPC_UUID_FORMAT_STRING "\n", RPC_UUID_FORMAT_ARGUMENTS(ChannelCookie)); + WLog_ERR(TAG, "Destination: %d BytesReceived: %d AvailableWindow: %d", + Destination, BytesReceived, AvailableWindow); + WLog_ERR(TAG, "ChannelCookie: " RPC_UUID_FORMAT_STRING "", RPC_UUID_FORMAT_ARGUMENTS(ChannelCookie)); #endif rpc->VirtualConnection->DefaultInChannel->SenderAvailableWindow = @@ -1027,7 +1031,7 @@ int rts_command_length(rdpRpc* rpc, UINT32 CommandType, BYTE* buffer, UINT32 len break; default: - DEBUG_WARN( "Error: Unknown RTS Command Type: 0x%x\n", CommandType); + WLog_ERR(TAG, "Error: Unknown RTS Command Type: 0x%x", CommandType); return -1; break; } @@ -1055,7 +1059,7 @@ int rts_recv_out_of_sequence_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length) case RTS_PDU_PING: return rts_send_ping_pdu(rpc); default: - DEBUG_WARN( "%s: unimplemented signature id: 0x%08X\n", __FUNCTION__, SignatureId); + WLog_ERR(TAG, "unimplemented signature id: 0x%08X", SignatureId); rts_print_pdu_signature(rpc, &signature); break; } diff --git a/libfreerdp/core/gateway/rts.h b/libfreerdp/core/gateway/rts.h index f26956f53..a0fd620a9 100644 --- a/libfreerdp/core/gateway/rts.h +++ b/libfreerdp/core/gateway/rts.h @@ -28,7 +28,7 @@ #include #include -#include +#include #define RTS_FLAG_NONE 0x0000 #define RTS_FLAG_PING 0x0001 @@ -147,10 +147,11 @@ int rts_recv_out_of_sequence_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length); #define WITH_DEBUG_RTS #endif +#define RTS_TAG FREERDP_TAG("core.gateway.rts") #ifdef WITH_DEBUG_RTS -#define DEBUG_RTS(fmt, ...) DEBUG_CLASS(RTS, fmt, ## __VA_ARGS__) +#define DEBUG_RTS(fmt, ...) WLog_DBG(RTS_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_RTS(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_RTS(fmt, ...) do { } while (0) #endif #endif /* FREERDP_CORE_RTS_H */ diff --git a/libfreerdp/core/gateway/rts_signature.c b/libfreerdp/core/gateway/rts_signature.c index e52e09b1a..b9d9ccc1b 100644 --- a/libfreerdp/core/gateway/rts_signature.c +++ b/libfreerdp/core/gateway/rts_signature.c @@ -17,8 +17,12 @@ * limitations under the License. */ +#include + #include "rts_signature.h" +#define TAG FREERDP_TAG("core.gateway") + RtsPduSignature RTS_PDU_CONN_A1_SIGNATURE = { RTS_FLAG_NONE, 4, { RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0, 0 } }; RtsPduSignature RTS_PDU_CONN_A2_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 5, @@ -317,14 +321,12 @@ int rts_print_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature) { UINT32 SignatureId; RTS_PDU_SIGNATURE_ENTRY* entry; - - DEBUG_WARN( "RTS PDU Signature: Flags: 0x%04X NumberOfCommands: %d\n", - signature->Flags, signature->NumberOfCommands); - + WLog_INFO(TAG, "RTS PDU Signature: Flags: 0x%04X NumberOfCommands: %d", + signature->Flags, signature->NumberOfCommands); SignatureId = rts_identify_pdu_signature(rpc, signature, &entry); if (SignatureId) - DEBUG_WARN( "Identified %s RTS PDU\n", entry->PduName); + WLog_ERR(TAG, "Identified %s RTS PDU", entry->PduName); return 0; } diff --git a/libfreerdp/core/gateway/tsg.c b/libfreerdp/core/gateway/tsg.c index a9b6c503d..f23f90306 100644 --- a/libfreerdp/core/gateway/tsg.c +++ b/libfreerdp/core/gateway/tsg.c @@ -35,7 +35,7 @@ #include "rpc_client.h" #include "tsg.h" -#define TAG FREERDP_TAG("core") +#define TAG FREERDP_TAG("core.gateway.tsg") /** * RPC Functions: http://msdn.microsoft.com/en-us/library/windows/desktop/aa378623/ @@ -132,7 +132,7 @@ DWORD TsProxySendToServer(handle_t IDL_handle, byte pRpcMessage[], UINT32 count, if (status <= 0) { - DEBUG_WARN("rpc_write failed!\n"); + WLog_ERR(TAG, "rpc_write failed!"); return -1; } @@ -289,8 +289,8 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu) if (versionCaps->tsgHeader.ComponentId != TS_GATEWAY_TRANSPORT) { - DEBUG_WARN("Unexpected ComponentId: 0x%04X, Expected TS_GATEWAY_TRANSPORT\n", - versionCaps->tsgHeader.ComponentId); + WLog_ERR(TAG, "Unexpected ComponentId: 0x%04X, Expected TS_GATEWAY_TRANSPORT", + versionCaps->tsgHeader.ComponentId); free(packetCapsResponse); free(versionCaps); free(packet); @@ -318,8 +318,8 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu) if ((SwitchValue != TSG_CAPABILITY_TYPE_NAP) || (tsgCaps->capabilityType != TSG_CAPABILITY_TYPE_NAP)) { - DEBUG_WARN("Unexpected CapabilityType: 0x%08X, Expected TSG_CAPABILITY_TYPE_NAP\n", - tsgCaps->capabilityType); + WLog_ERR(TAG, "Unexpected CapabilityType: 0x%08X, Expected TSG_CAPABILITY_TYPE_NAP", + tsgCaps->capabilityType); free(tsgCaps); free(versionCaps); free(packetCapsResponse); @@ -349,7 +349,7 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu) if (MsgBytes > TSG_MESSAGING_MAX_MESSAGE_LENGTH) { - DEBUG_WARN("Out of Spec Message Length %d", MsgBytes); + WLog_ERR(TAG, "Out of Spec Message Length %d", MsgBytes); free(tsgCaps); free(versionCaps); free(packetCapsResponse); @@ -365,7 +365,7 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu) // the ContextHandle TunnelContext below. break; default: - DEBUG_WARN("Unexpected Message Type: 0x%X\n", (int) MessageSwitchValue); + WLog_ERR(TAG, "Unexpected Message Type: 0x%X", (int) MessageSwitchValue); free(tsgCaps); free(versionCaps); free(packetCapsResponse); @@ -381,9 +381,8 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu) // UINT32 TunnelId // HRESULT ReturnValue #ifdef WITH_DEBUG_TSG - DEBUG_WARN("TSG TunnelContext:\n"); + WLog_DBG(TAG, "TSG TunnelContext:"); winpr_HexDump(TAG, WLOG_DEBUG, (void*) &tsg->TunnelContext, 20); - DEBUG_WARN("\n"); #endif free(tsgCaps); free(versionCaps); @@ -439,8 +438,8 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu) if (versionCaps->tsgHeader.ComponentId != TS_GATEWAY_TRANSPORT) { - DEBUG_WARN("Unexpected ComponentId: 0x%04X, Expected TS_GATEWAY_TRANSPORT\n", - versionCaps->tsgHeader.ComponentId); + WLog_ERR(TAG, "Unexpected ComponentId: 0x%04X, Expected TS_GATEWAY_TRANSPORT", + versionCaps->tsgHeader.ComponentId); free(versionCaps); free(packetQuarEncResponse); free(packet); @@ -465,17 +464,16 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu) CopyMemory(tsg->TunnelContext.ContextUuid, &buffer[offset + 4], 16); /* ContextUuid */ offset += 20; #ifdef WITH_DEBUG_TSG - DEBUG_WARN("TSG TunnelContext:\n"); + WLog_DBG(TAG, "TSG TunnelContext:"); winpr_HexDump(TAG, WLOG_DEBUG, (void*) &tsg->TunnelContext, 20); - DEBUG_WARN("\n"); #endif free(versionCaps); free(packetQuarEncResponse); } else { - DEBUG_WARN("Unexpected PacketId: 0x%08X, Expected TSG_PACKET_TYPE_CAPS_RESPONSE " - "or TSG_PACKET_TYPE_QUARENC_RESPONSE\n", packet->packetId); + WLog_ERR(TAG, "Unexpected PacketId: 0x%08X, Expected TSG_PACKET_TYPE_CAPS_RESPONSE " + "or TSG_PACKET_TYPE_QUARENC_RESPONSE", packet->packetId); free(packet); return FALSE; } @@ -498,11 +496,11 @@ BOOL TsProxyCreateTunnel(rdpTsg* tsg, PTSG_PACKET tsgPacket, PTSG_PACKET* tsgPac * [out] unsigned long* tunnelId * ); */ - DEBUG_TSG("TsProxyCreateTunnel"); + DEBUG_TSG(""); if (!TsProxyCreateTunnelWriteRequest(tsg)) { - DEBUG_WARN("TsProxyCreateTunnel: error writing request\n"); + WLog_ERR(TAG, "error writing request"); return FALSE; } @@ -587,16 +585,16 @@ BOOL TsProxyAuthorizeTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu) if (packet->packetId == E_PROXY_NAP_ACCESSDENIED) { - DEBUG_WARN("status: E_PROXY_NAP_ACCESSDENIED (0x%08X)\n", E_PROXY_NAP_ACCESSDENIED); - DEBUG_WARN("Ensure that the Gateway Connection Authorization Policy is correct\n"); + WLog_ERR(TAG, "status: E_PROXY_NAP_ACCESSDENIED (0x%08X)", E_PROXY_NAP_ACCESSDENIED); + WLog_ERR(TAG, "Ensure that the Gateway Connection Authorization Policy is correct"); free(packet); return FALSE; } if ((packet->packetId != TSG_PACKET_TYPE_RESPONSE) || (SwitchValue != TSG_PACKET_TYPE_RESPONSE)) { - DEBUG_WARN("Unexpected PacketId: 0x%08X, Expected TSG_PACKET_TYPE_RESPONSE\n", - packet->packetId); + WLog_ERR(TAG, "Unexpected PacketId: 0x%08X, Expected TSG_PACKET_TYPE_RESPONSE", + packet->packetId); free(packet); return FALSE; } @@ -609,8 +607,8 @@ BOOL TsProxyAuthorizeTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu) if (packetResponse->flags != TSG_PACKET_TYPE_QUARREQUEST) { - DEBUG_WARN("Unexpected Packet Response Flags: 0x%08X, Expected TSG_PACKET_TYPE_QUARREQUEST\n", - packetResponse->flags); + WLog_ERR(TAG, "Unexpected Packet Response Flags: 0x%08X, Expected TSG_PACKET_TYPE_QUARREQUEST", + packetResponse->flags); free(packet); free(packetResponse); return FALSE; @@ -633,8 +631,8 @@ BOOL TsProxyAuthorizeTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu) if (SizeValue != packetResponse->responseDataLen) { - DEBUG_WARN("Unexpected size value: %d, expected: %d\n", - SizeValue, packetResponse->responseDataLen); + WLog_ERR(TAG, "Unexpected size value: %d, expected: %d", + SizeValue, packetResponse->responseDataLen); free(packetResponse); free(packet); return FALSE; @@ -660,11 +658,11 @@ BOOL TsProxyAuthorizeTunnel(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunn * ); * */ - DEBUG_TSG("TsProxyAuthorizeTunnel"); + DEBUG_TSG(""); if (!TsProxyAuthorizeTunnelWriteRequest(tsg, tunnelContext)) { - DEBUG_WARN("TsProxyAuthorizeTunnel: error writing request\n"); + WLog_ERR(TAG, "error writing request"); return FALSE; } @@ -737,8 +735,8 @@ BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu) if ((packet->packetId != TSG_PACKET_TYPE_MESSAGE_PACKET) || (SwitchValue != TSG_PACKET_TYPE_MESSAGE_PACKET)) { - DEBUG_WARN("Unexpected PacketId: 0x%08X, Expected TSG_PACKET_TYPE_MESSAGE_PACKET\n", - packet->packetId); + WLog_ERR(TAG, "Unexpected PacketId: 0x%08X, Expected TSG_PACKET_TYPE_MESSAGE_PACKET", + packet->packetId); free(packet); return FALSE; } @@ -767,7 +765,7 @@ BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu) /* Offset */ ActualCount = *((UINT32*) &buffer[offset + 56]); /* ActualCount */ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) &buffer[offset + 60], ActualCount, &messageText, 0, NULL, NULL); - DEBUG_WARN("Consent Message: %s\n", messageText); + WLog_ERR(TAG, "Consent Message: %s", messageText); free(messageText); break; case TSG_ASYNC_MESSAGE_SERVICE_MESSAGE: @@ -783,7 +781,7 @@ BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu) /* Offset */ ActualCount = *((UINT32*) &buffer[offset + 56]); /* ActualCount */ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) &buffer[offset + 60], ActualCount, &messageText, 0, NULL, NULL); - DEBUG_WARN("Service Message: %s\n", messageText); + WLog_ERR(TAG, "Service Message: %s", messageText); free(messageText); break; case TSG_ASYNC_MESSAGE_REAUTH: @@ -793,8 +791,8 @@ BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu) Pointer = *((UINT32*) &buffer[offset + 28]); /* ReauthMessagePtr */ break; default: - DEBUG_WARN("TsProxyMakeTunnelCallReadResponse: unexpected message type: %d\n", - SwitchValue); + WLog_ERR(TAG, "unexpected message type: %d", + SwitchValue); rc = FALSE; break; } @@ -828,11 +826,11 @@ BOOL TsProxyMakeTunnelCall(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunne * [out, ref] PTSG_PACKET* tsgPacketResponse * ); */ - DEBUG_TSG("TsProxyMakeTunnelCall"); + DEBUG_TSG(""); if (!TsProxyMakeTunnelCallWriteRequest(tsg, tunnelContext, procId)) { - DEBUG_WARN("TsProxyMakeTunnelCall: error writing request\n"); + WLog_ERR(TAG, "error writing request"); return FALSE; } @@ -849,9 +847,8 @@ BOOL TsProxyCreateChannelWriteRequest(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_NOSERI rdpRpc* rpc = tsg->rpc; count = _wcslen(tsg->Hostname) + 1; #ifdef WITH_DEBUG_TSG - DEBUG_WARN("ResourceName:\n"); + WLog_DBG(TAG, "ResourceName:"); winpr_HexDump(TAG, WLOG_DEBUG, (BYTE*) tsg->Hostname, (count - 1) * 2); - DEBUG_WARN("\n"); #endif length = 60 + (count * 2); buffer = (BYTE*) malloc(length); @@ -908,9 +905,8 @@ BOOL TsProxyCreateChannelReadResponse(rdpTsg* tsg, RPC_PDU* pdu) CopyMemory(&tsg->ChannelContext.ContextType, &buffer[offset], 4); /* ContextType (4 bytes) */ CopyMemory(tsg->ChannelContext.ContextUuid, &buffer[offset + 4], 16); /* ContextUuid (16 bytes) */ #ifdef WITH_DEBUG_TSG - DEBUG_WARN("ChannelContext:\n"); + WLog_DBG(TAG, "ChannelContext:"); winpr_HexDump(TAG, WLOG_DEBUG, (void*) &tsg->ChannelContext, 20); - DEBUG_WARN("\n"); #endif rpc_client_receive_pool_return(rpc, pdu); return TRUE; @@ -929,11 +925,11 @@ BOOL TsProxyCreateChannel(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunnel * [out] unsigned long* channelId * ); */ - DEBUG_TSG("TsProxyCreateChannel"); + DEBUG_TSG(""); if (!TsProxyCreateChannelWriteRequest(tsg, tunnelContext)) { - DEBUG_WARN("TsProxyCreateChannel: error writing request\n"); + WLog_ERR(TAG, "error writing request"); return FALSE; } @@ -990,17 +986,17 @@ HRESULT TsProxyCloseChannel(rdpTsg* tsg, PCHANNEL_CONTEXT_HANDLE_NOSERIALIZE* co * [in, out] PCHANNEL_CONTEXT_HANDLE_NOSERIALIZE* context * ); */ - DEBUG_TSG("TsProxyCloseChannel"); + DEBUG_TSG(""); if (!TsProxyCloseChannelWriteRequest(tsg, context)) { - DEBUG_WARN("TsProxyCloseChannel: error writing request\n"); + WLog_ERR(TAG, "error writing request"); return FALSE; } if (!TsProxyCloseChannelReadResponse(tsg, pdu)) { - DEBUG_WARN("TsProxyCloseChannel: error reading response\n"); + WLog_ERR(TAG, "error reading response"); return FALSE; } @@ -1057,17 +1053,17 @@ HRESULT TsProxyCloseTunnel(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_SERIALIZE* contex * [in, out] PTUNNEL_CONTEXT_HANDLE_SERIALIZE* context * ); */ - DEBUG_TSG("TsProxyCloseTunnel"); + DEBUG_TSG(""); if (!TsProxyCloseTunnelWriteRequest(tsg, context)) { - DEBUG_WARN("TsProxyCloseTunnel: error writing request\n"); + WLog_ERR(TAG, "error writing request"); return FALSE; } if (!TsProxyCloseTunnelReadResponse(tsg, pdu)) { - DEBUG_WARN("TsProxyCloseTunnel: error reading response\n"); + WLog_ERR(TAG, "error reading response"); return FALSE; } @@ -1110,11 +1106,11 @@ BOOL TsProxySetupReceivePipe(handle_t IDL_handle, BYTE* pRpcMessage) * ); */ tsg = (rdpTsg*) IDL_handle; - DEBUG_TSG("TsProxySetupReceivePipe"); + DEBUG_TSG(""); if (!TsProxySetupReceivePipeWriteRequest(tsg)) { - DEBUG_WARN("TsProxySetupReceivePipe: error writing request\n"); + WLog_ERR(TAG, "error writing request"); return FALSE; } @@ -1133,7 +1129,7 @@ BOOL tsg_connect(rdpTsg* tsg, const char* hostname, UINT16 port) if (!rpc_connect(rpc)) { - DEBUG_WARN("rpc_connect failed!\n"); + WLog_ERR(TAG, "rpc_connect failed!"); return FALSE; } @@ -1194,7 +1190,7 @@ BOOL tsg_connect(rdpTsg* tsg, const char* hostname, UINT16 port) if (!TsProxyCreateTunnelReadResponse(tsg, pdu)) { - DEBUG_WARN("TsProxyCreateTunnel: error reading response\n"); + WLog_ERR(TAG, "error reading response"); return FALSE; } @@ -1240,7 +1236,7 @@ BOOL tsg_connect(rdpTsg* tsg, const char* hostname, UINT16 port) if (!TsProxyAuthorizeTunnelReadResponse(tsg, pdu)) { - DEBUG_WARN("TsProxyAuthorizeTunnel: error reading response\n"); + WLog_ERR(TAG, "error reading response"); return FALSE; } @@ -1280,7 +1276,7 @@ BOOL tsg_connect(rdpTsg* tsg, const char* hostname, UINT16 port) if (!pdu) { - DEBUG_WARN("TsProxyCreateChannel: error reading response\n"); + WLog_ERR(TAG, "error reading response"); return FALSE; } @@ -1290,7 +1286,7 @@ BOOL tsg_connect(rdpTsg* tsg, const char* hostname, UINT16 port) { if (!TsProxyMakeTunnelCallReadResponse(tsg, pdu)) { - DEBUG_WARN("TsProxyMakeTunnelCall: error reading response\n"); + WLog_ERR(TAG, "error reading response"); return FALSE; } @@ -1299,7 +1295,7 @@ BOOL tsg_connect(rdpTsg* tsg, const char* hostname, UINT16 port) if (!TsProxyCreateChannelReadResponse(tsg, pdu)) { - DEBUG_WARN("TsProxyCreateChannel: error reading response\n"); + WLog_ERR(TAG, "error reading response"); return FALSE; } @@ -1331,14 +1327,14 @@ BOOL tsg_connect(rdpTsg* tsg, const char* hostname, UINT16 port) if (!TsProxySetupReceivePipeReadResponse(tsg, pdu)) { - DEBUG_WARN("TsProxySetupReceivePipe: error reading response\n"); + WLog_ERR(TAG, "error reading response"); return FALSE; } #endif rpc->client->SynchronousSend = TRUE; rpc->client->SynchronousReceive = TRUE; - DEBUG_WARN("TS Gateway Connection Success\n"); + WLog_INFO(TAG, "TS Gateway Connection Success"); return TRUE; } @@ -1398,7 +1394,7 @@ int tsg_read(rdpTsg* tsg, BYTE* data, UINT32 length) if (rpc->transport->layer == TRANSPORT_LAYER_CLOSED) { - DEBUG_WARN("tsg_read error: connection lost\n"); + WLog_ERR(TAG, "tsg_read error: connection lost"); return -1; } @@ -1454,7 +1450,7 @@ int tsg_write(rdpTsg* tsg, BYTE* data, UINT32 length) if (tsg->rpc->transport->layer == TRANSPORT_LAYER_CLOSED) { - DEBUG_WARN("%s: error, connection lost\n", __FUNCTION__); + WLog_ERR(TAG, "error, connection lost"); return -1; } diff --git a/libfreerdp/core/gateway/tsg.h b/libfreerdp/core/gateway/tsg.h index e041b224c..1bbfdf553 100644 --- a/libfreerdp/core/gateway/tsg.h +++ b/libfreerdp/core/gateway/tsg.h @@ -38,7 +38,7 @@ typedef struct rdp_tsg rdpTsg; #include #include -#include +#include enum _TSG_STATE { @@ -317,10 +317,11 @@ BOOL tsg_set_blocking_mode(rdpTsg* tsg, BOOL blocking); rdpTsg* tsg_new(rdpTransport* transport); void tsg_free(rdpTsg* tsg); +#define TSG_TAG FREERDP_TAG("core.gateway.tsg") #ifdef WITH_DEBUG_TSG -#define DEBUG_TSG(fmt, ...) DEBUG_CLASS(TSG, fmt, ## __VA_ARGS__) +#define DEBUG_TSG(fmt, ...) WLog_DBG(TSG_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_TSG(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_TSG(fmt, ...) do { } while (0) #endif #endif /* FREERDP_CORE_TSG_H */ diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index ac75bc4ba..23b14174c 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -23,9 +23,13 @@ #include +#include + #include "gcc.h" #include "certificate.h" +#define TAG FREERDP_TAG("core") + /** * T.124 GCC is defined in: * @@ -274,7 +278,7 @@ BOOL gcc_read_conference_create_response(wStream* s, rdpMcs* mcs) if (!gcc_read_server_data_blocks(s, mcs, length)) { - DEBUG_WARN( "gcc_read_conference_create_response: gcc_read_server_data_blocks failed\n"); + WLog_ERR(TAG, "gcc_read_conference_create_response: gcc_read_server_data_blocks failed"); return FALSE; } @@ -374,7 +378,7 @@ BOOL gcc_read_client_data_blocks(wStream* s, rdpMcs* mcs, int length) break; default: - DEBUG_WARN( "Unknown GCC client data block: 0x%04X\n", type); + WLog_ERR(TAG, "Unknown GCC client data block: 0x%04X", type); Stream_Seek(s, blockLength - 4); break; } @@ -383,8 +387,8 @@ BOOL gcc_read_client_data_blocks(wStream* s, rdpMcs* mcs, int length) if (endPos != (begPos + blockLength)) { - DEBUG_WARN( "Error parsing GCC client data block 0x%04X: Actual Offset: %d Expected Offset: %d\n", - type, endPos, begPos + blockLength); + WLog_ERR(TAG, "Error parsing GCC client data block 0x%04X: Actual Offset: %d Expected Offset: %d", + type, endPos, begPos + blockLength); } length -= blockLength; @@ -419,16 +423,16 @@ void gcc_write_client_data_blocks(wStream* s, rdpMcs* mcs) { if (settings->UseMultimon && !settings->SpanMonitors) { - DEBUG_WARN( "WARNING: true multi monitor support was not advertised by server!\n"); + WLog_ERR(TAG, "WARNING: true multi monitor support was not advertised by server!"); if (settings->ForceMultimon) { - DEBUG_WARN( "Sending multi monitor information anyway (may break connectivity!)\n"); + WLog_ERR(TAG, "Sending multi monitor information anyway (may break connectivity!)"); gcc_write_client_monitor_data(s, mcs); } else { - DEBUG_WARN( "Use /multimon:force to force sending multi monitor information\n"); + WLog_ERR(TAG, "Use /multimon:force to force sending multi monitor information"); } } } @@ -447,7 +451,7 @@ BOOL gcc_read_server_data_blocks(wStream* s, rdpMcs* mcs, int length) if (!gcc_read_user_data_header(s, &type, &blockLength)) { - DEBUG_WARN( "gcc_read_server_data_blocks: gcc_read_user_data_header failed\n"); + WLog_ERR(TAG, "gcc_read_server_data_blocks: gcc_read_user_data_header failed"); return FALSE; } @@ -456,7 +460,7 @@ BOOL gcc_read_server_data_blocks(wStream* s, rdpMcs* mcs, int length) case SC_CORE: if (!gcc_read_server_core_data(s, mcs)) { - DEBUG_WARN( "gcc_read_server_data_blocks: gcc_read_server_core_data failed\n"); + WLog_ERR(TAG, "gcc_read_server_data_blocks: gcc_read_server_core_data failed"); return FALSE; } break; @@ -464,7 +468,7 @@ BOOL gcc_read_server_data_blocks(wStream* s, rdpMcs* mcs, int length) case SC_SECURITY: if (!gcc_read_server_security_data(s, mcs)) { - DEBUG_WARN( "gcc_read_server_data_blocks: gcc_read_server_security_data failed\n"); + WLog_ERR(TAG, "gcc_read_server_data_blocks: gcc_read_server_security_data failed"); return FALSE; } break; @@ -472,7 +476,7 @@ BOOL gcc_read_server_data_blocks(wStream* s, rdpMcs* mcs, int length) case SC_NET: if (!gcc_read_server_network_data(s, mcs)) { - DEBUG_WARN( "gcc_read_server_data_blocks: gcc_read_server_network_data failed\n"); + WLog_ERR(TAG, "gcc_read_server_data_blocks: gcc_read_server_network_data failed"); return FALSE; } break; @@ -480,7 +484,7 @@ BOOL gcc_read_server_data_blocks(wStream* s, rdpMcs* mcs, int length) case SC_MCS_MSGCHANNEL: if (!gcc_read_server_message_channel_data(s, mcs)) { - DEBUG_WARN( "gcc_read_server_data_blocks: gcc_read_server_message_channel_data failed\n"); + WLog_ERR(TAG, "gcc_read_server_data_blocks: gcc_read_server_message_channel_data failed"); return FALSE; } break; @@ -488,13 +492,13 @@ BOOL gcc_read_server_data_blocks(wStream* s, rdpMcs* mcs, int length) case SC_MULTITRANSPORT: if (!gcc_read_server_multitransport_channel_data(s, mcs)) { - DEBUG_WARN( "gcc_read_server_data_blocks: gcc_read_server_multitransport_channel_data failed\n"); + WLog_ERR(TAG, "gcc_read_server_data_blocks: gcc_read_server_multitransport_channel_data failed"); return FALSE; } break; default: - DEBUG_WARN( "gcc_read_server_data_blocks: ignoring type=%hu\n", type); + WLog_ERR(TAG, "gcc_read_server_data_blocks: ignoring type=%hu", type); break; } offset += blockLength; @@ -1174,7 +1178,7 @@ void gcc_write_server_security_data(wStream* s, rdpMcs* mcs) md5 = crypto_md5_init(); if (!md5) { - DEBUG_WARN( "%s: unable to allocate a md5\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a md5"); return; } @@ -1269,8 +1273,8 @@ BOOL gcc_read_server_network_data(wStream* s, rdpMcs* mcs) if (channelCount != mcs->channelCount) { - DEBUG_WARN( "requested %d channels, got %d instead\n", - mcs->channelCount, channelCount); + WLog_ERR(TAG, "requested %d channels, got %d instead", + mcs->channelCount, channelCount); /* we ensure that the response is not bigger than the request */ diff --git a/libfreerdp/core/heartbeat.h b/libfreerdp/core/heartbeat.h index 80e3f46a3..ed4e60c52 100644 --- a/libfreerdp/core/heartbeat.h +++ b/libfreerdp/core/heartbeat.h @@ -25,6 +25,7 @@ typedef struct rdp_heartbeat rdpHeartbeat; #include "rdp.h" #include +#include #include @@ -38,10 +39,11 @@ int rdp_recv_heartbeat_packet(rdpRdp* rdp, wStream* s); rdpHeartbeat* heartbeat_new(void); void heartbeat_free(rdpHeartbeat* heartbeat); +#define HEARTBEAT_TAG FREERDP_TAG("core.heartbeat") #ifdef WITH_DEBUG_HEARTBEAT -#define DEBUG_HEARTBEAT(fmt, ...) DEBUG_CLASS(HEARTBEAT, fmt, ## __VA_ARGS__) +#define DEBUG_HEARTBEAT(fmt, ...) WLog_DBG(HEARTBEAT_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_HEARTBEAT(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_HEARTBEAT(fmt, ...) do { } while (0) #endif #endif /* __HEARTBEAT_H */ diff --git a/libfreerdp/core/info.c b/libfreerdp/core/info.c index 217b3ff21..9fd499a8a 100644 --- a/libfreerdp/core/info.c +++ b/libfreerdp/core/info.c @@ -23,12 +23,15 @@ #include #include +#include #include #include "timezone.h" #include "info.h" +#define TAG FREERDP_TAG("core") + #define INFO_TYPE_LOGON 0x00000000 #define INFO_TYPE_LOGON_LONG 0x00000001 #define INFO_TYPE_LOGON_PLAIN_NOTIFY 0x00000002 @@ -67,7 +70,7 @@ BOOL rdp_read_server_auto_reconnect_cookie(wStream* s, rdpSettings* settings) char *base64; base64 = crypto_base64_encode((BYTE *) autoReconnectCookie, sizeof(ARC_SC_PRIVATE_PACKET)); - DEBUG_WARN( "Reconnect-cookie: %s\n", base64); + WLog_INFO(TAG, "Reconnect-cookie: %s", base64); free(base64); } return TRUE; @@ -256,8 +259,7 @@ void rdp_write_extended_info_packet(wStream* s, rdpSettings* settings) CryptoHmac hmac; ARC_SC_PRIVATE_PACKET* serverCookie; ARC_CS_PRIVATE_PACKET* clientCookie; - - DEBUG_MSG("Sending auto reconnect\n"); + WLog_DBG(TAG, "Sending auto reconnect"); serverCookie = settings->ServerAutoReconnectCookie; clientCookie = settings->ClientAutoReconnectCookie; @@ -268,7 +270,7 @@ void rdp_write_extended_info_packet(wStream* s, rdpSettings* settings) hmac = crypto_hmac_new(); if (!hmac) { - DEBUG_WARN( "%s: unable to allocate hmac\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate hmac"); goto out_free; } @@ -592,7 +594,7 @@ BOOL rdp_recv_client_info(rdpRdp* rdp, wStream* s) { if (securityFlags & SEC_REDIRECTION_PKT) { - DEBUG_WARN( "Error: SEC_REDIRECTION_PKT unsupported\n"); + WLog_ERR(TAG, "Error: SEC_REDIRECTION_PKT unsupported"); return FALSE; } @@ -600,7 +602,7 @@ BOOL rdp_recv_client_info(rdpRdp* rdp, wStream* s) { if (!rdp_decrypt(rdp, s, length - 4, securityFlags)) { - DEBUG_WARN( "rdp_decrypt failed\n"); + WLog_ERR(TAG, "rdp_decrypt failed"); return FALSE; } } @@ -753,7 +755,7 @@ BOOL rdp_recv_save_session_info(rdpRdp* rdp, wStream* s) return FALSE; Stream_Read_UINT32(s, infoType); /* infoType (4 bytes) */ - //DEBUG_WARN( "%s\n", INFO_TYPE_LOGON_STRINGS[infoType]); + //WLog_ERR(TAG, "%s\n", INFO_TYPE_LOGON_STRINGS[infoType]); switch (infoType) { diff --git a/libfreerdp/core/input.c b/libfreerdp/core/input.c index 904bce130..631dceb0e 100644 --- a/libfreerdp/core/input.c +++ b/libfreerdp/core/input.c @@ -24,11 +24,14 @@ #include #include +#include #include "message.h" #include "input.h" +#define TAG FREERDP_TAG("core") + void rdp_write_client_input_pdu_header(wStream* s, UINT16 number) { Stream_Write_UINT16(s, 1); /* numberEvents (2 bytes) */ @@ -434,7 +437,7 @@ static BOOL input_recv_event(rdpInput* input, wStream* s) break; default: - DEBUG_WARN( "Unknown messageType %u\n", messageType); + WLog_ERR(TAG, "Unknown messageType %u", messageType); /* Each input event uses 6 bytes. */ Stream_Seek(s, 6); break; diff --git a/libfreerdp/core/license.c b/libfreerdp/core/license.c index aa2c17f1d..74c9d67cd 100644 --- a/libfreerdp/core/license.c +++ b/libfreerdp/core/license.c @@ -24,12 +24,13 @@ #include #include + #include "redirection.h" #include "certificate.h" #include "license.h" -#define TAG FREERDP_TAG("core") +#define TAG FREERDP_TAG("core.license") /* #define LICENSE_NULL_CLIENT_RANDOM 1 */ /* #define LICENSE_NULL_PREMASTER_SECRET 1 */ @@ -88,10 +89,10 @@ void license_print_product_info(LICENSE_PRODUCT_INFO* productInfo) productInfo->cbCompanyName / 2, &CompanyName, 0, NULL, NULL); ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) productInfo->pbProductId, productInfo->cbProductId / 2, &ProductId, 0, NULL, NULL); - DEBUG_WARN("ProductInfo:\n"); - DEBUG_WARN("\tdwVersion: 0x%08X\n", productInfo->dwVersion); - DEBUG_WARN("\tCompanyName: %s\n", CompanyName); - DEBUG_WARN("\tProductId: %s\n", ProductId); + WLog_INFO(TAG, "ProductInfo:"); + WLog_INFO(TAG, "\tdwVersion: 0x%08X", productInfo->dwVersion); + WLog_INFO(TAG, "\tCompanyName: %s", CompanyName); + WLog_INFO(TAG, "\tProductId: %s", ProductId); free(CompanyName); free(ProductId); } @@ -100,12 +101,12 @@ void license_print_scope_list(SCOPE_LIST* scopeList) { int index; LICENSE_BLOB* scope; - DEBUG_WARN("ScopeList (%d):\n", scopeList->count); + WLog_INFO(TAG, "ScopeList (%d):", scopeList->count); for (index = 0; index < scopeList->count; index++) { scope = &scopeList->array[index]; - DEBUG_WARN("\t%s\n", (char*) scope->data); + WLog_INFO(TAG, "\t%s", (char*) scope->data); } } @@ -200,7 +201,7 @@ BOOL license_send(rdpLicense* license, wStream* s, BYTE type) license_write_preamble(s, type, flags, wMsgSize); #ifdef WITH_DEBUG_LICENSE - DEBUG_WARN("Sending %s Packet, length %d\n", LICENSE_MESSAGE_STRINGS[type & 0x1F], wMsgSize); + WLog_DBG(TAG, "Sending %s Packet, length %d", LICENSE_MESSAGE_STRINGS[type & 0x1F], wMsgSize); winpr_HexDump(TAG, WLOG_DEBUG, Stream_Pointer(s) - LICENSE_PREAMBLE_LENGTH, wMsgSize); #endif Stream_SetPosition(s, length); @@ -228,7 +229,7 @@ int license_recv(rdpLicense* license, wStream* s) if (!rdp_read_header(license->rdp, s, &length, &channelId)) { - DEBUG_WARN("%s: Incorrect RDP header.\n", __FUNCTION__); + WLog_ERR(TAG, "Incorrect RDP header."); return -1; } @@ -239,7 +240,7 @@ int license_recv(rdpLicense* license, wStream* s) { if (!rdp_decrypt(license->rdp, s, length - 4, securityFlags)) { - DEBUG_WARN("%s: rdp_decrypt failed\n", __FUNCTION__); + WLog_ERR(TAG, "rdp_decrypt failed"); return -1; } } @@ -255,7 +256,7 @@ int license_recv(rdpLicense* license, wStream* s) if (status < 0) { - DEBUG_WARN("%s: unexpected license packet.\n", __FUNCTION__); + WLog_ERR(TAG, "unexpected license packet."); return status; } @@ -296,7 +297,7 @@ int license_recv(rdpLicense* license, wStream* s) break; default: - DEBUG_WARN("%s: invalid bMsgType:%d\n", __FUNCTION__, bMsgType); + WLog_ERR(TAG, "invalid bMsgType:%d", bMsgType); return FALSE; } @@ -331,27 +332,20 @@ void license_generate_keys(rdpLicense* license) security_licensing_encryption_key(license->SessionKeyBlob, license->ClientRandom, license->ServerRandom, license->LicensingEncryptionKey); /* LicensingEncryptionKey */ #ifdef WITH_DEBUG_LICENSE - DEBUG_WARN("ClientRandom:\n"); + WLog_DBG(TAG, "ClientRandom:"); winpr_HexDump(TAG, WLOG_DEBUG, license->ClientRandom, CLIENT_RANDOM_LENGTH); - DEBUG_WARN("\n"); - DEBUG_WARN("ServerRandom:\n"); + WLog_DBG(TAG, "ServerRandom:"); winpr_HexDump(TAG, WLOG_DEBUG, license->ServerRandom, SERVER_RANDOM_LENGTH); - DEBUG_WARN("\n"); - DEBUG_WARN("PremasterSecret:\n"); + WLog_DBG(TAG, "PremasterSecret:"); winpr_HexDump(TAG, WLOG_DEBUG, license->PremasterSecret, PREMASTER_SECRET_LENGTH); - DEBUG_WARN("\n"); - DEBUG_WARN("MasterSecret:\n"); + WLog_DBG(TAG, "MasterSecret:"); winpr_HexDump(TAG, WLOG_DEBUG, license->MasterSecret, MASTER_SECRET_LENGTH); - DEBUG_WARN("\n"); - DEBUG_WARN("SessionKeyBlob:\n"); + WLog_DBG(TAG, "SessionKeyBlob:"); winpr_HexDump(TAG, WLOG_DEBUG, license->SessionKeyBlob, SESSION_KEY_BLOB_LENGTH); - DEBUG_WARN("\n"); - DEBUG_WARN("MacSaltKey:\n"); + WLog_DBG(TAG, "MacSaltKey:"); winpr_HexDump(TAG, WLOG_DEBUG, license->MacSaltKey, MAC_SALT_KEY_LENGTH); - DEBUG_WARN("\n"); - DEBUG_WARN("LicensingEncryptionKey:\n"); + WLog_DBG(TAG, "LicensingEncryptionKey:"); winpr_HexDump(TAG, WLOG_DEBUG, license->LicensingEncryptionKey, LICENSING_ENCRYPTION_KEY_LENGTH); - DEBUG_WARN("\n"); #endif } @@ -370,7 +364,7 @@ void license_generate_hwid(rdpLicense* license) if (!md5) { - DEBUG_WARN("%s: unable to allocate a md5\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a md5"); return; } @@ -405,12 +399,10 @@ void license_encrypt_premaster_secret(rdpLicense* license) BYTE* EncryptedPremasterSecret; license_get_server_rsa_public_key(license); #ifdef WITH_DEBUG_LICENSE - DEBUG_WARN("Modulus (%d bits):\n", license->ModulusLength * 8); + WLog_DBG(TAG, "Modulus (%d bits):", license->ModulusLength * 8); winpr_HexDump(TAG, WLOG_DEBUG, license->Modulus, license->ModulusLength); - DEBUG_WARN("\n"); - DEBUG_WARN("Exponent:\n"); + WLog_DBG(TAG, "Exponent:"); winpr_HexDump(TAG, WLOG_DEBUG, license->Exponent, 4); - DEBUG_WARN("\n"); #endif EncryptedPremasterSecret = (BYTE*) malloc(license->ModulusLength); ZeroMemory(EncryptedPremasterSecret, license->ModulusLength); @@ -433,7 +425,7 @@ void license_decrypt_platform_challenge(rdpLicense* license) if (!rc4) { - DEBUG_WARN("%s: unable to allocate a rc4\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a rc4"); return; } @@ -541,7 +533,7 @@ BOOL license_read_binary_blob(wStream* s, LICENSE_BLOB* blob) if ((blob->type != wBlobType) && (blob->type != BB_ANY_BLOB)) { - DEBUG_WARN("license binary blob type (%x) does not match expected type (%x).\n", wBlobType, blob->type); + WLog_ERR(TAG, "license binary blob type (%x) does not match expected type (%x).", wBlobType, blob->type); } blob->type = wBlobType; @@ -574,7 +566,7 @@ void license_write_encrypted_premaster_secret_blob(wStream* s, LICENSE_BLOB* blo if (blob->length > ModulusLength) { - DEBUG_WARN("license_write_encrypted_premaster_secret_blob: invalid blob\n"); + WLog_ERR(TAG, "license_write_encrypted_premaster_secret_blob: invalid blob"); return; } @@ -734,13 +726,10 @@ BOOL license_read_license_request_packet(rdpLicense* license, wStream* s) license_generate_hwid(license); license_encrypt_premaster_secret(license); #ifdef WITH_DEBUG_LICENSE - DEBUG_WARN("ServerRandom:\n"); + WLog_DBG(TAG, "ServerRandom:"); winpr_HexDump(TAG, WLOG_DEBUG, license->ServerRandom, 32); - DEBUG_WARN("\n"); license_print_product_info(license->ProductInfo); - DEBUG_WARN("\n"); license_print_scope_list(license->ScopeList); - DEBUG_WARN("\n"); #endif return TRUE; } @@ -773,17 +762,13 @@ BOOL license_read_platform_challenge_packet(rdpLicense* license, wStream* s) Stream_Read(s, MacData, 16); /* MACData (16 bytes) */ license_decrypt_platform_challenge(license); #ifdef WITH_DEBUG_LICENSE - DEBUG_WARN("ConnectFlags: 0x%08X\n", ConnectFlags); - DEBUG_WARN("\n"); - DEBUG_WARN("EncryptedPlatformChallenge:\n"); + WLog_DBG(TAG, "ConnectFlags: 0x%08X", ConnectFlags); + WLog_DBG(TAG, "EncryptedPlatformChallenge:"); winpr_HexDump(TAG, WLOG_DEBUG, license->EncryptedPlatformChallenge->data, license->EncryptedPlatformChallenge->length); - DEBUG_WARN("\n"); - DEBUG_WARN("PlatformChallenge:\n"); + WLog_DBG(TAG, "PlatformChallenge:"); winpr_HexDump(TAG, WLOG_DEBUG, license->PlatformChallenge->data, license->PlatformChallenge->length); - DEBUG_WARN("\n"); - DEBUG_WARN("MacData:\n"); + WLog_DBG(TAG, "MacData:"); winpr_HexDump(TAG, WLOG_DEBUG, MacData, 16); - DEBUG_WARN("\n"); #endif return TRUE; } @@ -836,8 +821,8 @@ BOOL license_read_error_alert_packet(rdpLicense* license, wStream* s) return FALSE; #ifdef WITH_DEBUG_LICENSE - DEBUG_WARN("dwErrorCode: %s, dwStateTransition: %s\n", - error_codes[dwErrorCode], state_transitions[dwStateTransition]); + WLog_DBG(TAG, "dwErrorCode: %s, dwStateTransition: %s", + error_codes[dwErrorCode], state_transitions[dwStateTransition]); #endif if (dwErrorCode == STATUS_VALID_CLIENT) @@ -885,18 +870,13 @@ void license_write_new_license_request_packet(rdpLicense* license, wStream* s) license_write_binary_blob(s, license->ClientUserName); /* ClientUserName */ license_write_binary_blob(s, license->ClientMachineName); /* ClientMachineName */ #ifdef WITH_DEBUG_LICENSE - DEBUG_WARN("PreferredKeyExchangeAlg: 0x%08X\n", PreferredKeyExchangeAlg); - DEBUG_WARN("\n"); - DEBUG_WARN("ClientRandom:\n"); + WLog_DBG(TAG, "PreferredKeyExchangeAlg: 0x%08X", PreferredKeyExchangeAlg); + WLog_DBG(TAG, "ClientRandom:"); winpr_HexDump(TAG, WLOG_DEBUG, license->ClientRandom, 32); - DEBUG_WARN("\n"); - DEBUG_WARN("EncryptedPremasterSecret\n"); + WLog_DBG(TAG, "EncryptedPremasterSecret"); winpr_HexDump(TAG, WLOG_DEBUG, license->EncryptedPremasterSecret->data, license->EncryptedPremasterSecret->length); - DEBUG_WARN("\n"); - DEBUG_WARN("ClientUserName (%d): %s\n", license->ClientUserName->length, (char*) license->ClientUserName->data); - DEBUG_WARN("\n"); - DEBUG_WARN("ClientMachineName (%d): %s\n", license->ClientMachineName->length, (char*) license->ClientMachineName->data); - DEBUG_WARN("\n"); + WLog_DBG(TAG, "ClientUserName (%d): %s", license->ClientUserName->length, (char*) license->ClientUserName->data); + WLog_DBG(TAG, "ClientMachineName (%d): %s", license->ClientMachineName->length, (char*) license->ClientMachineName->data); #endif } @@ -973,7 +953,7 @@ void license_send_platform_challenge_response_packet(rdpLicense* license) if (!rc4) { - DEBUG_WARN("%s: unable to allocate a rc4\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a rc4"); free(buffer); return; } @@ -984,15 +964,12 @@ void license_send_platform_challenge_response_packet(rdpLicense* license) license->EncryptedHardwareId->data = buffer; license->EncryptedHardwareId->length = HWID_LENGTH; #ifdef WITH_DEBUG_LICENSE - DEBUG_WARN("LicensingEncryptionKey:\n"); + WLog_DBG(TAG, "LicensingEncryptionKey:"); winpr_HexDump(TAG, WLOG_DEBUG, license->LicensingEncryptionKey, 16); - DEBUG_WARN("\n"); - DEBUG_WARN("HardwareId:\n"); + WLog_DBG(TAG, "HardwareId:"); winpr_HexDump(TAG, WLOG_DEBUG, license->HardwareId, HWID_LENGTH); - DEBUG_WARN("\n"); - DEBUG_WARN("EncryptedHardwareId:\n"); + WLog_DBG(TAG, "EncryptedHardwareId:"); winpr_HexDump(TAG, WLOG_DEBUG, license->EncryptedHardwareId->data, HWID_LENGTH); - DEBUG_WARN("\n"); #endif license_write_platform_challenge_response_packet(license, s, mac_data); license_send(license, s, PLATFORM_CHALLENGE_RESPONSE); diff --git a/libfreerdp/core/license.h b/libfreerdp/core/license.h index 547c710ef..c8dcdc75e 100644 --- a/libfreerdp/core/license.h +++ b/libfreerdp/core/license.h @@ -28,7 +28,7 @@ typedef struct rdp_license rdpLicense; #include #include -#include +#include #include @@ -240,10 +240,11 @@ BOOL license_send_valid_client_error_packet(rdpLicense* license); rdpLicense* license_new(rdpRdp* rdp); void license_free(rdpLicense* license); +#define LICENSE_TAG FREERDP_TAG("core.license") #ifdef WITH_DEBUG_LICENSE -#define DEBUG_LICENSE(fmt, ...) DEBUG_CLASS(LICENSE, fmt, ## __VA_ARGS__) +#define DEBUG_LICENSE(fmt, ...) WLog_DBG(LICENSE_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_LICENSE(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_LICENSE(fmt, ...) do { } while (0) #endif #endif /* __LICENSE_H */ diff --git a/libfreerdp/core/listener.c b/libfreerdp/core/listener.c index 4073b10ca..0a3f47538 100644 --- a/libfreerdp/core/listener.c +++ b/libfreerdp/core/listener.c @@ -28,6 +28,7 @@ #include #include +#include #ifndef _WIN32 #include @@ -44,6 +45,8 @@ #include "listener.h" +#define TAG FREERDP_TAG("core.listener") + #ifdef _WIN32 #if _WIN32_WINNT < 0x0600 static const char* inet_ntop(int af, const void* src, char* dst, size_t cnt) @@ -102,9 +105,9 @@ static BOOL freerdp_listener_open(freerdp_listener* instance, const char* bind_a if (status != 0) { #ifdef _WIN32 - _tprintf(_T("getaddrinfo error: %s\n"), gai_strerror(status)); + WLog_ERR(_T("getaddrinfo error: %s"), gai_strerror(status)); #else - DEBUG_WARN("getaddrinfo"); + WLog_ERR(TAG, "getaddrinfo"); #endif return FALSE; } @@ -118,14 +121,14 @@ static BOOL freerdp_listener_open(freerdp_listener* instance, const char* bind_a if (sockfd == -1) { - DEBUG_WARN("socket"); + WLog_ERR(TAG, "socket"); continue; } option_value = 1; if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (void*) &option_value, sizeof(option_value)) == -1) - DEBUG_WARN("setsockopt"); + WLog_ERR(TAG, "setsockopt"); #ifndef _WIN32 fcntl(sockfd, F_SETFL, O_NONBLOCK); @@ -139,10 +142,10 @@ static BOOL freerdp_listener_open(freerdp_listener* instance, const char* bind_a if (status != 0) { #ifdef _WIN32 - _tprintf(L"bind() failed with error: %u\n", WSAGetLastError()); + WLog_ERR("bind() failed with error: %u", WSAGetLastError()); WSACleanup(); #else - DEBUG_WARN("bind"); + WLog_ERR(TAG, "bind"); close(sockfd); #endif continue; @@ -152,7 +155,7 @@ static BOOL freerdp_listener_open(freerdp_listener* instance, const char* bind_a if (status != 0) { - DEBUG_WARN("listen"); + WLog_ERR(TAG, "listen"); close(sockfd); continue; } @@ -168,7 +171,7 @@ static BOOL freerdp_listener_open(freerdp_listener* instance, const char* bind_a else sin_addr = &(((struct sockaddr_in6*) ai->ai_addr)->sin6_addr); - DEBUG_WARN( "Listening on %s port %s.\n", inet_ntop(ai->ai_family, sin_addr, buf, sizeof(buf)), servname); + WLog_ERR(TAG, "Listening on %s port %s.\n", inet_ntop(ai->ai_family, sin_addr, buf, sizeof(buf)), servname); } freeaddrinfo(res); @@ -188,7 +191,7 @@ static BOOL freerdp_listener_open_local(freerdp_listener* instance, const char* if (sockfd == -1) { - DEBUG_WARN("socket"); + WLog_ERR(TAG, "socket"); return FALSE; } @@ -202,7 +205,7 @@ static BOOL freerdp_listener_open_local(freerdp_listener* instance, const char* if (status != 0) { - DEBUG_WARN("bind"); + WLog_ERR(TAG, "bind"); close(sockfd); return FALSE; } @@ -211,7 +214,7 @@ static BOOL freerdp_listener_open_local(freerdp_listener* instance, const char* if (status != 0) { - DEBUG_WARN("listen"); + WLog_ERR(TAG, "listen"); close(sockfd); return FALSE; } @@ -219,9 +222,7 @@ static BOOL freerdp_listener_open_local(freerdp_listener* instance, const char* listener->sockfds[listener->num_sockfds] = sockfd; listener->events[listener->num_sockfds] = CreateFileDescriptorEvent(NULL, FALSE, FALSE, sockfd); listener->num_sockfds++; - - DEBUG_WARN( "Listening on socket %s.\n", addr.sun_path); - + WLog_INFO(TAG, "Listening on socket %s.", addr.sun_path); return TRUE; #else return TRUE; @@ -308,7 +309,8 @@ static BOOL freerdp_listener_check_fds(freerdp_listener* instance) if (errno == EAGAIN || errno == EWOULDBLOCK) continue; #endif - DEBUG_WARN("accept"); + WLog_DBG(TAG, "accept"); + if (client) free(client); return FALSE; diff --git a/libfreerdp/core/mcs.c b/libfreerdp/core/mcs.c index 326622116..f16fc6dcf 100644 --- a/libfreerdp/core/mcs.c +++ b/libfreerdp/core/mcs.c @@ -22,6 +22,7 @@ #endif #include +#include #include "gcc.h" @@ -30,6 +31,8 @@ #include "tpkt.h" #include "client.h" +#define TAG FREERDP_TAG("core") + /** * T.125 MCS is defined in: * @@ -328,16 +331,16 @@ void mcs_write_domain_parameters(wStream* s, DomainParameters* domainParameters) void mcs_print_domain_parameters(DomainParameters* domainParameters) { - DEBUG_WARN( "DomainParameters {\n"); - DEBUG_WARN( "\tmaxChannelIds:%d\n", domainParameters->maxChannelIds); - DEBUG_WARN( "\tmaxUserIds:%d\n", domainParameters->maxUserIds); - DEBUG_WARN( "\tmaxTokenIds:%d\n", domainParameters->maxTokenIds); - DEBUG_WARN( "\tnumPriorities:%d\n", domainParameters->numPriorities); - DEBUG_WARN( "\tminThroughput:%d\n", domainParameters->minThroughput); - DEBUG_WARN( "\tmaxHeight:%d\n", domainParameters->maxHeight); - DEBUG_WARN( "\tmaxMCSPDUsize:%d\n", domainParameters->maxMCSPDUsize); - DEBUG_WARN( "\tprotocolVersion:%d\n", domainParameters->protocolVersion); - DEBUG_WARN( "}\n"); + WLog_INFO(TAG, "DomainParameters {"); + WLog_INFO(TAG, "\tmaxChannelIds:%d", domainParameters->maxChannelIds); + WLog_INFO(TAG, "\tmaxUserIds:%d", domainParameters->maxUserIds); + WLog_INFO(TAG, "\tmaxTokenIds:%d", domainParameters->maxTokenIds); + WLog_INFO(TAG, "\tnumPriorities:%d", domainParameters->numPriorities); + WLog_INFO(TAG, "\tminThroughput:%d", domainParameters->minThroughput); + WLog_INFO(TAG, "\tmaxHeight:%d", domainParameters->maxHeight); + WLog_INFO(TAG, "\tmaxMCSPDUsize:%d", domainParameters->maxMCSPDUsize); + WLog_INFO(TAG, "\tprotocolVersion:%d", domainParameters->protocolVersion); + WLog_INFO(TAG, "}"); } /** @@ -661,7 +664,7 @@ BOOL mcs_recv_connect_response(rdpMcs* mcs, wStream* s) if (!gcc_read_conference_create_response(s, mcs)) { - DEBUG_WARN( "mcs_recv_connect_response: gcc_read_conference_create_response failed\n"); + WLog_ERR(TAG, "gcc_read_conference_create_response failed"); return FALSE; } diff --git a/libfreerdp/core/message.c b/libfreerdp/core/message.c index 62c66f647..c51c6d7c0 100644 --- a/libfreerdp/core/message.c +++ b/libfreerdp/core/message.c @@ -27,12 +27,14 @@ #include "message.h" #include "transport.h" +#include #include #include #include #include +#define TAG FREERDP_TAG("core.message") #define WITH_STREAM_POOL 1 /* Update */ @@ -762,7 +764,7 @@ static void update_message_WindowIcon(rdpContext* context, WINDOW_ORDER_INFO* or lParam = (WINDOW_ICON_ORDER*) malloc(sizeof(WINDOW_ICON_ORDER)); CopyMemory(lParam, windowIcon, sizeof(WINDOW_ICON_ORDER)); - DEBUG_WARN( "update_message_WindowIcon\n"); + WLog_VRB(TAG, "update_message_WindowIcon"); if (windowIcon->iconInfo->cbBitsColor > 0) { @@ -1871,7 +1873,7 @@ static int update_message_free_class(wMessage*msg, int msgClass, int msgType) } if (status < 0) - DEBUG_WARN( "Unknown message: class: %d type: %d\n", msgClass, msgType); + WLog_ERR(TAG, "Unknown message: class: %d type: %d", msgClass, msgType); return status; } @@ -1912,7 +1914,7 @@ static int update_message_process_class(rdpUpdateProxy* proxy, wMessage* msg, in } if (status < 0) - DEBUG_WARN( "Unknown message: class: %d type: %d\n", msgClass, msgType); + WLog_ERR(TAG, "Unknown message: class: %d type: %d", msgClass, msgType); return status; } @@ -2166,7 +2168,7 @@ static void *update_message_proxy_thread(void *arg) if (!update || !update->queue) { - DEBUG_WARN("update=%p, update->queue=%p", update, update ? update->queue : NULL); + WLog_ERR(TAG, "update=%p, update->queue=%p", update, update ? update->queue : NULL); ExitThread(-1); return NULL; } @@ -2348,7 +2350,7 @@ static int input_message_free_class(wMessage* msg, int msgClass, int msgType) } if (status < 0) - DEBUG_WARN( "Unknown event: class: %d type: %d\n", msgClass, msgType); + WLog_ERR(TAG, "Unknown event: class: %d type: %d", msgClass, msgType); return status; } @@ -2369,7 +2371,7 @@ static int input_message_process_class(rdpInputProxy* proxy, wMessage* msg, int } if (status < 0) - DEBUG_WARN( "Unknown event: class: %d type: %d\n", msgClass, msgType); + WLog_ERR(TAG, "Unknown event: class: %d type: %d", msgClass, msgType); return status; } diff --git a/libfreerdp/core/nego.c b/libfreerdp/core/nego.c index d5c98ef29..371798e2b 100644 --- a/libfreerdp/core/nego.c +++ b/libfreerdp/core/nego.c @@ -26,12 +26,16 @@ #include +#include + #include "tpkt.h" #include "nego.h" #include "transport.h" +#define TAG FREERDP_TAG("core.nego") + #ifdef WITH_DEBUG_NEGO static const char* const NEGO_STATE_STRINGS[] = { @@ -595,7 +599,7 @@ int nego_recv(rdpTransport* transport, wStream* s, void* extra) } else { - DEBUG_WARN( "invalid negotiation response\n"); + WLog_ERR(TAG, "invalid negotiation response"); nego->state = NEGO_STATE_FAIL; } @@ -621,7 +625,7 @@ BOOL nego_read_request(rdpNego* nego, wStream* s) if (li != Stream_GetRemainingLength(s) + 6) { - DEBUG_WARN( "Incorrect TPDU length indicator.\n"); + WLog_ERR(TAG, "Incorrect TPDU length indicator."); return FALSE; } @@ -653,7 +657,7 @@ BOOL nego_read_request(rdpNego* nego, wStream* s) if (type != TYPE_RDP_NEG_REQ) { - DEBUG_WARN( "Incorrect negotiation request type %d\n", type); + WLog_ERR(TAG, "Incorrect negotiation request type %d", type); return FALSE; } @@ -904,8 +908,7 @@ BOOL nego_send_negotiation_response(rdpNego* nego) * TODO: Check for other possibilities, * like SSL_NOT_ALLOWED_BY_SERVER. */ - DEBUG_WARN( "%s: client supports only Standard RDP Security\n", __FUNCTION__); - + WLog_ERR(TAG, "client supports only Standard RDP Security"); Stream_Write_UINT32(s, SSL_REQUIRED_BY_SERVER); length += 8; status = FALSE; @@ -962,13 +965,13 @@ BOOL nego_send_negotiation_response(rdpNego* nego) if (settings->DisableEncryption) { - fprintf(stderr, "Encryption is disabled.\n"); + WLog_WARN(TAG, "Encryption is disabled."); return FALSE; } if (!settings->RdpServerRsaKey && !settings->RdpKeyFile) { - fprintf(stderr, "Missing server certificate\n"); + WLog_ERR(TAG, "Missing server certificate"); return FALSE; } } diff --git a/libfreerdp/core/nego.h b/libfreerdp/core/nego.h index c36be4619..513564d15 100644 --- a/libfreerdp/core/nego.h +++ b/libfreerdp/core/nego.h @@ -24,7 +24,7 @@ #include #include -#include +#include #include @@ -157,10 +157,11 @@ void nego_set_send_preconnection_pdu(rdpNego* nego, BOOL send_pcpdu); void nego_set_preconnection_id(rdpNego* nego, UINT32 id); void nego_set_preconnection_blob(rdpNego* nego, char* blob); +#define NEGO_TAG FREERDP_TAG("core.nego") #ifdef WITH_DEBUG_NEGO -#define DEBUG_NEGO(fmt, ...) DEBUG_CLASS(NEGO, fmt, ## __VA_ARGS__) +#define DEBUG_NEGO(fmt, ...) WLog_DBG(NEGO_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_NEGO(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_NEGO(fmt, ...) do { } while (0) #endif #endif /* __NEGO_H */ diff --git a/libfreerdp/core/nla.c b/libfreerdp/core/nla.c index 02d307ec0..ecbfc8b26 100644 --- a/libfreerdp/core/nla.c +++ b/libfreerdp/core/nla.c @@ -186,8 +186,8 @@ int credssp_ntlm_client_init(rdpCredssp* credssp) } #endif #ifdef WITH_DEBUG_NLA - DEBUG_MSG("User: %s Domain: %s Password: %s\n", - (char*) credssp->identity.User, (char*) credssp->identity.Domain, (char*) credssp->identity.Password); + WLog_DBG(TAG, "User: %s Domain: %s Password: %s", + (char*) credssp->identity.User, (char*) credssp->identity.Domain, (char*) credssp->identity.Password); #endif if (credssp->transport->layer == TRANSPORT_LAYER_TLS) @@ -200,7 +200,7 @@ int credssp_ntlm_client_init(rdpCredssp* credssp) } else { - DEBUG_WARN("Unknown NLA transport layer\n"); + WLog_ERR(TAG, "Unknown NLA transport layer"); return 0; } @@ -261,7 +261,7 @@ int credssp_client_authenticate(rdpCredssp* credssp) if (status != SEC_E_OK) { - DEBUG_WARN("QuerySecurityPackageInfo status: 0x%08X\n", status); + WLog_ERR(TAG, "QuerySecurityPackageInfo status: 0x%08X", status); return 0; } @@ -271,7 +271,7 @@ int credssp_client_authenticate(rdpCredssp* credssp) if (status != SEC_E_OK) { - DEBUG_WARN("AcquireCredentialsHandle status: 0x%08X\n", status); + WLog_ERR(TAG, "AcquireCredentialsHandle status: 0x%08X", status); return 0; } @@ -327,7 +327,7 @@ int credssp_client_authenticate(rdpCredssp* credssp) if (credssp->table->QueryContextAttributes(&credssp->context, SECPKG_ATTR_SIZES, &credssp->ContextSizes) != SEC_E_OK) { - DEBUG_WARN("QueryContextAttributes SECPKG_ATTR_SIZES failure\n"); + WLog_ERR(TAG, "QueryContextAttributes SECPKG_ATTR_SIZES failure"); return 0; } @@ -341,7 +341,7 @@ int credssp_client_authenticate(rdpCredssp* credssp) credssp->negoToken.pvBuffer = output_buffer.pvBuffer; credssp->negoToken.cbBuffer = output_buffer.cbBuffer; #ifdef WITH_DEBUG_CREDSSP - DEBUG_WARN("Sending Authentication Token\n"); + WLog_DBG(TAG, "Sending Authentication Token"); winpr_HexDump(TAG, WLOG_DEBUG, credssp->negoToken.pvBuffer, credssp->negoToken.cbBuffer); #endif credssp_send(credssp); @@ -361,7 +361,7 @@ int credssp_client_authenticate(rdpCredssp* credssp) return -1; #ifdef WITH_DEBUG_CREDSSP - DEBUG_WARN("Receiving Authentication Token (%d)\n", (int) credssp->negoToken.cbBuffer); + WLog_DBG(TAG, "Receiving Authentication Token (%d)", (int) credssp->negoToken.cbBuffer); winpr_HexDump(TAG, WLOG_DEBUG, credssp->negoToken.pvBuffer, credssp->negoToken.cbBuffer); #endif input_buffer.pvBuffer = credssp->negoToken.pvBuffer; @@ -380,7 +380,7 @@ int credssp_client_authenticate(rdpCredssp* credssp) if (status != SEC_E_OK) { - DEBUG_WARN("Could not verify public key echo!\n"); + WLog_ERR(TAG, "Could not verify public key echo!"); return -1; } @@ -389,7 +389,7 @@ int credssp_client_authenticate(rdpCredssp* credssp) if (status != SEC_E_OK) { - DEBUG_WARN("credssp_encrypt_ts_credentials status: 0x%08X\n", status); + WLog_ERR(TAG, "credssp_encrypt_ts_credentials status: 0x%08X", status); return 0; } @@ -436,7 +436,7 @@ int credssp_server_authenticate(rdpCredssp* credssp) if (!hSSPI) { - DEBUG_WARN("Failed to load SSPI module: %s\n", credssp->SspiModule); + WLog_ERR(TAG, "Failed to load SSPI module: %s", credssp->SspiModule); return 0; } @@ -456,7 +456,7 @@ int credssp_server_authenticate(rdpCredssp* credssp) if (status != SEC_E_OK) { - DEBUG_WARN("QuerySecurityPackageInfo status: 0x%08X\n", status); + WLog_ERR(TAG, "QuerySecurityPackageInfo status: 0x%08X", status); return 0; } @@ -466,7 +466,7 @@ int credssp_server_authenticate(rdpCredssp* credssp) if (status != SEC_E_OK) { - DEBUG_WARN("AcquireCredentialsHandle status: 0x%08X\n", status); + WLog_ERR(TAG, "AcquireCredentialsHandle status: 0x%08X", status); return 0; } @@ -509,7 +509,7 @@ int credssp_server_authenticate(rdpCredssp* credssp) return -1; #ifdef WITH_DEBUG_CREDSSP - DEBUG_WARN("Receiving Authentication Token\n"); + WLog_DBG(TAG, "Receiving Authentication Token"); credssp_buffer_print(credssp); #endif input_buffer.pvBuffer = credssp->negoToken.pvBuffer; @@ -517,7 +517,7 @@ int credssp_server_authenticate(rdpCredssp* credssp) if (credssp->negoToken.cbBuffer < 1) { - DEBUG_WARN("CredSSP: invalid negoToken!\n"); + WLog_ERR(TAG, "CredSSP: invalid negoToken!"); return -1; } @@ -551,13 +551,13 @@ int credssp_server_authenticate(rdpCredssp* credssp) if (credssp->table->QueryContextAttributes(&credssp->context, SECPKG_ATTR_SIZES, &credssp->ContextSizes) != SEC_E_OK) { - DEBUG_WARN("QueryContextAttributes SECPKG_ATTR_SIZES failure\n"); + WLog_ERR(TAG, "QueryContextAttributes SECPKG_ATTR_SIZES failure"); return 0; } if (credssp_decrypt_public_key_echo(credssp) != SEC_E_OK) { - DEBUG_WARN("Error: could not verify client's public key echo\n"); + WLog_ERR(TAG, "Error: could not verify client's public key echo"); return -1; } @@ -569,13 +569,13 @@ int credssp_server_authenticate(rdpCredssp* credssp) if ((status != SEC_E_OK) && (status != SEC_I_CONTINUE_NEEDED)) { - DEBUG_WARN("AcceptSecurityContext status: 0x%08X\n", status); + WLog_ERR(TAG, "AcceptSecurityContext status: 0x%08X", status); return -1; /* Access Denied */ } /* send authentication token */ #ifdef WITH_DEBUG_CREDSSP - DEBUG_WARN("Sending Authentication Token\n"); + WLog_DBG(TAG, "Sending Authentication Token"); credssp_buffer_print(credssp); #endif credssp_send(credssp); @@ -594,13 +594,13 @@ int credssp_server_authenticate(rdpCredssp* credssp) if (credssp_decrypt_ts_credentials(credssp) != SEC_E_OK) { - DEBUG_WARN("Could not decrypt TSCredentials status: 0x%08X\n", status); + WLog_ERR(TAG, "Could not decrypt TSCredentials status: 0x%08X", status); return 0; } if (status != SEC_E_OK) { - DEBUG_WARN("AcceptSecurityContext status: 0x%08X\n", status); + WLog_ERR(TAG, "AcceptSecurityContext status: 0x%08X", status); return 0; } @@ -608,7 +608,7 @@ int credssp_server_authenticate(rdpCredssp* credssp) if (status != SEC_E_OK) { - DEBUG_WARN("ImpersonateSecurityContext status: 0x%08X\n", status); + WLog_ERR(TAG, "ImpersonateSecurityContext status: 0x%08X", status); return 0; } else @@ -617,7 +617,7 @@ int credssp_server_authenticate(rdpCredssp* credssp) if (status != SEC_E_OK) { - DEBUG_WARN("RevertSecurityContext status: 0x%08X\n", status); + WLog_ERR(TAG, "RevertSecurityContext status: 0x%08X", status); return 0; } } @@ -707,7 +707,7 @@ SECURITY_STATUS credssp_encrypt_public_key_echo(rdpCredssp* credssp) if (status != SEC_E_OK) { - DEBUG_WARN("EncryptMessage status: 0x%08X\n", status); + WLog_ERR(TAG, "EncryptMessage status: 0x%08X", status); return status; } @@ -728,7 +728,7 @@ SECURITY_STATUS credssp_decrypt_public_key_echo(rdpCredssp* credssp) if (credssp->PublicKey.cbBuffer + credssp->ContextSizes.cbMaxSignature != credssp->pubKeyAuth.cbBuffer) { - DEBUG_WARN("unexpected pubKeyAuth buffer size:%d\n", (int) credssp->pubKeyAuth.cbBuffer); + WLog_ERR(TAG, "unexpected pubKeyAuth buffer size:%d", (int) credssp->pubKeyAuth.cbBuffer); return SEC_E_INVALID_TOKEN; } @@ -749,7 +749,7 @@ SECURITY_STATUS credssp_decrypt_public_key_echo(rdpCredssp* credssp) if (status != SEC_E_OK) { - DEBUG_WARN("DecryptMessage failure: 0x%08X\n", status); + WLog_ERR(TAG, "DecryptMessage failure: 0x%08X", status); return status; } @@ -764,10 +764,10 @@ SECURITY_STATUS credssp_decrypt_public_key_echo(rdpCredssp* credssp) if (memcmp(public_key1, public_key2, public_key_length) != 0) { - DEBUG_WARN("Could not verify server's public key echo\n"); - DEBUG_WARN("Expected (length = %d):\n", public_key_length); + WLog_ERR(TAG, "Could not verify server's public key echo"); + WLog_ERR(TAG, "Expected (length = %d):", public_key_length); winpr_HexDump(TAG, WLOG_ERROR, public_key1, public_key_length); - DEBUG_WARN("Actual (length = %d):\n", public_key_length); + WLog_ERR(TAG, "Actual (length = %d):", public_key_length); winpr_HexDump(TAG, WLOG_ERROR, public_key2, public_key_length); return SEC_E_MESSAGE_ALTERED; /* DO NOT SEND CREDENTIALS! */ } @@ -954,7 +954,7 @@ SECURITY_STATUS credssp_decrypt_ts_credentials(rdpCredssp* credssp) if (credssp->authInfo.cbBuffer < 1) { - DEBUG_WARN("credssp_decrypt_ts_credentials missing authInfo buffer\n"); + WLog_ERR(TAG, "credssp_decrypt_ts_credentials missing authInfo buffer"); return SEC_E_INVALID_TOKEN; } @@ -1089,7 +1089,7 @@ int credssp_recv(rdpCredssp* credssp) if (status < 0) { - DEBUG_WARN("credssp_recv() error: %d\n", status); + WLog_ERR(TAG, "credssp_recv() error: %d", status); Stream_Free(s, TRUE); return -1; } @@ -1159,21 +1159,21 @@ void credssp_buffer_print(rdpCredssp* credssp) { if (credssp->negoToken.cbBuffer > 0) { - DEBUG_WARN("CredSSP.negoToken (length = %d):\n", (int) credssp->negoToken.cbBuffer); + WLog_ERR(TAG, "CredSSP.negoToken (length = %d):", (int) credssp->negoToken.cbBuffer); winpr_HexDump(TAG, WLOG_ERROR, credssp->negoToken.pvBuffer, credssp->negoToken.cbBuffer); } if (credssp->pubKeyAuth.cbBuffer > 0) { - DEBUG_WARN("CredSSP.pubKeyAuth (length = %d):\n", (int) credssp->pubKeyAuth.cbBuffer); + WLog_ERR(TAG, "CredSSP.pubKeyAuth (length = %d):", (int) credssp->pubKeyAuth.cbBuffer); winpr_HexDump(TAG, WLOG_ERROR, credssp->pubKeyAuth.pvBuffer, credssp->pubKeyAuth.cbBuffer); } if (credssp->authInfo.cbBuffer > 0) { - DEBUG_WARN("CredSSP.authInfo (length = %d):\n", (int) credssp->authInfo.cbBuffer); + WLog_ERR(TAG, "CredSSP.authInfo (length = %d):", (int) credssp->authInfo.cbBuffer); winpr_HexDump(TAG, WLOG_ERROR, credssp->authInfo.pvBuffer, credssp->authInfo.cbBuffer); } @@ -1284,7 +1284,7 @@ rdpCredssp* credssp_new(freerdp* instance, rdpTransport* transport, rdpSettings* if (status == ERROR_SUCCESS) { - DEBUG_WARN("Using SSPI Module: %s\n", credssp->SspiModule); + WLog_INFO(TAG, "Using SSPI Module: %s", credssp->SspiModule); RegCloseKey(hKey); } } diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 8a9b98997..3142aba7b 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -26,11 +26,14 @@ #include #include +#include #include #include #include "orders.h" +#define TAG FREERDP_TAG("core.orders") + #ifdef WITH_DEBUG_ORDERS static const char* const PRIMARY_DRAWING_ORDER_STRINGS[] = @@ -749,7 +752,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int if (orderInfo->fieldFlags & (1 << (NO-1))) \ { \ if (Stream_GetRemainingLength(s) < 1) {\ - DEBUG_WARN( "%s: error reading %s\n", __FUNCTION__, #TARGET); \ + WLog_ERR(TAG, "error reading %s", #TARGET); \ return FALSE; \ } \ Stream_Read_UINT8(s, TARGET); \ @@ -761,7 +764,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int if (orderInfo->fieldFlags & (1 << (NO-1))) \ { \ if (Stream_GetRemainingLength(s) < 2) { \ - DEBUG_WARN( "%s: error reading %s or %s\n", __FUNCTION__, #TARGET1, #TARGET2); \ + WLog_ERR(TAG, "error reading %s or %s", #TARGET1, #TARGET2); \ return FALSE; \ } \ Stream_Read_UINT8(s, TARGET1); \ @@ -774,7 +777,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int if (orderInfo->fieldFlags & (1 << (NO-1))) \ { \ if (Stream_GetRemainingLength(s) < 2) { \ - DEBUG_WARN( "%s: error reading %s\n", __FUNCTION__, #TARGET); \ + WLog_ERR(TAG, "error reading %s", #TARGET); \ return FALSE; \ } \ Stream_Read_UINT16(s, TARGET); \ @@ -785,7 +788,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int if (orderInfo->fieldFlags & (1 << (NO-1))) \ { \ if (Stream_GetRemainingLength(s) < 4) { \ - DEBUG_WARN( "%s: error reading %s\n", __FUNCTION__, #TARGET); \ + WLog_ERR(TAG, "error reading %s", #TARGET); \ return FALSE; \ } \ Stream_Read_UINT32(s, TARGET); \ @@ -795,14 +798,14 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int #define ORDER_FIELD_COORD(NO, TARGET) \ do { \ if ((orderInfo->fieldFlags & (1 << (NO-1))) && !update_read_coord(s, &TARGET, orderInfo->deltaCoordinates)) { \ - DEBUG_WARN( "%s: error reading %s\n", __FUNCTION__, #TARGET); \ + WLog_ERR(TAG, "error reading %s", #TARGET); \ return FALSE; \ } \ } while(0) #define ORDER_FIELD_COLOR(NO, TARGET) \ do { \ if ((orderInfo->fieldFlags & (1 << (NO-1))) && !update_read_color(s, &TARGET)) { \ - DEBUG_WARN( "%s: error reading %s\n", __FUNCTION__, #TARGET); \ + WLog_ERR(TAG, "error reading %s", #TARGET); \ return FALSE; \ } \ } while(0) @@ -811,12 +814,12 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int #define FIELD_SKIP_BUFFER16(s, TARGET_LEN) \ do { \ if (Stream_GetRemainingLength(s) < 2) {\ - DEBUG_WARN( "%s: error reading length %s\n", __FUNCTION__, #TARGET_LEN); \ + WLog_ERR(TAG, "error reading length %s", #TARGET_LEN); \ return FALSE; \ }\ Stream_Read_UINT16(s, TARGET_LEN); \ if (!Stream_SafeSeek(s, TARGET_LEN)) { \ - DEBUG_WARN( "%s: error skipping %d bytes\n", __FUNCTION__, TARGET_LEN); \ + WLog_ERR(TAG, "error skipping %d bytes", TARGET_LEN); \ return FALSE; \ } \ } while(0) @@ -1842,7 +1845,7 @@ BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap Stream_Read_UINT8(s, cache_bitmap->bitmapBpp); /* bitmapBpp (1 byte) */ if ((cache_bitmap->bitmapBpp < 1) || (cache_bitmap->bitmapBpp > 32)) { - DEBUG_WARN( "%s: invalid bitmap bpp %d\n", __FUNCTION__, cache_bitmap->bitmapBpp); + WLog_ERR(TAG, "invalid bitmap bpp %d", cache_bitmap->bitmapBpp); return FALSE; } Stream_Read_UINT16(s, cache_bitmap->bitmapLength); /* bitmapLength (2 bytes) */ @@ -2085,7 +2088,7 @@ BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_ Stream_Read_UINT8(s, bitmapData->bpp); if ((bitmapData->bpp < 1) || (bitmapData->bpp > 32)) { - DEBUG_WARN( "%s: invalid bpp value %d", __FUNCTION__, bitmapData->bpp); + WLog_ERR(TAG, "invalid bpp value %d", bitmapData->bpp); return FALSE; } Stream_Seek_UINT8(s); /* reserved1 (1 byte) */ @@ -2447,7 +2450,7 @@ BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush, U { if (cache_brush->length != 8) { - DEBUG_WARN( "incompatible 1bpp brush of length:%d\n", cache_brush->length); + WLog_ERR(TAG, "incompatible 1bpp brush of length:%d", cache_brush->length); return TRUE; // should be FALSE ? } @@ -2526,7 +2529,7 @@ BOOL update_write_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush, { if (cache_brush->length != 8) { - DEBUG_WARN( "incompatible 1bpp brush of length:%d\n", cache_brush->length); + WLog_ERR(TAG, "incompatible 1bpp brush of length:%d", cache_brush->length); return FALSE; } @@ -2694,7 +2697,7 @@ BOOL update_read_create_nine_grid_bitmap_order(wStream* s, CREATE_NINE_GRID_BITM Stream_Read_UINT8(s, create_nine_grid_bitmap->bitmapBpp); /* bitmapBpp (1 byte) */ if ((create_nine_grid_bitmap->bitmapBpp < 1) || (create_nine_grid_bitmap->bitmapBpp > 32)) { - DEBUG_WARN( "%s: invalid bpp value %d", __FUNCTION__, create_nine_grid_bitmap->bitmapBpp); + WLog_ERR(TAG, "invalid bpp value %d", create_nine_grid_bitmap->bitmapBpp); return FALSE; } Stream_Read_UINT16(s, create_nine_grid_bitmap->bitmapId); /* bitmapId (2 bytes) */ @@ -2734,7 +2737,7 @@ BOOL update_read_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER Stream_Read_UINT8(s, stream_bitmap_first->bitmapBpp); /* bitmapBpp (1 byte) */ if ((stream_bitmap_first->bitmapBpp < 1) || (stream_bitmap_first->bitmapBpp > 32)) { - DEBUG_WARN( "%s: invalid bpp value %d", __FUNCTION__, stream_bitmap_first->bitmapBpp); + WLog_ERR(TAG, "invalid bpp value %d", stream_bitmap_first->bitmapBpp); return FALSE; } @@ -3076,7 +3079,7 @@ BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) if (orderInfo->orderType >= PRIMARY_DRAWING_ORDER_COUNT) { - DEBUG_WARN( "Invalid Primary Drawing Order (0x%02X)\n", orderInfo->orderType); + WLog_ERR(TAG, "Invalid Primary Drawing Order (0x%02X)", orderInfo->orderType); return FALSE; } @@ -3098,7 +3101,7 @@ BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) orderInfo->deltaCoordinates = (flags & ORDER_DELTA_COORDINATES) ? TRUE : FALSE; #ifdef WITH_DEBUG_ORDERS - DEBUG_WARN( "%s Primary Drawing Order (0x%02X)\n", PRIMARY_DRAWING_ORDER_STRINGS[orderInfo->orderType], orderInfo->orderType); + WLog_DBG(TAG, "%s Primary Drawing Order (0x%02X)", PRIMARY_DRAWING_ORDER_STRINGS[orderInfo->orderType], orderInfo->orderType); #endif switch (orderInfo->orderType) @@ -3289,9 +3292,9 @@ BOOL update_recv_secondary_order(rdpUpdate* update, wStream* s, BYTE flags) #ifdef WITH_DEBUG_ORDERS if (orderType < SECONDARY_DRAWING_ORDER_COUNT) - DEBUG_WARN( "%s Secondary Drawing Order (0x%02X)\n", SECONDARY_DRAWING_ORDER_STRINGS[orderType], orderType); + WLog_DBG(TAG, "%s Secondary Drawing Order (0x%02X)", SECONDARY_DRAWING_ORDER_STRINGS[orderType], orderType); else - DEBUG_WARN( "Unknown Secondary Drawing Order (0x%02X)\n", orderType); + WLog_DBG(TAG, "Unknown Secondary Drawing Order (0x%02X)", orderType); #endif switch (orderType) @@ -3381,9 +3384,9 @@ BOOL update_recv_altsec_order(rdpUpdate* update, wStream* s, BYTE flags) #ifdef WITH_DEBUG_ORDERS if (orderType < ALTSEC_DRAWING_ORDER_COUNT) - DEBUG_WARN( "%s Alternate Secondary Drawing Order (0x%02X)\n", ALTSEC_DRAWING_ORDER_STRINGS[orderType], orderType); + WLog_DBG(TAG, "%s Alternate Secondary Drawing Order (0x%02X)", ALTSEC_DRAWING_ORDER_STRINGS[orderType], orderType); else - DEBUG_WARN( "Unknown Alternate Secondary Drawing Order: 0x%02X\n", orderType); + WLog_DBG(TAG, "Unknown Alternate Secondary Drawing Order: 0x%02X", orderType); #endif switch (orderType) diff --git a/libfreerdp/core/peer.c b/libfreerdp/core/peer.c index e2f3f48f2..cc1451b3f 100644 --- a/libfreerdp/core/peer.c +++ b/libfreerdp/core/peer.c @@ -26,10 +26,13 @@ #include "info.h" #include "certificate.h" +#include #include #include "peer.h" +#define TAG FREERDP_TAG("core.peer") + #ifdef WITH_DEBUG_RDP extern const char* DATA_PDU_TYPE_STRINGS[80]; #endif @@ -50,14 +53,14 @@ static BOOL freerdp_peer_initialize(freerdp_peer* client) if (!settings->RdpServerRsaKey) { - DEBUG_WARN( "%s: inavlid RDP key file %s\n", __FUNCTION__, settings->RdpKeyFile); + WLog_ERR(TAG, "inavlid RDP key file %s", settings->RdpKeyFile); return FALSE; } if (settings->RdpServerRsaKey->ModulusLength > 256) { - DEBUG_WARN( "%s: Key sizes > 2048 are currently not supported for RDP security.\n", __FUNCTION__); - DEBUG_WARN( "%s: Set a different key file than %s\n", __FUNCTION__, settings->RdpKeyFile); + WLog_ERR(TAG, "Key sizes > 2048 are currently not supported for RDP security."); + WLog_ERR(TAG, "Set a different key file than %s", settings->RdpKeyFile); exit(1); } } @@ -105,8 +108,8 @@ static BOOL peer_recv_data_pdu(freerdp_peer* client, wStream* s) return FALSE; #ifdef WITH_DEBUG_RDP - DEBUG_MSG("recv %s Data PDU (0x%02X), length: %d\n", - type < ARRAYSIZE(DATA_PDU_TYPE_STRINGS) ? DATA_PDU_TYPE_STRINGS[type] : "???", type, length); + WLog_DBG(TAG, "recv %s Data PDU (0x%02X), length: %d", + type < ARRAYSIZE(DATA_PDU_TYPE_STRINGS) ? DATA_PDU_TYPE_STRINGS[type] : "???", type, length); #endif switch (type) @@ -159,7 +162,7 @@ static BOOL peer_recv_data_pdu(freerdp_peer* client, wStream* s) break; default: - DEBUG_WARN( "Data PDU type %d\n", type); + WLog_ERR(TAG, "Data PDU type %d", type); break; } @@ -180,7 +183,7 @@ static int peer_recv_tpkt_pdu(freerdp_peer* client, wStream* s) if (!rdp_read_header(rdp, s, &length, &channelId)) { - DEBUG_WARN( "Incorrect RDP header.\n"); + WLog_ERR(TAG, "Incorrect RDP header."); return -1; } @@ -196,7 +199,7 @@ static int peer_recv_tpkt_pdu(freerdp_peer* client, wStream* s) { if (!rdp_decrypt(rdp, s, length - 4, securityFlags)) { - DEBUG_WARN( "rdp_decrypt failed\n"); + WLog_ERR(TAG, "rdp_decrypt failed"); return -1; } } @@ -227,7 +230,7 @@ static int peer_recv_tpkt_pdu(freerdp_peer* client, wStream* s) break; default: - DEBUG_WARN( "Client sent pduType %d\n", pduType); + WLog_ERR(TAG, "Client sent pduType %d", pduType); return -1; } } @@ -248,7 +251,7 @@ static int peer_recv_fastpath_pdu(freerdp_peer* client, wStream* s) if ((length == 0) || (length > Stream_GetRemainingLength(s))) { - DEBUG_WARN( "incorrect FastPath PDU header length %d\n", length); + WLog_ERR(TAG, "incorrect FastPath PDU header length %d", length); return -1; } @@ -387,7 +390,7 @@ static int peer_recv_callback(rdpTransport* transport, wStream* s, void* extra) break; default: - DEBUG_WARN( "Invalid state %d\n", rdp->state); + WLog_ERR(TAG, "Invalid state %d", rdp->state); return -1; } diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index 5360d53d6..e91855c2f 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -29,6 +29,9 @@ #include "redirection.h" #include +#include + +#define TAG FREERDP_TAG("core.rdp") #ifdef WITH_DEBUG_RDP const char* DATA_PDU_TYPE_STRINGS[80] = @@ -320,8 +323,7 @@ BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channelId) rdp_set_error_info(rdp, ERRINFO_RPC_INITIATED_DISCONNECT); } - DEBUG_WARN( "DisconnectProviderUltimatum: reason: %d\n", reason); - + WLog_ERR(TAG, "DisconnectProviderUltimatum: reason: %d", reason); rdp->disconnect = TRUE; EventArgsInit(&e, "freerdp"); @@ -417,7 +419,6 @@ static UINT32 rdp_security_stream_out(rdpRdp* rdp, wStream* s, int length, UINT3 memset(data+length, 0, pad); Stream_Write_UINT8(s, pad); - security_hmac_signature(data, length, Stream_Pointer(s), rdp); Stream_Seek(s, 8); security_fips_encrypt(data, length + pad, rdp); @@ -467,7 +468,7 @@ static UINT32 rdp_get_sec_bytes(rdpRdp* rdp) } /** - * Send an RDP packet.\n + * Send an RDP packet. * @param rdp RDP module * @param s stream * @param channel_id channel id @@ -476,14 +477,10 @@ static UINT32 rdp_get_sec_bytes(rdpRdp* rdp) BOOL rdp_send(rdpRdp* rdp, wStream* s, UINT16 channel_id) { UINT16 length; - length = Stream_GetPosition(s); Stream_SetPosition(s, 0); - rdp_write_header(rdp, s, length, channel_id); - length += rdp_security_stream_out(rdp, s, length, 0); - Stream_SetPosition(s, length); Stream_SealLength(s); @@ -498,21 +495,15 @@ BOOL rdp_send_pdu(rdpRdp* rdp, wStream* s, UINT16 type, UINT16 channel_id) UINT16 length; UINT32 sec_bytes; int sec_hold; - length = Stream_GetPosition(s); Stream_SetPosition(s, 0); - rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID); - sec_bytes = rdp_get_sec_bytes(rdp); sec_hold = Stream_GetPosition(s); Stream_Seek(s, sec_bytes); - rdp_write_share_control_header(s, length - sec_bytes, type, channel_id); - Stream_SetPosition(s, sec_hold); length += rdp_security_stream_out(rdp, s, length, 0); - Stream_SetPosition(s, length); Stream_SealLength(s); @@ -527,22 +518,16 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id) UINT16 length; UINT32 sec_bytes; int sec_hold; - length = Stream_GetPosition(s); Stream_SetPosition(s, 0); - rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID); - sec_bytes = rdp_get_sec_bytes(rdp); sec_hold = Stream_GetPosition(s); Stream_Seek(s, sec_bytes); - rdp_write_share_control_header(s, length - sec_bytes, PDU_TYPE_DATA, channel_id); rdp_write_share_data_header(s, length - sec_bytes, type, rdp->settings->ShareId); - Stream_SetPosition(s, sec_hold); length += rdp_security_stream_out(rdp, s, length, 0); - Stream_SetPosition(s, length); Stream_SealLength(s); @@ -557,19 +542,14 @@ BOOL rdp_send_message_channel_pdu(rdpRdp* rdp, wStream* s, UINT16 sec_flags) UINT16 length; UINT32 sec_bytes; int sec_hold; - length = Stream_GetPosition(s); Stream_SetPosition(s, 0); - rdp_write_header(rdp, s, length, rdp->mcs->messageChannelId); - sec_bytes = rdp_get_sec_bytes(rdp); sec_hold = Stream_GetPosition(s); Stream_Seek(s, sec_bytes); - Stream_SetPosition(s, sec_hold); length += rdp_security_stream_out(rdp, s, length, sec_flags); - Stream_SetPosition(s, length); Stream_SealLength(s); @@ -594,7 +574,6 @@ BOOL rdp_recv_server_set_keyboard_indicators_pdu(rdpRdp* rdp, wStream* s) Stream_Read_UINT16(s, unitId); /* unitId (2 bytes) */ Stream_Read_UINT16(s, ledFlags); /* ledFlags (2 bytes) */ - return TRUE; } @@ -610,7 +589,6 @@ BOOL rdp_recv_server_set_keyboard_ime_status_pdu(rdpRdp* rdp, wStream* s) Stream_Read_UINT16(s, unitId); /* unitId (2 bytes) */ Stream_Read_UINT32(s, imeState); /* imeState (4 bytes) */ Stream_Read_UINT32(s, imeConvMode); /* imeConvMode (4 bytes) */ - return TRUE; } @@ -622,9 +600,7 @@ BOOL rdp_recv_set_error_info_data_pdu(rdpRdp* rdp, wStream* s) return FALSE; Stream_Read_UINT32(s, errorInfo); /* errorInfo (4 bytes) */ - rdp_set_error_info(rdp, errorInfo); - return TRUE; } @@ -636,7 +612,6 @@ BOOL rdp_recv_server_auto_reconnect_status_pdu(rdpRdp* rdp, wStream* s) return FALSE; Stream_Read_UINT32(s, arcStatus); /* arcStatus (4 bytes) */ - return TRUE; } @@ -648,7 +623,6 @@ BOOL rdp_recv_server_status_info_pdu(rdpRdp* rdp, wStream* s) return FALSE; Stream_Read_UINT32(s, statusCode); /* statusCode (4 bytes) */ - return TRUE; } @@ -673,7 +647,6 @@ BOOL rdp_recv_monitor_layout_pdu(rdpRdp* rdp, wStream* s) for (index = 0; index < monitorCount; index++) { monitor = &(monitorDefArray[index]); - Stream_Read_UINT32(s, monitor->left); /* left (4 bytes) */ Stream_Read_UINT32(s, monitor->top); /* top (4 bytes) */ Stream_Read_UINT32(s, monitor->right); /* right (4 bytes) */ @@ -682,7 +655,6 @@ BOOL rdp_recv_monitor_layout_pdu(rdpRdp* rdp, wStream* s) } free(monitorDefArray); - return TRUE; } @@ -690,15 +662,12 @@ BOOL rdp_write_monitor_layout_pdu(wStream* s, UINT32 monitorCount, MONITOR_DEF* { UINT32 index; MONITOR_DEF* monitor; - Stream_EnsureRemainingCapacity(s, 4 + (monitorCount * 20)); - Stream_Write_UINT32(s, monitorCount); /* monitorCount (4 bytes) */ for (index = 0; index < monitorCount; index++) { monitor = &(monitorDefArray[index]); - Stream_Write_UINT32(s, monitor->left); /* left (4 bytes) */ Stream_Write_UINT32(s, monitor->top); /* top (4 bytes) */ Stream_Write_UINT32(s, monitor->right); /* right (4 bytes) */ @@ -731,7 +700,7 @@ int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s) if (Stream_GetRemainingLength(s) < (size_t) SrcSize) { - DEBUG_WARN( "bulk_decompress: not enough bytes for compressedLength %d\n", compressedLength); + WLog_ERR(TAG, "bulk_decompress: not enough bytes for compressedLength %d", compressedLength); return -1; } @@ -746,7 +715,7 @@ int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s) } else { - DEBUG_WARN( "bulk_decompress() failed\n"); + WLog_ERR(TAG, "bulk_decompress() failed"); return -1; } @@ -754,8 +723,8 @@ int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s) } #ifdef WITH_DEBUG_RDP - DEBUG_MSG("recv %s Data PDU (0x%02X), length: %d\n", - type < ARRAYSIZE(DATA_PDU_TYPE_STRINGS) ? DATA_PDU_TYPE_STRINGS[type] : "???", type, length); + WLog_DBG(TAG, "recv %s Data PDU (0x%02X), length: %d", + type < ARRAYSIZE(DATA_PDU_TYPE_STRINGS) ? DATA_PDU_TYPE_STRINGS[type] : "???", type, length); #endif switch (type) @@ -923,13 +892,13 @@ BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, int length, UINT16 securityFlags) if (!security_fips_decrypt(Stream_Pointer(s), length, rdp)) { - DEBUG_WARN( "FATAL: cannot decrypt\n"); + WLog_ERR(TAG, "FATAL: cannot decrypt"); return FALSE; /* TODO */ } if (!security_fips_check_signature(Stream_Pointer(s), length - pad, sig, rdp)) { - DEBUG_WARN( "FATAL: invalid packet signature\n"); + WLog_ERR(TAG, "FATAL: invalid packet signature"); return FALSE; /* TODO */ } @@ -953,7 +922,7 @@ BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, int length, UINT16 securityFlags) if (memcmp(wmac, cmac, sizeof(wmac)) != 0) { - DEBUG_WARN( "WARNING: invalid packet signature\n"); + WLog_ERR(TAG, "WARNING: invalid packet signature"); /* * Because Standard RDP Security is totally broken, * and cannot protect against MITM, don't treat signature @@ -985,7 +954,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s) if (!rdp_read_header(rdp, s, &length, &channelId)) { - DEBUG_WARN( "Incorrect RDP header.\n"); + WLog_ERR(TAG, "Incorrect RDP header."); return -1; } @@ -1001,7 +970,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s) { if (!rdp_decrypt(rdp, s, length - 4, securityFlags)) { - DEBUG_WARN( "rdp_decrypt failed\n"); + WLog_ERR(TAG, "rdp_decrypt failed"); return -1; } } @@ -1036,7 +1005,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s) case PDU_TYPE_DATA: if (rdp_recv_data_pdu(rdp, s) < 0) { - DEBUG_WARN( "rdp_recv_data_pdu failed\n"); + WLog_ERR(TAG, "rdp_recv_data_pdu failed"); return -1; } break; @@ -1051,7 +1020,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s) break; default: - DEBUG_WARN( "incorrect PDU type: 0x%04X\n", pduType); + WLog_ERR(TAG, "incorrect PDU type: 0x%04X", pduType); break; } @@ -1083,7 +1052,7 @@ static int rdp_recv_fastpath_pdu(rdpRdp* rdp, wStream* s) if ((length == 0) || (length > Stream_GetRemainingLength(s))) { - DEBUG_WARN( "incorrect FastPath PDU header length %d\n", length); + WLog_ERR(TAG, "incorrect FastPath PDU header length %d", length); return -1; } @@ -1164,7 +1133,7 @@ static int rdp_recv_callback(rdpTransport* transport, wStream* s, void* extra) break; default: - DEBUG_WARN( "Invalid state %d\n", rdp->state); + WLog_ERR(TAG, "Invalid state %d", rdp->state); status = -1; break; } diff --git a/libfreerdp/core/rdp.h b/libfreerdp/core/rdp.h index f830e737b..959a3b623 100644 --- a/libfreerdp/core/rdp.h +++ b/libfreerdp/core/rdp.h @@ -46,7 +46,7 @@ #include #include -#include +#include #include @@ -211,10 +211,11 @@ rdpRdp* rdp_new(rdpContext* context); void rdp_reset(rdpRdp* rdp); void rdp_free(rdpRdp* rdp); +#define RDP_TAG FREERDP_TAG("core.rdp") #ifdef WITH_DEBUG_RDP -#define DEBUG_RDP(fmt, ...) DEBUG_CLASS(RDP, fmt, ## __VA_ARGS__) +#define DEBUG_RDP(fmt, ...) WLog_DBG(RDP_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_RDP(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_RDP(fmt, ...) do { } while (0) #endif BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, int length, UINT16 securityFlags); diff --git a/libfreerdp/core/redirection.c b/libfreerdp/core/redirection.c index 156549279..242d001d4 100644 --- a/libfreerdp/core/redirection.c +++ b/libfreerdp/core/redirection.c @@ -23,56 +23,57 @@ #include #include + #include "connection.h" #include "redirection.h" -#define TAG FREERDP_TAG("core") +#define TAG FREERDP_TAG("core.redirection") void rdp_print_redirection_flags(UINT32 flags) { - DEBUG_WARN("redirectionFlags = {\n"); + WLog_INFO(TAG, "redirectionFlags = {"); if (flags & LB_TARGET_NET_ADDRESS) - DEBUG_WARN("\tLB_TARGET_NET_ADDRESS\n"); + WLog_INFO(TAG, "\tLB_TARGET_NET_ADDRESS"); if (flags & LB_LOAD_BALANCE_INFO) - DEBUG_WARN("\tLB_LOAD_BALANCE_INFO\n"); + WLog_INFO(TAG, "\tLB_LOAD_BALANCE_INFO"); if (flags & LB_USERNAME) - DEBUG_WARN("\tLB_USERNAME\n"); + WLog_INFO(TAG, "\tLB_USERNAME"); if (flags & LB_DOMAIN) - DEBUG_WARN("\tLB_DOMAIN\n"); + WLog_INFO(TAG, "\tLB_DOMAIN"); if (flags & LB_PASSWORD) - DEBUG_WARN("\tLB_PASSWORD\n"); + WLog_INFO(TAG, "\tLB_PASSWORD"); if (flags & LB_DONTSTOREUSERNAME) - DEBUG_WARN("\tLB_DONTSTOREUSERNAME\n"); + WLog_INFO(TAG, "\tLB_DONTSTOREUSERNAME"); if (flags & LB_SMARTCARD_LOGON) - DEBUG_WARN("\tLB_SMARTCARD_LOGON\n"); + WLog_INFO(TAG, "\tLB_SMARTCARD_LOGON"); if (flags & LB_NOREDIRECT) - DEBUG_WARN("\tLB_NOREDIRECT\n"); + WLog_INFO(TAG, "\tLB_NOREDIRECT"); if (flags & LB_TARGET_FQDN) - DEBUG_WARN("\tLB_TARGET_FQDN\n"); + WLog_INFO(TAG, "\tLB_TARGET_FQDN"); if (flags & LB_TARGET_NETBIOS_NAME) - DEBUG_WARN("\tLB_TARGET_NETBIOS_NAME\n"); + WLog_INFO(TAG, "\tLB_TARGET_NETBIOS_NAME"); if (flags & LB_TARGET_NET_ADDRESSES) - DEBUG_WARN("\tLB_TARGET_NET_ADDRESSES\n"); + WLog_INFO(TAG, "\tLB_TARGET_NET_ADDRESSES"); if (flags & LB_CLIENT_TSV_URL) - DEBUG_WARN("\tLB_CLIENT_TSV_URL\n"); + WLog_INFO(TAG, "\tLB_CLIENT_TSV_URL"); if (flags & LB_SERVER_TSV_CAPABLE) - DEBUG_WARN("\tLB_SERVER_TSV_CAPABLE\n"); + WLog_INFO(TAG, "\tLB_SERVER_TSV_CAPABLE"); - DEBUG_WARN("}\n"); + WLog_INFO(TAG, "}"); } BOOL rdp_redirection_read_string(wStream* s, char** str) @@ -81,7 +82,7 @@ BOOL rdp_redirection_read_string(wStream* s, char** str) if (Stream_GetRemainingLength(s) < 4) { - DEBUG_WARN("rdp_redirection_read_string failure: cannot read length\n"); + WLog_ERR(TAG, "rdp_redirection_read_string failure: cannot read length"); return FALSE; } @@ -89,7 +90,7 @@ BOOL rdp_redirection_read_string(wStream* s, char** str) if (Stream_GetRemainingLength(s) < length) { - DEBUG_WARN("rdp_redirection_read_string failure: incorrect length %d\n", length); + WLog_ERR(TAG, "rdp_redirection_read_string failure: incorrect length %d", length); return FALSE; } diff --git a/libfreerdp/core/redirection.h b/libfreerdp/core/redirection.h index 4451027eb..4c239b904 100644 --- a/libfreerdp/core/redirection.h +++ b/libfreerdp/core/redirection.h @@ -25,7 +25,7 @@ typedef struct rdp_redirection rdpRedirection; #include "rdp.h" #include -#include +#include #include #include @@ -57,10 +57,11 @@ int rdp_redirection_apply_settings(rdpRdp* rdp); rdpRedirection* redirection_new(void); void redirection_free(rdpRedirection* redirection); +#define REDIR_TAG FREERDP_TAG("core.redirection") #ifdef WITH_DEBUG_REDIR -#define DEBUG_REDIR(fmt, ...) DEBUG_CLASS(REDIR, fmt, ## __VA_ARGS__) +#define DEBUG_REDIR(fmt, ...) WLog_DBG(REDIR_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_REDIR(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_REDIR(fmt, ...) do { } while (0) #endif #endif /* __REDIRECTION_H */ diff --git a/libfreerdp/core/security.c b/libfreerdp/core/security.c index 4bd8427c9..dc46c42b5 100644 --- a/libfreerdp/core/security.c +++ b/libfreerdp/core/security.c @@ -24,6 +24,10 @@ #include "security.h" +#include + +#define TAG FREERDP_TAG("core") + /* 0x36 repeated 40 times */ static const BYTE pad1[40] = { @@ -132,7 +136,7 @@ static void security_salted_hash(const BYTE* salt, const BYTE* input, int length sha1 = crypto_sha1_init(); if (!sha1) { - DEBUG_WARN( "%s: unable to allocate a sha1\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a sha1"); return; } crypto_sha1_update(sha1, input, length); /* Input */ @@ -145,7 +149,7 @@ static void security_salted_hash(const BYTE* salt, const BYTE* input, int length md5 = crypto_md5_init(); if (!md5) { - DEBUG_WARN( "%s: unable to allocate a md5\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a md5"); return; } crypto_md5_update(md5, salt, 48); /* Salt (48 bytes) */ @@ -198,7 +202,7 @@ void security_md5_16_32_32(const BYTE* in0, const BYTE* in1, const BYTE* in2, BY md5 = crypto_md5_init(); if (!md5) { - DEBUG_WARN( "%s: unable to allocate a md5\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a md5"); return; } crypto_md5_update(md5, in0, 16); @@ -238,7 +242,7 @@ void security_mac_data(const BYTE* mac_salt_key, const BYTE* data, UINT32 length sha1 = crypto_sha1_init(); if (!sha1) { - DEBUG_WARN( "%s: unable to allocate a sha1\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a sha1"); return; } crypto_sha1_update(sha1, mac_salt_key, 16); /* MacSaltKey */ @@ -251,7 +255,7 @@ void security_mac_data(const BYTE* mac_salt_key, const BYTE* data, UINT32 length md5 = crypto_md5_init(); if (!md5) { - DEBUG_WARN( "%s: unable to allocate a md5\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a md5"); return; } crypto_md5_update(md5, mac_salt_key, 16); /* MacSaltKey */ @@ -274,7 +278,7 @@ void security_mac_signature(rdpRdp *rdp, const BYTE* data, UINT32 length, BYTE* sha1 = crypto_sha1_init(); if (!sha1) { - DEBUG_WARN( "%s: unable to allocate a sha1\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a sha1"); return; } crypto_sha1_update(sha1, rdp->sign_key, rdp->rc4_key_len); /* MacKeyN */ @@ -287,7 +291,7 @@ void security_mac_signature(rdpRdp *rdp, const BYTE* data, UINT32 length, BYTE* md5 = crypto_md5_init(); if (!md5) { - DEBUG_WARN( "%s: unable to allocate a md5\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a md5"); return; } crypto_md5_update(md5, rdp->sign_key, rdp->rc4_key_len); /* MacKeyN */ @@ -327,7 +331,7 @@ void security_salted_mac_signature(rdpRdp *rdp, const BYTE* data, UINT32 length, sha1 = crypto_sha1_init(); if (!sha1) { - DEBUG_WARN( "%s: unable to allocate a sha1\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a sha1"); return; } crypto_sha1_update(sha1, rdp->sign_key, rdp->rc4_key_len); /* MacKeyN */ @@ -341,7 +345,7 @@ void security_salted_mac_signature(rdpRdp *rdp, const BYTE* data, UINT32 length, md5 = crypto_md5_init(); if (!md5) { - DEBUG_WARN( "%s: unable to allocate a md5\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a md5"); return; } crypto_md5_update(md5, rdp->sign_key, rdp->rc4_key_len); /* MacKeyN */ @@ -418,13 +422,11 @@ BOOL security_establish_keys(const BYTE* client_random, rdpRdp* rdp) CryptoSha1 sha1; BYTE client_encrypt_key_t[CRYPTO_SHA1_DIGEST_LENGTH + 1]; BYTE client_decrypt_key_t[CRYPTO_SHA1_DIGEST_LENGTH + 1]; - - DEBUG_WARN( "FIPS Compliant encryption level.\n"); - + WLog_INFO(TAG, "FIPS Compliant encryption level."); sha1 = crypto_sha1_init(); if (!sha1) { - DEBUG_WARN( "%s: unable to allocate a sha1\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a sha1"); return FALSE; } crypto_sha1_update(sha1, client_random + 16, 16); @@ -435,7 +437,7 @@ BOOL security_establish_keys(const BYTE* client_random, rdpRdp* rdp) sha1 = crypto_sha1_init(); if (!sha1) { - DEBUG_WARN( "%s: unable to allocate a sha1\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a sha1"); return FALSE; } crypto_sha1_update(sha1, client_random, 16); @@ -446,7 +448,7 @@ BOOL security_establish_keys(const BYTE* client_random, rdpRdp* rdp) sha1 = crypto_sha1_init(); if (!sha1) { - DEBUG_WARN( "%s: unable to allocate a sha1\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a sha1"); return FALSE; } crypto_sha1_update(sha1, client_decrypt_key_t, 20); @@ -528,7 +530,7 @@ BOOL security_key_update(BYTE* key, BYTE* update_key, int key_len, rdpRdp* rdp) sha1 = crypto_sha1_init(); if (!sha1) { - DEBUG_WARN( "%s: unable to allocate a sha1\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a sha1"); return FALSE; } crypto_sha1_update(sha1, update_key, key_len); @@ -539,7 +541,7 @@ BOOL security_key_update(BYTE* key, BYTE* update_key, int key_len, rdpRdp* rdp) md5 = crypto_md5_init(); if (!md5) { - DEBUG_WARN( "%s: unable to allocate a md5\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a md5"); return FALSE; } crypto_md5_update(md5, update_key, key_len); @@ -550,7 +552,7 @@ BOOL security_key_update(BYTE* key, BYTE* update_key, int key_len, rdpRdp* rdp) rc4 = crypto_rc4_init(key, key_len); if (!rc4) { - DEBUG_WARN( "%s: unable to allocate a rc4\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate a rc4"); return FALSE; } crypto_rc4(rc4, key_len, key, key); @@ -573,7 +575,7 @@ BOOL security_encrypt(BYTE* data, int length, rdpRdp* rdp) rdp->rc4_encrypt_key = crypto_rc4_init(rdp->encrypt_key, rdp->rc4_key_len); if (!rdp->rc4_encrypt_key) { - DEBUG_WARN( "%s: unable to allocate rc4 encrypt key\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate rc4 encrypt key"); return FALSE; } rdp->encrypt_use_count = 0; @@ -595,7 +597,7 @@ BOOL security_decrypt(BYTE* data, int length, rdpRdp* rdp) rdp->rc4_decrypt_key = crypto_rc4_init(rdp->decrypt_key, rdp->rc4_key_len); if (!rdp->rc4_decrypt_key) { - DEBUG_WARN( "%s: unable to allocate rc4 decrypt key\n", __FUNCTION__); + WLog_ERR(TAG, "unable to allocate rc4 decrypt key"); return FALSE; } diff --git a/libfreerdp/core/server.c b/libfreerdp/core/server.c index 6c84922d4..825501ee2 100644 --- a/libfreerdp/core/server.c +++ b/libfreerdp/core/server.c @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -36,10 +37,11 @@ #include "server.h" +#define TAG FREERDP_TAG("core.server") #ifdef WITH_DEBUG_DVC -#define DEBUG_DVC(fmt, ...) DEBUG_CLASS(DVC, fmt, ## __VA_ARGS__) +#define DEBUG_DVC(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_DVC(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_DVC(fmt, ...) do { } while (0) #endif struct _wtsChannelMessage @@ -195,7 +197,7 @@ static void wts_read_drdynvc_data(rdpPeerChannel* channel, wStream* s, UINT32 le if (Stream_GetPosition(channel->receiveData) + length > channel->dvc_total_length) { channel->dvc_total_length = 0; - DEBUG_WARN( "wts_read_drdynvc_data: incorrect fragment data, discarded.\n"); + WLog_ERR(TAG, "incorrect fragment data, discarded."); return; } @@ -279,7 +281,7 @@ static void wts_read_drdynvc_pdu(rdpPeerChannel* channel) break; default: - DEBUG_WARN( "wts_read_drdynvc_pdu: Cmd %d not recognized.\n", Cmd); + WLog_ERR(TAG, "Cmd %d not recognized.", Cmd); break; } } @@ -290,7 +292,7 @@ static void wts_read_drdynvc_pdu(rdpPeerChannel* channel) } else { - DEBUG_WARN( "wts_read_drdynvc_pdu: received Cmd %d but channel is not ready.\n", Cmd); + WLog_ERR(TAG, "received Cmd %d but channel is not ready.", Cmd); } } @@ -352,7 +354,7 @@ static void WTSProcessChannelData(rdpPeerChannel* channel, UINT16 channelId, BYT { if (Stream_GetPosition(channel->receiveData) != totalSize) { - DEBUG_WARN( "WTSProcessChannelData: read error\n"); + WLog_ERR(TAG, "read error"); } if (channel == channel->vcm->drdynvc_channel) { diff --git a/libfreerdp/core/server.h b/libfreerdp/core/server.h index fe438330e..6c878d4b8 100644 --- a/libfreerdp/core/server.h +++ b/libfreerdp/core/server.h @@ -21,7 +21,7 @@ #define FREERDP_CORE_SERVER_H #include -#include + #include #include diff --git a/libfreerdp/core/surface.c b/libfreerdp/core/surface.c index 1019f13f9..f1997c3d0 100644 --- a/libfreerdp/core/surface.c +++ b/libfreerdp/core/surface.c @@ -22,9 +22,12 @@ #endif #include +#include #include "surface.h" +#define TAG FREERDP_TAG("core.surface") + static int update_recv_surfcmd_surface_bits(rdpUpdate* update, wStream* s, UINT32* length) { int pos; @@ -40,7 +43,7 @@ static int update_recv_surfcmd_surface_bits(rdpUpdate* update, wStream* s, UINT3 Stream_Read_UINT8(s, cmd->bpp); if ((cmd->bpp < 1) || (cmd->bpp > 32)) { - DEBUG_WARN( "%s: invalid bpp value %d", __FUNCTION__, cmd->bpp); + WLog_ERR(TAG, "invalid bpp value %d", cmd->bpp); return FALSE; } @@ -60,11 +63,10 @@ static int update_recv_surfcmd_surface_bits(rdpUpdate* update, wStream* s, UINT3 *length = 20 + cmd->bitmapDataLength; WLog_Print(update->log, WLOG_DEBUG, - "SurfaceBits: destLeft: %d destTop: %d destRight: %d destBottom: %d " - "bpp: %d codecId: %d width: %d height: %d bitmapDataLength: %d", - cmd->destLeft, cmd->destTop, cmd->destRight, cmd->destBottom, - cmd->bpp, cmd->codecID, cmd->width, cmd->height, cmd->bitmapDataLength); - + "SurfaceBits: destLeft: %d destTop: %d destRight: %d destBottom: %d " + "bpp: %d codecId: %d width: %d height: %d bitmapDataLength: %d", + cmd->destLeft, cmd->destTop, cmd->destRight, cmd->destBottom, + cmd->bpp, cmd->codecID, cmd->width, cmd->height, cmd->bitmapDataLength); IFCALL(update->SurfaceBits, update->context, cmd); return 0; @@ -118,7 +120,7 @@ int update_recv_surfcmds(rdpUpdate* update, UINT32 size, wStream* s) break; default: - DEBUG_WARN("unknown cmdType 0x%X", cmdType); + WLog_ERR(TAG, "unknown cmdType 0x%X", cmdType); return -1; } diff --git a/libfreerdp/core/tcp.c b/libfreerdp/core/tcp.c index 66029fca8..faf1cecae 100644 --- a/libfreerdp/core/tcp.c +++ b/libfreerdp/core/tcp.c @@ -65,13 +65,15 @@ #endif -#include +#include #include #include #include #include "tcp.h" +#define TAG FREERDP_TAG("core") + /* Simple Socket BIO */ static int transport_bio_simple_new(BIO* bio); @@ -277,7 +279,7 @@ static int transport_bio_buffered_write(BIO* bio, const char* buf, int num) */ if (buf && num && !ringbuffer_write(&tcp->xmitBuffer, (const BYTE*) buf, num)) { - DEBUG_WARN( "%s: an error occured when writing(toWrite=%d)\n", __FUNCTION__, num); + WLog_ERR(TAG, "an error occured when writing(toWrite=%d)", num); return -1; } @@ -476,14 +478,13 @@ void tcp_get_mac_address(rdpTcp* tcp) if (ioctl(tcp->sockfd, SIOCGIFHWADDR, &if_req) != 0) { - DEBUG_WARN( "failed to obtain MAC address\n"); + WLog_ERR(TAG, "failed to obtain MAC address"); return; } memmove((void*) mac, (void*) &if_req.ifr_ifru.ifru_hwaddr.sa_data[0], 6); #endif - - /* DEBUG_WARN( "MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", + /* WLog_ERR(TAG, "MAC: %02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); */ } @@ -590,7 +591,7 @@ BOOL tcp_connect(rdpTcp* tcp, const char* hostname, int port, int timeout) if (!tcp->ipcSocket) { if (setsockopt(tcp->sockfd, IPPROTO_TCP, TCP_NODELAY, (void*) &option_value, option_len) < 0) - fprintf(stderr, "%s: unable to set TCP_NODELAY\n", __FUNCTION__); + WLog_ERR(TAG, "unable to set TCP_NODELAY"); } /* receive buffer must be a least 32 K */ @@ -603,7 +604,7 @@ BOOL tcp_connect(rdpTcp* tcp, const char* hostname, int port, int timeout) if (setsockopt(tcp->sockfd, SOL_SOCKET, SO_RCVBUF, (void*) &option_value, option_len) < 0) { - DEBUG_WARN( "%s: unable to set receive buffer len\n", __FUNCTION__); + WLog_ERR(TAG, "unable to set receive buffer len"); return FALSE; } } @@ -643,7 +644,7 @@ BOOL tcp_set_blocking_mode(rdpTcp* tcp, BOOL blocking) if (flags == -1) { - DEBUG_WARN( "%s: fcntl failed, %s.\n", __FUNCTION__, strerror(errno)); + WLog_ERR(TAG, "fcntl failed, %s.", strerror(errno)); return FALSE; } @@ -693,7 +694,7 @@ BOOL tcp_set_keep_alive_mode(rdpTcp* tcp) if (setsockopt(tcp->sockfd, SOL_SOCKET, SO_KEEPALIVE, (void*) &option_value, option_len) < 0) { - DEBUG_WARN("setsockopt() SOL_SOCKET, SO_KEEPALIVE:"); + WLog_ERR(TAG, "setsockopt() SOL_SOCKET, SO_KEEPALIVE:"); return FALSE; } @@ -703,7 +704,7 @@ BOOL tcp_set_keep_alive_mode(rdpTcp* tcp) if (setsockopt(tcp->sockfd, IPPROTO_TCP, TCP_KEEPIDLE, (void*) &option_value, option_len) < 0) { - DEBUG_WARN("setsockopt() IPPROTO_TCP, TCP_KEEPIDLE:"); + WLog_ERR(TAG, "setsockopt() IPPROTO_TCP, TCP_KEEPIDLE:"); return FALSE; } #endif @@ -714,7 +715,7 @@ BOOL tcp_set_keep_alive_mode(rdpTcp* tcp) if (setsockopt(tcp->sockfd, SOL_TCP, TCP_KEEPCNT, (void *) &option_value, option_len) < 0) { - DEBUG_WARN("setsockopt() SOL_TCP, TCP_KEEPCNT:"); + WLog_ERR(TAG, "setsockopt() SOL_TCP, TCP_KEEPCNT:"); return FALSE; } #endif @@ -725,7 +726,7 @@ BOOL tcp_set_keep_alive_mode(rdpTcp* tcp) if (setsockopt(tcp->sockfd, SOL_TCP, TCP_KEEPINTVL, (void *) &option_value, option_len) < 0) { - DEBUG_WARN("setsockopt() SOL_TCP, TCP_KEEPINTVL:"); + WLog_ERR(TAG, "setsockopt() SOL_TCP, TCP_KEEPINTVL:"); return FALSE; } #endif @@ -736,7 +737,7 @@ BOOL tcp_set_keep_alive_mode(rdpTcp* tcp) option_len = sizeof(option_value); if (setsockopt(tcp->sockfd, SOL_SOCKET, SO_NOSIGPIPE, (void *) &option_value, option_len) < 0) { - DEBUG_WARN("setsockopt() SOL_SOCKET, SO_NOSIGPIPE:"); + WLog_ERR(TAG, "setsockopt() SOL_SOCKET, SO_NOSIGPIPE:"); } #endif return TRUE; diff --git a/libfreerdp/core/timezone.h b/libfreerdp/core/timezone.h index 076a4bed5..a45cd4437 100644 --- a/libfreerdp/core/timezone.h +++ b/libfreerdp/core/timezone.h @@ -26,6 +26,7 @@ #include "config.h" #endif +#include #include #include @@ -37,10 +38,11 @@ void rdp_get_client_time_zone(wStream* s, rdpSettings* settings); BOOL rdp_read_client_time_zone(wStream* s, rdpSettings* settings); void rdp_write_client_time_zone(wStream* s, rdpSettings* settings); +#define TIMEZONE_TAG FREERDP_TAG("core.timezone") #ifdef WITH_DEBUG_TIMEZONE -#define DEBUG_TIMEZONE(fmt, ...) DEBUG_CLASS(TIMEZONE, fmt, ## __VA_ARGS__) +#define DEBUG_TIMEZONE(fmt, ...) WLog_DBG(TIMEZONE_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_TIMEZONE(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_TIMEZONE(fmt, ...) do { } while (0) #endif #endif /* __TIMEZONE_H */ diff --git a/libfreerdp/core/tpdu.c b/libfreerdp/core/tpdu.c index 0f49ffe29..441b0906d 100644 --- a/libfreerdp/core/tpdu.c +++ b/libfreerdp/core/tpdu.c @@ -24,10 +24,12 @@ #include #include -#include +#include #include "tpdu.h" +#define TAG FREERDP_TAG("core") + /** * TPDUs are defined in: * @@ -132,7 +134,7 @@ BOOL tpdu_read_connection_request(wStream* s, BYTE* li) if (code != X224_TPDU_CONNECTION_REQUEST) { - DEBUG_WARN( "Error: expected X224_TPDU_CONNECTION_REQUEST\n"); + WLog_ERR(TAG, "Error: expected X224_TPDU_CONNECTION_REQUEST"); return FALSE; } @@ -170,7 +172,7 @@ BOOL tpdu_read_connection_confirm(wStream* s, BYTE* li) if (code != X224_TPDU_CONNECTION_CONFIRM) { - DEBUG_WARN( "Error: expected X224_TPDU_CONNECTION_CONFIRM: 0x%02X\n", code); + WLog_ERR(TAG, "Error: expected X224_TPDU_CONNECTION_CONFIRM"); return FALSE; } /* diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 12e6f0739..7fc8d6122 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -55,7 +55,7 @@ #include "transport.h" #include "rdp.h" -#define TAG FREERDP_TAG("core") +#define TAG FREERDP_TAG("core.transport") #define BUFFER_SIZE 16384 @@ -276,7 +276,7 @@ BOOL transport_connect_tls(rdpTransport* transport) if (!transport->frontBio) { - DEBUG_WARN("%s: unable to prepend a filtering TLS bio", __FUNCTION__); + WLog_ERR(TAG, "unable to prepend a filtering TLS bio"); return FALSE; } @@ -330,8 +330,8 @@ BOOL transport_connect_nla(rdpTransport* transport) freerdp_set_last_error(instance->context, FREERDP_ERROR_AUTHENTICATION_FAILED); } - DEBUG_WARN("Authentication failure, check credentials.\n" - "If credentials are valid, the NTLMSSP implementation may be to blame.\n"); + WLog_ERR(TAG, "Authentication failure, check credentials." + "If credentials are valid, the NTLMSSP implementation may be to blame."); transport_set_nla_mode(transport, FALSE); credssp_free(credSsp); transport->credssp = NULL; @@ -532,7 +532,7 @@ BOOL transport_accept_nla(rdpTransport* transport) if (credssp_authenticate(transport->credssp) < 0) { - DEBUG_WARN("client authentication failure\n"); + WLog_ERR(TAG, "client authentication failure"); transport_set_nla_mode(transport, FALSE); credssp_free(transport->credssp); transport->credssp = NULL; @@ -612,7 +612,7 @@ int transport_read_layer(rdpTransport* transport, BYTE* data, int bytes) * requested bytes */ if (transport_wait_for_read(transport) < 0) { - DEBUG_WARN("%s: error when selecting for read\n", __FUNCTION__); + WLog_ERR(TAG, "error when selecting for read"); return -1; } @@ -726,7 +726,7 @@ int transport_read_pdu(rdpTransport* transport, wStream* s) } else { - DEBUG_WARN("Error reading TSRequest!\n"); + WLog_ERR(TAG, "Error reading TSRequest!"); return -1; } } @@ -750,7 +750,7 @@ int transport_read_pdu(rdpTransport* transport, wStream* s) /* min and max values according to ITU-T Rec. T.123 (01/2007) section 8 */ if (pduLength < 7 || pduLength > 0xFFFF) { - DEBUG_WARN("%s: tpkt - invalid pduLength: %d\n", __FUNCTION__, pduLength); + WLog_ERR(TAG, "tpkt - invalid pduLength: %d", pduLength); return -1; } } @@ -774,7 +774,7 @@ int transport_read_pdu(rdpTransport* transport, wStream* s) */ if (pduLength < 3 || pduLength > 0x8000) { - DEBUG_WARN("%s: fast path - invalid pduLength: %d\n", __FUNCTION__, pduLength); + WLog_ERR(TAG, "fast path - invalid pduLength: %d", pduLength); return -1; } } @@ -791,7 +791,7 @@ int transport_read_pdu(rdpTransport* transport, wStream* s) /* dump when whole PDU is read */ if (Stream_GetPosition(s) >= pduLength) { - DEBUG_WARN("Local < Remote\n"); + WLog_DBG(TAG, "Local < Remote"); winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), pduLength); } @@ -818,7 +818,7 @@ int transport_write(rdpTransport* transport, wStream* s) if (length > 0) { - DEBUG_WARN("Local > Remote\n"); + WLog_DBG(TAG, "Local > Remote"); winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), length); } @@ -848,7 +848,7 @@ int transport_write(rdpTransport* transport, wStream* s) if (transport_wait_for_write(transport) < 0) { - DEBUG_WARN("%s: error when selecting for write\n", __FUNCTION__); + WLog_ERR(TAG, "error when selecting for write"); return -1; } @@ -864,13 +864,13 @@ int transport_write(rdpTransport* transport, wStream* s) { if (transport_wait_for_write(transport) < 0) { - DEBUG_WARN("%s: error when selecting for write\n", __FUNCTION__); + WLog_ERR(TAG, "error when selecting for write"); return -1; } if (!transport_bio_buffered_drain(out->bufferedBio)) { - DEBUG_WARN("%s: error when draining outputBuffer\n", __FUNCTION__); + WLog_ERR(TAG, "error when draining outputBuffer"); return -1; } } @@ -1158,7 +1158,7 @@ rdpTransport* transport_new(rdpSettings* settings) return NULL; WLog_Init(); - transport->log = WLog_Get("com.freerdp.core.transport"); + transport->log = WLog_Get(TAG); if (!transport->log) goto out_free; diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index 11ff7c0a7..daeef3f29 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -31,9 +31,12 @@ #include "surface.h" #include "message.h" +#include #include #include +#define TAG FREERDP_TAG("core.update") + const char* const UPDATE_TYPE_STRINGS[] = { "Orders", @@ -348,9 +351,9 @@ BOOL update_read_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color, scanlineSize = ((scanlineSize + 1) / 2) * 2; if (scanlineSize * pointer_color->height != pointer_color->lengthXorMask) { - DEBUG_WARN( "%s: invalid lengthXorMask: width=%d height=%d, %d instead of %d\n", __FUNCTION__, - pointer_color->width, pointer_color->height, - pointer_color->lengthXorMask, scanlineSize * pointer_color->height); + WLog_ERR(TAG, "invalid lengthXorMask: width=%d height=%d, %d instead of %d", + pointer_color->width, pointer_color->height, + pointer_color->lengthXorMask, scanlineSize * pointer_color->height); return FALSE; } @@ -379,8 +382,8 @@ BOOL update_read_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color, scanlineSize = ((1 + scanlineSize) / 2) * 2; if (scanlineSize * pointer_color->height != pointer_color->lengthAndMask) { - DEBUG_WARN( "%s: invalid lengthAndMask: %d instead of %d\n", __FUNCTION__, - pointer_color->lengthAndMask, scanlineSize * pointer_color->height); + WLog_ERR(TAG, "invalid lengthAndMask: %d instead of %d", + pointer_color->lengthAndMask, scanlineSize * pointer_color->height); return FALSE; } @@ -407,7 +410,7 @@ BOOL update_read_pointer_new(wStream* s, POINTER_NEW_UPDATE* pointer_new) Stream_Read_UINT16(s, pointer_new->xorBpp); /* xorBpp (2 bytes) */ if ((pointer_new->xorBpp < 1) || (pointer_new->xorBpp > 32)) { - DEBUG_WARN( "%s: invalid xorBpp %d\n", __FUNCTION__, pointer_new->xorBpp); + WLog_ERR(TAG, "invalid xorBpp %d", pointer_new->xorBpp); return FALSE; } return update_read_pointer_color(s, &pointer_new->colorPtrAttr, pointer_new->xorBpp); /* colorPtrAttr */ @@ -481,8 +484,7 @@ BOOL update_recv(rdpUpdate* update, wStream* s) return FALSE; Stream_Read_UINT16(s, updateType); /* updateType (2 bytes) */ - - //DEBUG_MSG("%s Update Data PDU\n", UPDATE_TYPE_STRINGS[updateType]); + //WLog_DBG(TAG, "%s Update Data PDU", UPDATE_TYPE_STRINGS[updateType]); IFCALL(update->BeginPaint, context); @@ -614,7 +616,7 @@ static void update_end_paint(rdpContext* context) if (update->numberOrders > 0) { - DEBUG_WARN( "%s: sending %d orders\n", __FUNCTION__, update->numberOrders); + WLog_ERR(TAG, "sending %d orders", update->numberOrders); fastpath_send_update_pdu(context->rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); } diff --git a/libfreerdp/core/window.c b/libfreerdp/core/window.c index 84c34ccc7..c33411c24 100644 --- a/libfreerdp/core/window.c +++ b/libfreerdp/core/window.c @@ -24,22 +24,27 @@ #include +#include #include #include "window.h" +#define TAG FREERDP_TAG("core.window") + BOOL update_read_icon_info(wStream* s, ICON_INFO* iconInfo) { - BYTE *newBitMask; + BYTE* newBitMask; + if (Stream_GetRemainingLength(s) < 8) return FALSE; Stream_Read_UINT16(s, iconInfo->cacheEntry); /* cacheEntry (2 bytes) */ Stream_Read_UINT8(s, iconInfo->cacheId); /* cacheId (1 byte) */ Stream_Read_UINT8(s, iconInfo->bpp); /* bpp (1 byte) */ + if ((iconInfo->bpp < 1) || (iconInfo->bpp > 32)) { - DEBUG_WARN( "%s: invalid bpp value %d", __FUNCTION__, iconInfo->bpp); + WLog_ERR(TAG, "invalid bpp value %d", iconInfo->bpp); return FALSE; } diff --git a/libfreerdp/core/window.h b/libfreerdp/core/window.h index b32e470ac..44084df9d 100644 --- a/libfreerdp/core/window.h +++ b/libfreerdp/core/window.h @@ -24,13 +24,15 @@ #include "update.h" #include +#include BOOL update_recv_altsec_window_order(rdpUpdate* update, wStream* s); +#define WND_TAG FREERDP_TAG("core.wnd") #ifdef WITH_DEBUG_WND -#define DEBUG_WND(fmt, ...) DEBUG_CLASS(WND, fmt, ## __VA_ARGS__) +#define DEBUG_WND(fmt, ...) WLog_DBG(WND_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_WND(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_WND(fmt, ...) do { } while (0) #endif #endif /* __WINDOW_H */ diff --git a/libfreerdp/crypto/CMakeLists.txt b/libfreerdp/crypto/CMakeLists.txt index b307cb3a6..56dd9e99c 100644 --- a/libfreerdp/crypto/CMakeLists.txt +++ b/libfreerdp/crypto/CMakeLists.txt @@ -18,7 +18,7 @@ set(MODULE_NAME "freerdp-crypto") set(MODULE_PREFIX "FREERDP_CRYPTO") -set(${MODULE_PREFIX}_SRCS +freerdp_module_add( er.c der.c ber.c @@ -28,44 +28,17 @@ set(${MODULE_PREFIX}_SRCS crypto.c tls.c) -add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT" - MONOLITHIC ${MONOLITHIC_BUILD} - SOURCES ${${MODULE_PREFIX}_SRCS} - EXPORT) +freerdp_include_directory_add(${OPENSSL_INCLUDE_DIR}) +freerdp_include_directory_add(${ZLIB_INCLUDE_DIRS}) -include_directories(${OPENSSL_INCLUDE_DIR}) -include_directories(${ZLIB_INCLUDE_DIRS}) - -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) -endif() -set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "lib") - -set(${MODULE_PREFIX}_LIBS - ${OPENSSL_LIBRARIES}) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) +freerdp_library_add(${OPENSSL_LIBRARIES}) if(WIN32) - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ws2_32) + freerdp_library_add(ws2_32) else() - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${ZLIB_LIBRARIES}) + freerdp_library_add(${ZLIB_LIBRARIES}) endif() -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} INTERNAL - MODULE freerdp - MODULES freerdp-utils) - -if(MONOLITHIC_BUILD) - set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) -else() - target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) - install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets) -endif() - -set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") - if(BUILD_TESTING) add_subdirectory(test) endif() diff --git a/libfreerdp/crypto/ber.c b/libfreerdp/crypto/ber.c index a983849bf..9e54232f7 100644 --- a/libfreerdp/crypto/ber.c +++ b/libfreerdp/crypto/ber.c @@ -24,9 +24,11 @@ #include #include -#include +#include #include +#define TAG FREERDP_TAG("crypto") + BOOL ber_read_length(wStream* s, int* length) { BYTE byte; @@ -400,12 +402,12 @@ BOOL ber_read_integer(wStream* s, UINT32* value) } else if (length == 8) { - DEBUG_WARN( "%s: should implement reading an 8 bytes integer\n", __FUNCTION__); + WLog_ERR(TAG, "should implement reading an 8 bytes integer"); return FALSE; } else { - DEBUG_WARN( "%s: should implement reading an integer with length=%d\n", __FUNCTION__, length); + WLog_ERR(TAG, "should implement reading an integer with length=%d", length); return FALSE; } diff --git a/libfreerdp/crypto/certificate.c b/libfreerdp/crypto/certificate.c index fa9533d99..945021d7e 100644 --- a/libfreerdp/crypto/certificate.c +++ b/libfreerdp/crypto/certificate.c @@ -37,9 +37,11 @@ static const char certificate_store_dir[] = "certs"; static const char certificate_server_dir[] = "server"; static const char certificate_known_hosts_file[] = "known_hosts"; -#include +#include #include +#define TAG FREERDP_TAG("crypto") + int certificate_store_init(rdpCertificateStore* certificate_store) { char* server_path; @@ -50,7 +52,7 @@ int certificate_store_init(rdpCertificateStore* certificate_store) if (!PathFileExistsA(settings->ConfigPath)) { CreateDirectoryA(settings->ConfigPath, 0); - DEBUG_WARN( "creating directory %s\n", settings->ConfigPath); + WLog_INFO(TAG, "creating directory %s", settings->ConfigPath); } certificate_store->path = GetCombinedPath(settings->ConfigPath, (char*) certificate_store_dir); @@ -61,7 +63,7 @@ int certificate_store_init(rdpCertificateStore* certificate_store) if (!PathFileExistsA(certificate_store->path)) { CreateDirectoryA(certificate_store->path, 0); - DEBUG_WARN( "creating directory %s\n", certificate_store->path); + WLog_INFO(TAG, "creating directory %s", certificate_store->path); } server_path = GetCombinedPath(settings->ConfigPath, (char*) certificate_server_dir); @@ -72,7 +74,7 @@ int certificate_store_init(rdpCertificateStore* certificate_store) if (!PathFileExistsA(server_path)) { CreateDirectoryA(server_path, 0); - DEBUG_WARN( "creating directory %s\n", server_path); + WLog_INFO(TAG, "creating directory %s", server_path); } free(server_path); @@ -88,7 +90,7 @@ int certificate_store_init(rdpCertificateStore* certificate_store) if (!certificate_store->fp) { - DEBUG_WARN( "certificate_store_open: error opening [%s] for writing\n", certificate_store->file); + WLog_ERR(TAG, "certificate_store_open: error opening [%s] for writing", certificate_store->file); return -1; } diff --git a/libfreerdp/crypto/crypto.c b/libfreerdp/crypto/crypto.c index b75e4eb6a..efbdd5aa3 100644 --- a/libfreerdp/crypto/crypto.c +++ b/libfreerdp/crypto/crypto.c @@ -23,9 +23,11 @@ #include -#include +#include #include +#define TAG FREERDP_TAG("crypto") + CryptoSha1 crypto_sha1_init(void) { CryptoSha1 sha1 = malloc(sizeof(*sha1)); @@ -203,7 +205,7 @@ BOOL crypto_cert_get_public_key(CryptoCert cert, BYTE** PublicKey, DWORD* Public pkey = X509_get_pubkey(cert->px509); if (!pkey) { - DEBUG_WARN( "%s: X509_get_pubkey() failed\n", __FUNCTION__); + WLog_ERR(TAG, "X509_get_pubkey() failed"); status = FALSE; goto exit; } @@ -211,7 +213,7 @@ BOOL crypto_cert_get_public_key(CryptoCert cert, BYTE** PublicKey, DWORD* Public length = i2d_PublicKey(pkey, NULL); if (length < 1) { - DEBUG_WARN( "%s: i2d_PublicKey() failed\n", __FUNCTION__); + WLog_ERR(TAG, "i2d_PublicKey() failed"); status = FALSE; goto exit; } @@ -276,7 +278,7 @@ static int crypto_rsa_common(const BYTE* input, int length, UINT32 key_length, c BN_free(&mod); BN_CTX_free(ctx); -out_free_input_reverse: +out_free_input_reverse: free(input_reverse); return output_length; @@ -570,18 +572,17 @@ void crypto_cert_print_info(X509* xcert) fp = crypto_cert_fingerprint(xcert); if (!fp) { - DEBUG_WARN( "%s: error computing fingerprint\n", __FUNCTION__); + WLog_ERR(TAG, "error computing fingerprint"); goto out_free_issuer; } - DEBUG_WARN( "Certificate details:\n"); - DEBUG_WARN( "\tSubject: %s\n", subject); - DEBUG_WARN( "\tIssuer: %s\n", issuer); - DEBUG_WARN( "\tThumbprint: %s\n", fp); - DEBUG_WARN( "The above X.509 certificate could not be verified, possibly because you do not have " - "the CA certificate in your certificate store, or the certificate has expired. " - "Please look at the documentation on how to create local certificate store for a private CA.\n"); - + WLog_INFO(TAG, "Certificate details:"); + WLog_INFO(TAG, "\tSubject: %s", subject); + WLog_INFO(TAG, "\tIssuer: %s", issuer); + WLog_INFO(TAG, "\tThumbprint: %s", fp); + WLog_INFO(TAG, "The above X.509 certificate could not be verified, possibly because you do not have " + "the CA certificate in your certificate store, or the certificate has expired. " + "Please look at the documentation on how to create local certificate store for a private CA."); free(fp); out_free_issuer: free(issuer); diff --git a/libfreerdp/crypto/test/CMakeLists.txt b/libfreerdp/crypto/test/CMakeLists.txt index 4333b010f..56023e08f 100644 --- a/libfreerdp/crypto/test/CMakeLists.txt +++ b/libfreerdp/crypto/test/CMakeLists.txt @@ -13,12 +13,7 @@ create_test_sourcelist(${MODULE_PREFIX}_SRCS add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-crypto) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} freerdp) set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}") diff --git a/libfreerdp/crypto/tls.c b/libfreerdp/crypto/tls.c index b48a1d024..24878d275 100644 --- a/libfreerdp/crypto/tls.c +++ b/libfreerdp/crypto/tls.c @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include "../core/tcp.h" @@ -39,6 +39,7 @@ #include #endif +#define TAG FREERDP_TAG("crypto") struct _BIO_RDP_TLS { @@ -511,7 +512,7 @@ static CryptoCert tls_get_certificate(rdpTls* tls, BOOL peer) if (!remote_cert) { - DEBUG_WARN( "%s: failed to get the server TLS certificate\n", __FUNCTION__); + WLog_ERR(TAG, "failed to get the server TLS certificate"); return NULL; } @@ -584,7 +585,7 @@ BOOL tls_prepare(rdpTls* tls, BIO *underlying, const SSL_METHOD *method, int opt tls->ctx = SSL_CTX_new(method); if (!tls->ctx) { - DEBUG_WARN( "%s: SSL_CTX_new failed\n", __FUNCTION__); + WLog_ERR(TAG, "SSL_CTX_new failed"); return FALSE; } @@ -595,7 +596,7 @@ BOOL tls_prepare(rdpTls* tls, BIO *underlying, const SSL_METHOD *method, int opt if (tls->settings->PermittedTLSCiphers) { if(!SSL_CTX_set_cipher_list(tls->ctx, tls->settings->PermittedTLSCiphers)) { - DEBUG_WARN( "SSL_CTX_set_cipher_list %s failed\n", tls->settings->PermittedTLSCiphers); + WLog_ERR(TAG, "SSL_CTX_set_cipher_list %s failed", tls->settings->PermittedTLSCiphers); return FALSE; } } @@ -604,7 +605,7 @@ BOOL tls_prepare(rdpTls* tls, BIO *underlying, const SSL_METHOD *method, int opt if (BIO_get_ssl(tls->bio, &tls->ssl) < 0) { - DEBUG_WARN( "%s: unable to retrieve the SSL of the connection\n", __FUNCTION__); + WLog_ERR(TAG, "unable to retrieve the SSL of the connection"); return FALSE; } @@ -642,7 +643,7 @@ int tls_do_handshake(rdpTls* tls, BOOL clientMode) if (fd < 0) { - DEBUG_WARN( "%s: unable to retrieve BIO fd\n", __FUNCTION__); + WLog_ERR(TAG, "unable to retrieve BIO fd"); return -1; } @@ -666,7 +667,7 @@ int tls_do_handshake(rdpTls* tls, BOOL clientMode) #endif if (status < 0) { - DEBUG_WARN( "%s: error during select()\n", __FUNCTION__); + WLog_ERR(TAG, "error during select()"); return -1; } } @@ -675,21 +676,21 @@ int tls_do_handshake(rdpTls* tls, BOOL clientMode) cert = tls_get_certificate(tls, clientMode); if (!cert) { - DEBUG_WARN( "%s: tls_get_certificate failed to return the server certificate.\n", __FUNCTION__); + WLog_ERR(TAG, "tls_get_certificate failed to return the server certificate."); return -1; } tls->Bindings = tls_get_channel_bindings(cert->px509); if (!tls->Bindings) { - DEBUG_WARN( "%s: unable to retrieve bindings\n", __FUNCTION__); + WLog_ERR(TAG, "unable to retrieve bindings"); verify_status = -1; goto out; } if (!crypto_cert_get_public_key(cert, &tls->PublicKey, &tls->PublicKeyLength)) { - DEBUG_WARN( "%s: crypto_cert_get_public_key failed to return the server public key.\n", __FUNCTION__); + WLog_ERR(TAG, "crypto_cert_get_public_key failed to return the server public key."); verify_status = -1; goto out; } @@ -704,7 +705,7 @@ int tls_do_handshake(rdpTls* tls, BOOL clientMode) if (verify_status < 1) { - DEBUG_WARN( "%s: certificate not trusted, aborting.\n", __FUNCTION__); + WLog_ERR(TAG, "certificate not trusted, aborting."); tls_disconnect(tls); verify_status = 0; } @@ -803,14 +804,14 @@ BOOL tls_accept(rdpTls* tls, BIO *underlying, const char* cert_file, const char* if (SSL_use_RSAPrivateKey_file(tls->ssl, privatekey_file, SSL_FILETYPE_PEM) <= 0) { - DEBUG_WARN( "%s: SSL_CTX_use_RSAPrivateKey_file failed\n", __FUNCTION__); - DEBUG_WARN( "PrivateKeyFile: %s\n", privatekey_file); + WLog_ERR(TAG, "SSL_CTX_use_RSAPrivateKey_file failed"); + WLog_ERR(TAG, "PrivateKeyFile: %s", privatekey_file); return FALSE; } if (SSL_use_certificate_file(tls->ssl, cert_file, SSL_FILETYPE_PEM) <= 0) { - DEBUG_WARN( "%s: SSL_use_certificate_file failed\n", __FUNCTION__); + WLog_ERR(TAG, "SSL_use_certificate_file failed"); return FALSE; } @@ -892,7 +893,7 @@ int tls_write_all(rdpTls* tls, const BYTE* data, int length) if (!bufferedBio) { - DEBUG_WARN( "%s: error unable to retrieve the bufferedBio in the BIO chain\n", __FUNCTION__); + WLog_ERR(TAG, "error unable to retrieve the bufferedBio in the BIO chain"); return -1; } @@ -922,7 +923,7 @@ int tls_write_all(rdpTls* tls, const BYTE* data, int length) } else { - DEBUG_WARN( "%s: weird we're blocked but the underlying is not read or write blocked !\n", __FUNCTION__); + WLog_ERR(TAG, "weird we're blocked but the underlying is not read or write blocked !"); USleep(10); continue; } @@ -950,7 +951,7 @@ int tls_write_all(rdpTls* tls, const BYTE* data, int length) } else { - DEBUG_WARN( "%s: weird we're blocked but the underlying is not read or write blocked !\n", __FUNCTION__); + WLog_ERR(TAG, "weird we're blocked but the underlying is not read or write blocked !"); USleep(10); continue; } @@ -1081,7 +1082,7 @@ int tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname, int por if (!bio) { - DEBUG_WARN( "%s: BIO_new() failure\n", __FUNCTION__); + WLog_ERR(TAG, "BIO_new() failure"); return -1; } @@ -1089,7 +1090,7 @@ int tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname, int por if (status < 0) { - DEBUG_WARN( "%s: PEM_write_bio_X509 failure: %d\n", __FUNCTION__, status); + WLog_ERR(TAG, "PEM_write_bio_X509 failure: %d", status); return -1; } @@ -1101,7 +1102,7 @@ int tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname, int por if (status < 0) { - DEBUG_WARN( "%s: failed to read certificate\n", __FUNCTION__); + WLog_ERR(TAG, "failed to read certificate"); return -1; } @@ -1122,7 +1123,7 @@ int tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname, int por if (status < 0) { - DEBUG_WARN( "%s: failed to read certificate\n", __FUNCTION__); + WLog_ERR(TAG, "failed to read certificate"); return -1; } @@ -1136,7 +1137,7 @@ int tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname, int por status = instance->VerifyX509Certificate(instance, pemCert, length, hostname, port, tls->isGatewayTransport); } - DEBUG_WARN( "%s: (length = %d) status: %d\n%s\n", __FUNCTION__, length, status, pemCert); + WLog_ERR(TAG, "(length = %d) status: %d%s", length, status, pemCert); free(pemCert); BIO_free(bio); @@ -1296,18 +1297,18 @@ int tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname, int por void tls_print_certificate_error(char* hostname, char* fingerprint, char *hosts_file) { - DEBUG_WARN( "The host key for %s has changed\n", hostname); - DEBUG_WARN( "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); - DEBUG_WARN( "@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @\n"); - DEBUG_WARN( "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); - DEBUG_WARN( "IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!\n"); - DEBUG_WARN( "Someone could be eavesdropping on you right now (man-in-the-middle attack)!\n"); - DEBUG_WARN( "It is also possible that a host key has just been changed.\n"); - DEBUG_WARN( "The fingerprint for the host key sent by the remote host is\n%s\n", fingerprint); - DEBUG_WARN( "Please contact your system administrator.\n"); - DEBUG_WARN( "Add correct host key in %s to get rid of this message.\n", hosts_file); - DEBUG_WARN( "Host key for %s has changed and you have requested strict checking.\n", hostname); - DEBUG_WARN( "Host key verification failed.\n"); + WLog_ERR(TAG, "The host key for %s has changed", hostname); + WLog_ERR(TAG, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); + WLog_ERR(TAG, "@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @"); + WLog_ERR(TAG, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); + WLog_ERR(TAG, "IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!"); + WLog_ERR(TAG, "Someone could be eavesdropping on you right now (man-in-the-middle attack)!"); + WLog_ERR(TAG, "It is also possible that a host key has just been changed."); + WLog_ERR(TAG, "The fingerprint for the host key sent by the remote host is%s", fingerprint); + WLog_ERR(TAG, "Please contact your system administrator."); + WLog_ERR(TAG, "Add correct host key in %s to get rid of this message.", hosts_file); + WLog_ERR(TAG, "Host key for %s has changed and you have requested strict checking.", hostname); + WLog_ERR(TAG, "Host key verification failed."); } void tls_print_certificate_name_mismatch_error(char* hostname, char* common_name, char** alt_names, int alt_names_count) @@ -1315,25 +1316,24 @@ void tls_print_certificate_name_mismatch_error(char* hostname, char* common_name int index; assert(NULL != hostname); - - DEBUG_WARN( "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); - DEBUG_WARN( "@ WARNING: CERTIFICATE NAME MISMATCH! @\n"); - DEBUG_WARN( "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); - DEBUG_WARN( "The hostname used for this connection (%s) \n", hostname); - DEBUG_WARN( "does not match %s given in the certificate:\n", alt_names_count < 1 ? "the name" : "any of the names"); - DEBUG_WARN( "Common Name (CN):\n"); - DEBUG_WARN( "\t%s\n", common_name ? common_name : "no CN found in certificate"); + WLog_ERR(TAG, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); + WLog_ERR(TAG, "@ WARNING: CERTIFICATE NAME MISMATCH! @"); + WLog_ERR(TAG, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); + WLog_ERR(TAG, "The hostname used for this connection (%s) ", hostname); + WLog_ERR(TAG, "does not match %s given in the certificate:", alt_names_count < 1 ? "the name" : "any of the names"); + WLog_ERR(TAG, "Common Name (CN):"); + WLog_ERR(TAG, "\t%s", common_name ? common_name : "no CN found in certificate"); if (alt_names_count > 0) { assert(NULL != alt_names); - DEBUG_WARN( "Alternative names:\n"); + WLog_ERR(TAG, "Alternative names:"); for (index = 0; index < alt_names_count; index++) { assert(alt_names[index]); - DEBUG_WARN( "\t %s\n", alt_names[index]); + WLog_ERR(TAG, "\t %s", alt_names[index]); } } - DEBUG_WARN( "A valid certificate for the wrong name should NOT be trusted!\n"); + WLog_ERR(TAG, "A valid certificate for the wrong name should NOT be trusted!"); } rdpTls* tls_new(rdpSettings* settings) diff --git a/libfreerdp/dummy.c b/libfreerdp/dummy.c deleted file mode 100644 index fb941c948..000000000 --- a/libfreerdp/dummy.c +++ /dev/null @@ -1,5 +0,0 @@ - -int freerdp_dummy() -{ - return 0; -} diff --git a/libfreerdp/gdi/16bpp.c b/libfreerdp/gdi/16bpp.c index fb9dfd26c..ff90f485f 100644 --- a/libfreerdp/gdi/16bpp.c +++ b/libfreerdp/gdi/16bpp.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -38,6 +39,8 @@ #include +#define TAG FREERDP_TAG("gdi") + UINT16 gdi_get_color_16bpp(HGDI_DC hdc, GDI_COLOR color) { BYTE r, g, b; @@ -412,7 +415,8 @@ static int BitBlt_DSPDxax_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi if (hdcSrc->bytesPerPixel != 1) { - DEBUG_WARN( "BitBlt_DSPDxax expects 1 bpp, unimplemented for %d\n", hdcSrc->bytesPerPixel); + WLog_ERR(TAG, "BitBlt_DSPDxax expects 1 bpp, unimplemented for %d", + hdcSrc->bytesPerPixel); return 0; } @@ -893,8 +897,8 @@ int BitBlt_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeigh return BitBlt_PATPAINT_16bpp(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc); break; } - - DEBUG_WARN( "BitBlt: unknown rop: 0x%08X\n", rop); + + WLog_ERR(TAG, "BitBlt: unknown rop: 0x%08X", rop); return 1; } @@ -939,7 +943,7 @@ int PatBlt_16bpp(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, i break; } - DEBUG_WARN( "PatBlt: unknown rop: 0x%08X\n", rop); + WLog_ERR(TAG, "PatBlt: unknown rop: 0x%08X", rop); return 1; } diff --git a/libfreerdp/gdi/32bpp.c b/libfreerdp/gdi/32bpp.c index ed20b675f..5458917ae 100644 --- a/libfreerdp/gdi/32bpp.c +++ b/libfreerdp/gdi/32bpp.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -38,6 +39,8 @@ #include +#define TAG FREERDP_TAG("gdi") + UINT32 gdi_get_color_32bpp(HGDI_DC hdc, GDI_COLOR color) { UINT32 color32; @@ -859,7 +862,7 @@ static int BitBlt_PATINVERT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n } } } - + return 0; } @@ -996,8 +999,8 @@ int BitBlt_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeigh return BitBlt_PATPAINT_32bpp(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc); break; } - - DEBUG_WARN( "BitBlt: unknown rop: 0x%08X\n", rop); + + WLog_ERR(TAG, "BitBlt: unknown rop: 0x%08X", rop); return 1; } @@ -1041,8 +1044,8 @@ int PatBlt_32bpp(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, i default: break; } - - DEBUG_WARN( "PatBlt: unknown rop: 0x%08X\n", rop); + + WLog_ERR(TAG, "PatBlt: unknown rop: 0x%08X", rop); return 1; } diff --git a/libfreerdp/gdi/8bpp.c b/libfreerdp/gdi/8bpp.c index 85a00e7a9..96c1d5883 100644 --- a/libfreerdp/gdi/8bpp.c +++ b/libfreerdp/gdi/8bpp.c @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -38,6 +39,8 @@ #include +#define TAG FREERDP_TAG("gdi") + BYTE gdi_get_color_8bpp(HGDI_DC hdc, GDI_COLOR color) { /* TODO: Implement 8bpp gdi_get_color_8bpp() */ @@ -806,8 +809,8 @@ int BitBlt_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight return BitBlt_PATPAINT_8bpp(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc); break; } - - DEBUG_WARN( "BitBlt: unknown rop: 0x%08X\n", rop); + + WLog_ERR(TAG, "BitBlt: unknown rop: 0x%08X", rop); return 1; } @@ -851,8 +854,8 @@ int PatBlt_8bpp(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, in default: break; } - - DEBUG_WARN( "PatBlt: unknown rop: 0x%08X\n", rop); + + WLog_ERR(TAG, "PatBlt: unknown rop: 0x%08X", rop); return 1; } diff --git a/libfreerdp/gdi/CMakeLists.txt b/libfreerdp/gdi/CMakeLists.txt index 0a2624385..c64979a2c 100644 --- a/libfreerdp/gdi/CMakeLists.txt +++ b/libfreerdp/gdi/CMakeLists.txt @@ -40,29 +40,7 @@ set(${MODULE_PREFIX}_SRCS gdi.c gdi.h) -add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT" - MONOLITHIC ${MONOLITHIC_BUILD} - SOURCES ${${MODULE_PREFIX}_SRCS} - EXPORT) - -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) -endif() -set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "lib") - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} INTERNAL - MODULE freerdp - MODULES freerdp-core freerdp-cache freerdp-codec) - -if(MONOLITHIC_BUILD) - set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) -else() - target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) - install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets) -endif() - -set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") +freerdp_module_add(${${MODULE_PREFIX}_SRCS}) if(BUILD_TESTING) add_subdirectory(test) diff --git a/libfreerdp/gdi/gdi.c b/libfreerdp/gdi/gdi.c index 881c7886a..dd2402dcd 100644 --- a/libfreerdp/gdi/gdi.c +++ b/libfreerdp/gdi/gdi.c @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -51,6 +52,8 @@ #include "gdi.h" +#define TAG FREERDP_TAG("gdi") + /* Ternary Raster Operation Table */ static const UINT32 rop3_code_table[] = { @@ -372,7 +375,8 @@ INLINE BYTE* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, int x, int y) } else { - DEBUG_WARN( "gdi_get_bitmap_pointer: requesting invalid pointer: (%d,%d) in %dx%d\n", x, y, hBmp->width, hBmp->height); + WLog_ERR(TAG, "gdi_get_bitmap_pointer: requesting invalid pointer: (%d,%d) in %dx%d", + x, y, hBmp->width, hBmp->height); return 0; } } @@ -493,6 +497,7 @@ void gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate) int nYSrc; int nWidth; int nHeight; + int nSrcStep; int nDstStep; UINT32 index; BYTE* pSrcData; @@ -542,7 +547,7 @@ void gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate) freerdp_client_codecs_prepare(codecs, FREERDP_CODEC_INTERLEAVED); status = interleaved_decompress(codecs->interleaved, pSrcData, SrcSize, bitsPerPixel, - &pDstData, gdi->format, -1, 0, 0, nWidth, nHeight); + &pDstData, gdi->format, -1, 0, 0, nWidth, nHeight, gdi->palette); } else { @@ -554,7 +559,7 @@ void gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate) if (status < 0) { - DEBUG_WARN("gdi_bitmap_update: bitmap decompression failure\n"); + WLog_ERR(TAG, "bitmap decompression failure"); return; } @@ -566,11 +571,13 @@ void gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate) SrcFormat = gdi_get_pixel_format(bitsPerPixel, TRUE); status = freerdp_image_copy(pDstData, gdi->format, -1, 0, 0, - nWidth, nHeight, pSrcData, SrcFormat, -1, 0, 0); + nWidth, nHeight, pSrcData, SrcFormat, -1, 0, 0, gdi->palette); pSrcData = gdi->bitmap_buffer; } + nSrcStep = nWidth * 4; + pDstData = gdi->primary_buffer; nDstStep = gdi->width * gdi->bytesPerPixel; @@ -578,7 +585,7 @@ void gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate) nHeight = bitmap->destBottom - bitmap->destTop + 1; /* clip height */ status = freerdp_image_copy(pDstData, gdi->format, nDstStep, nXDst, nYDst, - nWidth, nHeight, pSrcData, gdi->format, -1, nXSrc, nYSrc); + nWidth, nHeight, pSrcData, gdi->format, nSrcStep, nXSrc, nYSrc, gdi->palette); gdi_InvalidateRegion(gdi->primary->hdc, nXDst, nYDst, nWidth, nHeight); } @@ -586,8 +593,20 @@ void gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate) void gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette) { + int index; + PALETTE_ENTRY* pe; + UINT32* palette32; rdpGdi* gdi = context->gdi; + CopyMemory(gdi->clrconv->palette, palette, sizeof(rdpPalette)); + + palette32 = (UINT32*) gdi->palette; + + for (index = 0; index < palette->number; index++) + { + pe = &(palette->entries[index]); + palette32[index] = RGB32(pe->red, pe->green, pe->blue); + } } void gdi_set_bounds(rdpContext* context, rdpBounds* bounds) @@ -625,8 +644,8 @@ void gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) brush = &patblt->brush; - foreColor = freerdp_convert_gdi_order_color(patblt->foreColor, gdi->srcBpp, gdi->format); - backColor = freerdp_convert_gdi_order_color(patblt->backColor, gdi->srcBpp, gdi->format); + foreColor = freerdp_convert_gdi_order_color(patblt->foreColor, gdi->srcBpp, gdi->format, gdi->palette); + backColor = freerdp_convert_gdi_order_color(patblt->backColor, gdi->srcBpp, gdi->format, gdi->palette); originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor); @@ -687,7 +706,7 @@ void gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) } else { - DEBUG_WARN( "unimplemented brush style:%d\n", brush->style); + WLog_ERR(TAG, "unimplemented brush style:%d", brush->style); } gdi_SetTextColor(gdi->drawing->hdc, originalColor); @@ -712,7 +731,7 @@ void gdi_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect) gdi_CRgnToRect(opaque_rect->nLeftRect, opaque_rect->nTopRect, opaque_rect->nWidth, opaque_rect->nHeight, &rect); - brush_color = freerdp_convert_gdi_order_color(opaque_rect->color, gdi->srcBpp, gdi->format); + brush_color = freerdp_convert_gdi_order_color(opaque_rect->color, gdi->srcBpp, gdi->format, gdi->palette); hBrush = gdi_CreateSolidBrush(brush_color); gdi_FillRect(gdi->drawing->hdc, &rect, hBrush); @@ -736,7 +755,7 @@ void gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* multi_o gdi_CRgnToRect(rectangle->left, rectangle->top, rectangle->width, rectangle->height, &rect); - brush_color = freerdp_convert_gdi_order_color(multi_opaque_rect->color, gdi->srcBpp, gdi->format); + brush_color = freerdp_convert_gdi_order_color(multi_opaque_rect->color, gdi->srcBpp, gdi->format, gdi->palette); hBrush = gdi_CreateSolidBrush(brush_color); gdi_FillRect(gdi->drawing->hdc, &rect, hBrush); @@ -751,7 +770,7 @@ void gdi_line_to(rdpContext* context, LINE_TO_ORDER* lineTo) HGDI_PEN hPen; rdpGdi* gdi = context->gdi; - color = freerdp_convert_gdi_order_color(lineTo->penColor, gdi->srcBpp, gdi->format); + color = freerdp_convert_gdi_order_color(lineTo->penColor, gdi->srcBpp, gdi->format, gdi->palette); hPen = gdi_CreatePen(lineTo->penStyle, lineTo->penWidth, (GDI_COLOR) color); gdi_SelectObject(gdi->drawing->hdc, (HGDIOBJECT) hPen); gdi_SetROP2(gdi->drawing->hdc, lineTo->bRop2); @@ -772,7 +791,7 @@ void gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline) DELTA_POINT* points; rdpGdi* gdi = context->gdi; - color = freerdp_convert_gdi_order_color(polyline->penColor, gdi->srcBpp, gdi->format); + color = freerdp_convert_gdi_order_color(polyline->penColor, gdi->srcBpp, gdi->format, gdi->palette); hPen = gdi_CreatePen(GDI_PS_SOLID, 1, (GDI_COLOR) color); gdi_SelectObject(gdi->drawing->hdc, (HGDIOBJECT) hPen); gdi_SetROP2(gdi->drawing->hdc, polyline->bRop2); @@ -819,8 +838,8 @@ void gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt) brush = &mem3blt->brush; bitmap = (gdiBitmap*) mem3blt->bitmap; - foreColor = freerdp_convert_gdi_order_color(mem3blt->foreColor, gdi->srcBpp, gdi->format); - backColor = freerdp_convert_gdi_order_color(mem3blt->backColor, gdi->srcBpp, gdi->format); + foreColor = freerdp_convert_gdi_order_color(mem3blt->foreColor, gdi->srcBpp, gdi->format, gdi->palette); + backColor = freerdp_convert_gdi_order_color(mem3blt->backColor, gdi->srcBpp, gdi->format, gdi->palette); originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor); @@ -864,7 +883,7 @@ void gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt) } else { - DEBUG_WARN( "Mem3Blt unimplemented brush style:%d\n", brush->style); + WLog_ERR(TAG, "Mem3Blt unimplemented brush style:%d", brush->style); } gdi_SetTextColor(gdi->drawing->hdc, originalColor); @@ -872,27 +891,27 @@ void gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt) void gdi_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc) { - DEBUG_WARN( "PolygonSC\n"); + WLog_ERR(TAG, "PolygonSC"); } void gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb) { - DEBUG_WARN( "PolygonCB\n"); + WLog_ERR(TAG, "PolygonCB"); } void gdi_ellipse_sc(rdpContext* context, ELLIPSE_SC_ORDER* ellipse_sc) { - DEBUG_WARN( "EllipseSC\n"); + WLog_ERR(TAG, "EllipseSC"); } void gdi_ellipse_cb(rdpContext* context, ELLIPSE_CB_ORDER* ellipse_cb) { - DEBUG_WARN( "EllipseCB\n"); + WLog_ERR(TAG, "EllipseCB"); } void gdi_frame_marker(rdpContext* context, FRAME_MARKER_ORDER* frameMarker) { - + WLog_ERR(TAG, ""); } void gdi_surface_frame_marker(rdpContext* context, SURFACE_FRAME_MARKER* surface_frame_marker) @@ -946,14 +965,14 @@ void gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* cmd) pSrcData = message->tiles[i]->data; pDstData = gdi->tile->bitmap->data; - if (!gdi->abgr && (gdi->dstBpp == 32)) + if (!gdi->invert && (gdi->dstBpp == 32)) { gdi->tile->bitmap->data = pSrcData; } else { freerdp_image_copy(pDstData, gdi->format, -1, 0, 0, - 64, 64, pSrcData, PIXEL_FORMAT_XRGB32, -1, 0, 0); + 64, 64, pSrcData, PIXEL_FORMAT_XRGB32, -1, 0, 0, gdi->palette); } for (j = 0; j < message->numRects; j++) @@ -991,7 +1010,7 @@ void gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* cmd) pSrcData = gdi->codecs->nsc->BitmapData; freerdp_image_copy(pDstData, gdi->format, -1, 0, 0, - cmd->width, cmd->height, pSrcData, PIXEL_FORMAT_XRGB32_VF, -1, 0, 0); + cmd->width, cmd->height, pSrcData, PIXEL_FORMAT_XRGB32_VF, -1, 0, 0, gdi->palette); gdi->image->bitmap->width = cmd->width; gdi->image->bitmap->height = cmd->height; @@ -1016,7 +1035,7 @@ void gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* cmd) pSrcData = cmd->bitmapData; freerdp_image_copy(pDstData, gdi->format, -1, 0, 0, - cmd->width, cmd->height, pSrcData, PIXEL_FORMAT_XRGB32_VF, -1, 0, 0); + cmd->width, cmd->height, pSrcData, PIXEL_FORMAT_XRGB32_VF, -1, 0, 0, gdi->palette); gdi->image->bitmap->width = cmd->width; gdi->image->bitmap->height = cmd->height; @@ -1028,7 +1047,7 @@ void gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* cmd) } else { - DEBUG_WARN("Unsupported codecID %d\n", cmd->codecID); + WLog_ERR(TAG, "Unsupported codecID %d", cmd->codecID); } } @@ -1131,6 +1150,7 @@ void gdi_resize(rdpGdi* gdi, int width, int height) int gdi_init(freerdp* instance, UINT32 flags, BYTE* buffer) { + BOOL rgb555; rdpGdi* gdi; rdpCache* cache; @@ -1152,11 +1172,12 @@ int gdi_init(freerdp* instance, UINT32 flags, BYTE* buffer) /* default internal buffer format */ gdi->dstBpp = 32; gdi->bytesPerPixel = 4; - gdi->format = PIXEL_FORMAT_XRGB32; - if (flags & CLRBUF_ABGR) - gdi->abgr = TRUE; + if (flags & CLRCONV_INVERT) + gdi->invert = TRUE; + + rgb555 = (flags & CLRCONV_RGB555) ? TRUE : FALSE; if (gdi->srcBpp > 16) { @@ -1165,14 +1186,9 @@ int gdi_init(freerdp* instance, UINT32 flags, BYTE* buffer) gdi->dstBpp = 32; gdi->bytesPerPixel = 4; } - else if (flags & CLRBUF_24BPP) - { - gdi->dstBpp = 24; - gdi->bytesPerPixel = 3; - } else if (flags & CLRBUF_16BPP) { - gdi->dstBpp = 16; + gdi->dstBpp = rgb555 ? 15 : 16; gdi->bytesPerPixel = 2; } } @@ -1180,7 +1196,7 @@ int gdi_init(freerdp* instance, UINT32 flags, BYTE* buffer) { if (flags & CLRBUF_16BPP) { - gdi->dstBpp = 16; + gdi->dstBpp = rgb555 ? 15 : 16; gdi->bytesPerPixel = 2; } else if (flags & CLRBUF_32BPP) @@ -1190,12 +1206,10 @@ int gdi_init(freerdp* instance, UINT32 flags, BYTE* buffer) } } - if (!gdi->abgr) + if (!gdi->invert) { if (gdi->bytesPerPixel == 4) gdi->format = PIXEL_FORMAT_XRGB32; - else if (gdi->bytesPerPixel == 3) - gdi->format = PIXEL_FORMAT_RGB24; else if ((gdi->bytesPerPixel == 2) && (gdi->dstBpp == 16)) gdi->format = PIXEL_FORMAT_RGB565; else if ((gdi->bytesPerPixel == 2) && (gdi->dstBpp == 15)) @@ -1205,8 +1219,6 @@ int gdi_init(freerdp* instance, UINT32 flags, BYTE* buffer) { if (gdi->bytesPerPixel == 4) gdi->format = PIXEL_FORMAT_XBGR32; - else if (gdi->bytesPerPixel == 3) - gdi->format = PIXEL_FORMAT_BGR24; else if ((gdi->bytesPerPixel == 2) && (gdi->dstBpp == 16)) gdi->format = PIXEL_FORMAT_BGR565; else if ((gdi->bytesPerPixel == 2) && (gdi->dstBpp == 15)) @@ -1222,9 +1234,9 @@ int gdi_init(freerdp* instance, UINT32 flags, BYTE* buffer) if (!gdi->clrconv) return -1; - gdi->clrconv->alpha = (flags & CLRCONV_ALPHA) ? 1 : 0; - gdi->clrconv->invert = (flags & CLRCONV_INVERT) ? 1 : 0; - gdi->clrconv->rgb555 = (flags & CLRCONV_RGB555) ? 1 : 0; + gdi->clrconv->alpha = (flags & CLRCONV_ALPHA) ? TRUE : FALSE; + gdi->clrconv->invert = (flags & CLRCONV_INVERT) ? TRUE : FALSE; + gdi->clrconv->rgb555 = (flags & CLRCONV_RGB555) ? TRUE : FALSE; gdi->clrconv->palette = (rdpPalette*) malloc(sizeof(rdpPalette)); if (!gdi->clrconv->palette) diff --git a/libfreerdp/gdi/gfx.c b/libfreerdp/gdi/gfx.c index a60706b6a..fab5caf22 100644 --- a/libfreerdp/gdi/gfx.c +++ b/libfreerdp/gdi/gfx.c @@ -21,9 +21,12 @@ #include "config.h" #endif +#include #include #include +#define TAG FREERDP_TAG("gdi") + int gdi_ResetGraphics(RdpgfxClientContext* context, RDPGFX_RESET_GRAPHICS_PDU* resetGraphics) { rdpGdi* gdi = (rdpGdi*) context->custom; @@ -83,7 +86,7 @@ int gdi_OutputUpdate(rdpGdi* gdi) update->BeginPaint(gdi->context); freerdp_image_copy(pDstData, gdi->format, nDstStep, nXDst, nYDst, nWidth, nHeight, - surface->data, surface->format, surface->scanline, nXSrc, nYSrc); + surface->data, surface->format, surface->scanline, nXSrc, nYSrc, NULL); gdi_InvalidateRegion(gdi->primary->hdc, nXDst, nYDst, nWidth, nHeight); @@ -142,7 +145,7 @@ int gdi_SurfaceCommand_Uncompressed(rdpGdi* gdi, RdpgfxClientContext* context, R return -1; freerdp_image_copy(surface->data, surface->format, surface->scanline, cmd->left, cmd->top, - cmd->width, cmd->height, cmd->data, PIXEL_FORMAT_XRGB32, cmd->width * 4, 0, 0); + cmd->width, cmd->height, cmd->data, PIXEL_FORMAT_XRGB32, cmd->width * 4, 0, 0, NULL); invalidRect.left = cmd->left; invalidRect.top = cmd->top; @@ -222,7 +225,7 @@ int gdi_SurfaceCommand_RemoteFX(rdpGdi* gdi, RdpgfxClientContext* context, RDPGF freerdp_image_copy(surface->data, surface->format, surface->scanline, nXDst, nYDst, nWidth, nHeight, - tile->data, PIXEL_FORMAT_XRGB32, 64 * 4, 0, 0); + tile->data, PIXEL_FORMAT_XRGB32, 64 * 4, 0, 0, NULL); region16_union_rect(&(gdi->invalidRegion), &(gdi->invalidRegion), &updateRects[j]); } @@ -259,7 +262,7 @@ int gdi_SurfaceCommand_ClearCodec(rdpGdi* gdi, RdpgfxClientContext* context, RDP if (status < 0) { - printf("clear_decompress failure: %d\n", status); + WLog_ERR(TAG, "clear_decompress failure: %d", status); return -1; } @@ -342,7 +345,7 @@ int gdi_SurfaceCommand_H264(rdpGdi* gdi, RdpgfxClientContext* context, RDPGFX_SU if (status < 0) { - printf("h264_decompress failure: %d\n",status); + WLog_ERR(TAG, "h264_decompress failure: %d",status); return -1; } @@ -370,7 +373,7 @@ int gdi_SurfaceCommand_Alpha(rdpGdi* gdi, RdpgfxClientContext* context, RDPGFX_S if (!surface) return -1; - printf("gdi_SurfaceCommand_Alpha: status: %d\n", status); + WLog_DBG(TAG, "gdi_SurfaceCommand_Alpha: status: %d", status); /* fill with green for now to distinguish from the rest */ @@ -425,7 +428,7 @@ int gdi_SurfaceCommand_Progressive(rdpGdi* gdi, RdpgfxClientContext* context, RD if (status < 0) { - printf("progressive_decompress failure: %d\n", status); + WLog_ERR(TAG, "progressive_decompress failure: %d", status); return -1; } @@ -470,7 +473,7 @@ int gdi_SurfaceCommand_Progressive(rdpGdi* gdi, RdpgfxClientContext* context, RD freerdp_image_copy(surface->data, surface->format, surface->scanline, nXDst, nYDst, nWidth, nHeight, - tile->data, PIXEL_FORMAT_XRGB32, 64 * 4, nXSrc, nYSrc); + tile->data, PIXEL_FORMAT_XRGB32, 64 * 4, nXSrc, nYSrc, NULL); region16_union_rect(&(gdi->invalidRegion), &(gdi->invalidRegion), &updateRects[j]); } @@ -546,7 +549,7 @@ int gdi_CreateSurface(RdpgfxClientContext* context, RDPGFX_CREATE_SURFACE_PDU* c surface->height = (UINT32) createSurface->height; surface->alpha = (createSurface->pixelFormat == PIXEL_FORMAT_ARGB_8888) ? TRUE : FALSE; - surface->format = (!gdi->abgr) ? PIXEL_FORMAT_XRGB32 : PIXEL_FORMAT_XBGR32; + surface->format = (!gdi->invert) ? PIXEL_FORMAT_XRGB32 : PIXEL_FORMAT_XBGR32; surface->scanline = (surface->width + (surface->width % 4)) * 4; surface->data = (BYTE*) calloc(1, surface->scanline * surface->height); @@ -601,7 +604,7 @@ int gdi_SolidFill(RdpgfxClientContext* context, RDPGFX_SOLID_FILL_PDU* solidFill r = solidFill->fillPixel.R; a = solidFill->fillPixel.XA; - if (!gdi->abgr) + if (!gdi->invert) color = ARGB32(a, r, g, b); else color = ABGR32(a, r, g, b); @@ -673,7 +676,7 @@ int gdi_SurfaceToSurface(RdpgfxClientContext* context, RDPGFX_SURFACE_TO_SURFACE { freerdp_image_copy(surfaceDst->data, surfaceDst->format, surfaceDst->scanline, destPt->x, destPt->y, nWidth, nHeight, surfaceSrc->data, surfaceSrc->format, - surfaceSrc->scanline, rectSrc->left, rectSrc->top); + surfaceSrc->scanline, rectSrc->left, rectSrc->top, NULL); } invalidRect.left = destPt->x; @@ -713,7 +716,7 @@ int gdi_SurfaceToCache(RdpgfxClientContext* context, RDPGFX_SURFACE_TO_CACHE_PDU cacheEntry->height = (UINT32) (rect->bottom - rect->top); cacheEntry->alpha = surface->alpha; - cacheEntry->format = (!gdi->abgr) ? PIXEL_FORMAT_XRGB32 : PIXEL_FORMAT_XBGR32; + cacheEntry->format = (!gdi->invert) ? PIXEL_FORMAT_XRGB32 : PIXEL_FORMAT_XBGR32; cacheEntry->scanline = (cacheEntry->width + (cacheEntry->width % 4)) * 4; cacheEntry->data = (BYTE*) calloc(1, cacheEntry->scanline * cacheEntry->height); @@ -723,7 +726,7 @@ int gdi_SurfaceToCache(RdpgfxClientContext* context, RDPGFX_SURFACE_TO_CACHE_PDU freerdp_image_copy(cacheEntry->data, cacheEntry->format, cacheEntry->scanline, 0, 0, cacheEntry->width, cacheEntry->height, surface->data, - surface->format, surface->scanline, rect->left, rect->top); + surface->format, surface->scanline, rect->left, rect->top, NULL); context->SetCacheSlotData(context, surfaceToCache->cacheSlot, (void*) cacheEntry); @@ -751,7 +754,7 @@ int gdi_CacheToSurface(RdpgfxClientContext* context, RDPGFX_CACHE_TO_SURFACE_PDU freerdp_image_copy(surface->data, surface->format, surface->scanline, destPt->x, destPt->y, cacheEntry->width, cacheEntry->height, - cacheEntry->data, cacheEntry->format, cacheEntry->scanline, 0, 0); + cacheEntry->data, cacheEntry->format, cacheEntry->scanline, 0, 0, NULL); invalidRect.left = destPt->x; invalidRect.top = destPt->y; diff --git a/libfreerdp/gdi/graphics.c b/libfreerdp/gdi/graphics.c index 170b80bf8..6c7bd881f 100644 --- a/libfreerdp/gdi/graphics.c +++ b/libfreerdp/gdi/graphics.c @@ -23,6 +23,7 @@ #include +#include #include #include #include @@ -40,6 +41,7 @@ #include "graphics.h" +#define TAG FREERDP_TAG("gdi") /* Bitmap Class */ HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, int nWidth, int nHeight, int bpp, BYTE* data) @@ -96,7 +98,7 @@ HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, int nWidth, int nHeight, int bpp, BYT nSrcStep = nWidth * bytesPerPixel; freerdp_image_copy(pDstData, gdi->format, nDstStep, 0, 0, - nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, 0, 0); + nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, 0, 0, gdi->palette); bitmap = gdi_CreateBitmap(nWidth, nHeight, gdi->dstBpp, pDstData); @@ -173,7 +175,7 @@ void gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, freerdp_client_codecs_prepare(gdi->codecs, FREERDP_CODEC_INTERLEAVED); status = interleaved_decompress(gdi->codecs->interleaved, pSrcData, SrcSize, bpp, - &pDstData, gdi->format, -1, 0, 0, width, height); + &pDstData, gdi->format, -1, 0, 0, width, height, gdi->palette); } else { @@ -185,7 +187,7 @@ void gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, if (status < 0) { - DEBUG_WARN("gdi_Bitmap_Decompress: Bitmap Decompression Failed\n"); + WLog_ERR(TAG, "Bitmap Decompression Failed"); return; } } @@ -194,7 +196,7 @@ void gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, SrcFormat = gdi_get_pixel_format(bpp, TRUE); status = freerdp_image_copy(pDstData, gdi->format, -1, 0, 0, - width, height, pSrcData, SrcFormat, -1, 0, 0); + width, height, pSrcData, SrcFormat, -1, 0, 0, gdi->palette); } bitmap->compressed = FALSE; @@ -265,8 +267,8 @@ void gdi_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int heigh HGDI_BRUSH brush; rdpGdi* gdi = context->gdi; - bgcolor = freerdp_convert_gdi_order_color(bgcolor, gdi->srcBpp, gdi->format); - fgcolor = freerdp_convert_gdi_order_color(fgcolor, gdi->srcBpp, gdi->format); + bgcolor = freerdp_convert_gdi_order_color(bgcolor, gdi->srcBpp, gdi->format, gdi->palette); + fgcolor = freerdp_convert_gdi_order_color(fgcolor, gdi->srcBpp, gdi->format, gdi->palette); gdi_CRgnToRect(x, y, width, height, &rect); @@ -281,7 +283,7 @@ void gdi_Glyph_EndDraw(rdpContext* context, int x, int y, int width, int height, { rdpGdi* gdi = context->gdi; - bgcolor = freerdp_convert_gdi_order_color(bgcolor, gdi->srcBpp, gdi->format); + bgcolor = freerdp_convert_gdi_order_color(bgcolor, gdi->srcBpp, gdi->format, gdi->palette); gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor); } diff --git a/libfreerdp/gdi/test/CMakeLists.txt b/libfreerdp/gdi/test/CMakeLists.txt index 4a2ba50fc..8f9845bf1 100644 --- a/libfreerdp/gdi/test/CMakeLists.txt +++ b/libfreerdp/gdi/test/CMakeLists.txt @@ -21,16 +21,7 @@ include_directories(..) add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS}) - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-gdi) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} winpr freerdp) set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}") diff --git a/libfreerdp/locale/CMakeLists.txt b/libfreerdp/locale/CMakeLists.txt index 67f2145c1..f6bdf73f8 100644 --- a/libfreerdp/locale/CMakeLists.txt +++ b/libfreerdp/locale/CMakeLists.txt @@ -44,13 +44,13 @@ if(CMAKE_SYSTEM_NAME MATCHES Solaris) endif() if(WITH_X11) - add_definitions(-DWITH_X11) - include_directories(${X11_INCLUDE_DIRS}) + freerdp_definition_add(-DWITH_X11) + freerdp_include_directory_add(${X11_INCLUDE_DIRS}) set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_X11_SRCS}) - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${X11_LIBRARIES}) + freerdp_library_add(${X11_LIBRARIES}) if(WITH_SUN) - add_definitions(-DWITH_SUN) + freerdp_definition_add(-DWITH_SUN) set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_SUN_SRCS}) endif() @@ -61,37 +61,13 @@ if(WITH_X11) find_feature(XKBFile ${XKBFILE_FEATURE_TYPE} ${XKBFILE_FEATURE_PURPOSE} ${XKBFILE_FEATURE_DESCRIPTION}) if(WITH_XKBFILE AND (NOT APPLE)) - add_definitions(-DWITH_XKBFILE) - include_directories(${XKBFILE_INCLUDE_DIRS}) + freerdp_definition_add(-DWITH_XKBFILE) + freerdp_include_directory_add(${XKBFILE_INCLUDE_DIRS}) set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_XKBFILE_SRCS}) - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XKBFILE_LIBRARIES}) + freerdp_library_add(${XKBFILE_LIBRARIES}) else() set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_X11_KEYMAP_SRCS}) endif() endif() -add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT" - MONOLITHIC ${MONOLITHIC_BUILD} - SOURCES ${${MODULE_PREFIX}_SRCS} - EXPORT) - -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) -endif() -set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "lib") - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} INTERNAL - MODULE freerdp - MODULES freerdp-utils) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -if(MONOLITHIC_BUILD) - set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) -else() - target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) - install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets) -endif() - -set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") +freerdp_module_add(${${MODULE_PREFIX}_SRCS}) diff --git a/libfreerdp/locale/keyboard_xkbfile.c b/libfreerdp/locale/keyboard_xkbfile.c index 8387d2736..a2b4ff210 100644 --- a/libfreerdp/locale/keyboard_xkbfile.c +++ b/libfreerdp/locale/keyboard_xkbfile.c @@ -345,7 +345,7 @@ int freerdp_keyboard_init_xkbfile(DWORD* keyboardLayoutId, DWORD x11_keycode_to_ if (*keyboardLayoutId == 0) { detect_keyboard_layout_from_xkbfile(display, keyboardLayoutId); - DEBUG_KBD("detect_keyboard_layout_from_xkb: %X", (unsigned int) keyboardLayoutId); + DEBUG_KBD("detect_keyboard_layout_from_xkb: %p", keyboardLayoutId); } freerdp_keyboard_load_map_from_xkbfile(display, x11_keycode_to_rdp_scancode); diff --git a/libfreerdp/locale/liblocale.h b/libfreerdp/locale/liblocale.h index 27c0987c9..f88357640 100644 --- a/libfreerdp/locale/liblocale.h +++ b/libfreerdp/locale/liblocale.h @@ -24,18 +24,20 @@ #include "config.h" #endif -#include +#include +#define KBD_TAG FREERDP_TAG("locale") #ifdef WITH_DEBUG_KBD -#define DEBUG_KBD(fmt, ...) DEBUG_CLASS(KBD, fmt, ## __VA_ARGS__) +#define DEBUG_KBD(fmt, ...) WLog_DBG(KBD_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_KBD(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_KBD(fmt, ...) do { } while (0) #endif +#define TIMEZONE_TAG FREERDP_TAG("timezone") #ifdef WITH_DEBUG_TIMEZONE -#define DEBUG_TIMEZONE(fmt, ...) DEBUG_CLASS(TIMEZONE, fmt, ## __VA_ARGS__) +#define DEBUG_TIMEZONE(fmt, ...) WLog_DBG(TIMEZONE_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_TIMEZONE(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_TIMEZONE(fmt, ...) do { } while (0) #endif #endif /* __LIBLOCALE_H */ diff --git a/libfreerdp/locale/timezone.c b/libfreerdp/locale/timezone.c index 76353a987..ead84324d 100644 --- a/libfreerdp/locale/timezone.c +++ b/libfreerdp/locale/timezone.c @@ -30,10 +30,12 @@ #include "liblocale.h" +#include #include - #include +#define TAG FREERDP_TAG("locale") + /* Time Zone Redirection table generated with TimeZones.cs script */ @@ -1565,7 +1567,7 @@ char* freerdp_get_unix_timezone_identifier() return tzid; } - DEBUG_WARN( "Unable to detect time zone\n"); + WLog_ERR(TAG, "Unable to detect time zone"); return tzid; #else return 0; @@ -1626,7 +1628,7 @@ TIME_ZONE_ENTRY* freerdp_detect_windows_time_zone(UINT32 bias) } } - DEBUG_WARN( "Unable to find a match for unix timezone: %s\n", tzid); + WLog_ERR(TAG, "Unable to find a match for unix timezone: %s", tzid); free(tzid); return NULL; } @@ -1642,12 +1644,12 @@ TIME_ZONE_RULE_ENTRY* freerdp_get_current_time_zone_rule(TIME_ZONE_RULE_ENTRY* r { if ((rules[i].TicksStart >= windows_time) && (windows_time >= rules[i].TicksEnd)) { - /*DEBUG_WARN( "Got rule %d from table at %p with count %u\n", i, rules, count);*/ + /*WLog_ERR(TAG, "Got rule %d from table at %p with count %u", i, rules, count);*/ return &rules[i]; } } - DEBUG_WARN( "Unable to get current timezone rule\n"); + WLog_ERR(TAG, "Unable to get current timezone rule"); return NULL; } diff --git a/libfreerdp/primitives/CMakeLists.txt b/libfreerdp/primitives/CMakeLists.txt deleted file mode 100644 index 0cf492670..000000000 --- a/libfreerdp/primitives/CMakeLists.txt +++ /dev/null @@ -1,112 +0,0 @@ -# FreeRDP: A Remote Desktop Protocol Client -# libfreerdp-primitives cmake build script -# vi:ts=4 sw=4: -# -# (c) Copyright 2012 Hewlett-Packard Development Company, L.P. -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. See the License for the specific language governing permissions -# and limitations under the License. -# - -set(MODULE_NAME "freerdp-primitives") -set(MODULE_PREFIX "FREERDP_PRIMITIVES") - -set(${MODULE_PREFIX}_SRCS - prim_16to32bpp.c - prim_add.c - prim_andor.c - prim_alphaComp.c - prim_colors.c - prim_copy.c - prim_set.c - prim_shift.c - prim_sign.c - prim_YUV.c - prim_YCoCg.c - primitives.c - prim_internal.h) - -set(${MODULE_PREFIX}_OPT_SRCS - prim_16to32bpp_opt.c - prim_add_opt.c - prim_andor_opt.c - prim_alphaComp_opt.c - prim_colors_opt.c - prim_set_opt.c - prim_shift_opt.c - prim_sign_opt.c - prim_YUV_opt.c - prim_YCoCg_opt.c) - -add_definitions(-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) - -### IPP Variable debugging -if(WITH_IPP) - if(CMAKE_COMPILER_IS_GNUCC) - foreach(INCLDIR ${IPP_INCLUDE_DIRS}) - set(OPTIMIZATION "${OPTIMIZATION} -I${INCLDIR}") - endforeach(INCLDIR) - endif() -endif() - -if(WITH_SSE2) - if(CMAKE_COMPILER_IS_GNUCC) - set(OPTIMIZATION "${OPTIMIZATION} -msse2 -mssse3 -O2 -Wdeclaration-after-statement") - endif() - - if(MSVC) - set(OPTIMIZATION "${OPTIMIZATION} /arch:SSE2") - endif() -elseif(WITH_NEON) - if(CMAKE_COMPILER_IS_GNUCC) - set(OPTIMIZATION "${OPTIMIZATION} -mfpu=neon -mfloat-abi=${ARM_FP_ABI}") - endif() - # TODO: Add MSVC equivalent -endif() - -set_property(SOURCE ${${MODULE_PREFIX}_OPT_SRCS} PROPERTY COMPILE_FLAGS ${OPTIMIZATION}) - -# always compile with optimization -if(CMAKE_COMPILER_IS_GNUCC) - set_property(SOURCE ${${MODULE_PREFIX}_SRCS} PROPERTY COMPILE_FLAGS "-O2") -endif() - -set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_OPT_SRCS}) - -add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT" - MONOLITHIC ${MONOLITHIC_BUILD} - SOURCES ${${MODULE_PREFIX}_SRCS} - EXPORT) - -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) -endif() -set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "lib") - -if(IPP_FOUND) - include_directories(${IPP_INCLUDE_DIRS}) - foreach(ipp_lib ${IPP_LIBRARIES}) - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} "${ipp_lib}_imported") - endforeach() -endif() - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -if(MONOLITHIC_BUILD) - set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) -else() - target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) - install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets) -endif() - -set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") - -if(BUILD_TESTING AND NOT WIN32 AND NOT APPLE) - add_subdirectory(test) -endif() - diff --git a/libfreerdp/primitives/test/CMakeLists.txt b/libfreerdp/primitives/test/CMakeLists.txt index 8b7162455..9a652a36a 100644 --- a/libfreerdp/primitives/test/CMakeLists.txt +++ b/libfreerdp/primitives/test/CMakeLists.txt @@ -28,12 +28,7 @@ set(${MODULE_PREFIX}_EXTRA_SRCS add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_EXTRA_SRCS}) -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-primitives) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/libfreerdp/primitives/test/TestPrimitivesYCoCg.c b/libfreerdp/primitives/test/TestPrimitivesYCoCg.c index c280b5be3..4c6a4b8e4 100644 --- a/libfreerdp/primitives/test/TestPrimitivesYCoCg.c +++ b/libfreerdp/primitives/test/TestPrimitivesYCoCg.c @@ -85,7 +85,7 @@ int test_YCoCgRToRGB_8u_AC4R_func(void) /* ------------------------------------------------------------------------- */ STD_SPEED_TEST( - ycocg_to_rgb_speed, const BYTE, BYTE, PRIM_NOP, + ycocg_to_rgb_speed, BYTE, BYTE, PRIM_NOP, TRUE, general_YCoCgToRGB_8u_AC4R(src1, 64*4, dst, 64*4, 64, 64, 2, FALSE, FALSE), #ifdef WITH_SSE2 TRUE, ssse3_YCoCgRToRGB_8u_AC4R(src1, 64*4, dst, 64*4, 64, 64, 2, FALSE, FALSE), diff --git a/libfreerdp/rail/CMakeLists.txt b/libfreerdp/rail/CMakeLists.txt index 504f7b303..c84d74ba9 100644 --- a/libfreerdp/rail/CMakeLists.txt +++ b/libfreerdp/rail/CMakeLists.txt @@ -18,33 +18,9 @@ set(MODULE_NAME "freerdp-rail") set(MODULE_PREFIX "FREERDP_RAIL") -set(${MODULE_PREFIX}_SRCS +freerdp_module_add( window_list.c window.c icon.c rail.c librail.h) - -add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT" - MONOLITHIC ${MONOLITHIC_BUILD} - SOURCES ${${MODULE_PREFIX}_SRCS} - EXPORT) - -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) -endif() -set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "lib") - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} INTERNAL - MODULE freerdp - MODULES freerdp-utils) - -if(MONOLITHIC_BUILD) - set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) -else() - target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) - install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets) -endif() - -set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") diff --git a/libfreerdp/rail/icon.c b/libfreerdp/rail/icon.c index fd8240298..73d09a3ba 100644 --- a/libfreerdp/rail/icon.c +++ b/libfreerdp/rail/icon.c @@ -26,22 +26,24 @@ #include -#include +#include #include +#define TAG FREERDP_TAG("rail") + ICON_INFO* icon_cache_get(rdpIconCache* cache, BYTE id, UINT16 index, void** extra) { ICON_INFO* entry; if (id >= cache->numCaches) { - DEBUG_WARN( "invalid window icon cache id:%d\n", id); + WLog_ERR(TAG, "invalid window icon cache id:%d", id); return (ICON_INFO*) NULL; } if (index >= cache->numCacheEntries) { - DEBUG_WARN( "invalid window icon cache index:%d in cache id:%d\n", index, id); + WLog_ERR(TAG, "invalid window icon cache index:%d in cache id:%d", index, id); return (ICON_INFO*) NULL; } @@ -57,13 +59,13 @@ void icon_cache_put(rdpIconCache* cache, BYTE id, UINT16 index, ICON_INFO* entry { if (id >= cache->numCaches) { - DEBUG_WARN( "invalid window icon cache id:%d\n", id); + WLog_ERR(TAG, "invalid window icon cache id:%d", id); return; } if (index >= cache->numCacheEntries) { - DEBUG_WARN( "invalid window icon cache index:%d in cache id:%d\n", index, id); + WLog_ERR(TAG, "invalid window icon cache index:%d in cache id:%d", index, id); return; } diff --git a/libfreerdp/rail/librail.h b/libfreerdp/rail/librail.h index f4795caa0..b762e4816 100644 --- a/libfreerdp/rail/librail.h +++ b/libfreerdp/rail/librail.h @@ -24,12 +24,13 @@ #include "config.h" #endif -#include +#include +#define RAIL_TAG FREERDP_TAG("rail") #ifdef WITH_DEBUG_RAIL -#define DEBUG_RAIL(fmt, ...) DEBUG_CLASS(RAIL, fmt, ## __VA_ARGS__) +#define DEBUG_RAIL(fmt, ...) WLog_DBG(RAIL_TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_RAIL(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_RAIL(fmt, ...) do { } while (0) #endif #endif /* __LIBRAIL_H */ diff --git a/libfreerdp/rail/window.c b/libfreerdp/rail/window.c index b56c0eeee..b020c3c94 100644 --- a/libfreerdp/rail/window.c +++ b/libfreerdp/rail/window.c @@ -29,8 +29,8 @@ #include "librail.h" -#include #include +#include #define TAG FREERDP_TAG("rail") @@ -102,7 +102,7 @@ static const WINDOW_STYLE EXTENDED_WINDOW_STYLES[] = void print_window_styles(UINT32 style) { int i; - DEBUG_WARN("Window Styles:\n{\n"); + WLog_INFO(TAG, "Window Styles:{"); for (i = 0; i < ARRAYSIZE(WINDOW_STYLES); i++) { @@ -114,17 +114,17 @@ void print_window_styles(UINT32 style) continue; } - DEBUG_WARN("\t%s\n", WINDOW_STYLES[i].name); + WLog_INFO(TAG, "\t%s", WINDOW_STYLES[i].name); } } - DEBUG_WARN("}\n"); + WLog_INFO(TAG, "}"); } void print_extended_window_styles(UINT32 style) { int i; - DEBUG_WARN("Extended Window Styles:\n{\n"); + WLog_INFO(TAG, "Extended Window Styles:{"); for (i = 0; i < ARRAYSIZE(EXTENDED_WINDOW_STYLES); i++) { @@ -136,11 +136,11 @@ void print_extended_window_styles(UINT32 style) continue; } - DEBUG_WARN("\t%s\n", EXTENDED_WINDOW_STYLES[i].name); + WLog_INFO(TAG, "\t%s", EXTENDED_WINDOW_STYLES[i].name); } } - DEBUG_WARN("}\n"); + WLog_INFO(TAG, "}"); } void window_state_update(rdpWindow* window, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* window_state) diff --git a/libfreerdp/utils/CMakeLists.txt b/libfreerdp/utils/CMakeLists.txt index ad2a419ee..6c0ac2c62 100644 --- a/libfreerdp/utils/CMakeLists.txt +++ b/libfreerdp/utils/CMakeLists.txt @@ -36,41 +36,18 @@ if(NOT WIN32) set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} msusb.c) endif() -add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT" - MONOLITHIC ${MONOLITHIC_BUILD} - SOURCES ${${MODULE_PREFIX}_SRCS} - EXPORT) +freerdp_module_add(${${MODULE_PREFIX}_SRCS}) -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) -endif() -set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "lib") - -set(${MODULE_PREFIX}_LIBS - ${CMAKE_THREAD_LIBS_INIT} - ${CMAKE_DL_LIBS}) +freerdp_library_add(${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) if(WIN32) - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ws2_32) + freerdp_library_add(ws2_32) endif() if(${CMAKE_SYSTEM_NAME} MATCHES SunOS) - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} rt) + freerdp_library_add(rt) endif() -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -if(MONOLITHIC_BUILD) - set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) -else() - target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) - install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets) -endif() - -set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") - - if(BUILD_TESTING) add_subdirectory(test) endif() - diff --git a/libfreerdp/utils/msusb.c b/libfreerdp/utils/msusb.c index 651bf8308..4d75d74c4 100644 --- a/libfreerdp/utils/msusb.c +++ b/libfreerdp/utils/msusb.c @@ -22,13 +22,15 @@ #include #include -#include +#include #include +#define TAG FREERDP_TAG("utils") + #ifdef WITH_DEBUG_MSUSB -#define DEBUG_MSUSB(fmt, ...) DEBUG_CLASS(MSUSB, fmt, ## __VA_ARGS__) +#define DEBUG_MSUSB(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__) #else -#define DEBUG_MSUSB(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#define DEBUG_MSUSB(fmt, ...) do { } while (0) #endif @@ -321,42 +323,41 @@ void msusb_msconfig_dump(MSUSB_CONFIG_DESCRIPTOR* MsConfig) MSUSB_PIPE_DESCRIPTOR ** MsPipes; MSUSB_PIPE_DESCRIPTOR * MsPipe; int inum = 0, pnum = 0; - - DEBUG_WARN( "=================MsConfig:========================\n"); - DEBUG_WARN( "wTotalLength:%d\n", MsConfig->wTotalLength); - DEBUG_WARN( "bConfigurationValue:%d\n", MsConfig->bConfigurationValue); - DEBUG_WARN( "ConfigurationHandle:0x%x\n", MsConfig->ConfigurationHandle); - DEBUG_WARN( "InitCompleted:%d\n", MsConfig->InitCompleted); - DEBUG_WARN( "MsOutSize:%d\n", MsConfig->MsOutSize); - DEBUG_WARN( "NumInterfaces:%d\n\n", MsConfig->NumInterfaces); + WLog_INFO(TAG, "=================MsConfig:========================"); + WLog_INFO(TAG, "wTotalLength:%d", MsConfig->wTotalLength); + WLog_INFO(TAG, "bConfigurationValue:%d", MsConfig->bConfigurationValue); + WLog_INFO(TAG, "ConfigurationHandle:0x%x", MsConfig->ConfigurationHandle); + WLog_INFO(TAG, "InitCompleted:%d", MsConfig->InitCompleted); + WLog_INFO(TAG, "MsOutSize:%d", MsConfig->MsOutSize); + WLog_INFO(TAG, "NumInterfaces:%d", MsConfig->NumInterfaces); MsInterfaces = MsConfig->MsInterfaces; for(inum = 0; inum < MsConfig->NumInterfaces; inum++) { MsInterface = MsInterfaces[inum]; - DEBUG_WARN( " Interfase: %d\n", MsInterface->InterfaceNumber); - DEBUG_WARN( " Length: %d\n", MsInterface->Length); - DEBUG_WARN( " NumberOfPipesExpected: %d\n", MsInterface->NumberOfPipesExpected); - DEBUG_WARN( " AlternateSetting: %d\n", MsInterface->AlternateSetting); - DEBUG_WARN( " NumberOfPipes: %d\n", MsInterface->NumberOfPipes); - DEBUG_WARN( " InterfaceHandle: 0x%x\n", MsInterface->InterfaceHandle); - DEBUG_WARN( " bInterfaceClass: 0x%x\n", MsInterface->bInterfaceClass); - DEBUG_WARN( " bInterfaceSubClass: 0x%x\n", MsInterface->bInterfaceSubClass); - DEBUG_WARN( " bInterfaceProtocol: 0x%x\n", MsInterface->bInterfaceProtocol); - DEBUG_WARN( " InitCompleted: %d\n\n", MsInterface->InitCompleted); + WLog_INFO(TAG, " Interfase: %d", MsInterface->InterfaceNumber); + WLog_INFO(TAG, " Length: %d", MsInterface->Length); + WLog_INFO(TAG, " NumberOfPipesExpected: %d", MsInterface->NumberOfPipesExpected); + WLog_INFO(TAG, " AlternateSetting: %d", MsInterface->AlternateSetting); + WLog_INFO(TAG, " NumberOfPipes: %d", MsInterface->NumberOfPipes); + WLog_INFO(TAG, " InterfaceHandle: 0x%x", MsInterface->InterfaceHandle); + WLog_INFO(TAG, " bInterfaceClass: 0x%x", MsInterface->bInterfaceClass); + WLog_INFO(TAG, " bInterfaceSubClass: 0x%x", MsInterface->bInterfaceSubClass); + WLog_INFO(TAG, " bInterfaceProtocol: 0x%x", MsInterface->bInterfaceProtocol); + WLog_INFO(TAG, " InitCompleted: %d", MsInterface->InitCompleted); MsPipes = MsInterface->MsPipes; for (pnum = 0; pnum < MsInterface->NumberOfPipes; pnum++) { MsPipe = MsPipes[pnum]; - DEBUG_WARN( " Pipe: %d\n", pnum); - DEBUG_WARN( " MaximumPacketSize: 0x%x\n", MsPipe->MaximumPacketSize); - DEBUG_WARN( " MaximumTransferSize: 0x%x\n", MsPipe->MaximumTransferSize); - DEBUG_WARN( " PipeFlags: 0x%x\n", MsPipe->PipeFlags); - DEBUG_WARN( " PipeHandle: 0x%x\n", MsPipe->PipeHandle); - DEBUG_WARN( " bEndpointAddress: 0x%x\n", MsPipe->bEndpointAddress); - DEBUG_WARN( " bInterval: %d\n", MsPipe->bInterval); - DEBUG_WARN( " PipeType: 0x%x\n", MsPipe->PipeType); - DEBUG_WARN( " InitCompleted: %d\n\n", MsPipe->InitCompleted); + WLog_INFO(TAG, " Pipe: %d", pnum); + WLog_INFO(TAG, " MaximumPacketSize: 0x%x", MsPipe->MaximumPacketSize); + WLog_INFO(TAG, " MaximumTransferSize: 0x%x", MsPipe->MaximumTransferSize); + WLog_INFO(TAG, " PipeFlags: 0x%x", MsPipe->PipeFlags); + WLog_INFO(TAG, " PipeHandle: 0x%x", MsPipe->PipeHandle); + WLog_INFO(TAG, " bEndpointAddress: 0x%x", MsPipe->bEndpointAddress); + WLog_INFO(TAG, " bInterval: %d", MsPipe->bInterval); + WLog_INFO(TAG, " PipeType: 0x%x", MsPipe->PipeType); + WLog_INFO(TAG, " InitCompleted: %d", MsPipe->InitCompleted); } } - DEBUG_WARN( "==================================================\n"); + WLog_INFO(TAG, "=================================================="); } diff --git a/libfreerdp/utils/pcap.c b/libfreerdp/utils/pcap.c index 347c67f8d..21e906e6c 100644 --- a/libfreerdp/utils/pcap.c +++ b/libfreerdp/utils/pcap.c @@ -26,7 +26,9 @@ #include #include -#include +#include + +#define TAG FREERDP_TAG("utils") #ifndef _WIN32 #include @@ -163,7 +165,7 @@ rdpPcap* pcap_open(char* name, BOOL write) if (pcap_fp == NULL) { - DEBUG_WARN("opening pcap dump"); + WLog_ERR(TAG, "opening pcap dump"); return NULL; } diff --git a/libfreerdp/utils/profiler.c b/libfreerdp/utils/profiler.c index 306c94513..11737a210 100644 --- a/libfreerdp/utils/profiler.c +++ b/libfreerdp/utils/profiler.c @@ -25,7 +25,9 @@ #include #include -#include +#include + +#define TAG FREERDP_TAG("utils") PROFILER* profiler_create(char* name) { @@ -58,24 +60,22 @@ void profiler_exit(PROFILER* profiler) void profiler_print_header() { - DEBUG_WARN( "\n"); - DEBUG_WARN( " |-----------------------|\n" ); - DEBUG_WARN( " PROFILER | elapsed seconds |\n" ); - DEBUG_WARN( "|--------------------------------------------|-----------------------|\n" ); - DEBUG_WARN( "| code section | iterations | total | avg. |\n" ); - DEBUG_WARN( "|-------------------------------|------------|-----------|-----------|\n" ); + WLog_INFO(TAG, " |-----------------------|"); + WLog_INFO(TAG, " PROFILER | elapsed seconds |"); + WLog_INFO(TAG, "|--------------------------------------------|-----------------------|"); + WLog_INFO(TAG, "| code section | iterations | total | avg. |"); + WLog_INFO(TAG, "|-------------------------------|------------|-----------|-----------|"); } void profiler_print(PROFILER* profiler) { double elapsed_sec = stopwatch_get_elapsed_time_in_seconds(profiler->stopwatch); double avg_sec = elapsed_sec / (double) profiler->stopwatch->count; - - DEBUG_WARN( "| %-30.30s| %10du | %9f | %9f |\n", - profiler->name, profiler->stopwatch->count, elapsed_sec, avg_sec); + WLog_INFO(TAG, "| %-30.30s| %10du | %9f | %9f |", + profiler->name, profiler->stopwatch->count, elapsed_sec, avg_sec); } void profiler_print_footer() { - DEBUG_WARN( "|--------------------------------------------------------------------|\n" ); + WLog_INFO(TAG, "|--------------------------------------------------------------------|"); } diff --git a/libfreerdp/utils/rail.c b/libfreerdp/utils/rail.c index b0d01ab40..19029f43b 100644 --- a/libfreerdp/utils/rail.c +++ b/libfreerdp/utils/rail.c @@ -143,7 +143,7 @@ void* rail_clone_order(UINT32 event_type, void* order) new_order = malloc(order_size); CopyMemory(new_order, order, order_size); - //DEBUG_WARN( "rail_clone_order: type=%d order=%p\n", event_type, new_order); + //WLog_ERR(TAG, "rail_clone_order: type=%d order=%p\n", event_type, new_order); // Create copy of variable data for some orders if ((event_type == RailChannel_GetSystemParam) || @@ -183,7 +183,7 @@ void* rail_clone_order(UINT32 event_type, void* order) void rail_free_cloned_order(UINT32 event_type, void* order) { - //DEBUG_WARN( "rail_free_cloned_order: type=%d order=%p\n", event_type, order); + //WLog_ERR(TAG, "rail_free_cloned_order: type=%d order=%p\n", event_type, order); if ((event_type == RailChannel_GetSystemParam) || (event_type == RailChannel_ClientSystemParam)) { diff --git a/libfreerdp/utils/signal.c b/libfreerdp/utils/signal.c index fe3b3c6f8..978aac6dd 100644 --- a/libfreerdp/utils/signal.c +++ b/libfreerdp/utils/signal.c @@ -26,7 +26,9 @@ #include #include -#include +#include + +#define TAG FREERDP_TAG("utils") #ifdef _WIN32 @@ -49,8 +51,7 @@ static void fatal_handler(int signum) { struct sigaction default_sigaction; sigset_t this_mask; - - DEBUG_MSG("fatal_handler: signum=%d\n", signum); + WLog_DBG(TAG, "fatal_handler: signum=%d", signum); if (terminal_needs_reset) tcsetattr(terminal_fildes, TCSAFLUSH, &orig_flags); diff --git a/libfreerdp/utils/svc_plugin.c b/libfreerdp/utils/svc_plugin.c index a5a7d5913..50e418529 100644 --- a/libfreerdp/utils/svc_plugin.c +++ b/libfreerdp/utils/svc_plugin.c @@ -33,10 +33,12 @@ #include #include -#include +#include #include #include +#define TAG FREERDP_TAG("utils") + static wListDictionary* g_InitHandles; static wListDictionary* g_OpenHandles; @@ -139,7 +141,7 @@ static VOID VCAPITYPE svc_plugin_open_event(DWORD openHandle, UINT event, LPVOID if (!plugin) { - DEBUG_WARN( "svc_plugin_open_event: error no match\n"); + WLog_ERR(TAG, "svc_plugin_open_event: error no match"); return; } @@ -214,7 +216,7 @@ static void svc_plugin_process_connected(rdpSvcPlugin* plugin, LPVOID pData, UIN if (status != CHANNEL_RC_OK) { - DEBUG_WARN( "svc_plugin_process_connected: open failed: status: %d\n", status); + WLog_ERR(TAG, "svc_plugin_process_connected: open failed: status: %d", status); return; } @@ -264,7 +266,7 @@ static VOID VCAPITYPE svc_plugin_init_event(LPVOID pInitHandle, UINT event, LPVO if (!plugin) { - DEBUG_WARN( "svc_plugin_init_event: error no match\n"); + WLog_ERR(TAG, "svc_plugin_init_event: error no match"); return; } @@ -333,7 +335,7 @@ int svc_plugin_send(rdpSvcPlugin* plugin, wStream* data_out) if (status != CHANNEL_RC_OK) { Stream_Free(data_out, TRUE); - DEBUG_WARN( "svc_plugin_send: VirtualChannelWrite failed %d\n", status); + WLog_ERR(TAG, "svc_plugin_send: VirtualChannelWrite failed %d", status); } return status; @@ -349,7 +351,7 @@ int svc_plugin_send_event(rdpSvcPlugin* plugin, wMessage* event) status = plugin->channel_entry_points.pVirtualChannelEventPush(plugin->OpenHandle, event); if (status != CHANNEL_RC_OK) - DEBUG_WARN( "svc_plugin_send_event: VirtualChannelEventPush failed %d\n", status); + WLog_ERR(TAG, "svc_plugin_send_event: VirtualChannelEventPush failed %d", status); return status; } diff --git a/libfreerdp/utils/tcp.c b/libfreerdp/utils/tcp.c index 1e9aba90a..a64c49cd6 100644 --- a/libfreerdp/utils/tcp.c +++ b/libfreerdp/utils/tcp.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include @@ -74,6 +74,8 @@ #endif +#define TAG FREERDP_TAG("utils") + int freerdp_tcp_connect(const char* hostname, int port) { int status; @@ -97,7 +99,7 @@ int freerdp_tcp_connect(const char* hostname, int port) if (status != 0) { - //DEBUG_WARN( "tcp_connect: getaddrinfo (%s)\n", gai_strerror(status)); + //WLog_ERR(TAG, "tcp_connect: getaddrinfo (%s)", gai_strerror(status)); return -1; } @@ -112,7 +114,7 @@ int freerdp_tcp_connect(const char* hostname, int port) if (connect(sockfd, ai->ai_addr, ai->ai_addrlen) == 0) { - DEBUG_WARN( "connected to %s:%s\n", hostname, servname); + WLog_ERR(TAG, "connected to %s:%s", hostname, servname); break; } @@ -124,7 +126,7 @@ int freerdp_tcp_connect(const char* hostname, int port) if (sockfd == -1) { - DEBUG_WARN( "unable to connect to %s:%s\n", hostname, servname); + WLog_ERR(TAG, "unable to connect to %s:%s", hostname, servname); return -1; } @@ -150,13 +152,13 @@ int freerdp_tcp_read(int sockfd, BYTE* data, int length) if (wsa_error == WSAEWOULDBLOCK) return 0; - DEBUG_WARN( "recv() error: %d\n", wsa_error); + WLog_ERR(TAG, "recv() error: %d", wsa_error); #else /* No data available */ if (errno == EAGAIN || errno == EWOULDBLOCK) return 0; - DEBUG_WARN("recv"); + WLog_ERR(TAG, "recv"); #endif return -1; } @@ -179,12 +181,14 @@ int freerdp_tcp_write(int sockfd, BYTE* data, int length) if (wsa_error == WSAEWOULDBLOCK) status = 0; else - DEBUG_WARN("send"); + WLog_ERR(TAG, "send"); + #else if (errno == EAGAIN || errno == EWOULDBLOCK) status = 0; else - DEBUG_WARN("send"); + WLog_ERR(TAG, "send"); + #endif } @@ -204,7 +208,7 @@ int freerdp_tcp_wait_read(int sockfd) if (sockfd < 1) { - DEBUG_WARN( "Invalid socket to watch: %d\n", sockfd); + WLog_ERR(TAG, "Invalid socket to watch: %d", sockfd); return 0 ; } @@ -241,7 +245,7 @@ int freerdp_tcp_wait_write(int sockfd) if (sockfd < 1) { - DEBUG_WARN( "Invalid socket to watch: %d\n", sockfd); + WLog_ERR(TAG, "Invalid socket to watch: %d", sockfd); return 0 ; } diff --git a/libfreerdp/utils/test/CMakeLists.txt b/libfreerdp/utils/test/CMakeLists.txt index ace2867c6..a08ee112d 100644 --- a/libfreerdp/utils/test/CMakeLists.txt +++ b/libfreerdp/utils/test/CMakeLists.txt @@ -13,14 +13,7 @@ create_test_sourcelist(${MODULE_PREFIX}_SRCS add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-utils) - -target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +target_link_libraries(${MODULE_NAME} winpr freerdp) set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}") diff --git a/libfreerdp/utils/uds.c b/libfreerdp/utils/uds.c index 6c872a6f1..9aa62588b 100644 --- a/libfreerdp/utils/uds.c +++ b/libfreerdp/utils/uds.c @@ -22,7 +22,7 @@ #endif #include -#include +#include #include #include @@ -44,6 +44,8 @@ #endif +#define TAG FREERDP_TAG("utils") + int freerdp_uds_connect(const char* path) { #ifndef _WIN32 @@ -55,7 +57,7 @@ int freerdp_uds_connect(const char* path) sockfd = socket(AF_UNIX, SOCK_STREAM, 0); if (sockfd == -1) { - DEBUG_WARN("socket"); + WLog_ERR(TAG, "socket"); return -1; } @@ -64,7 +66,7 @@ int freerdp_uds_connect(const char* path) status = connect(sockfd, (struct sockaddr *) &addr, sizeof(addr)); if (status < 0) { - DEBUG_WARN("connect"); + WLog_ERR(TAG, "connect"); close(sockfd); return -1; } diff --git a/server/Mac/CMakeLists.txt b/server/Mac/CMakeLists.txt index bedd69ec8..4217d5477 100644 --- a/server/Mac/CMakeLists.txt +++ b/server/Mac/CMakeLists.txt @@ -67,12 +67,7 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${IOSURFACE} ${CARBON}) -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-core freerdp-utils freerdp-codec freerdp-primitives) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/server/Mac/mf_audin.c b/server/Mac/mf_audin.c index 02f77699b..dd32ca7bf 100644 --- a/server/Mac/mf_audin.c +++ b/server/Mac/mf_audin.c @@ -25,16 +25,17 @@ #include "mf_audin.h" +#include +#define TAG SERVER_TAG("mac") + static const AUDIO_FORMAT supported_audio_formats[] = { - { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, NULL }, { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, NULL } }; static void mf_peer_audin_opening(audin_server_context* context) { - /* Simply choose the first format supported by the client. */ context->SelectFormat(context, 0); } diff --git a/server/Mac/mf_event.c b/server/Mac/mf_event.c index 669d97454..70971e1ab 100644 --- a/server/Mac/mf_event.c +++ b/server/Mac/mf_event.c @@ -29,6 +29,9 @@ #include "mf_event.h" +#include +#define TAG SERVER_TAG("mac") + int mf_is_event_set(mfEventQueue* event_queue) { fd_set rfds; @@ -48,6 +51,9 @@ void mf_signal_event(mfEventQueue* event_queue) int length; length = write(event_queue->pipe_fd[1], "sig", 4); + + if (length != 4) + WLog_ERR(TAG, "mf_signal_event: error"); } void mf_set_event(mfEventQueue* event_queue) @@ -55,6 +61,9 @@ void mf_set_event(mfEventQueue* event_queue) int length; length = write(event_queue->pipe_fd[1], "sig", 4); + + if (length != 4) + WLog_ERR(TAG, "mf_set_event: error"); } void mf_clear_events(mfEventQueue* event_queue) @@ -64,6 +73,9 @@ void mf_clear_events(mfEventQueue* event_queue) while (mf_is_event_set(event_queue)) { length = read(event_queue->pipe_fd[0], &length, 4); + + if (length != 4) + WLog_ERR(TAG, "mf_clear_event: error"); } } @@ -72,6 +84,9 @@ void mf_clear_event(mfEventQueue* event_queue) int length; length = read(event_queue->pipe_fd[0], &length, 4); + + if (length != 4) + WLog_ERR(TAG, "mf_clear_event: error"); } void mf_event_push(mfEventQueue* event_queue, mfEvent* event) diff --git a/server/Mac/mf_info.c b/server/Mac/mf_info.c index 4a9f3ade8..c65fbe7d0 100644 --- a/server/Mac/mf_info.c +++ b/server/Mac/mf_info.c @@ -1,237 +1,231 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * FreeRDP Mac OS X Server - * - * Copyright 2012 Corey Clayton - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include "mf_info.h" -#include "mf_mountain_lion.h" -//#include "mf_update.h" - -static mfInfo* mfInfoInstance = NULL; -//static int _IDcount = 0; - -int mf_info_lock(mfInfo* mfi) -{ - int status = pthread_mutex_lock(&mfi->mutex); - - switch (status) - { - case 0: - return TRUE; - break; - - default: - return -1; - break; - } - -} - -int mf_info_try_lock(mfInfo* mfi, UINT32 ms) -{ - - int status = pthread_mutex_trylock(&mfi->mutex); - - switch (status) - { - case 0: - return TRUE; - break; - - case EBUSY: - return FALSE; - break; - - default: - return -1; - break; - } - -} - -int mf_info_unlock(mfInfo* mfi) -{ - int status = pthread_mutex_unlock(&mfi->mutex); - - switch (status) - { - case 0: - return TRUE; - break; - - default: - return -1; - break; - } - -} - -mfInfo* mf_info_init() -{ - mfInfo* mfi; - - mfi = (mfInfo*) malloc(sizeof(mfInfo)); - memset(mfi, 0, sizeof(mfInfo)); - - if (mfi != NULL) - { - pthread_mutex_init(&mfi->mutex, NULL); - - mfi->peers = (freerdp_peer**) malloc(sizeof(freerdp_peer*) * MF_INFO_MAXPEERS); - memset(mfi->peers, 0, sizeof(freerdp_peer*) * MF_INFO_MAXPEERS); - - mfi->framesPerSecond = MF_INFO_DEFAULT_FPS; - - mfi->input_disabled = FALSE; - } - - return mfi; -} - -mfInfo* mf_info_get_instance() -{ - if (mfInfoInstance == NULL) - mfInfoInstance = mf_info_init(); - - return mfInfoInstance; -} - -void mf_info_peer_register(mfInfo* mfi, mfPeerContext* context) -{ - if (mf_info_lock(mfi) > 0) - { - int i; - int peerId; - - if (mfi->peerCount == MF_INFO_MAXPEERS) - { - //context->socketClose = TRUE; - mf_info_unlock(mfi); - return; - } - - context->info = mfi; - - //initialize screen capture - if (mfi->peerCount == 0) - { - mf_mlion_display_info(&mfi->servscreen_width, &mfi->servscreen_height, &mfi->scale); - mf_mlion_screen_updates_init(); - mf_mlion_start_getting_screen_updates(); - } - - //look trhough the array of peers until an empty slot - peerId = NULL; - for(i=0; ipeers[i] == NULL) - { - peerId = i; - break; - } - } - - mfi->peers[peerId] = ((rdpContext*) context)->peer; - mfi->peers[peerId]->pId = peerId; - mfi->peerCount++; - //printf("Registering Peer: id=%d #=%d\n", peerId, mfi->peerCount); - - mf_info_unlock(mfi); - } -} - -void mf_info_peer_unregister(mfInfo* mfi, mfPeerContext* context) -{ - if (mf_info_lock(mfi) > 0) - { - int peerId; - - peerId = ((rdpContext*) context)->peer->pId; - mfi->peers[peerId] = NULL; - mfi->peerCount--; - - //screen capture cleanup - if (mfi->peerCount == 0) - { - mf_mlion_stop_getting_screen_updates(); - } - mf_info_unlock(mfi); - } -} - -BOOL mf_info_have_updates(mfInfo* mfi) -{ - if(mfi->framesWaiting == 0) - return FALSE; - - return TRUE; -} - -void mf_info_update_changes(mfInfo* mfi) -{ - -} - -void mf_info_find_invalid_region(mfInfo* mfi) -{ - mf_mlion_get_dirty_region(&mfi->invalid); -} - -void mf_info_clear_invalid_region(mfInfo* mfi) -{ - mf_mlion_clear_dirty_region(); - mfi->invalid.height = 0; - mfi->invalid.width = 0; -} - -void mf_info_invalidate_full_screen(mfInfo* mfi) -{ - mfi->invalid.x = 0; - mfi->invalid.y = 0; - mfi->invalid.height = mfi->servscreen_height; - mfi->invalid.height = mfi->servscreen_width; -} - -BOOL mf_info_have_invalid_region(mfInfo* mfi) -{ - if (mfi->invalid.width * mfi->invalid.height == 0) { - return FALSE; - } - return TRUE; -} - -void mf_info_getScreenData(mfInfo* mfi, long* width, long* height, BYTE** pBits, int* pitch) -{ - *width = mfi->invalid.width / mfi->scale; - *height = mfi->invalid.height / mfi->scale; - *pitch = mfi->servscreen_width * mfi->scale * 4; - - mf_mlion_get_pixelData(mfi->invalid.x / mfi->scale, mfi->invalid.y / mfi->scale, *width, *height, pBits); - - *pBits = *pBits + (mfi->invalid.x * 4) + (*pitch * mfi->invalid.y); - -} - +/** + * FreeRDP: A Remote Desktop Protocol Client + * FreeRDP Mac OS X Server + * + * Copyright 2012 Corey Clayton + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include "mf_info.h" +#include "mf_mountain_lion.h" + +static mfInfo* mfInfoInstance = NULL; + +int mf_info_lock(mfInfo* mfi) +{ + int status = pthread_mutex_lock(&mfi->mutex); + + switch (status) + { + case 0: + return TRUE; + break; + + default: + return -1; + break; + } + + return 1; +} + +int mf_info_try_lock(mfInfo* mfi, UINT32 ms) +{ + int status = pthread_mutex_trylock(&mfi->mutex); + + switch (status) + { + case 0: + return TRUE; + break; + + case EBUSY: + return FALSE; + break; + + default: + return -1; + break; + } + + return 1; +} + +int mf_info_unlock(mfInfo* mfi) +{ + int status = pthread_mutex_unlock(&mfi->mutex); + + switch (status) + { + case 0: + return TRUE; + break; + + default: + return -1; + break; + } + + return 1; +} + +mfInfo* mf_info_init() +{ + mfInfo* mfi; + + mfi = (mfInfo*) malloc(sizeof(mfInfo)); + memset(mfi, 0, sizeof(mfInfo)); + + if (mfi != NULL) + { + pthread_mutex_init(&mfi->mutex, NULL); + + mfi->peers = (freerdp_peer**) malloc(sizeof(freerdp_peer*) * MF_INFO_MAXPEERS); + memset(mfi->peers, 0, sizeof(freerdp_peer*) * MF_INFO_MAXPEERS); + + mfi->framesPerSecond = MF_INFO_DEFAULT_FPS; + + mfi->input_disabled = FALSE; + } + + return mfi; +} + +mfInfo* mf_info_get_instance() +{ + if (mfInfoInstance == NULL) + mfInfoInstance = mf_info_init(); + + return mfInfoInstance; +} + +void mf_info_peer_register(mfInfo* mfi, mfPeerContext* context) +{ + if (mf_info_lock(mfi) > 0) + { + int i; + int peerId; + + if (mfi->peerCount == MF_INFO_MAXPEERS) + { + mf_info_unlock(mfi); + return; + } + + context->info = mfi; + + if (mfi->peerCount == 0) + { + mf_mlion_display_info(&mfi->servscreen_width, &mfi->servscreen_height, &mfi->scale); + mf_mlion_screen_updates_init(); + mf_mlion_start_getting_screen_updates(); + } + + peerId = NULL; + + for(i=0; ipeers[i] == NULL) + { + peerId = i; + break; + } + } + + mfi->peers[peerId] = ((rdpContext*) context)->peer; + mfi->peers[peerId]->pId = peerId; + mfi->peerCount++; + + mf_info_unlock(mfi); + } +} + +void mf_info_peer_unregister(mfInfo* mfi, mfPeerContext* context) +{ + if (mf_info_lock(mfi) > 0) + { + int peerId; + + peerId = ((rdpContext*) context)->peer->pId; + mfi->peers[peerId] = NULL; + mfi->peerCount--; + + if (mfi->peerCount == 0) + mf_mlion_stop_getting_screen_updates(); + + mf_info_unlock(mfi); + } +} + +BOOL mf_info_have_updates(mfInfo* mfi) +{ + if(mfi->framesWaiting == 0) + return FALSE; + + return TRUE; +} + +void mf_info_update_changes(mfInfo* mfi) +{ + +} + +void mf_info_find_invalid_region(mfInfo* mfi) +{ + mf_mlion_get_dirty_region(&mfi->invalid); +} + +void mf_info_clear_invalid_region(mfInfo* mfi) +{ + mf_mlion_clear_dirty_region(); + mfi->invalid.height = 0; + mfi->invalid.width = 0; +} + +void mf_info_invalidate_full_screen(mfInfo* mfi) +{ + mfi->invalid.x = 0; + mfi->invalid.y = 0; + mfi->invalid.height = mfi->servscreen_height; + mfi->invalid.height = mfi->servscreen_width; +} + +BOOL mf_info_have_invalid_region(mfInfo* mfi) +{ + if (mfi->invalid.width * mfi->invalid.height == 0) + return FALSE; + + return TRUE; +} + +void mf_info_getScreenData(mfInfo* mfi, long* width, long* height, BYTE** pBits, int* pitch) +{ + *width = mfi->invalid.width / mfi->scale; + *height = mfi->invalid.height / mfi->scale; + *pitch = mfi->servscreen_width * mfi->scale * 4; + + mf_mlion_get_pixelData(mfi->invalid.x / mfi->scale, mfi->invalid.y / mfi->scale, *width, *height, pBits); + + *pBits = *pBits + (mfi->invalid.x * 4) + (*pitch * mfi->invalid.y); + +} diff --git a/server/Mac/mf_input.c b/server/Mac/mf_input.c index 2a10617bf..dbfb617d7 100644 --- a/server/Mac/mf_input.c +++ b/server/Mac/mf_input.c @@ -29,7 +29,11 @@ #include "mf_input.h" #include "mf_info.h" -static const CGKeyCode keymap[256] = { +#include +#define TAG SERVER_TAG("mac") + +static const CGKeyCode keymap[256] = +{ 0xFF, //0x0 kVK_Escape, //0x1 kVK_ANSI_1, //0x2 diff --git a/server/Mac/mf_mountain_lion.c b/server/Mac/mf_mountain_lion.c index be3398734..0b8c9125c 100644 --- a/server/Mac/mf_mountain_lion.c +++ b/server/Mac/mf_mountain_lion.c @@ -207,7 +207,7 @@ int mf_mlion_stop_getting_screen_updates() } return 0; - + return 0; } @@ -277,4 +277,3 @@ int mf_mlion_get_pixelData(long x, long y, long width, long height, BYTE** pxDat return 0; } - diff --git a/server/Mac/mf_peer.c b/server/Mac/mf_peer.c index 15c225732..239aafd6d 100644 --- a/server/Mac/mf_peer.c +++ b/server/Mac/mf_peer.c @@ -1,443 +1,443 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * FreeRDP Mac OS X Server - * - * Copyright 2012 Corey Clayton - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#include - -#include "mf_peer.h" -#include "mf_info.h" -#include "mf_input.h" -#include "mf_event.h" -#include "mf_rdpsnd.h" - -#include -#include -#include - -#include "OpenGL/OpenGL.h" -#include "OpenGL/gl.h" - -#include "CoreVideo/CoreVideo.h" - -//refactor these -int info_last_sec = 0; -int info_last_nsec = 0; - -dispatch_source_t info_timer; -dispatch_queue_t info_queue; - -mfEventQueue* info_event_queue; - - -CGLContextObj glContext; -CGContextRef bmp; -CGImageRef img; - - - -BOOL mf_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount) -{ - if (info_event_queue->pipe_fd[0] == -1) - return TRUE; - - rfds[*rcount] = (void *)(long) info_event_queue->pipe_fd[0]; - (*rcount)++; - - return TRUE; -} - -BOOL mf_peer_check_fds(freerdp_peer* client) -{ - mfPeerContext* context = (mfPeerContext*) client->context; - mfEvent* event; - - if (context->activated == FALSE) - return TRUE; - - event = mf_event_peek(info_event_queue); - - if (event != NULL) - { - if (event->type == MF_EVENT_TYPE_REGION) - { - - } - else if (event->type == MF_EVENT_TYPE_FRAME_TICK) - { - event = mf_event_pop(info_event_queue); - - mf_peer_rfx_update(client); - - mf_event_free(event); - } - } - - return TRUE; -} - -void mf_peer_rfx_update(freerdp_peer* client) -{ - //check - mfInfo* mfi = mf_info_get_instance(); - - mf_info_find_invalid_region(mfi); - - if (mf_info_have_invalid_region(mfi) == false) { - return; - } - - - long width; - long height; - int pitch; - BYTE* dataBits = NULL; - - mf_info_getScreenData(mfi, &width, &height, &dataBits, &pitch); - - mf_info_clear_invalid_region(mfi); - - //encode - - wStream* s; - RFX_RECT rect; - rdpUpdate* update; - mfPeerContext* mfp; - SURFACE_BITS_COMMAND* cmd; - - update = client->update; - mfp = (mfPeerContext*) client->context; - cmd = &update->surface_bits_command; - - - s = mfp->s; - Stream_Clear(s); - Stream_SetPosition(s, 0); - - UINT32 x = mfi->invalid.x / mfi->scale; - UINT32 y = mfi->invalid.y / mfi->scale; - - rect.x = 0; - rect.y = 0; - rect.width = width; - rect.height = height; - - mfp->rfx_context->width = mfi->servscreen_width; - mfp->rfx_context->height = mfi->servscreen_height; - - rfx_compose_message(mfp->rfx_context, s, &rect, 1, - (BYTE*) dataBits, rect.width, rect.height, pitch); - - cmd->destLeft = x; - cmd->destTop = y; - cmd->destRight = x + rect.width; - cmd->destBottom = y + rect.height; - - - cmd->bpp = 32; - cmd->codecID = 3; - cmd->width = rect.width; - cmd->height = rect.height; - cmd->bitmapDataLength = Stream_GetPosition(s); - cmd->bitmapData = Stream_Buffer(s); - - //send - - update->SurfaceBits(update->context, cmd); - - //clean up... maybe? - -} - -/* Called when we have a new peer connecting */ -int mf_peer_context_new(freerdp_peer* client, mfPeerContext* context) -{ - context->info = mf_info_get_instance(); - context->rfx_context = rfx_context_new(TRUE); - context->rfx_context->mode = RLGR3; - context->rfx_context->width = client->settings->DesktopWidth; - context->rfx_context->height = client->settings->DesktopHeight; - rfx_context_set_pixel_format(context->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8); - - //context->nsc_context = nsc_context_new(); - //nsc_context_set_pixel_format(context->nsc_context, RDP_PIXEL_FORMAT_B8G8R8A8); - - context->s = Stream_New(NULL, 0xFFFF); - - context->vcm = WTSOpenServerA((LPSTR) client->context); - - mf_info_peer_register(context->info, context); - - return 0; -} - -/* Called after a peer disconnects */ -void mf_peer_context_free(freerdp_peer* client, mfPeerContext* context) -{ - if (context) - { - mf_info_peer_unregister(context->info, context); - - dispatch_suspend(info_timer); - - Stream_Free(context->s, TRUE); - - rfx_context_free(context->rfx_context); - //nsc_context_free(context->nsc_context); - -#ifdef CHANNEL_AUDIN_SERVER - if (context->audin) - audin_server_context_free(context->audin); -#endif - - //#ifdef CHANNEL_RDPSND_SERVER - mf_peer_rdpsnd_stop(); - if (context->rdpsnd) - rdpsnd_server_context_free(context->rdpsnd); - //#endif - - WTSCloseServer(context->vcm); - } -} - -/* Called when a new client connects */ -void mf_peer_init(freerdp_peer* client) -{ - client->ContextSize = sizeof(mfPeerContext); - client->ContextNew = (psPeerContextNew) mf_peer_context_new; - client->ContextFree = (psPeerContextFree) mf_peer_context_free; - freerdp_peer_context_new(client); - - info_event_queue = mf_event_queue_new(); - - info_queue = dispatch_queue_create("FreeRDP.update.timer", DISPATCH_QUEUE_SERIAL); - info_timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, info_queue); - - if(info_timer) - { - //DEBUG_WARN( "created timer\n"); - dispatch_source_set_timer(info_timer, DISPATCH_TIME_NOW, 42ull * NSEC_PER_MSEC, 100ull * NSEC_PER_MSEC); - dispatch_source_set_event_handler(info_timer, ^{ - //DEBUG_WARN( "dispatch\n"); - mfEvent* event = mf_event_new(MF_EVENT_TYPE_FRAME_TICK); - mf_event_push(info_event_queue, (mfEvent*) event);} - ); - dispatch_resume(info_timer); - } -} - -BOOL mf_peer_post_connect(freerdp_peer* client) -{ - mfPeerContext* context = (mfPeerContext*) client->context; - rdpSettings* settings = client->settings; - - mfInfo* mfi = mf_info_get_instance(); - mfi->scale = 1; - - //mfi->servscreen_width = 2880 / mfi->scale; - //mfi->servscreen_height = 1800 / mfi->scale; - UINT32 bitsPerPixel = 32; - - if ((settings->DesktopWidth != mfi->servscreen_width) || (settings->DesktopHeight != mfi->servscreen_height)) - { - - } - - settings->DesktopWidth = mfi->servscreen_width; - settings->DesktopHeight = mfi->servscreen_height; - settings->ColorDepth = bitsPerPixel; - - client->update->DesktopResize(client->update->context); - - mfi->mouse_down_left = FALSE; - mfi->mouse_down_right = FALSE; - mfi->mouse_down_other = FALSE; - - if (WTSVirtualChannelManagerIsChannelJoined(context->vcm, "rdpsnd")) - { - mf_peer_rdpsnd_init(context); /* Audio Output */ - } - - /* Dynamic Virtual Channels */ - -#ifdef CHANNEL_AUDIN_SERVER - mf_peer_audin_init(context); /* Audio Input */ -#endif - - return TRUE; -} - -BOOL mf_peer_activate(freerdp_peer* client) -{ - mfPeerContext* context = (mfPeerContext*) client->context; - - rfx_context_reset(context->rfx_context); - context->activated = TRUE; - - return TRUE; -} - -void mf_peer_synchronize_event(rdpInput* input, UINT32 flags) -{ - -} - -void mf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) -{ - UINT16 down = 0x4000; - //UINT16 up = 0x8000; - - bool state_down = FALSE; - - if (flags == down) - { - state_down = TRUE; - } -} - -void mf_peer_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) -{ - -} - -static void mf_peer_suppress_output(rdpContext* context, BYTE allow, RECTANGLE_16* area) -{ - -} - -void mf_peer_accepted(freerdp_listener* instance, freerdp_peer* client) -{ - pthread_t th; - - pthread_create(&th, 0, mf_peer_main_loop, client); - pthread_detach(th); -} - -void* mf_peer_main_loop(void* arg) -{ - int i; - int fds; - int max_fds; - int rcount; - void* rfds[32]; - fd_set rfds_set; - mfPeerContext* context; - freerdp_peer* client = (freerdp_peer*) arg; - - memset(rfds, 0, sizeof(rfds)); - - mf_peer_init(client); - - /* Initialize the real server settings here */ - client->settings->CertificateFile = _strdup("server.crt"); - client->settings->PrivateKeyFile = _strdup("server.key"); - client->settings->NlaSecurity = FALSE; - client->settings->RemoteFxCodec = TRUE; - client->settings->ColorDepth = 32; - client->settings->SuppressOutput = TRUE; - client->settings->RefreshRect = FALSE; - - client->PostConnect = mf_peer_post_connect; - client->Activate = mf_peer_activate; - - client->input->SynchronizeEvent = mf_peer_synchronize_event; - client->input->KeyboardEvent = mf_input_keyboard_event;//mf_peer_keyboard_event; - client->input->UnicodeKeyboardEvent = mf_peer_unicode_keyboard_event; - client->input->MouseEvent = mf_input_mouse_event; - client->input->ExtendedMouseEvent = mf_input_extended_mouse_event; - - //client->update->RefreshRect = mf_peer_refresh_rect; - client->update->SuppressOutput = mf_peer_suppress_output; - - client->Initialize(client); - context = (mfPeerContext*) client->context; - - - while (1) - { - rcount = 0; - - if (client->GetFileDescriptor(client, rfds, &rcount) != TRUE) - { - break; - } - - if (mf_peer_get_fds(client, rfds, &rcount) != TRUE) - { - break; - } - - WTSVirtualChannelManagerGetFileDescriptor(context->vcm, rfds, &rcount); - - max_fds = 0; - FD_ZERO(&rfds_set); - - for (i = 0; i < rcount; i++) - { - fds = (int)(long)(rfds[i]); - - if (fds > max_fds) - max_fds = fds; - - FD_SET(fds, &rfds_set); - } - - if (max_fds == 0) - break; - - if (select(max_fds + 1, &rfds_set, NULL, NULL, NULL) == -1) - { - /* these are not really errors */ - if (!((errno == EAGAIN) || - (errno == EWOULDBLOCK) || - (errno == EINPROGRESS) || - (errno == EINTR))) /* signal occurred */ - { - break; - } - } - - if (client->CheckFileDescriptor(client) != TRUE) - { - break; - } - - if ((mf_peer_check_fds(client)) != TRUE) - { - break; - } - - if (WTSVirtualChannelManagerCheckFileDescriptor(context->vcm) != TRUE) - { - break; - } - } - - client->Disconnect(client); - freerdp_peer_context_free(client); - freerdp_peer_free(client); - - return NULL; -} +/** + * FreeRDP: A Remote Desktop Protocol Client + * FreeRDP Mac OS X Server + * + * Copyright 2012 Corey Clayton + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include + +#include "mf_peer.h" +#include "mf_info.h" +#include "mf_input.h" +#include "mf_event.h" +#include "mf_rdpsnd.h" + +#include +#include +#include + +#include "OpenGL/OpenGL.h" +#include "OpenGL/gl.h" + +#include "CoreVideo/CoreVideo.h" + +//refactor these +int info_last_sec = 0; +int info_last_nsec = 0; + +dispatch_source_t info_timer; +dispatch_queue_t info_queue; + +mfEventQueue* info_event_queue; + + +CGLContextObj glContext; +CGContextRef bmp; +CGImageRef img; + + + +BOOL mf_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount) +{ + if (info_event_queue->pipe_fd[0] == -1) + return TRUE; + + rfds[*rcount] = (void *)(long) info_event_queue->pipe_fd[0]; + (*rcount)++; + + return TRUE; +} + +BOOL mf_peer_check_fds(freerdp_peer* client) +{ + mfPeerContext* context = (mfPeerContext*) client->context; + mfEvent* event; + + if (context->activated == FALSE) + return TRUE; + + event = mf_event_peek(info_event_queue); + + if (event != NULL) + { + if (event->type == MF_EVENT_TYPE_REGION) + { + + } + else if (event->type == MF_EVENT_TYPE_FRAME_TICK) + { + event = mf_event_pop(info_event_queue); + + mf_peer_rfx_update(client); + + mf_event_free(event); + } + } + + return TRUE; +} + +void mf_peer_rfx_update(freerdp_peer* client) +{ + //check + mfInfo* mfi = mf_info_get_instance(); + + mf_info_find_invalid_region(mfi); + + if (mf_info_have_invalid_region(mfi) == false) { + return; + } + + + long width; + long height; + int pitch; + BYTE* dataBits = NULL; + + mf_info_getScreenData(mfi, &width, &height, &dataBits, &pitch); + + mf_info_clear_invalid_region(mfi); + + //encode + + wStream* s; + RFX_RECT rect; + rdpUpdate* update; + mfPeerContext* mfp; + SURFACE_BITS_COMMAND* cmd; + + update = client->update; + mfp = (mfPeerContext*) client->context; + cmd = &update->surface_bits_command; + + + s = mfp->s; + Stream_Clear(s); + Stream_SetPosition(s, 0); + + UINT32 x = mfi->invalid.x / mfi->scale; + UINT32 y = mfi->invalid.y / mfi->scale; + + rect.x = 0; + rect.y = 0; + rect.width = width; + rect.height = height; + + mfp->rfx_context->width = mfi->servscreen_width; + mfp->rfx_context->height = mfi->servscreen_height; + + rfx_compose_message(mfp->rfx_context, s, &rect, 1, + (BYTE*) dataBits, rect.width, rect.height, pitch); + + cmd->destLeft = x; + cmd->destTop = y; + cmd->destRight = x + rect.width; + cmd->destBottom = y + rect.height; + + + cmd->bpp = 32; + cmd->codecID = 3; + cmd->width = rect.width; + cmd->height = rect.height; + cmd->bitmapDataLength = Stream_GetPosition(s); + cmd->bitmapData = Stream_Buffer(s); + + //send + + update->SurfaceBits(update->context, cmd); + + //clean up... maybe? + +} + +/* Called when we have a new peer connecting */ +int mf_peer_context_new(freerdp_peer* client, mfPeerContext* context) +{ + context->info = mf_info_get_instance(); + context->rfx_context = rfx_context_new(TRUE); + context->rfx_context->mode = RLGR3; + context->rfx_context->width = client->settings->DesktopWidth; + context->rfx_context->height = client->settings->DesktopHeight; + rfx_context_set_pixel_format(context->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8); + + //context->nsc_context = nsc_context_new(); + //nsc_context_set_pixel_format(context->nsc_context, RDP_PIXEL_FORMAT_B8G8R8A8); + + context->s = Stream_New(NULL, 0xFFFF); + + context->vcm = WTSOpenServerA((LPSTR) client->context); + + mf_info_peer_register(context->info, context); + + return 0; +} + +/* Called after a peer disconnects */ +void mf_peer_context_free(freerdp_peer* client, mfPeerContext* context) +{ + if (context) + { + mf_info_peer_unregister(context->info, context); + + dispatch_suspend(info_timer); + + Stream_Free(context->s, TRUE); + + rfx_context_free(context->rfx_context); + //nsc_context_free(context->nsc_context); + +#ifdef CHANNEL_AUDIN_SERVER + if (context->audin) + audin_server_context_free(context->audin); +#endif + + //#ifdef CHANNEL_RDPSND_SERVER + mf_peer_rdpsnd_stop(); + if (context->rdpsnd) + rdpsnd_server_context_free(context->rdpsnd); + //#endif + + WTSCloseServer(context->vcm); + } +} + +/* Called when a new client connects */ +void mf_peer_init(freerdp_peer* client) +{ + client->ContextSize = sizeof(mfPeerContext); + client->ContextNew = (psPeerContextNew) mf_peer_context_new; + client->ContextFree = (psPeerContextFree) mf_peer_context_free; + freerdp_peer_context_new(client); + + info_event_queue = mf_event_queue_new(); + + info_queue = dispatch_queue_create("FreeRDP.update.timer", DISPATCH_QUEUE_SERIAL); + info_timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, info_queue); + + if(info_timer) + { + //DEBUG_WARN( "created timer\n"); + dispatch_source_set_timer(info_timer, DISPATCH_TIME_NOW, 42ull * NSEC_PER_MSEC, 100ull * NSEC_PER_MSEC); + dispatch_source_set_event_handler(info_timer, ^{ + //DEBUG_WARN( "dispatch\n"); + mfEvent* event = mf_event_new(MF_EVENT_TYPE_FRAME_TICK); + mf_event_push(info_event_queue, (mfEvent*) event);} + ); + dispatch_resume(info_timer); + } +} + +BOOL mf_peer_post_connect(freerdp_peer* client) +{ + mfPeerContext* context = (mfPeerContext*) client->context; + rdpSettings* settings = client->settings; + + mfInfo* mfi = mf_info_get_instance(); + mfi->scale = 1; + + //mfi->servscreen_width = 2880 / mfi->scale; + //mfi->servscreen_height = 1800 / mfi->scale; + UINT32 bitsPerPixel = 32; + + if ((settings->DesktopWidth != mfi->servscreen_width) || (settings->DesktopHeight != mfi->servscreen_height)) + { + + } + + settings->DesktopWidth = mfi->servscreen_width; + settings->DesktopHeight = mfi->servscreen_height; + settings->ColorDepth = bitsPerPixel; + + client->update->DesktopResize(client->update->context); + + mfi->mouse_down_left = FALSE; + mfi->mouse_down_right = FALSE; + mfi->mouse_down_other = FALSE; + + if (WTSVirtualChannelManagerIsChannelJoined(context->vcm, "rdpsnd")) + { + mf_peer_rdpsnd_init(context); /* Audio Output */ + } + + /* Dynamic Virtual Channels */ + +#ifdef CHANNEL_AUDIN_SERVER + mf_peer_audin_init(context); /* Audio Input */ +#endif + + return TRUE; +} + +BOOL mf_peer_activate(freerdp_peer* client) +{ + mfPeerContext* context = (mfPeerContext*) client->context; + + rfx_context_reset(context->rfx_context); + context->activated = TRUE; + + return TRUE; +} + +void mf_peer_synchronize_event(rdpInput* input, UINT32 flags) +{ + +} + +void mf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) +{ + UINT16 down = 0x4000; + //UINT16 up = 0x8000; + + bool state_down = FALSE; + + if (flags == down) + { + state_down = TRUE; + } +} + +void mf_peer_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) +{ + +} + +static void mf_peer_suppress_output(rdpContext* context, BYTE allow, RECTANGLE_16* area) +{ + +} + +void mf_peer_accepted(freerdp_listener* instance, freerdp_peer* client) +{ + pthread_t th; + + pthread_create(&th, 0, mf_peer_main_loop, client); + pthread_detach(th); +} + +void* mf_peer_main_loop(void* arg) +{ + int i; + int fds; + int max_fds; + int rcount; + void* rfds[32]; + fd_set rfds_set; + mfPeerContext* context; + freerdp_peer* client = (freerdp_peer*) arg; + + memset(rfds, 0, sizeof(rfds)); + + mf_peer_init(client); + + /* Initialize the real server settings here */ + client->settings->CertificateFile = _strdup("server.crt"); + client->settings->PrivateKeyFile = _strdup("server.key"); + client->settings->NlaSecurity = FALSE; + client->settings->RemoteFxCodec = TRUE; + client->settings->ColorDepth = 32; + client->settings->SuppressOutput = TRUE; + client->settings->RefreshRect = FALSE; + + client->PostConnect = mf_peer_post_connect; + client->Activate = mf_peer_activate; + + client->input->SynchronizeEvent = mf_peer_synchronize_event; + client->input->KeyboardEvent = mf_input_keyboard_event;//mf_peer_keyboard_event; + client->input->UnicodeKeyboardEvent = mf_peer_unicode_keyboard_event; + client->input->MouseEvent = mf_input_mouse_event; + client->input->ExtendedMouseEvent = mf_input_extended_mouse_event; + + //client->update->RefreshRect = mf_peer_refresh_rect; + client->update->SuppressOutput = mf_peer_suppress_output; + + client->Initialize(client); + context = (mfPeerContext*) client->context; + + + while (1) + { + rcount = 0; + + if (client->GetFileDescriptor(client, rfds, &rcount) != TRUE) + { + break; + } + + if (mf_peer_get_fds(client, rfds, &rcount) != TRUE) + { + break; + } + + WTSVirtualChannelManagerGetFileDescriptor(context->vcm, rfds, &rcount); + + max_fds = 0; + FD_ZERO(&rfds_set); + + for (i = 0; i < rcount; i++) + { + fds = (int)(long)(rfds[i]); + + if (fds > max_fds) + max_fds = fds; + + FD_SET(fds, &rfds_set); + } + + if (max_fds == 0) + break; + + if (select(max_fds + 1, &rfds_set, NULL, NULL, NULL) == -1) + { + /* these are not really errors */ + if (!((errno == EAGAIN) || + (errno == EWOULDBLOCK) || + (errno == EINPROGRESS) || + (errno == EINTR))) /* signal occurred */ + { + break; + } + } + + if (client->CheckFileDescriptor(client) != TRUE) + { + break; + } + + if ((mf_peer_check_fds(client)) != TRUE) + { + break; + } + + if (WTSVirtualChannelManagerCheckFileDescriptor(context->vcm) != TRUE) + { + break; + } + } + + client->Disconnect(client); + freerdp_peer_context_free(client); + freerdp_peer_free(client); + + return NULL; +} diff --git a/server/Mac/mf_rdpsnd.c b/server/Mac/mf_rdpsnd.c index 5e4b00230..1580a437d 100644 --- a/server/Mac/mf_rdpsnd.c +++ b/server/Mac/mf_rdpsnd.c @@ -21,14 +21,14 @@ #include "config.h" #endif -#include -#include - #include #include "mf_info.h" #include "mf_rdpsnd.h" +#include +#define TAG SERVER_TAG("mac") + AQRecorderState recorderState; static const AUDIO_FORMAT supported_audio_formats[] = @@ -46,7 +46,12 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context) //we should actually loop through the list of client formats here //and see if we can send the client something that it supports... +<<<<<<< HEAD +======= + WLog_DBG(TAG, "Client supports the following %d formats: ", context->num_client_formats); + +>>>>>>> f7d21655fa2552c8813be9d2d5bac4bbaa5abf6a for (i = 0; i < context->num_client_formats; i++) { /* TODO: improve the way we agree on a format */ @@ -56,6 +61,10 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context) (context->client_formats[i].nChannels == context->server_formats[j].nChannels) && (context->client_formats[i].nSamplesPerSec == context->server_formats[j].nSamplesPerSec)) { +<<<<<<< HEAD +======= + WLog_DBG(TAG, "agreed on format!"); +>>>>>>> f7d21655fa2552c8813be9d2d5bac4bbaa5abf6a formatAgreed = TRUE; agreedFormat = (AUDIO_FORMAT*)&context->server_formats[j]; break; @@ -68,9 +77,13 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context) if (formatAgreed == FALSE) { +<<<<<<< HEAD +======= + WLog_DBG(TAG, "Could not agree on a audio format with the server"); +>>>>>>> f7d21655fa2552c8813be9d2d5bac4bbaa5abf6a return; } - + context->SelectFormat(context, i); context->SetVolume(context, 0x7FFF, 0x7FFF); @@ -110,7 +123,11 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context) if (status != noErr) { +<<<<<<< HEAD +======= + WLog_DBG(TAG, "Failed to create a new Audio Queue. Status code: %d", status); +>>>>>>> f7d21655fa2552c8813be9d2d5bac4bbaa5abf6a } UInt32 dataFormatSize = sizeof (recorderState.dataFormat); @@ -206,7 +223,11 @@ void mf_peer_rdpsnd_input_callback (void *inUserD if (status != noErr) { +<<<<<<< HEAD +======= + WLog_DBG(TAG, "AudioQueueEnqueueBuffer() returned status = %d", status); +>>>>>>> f7d21655fa2552c8813be9d2d5bac4bbaa5abf6a } } diff --git a/server/Mac/mfreerdp.c b/server/Mac/mfreerdp.c index b20c76451..ad6233c5c 100644 --- a/server/Mac/mfreerdp.c +++ b/server/Mac/mfreerdp.c @@ -121,4 +121,3 @@ int main(int argc, char* argv[]) return 0; } - diff --git a/server/Sample/CMakeLists.txt b/server/Sample/CMakeLists.txt index 1252e3f7f..6e3b16077 100644 --- a/server/Sample/CMakeLists.txt +++ b/server/Sample/CMakeLists.txt @@ -31,13 +31,7 @@ set(${MODULE_PREFIX}_SRCS add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-server) - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-core freerdp-utils freerdp-codec freerdp-primitives) - -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/server/Sample/sf_audin.c b/server/Sample/sf_audin.c index 5edc16357..1fdf0f1fe 100644 --- a/server/Sample/sf_audin.c +++ b/server/Sample/sf_audin.c @@ -21,12 +21,15 @@ #include "config.h" #endif -#include + #include "sfreerdp.h" #include "sf_audin.h" +#include +#define TAG SERVER_TAG("sample") + static const AUDIO_FORMAT test_audio_formats[] = { { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, NULL }, @@ -35,19 +38,19 @@ static const AUDIO_FORMAT test_audio_formats[] = static void sf_peer_audin_opening(audin_server_context* context) { - DEBUG_MSG("AUDIN opening.\n"); + WLog_DBG(TAG, "AUDIN opening."); /* Simply choose the first format supported by the client. */ context->SelectFormat(context, 0); } static void sf_peer_audin_open_result(audin_server_context* context, UINT32 result) { - DEBUG_MSG("AUDIN open result %d.\n", result); + WLog_DBG(TAG, "AUDIN open result %d.", result); } static void sf_peer_audin_receive_samples(audin_server_context* context, const void* buf, int nframes) { - DEBUG_MSG("AUDIN receive %d frames.\n", nframes); + WLog_DBG(TAG, "AUDIN receive %d frames.", nframes); } void sf_peer_audin_init(testPeerContext* context) diff --git a/server/Sample/sf_rdpsnd.c b/server/Sample/sf_rdpsnd.c index 3b5ee0126..0475b9f9a 100644 --- a/server/Sample/sf_rdpsnd.c +++ b/server/Sample/sf_rdpsnd.c @@ -22,10 +22,13 @@ #endif #include -#include + #include "sf_rdpsnd.h" +#include +#define TAG SERVER_TAG("sample") + static const AUDIO_FORMAT test_audio_formats[] = { { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, NULL }, @@ -34,7 +37,7 @@ static const AUDIO_FORMAT test_audio_formats[] = static void sf_peer_rdpsnd_activated(RdpsndServerContext* context) { - DEBUG_MSG("RDPSND Activated\n"); + WLog_DBG(TAG, "RDPSND Activated"); } BOOL sf_peer_rdpsnd_init(testPeerContext* context) diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index 784bba1e2..c39b9566c 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -33,7 +33,7 @@ #include #include -#include + #include #include @@ -45,6 +45,9 @@ #include "sfreerdp.h" +#include +#define TAG SERVER_TAG("sample") + #define SAMPLE_SERVER_USE_CLIENT_RESOLUTION 1 #define SAMPLE_SERVER_DEFAULT_WIDTH 1024 #define SAMPLE_SERVER_DEFAULT_HEIGHT 768 @@ -342,7 +345,7 @@ static BOOL test_sleep_tsdiff(UINT32 *old_sec, UINT32 *old_usec, UINT32 new_sec, if ((sec < 0) || ((sec == 0) && (usec < 0))) { - DEBUG_MSG("Invalid time stamp detected.\n"); + WLog_ERR(TAG, "Invalid time stamp detected."); return FALSE; } @@ -451,8 +454,7 @@ static void* tf_debug_channel_thread_func(void* arg) } Stream_SetPosition(s, BytesReturned); - - DEBUG_MSG("got %lu bytes\n", BytesReturned); + WLog_DBG(TAG, "got %lu bytes", BytesReturned); } Stream_Free(s, TRUE); @@ -470,31 +472,28 @@ BOOL tf_peer_post_connect(freerdp_peer* client) * The server may start sending graphics output and receiving keyboard/mouse input after this * callback returns. */ - - DEBUG_MSG("Client %s is activated (osMajorType %d osMinorType %d)", client->local ? "(local)" : client->hostname, - client->settings->OsMajorType, client->settings->OsMinorType); + WLog_DBG(TAG, "Client %s is activated (osMajorType %d osMinorType %d)", client->local ? "(local)" : client->hostname, + client->settings->OsMajorType, client->settings->OsMinorType); if (client->settings->AutoLogonEnabled) { - DEBUG_MSG(" and wants to login automatically as %s\\%s", - client->settings->Domain ? client->settings->Domain : "", - client->settings->Username); - + WLog_DBG(TAG, " and wants to login automatically as %s\\%s", + client->settings->Domain ? client->settings->Domain : "", + client->settings->Username); /* A real server may perform OS login here if NLA is not executed previously. */ } - DEBUG_MSG("\n"); - - DEBUG_MSG("Client requested desktop: %dx%dx%d\n", - client->settings->DesktopWidth, client->settings->DesktopHeight, client->settings->ColorDepth); + WLog_DBG(TAG, ""); + WLog_DBG(TAG, "Client requested desktop: %dx%dx%d", + client->settings->DesktopWidth, client->settings->DesktopHeight, client->settings->ColorDepth); #if (SAMPLE_SERVER_USE_CLIENT_RESOLUTION == 1) context->rfx_context->width = client->settings->DesktopWidth; context->rfx_context->height = client->settings->DesktopHeight; - DEBUG_MSG("Using resolution requested by client.\n"); + WLog_DBG(TAG, "Using resolution requested by client."); #else client->settings->DesktopWidth = context->rfx_context->width; client->settings->DesktopHeight = context->rfx_context->height; - DEBUG_MSG("Resizing client to %dx%d\n", client->settings->DesktopWidth, client->settings->DesktopHeight); + WLog_DBG(TAG, "Resizing client to %dx%d", client->settings->DesktopWidth, client->settings->DesktopHeight); client->update->DesktopResize(client->update->context); #endif @@ -507,8 +506,7 @@ BOOL tf_peer_post_connect(freerdp_peer* client) if (context->debug_channel != NULL) { - DEBUG_MSG("Open channel rdpdbg.\n"); - + WLog_DBG(TAG, "Open channel rdpdbg."); context->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL); context->debug_channel_thread = CreateThread(NULL, 0, @@ -562,7 +560,7 @@ BOOL tf_peer_activate(freerdp_peer* client) void tf_peer_synchronize_event(rdpInput* input, UINT32 flags) { - DEBUG_MSG("Client sent a synchronize event (flags:0x%X)\n", flags); + WLog_DBG(TAG, "Client sent a synchronize event (flags:0x%X)", flags); } void tf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) @@ -570,8 +568,7 @@ void tf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) freerdp_peer* client = input->context->peer; rdpUpdate* update = client->update; testPeerContext* context = (testPeerContext*) input->context; - - DEBUG_MSG("Client sent a keyboard event (flags:0x%X code:0x%X)\n", flags, code); + WLog_DBG(TAG, "Client sent a keyboard event (flags:0x%X code:0x%X)", flags, code); if ((flags & 0x4000) && code == 0x22) /* 'g' key */ { @@ -623,30 +620,28 @@ void tf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) void tf_peer_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) { - DEBUG_MSG("Client sent a unicode keyboard event (flags:0x%X code:0x%X)\n", flags, code); + WLog_DBG(TAG, "Client sent a unicode keyboard event (flags:0x%X code:0x%X)", flags, code); } void tf_peer_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) { - //printf("Client sent a mouse event (flags:0x%X pos:%d,%d)\n", flags, x, y); - + //WLog_DBG(TAG, "Client sent a mouse event (flags:0x%X pos:%d,%d)", flags, x, y); test_peer_draw_icon(input->context->peer, x + 10, y); } void tf_peer_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) { - //printf("Client sent an extended mouse event (flags:0x%X pos:%d,%d)\n", flags, x, y); + //WLog_DBG(TAG, "Client sent an extended mouse event (flags:0x%X pos:%d,%d)", flags, x, y); } static void tf_peer_refresh_rect(rdpContext* context, BYTE count, RECTANGLE_16* areas) { BYTE i; - - DEBUG_MSG("Client requested to refresh:\n"); + WLog_DBG(TAG, "Client requested to refresh:"); for (i = 0; i < count; i++) { - DEBUG_MSG(" (%d, %d) (%d, %d)\n", areas[i].left, areas[i].top, areas[i].right, areas[i].bottom); + WLog_DBG(TAG, " (%d, %d) (%d, %d)", areas[i].left, areas[i].top, areas[i].right, areas[i].bottom); } } @@ -654,11 +649,11 @@ static void tf_peer_suppress_output(rdpContext* context, BYTE allow, RECTANGLE_1 { if (allow > 0) { - DEBUG_MSG("Client restore output (%d, %d) (%d, %d).\n", area->left, area->top, area->right, area->bottom); + WLog_DBG(TAG, "Client restore output (%d, %d) (%d, %d).", area->left, area->top, area->right, area->bottom); } else { - DEBUG_MSG("Client minimized and suppress output.\n"); + WLog_DBG(TAG, "Client minimized and suppress output."); } } @@ -700,8 +695,7 @@ static void* test_peer_mainloop(void* arg) client->Initialize(client); context = (testPeerContext*) client->context; - - DEBUG_MSG("We've got a client %s\n", client->local ? "(local)" : client->hostname); + WLog_INFO(TAG, "We've got a client %s", client->local ? "(local)" : client->hostname); while (1) { @@ -710,7 +704,7 @@ static void* test_peer_mainloop(void* arg) memset(rfds, 0, sizeof(rfds)); if (client->GetFileDescriptor(client, rfds, &rcount) != TRUE) { - DEBUG_MSG("Failed to get FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to get FreeRDP file descriptor"); break; } @@ -744,7 +738,7 @@ static void* test_peer_mainloop(void* arg) (wsa_error == WSAEINPROGRESS) || (wsa_error == WSAEINTR))) { - DEBUG_MSG("select failed (WSAGetLastError: %d)\n", wsa_error); + WLog_ERR(TAG, "select failed (WSAGetLastError: %d)", wsa_error); break; } #else @@ -754,7 +748,7 @@ static void* test_peer_mainloop(void* arg) (errno == EINPROGRESS) || (errno == EINTR))) /* signal occurred */ { - DEBUG_MSG("select failed (errno: %d)\n", errno); + WLog_ERR(TAG, "select failed (errno: %d)", errno); break; } #endif @@ -767,8 +761,7 @@ static void* test_peer_mainloop(void* arg) break; } - DEBUG_MSG("Client %s disconnected.\n", client->local ? "(local)" : client->hostname); - + WLog_INFO(TAG, "Client %s disconnected.", client->local ? "(local)" : client->hostname); client->Disconnect(client); freerdp_peer_context_free(client); freerdp_peer_free(client); @@ -800,7 +793,7 @@ static void test_server_mainloop(freerdp_listener* instance) memset(rfds, 0, sizeof(rfds)); if (instance->GetFileDescriptor(instance, rfds, &rcount) != TRUE) { - DEBUG_MSG("Failed to get FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to get FreeRDP file descriptor"); break; } @@ -828,14 +821,14 @@ static void test_server_mainloop(freerdp_listener* instance) (errno == EINPROGRESS) || (errno == EINTR))) /* signal occurred */ { - DEBUG_MSG("select failed\n"); + WLog_ERR(TAG, "select failed"); break; } } if (instance->CheckFileDescriptor(instance) != TRUE) { - DEBUG_MSG("Failed to check FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to check FreeRDP file descriptor"); break; } } diff --git a/server/Windows/CMakeLists.txt b/server/Windows/CMakeLists.txt index 013c2a797..93336a5b6 100644 --- a/server/Windows/CMakeLists.txt +++ b/server/Windows/CMakeLists.txt @@ -75,12 +75,7 @@ if(CMAKE_WINDOWS_VERSION STREQUAL "WIN8") endif() set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} dsound) -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-server) - -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-core freerdp-utils freerdp-codec freerdp-primitives) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-server freerdp) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/server/Windows/cli/wfreerdp.c b/server/Windows/cli/wfreerdp.c index 48a5cd900..5599d13b1 100644 --- a/server/Windows/cli/wfreerdp.c +++ b/server/Windows/cli/wfreerdp.c @@ -32,14 +32,16 @@ #include "wfreerdp.h" +#include +#define TAG SERVER_TAG("windows") + int IDcount = 0; BOOL CALLBACK moncb(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) { - DEBUG_MSG("%d\t(%d, %d), (%d, %d)\n", - IDcount, lprcMonitor->left, lprcMonitor->top, - lprcMonitor->right, lprcMonitor->bottom); - + WLog_DBG(TAG, "%d\t(%d, %d), (%d, %d)", + IDcount, lprcMonitor->left, lprcMonitor->top, + lprcMonitor->right, lprcMonitor->bottom); IDcount++; return TRUE; @@ -67,10 +69,9 @@ int main(int argc, char* argv[]) int height; int bpp; int i; + WLog_INFO(TAG, "Detecting screens..."); + WLog_INFO(TAG, "ID\tResolution\t\tName (Interface)"); - _tprintf(_T("Detecting screens...\n")); - _tprintf(_T("\nID\tResolution\t\tName (Interface)\n\n")); - for (i=0; ; i++) { if (get_screen_info(i, name, &width, &height, &bpp) != 0) @@ -78,8 +79,8 @@ int main(int argc, char* argv[]) if ( (width * height * bpp) == 0 ) continue; - _tprintf(_T("%d\t%dx%dx%d\t"), i, width, height, bpp); - _tprintf(_T("%s\n"), name); + WLog_INFO(TAG, "%d\t%dx%dx%d\t", i, width, height, bpp); + WLog_INFO(TAG, "%s", name); } else { @@ -92,11 +93,10 @@ int main(int argc, char* argv[]) int vscreen_h; vscreen_w = GetSystemMetrics(SM_CXVIRTUALSCREEN); vscreen_h = GetSystemMetrics(SM_CYVIRTUALSCREEN); - - DEBUG_MSG("\n"); + WLog_INFO(TAG, ""); EnumDisplayMonitors(NULL, NULL, moncb, 0); IDcount = 0; - DEBUG_MSG("\nVirtual Screen = %dx%d\n", vscreen_w, vscreen_h); + WLog_INFO(TAG, "Virtual Screen = %dx%d", vscreen_w, vscreen_h); } return 0; @@ -108,7 +108,7 @@ int main(int argc, char* argv[]) index++; if (index == argc) { - DEBUG_MSG("missing screen id parameter\n"); + WLog_INFO(TAG, "missing screen id parameter"); return 0; } @@ -130,10 +130,9 @@ int main(int argc, char* argv[]) int height; int bpp; int i; - - _tprintf(_T("screen id not provided. attempting to detect...\n")); - _tprintf(_T("Detecting screens...\n")); - _tprintf(_T("\nID\tResolution\t\tName (Interface)\n\n")); + WLog_INFO(TAG, "screen id not provided. attempting to detect..."); + WLog_INFO(TAG, "Detecting screens..."); + WLog_INFO(TAG, "ID\tResolution\t\tName (Interface)"); for (i=0; ; i++) { @@ -142,8 +141,8 @@ int main(int argc, char* argv[]) if ( (width * height * bpp) == 0 ) continue; - _tprintf(_T("%d\t%dx%dx%d\t"), i, width, height, bpp); - _tprintf(_T("%s\n"), name); + WLog_INFO(TAG, "%d\t%dx%dx%d\t", i, width, height, bpp); + WLog_INFO(TAG, "%s", name); set_screen_id(i); break; } @@ -154,14 +153,11 @@ int main(int argc, char* argv[]) } } - DEBUG_MSG("Starting server\n"); - + WLog_INFO(TAG, "Starting server"); wfreerdp_server_start(server); WaitForSingleObject(server->thread, INFINITE); - - DEBUG_MSG("Stopping server\n"); - + WLog_INFO(TAG, "Stopping server"); wfreerdp_server_stop(server); wfreerdp_server_free(server); diff --git a/server/Windows/wf_directsound.c b/server/Windows/wf_directsound.c index 74c66adb9..37c31205d 100644 --- a/server/Windows/wf_directsound.c +++ b/server/Windows/wf_directsound.c @@ -14,6 +14,9 @@ #include #include +#include +#define TAG SERVER_TAG("windows") + IDirectSoundCapture8* cap; IDirectSoundCaptureBuffer8* capBuf; DSCBUFFERDESC dscbd; @@ -34,18 +37,16 @@ int wf_directsound_activate(RdpsndServerContext* context) LPDIRECTSOUNDCAPTUREBUFFER pDSCB; wfi = wf_info_get_instance(); - - DEBUG_MSG("RDPSND (direct sound) Activated\n"); - + WLog_DBG(TAG, "RDPSND (direct sound) Activated"); hr = DirectSoundCaptureCreate8(NULL, &cap, NULL); if (FAILED(hr)) { - _tprintf(_T("Failed to create sound capture device\n")); + WLog_ERR(TAG, "Failed to create sound capture device"); return 1; } - _tprintf(_T("Created sound capture device\n")); + WLog_INFO(TAG, "Created sound capture device"); dscbd.dwSize = sizeof(DSCBUFFERDESC); dscbd.dwFlags = 0; dscbd.dwBufferBytes = wfi->agreed_format->nAvgBytesPerSec; @@ -58,18 +59,17 @@ int wf_directsound_activate(RdpsndServerContext* context) if (FAILED(hr)) { - _tprintf(_T("Failed to create capture buffer\n")); + WLog_ERR(TAG, "Failed to create capture buffer"); } - _tprintf(_T("Created capture buffer")); + WLog_INFO(TAG, "Created capture buffer"); hr = pDSCB->lpVtbl->QueryInterface(pDSCB, &IID_IDirectSoundCaptureBuffer8, (LPVOID*)&capBuf); if (FAILED(hr)) { - _tprintf(_T("Failed to QI capture buffer\n")); + WLog_ERR(TAG, "Failed to QI capture buffer"); } - _tprintf(_T("Created IDirectSoundCaptureBuffer8\n")); - pDSCB->lpVtbl->Release(pDSCB); - + WLog_INFO(TAG, "Created IDirectSoundCaptureBuffer8"); + pDSCB->lpVtbl->Release(pDSCB); lastPos = 0; CreateThread(NULL, 0, wf_rdpsnd_directsound_thread, latestPeer, 0, NULL); @@ -98,14 +98,13 @@ DWORD WINAPI wf_rdpsnd_directsound_thread(LPVOID lpParam) context = (wfPeerContext*)lpParam; rate = 1000 / 24; - - _tprintf(_T("Trying to start capture\n")); + WLog_INFO(TAG, "Trying to start capture"); hr = capBuf->lpVtbl->Start(capBuf, DSCBSTART_LOOPING); if (FAILED(hr)) { - _tprintf(_T("Failed to start capture\n")); + WLog_ERR(TAG, "Failed to start capture"); } - _tprintf(_T("Capture started\n")); + WLog_INFO(TAG, "Capture started"); while (1) { @@ -132,7 +131,7 @@ DWORD WINAPI wf_rdpsnd_directsound_thread(LPVOID lpParam) hr = capBuf->lpVtbl->GetCurrentPosition(capBuf, NULL, &dwReadPos); if (FAILED(hr)) { - _tprintf(_T("Failed to get read pos\n")); + WLog_ERR(TAG, "Failed to get read pos"); wf_rdpsnd_unlock(); break; } @@ -140,9 +139,9 @@ DWORD WINAPI wf_rdpsnd_directsound_thread(LPVOID lpParam) lLockSize = dwReadPos - lastPos;//dscbd.dwBufferBytes; if (lLockSize < 0) lLockSize += dscbd.dwBufferBytes; - //printf("Last, read, lock = [%d, %d, %d]\n", lastPos, dwReadPos, lLockSize); + //WLog_DBG(TAG, "Last, read, lock = [%d, %d, %d]\n", lastPos, dwReadPos, lLockSize); - if (lLockSize == 0) + if (lLockSize == 0) { wf_rdpsnd_unlock(); continue; @@ -152,7 +151,7 @@ DWORD WINAPI wf_rdpsnd_directsound_thread(LPVOID lpParam) hr = capBuf->lpVtbl->Lock(capBuf, lastPos, lLockSize, &pbCaptureData, &dwCaptureLength, &pbCaptureData2, &dwCaptureLength2, 0L); if (FAILED(hr)) { - _tprintf(_T("Failed to lock sound capture buffer\n")); + WLog_ERR(TAG, "Failed to lock sound capture buffer"); wf_rdpsnd_unlock(); break; } @@ -169,7 +168,7 @@ DWORD WINAPI wf_rdpsnd_directsound_thread(LPVOID lpParam) hr = capBuf->lpVtbl->Unlock(capBuf, pbCaptureData, dwCaptureLength, pbCaptureData2, dwCaptureLength2); if (FAILED(hr)) { - _tprintf(_T("Failed to unlock sound capture buffer\n")); + WLog_ERR(TAG, "Failed to unlock sound capture buffer"); wf_rdpsnd_unlock(); return 0; } @@ -186,13 +185,14 @@ DWORD WINAPI wf_rdpsnd_directsound_thread(LPVOID lpParam) } - _tprintf(_T("Trying to stop sound capture\n")); + WLog_INFO(TAG, "Trying to stop sound capture"); hr = capBuf->lpVtbl->Stop(capBuf); if (FAILED(hr)) { - _tprintf(_T("Failed to stop capture\n")); + WLog_ERR(TAG, "Failed to stop capture"); } - _tprintf(_T("Capture stopped\n")); + + WLog_INFO(TAG, "Capture stopped"); capBuf->lpVtbl->Release(capBuf); cap->lpVtbl->Release(cap); diff --git a/server/Windows/wf_dxgi.c b/server/Windows/wf_dxgi.c index fdaacca2d..a2801f665 100644 --- a/server/Windows/wf_dxgi.c +++ b/server/Windows/wf_dxgi.c @@ -33,6 +33,9 @@ #include #include "wf_dxgi.h" +#include +#define TAG SERVER_TAG("windows") + /* Driver types supported */ D3D_DRIVER_TYPE DriverTypes[] = { @@ -94,12 +97,12 @@ int wf_dxgi_createDevice(wfInfo* wfi) if (SUCCEEDED(status)) break; - _tprintf(_T("D3D11CreateDevice returned [%d] for Driver Type %d\n"), status, DriverTypes[DriverTypeIndex]); + WLog_INFO(TAG, "D3D11CreateDevice returned [%d] for Driver Type %d", status, DriverTypes[DriverTypeIndex]); } if (FAILED(status)) { - _tprintf(_T("Failed to create device in InitializeDx\n")); + WLog_ERR(TAG, "Failed to create device in InitializeDx"); return 1; } @@ -121,7 +124,7 @@ int wf_dxgi_getDuplication(wfInfo* wfi) if (FAILED(status)) { - _tprintf(_T("Failed to get QI for DXGI Device\n")); + WLog_ERR(TAG, "Failed to get QI for DXGI Device"); return 1; } @@ -131,7 +134,7 @@ int wf_dxgi_getDuplication(wfInfo* wfi) if (FAILED(status)) { - _tprintf(_T("Failed to get parent DXGI Adapter\n")); + WLog_ERR(TAG, "Failed to get parent DXGI Adapter"); return 1; } @@ -146,11 +149,11 @@ int wf_dxgi_getDuplication(wfInfo* wfi) if (FAILED(status)) { - _tprintf(_T("Failed to get description\n")); + WLog_ERR(TAG, "Failed to get description"); return 1; } - _tprintf(_T("Output %d: [%s] [%d]\n"), i, pDesc->DeviceName, pDesc->AttachedToDesktop); + WLog_INFO(TAG, "Output %d: [%s] [%d]", i, pDesc->DeviceName, pDesc->AttachedToDesktop); if (pDesc->AttachedToDesktop) dTop = i; @@ -167,7 +170,7 @@ int wf_dxgi_getDuplication(wfInfo* wfi) if (FAILED(status)) { - _tprintf(_T("Failed to get output\n")); + WLog_ERR(TAG, "Failed to get output"); return 1; } @@ -177,7 +180,7 @@ int wf_dxgi_getDuplication(wfInfo* wfi) if (FAILED(status)) { - _tprintf(_T("Failed to get IDXGIOutput1\n")); + WLog_ERR(TAG, "Failed to get IDXGIOutput1"); return 1; } @@ -189,11 +192,11 @@ int wf_dxgi_getDuplication(wfInfo* wfi) { if (status == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE) { - _tprintf(_T("There is already the maximum number of applications using the Desktop Duplication API running, please close one of those applications and then try again.\n")); + WLog_ERR(TAG, "There is already the maximum number of applications using the Desktop Duplication API running, please close one of those applications and then try again.")); return 1; } - - _tprintf(_T("Failed to get duplicate output. Status = %#X\n"), status); + + WLog_ERR(TAG, "Failed to get duplicate output. Status = %#X", status); return 1; } @@ -265,8 +268,9 @@ int wf_dxgi_nextFrame(wfInfo* wfi, UINT timeout) { if (status == DXGI_ERROR_ACCESS_LOST) { - _tprintf(_T("Failed to acquire next frame with status=%#X\n"), status); - _tprintf(_T("Trying to reinitialize due to ACCESS LOST...")); + WLog_ERR(TAG, "Failed to acquire next frame with status=%#X", status); + WLog_ERR(TAG, "Trying to reinitialize due to ACCESS LOST..."); + if (gAcquiredDesktopImage) { gAcquiredDesktopImage->lpVtbl->Release(gAcquiredDesktopImage); @@ -285,13 +289,12 @@ int wf_dxgi_nextFrame(wfInfo* wfi, UINT timeout) } else { - _tprintf(_T("Failed to acquire next frame with status=%#X\n"), status); - + WLog_ERR(TAG, "Failed to acquire next frame with status=%#X", status); status = gOutputDuplication->lpVtbl->ReleaseFrame(gOutputDuplication); if (FAILED(status)) { - _tprintf(_T("Failed to release frame with status=%d\n"), status); + WLog_ERR(TAG, "Failed to release frame with status=%d", status); } return 1; @@ -315,7 +318,7 @@ int wf_dxgi_nextFrame(wfInfo* wfi, UINT timeout) if (FAILED(status)) { - _tprintf(_T("Failed to release frame with status=%d\n"), status); + WLog_ERR(TAG, "Failed to release frame with status=%d", status); } } @@ -352,7 +355,7 @@ int wf_dxgi_getPixelData(wfInfo* wfi, BYTE** data, int* pitch, RECT* invalid) if (FAILED(status)) { - _tprintf(_T("Failed to create staging surface\n")); + WLog_ERR(TAG, "Failed to create staging surface"); exit(1); return 1; } @@ -363,7 +366,7 @@ int wf_dxgi_getPixelData(wfInfo* wfi, BYTE** data, int* pitch, RECT* invalid) if (FAILED(status)) { - _tprintf(_T("Failed to QI staging surface\n")); + WLog_ERR(TAG, "Failed to QI staging surface"); exit(1); return 1; } @@ -372,7 +375,7 @@ int wf_dxgi_getPixelData(wfInfo* wfi, BYTE** data, int* pitch, RECT* invalid) if (FAILED(status)) { - _tprintf(_T("Failed to map staging surface\n")); + WLog_ERR(TAG, "Failed to map staging surface"); exit(1); return 1; } @@ -397,7 +400,7 @@ int wf_dxgi_releasePixelData(wfInfo* wfi) if (FAILED(status)) { - _tprintf(_T("Failed to release frame\n")); + WLog_ERR(TAG, "Failed to release frame"); return 1; } @@ -438,7 +441,7 @@ int wf_dxgi_getInvalidRegion(RECT* invalid) if (!DataBuffer) { DataBufferSize = 0; - _tprintf(_T("Failed to allocate memory for metadata\n")); + WLog_ERR(TAG, "Failed to allocate memory for metadata"); exit(1); } @@ -451,7 +454,7 @@ int wf_dxgi_getInvalidRegion(RECT* invalid) if (FAILED(status)) { - _tprintf(_T("Failed to get frame move rects\n")); + WLog_ERR(TAG, "Failed to get frame move rects"); return 1; } @@ -462,7 +465,7 @@ int wf_dxgi_getInvalidRegion(RECT* invalid) if (FAILED(status)) { - _tprintf(_T("Failed to get frame dirty rects\n")); + WLog_ERR(TAG, "Failed to get frame dirty rects"); return 1; } dirty = BufSize / sizeof(RECT); diff --git a/server/Windows/wf_info.c b/server/Windows/wf_info.c index 4300c5513..f8263e1bb 100644 --- a/server/Windows/wf_info.c +++ b/server/Windows/wf_info.c @@ -1,47 +1,50 @@ -/** -* FreeRDP: A Remote Desktop Protocol Client -* FreeRDP Windows Server -* -* Copyright 2012 Corey Clayton -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ +/** +* FreeRDP: A Remote Desktop Protocol Client +* FreeRDP Windows Server +* +* Copyright 2012 Corey Clayton +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include + +#include "wf_info.h" +#include "wf_update.h" +#include "wf_mirage.h" +#include "wf_dxgi.h" + +#include +#define TAG SERVER_TAG("windows") + +static wfInfo* wfInfoInstance = NULL; +static int _IDcount = 0; + +int wf_info_lock(wfInfo* wfi) +{ + DWORD dRes; -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include -#include - -#include "wf_info.h" -#include "wf_update.h" -#include "wf_mirage.h" -#include "wf_dxgi.h" - -static wfInfo* wfInfoInstance = NULL; -static int _IDcount = 0; - -int wf_info_lock(wfInfo* wfi) -{ - DWORD dRes; - - dRes = WaitForSingleObject(wfi->mutex, INFINITE); - - switch (dRes) - { + dRes = WaitForSingleObject(wfi->mutex, INFINITE); + + switch (dRes) + { case WAIT_ABANDONED: case WAIT_OBJECT_0: return TRUE; @@ -52,22 +55,22 @@ int wf_info_lock(wfInfo* wfi) break; case WAIT_FAILED: - DEBUG_WARN("wf_info_lock failed with 0x%08X\n", GetLastError()); + WLog_ERR(TAG, "wf_info_lock failed with 0x%08X", GetLastError()); return -1; break; - } + } + + return -1; +} + +int wf_info_try_lock(wfInfo* wfi, DWORD dwMilliseconds) +{ + DWORD dRes; - return -1; -} - -int wf_info_try_lock(wfInfo* wfi, DWORD dwMilliseconds) -{ - DWORD dRes; - - dRes = WaitForSingleObject(wfi->mutex, dwMilliseconds); - - switch (dRes) - { + dRes = WaitForSingleObject(wfi->mutex, dwMilliseconds); + + switch (dRes) + { case WAIT_ABANDONED: case WAIT_OBJECT_0: return TRUE; @@ -78,293 +81,291 @@ int wf_info_try_lock(wfInfo* wfi, DWORD dwMilliseconds) break; case WAIT_FAILED: - DEBUG_WARN("wf_info_try_lock failed with 0x%08X\n", GetLastError()); + WLog_ERR(TAG, "wf_info_try_lock failed with 0x%08X", GetLastError()); return -1; break; - } + } + + return -1; +} + +int wf_info_unlock(wfInfo* wfi) +{ + if (ReleaseMutex(wfi->mutex) == 0) + { + WLog_ERR(TAG, "wf_info_unlock failed with 0x%08X", GetLastError()); + return -1; + } + + return TRUE; +} + +wfInfo* wf_info_init() +{ + wfInfo* wfi; - return -1; -} - -int wf_info_unlock(wfInfo* wfi) -{ - if (ReleaseMutex(wfi->mutex) == 0) - { - DEBUG_WARN("wf_info_unlock failed with 0x%08X\n", GetLastError()); - return -1; - } - - return TRUE; -} - -wfInfo* wf_info_init() -{ - wfInfo* wfi; - - wfi = (wfInfo*) malloc(sizeof(wfInfo)); - ZeroMemory(wfi, sizeof(wfInfo)); - - if (wfi != NULL) - { - HKEY hKey; - LONG status; - DWORD dwType; - DWORD dwSize; - DWORD dwValue; - - wfi->mutex = CreateMutex(NULL, FALSE, NULL); + wfi = (wfInfo*) malloc(sizeof(wfInfo)); + ZeroMemory(wfi, sizeof(wfInfo)); + + if (wfi != NULL) + { + HKEY hKey; + LONG status; + DWORD dwType; + DWORD dwSize; + DWORD dwValue; + wfi->mutex = CreateMutex(NULL, FALSE, NULL); + if (wfi->mutex == NULL) - { - _tprintf(_T("CreateMutex error: %d\n"), GetLastError()); - } + { + WLog_ERR(TAG, "CreateMutex error: %d", GetLastError()); + } + + wfi->updateSemaphore = CreateSemaphore(NULL, 0, 32, NULL); - wfi->updateSemaphore = CreateSemaphore(NULL, 0, 32, NULL); + wfi->updateThread = CreateThread(NULL, 0, wf_update_thread, wfi, CREATE_SUSPENDED, NULL); + + if (!wfi->updateThread) + { + WLog_ERR(TAG, "Failed to create update thread"); + } + + wfi->peers = (freerdp_peer**) malloc(sizeof(freerdp_peer*) * WF_INFO_MAXPEERS); + memset(wfi->peers, 0, sizeof(freerdp_peer*) * WF_INFO_MAXPEERS); - wfi->updateThread = CreateThread(NULL, 0, wf_update_thread, wfi, CREATE_SUSPENDED, NULL); + //Set FPS + wfi->framesPerSecond = WF_INFO_DEFAULT_FPS; - if (!wfi->updateThread) - { - _tprintf(_T("Failed to create update thread\n")); - } - - wfi->peers = (freerdp_peer**) malloc(sizeof(freerdp_peer*) * WF_INFO_MAXPEERS); - memset(wfi->peers, 0, sizeof(freerdp_peer*) * WF_INFO_MAXPEERS); - - //Set FPS - wfi->framesPerSecond = WF_INFO_DEFAULT_FPS; - - status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\FreeRDP\\Server"), 0, KEY_READ | KEY_WOW64_64KEY, &hKey); - if (status == ERROR_SUCCESS) - { - if (RegQueryValueEx(hKey, _T("FramesPerSecond"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS) + status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\FreeRDP\\Server"), 0, KEY_READ | KEY_WOW64_64KEY, &hKey); + if (status == ERROR_SUCCESS) + { + if (RegQueryValueEx(hKey, _T("FramesPerSecond"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS) wfi->framesPerSecond = dwValue; - } + } RegCloseKey(hKey); + + //Set input toggle + wfi->input_disabled = FALSE; - //Set input toggle - wfi->input_disabled = FALSE; - - status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\FreeRDP\\Server"), 0, KEY_READ | KEY_WOW64_64KEY, &hKey); - if (status == ERROR_SUCCESS) - { - if (RegQueryValueEx(hKey, _T("DisableInput"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS) - { - if (dwValue != 0) - wfi->input_disabled = TRUE; - } - } - RegCloseKey(hKey); - } - - return wfi; -} - -wfInfo* wf_info_get_instance() -{ - if (wfInfoInstance == NULL) - wfInfoInstance = wf_info_init(); - - return wfInfoInstance; -} - -void wf_info_peer_register(wfInfo* wfi, wfPeerContext* context) -{ - if (wf_info_lock(wfi) > 0) - { - int i; - int peerId; - if (wfi->peerCount == WF_INFO_MAXPEERS) - { - context->socketClose = TRUE; - wf_info_unlock(wfi); - return; - } - - context->info = wfi; - context->updateEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - - //get the offset of the top left corner of selected screen - EnumDisplayMonitors(NULL, NULL, wf_info_monEnumCB, 0); - _IDcount = 0; + status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\FreeRDP\\Server"), 0, KEY_READ | KEY_WOW64_64KEY, &hKey); + if (status == ERROR_SUCCESS) + { + if (RegQueryValueEx(hKey, _T("DisableInput"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS) + { + if (dwValue != 0) + wfi->input_disabled = TRUE; + } + } + RegCloseKey(hKey); + } + + return wfi; +} + +wfInfo* wf_info_get_instance() +{ + if (wfInfoInstance == NULL) + wfInfoInstance = wf_info_init(); + + return wfInfoInstance; +} + +void wf_info_peer_register(wfInfo* wfi, wfPeerContext* context) +{ + if (wf_info_lock(wfi) > 0) + { + int i; + int peerId; + if (wfi->peerCount == WF_INFO_MAXPEERS) + { + context->socketClose = TRUE; + wf_info_unlock(wfi); + return; + } + + context->info = wfi; + context->updateEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + //get the offset of the top left corner of selected screen + EnumDisplayMonitors(NULL, NULL, wf_info_monEnumCB, 0); + _IDcount = 0; + #ifdef WITH_DXGI_1_2 - if (wfi->peerCount == 0) - wf_dxgi_init(wfi); -#else - if (wf_mirror_driver_activate(wfi) == FALSE) - { - context->socketClose = TRUE; - wf_info_unlock(wfi); - return; - } -#endif - //look trhough the array of peers until an empty slot + if (wfi->peerCount == 0) + wf_dxgi_init(wfi); +#else + if (wf_mirror_driver_activate(wfi) == FALSE) + { + context->socketClose = TRUE; + wf_info_unlock(wfi); + return; + } +#endif + //look trhough the array of peers until an empty slot for(i=0; ipeers[i] == NULL) - { - peerId = i; - break; - } - } + { + //empty index will be our peer id + if (wfi->peers[i] == NULL) + { + peerId = i; + break; + } + } + + wfi->peers[peerId] = ((rdpContext*) context)->peer; + wfi->peers[peerId]->pId = peerId; + wfi->peerCount++; + WLog_INFO(TAG, "Registering Peer: id=%d #=%d", peerId, wfi->peerCount); + wf_info_unlock(wfi); - wfi->peers[peerId] = ((rdpContext*) context)->peer; - wfi->peers[peerId]->pId = peerId; - wfi->peerCount++; - DEBUG_WARN("Registering Peer: id=%d #=%d\n", peerId, wfi->peerCount); + wfreerdp_server_peer_callback_event(peerId, WF_SRV_CALLBACK_EVENT_CONNECT); + } +} + +void wf_info_peer_unregister(wfInfo* wfi, wfPeerContext* context) +{ + if (wf_info_lock(wfi) > 0) + { + int peerId; - wf_info_unlock(wfi); + peerId = ((rdpContext*) context)->peer->pId; + wfi->peers[peerId] = NULL; + wfi->peerCount--; + CloseHandle(context->updateEvent); + WLog_INFO(TAG, "Unregistering Peer: id=%d, #=%d", peerId, wfi->peerCount); + +#ifdef WITH_DXGI_1_2 + if (wfi->peerCount == 0) + wf_dxgi_cleanup(wfi); +#endif + + wf_info_unlock(wfi); - wfreerdp_server_peer_callback_event(peerId, WF_SRV_CALLBACK_EVENT_CONNECT); - } -} - -void wf_info_peer_unregister(wfInfo* wfi, wfPeerContext* context) -{ - if (wf_info_lock(wfi) > 0) - { - int peerId; - - peerId = ((rdpContext*) context)->peer->pId; - wfi->peers[peerId] = NULL; - wfi->peerCount--; - CloseHandle(context->updateEvent); - - DEBUG_WARN("Unregistering Peer: id=%d, #=%d\n", peerId, wfi->peerCount); - -#ifdef WITH_DXGI_1_2 - if (wfi->peerCount == 0) - wf_dxgi_cleanup(wfi); -#endif - - wf_info_unlock(wfi); - - wfreerdp_server_peer_callback_event(peerId, WF_SRV_CALLBACK_EVENT_DISCONNECT); - } -} - -BOOL wf_info_have_updates(wfInfo* wfi) -{ + wfreerdp_server_peer_callback_event(peerId, WF_SRV_CALLBACK_EVENT_DISCONNECT); + } +} + +BOOL wf_info_have_updates(wfInfo* wfi) +{ #ifdef WITH_DXGI_1_2 if(wfi->framesWaiting == 0) - return FALSE; -#else - if (wfi->nextUpdate == wfi->lastUpdate) - return FALSE; -#endif - return TRUE; -} - -void wf_info_update_changes(wfInfo* wfi) -{ + return FALSE; +#else + if (wfi->nextUpdate == wfi->lastUpdate) + return FALSE; +#endif + return TRUE; +} + +void wf_info_update_changes(wfInfo* wfi) +{ #ifdef WITH_DXGI_1_2 - wf_dxgi_nextFrame(wfi, wfi->framesPerSecond * 1000); -#else - GETCHANGESBUF* buf; + wf_dxgi_nextFrame(wfi, wfi->framesPerSecond * 1000); +#else + GETCHANGESBUF* buf; - buf = (GETCHANGESBUF*) wfi->changeBuffer; - wfi->nextUpdate = buf->buffer->counter; -#endif -} - -void wf_info_find_invalid_region(wfInfo* wfi) -{ + buf = (GETCHANGESBUF*) wfi->changeBuffer; + wfi->nextUpdate = buf->buffer->counter; +#endif +} + +void wf_info_find_invalid_region(wfInfo* wfi) +{ #ifdef WITH_DXGI_1_2 - wf_dxgi_getInvalidRegion(&wfi->invalid); -#else - int i; - GETCHANGESBUF* buf; + wf_dxgi_getInvalidRegion(&wfi->invalid); +#else + int i; + GETCHANGESBUF* buf; - buf = (GETCHANGESBUF*) wfi->changeBuffer; - - for (i = wfi->lastUpdate; i != wfi->nextUpdate; i = (i + 1) % MAXCHANGES_BUF) - { - LPRECT lpR = &buf->buffer->pointrect[i].rect; - - //need to make sure we only get updates from the selected screen + buf = (GETCHANGESBUF*) wfi->changeBuffer; + + for (i = wfi->lastUpdate; i != wfi->nextUpdate; i = (i + 1) % MAXCHANGES_BUF) + { + LPRECT lpR = &buf->buffer->pointrect[i].rect; + + //need to make sure we only get updates from the selected screen if ( (lpR->left >= wfi->servscreen_xoffset) && (lpR->right <= (wfi->servscreen_xoffset + wfi->servscreen_width) ) && (lpR->top >= wfi->servscreen_yoffset) && (lpR->bottom <= (wfi->servscreen_yoffset + wfi->servscreen_height) ) ) - { - UnionRect(&wfi->invalid, &wfi->invalid, lpR); - } - else - { - continue; - } - } -#endif - - if (wfi->invalid.left < 0) - wfi->invalid.left = 0; - - if (wfi->invalid.top < 0) - wfi->invalid.top = 0; - - if (wfi->invalid.right >= wfi->servscreen_width) - wfi->invalid.right = wfi->servscreen_width - 1; - - if (wfi->invalid.bottom >= wfi->servscreen_height) - wfi->invalid.bottom = wfi->servscreen_height - 1; - - //printf("invalid region: (%d, %d), (%d, %d)\n", wfi->invalid.left, wfi->invalid.top, wfi->invalid.right, wfi->invalid.bottom); -} - -void wf_info_clear_invalid_region(wfInfo* wfi) -{ - wfi->lastUpdate = wfi->nextUpdate; - SetRectEmpty(&wfi->invalid); -} - -void wf_info_invalidate_full_screen(wfInfo* wfi) -{ - SetRect(&wfi->invalid, 0, 0, wfi->servscreen_width, wfi->servscreen_height); -} - -BOOL wf_info_have_invalid_region(wfInfo* wfi) -{ - return IsRectEmpty(&wfi->invalid); -} - -void wf_info_getScreenData(wfInfo* wfi, long* width, long* height, BYTE** pBits, int* pitch) -{ - *width = (wfi->invalid.right - wfi->invalid.left); - *height = (wfi->invalid.bottom - wfi->invalid.top); + { + UnionRect(&wfi->invalid, &wfi->invalid, lpR); + } + else + { + continue; + } + } +#endif + + if (wfi->invalid.left < 0) + wfi->invalid.left = 0; + + if (wfi->invalid.top < 0) + wfi->invalid.top = 0; + + if (wfi->invalid.right >= wfi->servscreen_width) + wfi->invalid.right = wfi->servscreen_width - 1; + + if (wfi->invalid.bottom >= wfi->servscreen_height) + wfi->invalid.bottom = wfi->servscreen_height - 1; + + //WLog_DBG(TAG, "invalid region: (%d, %d), (%d, %d)", wfi->invalid.left, wfi->invalid.top, wfi->invalid.right, wfi->invalid.bottom); +} + +void wf_info_clear_invalid_region(wfInfo* wfi) +{ + wfi->lastUpdate = wfi->nextUpdate; + SetRectEmpty(&wfi->invalid); +} + +void wf_info_invalidate_full_screen(wfInfo* wfi) +{ + SetRect(&wfi->invalid, 0, 0, wfi->servscreen_width, wfi->servscreen_height); +} + +BOOL wf_info_have_invalid_region(wfInfo* wfi) +{ + return IsRectEmpty(&wfi->invalid); +} + +void wf_info_getScreenData(wfInfo* wfi, long* width, long* height, BYTE** pBits, int* pitch) +{ + *width = (wfi->invalid.right - wfi->invalid.left); + *height = (wfi->invalid.bottom - wfi->invalid.top); #ifdef WITH_DXGI_1_2 - wf_dxgi_getPixelData(wfi, pBits, pitch, &wfi->invalid); -#else - { - long offset; - GETCHANGESBUF* changes; - changes = (GETCHANGESBUF*) wfi->changeBuffer; + wf_dxgi_getPixelData(wfi, pBits, pitch, &wfi->invalid); +#else + { + long offset; + GETCHANGESBUF* changes; + changes = (GETCHANGESBUF*) wfi->changeBuffer; - *width += 1; - *height += 1; + *width += 1; + *height += 1; - offset = (4 * wfi->invalid.left) + (wfi->invalid.top * wfi->virtscreen_width * 4); + offset = (4 * wfi->invalid.left) + (wfi->invalid.top * wfi->virtscreen_width * 4); *pBits = ((BYTE*) (changes->Userbuffer)) + offset; - *pitch = wfi->virtscreen_width * 4; - } -#endif -} - -BOOL CALLBACK wf_info_monEnumCB(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) -{ + *pitch = wfi->virtscreen_width * 4; + } +#endif +} + +BOOL CALLBACK wf_info_monEnumCB(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) +{ wfInfo * wfi; - wfi = wf_info_get_instance(); - + wfi = wf_info_get_instance(); + if(_IDcount == wfi->screenID) - { - wfi->servscreen_xoffset = lprcMonitor->left; - wfi->servscreen_yoffset = lprcMonitor->top; - } + { + wfi->servscreen_xoffset = lprcMonitor->left; + wfi->servscreen_yoffset = lprcMonitor->top; + } _IDcount++; - - return TRUE; -} + + return TRUE; +} diff --git a/server/Windows/wf_interface.c b/server/Windows/wf_interface.c index 80262649d..e2ece59b3 100644 --- a/server/Windows/wf_interface.c +++ b/server/Windows/wf_interface.c @@ -102,7 +102,7 @@ DWORD WINAPI wf_server_main_loop(LPVOID lpParam) if (instance->GetFileDescriptor(instance, rfds, &rcount) != TRUE) { - DEBUG_WARN("Failed to get FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to get FreeRDP file descriptor"); break; } @@ -127,13 +127,12 @@ DWORD WINAPI wf_server_main_loop(LPVOID lpParam) if (instance->CheckFileDescriptor(instance) != TRUE) { - DEBUG_WARN("Failed to check FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to check FreeRDP file descriptor"); break; } } - DEBUG_WARN("wf_server_main_loop terminating\n"); - + WLog_INFO(TAG, "wf_server_main_loop terminating"); instance->Close(instance); return 0; @@ -163,8 +162,7 @@ BOOL wfreerdp_server_stop(wfServer* server) wfInfo* wfi; wfi = wf_info_get_instance(); - - DEBUG_WARN("Stopping server\n"); + WLog_INFO(TAG, "Stopping server"); wfi->force_all_disconnect = TRUE; server->instance->Close(server->instance); return TRUE; @@ -210,7 +208,7 @@ FREERDP_API BOOL wfreerdp_server_is_running(wfServer* server) bRet = GetExitCodeThread(server->thread, &tStatus); if (bRet == 0) { - DEBUG_WARN("Error in call to GetExitCodeThread\n"); + WLog_ERR(TAG, "Error in call to GetExitCodeThread"); return FALSE; } @@ -245,7 +243,7 @@ FREERDP_API UINT32 wfreerdp_server_get_peer_hostname(int pId, wchar_t * dstStr) } else { - DEBUG_WARN("nonexistent peer id=%d\n", pId); + WLog_WARN(TAG, "nonexistent peer id=%d", pId); return 0; } } diff --git a/server/Windows/wf_interface.h b/server/Windows/wf_interface.h index 9a2c72215..6ab6b6f3e 100644 --- a/server/Windows/wf_interface.h +++ b/server/Windows/wf_interface.h @@ -29,7 +29,6 @@ #include #include -#include #include diff --git a/server/Windows/wf_mirage.c b/server/Windows/wf_mirage.c index be1fedca1..b3fa6c504 100644 --- a/server/Windows/wf_mirage.c +++ b/server/Windows/wf_mirage.c @@ -1,366 +1,368 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * FreeRDP Windows Server - * - * Copyright 2012 Marc-Andre Moreau - * Copyright 2012-2013 Corey Clayton - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * FreeRDP Windows Server + * + * Copyright 2012 Marc-Andre Moreau + * Copyright 2012-2013 Corey Clayton + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "wf_mirage.h" + +#define DEVICE_KEY_PREFIX _T("\\Registry\\Machine\\") +/* +This function will iterate over the loaded display devices until it finds +the mirror device we want to load. If found, it will then copy the registry +key corresponding to the device to the wfi and returns TRUE. Otherwise +the function returns FALSE. +*/ +BOOL wf_mirror_driver_find_display_device(wfInfo* wfi) +{ + BOOL result; + BOOL devFound; + DWORD deviceNumber; + DISPLAY_DEVICE deviceInfo; -#include -#include + devFound = FALSE; + deviceNumber = 0; + deviceInfo.cb = sizeof(deviceInfo); + + while (result = EnumDisplayDevices(NULL, deviceNumber, &deviceInfo, 0)) + { + if (_tcscmp(deviceInfo.DeviceString, _T("Mirage Driver")) == 0) + { + int deviceKeyLength; + int deviceKeyPrefixLength; -#include "wf_mirage.h" + deviceKeyPrefixLength = _tcslen(DEVICE_KEY_PREFIX); + + if (_tcsnicmp(deviceInfo.DeviceKey, DEVICE_KEY_PREFIX, deviceKeyPrefixLength) == 0) + { + deviceKeyLength = _tcslen(deviceInfo.DeviceKey) - deviceKeyPrefixLength; + wfi->deviceKey = (LPTSTR) malloc((deviceKeyLength + 1) * sizeof(TCHAR)); -#define DEVICE_KEY_PREFIX _T("\\Registry\\Machine\\") -/* -This function will iterate over the loaded display devices until it finds -the mirror device we want to load. If found, it will then copy the registry -key corresponding to the device to the wfi and returns TRUE. Otherwise -the function returns FALSE. -*/ -BOOL wf_mirror_driver_find_display_device(wfInfo* wfi) -{ - BOOL result; - BOOL devFound; - DWORD deviceNumber; - DISPLAY_DEVICE deviceInfo; - - devFound = FALSE; - deviceNumber = 0; - deviceInfo.cb = sizeof(deviceInfo); - - while (result = EnumDisplayDevices(NULL, deviceNumber, &deviceInfo, 0)) - { - if (_tcscmp(deviceInfo.DeviceString, _T("Mirage Driver")) == 0) - { - int deviceKeyLength; - int deviceKeyPrefixLength; - - deviceKeyPrefixLength = _tcslen(DEVICE_KEY_PREFIX); - - if (_tcsnicmp(deviceInfo.DeviceKey, DEVICE_KEY_PREFIX, deviceKeyPrefixLength) == 0) - { - deviceKeyLength = _tcslen(deviceInfo.DeviceKey) - deviceKeyPrefixLength; - wfi->deviceKey = (LPTSTR) malloc((deviceKeyLength + 1) * sizeof(TCHAR)); - - _tcsncpy_s(wfi->deviceKey, deviceKeyLength + 1, + _tcsncpy_s(wfi->deviceKey, deviceKeyLength + 1, &deviceInfo.DeviceKey[deviceKeyPrefixLength], deviceKeyLength); - } - - _tcsncpy_s(wfi->deviceName, 32, deviceInfo.DeviceName, _tcslen(deviceInfo.DeviceName)); - return TRUE; - } - - deviceNumber++; - } - - return FALSE; -} - -/** - * This function will attempt to access the the windows registry using the device - * key stored in the current wfi. It will attempt to read the value of the - * "Attach.ToDesktop" subkey and will return TRUE if the value is already set to + } + + _tcsncpy_s(wfi->deviceName, 32, deviceInfo.DeviceName, _tcslen(deviceInfo.DeviceName)); + return TRUE; + } + + deviceNumber++; + } + + return FALSE; +} + +/** + * This function will attempt to access the the windows registry using the device + * key stored in the current wfi. It will attempt to read the value of the + * "Attach.ToDesktop" subkey and will return TRUE if the value is already set to * val. If unable to read the subkey, this function will return FALSE. If the * subkey is not set to val it will then attempt to set it to val and return TRUE. If * unsuccessful or an unexpected value is encountered, the function returns - * FALSE. - */ + * FALSE. + */ + +BOOL wf_mirror_driver_display_device_attach(wfInfo* wfi, DWORD mode) +{ + HKEY hKey; + LONG status; + DWORD dwType; + DWORD dwSize; + DWORD dwValue; -BOOL wf_mirror_driver_display_device_attach(wfInfo* wfi, DWORD mode) -{ - HKEY hKey; - LONG status; - DWORD dwType; - DWORD dwSize; - DWORD dwValue; - - status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, wfi->deviceKey, + status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, wfi->deviceKey, 0, KEY_ALL_ACCESS | KEY_WOW64_64KEY, &hKey); - - if (status != ERROR_SUCCESS) - { - DEBUG_WARN("Error opening RegKey: status=%0X\n", status); - if (status == ERROR_ACCESS_DENIED) - DEBUG_WARN("access denied. Do you have admin privleges?\n"); - return FALSE; - } - - dwSize = sizeof(DWORD); - status = RegQueryValueEx(hKey, _T("Attach.ToDesktop"), + + if (status != ERROR_SUCCESS) + { + WLog_DBG(TAG, "Error opening RegKey: status=%0X", status); + + if (status == ERROR_ACCESS_DENIED) + WLog_DBG(TAG, "access denied. Do you have admin privleges?"); + + return FALSE; + } + + dwSize = sizeof(DWORD); + status = RegQueryValueEx(hKey, _T("Attach.ToDesktop"), NULL, &dwType, (BYTE*) &dwValue, &dwSize); + + if (status != ERROR_SUCCESS) + { + WLog_DBG(TAG, "Error querying RegKey: status=%0X", status); + + if (status == ERROR_ACCESS_DENIED) + WLog_DBG(TAG, "access denied. Do you have admin privleges?"); + + return FALSE; + } + + if (dwValue ^ mode) //only if we want to change modes + { + dwValue = mode; + dwSize = sizeof(DWORD); - if (status != ERROR_SUCCESS) - { - DEBUG_WARN("Error querying RegKey: status=%0X\n", status); - if (status == ERROR_ACCESS_DENIED) - DEBUG_WARN("access denied. Do you have admin privleges?\n"); - return FALSE; - } - - if (dwValue ^ mode) //only if we want to change modes - { - dwValue = mode; - dwSize = sizeof(DWORD); - - status = RegSetValueEx(hKey, _T("Attach.ToDesktop"), + status = RegSetValueEx(hKey, _T("Attach.ToDesktop"), 0, REG_DWORD, (BYTE*) &dwValue, dwSize); + + if (status != ERROR_SUCCESS) + { + WLog_DBG(TAG, "Error writing registry key: %d ", status); + + if (status == ERROR_ACCESS_DENIED) + WLog_DBG(TAG, "access denied. Do you have admin privleges?"); + + WLog_DBG(TAG, ""); + return FALSE; + } + } + + return TRUE; +} + +void wf_mirror_driver_print_display_change_status(LONG status) +{ + TCHAR disp_change[64]; + + switch (status) + { + case DISP_CHANGE_SUCCESSFUL: + _tcscpy(disp_change, _T("DISP_CHANGE_SUCCESSFUL")); + break; - if (status != ERROR_SUCCESS) - { - DEBUG_WARN("Error writing registry key: %d ", status); - if (status == ERROR_ACCESS_DENIED) - DEBUG_WARN("access denied. Do you have admin privleges?"); - DEBUG_WARN("\n"); - return FALSE; - } - } + case DISP_CHANGE_BADDUALVIEW: + _tcscpy(disp_change, _T("DISP_CHANGE_BADDUALVIEW")); + break; - return TRUE; -} + case DISP_CHANGE_BADFLAGS: + _tcscpy(disp_change, _T("DISP_CHANGE_BADFLAGS")); + break; -void wf_mirror_driver_print_display_change_status(LONG status) -{ - TCHAR disp_change[64]; + case DISP_CHANGE_BADMODE: + _tcscpy(disp_change, _T("DISP_CHANGE_BADMODE")); + break; - switch (status) - { - case DISP_CHANGE_SUCCESSFUL: - _tcscpy(disp_change, _T("DISP_CHANGE_SUCCESSFUL")); - break; + case DISP_CHANGE_BADPARAM: + _tcscpy(disp_change, _T("DISP_CHANGE_BADPARAM")); + break; - case DISP_CHANGE_BADDUALVIEW: - _tcscpy(disp_change, _T("DISP_CHANGE_BADDUALVIEW")); - break; + case DISP_CHANGE_FAILED: + _tcscpy(disp_change, _T("DISP_CHANGE_FAILED")); + break; - case DISP_CHANGE_BADFLAGS: - _tcscpy(disp_change, _T("DISP_CHANGE_BADFLAGS")); - break; + case DISP_CHANGE_NOTUPDATED: + _tcscpy(disp_change, _T("DISP_CHANGE_NOTUPDATED")); + break; - case DISP_CHANGE_BADMODE: - _tcscpy(disp_change, _T("DISP_CHANGE_BADMODE")); - break; + case DISP_CHANGE_RESTART: + _tcscpy(disp_change, _T("DISP_CHANGE_RESTART")); + break; - case DISP_CHANGE_BADPARAM: - _tcscpy(disp_change, _T("DISP_CHANGE_BADPARAM")); - break; - - case DISP_CHANGE_FAILED: - _tcscpy(disp_change, _T("DISP_CHANGE_FAILED")); - break; - - case DISP_CHANGE_NOTUPDATED: - _tcscpy(disp_change, _T("DISP_CHANGE_NOTUPDATED")); - break; - - case DISP_CHANGE_RESTART: - _tcscpy(disp_change, _T("DISP_CHANGE_RESTART")); - break; - - default: - _tcscpy(disp_change, _T("DISP_CHANGE_UNKNOWN")); - break; - } - - if (status != DISP_CHANGE_SUCCESSFUL) - _tprintf(_T("ChangeDisplaySettingsEx() failed with %s (%d)\n"), disp_change, status); - else - _tprintf(_T("ChangeDisplaySettingsEx() succeeded with %s (%d)\n"), disp_change, status); -} - -/** + default: + _tcscpy(disp_change, _T("DISP_CHANGE_UNKNOWN")); + break; + } + + if (status != DISP_CHANGE_SUCCESSFUL) + WLog_ERR(TAG, "ChangeDisplaySettingsEx() failed with %s (%d)", disp_change, status); + else + WLog_INFO(TAG, "ChangeDisplaySettingsEx() succeeded with %s (%d)", disp_change, status); +} + +/** * This function will attempt to apply the currently configured display settings * in the registry to the display driver. It will return TRUE if successful - * otherwise it returns FALSE. - * If mode is MIRROR_UNLOAD then the the driver will be asked to remove itself. - */ - -BOOL wf_mirror_driver_update(wfInfo* wfi, int mode) -{ - HDC dc; - BOOL status; - DWORD* extHdr; - WORD drvExtraSaved; - DEVMODE* deviceMode; - LONG disp_change_status; - DWORD dmf_devmodewext_magic_sig = 0xDF20C0DE; - + * otherwise it returns FALSE. + * If mode is MIRROR_UNLOAD then the the driver will be asked to remove itself. + */ + +BOOL wf_mirror_driver_update(wfInfo* wfi, int mode) +{ + HDC dc; + BOOL status; + DWORD* extHdr; + WORD drvExtraSaved; + DEVMODE* deviceMode; + LONG disp_change_status; + DWORD dmf_devmodewext_magic_sig = 0xDF20C0DE; + if ( (mode != MIRROR_LOAD) && (mode != MIRROR_UNLOAD) ) - { - DEBUG_WARN("Invalid mirror mode!\n"); - return FALSE; - } + { + WLog_DBG(TAG, "Invalid mirror mode!"); + return FALSE; + } - deviceMode = (DEVMODE*) malloc(sizeof(DEVMODE) + EXT_DEVMODE_SIZE_MAX); - deviceMode->dmDriverExtra = 2 * sizeof(DWORD); + deviceMode = (DEVMODE*) malloc(sizeof(DEVMODE) + EXT_DEVMODE_SIZE_MAX); + deviceMode->dmDriverExtra = 2 * sizeof(DWORD); extHdr = (DWORD*)((BYTE*) &deviceMode + sizeof(DEVMODE)); - extHdr[0] = dmf_devmodewext_magic_sig; - extHdr[1] = 0; + extHdr[0] = dmf_devmodewext_magic_sig; + extHdr[1] = 0; - drvExtraSaved = deviceMode->dmDriverExtra; - memset(deviceMode, 0, sizeof(DEVMODE) + EXT_DEVMODE_SIZE_MAX); - deviceMode->dmSize = sizeof(DEVMODE); - deviceMode->dmDriverExtra = drvExtraSaved; + drvExtraSaved = deviceMode->dmDriverExtra; + memset(deviceMode, 0, sizeof(DEVMODE) + EXT_DEVMODE_SIZE_MAX); + deviceMode->dmSize = sizeof(DEVMODE); + deviceMode->dmDriverExtra = drvExtraSaved; + + if (mode == MIRROR_LOAD) + { + wfi->virtscreen_width = GetSystemMetrics(SM_CXVIRTUALSCREEN); + wfi->virtscreen_height = GetSystemMetrics(SM_CYVIRTUALSCREEN); - if (mode == MIRROR_LOAD) - { - wfi->virtscreen_width = GetSystemMetrics(SM_CXVIRTUALSCREEN); - wfi->virtscreen_height = GetSystemMetrics(SM_CYVIRTUALSCREEN); + deviceMode->dmPelsWidth = wfi->virtscreen_width; + deviceMode->dmPelsHeight = wfi->virtscreen_height; + deviceMode->dmBitsPerPel = wfi->bitsPerPixel; + deviceMode->dmPosition.x = wfi->servscreen_xoffset; + deviceMode->dmPosition.y = wfi->servscreen_yoffset; + } + + deviceMode->dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION; - deviceMode->dmPelsWidth = wfi->virtscreen_width; - deviceMode->dmPelsHeight = wfi->virtscreen_height; - deviceMode->dmBitsPerPel = wfi->bitsPerPixel; - deviceMode->dmPosition.x = wfi->servscreen_xoffset; - deviceMode->dmPosition.y = wfi->servscreen_yoffset; - } + _tcsncpy_s(deviceMode->dmDeviceName, 32, wfi->deviceName, _tcslen(wfi->deviceName)); - deviceMode->dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION; + disp_change_status = ChangeDisplaySettingsEx(wfi->deviceName, deviceMode, NULL, CDS_UPDATEREGISTRY, NULL); - _tcsncpy_s(deviceMode->dmDeviceName, 32, wfi->deviceName, _tcslen(wfi->deviceName)); - - disp_change_status = ChangeDisplaySettingsEx(wfi->deviceName, deviceMode, NULL, CDS_UPDATEREGISTRY, NULL); - - status = (disp_change_status == DISP_CHANGE_SUCCESSFUL) ? TRUE : FALSE; - - if (!status) - wf_mirror_driver_print_display_change_status(disp_change_status); + status = (disp_change_status == DISP_CHANGE_SUCCESSFUL) ? TRUE : FALSE; + + if (!status) + wf_mirror_driver_print_display_change_status(disp_change_status); - return status; -} + return status; +} + +BOOL wf_mirror_driver_map_memory(wfInfo* wfi) +{ + int status; -BOOL wf_mirror_driver_map_memory(wfInfo* wfi) -{ - int status; - - wfi->driverDC = CreateDC(wfi->deviceName, NULL, NULL, NULL); - - if (wfi->driverDC == NULL) - { - _tprintf(_T("Could not create device driver context!\n")); - - { - LPVOID lpMsgBuf; + wfi->driverDC = CreateDC(wfi->deviceName, NULL, NULL, NULL); + + if (wfi->driverDC == NULL) + { + WLog_ERR(TAG, "Could not create device driver context!"); + { + LPVOID lpMsgBuf; DWORD dw = GetLastError(); - FormatMessage( + FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - dw, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &lpMsgBuf, + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + dw, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR) &lpMsgBuf, 0, NULL ); - // Display the error message and exit the process + // Display the error message and exit the process + WLog_ERR(TAG, "CreateDC failed on device [%s] with error %d: %s", wfi->deviceName, dw, lpMsgBuf); + LocalFree(lpMsgBuf); + } - _tprintf(_T("CreateDC failed on device [%s] with error %d: %s\n"), wfi->deviceName, dw, lpMsgBuf); + return FALSE; + } + + wfi->changeBuffer = malloc(sizeof(GETCHANGESBUF)); + ZeroMemory(wfi->changeBuffer, sizeof(GETCHANGESBUF)); - LocalFree(lpMsgBuf); - } + status = ExtEscape(wfi->driverDC, dmf_esc_usm_pipe_map, 0, 0, sizeof(GETCHANGESBUF), (LPSTR) wfi->changeBuffer); + + if (status <= 0) + { + WLog_ERR(TAG, "Failed to map shared memory from the driver! code %d", status); + return FALSE; + } + + return TRUE; +} + +/* Unmap the shared memory and release the DC */ + +BOOL wf_mirror_driver_cleanup(wfInfo* wfi) +{ + int status; - return FALSE; - } - - wfi->changeBuffer = malloc(sizeof(GETCHANGESBUF)); - ZeroMemory(wfi->changeBuffer, sizeof(GETCHANGESBUF)); - - status = ExtEscape(wfi->driverDC, dmf_esc_usm_pipe_map, 0, 0, sizeof(GETCHANGESBUF), (LPSTR) wfi->changeBuffer); - - if (status <= 0) - { - _tprintf(_T("Failed to map shared memory from the driver! code %d\n"), status); - return FALSE; - } - - return TRUE; -} - -/* Unmap the shared memory and release the DC */ - -BOOL wf_mirror_driver_cleanup(wfInfo* wfi) -{ - int status; - - status = ExtEscape(wfi->driverDC, dmf_esc_usm_pipe_unmap, sizeof(GETCHANGESBUF), (LPSTR) wfi->changeBuffer, 0, 0); + status = ExtEscape(wfi->driverDC, dmf_esc_usm_pipe_unmap, sizeof(GETCHANGESBUF), (LPSTR) wfi->changeBuffer, 0, 0); - if (status <= 0) - { - _tprintf(_T("Failed to unmap shared memory from the driver! code %d\n"), status); - } + if (status <= 0) + { + WLog_ERR(TAG, "Failed to unmap shared memory from the driver! code %d", status); + } + + if (wfi->driverDC != NULL) + { + status = DeleteDC(wfi->driverDC); + + if (status == 0) + { + WLog_ERR(TAG, "Failed to release DC!")); + } + } + + free(wfi->changeBuffer); - if (wfi->driverDC != NULL) - { - status = DeleteDC(wfi->driverDC); - - if (status == 0) - { - _tprintf(_T("Failed to release DC!\n")); - } - } - - free(wfi->changeBuffer); - - return TRUE; -} - -BOOL wf_mirror_driver_activate(wfInfo* wfi) -{ - if (!wfi->mirrorDriverActive) - { - DEBUG_WARN("Activating Mirror Driver\n"); - - if (wf_mirror_driver_find_display_device(wfi) == FALSE) - { - DEBUG_WARN("Could not find dfmirage mirror driver! Is it installed?\n"); - return FALSE; - } - - if (wf_mirror_driver_display_device_attach(wfi, 1) == FALSE) - { - DEBUG_WARN("Could not attach display device!\n"); - return FALSE; - } - - if (wf_mirror_driver_update(wfi, MIRROR_LOAD) == FALSE) - { - DEBUG_WARN("could not update system with new display settings!\n"); - return FALSE; - } - - if (wf_mirror_driver_map_memory(wfi) == FALSE) - { - DEBUG_WARN("Unable to map memory for mirror driver!\n"); - return FALSE; - } - wfi->mirrorDriverActive = TRUE; - } - - return TRUE; -} - -void wf_mirror_driver_deactivate(wfInfo* wfi) -{ - if (wfi->mirrorDriverActive) - { - DEBUG_WARN("Deactivating Mirror Driver\n"); - - wf_mirror_driver_cleanup(wfi); - wf_mirror_driver_display_device_attach(wfi, 0); - wf_mirror_driver_update(wfi, MIRROR_UNLOAD); - wfi->mirrorDriverActive = FALSE; - } + return TRUE; +} + +BOOL wf_mirror_driver_activate(wfInfo* wfi) +{ + if (!wfi->mirrorDriverActive) + { + WLog_DBG(TAG, "Activating Mirror Driver"); + + if (wf_mirror_driver_find_display_device(wfi) == FALSE) + { + WLog_DBG(TAG, "Could not find dfmirage mirror driver! Is it installed?"); + return FALSE; + } + + if (wf_mirror_driver_display_device_attach(wfi, 1) == FALSE) + { + WLog_DBG(TAG, "Could not attach display device!"); + return FALSE; + } + + if (wf_mirror_driver_update(wfi, MIRROR_LOAD) == FALSE) + { + WLog_DBG(TAG, "could not update system with new display settings!"); + return FALSE; + } + + if (wf_mirror_driver_map_memory(wfi) == FALSE) + { + WLog_DBG(TAG, "Unable to map memory for mirror driver!"); + return FALSE; + } + wfi->mirrorDriverActive = TRUE; + } + + return TRUE; +} + +void wf_mirror_driver_deactivate(wfInfo* wfi) +{ + if (wfi->mirrorDriverActive) + { + WLog_DBG(TAG, "Deactivating Mirror Driver"); + wf_mirror_driver_cleanup(wfi); + wf_mirror_driver_display_device_attach(wfi, 0); + wf_mirror_driver_update(wfi, MIRROR_UNLOAD); + wfi->mirrorDriverActive = FALSE; + } } \ No newline at end of file diff --git a/server/Windows/wf_peer.c b/server/Windows/wf_peer.c index 4a03d1bf9..c8cb3847f 100644 --- a/server/Windows/wf_peer.c +++ b/server/Windows/wf_peer.c @@ -1,331 +1,329 @@ -/** -* FreeRDP: A Remote Desktop Protocol Client -* FreeRDP Windows Server -* -* Copyright 2012 Marc-Andre Moreau -* Copyright 2012 Corey Clayton -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ +/** +* FreeRDP: A Remote Desktop Protocol Client +* FreeRDP Windows Server +* +* Copyright 2012 Marc-Andre Moreau +* Copyright 2012 Corey Clayton +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include +#include + +#include "wf_info.h" +#include "wf_input.h" +#include "wf_mirage.h" +#include "wf_update.h" +#include "wf_settings.h" +#include "wf_rdpsnd.h" + +#include "wf_peer.h" + +void wf_peer_context_new(freerdp_peer* client, wfPeerContext* context) +{ + context->info = wf_info_get_instance(); + context->vcm = WTSOpenServerA((LPSTR) client->context); + wf_info_peer_register(context->info, context); +} + +void wf_peer_context_free(freerdp_peer* client, wfPeerContext* context) +{ + wf_info_peer_unregister(context->info, context); + + if (context->rdpsnd) + { + wf_rdpsnd_lock(); + context->info->snd_stop = TRUE; + rdpsnd_server_context_free(context->rdpsnd); + wf_rdpsnd_unlock(); + } + + WTSCloseServer(context->vcm); +} + +void wf_peer_init(freerdp_peer* client) +{ + client->ContextSize = sizeof(wfPeerContext); + client->ContextNew = (psPeerContextNew) wf_peer_context_new; + client->ContextFree = (psPeerContextFree) wf_peer_context_free; -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif + freerdp_peer_context_new(client); +} + +BOOL wf_peer_post_connect(freerdp_peer* client) +{ + int i; + wfInfo* wfi; + rdpSettings* settings; + wfPeerContext* context = (wfPeerContext*) client->context; -#include -#include -#include - -#include -#include - -#include "wf_info.h" -#include "wf_input.h" -#include "wf_mirage.h" -#include "wf_update.h" -#include "wf_settings.h" -#include "wf_rdpsnd.h" - -#include "wf_peer.h" - -void wf_peer_context_new(freerdp_peer* client, wfPeerContext* context) -{ - context->info = wf_info_get_instance(); - context->vcm = WTSOpenServerA((LPSTR) client->context); - wf_info_peer_register(context->info, context); -} - -void wf_peer_context_free(freerdp_peer* client, wfPeerContext* context) -{ - wf_info_peer_unregister(context->info, context); - - if (context->rdpsnd) - { - wf_rdpsnd_lock(); - context->info->snd_stop = TRUE; - rdpsnd_server_context_free(context->rdpsnd); - wf_rdpsnd_unlock(); - } - - WTSCloseServer(context->vcm); -} - -void wf_peer_init(freerdp_peer* client) -{ - client->ContextSize = sizeof(wfPeerContext); - client->ContextNew = (psPeerContextNew) wf_peer_context_new; - client->ContextFree = (psPeerContextFree) wf_peer_context_free; - - freerdp_peer_context_new(client); -} - -BOOL wf_peer_post_connect(freerdp_peer* client) -{ - int i; - wfInfo* wfi; - rdpSettings* settings; - wfPeerContext* context = (wfPeerContext*) client->context; - - wfi = context->info; - settings = client->settings; - - if ((get_screen_info(wfi->screenID, NULL, &wfi->servscreen_width, &wfi->servscreen_height, &wfi->bitsPerPixel) == 0) || + wfi = context->info; + settings = client->settings; + + if ((get_screen_info(wfi->screenID, NULL, &wfi->servscreen_width, &wfi->servscreen_height, &wfi->bitsPerPixel) == 0) || (wfi->servscreen_width == 0) || (wfi->servscreen_height == 0) || (wfi->bitsPerPixel == 0) ) - { - _tprintf(_T("postconnect: error getting screen info for screen %d\n"), wfi->screenID); - _tprintf(_T("\t%dx%dx%d\n"), wfi->servscreen_height, wfi->servscreen_width, wfi->bitsPerPixel); - return FALSE; - } + { + WLog_ERR(TAG, "postconnect: error getting screen info for screen %d", wfi->screenID); + WLog_ERR(TAG, "\t%dx%dx%d", wfi->servscreen_height, wfi->servscreen_width, wfi->bitsPerPixel); + return FALSE; + } + + if ((settings->DesktopWidth != wfi->servscreen_width) || (settings->DesktopHeight != wfi->servscreen_height)) + { + /* + WLog_DBG(TAG, "Client requested resolution %dx%d, but will resize to %dx%d", + settings->DesktopWidth, settings->DesktopHeight, wfi->servscreen_width, wfi->servscreen_height); + */ - if ((settings->DesktopWidth != wfi->servscreen_width) || (settings->DesktopHeight != wfi->servscreen_height)) - { - /* - DEBUG_WARN("Client requested resolution %dx%d, but will resize to %dx%d\n", - settings->DesktopWidth, settings->DesktopHeight, wfi->servscreen_width, wfi->servscreen_height); - */ + settings->DesktopWidth = wfi->servscreen_width; + settings->DesktopHeight = wfi->servscreen_height; + settings->ColorDepth = wfi->bitsPerPixel; - settings->DesktopWidth = wfi->servscreen_width; - settings->DesktopHeight = wfi->servscreen_height; - settings->ColorDepth = wfi->bitsPerPixel; + client->update->DesktopResize(client->update->context); + } + + if (WTSVirtualChannelManagerIsChannelJoined(context->vcm, "rdpsnd")) + { + wf_peer_rdpsnd_init(context); /* Audio Output */ + } + + return TRUE; +} + +BOOL wf_peer_activate(freerdp_peer* client) +{ + wfInfo* wfi; + wfPeerContext* context = (wfPeerContext*) client->context; - client->update->DesktopResize(client->update->context); - } + wfi = context->info; + client->activated = TRUE; + wf_update_peer_activate(wfi, context); - if (WTSVirtualChannelManagerIsChannelJoined(context->vcm, "rdpsnd")) - { - wf_peer_rdpsnd_init(context); /* Audio Output */ - } + wfreerdp_server_peer_callback_event(((rdpContext*) context)->peer->pId, WF_SRV_CALLBACK_EVENT_ACTIVATE); - return TRUE; -} + return TRUE; +} + +BOOL wf_peer_logon(freerdp_peer* client, SEC_WINNT_AUTH_IDENTITY* identity, BOOL automatic) +{ + wfreerdp_server_peer_callback_event(((rdpContext*) client->context)->peer->pId, WF_SRV_CALLBACK_EVENT_AUTH); + return TRUE; +} + +void wf_peer_synchronize_event(rdpInput* input, UINT32 flags) +{ -BOOL wf_peer_activate(freerdp_peer* client) -{ - wfInfo* wfi; - wfPeerContext* context = (wfPeerContext*) client->context; +} + +void wf_peer_accepted(freerdp_listener* instance, freerdp_peer* client) +{ + CreateThread(NULL, 0, wf_peer_main_loop, client, 0, NULL); +} + +DWORD WINAPI wf_peer_socket_listener(LPVOID lpParam) +{ + int i, fds; + int rcount; + int max_fds; + void* rfds[32]; + fd_set rfds_set; + wfPeerContext* context; + freerdp_peer* client = (freerdp_peer*) lpParam; - wfi = context->info; - client->activated = TRUE; - wf_update_peer_activate(wfi, context); + ZeroMemory(rfds, sizeof(rfds)); + context = (wfPeerContext*) client->context; + + while (1) + { + rcount = 0; + + if (client->GetFileDescriptor(client, rfds, &rcount) != TRUE) + { + WLog_ERR(TAG, "Failed to get peer file descriptor"); + break; + } + + max_fds = 0; + FD_ZERO(&rfds_set); + + for (i = 0; i < rcount; i++) + { + fds = (int)(long)(rfds[i]); + + if (fds > max_fds) + max_fds = fds; + + FD_SET(fds, &rfds_set); + } + + if (max_fds == 0) + break; + + select(max_fds + 1, &rfds_set, NULL, NULL, NULL); - wfreerdp_server_peer_callback_event(((rdpContext*) context)->peer->pId, WF_SRV_CALLBACK_EVENT_ACTIVATE); + SetEvent(context->socketEvent); + WaitForSingleObject(context->socketSemaphore, INFINITE); + + if (context->socketClose) + break; + } + + return 0; +} + +void wf_peer_read_settings(freerdp_peer* client) +{ + if (!wf_settings_read_string_ascii(HKEY_LOCAL_MACHINE, _T("Software\\FreeRDP\\Server"), _T("CertificateFile"), &(client->settings->CertificateFile))) + client->settings->CertificateFile = _strdup("server.crt"); + + if (!wf_settings_read_string_ascii(HKEY_LOCAL_MACHINE, _T("Software\\FreeRDP\\Server"), _T("PrivateKeyFile"), &(client->settings->PrivateKeyFile))) + client->settings->PrivateKeyFile = _strdup("server.key"); +} + +DWORD WINAPI wf_peer_main_loop(LPVOID lpParam) +{ + wfInfo* wfi; + DWORD nCount; + DWORD status; + HANDLE handles[32]; + rdpSettings* settings; + wfPeerContext* context; + freerdp_peer* client = (freerdp_peer*) lpParam; + + if (!getenv("HOME")) + { + char home[MAX_PATH * 2] = "HOME="; + strcat(home, getenv("HOMEDRIVE")); + strcat(home, getenv("HOMEPATH")); + _putenv(home); + } + + wf_peer_init(client); - return TRUE; -} + settings = client->settings; + settings->RemoteFxCodec = TRUE; + settings->ColorDepth = 32; + settings->NSCodec = FALSE; + settings->JpegCodec = FALSE; + wf_peer_read_settings(client); -BOOL wf_peer_logon(freerdp_peer* client, SEC_WINNT_AUTH_IDENTITY* identity, BOOL automatic) -{ - wfreerdp_server_peer_callback_event(((rdpContext*) client->context)->peer->pId, WF_SRV_CALLBACK_EVENT_AUTH); - return TRUE; -} + client->PostConnect = wf_peer_post_connect; + client->Activate = wf_peer_activate; + client->Logon = wf_peer_logon; -void wf_peer_synchronize_event(rdpInput* input, UINT32 flags) -{ + client->input->SynchronizeEvent = wf_peer_synchronize_event; + client->input->KeyboardEvent = wf_peer_keyboard_event; + client->input->UnicodeKeyboardEvent = wf_peer_unicode_keyboard_event; + client->input->MouseEvent = wf_peer_mouse_event; + client->input->ExtendedMouseEvent = wf_peer_extended_mouse_event; -} - -void wf_peer_accepted(freerdp_listener* instance, freerdp_peer* client) -{ - CreateThread(NULL, 0, wf_peer_main_loop, client, 0, NULL); -} - -DWORD WINAPI wf_peer_socket_listener(LPVOID lpParam) -{ - int i, fds; - int rcount; - int max_fds; - void* rfds[32]; - fd_set rfds_set; - wfPeerContext* context; - freerdp_peer* client = (freerdp_peer*) lpParam; - - ZeroMemory(rfds, sizeof(rfds)); - context = (wfPeerContext*) client->context; - - while (1) - { - rcount = 0; - - if (client->GetFileDescriptor(client, rfds, &rcount) != TRUE) - { - //printf("Failed to get peer file descriptor\n"); - break; - } - - max_fds = 0; - FD_ZERO(&rfds_set); - - for (i = 0; i < rcount; i++) - { - fds = (int)(long)(rfds[i]); - - if (fds > max_fds) - max_fds = fds; - - FD_SET(fds, &rfds_set); - } - - if (max_fds == 0) - break; - - select(max_fds + 1, &rfds_set, NULL, NULL, NULL); - - SetEvent(context->socketEvent); - WaitForSingleObject(context->socketSemaphore, INFINITE); - - if (context->socketClose) - break; - } - - return 0; -} - -void wf_peer_read_settings(freerdp_peer* client) -{ - if (!wf_settings_read_string_ascii(HKEY_LOCAL_MACHINE, _T("Software\\FreeRDP\\Server"), _T("CertificateFile"), &(client->settings->CertificateFile))) - client->settings->CertificateFile = _strdup("server.crt"); - - if (!wf_settings_read_string_ascii(HKEY_LOCAL_MACHINE, _T("Software\\FreeRDP\\Server"), _T("PrivateKeyFile"), &(client->settings->PrivateKeyFile))) - client->settings->PrivateKeyFile = _strdup("server.key"); -} - -DWORD WINAPI wf_peer_main_loop(LPVOID lpParam) -{ - wfInfo* wfi; - DWORD nCount; - DWORD status; - HANDLE handles[32]; - rdpSettings* settings; - wfPeerContext* context; - freerdp_peer* client = (freerdp_peer*) lpParam; - - if (!getenv("HOME")) - { - char home[MAX_PATH * 2] = "HOME="; - strcat(home, getenv("HOMEDRIVE")); - strcat(home, getenv("HOMEPATH")); - _putenv(home); - } - - wf_peer_init(client); - - settings = client->settings; - settings->RemoteFxCodec = TRUE; - settings->ColorDepth = 32; - settings->NSCodec = FALSE; - settings->JpegCodec = FALSE; - wf_peer_read_settings(client); - - client->PostConnect = wf_peer_post_connect; - client->Activate = wf_peer_activate; - client->Logon = wf_peer_logon; - - client->input->SynchronizeEvent = wf_peer_synchronize_event; - client->input->KeyboardEvent = wf_peer_keyboard_event; - client->input->UnicodeKeyboardEvent = wf_peer_unicode_keyboard_event; - client->input->MouseEvent = wf_peer_mouse_event; - client->input->ExtendedMouseEvent = wf_peer_extended_mouse_event; - - client->Initialize(client); - context = (wfPeerContext*) client->context; - - if (context->socketClose) - return 0; - - wfi = context->info; - - if (wfi->input_disabled) - { - DEBUG_WARN("client input is disabled\n"); - client->input->KeyboardEvent = wf_peer_keyboard_event_dummy; - client->input->UnicodeKeyboardEvent = wf_peer_unicode_keyboard_event_dummy; - client->input->MouseEvent = wf_peer_mouse_event_dummy; - client->input->ExtendedMouseEvent = wf_peer_extended_mouse_event_dummy; - } - - context->socketEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + client->Initialize(client); + context = (wfPeerContext*) client->context; + + if (context->socketClose) + return 0; + + wfi = context->info; + + if (wfi->input_disabled) + { + WLog_INFO(TAG, "client input is disabled"); + client->input->KeyboardEvent = wf_peer_keyboard_event_dummy; + client->input->UnicodeKeyboardEvent = wf_peer_unicode_keyboard_event_dummy; + client->input->MouseEvent = wf_peer_mouse_event_dummy; + client->input->ExtendedMouseEvent = wf_peer_extended_mouse_event_dummy; + } + + context->socketEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - context->socketSemaphore = CreateSemaphore(NULL, 0, 1, NULL); - context->socketThread = CreateThread(NULL, 0, wf_peer_socket_listener, client, 0, NULL); + context->socketSemaphore = CreateSemaphore(NULL, 0, 1, NULL); + context->socketThread = CreateThread(NULL, 0, wf_peer_socket_listener, client, 0, NULL); + WLog_INFO(TAG, "We've got a client %s", client->local ? "(local)" : client->hostname); + nCount = 0; + handles[nCount++] = context->updateEvent; + handles[nCount++] = context->socketEvent; + + while (1) + { + status = WaitForMultipleObjects(nCount, handles, FALSE, INFINITE); + + if ((status == WAIT_FAILED) || (status == WAIT_TIMEOUT)) + { + WLog_ERR(TAG, "WaitForMultipleObjects failed"); + break; + } + + if (WaitForSingleObject(context->updateEvent, 0) == 0) + { + if (client->activated) + wf_update_peer_send(wfi, context); + + ResetEvent(context->updateEvent); + ReleaseSemaphore(wfi->updateSemaphore, 1, NULL); + } + + if (WaitForSingleObject(context->socketEvent, 0) == 0) + { + if (client->CheckFileDescriptor(client) != TRUE) + { + WLog_ERR(TAG, "Failed to check peer file descriptor"); + context->socketClose = TRUE; + } + + ResetEvent(context->socketEvent); + ReleaseSemaphore(context->socketSemaphore, 1, NULL); + + if (context->socketClose) + break; + } + + //force disconnect + if (wfi->force_all_disconnect == TRUE) + { + WLog_INFO(TAG, "Forcing Disconnect -> "); + break; + } + + /* FIXME: we should wait on this, instead of calling it every time */ + if (WTSVirtualChannelManagerCheckFileDescriptor(context->vcm) != TRUE) + break; + } + + WLog_INFO(TAG, "Client %s disconnected.", client->local ? "(local)" : client->hostname); + + if (WaitForSingleObject(context->updateEvent, 0) == 0) + { + ResetEvent(context->updateEvent); + ReleaseSemaphore(wfi->updateSemaphore, 1, NULL); + } + + wf_update_peer_deactivate(wfi, context); - DEBUG_WARN("We've got a client %s\n", client->local ? "(local)" : client->hostname); + client->Disconnect(client); - nCount = 0; - handles[nCount++] = context->updateEvent; - handles[nCount++] = context->socketEvent; + freerdp_peer_context_free(client); + freerdp_peer_free(client); - while (1) - { - status = WaitForMultipleObjects(nCount, handles, FALSE, INFINITE); - - if ((status == WAIT_FAILED) || (status == WAIT_TIMEOUT)) - { - DEBUG_WARN("WaitForMultipleObjects failed\n"); - break; - } - - if (WaitForSingleObject(context->updateEvent, 0) == 0) - { - if (client->activated) - wf_update_peer_send(wfi, context); - - ResetEvent(context->updateEvent); - ReleaseSemaphore(wfi->updateSemaphore, 1, NULL); - } - - if (WaitForSingleObject(context->socketEvent, 0) == 0) - { - if (client->CheckFileDescriptor(client) != TRUE) - { - //printf("Failed to check peer file descriptor\n"); - context->socketClose = TRUE; - } - - ResetEvent(context->socketEvent); - ReleaseSemaphore(context->socketSemaphore, 1, NULL); - - if (context->socketClose) - break; - } - - //force disconnect - if (wfi->force_all_disconnect == TRUE) - { - DEBUG_WARN("Forcing Disconnect -> "); - break; - } - - /* FIXME: we should wait on this, instead of calling it every time */ - if (WTSVirtualChannelManagerCheckFileDescriptor(context->vcm) != TRUE) - break; - } - - DEBUG_WARN("Client %s disconnected.\n", client->local ? "(local)" : client->hostname); - - if (WaitForSingleObject(context->updateEvent, 0) == 0) - { - ResetEvent(context->updateEvent); - ReleaseSemaphore(wfi->updateSemaphore, 1, NULL); - } - - wf_update_peer_deactivate(wfi, context); - - client->Disconnect(client); - - freerdp_peer_context_free(client); - freerdp_peer_free(client); - - return 0; -} + return 0; +} diff --git a/server/Windows/wf_rdpsnd.c b/server/Windows/wf_rdpsnd.c index 004de3e1e..d9d7f465a 100644 --- a/server/Windows/wf_rdpsnd.c +++ b/server/Windows/wf_rdpsnd.c @@ -54,8 +54,9 @@ static void wf_peer_rdpsnd_activated(RdpsndServerContext* context) wfi = wf_info_get_instance(); wfi->agreed_format = NULL; - DEBUG_WARN("Client supports the following %d formats: \n", context->num_client_formats); - for(i = 0; i < context->num_client_formats; i++) + WLog_DBG(TAG, "Client supports the following %d formats:", context->num_client_formats); + + for (i = 0; i < context->num_client_formats; i++) { //TODO: improve the way we agree on a format for (j = 0; j < context->num_server_formats; j++) @@ -64,7 +65,7 @@ static void wf_peer_rdpsnd_activated(RdpsndServerContext* context) (context->client_formats[i].nChannels == context->server_formats[j].nChannels) && (context->client_formats[i].nSamplesPerSec == context->server_formats[j].nSamplesPerSec)) { - DEBUG_WARN("agreed on format!\n"); + WLog_DBG(TAG, "agreed on format!"); wfi->agreed_format = (AUDIO_FORMAT*) &context->server_formats[j]; break; } @@ -76,7 +77,7 @@ static void wf_peer_rdpsnd_activated(RdpsndServerContext* context) if (wfi->agreed_format == NULL) { - DEBUG_WARN("Could not agree on a audio format with the server\n"); + WLog_ERR(TAG, "Could not agree on a audio format with the server"); return; } @@ -116,7 +117,7 @@ int wf_rdpsnd_lock() break; case WAIT_FAILED: - DEBUG_WARN("wf_rdpsnd_lock failed with 0x%08X\n", GetLastError()); + WLog_ERR(TAG, "wf_rdpsnd_lock failed with 0x%08X", GetLastError()); return -1; break; } @@ -132,7 +133,7 @@ int wf_rdpsnd_unlock() if (ReleaseMutex(wfi->snd_mutex) == 0) { - DEBUG_WARN("wf_rdpsnd_unlock failed with 0x%08X\n", GetLastError()); + WLog_DBG(TAG, "wf_rdpsnd_unlock failed with 0x%08X", GetLastError()); return -1; } diff --git a/server/Windows/wf_update.c b/server/Windows/wf_update.c index f03763150..0c7991773 100644 --- a/server/Windows/wf_update.c +++ b/server/Windows/wf_update.c @@ -62,8 +62,7 @@ DWORD WINAPI wf_update_thread(LPVOID lpParam) if (wf_info_have_updates(wfi)) { wf_update_encode(wfi); - - //printf("Start of parallel sending\n"); + //WLog_DBG(TAG, "Start of parallel sending"); index = 0; for (peerindex = 0; peerindex < wfi->peerCount; peerindex++) { @@ -71,7 +70,7 @@ DWORD WINAPI wf_update_thread(LPVOID lpParam) { if (wfi->peers[index] && wfi->peers[index]->activated) { - //printf("Setting event for %d of %d\n", index + 1, wfi->activePeerCount); + //WLog_DBG(TAG, "Setting event for %d of %d", index + 1, wfi->activePeerCount); SetEvent(((wfPeerContext*) wfi->peers[index]->context)->updateEvent); } } @@ -80,13 +79,12 @@ DWORD WINAPI wf_update_thread(LPVOID lpParam) for (index = 0; index < wfi->activePeerCount; index++) { - //printf("Waiting for %d of %d\n", index + 1, wfi->activePeerCount); + //WLog_DBG(TAG, "Waiting for %d of %d", index + 1, wfi->activePeerCount); //WaitForSingleObject(wfi->updateSemaphore, INFINITE); WaitForSingleObject(wfi->updateSemaphore, 1000); } - //printf("End of parallel sending\n"); - + //WLog_DBG(TAG, "End of parallel sending"); wf_info_clear_invalid_region(wfi); } } @@ -103,8 +101,7 @@ DWORD WINAPI wf_update_thread(LPVOID lpParam) } } - //printf("Exiting Update Thread\n"); - + //WLog_DBG(TAG, "Exiting Update Thread"); return 0; } @@ -129,9 +126,7 @@ void wf_update_encode(wfInfo* wfi) rect.y = 0; rect.width = (UINT16) width; rect.height = (UINT16) height; - - //printf("x:%d y:%d w:%d h:%d\n", wfi->invalid.left, wfi->invalid.top, width, height); - + //WLog_DBG(TAG, "x:%d y:%d w:%d h:%d", wfi->invalid.left, wfi->invalid.top, width, height); Stream_Clear(wfi->s); rfx_compose_message(wfi->rfx_context, wfi->s, &rect, 1, @@ -175,9 +170,8 @@ void wf_update_peer_send(wfInfo* wfi, wfPeerContext* context) return; /* This is an unexpected error condition */ - - DEBUG_WARN("Unexpected Frame Index: Actual: %d Expected: %d\n", - wfi->frame_idx, context->frame_idx + 1); + WLog_DBG(TAG, "Unexpected Frame Index: Actual: %d Expected: %d", + wfi->frame_idx, context->frame_idx + 1); } wfi->cmd.codecID = client->settings->RemoteFxCodecId; @@ -189,7 +183,7 @@ void wf_update_encoder_reset(wfInfo* wfi) { if (wf_info_lock(wfi) > 0) { - DEBUG_WARN("Resetting encoder\n"); + WLog_DBG(TAG, "Resetting encoder"); if (wfi->rfx_context) { @@ -225,9 +219,7 @@ void wf_update_peer_activate(wfInfo* wfi, wfPeerContext* context) wf_update_encoder_reset(wfi); wfi->activePeerCount++; - - DEBUG_WARN("Activating Peer Updates: %d\n", wfi->activePeerCount); - + WLog_DBG(TAG, "Activating Peer Updates: %d", wfi->activePeerCount); wf_info_unlock(wfi); } } @@ -247,8 +239,7 @@ void wf_update_peer_deactivate(wfInfo* wfi, wfPeerContext* context) client->activated = FALSE; wfi->activePeerCount--; - - DEBUG_WARN("Deactivating Peer Updates: %d\n", wfi->activePeerCount); + WLog_DBG(TAG, "Deactivating Peer Updates: %d", wfi->activePeerCount); } wf_info_unlock(wfi); diff --git a/server/Windows/wf_wasapi.c b/server/Windows/wf_wasapi.c index a0e1c0137..58275fd34 100644 --- a/server/Windows/wf_wasapi.c +++ b/server/Windows/wf_wasapi.c @@ -41,12 +41,11 @@ int wf_wasapi_activate(RdpsndServerContext* context) if (devStr == NULL) { - _tprintf(_T("Failed to match for output device! Disabling rdpsnd.\n")); + WLog_ERR(TAG, "Failed to match for output device! Disabling rdpsnd."); return 1; } - DEBUG_WARN("RDPSND (WASAPI) Activated\n"); - + WLog_DBG(TAG, "RDPSND (WASAPI) Activated"); CreateThread(NULL, 0, wf_rdpsnd_wasapi_thread, latestPeer, 0, NULL); return 0; @@ -66,23 +65,23 @@ int wf_wasapi_get_device_string(LPWSTR pattern, LPWSTR * deviceStr) hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &IID_IMMDeviceEnumerator, (void **) &pEnumerator); if (FAILED(hr)) { - _tprintf(_T("Failed to cocreate device enumerator\n")); + WLog_ERR(TAG, "Failed to cocreate device enumerator"); exit(1); } hr = pEnumerator->lpVtbl->EnumAudioEndpoints(pEnumerator, eCapture, DEVICE_STATE_ACTIVE, &pCollection); if ( FAILED(hr) ) { - _tprintf(_T("Failed to create endpoint collection\n")); + WLog_ERR(TAG, "Failed to create endpoint collection"); exit(1); } pCollection->lpVtbl->GetCount(pCollection, &count); - _tprintf(_T("Num endpoints: %d\n"), count); + WLog_INFO(TAG, "Num endpoints: %d", count); if (count == 0) { - _tprintf(_T("No endpoints!\n")); + WLog_ERR(TAG, "No endpoints!"); exit(1); } @@ -94,28 +93,28 @@ int wf_wasapi_get_device_string(LPWSTR pattern, LPWSTR * deviceStr) hr = pCollection->lpVtbl->Item(pCollection, i, &pEndpoint); if ( FAILED(hr) ) { - _tprintf(_T("Failed to get endpoint %d\n"), i); + WLog_ERR(TAG, "Failed to get endpoint %d", i); exit(1); } hr = pEndpoint->lpVtbl->GetId(pEndpoint, &pwszID); if ( FAILED(hr) ) { - _tprintf(_T("Failed to get endpoint ID\n")); + WLog_ERR(TAG, "Failed to get endpoint ID"); exit(1); } hr = pEndpoint->lpVtbl->OpenPropertyStore(pEndpoint, STGM_READ, &pProps); if ( FAILED(hr) ) { - _tprintf(_T("Failed to open property store\n")); + WLog_ERR(TAG, "Failed to open property store"); exit(1); } hr = pProps->lpVtbl->GetValue(pProps, &PKEY_Device_FriendlyName, &nameVar); if ( FAILED(hr) ) { - _tprintf(_T("Failed to get device friendly name\n")); + WLog_ERR(TAG, "Failed to get device friendly name"); exit(1); } @@ -123,9 +122,8 @@ int wf_wasapi_get_device_string(LPWSTR pattern, LPWSTR * deviceStr) if (wcscmp(pattern, nameVar.pwszVal) < 0) { unsigned int devStrLen; - _tprintf(_T("Using sound ouput endpoint: [%s] (%s)\n"), nameVar.pwszVal, pwszID); - //_tprintf(_T("matched %d characters\n"), wcscmp(pattern, nameVar.pwszVal)); - + WLog_INFO(TAG, "Using sound ouput endpoint: [%s] (%s)", nameVar.pwszVal, pwszID); + //WLog_INFO(TAG, "matched %d characters", wcscmp(pattern, nameVar.pwszVal); devStrLen = wcslen(pwszID); *deviceStr = (LPWSTR) malloc((devStrLen * 2) + 2); ZeroMemory(*deviceStr, (devStrLen * 2) + 2); @@ -179,28 +177,28 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam) hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &IID_IMMDeviceEnumerator, (void **) &pEnumerator); if (FAILED(hr)) { - _tprintf(_T("Failed to cocreate device enumerator\n")); + WLog_ERR(TAG, "Failed to cocreate device enumerator"); exit(1); } hr = pEnumerator->lpVtbl->GetDevice(pEnumerator, devStr, &pDevice); if (FAILED(hr)) { - _tprintf(_T("Failed to cocreate get device\n")); + WLog_ERR(TAG, "Failed to cocreate get device"); exit(1); } hr = pDevice->lpVtbl->Activate(pDevice, &IID_IAudioClient, CLSCTX_ALL, NULL, (void **)&pAudioClient); if (FAILED(hr)) { - _tprintf(_T("Failed to activate audio client\n")); + WLog_ERR(TAG, "Failed to activate audio client"); exit(1); } hr = pAudioClient->lpVtbl->GetMixFormat(pAudioClient, &pwfx); if (FAILED(hr)) { - _tprintf(_T("Failed to get mix format\n")); + WLog_ERR(TAG, "Failed to get mix format"); exit(1); } @@ -218,21 +216,21 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam) if (FAILED(hr)) { - _tprintf(_T("Failed to initialize the audio client\n")); + WLog_ERR(TAG, "Failed to initialize the audio client"); exit(1); } hr = pAudioClient->lpVtbl->GetBufferSize(pAudioClient, &bufferFrameCount); if (FAILED(hr)) { - _tprintf(_T("Failed to get buffer size\n")); + WLog_ERR(TAG, "Failed to get buffer size"); exit(1); } hr = pAudioClient->lpVtbl->GetService(pAudioClient, &IID_IAudioCaptureClient, (void **) &pCaptureClient); if (FAILED(hr)) { - _tprintf(_T("Failed to get the capture client\n")); + WLog_ERR(TAG, "Failed to get the capture client"); exit(1); } @@ -241,12 +239,13 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam) hr = pAudioClient->lpVtbl->Start(pAudioClient); if (FAILED(hr)) { - _tprintf(_T("Failed to start capture\n")); + WLog_ERR(TAG, "Failed to start capture"); exit(1); } dCount = 0; - while(wfi->snd_stop == FALSE) + + while (wfi->snd_stop == FALSE) { DWORD flags; @@ -255,7 +254,7 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam) hr = pCaptureClient->lpVtbl->GetNextPacketSize(pCaptureClient, &packetLength); if (FAILED(hr)) { - _tprintf(_T("Failed to get packet length\n")); + WLog_ERR(TAG, "Failed to get packet length"); exit(1); } @@ -264,7 +263,7 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam) hr = pCaptureClient->lpVtbl->GetBuffer(pCaptureClient, &pData, &numFramesAvailable, &flags, NULL, NULL); if (FAILED(hr)) { - _tprintf(_T("Failed to get buffer\n")); + WLog_ERR(TAG, "Failed to get buffer"); exit(1); } @@ -276,14 +275,14 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam) hr = pCaptureClient->lpVtbl->ReleaseBuffer(pCaptureClient, numFramesAvailable); if (FAILED(hr)) { - _tprintf(_T("Failed to release buffer\n")); + WLog_ERR(TAG, "Failed to release buffer"); exit(1); } hr = pCaptureClient->lpVtbl->GetNextPacketSize(pCaptureClient, &packetLength); if (FAILED(hr)) { - _tprintf(_T("Failed to get packet length\n")); + WLog_ERR(TAG, "Failed to get packet length"); exit(1); } } @@ -292,7 +291,7 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam) pAudioClient->lpVtbl->Stop(pAudioClient); if (FAILED(hr)) { - _tprintf(_T("Failed to stop audio client\n")); + WLog_ERR(TAG, "Failed to stop audio client"); exit(1); } diff --git a/server/shadow/CMakeLists.txt b/server/shadow/CMakeLists.txt index 4f55d6568..9577611cc 100644 --- a/server/shadow/CMakeLists.txt +++ b/server/shadow/CMakeLists.txt @@ -190,14 +190,12 @@ add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "freerdp-shadow") -set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS - MONOLITHIC ${MONOLITHIC_BUILD} - MODULE freerdp - MODULES freerdp-core freerdp-common freerdp-codec freerdp-primitives freerdp-utils freerdp-gdi freerdp-crypto freerdp-locale) - +list(APPEND ${MODULE_PREFIX}_LIBS freerdp) list(APPEND ${MODULE_PREFIX}_LIBS freerdp-server) list(APPEND ${MODULE_PREFIX}_LIBS freerdp-client) -list(APPEND ${MODULE_PREFIX}_LIBS winpr winpr-makecert-tool) + +list(APPEND ${MODULE_PREFIX}_LIBS winpr) +list(APPEND ${MODULE_PREFIX}_LIBS winpr-makecert-tool) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/server/shadow/Mac/mac_shadow.c b/server/shadow/Mac/mac_shadow.c index 3b5ce4964..65e8b8bc9 100644 --- a/server/shadow/Mac/mac_shadow.c +++ b/server/shadow/Mac/mac_shadow.c @@ -396,7 +396,7 @@ void (^mac_capture_stream_handler)(CGDisplayStreamFrameStatus, uint64_t, IOSurfa else { freerdp_image_copy(surface->data, PIXEL_FORMAT_XRGB32, surface->scanline, - x, y, width, height, pSrcData, PIXEL_FORMAT_XRGB32, nSrcStep, x, y); + x, y, width, height, pSrcData, PIXEL_FORMAT_XRGB32, nSrcStep, x, y, NULL); } IOSurfaceUnlock(frameSurface, kIOSurfaceLockReadOnly, NULL); diff --git a/server/shadow/Win/win_dxgi.c b/server/shadow/Win/win_dxgi.c index bb4c71a99..bd2f5d62b 100644 --- a/server/shadow/Win/win_dxgi.c +++ b/server/shadow/Win/win_dxgi.c @@ -22,9 +22,12 @@ #include #include +#include #include "win_dxgi.h" +#define TAG SERVER_TAG("shadow.win") + #ifdef WITH_DXGI_1_2 static D3D_DRIVER_TYPE DriverTypes[] = @@ -247,7 +250,7 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "ID3D11Device::QueryInterface(IDXGIDevice) failure: %s (0x%04X)\n", + WLog_ERR(TAG, "ID3D11Device::QueryInterface(IDXGIDevice) failure: %s (0x%04X)", GetDxgiErrorString(hr), hr); return -1; } @@ -262,7 +265,7 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IDXGIDevice::GetParent(IDXGIAdapter) failure: %s (0x%04X)\n", + WLog_ERR(TAG, "IDXGIDevice::GetParent(IDXGIAdapter) failure: %s (0x%04X)", GetDxgiErrorString(hr), hr); return -1; } @@ -278,7 +281,7 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IDXGIOutput::GetDesc failure: %s (0x%04X)\n", + WLog_ERR(TAG, "IDXGIOutput::GetDesc failure: %s (0x%04X)", GetDxgiErrorString(hr), hr); return -1; } @@ -302,7 +305,7 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IDXGIAdapter::EnumOutputs failure: %s (0x%04X)\n", + WLog_ERR(TAG, "IDXGIAdapter::EnumOutputs failure: %s (0x%04X)", GetDxgiErrorString(hr), hr); return -1; } @@ -317,7 +320,7 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IDXGIOutput::QueryInterface(IDXGIOutput1) failure: %s (0x%04X)\n", + WLog_ERR(TAG, "IDXGIOutput::QueryInterface(IDXGIOutput1) failure: %s (0x%04X)", GetDxgiErrorString(hr), hr); return -1; } @@ -333,7 +336,7 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IDXGIOutput1::DuplicateOutput failure: %s (0x%04X)\n", + WLog_ERR(TAG, "IDXGIOutput1::DuplicateOutput failure: %s (0x%04X)", GetDxgiErrorString(hr), hr); return -1; } @@ -355,7 +358,7 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "ID3D11Device::CreateTexture2D failure: %s (0x%04X)\n", + WLog_ERR(TAG, "ID3D11Device::CreateTexture2D failure: %s (0x%04X)", GetDxgiErrorString(hr), hr); return -1; } @@ -391,7 +394,7 @@ int win_shadow_dxgi_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "D3D11CreateDevice failure: 0x%04X\n", hr); + WLog_ERR(TAG, "D3D11CreateDevice failure: 0x%04X", hr); return -1; } @@ -461,7 +464,7 @@ int win_shadow_dxgi_fetch_frame_data(winShadowSubsystem* subsystem, if (FAILED(hr)) { - fprintf(stderr, "ID3D11Texture2D::QueryInterface(IDXGISurface) failure: %s 0x%04X\n", + WLog_ERR(TAG, "ID3D11Texture2D::QueryInterface(IDXGISurface) failure: %s 0x%04X", GetDxgiErrorString(hr), hr); return -1; } @@ -470,7 +473,7 @@ int win_shadow_dxgi_fetch_frame_data(winShadowSubsystem* subsystem, if (FAILED(hr)) { - fprintf(stderr, "IDXGISurface::Map failure: %s 0x%04X\n", + WLog_ERR(TAG, "IDXGISurface::Map failure: %s 0x%04X", GetDxgiErrorString(hr), hr); if (hr == DXGI_ERROR_DEVICE_REMOVED) @@ -558,7 +561,7 @@ int win_shadow_dxgi_get_next_frame(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IDXGIOutputDuplication::AcquireNextFrame failure: %s (0x%04X)\n", + WLog_ERR(TAG, "IDXGIOutputDuplication::AcquireNextFrame failure: %s (0x%04X)", GetDxgiErrorString(hr), hr); if (hr == DXGI_ERROR_ACCESS_LOST) @@ -610,7 +613,7 @@ int win_shadow_dxgi_get_next_frame(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IDXGIResource::QueryInterface(ID3D11Texture2D) failure: %s (0x%04X)\n", + WLog_ERR(TAG, "IDXGIResource::QueryInterface(ID3D11Texture2D) failure: %s (0x%04X)", GetDxgiErrorString(hr), hr); return -1; } @@ -666,7 +669,7 @@ int win_shadow_dxgi_get_invalid_region(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IDXGIOutputDuplication::GetFrameMoveRects failure: %s (0x%04X) Size: %d Total %d Used: %d\n", + WLog_ERR(TAG, "IDXGIOutputDuplication::GetFrameMoveRects failure: %s (0x%04X) Size: %d Total %d Used: %d", GetDxgiErrorString(hr), hr, MoveRectsBufferSize, MetadataBufferSize, UsedBufferSize); return -1; } @@ -683,7 +686,7 @@ int win_shadow_dxgi_get_invalid_region(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IDXGIOutputDuplication::GetFrameDirtyRects failure: %s (0x%04X) Size: %d Total %d Used: %d\n", + WLog_ERR(TAG, "IDXGIOutputDuplication::GetFrameDirtyRects failure: %s (0x%04X) Size: %d Total %d Used: %d", GetDxgiErrorString(hr), hr, DirtyRectsBufferSize, MetadataBufferSize, UsedBufferSize); return -1; } diff --git a/server/shadow/Win/win_rdp.c b/server/shadow/Win/win_rdp.c index eef6fd724..55f7382f0 100644 --- a/server/shadow/Win/win_rdp.c +++ b/server/shadow/Win/win_rdp.c @@ -22,21 +22,24 @@ #include #include +#include #include "win_rdp.h" +#define TAG SERVER_TAG("shadow.win") + void shw_OnChannelConnectedEventHandler(rdpContext* context, ChannelConnectedEventArgs* e) { shwContext* shw = (shwContext*) context; - printf("OnChannelConnected: %s\n", e->name); + WLog_INFO(TAG, "OnChannelConnected: %s", e->name); } void shw_OnChannelDisconnectedEventHandler(rdpContext* context, ChannelDisconnectedEventArgs* e) { shwContext* shw = (shwContext*) context; - printf("OnChannelDisconnected: %s\n", e->name); + WLog_INFO(TAG, "OnChannelDisconnected: %s", e->name); } void shw_begin_paint(rdpContext* context) @@ -106,7 +109,7 @@ int shw_verify_x509_certificate(freerdp* instance, BYTE* data, int length, const void shw_OnConnectionResultEventHandler(rdpContext* context, ConnectionResultEventArgs* e) { shwContext* shw = (shwContext*) context; - printf("OnConnectionResult: %d\n", e->result); + WLog_INFO(TAG, "OnConnectionResult: %d", e->result); } BOOL shw_pre_connect(freerdp* instance) @@ -177,7 +180,7 @@ void* shw_client_thread(void* arg) bSuccess = freerdp_connect(instance); - printf("freerdp_connect: %d\n", bSuccess); + WLog_INFO(TAG, "freerdp_connect: %d", bSuccess); if (!bSuccess) { @@ -194,13 +197,13 @@ void* shw_client_thread(void* arg) if (!freerdp_get_fds(instance, rfds, &rcount, wfds, &wcount)) { - fprintf(stderr, "Failed to get FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to get FreeRDP file descriptor"); break; } if (!freerdp_channels_get_fds(channels, instance, rfds, &rcount, wfds, &wcount)) { - fprintf(stderr, "Failed to get channels file descriptor\n"); + WLog_ERR(TAG, "Failed to get channels file descriptor"); break; } @@ -214,13 +217,13 @@ void* shw_client_thread(void* arg) if (MsgWaitForMultipleObjects(fds_count, fds, FALSE, 1000, QS_ALLINPUT) == WAIT_FAILED) { - fprintf(stderr, "MsgWaitForMultipleObjects failure: 0x%08X", GetLastError()); + WLog_ERR(TAG, "MsgWaitForMultipleObjects failure: 0x%08X", GetLastError()); break; } if (!freerdp_check_fds(instance)) { - fprintf(stderr, "Failed to check FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to check FreeRDP file descriptor"); break; } @@ -231,7 +234,7 @@ void* shw_client_thread(void* arg) if (!freerdp_channels_check_fds(channels, instance)) { - fprintf(stderr, "Failed to check channels file descriptor\n"); + WLog_ERR(TAG, "Failed to check channels file descriptor"); break; } } diff --git a/server/shadow/Win/win_shadow.c b/server/shadow/Win/win_shadow.c index a2299d808..1615764a4 100644 --- a/server/shadow/Win/win_shadow.c +++ b/server/shadow/Win/win_shadow.c @@ -22,6 +22,7 @@ #include #include +#include #include "../shadow_screen.h" #include "../shadow_surface.h" @@ -29,6 +30,8 @@ #include "win_shadow.h" +#define TAG SERVER_TAG("shadow.win") + void win_shadow_input_synchronize_event(winShadowSubsystem* subsystem, UINT32 flags) { @@ -252,7 +255,7 @@ int win_shadow_surface_copy(winShadowSubsystem* subsystem) height = surface->height; } - printf("SurfaceCopy x: %d y: %d width: %d height: %d right: %d bottom: %d\n", + WLog_INFO(TAG, "SurfaceCopy x: %d y: %d width: %d height: %d right: %d bottom: %d", x, y, width, height, x + width, y + height); #if defined(WITH_WDS_API) @@ -277,7 +280,7 @@ int win_shadow_surface_copy(winShadowSubsystem* subsystem) freerdp_image_copy(surface->data, PIXEL_FORMAT_XRGB32, surface->scanline, x - surface->x, y - surface->y, width, height, - pDstData, PIXEL_FORMAT_XRGB32, nDstStep, 0, 0); + pDstData, PIXEL_FORMAT_XRGB32, nDstStep, 0, 0, NULL); ArrayList_Lock(server->clients); @@ -441,7 +444,7 @@ int win_shadow_subsystem_init(winShadowSubsystem* subsystem) subsystem->monitors[0].flags = 1; } - printf("width: %d height: %d\n", subsystem->width, subsystem->height); + WLog_INFO(TAG, "width: %d height: %d", subsystem->width, subsystem->height); return 1; } diff --git a/server/shadow/Win/win_wds.c b/server/shadow/Win/win_wds.c index 52e2d1cec..1ec82172f 100644 --- a/server/shadow/Win/win_wds.c +++ b/server/shadow/Win/win_wds.c @@ -22,6 +22,7 @@ #include #include +#include #include "win_rdp.h" @@ -46,6 +47,8 @@ #include +#define TAG SERVER_TAG("shadow.win") + DEFINE_GUID(CLSID_RDPSession,0x9B78F0E6,0x3E05,0x4A5B,0xB2,0xE8,0xE7,0x43,0xA8,0x95,0x6B,0x65); DEFINE_GUID(DIID__IRDPSessionEvents,0x98a97042,0x6698,0x40e9,0x8e,0xfd,0xb3,0x20,0x09,0x90,0x00,0x4b); DEFINE_GUID(IID_IRDPSRAPISharingSession,0xeeb20886,0xe470,0x4cf6,0x84,0x2b,0x27,0x39,0xc0,0xec,0x5c,0xfb); @@ -213,7 +216,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_GetTypeInfoCount( __RPC__in _IRDPSessionEvents * This, /* [out] */ __RPC__out UINT *pctinfo) { - printf("Shadow_IRDPSessionEvents_GetTypeInfoCount\n"); + WLog_INFO(TAG, "Shadow_IRDPSessionEvents_GetTypeInfoCount"); *pctinfo = 1; return S_OK; } @@ -224,7 +227,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_GetTypeInfo( /* [in] */ LCID lcid, /* [out] */ __RPC__deref_out_opt ITypeInfo **ppTInfo) { - printf("Shadow_IRDPSessionEvents_GetTypeInfo\n"); + WLog_INFO(TAG, "Shadow_IRDPSessionEvents_GetTypeInfo"); return E_NOTIMPL; } @@ -236,7 +239,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_GetIDsOfNames( /* [in] */ LCID lcid, /* [size_is][out] */ __RPC__out_ecount_full(cNames) DISPID *rgDispId) { - printf("Shadow_IRDPSessionEvents_GetIDsOfNames\n"); + WLog_INFO(TAG, "Shadow_IRDPSessionEvents_GetIDsOfNames"); return E_NOTIMPL; } @@ -263,7 +266,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke( VARIANT vr; UINT uArgErr; - printf("%s (%d)\n", GetRDPSessionEventString(dispIdMember), dispIdMember); + WLog_INFO(TAG, "%s (%d)", GetRDPSessionEventString(dispIdMember), dispIdMember); switch (dispIdMember) { @@ -280,7 +283,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke( if (FAILED(hr)) { - printf("%s DispGetParam(0, VT_DISPATCH) failure: 0x%08X\n", + WLog_ERR(TAG, "%s DispGetParam(0, VT_DISPATCH) failure: 0x%08X", GetRDPSessionEventString(dispIdMember), hr); return hr; } @@ -291,7 +294,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke( if (FAILED(hr)) { - printf("%s IDispatch::QueryInterface(IRDPSRAPIAttendee) failure: 0x%08X\n", + WLog_INFO(TAG, "%s IDispatch::QueryInterface(IRDPSRAPIAttendee) failure: 0x%08X", GetRDPSessionEventString(dispIdMember), hr); return hr; } @@ -303,7 +306,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke( if (FAILED(hr)) { - printf("%s IRDPSRAPIAttendee::put_ControlLevel() failure: 0x%08X\n", + WLog_INFO(TAG, "%s IRDPSRAPIAttendee::put_ControlLevel() failure: 0x%08X", GetRDPSessionEventString(dispIdMember), hr); return hr; } @@ -346,7 +349,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke( if (FAILED(hr)) { - printf("%s DispGetParam(1, VT_INT) failure: 0x%08X\n", + WLog_INFO(TAG, "%s DispGetParam(1, VT_INT) failure: 0x%08X", GetRDPSessionEventString(dispIdMember), hr); return hr; } @@ -360,7 +363,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke( if (FAILED(hr)) { - printf("%s DispGetParam(0, VT_DISPATCH) failure: 0x%08X\n", + WLog_ERR(TAG, "%s DispGetParam(0, VT_DISPATCH) failure: 0x%08X", GetRDPSessionEventString(dispIdMember), hr); return hr; } @@ -371,7 +374,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke( if (FAILED(hr)) { - printf("%s IDispatch::QueryInterface(IRDPSRAPIAttendee) failure: 0x%08X\n", + WLog_INFO(TAG, "%s IDispatch::QueryInterface(IRDPSRAPIAttendee) failure: 0x%08X", GetRDPSessionEventString(dispIdMember), hr); return hr; } @@ -380,7 +383,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke( if (FAILED(hr)) { - printf("%s IRDPSRAPIAttendee::put_ControlLevel() failure: 0x%08X\n", + WLog_INFO(TAG, "%s IRDPSRAPIAttendee::put_ControlLevel() failure: 0x%08X", GetRDPSessionEventString(dispIdMember), hr); return hr; } @@ -507,7 +510,7 @@ int win_shadow_wds_wnd_init(winShadowSubsystem* subsystem) if (!RegisterClassEx(&wndClassEx)) { - printf("RegisterClassEx failure\n"); + WLog_ERR(TAG, "RegisterClassEx failure"); return -1; } @@ -518,7 +521,7 @@ int win_shadow_wds_wnd_init(winShadowSubsystem* subsystem) if (!subsystem->hWnd) { - printf("CreateWindowEx failure\n"); + WLog_INFO(TAG, "CreateWindowEx failure"); return -1; } @@ -551,7 +554,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "OleInitialize() failure\n"); + WLog_ERR(TAG, "OleInitialize() failure"); return -1; } @@ -559,7 +562,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "CoInitialize() failure\n"); + WLog_ERR(TAG, "CoInitialize() failure"); return -1; } @@ -568,7 +571,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "CoCreateInstance(IRDPSRAPISharingSession) failure: 0x%08X\n", hr); + WLog_ERR(TAG, "CoCreateInstance(IRDPSRAPISharingSession) failure: 0x%08X", hr); return -1; } @@ -577,7 +580,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "QueryInterface(IID_IConnectionPointContainer) failure: 0x%08X\n", hr); + WLog_ERR(TAG, "QueryInterface(IID_IConnectionPointContainer) failure: 0x%08X", hr); return -1; } @@ -585,7 +588,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IConnectionPointContainer::FindConnectionPoint(_IRDPSessionEvents) failure: 0x%08X\n", hr); + WLog_ERR(TAG, "IConnectionPointContainer::FindConnectionPoint(_IRDPSessionEvents) failure: 0x%08X", hr); return -1; } @@ -597,7 +600,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IConnectionPoint::Advise(Shadow_IRDPSessionEvents) failure: 0x%08X\n", hr); + WLog_ERR(TAG, "IConnectionPoint::Advise(Shadow_IRDPSessionEvents) failure: 0x%08X", hr); return -1; } @@ -605,7 +608,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IRDPSRAPISharingSession::put_ColorDepth() failure: 0x%08X\n", hr); + WLog_ERR(TAG, "IRDPSRAPISharingSession::put_ColorDepth() failure: 0x%08X", hr); return -1; } @@ -614,14 +617,14 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IRDPSRAPISharingSession::GetDesktopSharedRect() failure: 0x%08X\n", hr); + WLog_ERR(TAG, "IRDPSRAPISharingSession::GetDesktopSharedRect() failure: 0x%08X", hr); return -1; } width = right - left; height = bottom - top; - printf("GetDesktopSharedRect(): left: %d top: %d right: %d bottom: %d width: %d height: %d\n", + WLog_INFO(TAG, "GetDesktopSharedRect(): left: %d top: %d right: %d bottom: %d width: %d height: %d", left, top, right, bottom, width, height); hr = subsystem->pSharingSession->lpVtbl->get_VirtualChannelManager(subsystem->pSharingSession, @@ -629,7 +632,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IRDPSRAPISharingSession::get_VirtualChannelManager() failure: 0x%08X\n", hr); + WLog_ERR(TAG, "IRDPSRAPISharingSession::get_VirtualChannelManager() failure: 0x%08X", hr); return -1; } @@ -638,7 +641,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IRDPSRAPISharingSession::get_ApplicationFilter() failure: 0x%08X\n", hr); + WLog_ERR(TAG, "IRDPSRAPISharingSession::get_ApplicationFilter() failure: 0x%08X", hr); return -1; } @@ -647,7 +650,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IRDPSRAPISharingSession::get_Attendees() failure: 0x%08X\n", hr); + WLog_ERR(TAG, "IRDPSRAPISharingSession::get_Attendees() failure: 0x%08X", hr); return -1; } @@ -655,7 +658,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IRDPSRAPISharingSession::get_Properties() failure: 0x%08X\n", hr); + WLog_ERR(TAG, "IRDPSRAPISharingSession::get_Properties() failure: 0x%08X", hr); return -1; } @@ -670,7 +673,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IRDPSRAPISessionProperties::put_Property(PortId) failure: 0x%08X\n", hr); + WLog_ERR(TAG, "IRDPSRAPISessionProperties::put_Property(PortId) failure: 0x%08X", hr); return -1; } @@ -685,7 +688,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IRDPSRAPISessionProperties::put_Property(DrvConAttach) failure: 0x%08X\n", hr); + WLog_ERR(TAG, "IRDPSRAPISessionProperties::put_Property(DrvConAttach) failure: 0x%08X", hr); return -1; } @@ -703,7 +706,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IRDPSRAPISessionProperties::put_Property(PortProtocol) failure: 0x%08X\n", hr); + WLog_ERR(TAG, "IRDPSRAPISessionProperties::put_Property(PortProtocol) failure: 0x%08X", hr); return -1; } @@ -711,7 +714,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IRDPSRAPISharingSession::Open() failure: 0x%08X\n", hr); + WLog_ERR(TAG, "IRDPSRAPISharingSession::Open() failure: 0x%08X", hr); return -1; } @@ -720,7 +723,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IRDPSRAPISharingSession::get_Invitations() failure\n"); + WLog_ERR(TAG, "IRDPSRAPISharingSession::get_Invitations() failure"); return -1; } @@ -737,7 +740,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IRDPSRAPIInvitationManager::CreateInvitation() failure: 0x%08X\n", hr); + WLog_ERR(TAG, "IRDPSRAPIInvitationManager::CreateInvitation() failure: 0x%08X", hr); return -1; } @@ -745,7 +748,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - fprintf(stderr, "IRDPSRAPIInvitation::get_ConnectionString() failure: 0x%08X\n", hr); + WLog_ERR(TAG, "IRDPSRAPIInvitation::get_ConnectionString() failure: 0x%08X", hr); return -1; } @@ -759,7 +762,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (status < 0) return -1; - printf("ConnectionString: %s\n", file->ConnectionString2); + WLog_INFO(TAG, "ConnectionString: %s", file->ConnectionString2); if (0) { @@ -781,7 +784,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (status < 0) { - printf("win_shadow_rdp_init() failure: %d\n", status); + WLog_ERR(TAG, "win_shadow_rdp_init() failure: %d", status); return status; } @@ -808,7 +811,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (status < 0) { - printf("win_shadow_rdp_start() failure: %d\n", status); + WLog_ERR(TAG, "win_shadow_rdp_start() failure: %d", status); return status; } diff --git a/server/shadow/X11/x11_shadow.c b/server/shadow/X11/x11_shadow.c index 82281833e..eff82b7a8 100644 --- a/server/shadow/X11/x11_shadow.c +++ b/server/shadow/X11/x11_shadow.c @@ -37,6 +37,7 @@ #include #include +#include #include "../shadow_screen.h" #include "../shadow_capture.h" @@ -44,6 +45,8 @@ #include "x11_shadow.h" +#define TAG SERVER_TAG("shadow.x11") + void x11_shadow_input_synchronize_event(x11ShadowSubsystem* subsystem, UINT32 flags) { @@ -462,7 +465,7 @@ int x11_shadow_screen_grab(x11ShadowSubsystem* subsystem) freerdp_image_copy(surface->data, PIXEL_FORMAT_XRGB32, surface->scanline, x - surface->x, y - surface->y, width, height, (BYTE*) image->data, PIXEL_FORMAT_XRGB32, - image->bytes_per_line, x, y); + image->bytes_per_line, x, y, NULL); region16_union_rect(&(subsystem->invalidRegion), &(subsystem->invalidRegion), &invalidRect); @@ -505,7 +508,7 @@ int x11_shadow_screen_grab(x11ShadowSubsystem* subsystem) freerdp_image_copy(surface->data, PIXEL_FORMAT_XRGB32, surface->scanline, x, y, width, height, (BYTE*) image->data, PIXEL_FORMAT_XRGB32, - image->bytes_per_line, x, y); + image->bytes_per_line, x, y, NULL); region16_union_rect(&(subsystem->invalidRegion), &(subsystem->invalidRegion), &invalidRect); @@ -721,7 +724,7 @@ int x11_shadow_xshm_init(x11ShadowSubsystem* subsystem) if (!subsystem->fb_image) { - fprintf(stderr, "XShmCreateImage failed\n"); + WLog_ERR(TAG, "XShmCreateImage failed"); return -1; } @@ -730,7 +733,7 @@ int x11_shadow_xshm_init(x11ShadowSubsystem* subsystem) if (subsystem->fb_shm_info.shmid == -1) { - fprintf(stderr, "shmget failed\n"); + WLog_ERR(TAG, "shmget failed"); return -1; } @@ -739,7 +742,7 @@ int x11_shadow_xshm_init(x11ShadowSubsystem* subsystem) if (subsystem->fb_shm_info.shmaddr == ((char*) -1)) { - fprintf(stderr, "shmat failed\n"); + WLog_ERR(TAG, "shmat failed"); return -1; } @@ -803,7 +806,7 @@ int x11_shadow_subsystem_init(x11ShadowSubsystem* subsystem) if (!subsystem->display) { - fprintf(stderr, "failed to open display: %s\n", XDisplayName(NULL)); + WLog_ERR(TAG, "failed to open display: %s", XDisplayName(NULL)); return -1; } @@ -835,7 +838,7 @@ int x11_shadow_subsystem_init(x11ShadowSubsystem* subsystem) if (!pfs) { - fprintf(stderr, "XListPixmapFormats failed\n"); + WLog_ERR(TAG, "XListPixmapFormats failed"); return -1; } @@ -860,7 +863,7 @@ int x11_shadow_subsystem_init(x11ShadowSubsystem* subsystem) if (!vis) { - fprintf(stderr, "XGetVisualInfo failed\n"); + WLog_ERR(TAG, "XGetVisualInfo failed"); return -1; } @@ -931,7 +934,7 @@ int x11_shadow_subsystem_init(x11ShadowSubsystem* subsystem) subsystem->monitors[0].flags = 1; } - printf("X11 Extensions: XFixes: %d Xinerama: %d XDamage: %d XShm: %d\n", + WLog_INFO(TAG, "X11 Extensions: XFixes: %d Xinerama: %d XDamage: %d XShm: %d", subsystem->use_xfixes, subsystem->use_xinerama, subsystem->use_xdamage, subsystem->use_xshm); return 1; diff --git a/server/shadow/shadow_capture.c b/server/shadow/shadow_capture.c index 9f07ac964..6b1ffeb76 100644 --- a/server/shadow/shadow_capture.c +++ b/server/shadow/shadow_capture.c @@ -23,10 +23,14 @@ #include #include +#include + #include "shadow_surface.h" #include "shadow_capture.h" +#define TAG SERVER_TAG("shadow") + int shadow_capture_align_clip_rect(RECTANGLE_16* rect, RECTANGLE_16* clip) { int dx, dy; @@ -177,32 +181,36 @@ int shadow_capture_compare(BYTE* pData1, int nStep1, int nWidth, int nHeight, BY if (0) { - printf("\n"); + char *col_str = calloc(ncol + 1, sizeof(char)); + if (!col_str) + { + WLog_ERR(TAG, "calloc failed!"); + return 1; + } for (tx = 0; tx < ncol; tx++) - printf("-"); - printf("\n"); + sprintf(&col_str[tx], "-"); + WLog_INFO(TAG, "%s", col_str); for (tx = 0; tx < ncol; tx++) - printf("%s", cols[tx] ? "O" : "X"); - printf("\n"); + sprintf(&col_str[tx], "%c", cols[tx] ? 'O' : 'X'); + WLog_INFO(TAG, "%s", col_str); for (tx = 0; tx < ncol; tx++) - printf("-"); - printf("\n"); + sprintf(&col_str[tx], "-"); + WLog_INFO(TAG, "%s", col_str); for (ty = 0; ty < nrow; ty++) { for (tx = 0; tx < ncol; tx++) - { - printf("%s", grid[ty][tx] ? "O" : "X"); - } - - printf("|%s|\n", rows[ty] ? "O" : "X"); + sprintf(&col_str[tx], "%c", cols[tx] ? 'O' : 'X'); + WLog_INFO(TAG, "%s", col_str); + WLog_INFO(TAG, "|%s|", rows[ty] ? "O" : "X"); } - printf("left: %d top: %d right: %d bottom: %d ncol: %d nrow: %d\n", + WLog_INFO(TAG, "left: %d top: %d right: %d bottom: %d ncol: %d nrow: %d", l, t, r, b, ncol, nrow); + free(col_str); } return 1; diff --git a/server/shadow/shadow_client.c b/server/shadow/shadow_client.c index a0cbdfe4d..5002fa76b 100644 --- a/server/shadow/shadow_client.c +++ b/server/shadow/shadow_client.c @@ -27,8 +27,12 @@ #include #include +#include + #include "shadow.h" +#define TAG CLIENT_TAG("shadow") + void shadow_client_context_new(freerdp_peer* peer, rdpShadowClient* client) { rdpSettings* settings; @@ -134,7 +138,7 @@ BOOL shadow_client_post_connect(freerdp_peer* peer) if (settings->ColorDepth == 24) settings->ColorDepth = 16; /* disable 24bpp */ - fprintf(stderr, "Client from %s is activated (%dx%d@%d)\n", + WLog_ERR(TAG, "Client from %s is activated (%dx%d@%d)", peer->hostname, settings->DesktopWidth, settings->DesktopHeight, settings->ColorDepth); peer->update->DesktopResize(peer->update->context); @@ -510,7 +514,7 @@ int shadow_client_send_bitmap_update(rdpShadowClient* client, rdpShadowSurface* buffer = encoder->grid[k]; freerdp_image_copy(buffer, dstFormat, -1, 0, 0, nWidth, nHeight, - data, srcFormat, nSrcStep, 0, 0); + data, srcFormat, nSrcStep, 0, 0, NULL); lines = freerdp_bitmap_compress((char*) buffer, nWidth, nHeight, s, settings->ColorDepth, 64 * 64 * 4, nHeight - 1, ts, e); @@ -600,7 +604,7 @@ int shadow_client_send_surface_update(rdpShadowClient* client) nWidth = extents->right - extents->left; nHeight = extents->bottom - extents->top; - //printf("shadow_client_send_surface_update: x: %d y: %d width: %d height: %d right: %d bottom: %d\n", + //WLog_INFO(TAG, "shadow_client_send_surface_update: x: %d y: %d width: %d height: %d right: %d bottom: %d", // nXSrc, nYSrc, nWidth, nHeight, nXSrc + nWidth, nYSrc + nHeight); if (settings->RemoteFxCodec || settings->NSCodec) @@ -732,7 +736,7 @@ void* shadow_client_thread(rdpShadowClient* client) { if (!peer->CheckFileDescriptor(peer)) { - fprintf(stderr, "Failed to check FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to check FreeRDP file descriptor"); break; } } @@ -741,7 +745,7 @@ void* shadow_client_thread(rdpShadowClient* client) { if (WTSVirtualChannelManagerCheckFileDescriptor(client->vcm) != TRUE) { - fprintf(stderr, "WTSVirtualChannelManagerCheckFileDescriptor failure\n"); + WLog_ERR(TAG, "WTSVirtualChannelManagerCheckFileDescriptor failure"); break; } } diff --git a/server/shadow/shadow_encomsp.c b/server/shadow/shadow_encomsp.c index f0b1d48e3..ad0be4870 100644 --- a/server/shadow/shadow_encomsp.c +++ b/server/shadow/shadow_encomsp.c @@ -20,10 +20,13 @@ #include "config.h" #endif +#include #include "shadow.h" #include "shadow_encomsp.h" +#define TAG SERVER_TAG("shadow") + static int encomsp_change_participant_control_level(EncomspServerContext* context, ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU* pdu) { @@ -32,7 +35,7 @@ static int encomsp_change_participant_control_level(EncomspServerContext* contex BOOL mayInteract; rdpShadowClient* client = (rdpShadowClient*) context->custom; - printf("ChangeParticipantControlLevel: ParticipantId: %d Flags: 0x%04X\n", + WLog_INFO(TAG, "ChangeParticipantControlLevel: ParticipantId: %d Flags: 0x%04X", pdu->ParticipantId, pdu->Flags); mayView = (pdu->Flags & ENCOMSP_MAY_VIEW) ? TRUE : FALSE; diff --git a/server/shadow/shadow_server.c b/server/shadow/shadow_server.c index 84d61adab..49b4c1480 100644 --- a/server/shadow/shadow_server.c +++ b/server/shadow/shadow_server.c @@ -28,6 +28,7 @@ #include #include +#include #include @@ -42,6 +43,8 @@ #include "shadow.h" +#define TAG SERVER_TAG("shadow") + #ifdef _WIN32 static BOOL g_MessagePump = TRUE; #else @@ -79,14 +82,14 @@ int shadow_server_print_command_line_help(int argc, char** argv) int length; COMMAND_LINE_ARGUMENT_A* arg; - printf("Usage: %s [options]\n", argv[0]); - printf("\n"); + WLog_INFO(TAG, "Usage: %s [options]", argv[0]); + WLog_INFO(TAG, ""); - printf("Syntax:\n"); - printf(" /flag (enables flag)\n"); - printf(" /option: (specifies option with value)\n"); - printf(" +toggle -toggle (enables or disables toggle, where '/' is a synonym of '+')\n"); - printf("\n"); + WLog_INFO(TAG, "Syntax:"); + WLog_INFO(TAG, " /flag (enables flag)"); + WLog_INFO(TAG, " /option: (specifies option with value)"); + WLog_INFO(TAG, " +toggle -toggle (enables or disables toggle, where '/' is a synonym of '+')"); + WLog_INFO(TAG, ""); arg = shadow_args; @@ -94,28 +97,28 @@ int shadow_server_print_command_line_help(int argc, char** argv) { if (arg->Flags & COMMAND_LINE_VALUE_FLAG) { - printf(" %s", "/"); - printf("%-20s", arg->Name); - printf("\t%s\n", arg->Text); + WLog_INFO(TAG, " %s", "/"); + WLog_INFO(TAG, "%-20s", arg->Name); + WLog_INFO(TAG, "\t%s", arg->Text); } else if ((arg->Flags & COMMAND_LINE_VALUE_REQUIRED) || (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL)) { - printf(" %s", "/"); + WLog_INFO(TAG, " %s", "/"); if (arg->Format) { length = (int) (strlen(arg->Name) + strlen(arg->Format) + 2); str = (char*) malloc(length + 1); sprintf_s(str, length + 1, "%s:%s", arg->Name, arg->Format); - printf("%-20s", str); + WLog_INFO(TAG, "%-20s", str); free(str); } else { - printf("%-20s", arg->Name); + WLog_INFO(TAG, "%-20s", arg->Name); } - printf("\t%s\n", arg->Text); + WLog_INFO(TAG, "\t%s", arg->Text); } else if (arg->Flags & COMMAND_LINE_VALUE_BOOL) { @@ -124,12 +127,12 @@ int shadow_server_print_command_line_help(int argc, char** argv) sprintf_s(str, length + 1, "%s (default:%s)", arg->Name, arg->Default ? "on" : "off"); - printf(" %s", arg->Default ? "-" : "+"); + WLog_INFO(TAG, " %s", arg->Default ? "-" : "+"); - printf("%-20s", str); + WLog_INFO(TAG, "%-20s", str); free(str); - printf("\t%s\n", arg->Text); + WLog_INFO(TAG, "\t%s", arg->Text); } } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL); @@ -141,7 +144,7 @@ int shadow_server_command_line_status_print(rdpShadowServer* server, int argc, c { if (status == COMMAND_LINE_STATUS_PRINT_VERSION) { - printf("FreeRDP version %s (git %s)\n", FREERDP_VERSION_FULL, GIT_REVISION); + WLog_INFO(TAG, "FreeRDP version %s (git %s)", FREERDP_VERSION_FULL, GIT_REVISION); return COMMAND_LINE_STATUS_PRINT_VERSION; } else if (status == COMMAND_LINE_STATUS_PRINT) @@ -295,7 +298,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a width = monitor->right - monitor->left; height = monitor->bottom - monitor->top; - printf(" %s [%d] %dx%d\t+%d+%d\n", + WLog_INFO(TAG, " %s [%d] %dx%d\t+%d+%d", (monitor->flags == 1) ? "*" : " ", index, width, height, monitor->left, monitor->top); } @@ -357,7 +360,7 @@ void* shadow_server_thread(rdpShadowServer* server) if (listener->GetEventHandles(listener, events, &nCount) < 0) { - fprintf(stderr, "Failed to get FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to get FreeRDP file descriptor"); break; } @@ -372,7 +375,7 @@ void* shadow_server_thread(rdpShadowServer* server) if (!listener->CheckFileDescriptor(listener)) { - fprintf(stderr, "Failed to check FreeRDP file descriptor\n"); + WLog_ERR(TAG, "Failed to check FreeRDP file descriptor"); break; } @@ -557,7 +560,7 @@ int shadow_server_init(rdpShadowServer* server) status = server->subsystem->Init(server->subsystem); if (status < 0) - fprintf(stderr, "subsystem init failure: %d\n", status); + WLog_ERR(TAG, "subsystem init failure: %d", status); } return 1; diff --git a/winpr/libwinpr/path/shell.c b/winpr/libwinpr/path/shell.c index eae9a6539..d66a18b95 100644 --- a/winpr/libwinpr/path/shell.c +++ b/winpr/libwinpr/path/shell.c @@ -273,7 +273,7 @@ char* GetKnownSubPath(int id, const char* path) char* GetEnvironmentPath(char* name) { - char* env; + char* env = NULL; DWORD nSize; nSize = GetEnvironmentVariableA(name, NULL, 0); diff --git a/winpr/libwinpr/sspi/NTLM/ntlm_message.c b/winpr/libwinpr/sspi/NTLM/ntlm_message.c index 2155d8145..c1da55605 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm_message.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm_message.c @@ -211,7 +211,6 @@ SECURITY_STATUS ntlm_read_NegotiateMessage(NTLM_CONTEXT* context, PSecBuffer buf if (!((message->NegotiateFlags & NTLMSSP_REQUEST_TARGET) && (message->NegotiateFlags & NTLMSSP_NEGOTIATE_NTLM) && - (message->NegotiateFlags & NTLMSSP_NEGOTIATE_ALWAYS_SIGN) && (message->NegotiateFlags & NTLMSSP_NEGOTIATE_UNICODE))) { Stream_Free(s, FALSE); @@ -432,7 +431,7 @@ SECURITY_STATUS ntlm_read_ChallengeMessage(NTLM_CONTEXT* context, PSecBuffer buf if (context->ChallengeTargetInfo.cbBuffer > 0) { - WLog_ERR(TAG, "ChallengeTargetInfo (%d):", (int) context->ChallengeTargetInfo.cbBuffer); + WLog_DBG(TAG, "ChallengeTargetInfo (%d):", (int) context->ChallengeTargetInfo.cbBuffer); ntlm_print_av_pair_list(context->ChallengeTargetInfo.pvBuffer); } @@ -917,7 +916,7 @@ SECURITY_STATUS ntlm_write_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer if (context->AuthenticateTargetInfo.cbBuffer > 0) { - WLog_ERR(TAG, "AuthenticateTargetInfo (%d):", (int) context->AuthenticateTargetInfo.cbBuffer); + WLog_DBG(TAG, "AuthenticateTargetInfo (%d):", (int) context->AuthenticateTargetInfo.cbBuffer); ntlm_print_av_pair_list(context->AuthenticateTargetInfo.pvBuffer); } diff --git a/winpr/libwinpr/utils/collections/BitStream.c b/winpr/libwinpr/utils/collections/BitStream.c index 3756e6387..02e336a79 100644 --- a/winpr/libwinpr/utils/collections/BitStream.c +++ b/winpr/libwinpr/utils/collections/BitStream.c @@ -168,7 +168,7 @@ void BitDump(const char* tag, int level, const BYTE* buffer, UINT32 length, UINT const char* str; const char** strs; char pbuffer[64 * 8 + 1]; - size_t pos = 0, len = sizeof(pbuffer); + size_t pos = 0; strs = (flags & BITDUMP_MSB_FIRST) ? BYTE_BIT_STRINGS_MSB : BYTE_BIT_STRINGS_LSB; for (i = 0; i < length; i += 8) diff --git a/winpr/libwinpr/utils/print.c b/winpr/libwinpr/utils/print.c index c8cd7a44e..20bdae42b 100644 --- a/winpr/libwinpr/utils/print.c +++ b/winpr/libwinpr/utils/print.c @@ -37,7 +37,6 @@ void winpr_HexDump(const char* tag, int level, const BYTE* data, int length) { const BYTE* p = data; int i, line, offset = 0; - const size_t llen = (length > WINPR_HEXDUMP_LINE_LENGTH) ? WINPR_HEXDUMP_LINE_LENGTH : length; size_t blen = 7 + WINPR_HEXDUMP_LINE_LENGTH * 5; size_t pos = 0; char* buffer = malloc(blen); diff --git a/winpr/libwinpr/utils/wlog/wlog.c b/winpr/libwinpr/utils/wlog/wlog.c index 8d1794451..34dc579a0 100644 --- a/winpr/libwinpr/utils/wlog/wlog.c +++ b/winpr/libwinpr/utils/wlog/wlog.c @@ -74,7 +74,7 @@ static void log_recursion(const char* file, const char* fkt, int line) __android_log_print(ANDROID_LOG_FATAL, tag, "Check %s [%s:%d]", fkt, file, line); for (i=0; iLevel = WLOG_WARN; + log->Level = WLOG_INFO; nSize = GetEnvironmentVariableA("WLOG_LEVEL", NULL, 0); if (nSize)