diff --git a/cmake/ConfigOptions.cmake b/cmake/ConfigOptions.cmake index 7f1bb6f97..70e861c86 100644 --- a/cmake/ConfigOptions.cmake +++ b/cmake/ConfigOptions.cmake @@ -24,6 +24,8 @@ option(WITH_SERVER "Build server binaries" OFF) option(WITH_CHANNELS "Build virtual channel plugins" ON) option(WITH_THIRD_PARTY "Build third-party components" OFF) +option(WITH_SERVER_INTERFACE "Build server as a library with an interface" OFF) + option(WITH_DEBUG_ALL "Print all debug messages." OFF) if(WITH_DEBUG_ALL) diff --git a/server/Windows/CMakeLists.txt b/server/Windows/CMakeLists.txt index 70eb261eb..a58ff2606 100644 --- a/server/Windows/CMakeLists.txt +++ b/server/Windows/CMakeLists.txt @@ -17,7 +17,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_executable(wfreerdp-server +include_directories(.) + +set(WFREERDP_SERVER_SRCS wf_update.c wf_update.h wf_dxgi.c @@ -33,17 +35,21 @@ add_executable(wfreerdp-server wf_settings.c wf_settings.h wf_info.c - wf_info.h - wfreerdp.c - wfreerdp.h) + wf_info.h) + +if(WITH_SERVER_INTERFACE) + add_library(wfreerdp-server ${WFREERDP_SERVER_SRCS}) + set_target_properties(wfreerdp-server PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +else() + set(WFREERDP_SERVER_SRCS ${WFREERDP_SERVER_SRCS} cli/wfreerdp.c cli/wfreerdp.h) + add_executable(wfreerdp-server ${WFREERDP_SERVER_SRCS}) +endif() if(WITH_MONOLITHIC_BUILD) - target_link_libraries(wfreerdp-server freerdp) - + set(WFREERDP_SERVER_LIBS freerdp) else() - target_link_libraries(wfreerdp-server - + set(WFREERDP_SERVER_LIBS freerdp-core freerdp-utils @@ -53,3 +59,16 @@ else() freerdp-channels) endif() + +target_link_libraries(wfreerdp-server ${WFREERDP_SERVER_LIBS}) + + +if(WITH_SERVER_INTERFACE) + install(TARGETS wfreerdp-server DESTINATION ${CMAKE_INSTALL_LIBDIR}) +else() + install(TARGETS wfreerdp-server DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() + +if(WITH_SERVER_INTERFACE) + add_subdirectory(cli) +endif() diff --git a/server/Windows/cli/CMakeLists.txt b/server/Windows/cli/CMakeLists.txt new file mode 100644 index 000000000..bbd5f1a40 --- /dev/null +++ b/server/Windows/cli/CMakeLists.txt @@ -0,0 +1,34 @@ +# FreeRDP: A Remote Desktop Protocol Client +# FreeRDP Windows Server (CLI) 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. + +include_directories(..) + +set(WFREERDP_SERVER_CLI_SRCS + wfreerdp.c + wfreerdp.h) + +add_executable(wfreerdp-server-cli ${WFREERDP_SERVER_CLI_SRCS}) + +set_target_properties(wfreerdp-server-cli PROPERTIES OUTPUT_NAME "wfreerdp-server") + +set(WFREERDP_SERVER_CLI_LIBS wfreerdp-server) + +target_link_libraries(wfreerdp-server-cli ${WFREERDP_SERVER_CLI_LIBS}) + + +install(TARGETS wfreerdp-server-cli DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/server/Windows/wfreerdp.c b/server/Windows/cli/wfreerdp.c similarity index 95% rename from server/Windows/wfreerdp.c rename to server/Windows/cli/wfreerdp.c index e82f635f0..b4e7849d7 100644 --- a/server/Windows/wfreerdp.c +++ b/server/Windows/cli/wfreerdp.c @@ -1,52 +1,52 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * FreeRDP Windows Server - * - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#include -#include - -#include "wf_interface.h" - -#include "wfreerdp.h" - -int main(int argc, char* argv[]) -{ - wfServer* server; - - server = wfreerdp_server_new(); - - if (argc == 2) - server->port = (DWORD) atoi(argv[1]); - - wfreerdp_server_start(server); - - WaitForSingleObject(server->thread, INFINITE); - - wfreerdp_server_stop(server); - wfreerdp_server_free(server); - - return 0; -} +/** + * FreeRDP: A Remote Desktop Protocol Client + * FreeRDP Windows Server + * + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include +#include + +#include "wf_interface.h" + +#include "wfreerdp.h" + +int main(int argc, char* argv[]) +{ + wfServer* server; + + server = wfreerdp_server_new(); + + if (argc == 2) + server->port = (DWORD) atoi(argv[1]); + + wfreerdp_server_start(server); + + WaitForSingleObject(server->thread, INFINITE); + + wfreerdp_server_stop(server); + wfreerdp_server_free(server); + + return 0; +} diff --git a/server/Windows/wfreerdp.h b/server/Windows/cli/wfreerdp.h similarity index 72% rename from server/Windows/wfreerdp.h rename to server/Windows/cli/wfreerdp.h index 7f804fa07..68e3fad10 100644 --- a/server/Windows/wfreerdp.h +++ b/server/Windows/cli/wfreerdp.h @@ -1,41 +1,25 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * FreeRDP Windows Server - * - * 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. - */ - -#ifndef WFREERDP_H -#define WFREERDP_H - -#include - -#include "wf_info.h" - -struct wf_peer_context -{ - rdpContext _p; - - wfInfo* info; - boolean activated; - HANDLE updateEvent; - BOOL socketClose; - HANDLE socketEvent; - HANDLE socketThread; - HANDLE socketSemaphore; -}; -typedef struct wf_peer_context wfPeerContext; - -#endif /* WFREERDP_H */ +/** + * FreeRDP: A Remote Desktop Protocol Client + * FreeRDP Windows Server + * + * 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. + */ + +#ifndef WFREERDP_H +#define WFREERDP_H + +#include + +#endif /* WFREERDP_H */ diff --git a/server/Windows/wf_dxgi.h b/server/Windows/wf_dxgi.h index b538a69fd..1e0fcb7f7 100644 --- a/server/Windows/wf_dxgi.h +++ b/server/Windows/wf_dxgi.h @@ -20,7 +20,7 @@ #ifndef WF_DXGI_H #define WF_DXGI_H -#include "wfreerdp.h" +#include "wf_interface.h" diff --git a/server/Windows/wf_info.h b/server/Windows/wf_info.h index be81bf3e1..2ec70cf3c 100644 --- a/server/Windows/wf_info.h +++ b/server/Windows/wf_info.h @@ -20,39 +20,7 @@ #ifndef WF_INFO_H #define WF_INFO_H -#include -#include - -struct wf_peer_context; -typedef struct wf_peer_context wfPeerContext; - -struct wf_info -{ - STREAM* s; - int width; - int height; - int bitsPerPixel; - HDC driverDC; - int peerCount; - BOOL activated; - void* changeBuffer; - int framesPerSecond; - LPTSTR deviceKey; - TCHAR deviceName[32]; - wfPeerContext** peers; - - RECT invalid; - HANDLE mutex; - BOOL updatePending; - HANDLE updateEvent; - HANDLE updateThread; - HANDLE updateSemaphore; - RFX_CONTEXT* rfx_context; - unsigned long lastUpdate; - unsigned long nextUpdate; - SURFACE_BITS_COMMAND cmd; -}; -typedef struct wf_info wfInfo; +#include "wf_interface.h" int wf_info_lock(wfInfo* wfi); int wf_info_try_lock(wfInfo* wfi, DWORD dwMilliseconds); diff --git a/server/Windows/wf_input.h b/server/Windows/wf_input.h index 52f054977..d06c2ed74 100644 --- a/server/Windows/wf_input.h +++ b/server/Windows/wf_input.h @@ -20,7 +20,7 @@ #ifndef WF_INPUT_H #define WF_INPUT_H -#include "wfreerdp.h" +#include "wf_interface.h" void wf_peer_keyboard_event(rdpInput* input, uint16 flags, uint16 code); void wf_peer_unicode_keyboard_event(rdpInput* input, uint16 flags, uint16 code); diff --git a/server/Windows/wf_interface.h b/server/Windows/wf_interface.h index 7ba5e7cc9..8d3e8f65b 100644 --- a/server/Windows/wf_interface.h +++ b/server/Windows/wf_interface.h @@ -20,12 +20,58 @@ #ifndef WF_INTERFACE_H #define WF_INTERFACE_H -#include "wfreerdp.h" - #include + +#include #include #include +#include +#include + +typedef struct wf_info wfInfo; +typedef struct wf_peer_context wfPeerContext; + +struct wf_info +{ + STREAM* s; + int width; + int height; + int bitsPerPixel; + HDC driverDC; + int peerCount; + BOOL activated; + void* changeBuffer; + int framesPerSecond; + LPTSTR deviceKey; + TCHAR deviceName[32]; + wfPeerContext** peers; + + RECT invalid; + HANDLE mutex; + BOOL updatePending; + HANDLE updateEvent; + HANDLE updateThread; + HANDLE updateSemaphore; + RFX_CONTEXT* rfx_context; + unsigned long lastUpdate; + unsigned long nextUpdate; + SURFACE_BITS_COMMAND cmd; +}; + +struct wf_peer_context +{ + rdpContext _p; + + wfInfo* info; + boolean activated; + HANDLE updateEvent; + BOOL socketClose; + HANDLE socketEvent; + HANDLE socketThread; + HANDLE socketSemaphore; +}; + struct wf_server { DWORD port; @@ -34,10 +80,10 @@ struct wf_server }; typedef struct wf_server wfServer; -BOOL wfreerdp_server_start(wfServer* server); -BOOL wfreerdp_server_stop(wfServer* server); +FREERDP_API BOOL wfreerdp_server_start(wfServer* server); +FREERDP_API BOOL wfreerdp_server_stop(wfServer* server); -wfServer* wfreerdp_server_new(); -void wfreerdp_server_free(wfServer* server); +FREERDP_API wfServer* wfreerdp_server_new(); +FREERDP_API void wfreerdp_server_free(wfServer* server); #endif /* WF_INTERFACE_H */ diff --git a/server/Windows/wf_mirage.h b/server/Windows/wf_mirage.h index a18b22fa0..2bb2950df 100644 --- a/server/Windows/wf_mirage.h +++ b/server/Windows/wf_mirage.h @@ -20,7 +20,7 @@ #ifndef WF_MIRAGE_H #define WF_MIRAGE_H -#include "wfreerdp.h" +#include "wf_interface.h" enum { diff --git a/server/Windows/wf_peer.c b/server/Windows/wf_peer.c index cbc742fa2..510f1eb0f 100644 --- a/server/Windows/wf_peer.c +++ b/server/Windows/wf_peer.c @@ -29,6 +29,7 @@ #include #include +#include "wf_info.h" #include "wf_input.h" #include "wf_mirage.h" #include "wf_update.h" diff --git a/server/Windows/wf_peer.h b/server/Windows/wf_peer.h index 25a94b099..2c00c544d 100644 --- a/server/Windows/wf_peer.h +++ b/server/Windows/wf_peer.h @@ -20,12 +20,10 @@ #ifndef WF_PEER_H #define WF_PEER_H -#include "wfreerdp.h" +#include "wf_interface.h" #include -#include "wf_info.h" - void wf_peer_context_new(freerdp_peer* client, wfPeerContext* context); void wf_peer_context_free(freerdp_peer* client, wfPeerContext* context); diff --git a/server/Windows/wf_settings.h b/server/Windows/wf_settings.h index 8257885ca..a0f7eb935 100644 --- a/server/Windows/wf_settings.h +++ b/server/Windows/wf_settings.h @@ -20,7 +20,7 @@ #ifndef WF_SETTINGS_H #define WF_SETTINGS_H -#include "wfreerdp.h" +#include "wf_interface.h" BOOL wf_settings_read_dword(HKEY key, LPTSTR subkey, LPTSTR name, DWORD* value); BOOL wf_settings_read_string_ascii(HKEY key, LPTSTR subkey, LPTSTR name, char** value); diff --git a/server/Windows/wf_update.c b/server/Windows/wf_update.c index 57b3c94e8..6ef9825f6 100644 --- a/server/Windows/wf_update.c +++ b/server/Windows/wf_update.c @@ -27,6 +27,7 @@ #include #include "wf_peer.h" +#include "wf_info.h" #include "wf_mirage.h" #include "wf_update.h" diff --git a/server/Windows/wf_update.h b/server/Windows/wf_update.h index 98f6ca25d..c046308ea 100644 --- a/server/Windows/wf_update.h +++ b/server/Windows/wf_update.h @@ -20,7 +20,7 @@ #ifndef WF_UPDATE_H #define WF_UPDATE_H -#include "wfreerdp.h" +#include "wf_interface.h" void wf_update_encode(wfInfo* wfi); void wf_update_send(wfInfo* wfi);