[iortcw] 188/497: All: Get clipboard data from SDL
This is an automated email from the git hooks/post-receive script. smcv pushed a commit to annotated tag 1.42d in repository iortcw. commit 020d33d5a60c1d9fe23456b94c869e59115672d1 Author: m4n4t4...@gmail.com Date: Fri Aug 29 15:42:53 2014 + All: Get clipboard data from SDL --- MP/code/sys/sys_main.c | 29 + MP/code/sys/sys_unix.c | 11 +-- MP/code/sys/sys_win32.c | 27 --- SP/code/sys/sys_main.c | 29 + SP/code/sys/sys_unix.c | 10 -- SP/code/sys/sys_win32.c | 27 --- 6 files changed, 59 insertions(+), 74 deletions(-) diff --git a/MP/code/sys/sys_main.c b/MP/code/sys/sys_main.c index d8b8598..db21775 100644 --- a/MP/code/sys/sys_main.c +++ b/MP/code/sys/sys_main.c @@ -133,6 +133,35 @@ char *Sys_ConsoleInput(void) return CON_Input( ); } +/* +== +Sys_GetClipboardData +== +*/ +char *Sys_GetClipboardData(void) +{ +#ifdef DEDICATED + return NULL; +#else + char *data = NULL; + char *cliptext; + + if ( ( cliptext = SDL_GetClipboardText() ) != NULL ) { + if ( cliptext[0] != '\0' ) { + size_t bufsize = strlen( cliptext ) + 1; + + data = Z_Malloc( bufsize ); + Q_strncpyz( data, cliptext, bufsize ); + + // find first listed char and set to '\0' + strtok( data, "\n\r\b" ); + } + SDL_free( cliptext ); + } + return data; +#endif +} + #ifdef DEDICATED # define PID_FILENAME "iowolfmp_server.pid" #else diff --git a/MP/code/sys/sys_unix.c b/MP/code/sys/sys_unix.c index 925b27d..461272a 100644 --- a/MP/code/sys/sys_unix.c +++ b/MP/code/sys/sys_unix.c @@ -148,17 +148,8 @@ char *Sys_GetCurrentUser( void ) return p->pw_name; } -/* -== -Sys_GetClipboardData -== -*/ -char *Sys_GetClipboardData(void) -{ - return NULL; -} - #define MEM_THRESHOLD 96*1024*1024 + /* == Sys_LowPhysicalMemory diff --git a/MP/code/sys/sys_win32.c b/MP/code/sys/sys_win32.c index 40d99bd..95b6287 100644 --- a/MP/code/sys/sys_win32.c +++ b/MP/code/sys/sys_win32.c @@ -191,33 +191,6 @@ char *Sys_GetCurrentUser( void ) return s_userName; } -/* - -Sys_GetClipboardData - -*/ -char *Sys_GetClipboardData( void ) -{ - char *data = NULL; - char *cliptext; - - if ( OpenClipboard( NULL ) != 0 ) { - HANDLE hClipboardData; - - if ( ( hClipboardData = GetClipboardData( CF_TEXT ) ) != 0 ) { - if ( ( cliptext = GlobalLock( hClipboardData ) ) != 0 ) { - data = Z_Malloc( GlobalSize( hClipboardData ) + 1 ); - Q_strncpyz( data, cliptext, GlobalSize( hClipboardData ) ); - GlobalUnlock( hClipboardData ); - - strtok( data, "\n\r\b" ); - } - } - CloseClipboard(); - } - return data; -} - #define MEM_THRESHOLD 96*1024*1024 /* diff --git a/SP/code/sys/sys_main.c b/SP/code/sys/sys_main.c index 5b6d5cf..f87d8d1 100644 --- a/SP/code/sys/sys_main.c +++ b/SP/code/sys/sys_main.c @@ -133,6 +133,35 @@ char *Sys_ConsoleInput(void) return CON_Input( ); } +/* +== +Sys_GetClipboardData +== +*/ +char *Sys_GetClipboardData(void) +{ +#ifdef DEDICATED + return NULL; +#else + char *data = NULL; + char *cliptext; + + if ( ( cliptext = SDL_GetClipboardText() ) != NULL ) { + if ( cliptext[0] != '\0' ) { + size_t bufsize = strlen( cliptext ) + 1; + + data = Z_Malloc( bufsize ); + Q_strncpyz( data, cliptext, bufsize ); + + // find first listed char and set to '\0' + strtok( data, "\n\r\b" ); + } + SDL_free( cliptext ); + } + return data; +#endif +} + #ifdef DEDICATED # define PID_FILENAME "iowolfsp_server.pid" #else diff --git a/SP/code/sys/sys_unix.c b/SP/code/sys/sys_unix.c index 57b7c46..ec08ba0 100644 --- a/SP/code/sys/sys_unix.c +++ b/SP/code/sys/sys_unix.c @@ -148,16 +148,6 @@ char *Sys_GetCurrentUser( void ) return p->pw_name; } -/* -== -Sys_GetClipboardData -== -*/ -char *Sys_GetClipboardData(void) -{ - return NULL; -} - #define MEM_THRESHOLD 96*1024*1024 /* diff --git a/SP/code/sys/sys_win32.c b/SP/code/sys/sys_win32.c index 2f2af31..e0c4c4f 100644 --- a/SP/code/sys/sys_win32.c +++ b/SP/code/sys/sys_win32.c @@ -199,33 +199,6 @@ char *Sys_GetCurrentUser( void ) return s_userName; } -/* - -Sys_GetClipboardData -
[iortcw] 188/497: All: Get clipboard data from SDL
This is an automated email from the git hooks/post-receive script. smcv pushed a commit to annotated tag 1.42d in repository iortcw. commit 020d33d5a60c1d9fe23456b94c869e59115672d1 Author: m4n4t4...@gmail.com Date: Fri Aug 29 15:42:53 2014 + All: Get clipboard data from SDL --- MP/code/sys/sys_main.c | 29 + MP/code/sys/sys_unix.c | 11 +-- MP/code/sys/sys_win32.c | 27 --- SP/code/sys/sys_main.c | 29 + SP/code/sys/sys_unix.c | 10 -- SP/code/sys/sys_win32.c | 27 --- 6 files changed, 59 insertions(+), 74 deletions(-) diff --git a/MP/code/sys/sys_main.c b/MP/code/sys/sys_main.c index d8b8598..db21775 100644 --- a/MP/code/sys/sys_main.c +++ b/MP/code/sys/sys_main.c @@ -133,6 +133,35 @@ char *Sys_ConsoleInput(void) return CON_Input( ); } +/* +== +Sys_GetClipboardData +== +*/ +char *Sys_GetClipboardData(void) +{ +#ifdef DEDICATED + return NULL; +#else + char *data = NULL; + char *cliptext; + + if ( ( cliptext = SDL_GetClipboardText() ) != NULL ) { + if ( cliptext[0] != '\0' ) { + size_t bufsize = strlen( cliptext ) + 1; + + data = Z_Malloc( bufsize ); + Q_strncpyz( data, cliptext, bufsize ); + + // find first listed char and set to '\0' + strtok( data, "\n\r\b" ); + } + SDL_free( cliptext ); + } + return data; +#endif +} + #ifdef DEDICATED # define PID_FILENAME "iowolfmp_server.pid" #else diff --git a/MP/code/sys/sys_unix.c b/MP/code/sys/sys_unix.c index 925b27d..461272a 100644 --- a/MP/code/sys/sys_unix.c +++ b/MP/code/sys/sys_unix.c @@ -148,17 +148,8 @@ char *Sys_GetCurrentUser( void ) return p->pw_name; } -/* -== -Sys_GetClipboardData -== -*/ -char *Sys_GetClipboardData(void) -{ - return NULL; -} - #define MEM_THRESHOLD 96*1024*1024 + /* == Sys_LowPhysicalMemory diff --git a/MP/code/sys/sys_win32.c b/MP/code/sys/sys_win32.c index 40d99bd..95b6287 100644 --- a/MP/code/sys/sys_win32.c +++ b/MP/code/sys/sys_win32.c @@ -191,33 +191,6 @@ char *Sys_GetCurrentUser( void ) return s_userName; } -/* - -Sys_GetClipboardData - -*/ -char *Sys_GetClipboardData( void ) -{ - char *data = NULL; - char *cliptext; - - if ( OpenClipboard( NULL ) != 0 ) { - HANDLE hClipboardData; - - if ( ( hClipboardData = GetClipboardData( CF_TEXT ) ) != 0 ) { - if ( ( cliptext = GlobalLock( hClipboardData ) ) != 0 ) { - data = Z_Malloc( GlobalSize( hClipboardData ) + 1 ); - Q_strncpyz( data, cliptext, GlobalSize( hClipboardData ) ); - GlobalUnlock( hClipboardData ); - - strtok( data, "\n\r\b" ); - } - } - CloseClipboard(); - } - return data; -} - #define MEM_THRESHOLD 96*1024*1024 /* diff --git a/SP/code/sys/sys_main.c b/SP/code/sys/sys_main.c index 5b6d5cf..f87d8d1 100644 --- a/SP/code/sys/sys_main.c +++ b/SP/code/sys/sys_main.c @@ -133,6 +133,35 @@ char *Sys_ConsoleInput(void) return CON_Input( ); } +/* +== +Sys_GetClipboardData +== +*/ +char *Sys_GetClipboardData(void) +{ +#ifdef DEDICATED + return NULL; +#else + char *data = NULL; + char *cliptext; + + if ( ( cliptext = SDL_GetClipboardText() ) != NULL ) { + if ( cliptext[0] != '\0' ) { + size_t bufsize = strlen( cliptext ) + 1; + + data = Z_Malloc( bufsize ); + Q_strncpyz( data, cliptext, bufsize ); + + // find first listed char and set to '\0' + strtok( data, "\n\r\b" ); + } + SDL_free( cliptext ); + } + return data; +#endif +} + #ifdef DEDICATED # define PID_FILENAME "iowolfsp_server.pid" #else diff --git a/SP/code/sys/sys_unix.c b/SP/code/sys/sys_unix.c index 57b7c46..ec08ba0 100644 --- a/SP/code/sys/sys_unix.c +++ b/SP/code/sys/sys_unix.c @@ -148,16 +148,6 @@ char *Sys_GetCurrentUser( void ) return p->pw_name; } -/* -== -Sys_GetClipboardData -== -*/ -char *Sys_GetClipboardData(void) -{ - return NULL; -} - #define MEM_THRESHOLD 96*1024*1024 /* diff --git a/SP/code/sys/sys_win32.c b/SP/code/sys/sys_win32.c index 2f2af31..e0c4c4f 100644 --- a/SP/code/sys/sys_win32.c +++ b/SP/code/sys/sys_win32.c @@ -199,33 +199,6 @@ char *Sys_GetCurrentUser( void ) return s_userName; } -/* - -Sys_GetClipboardData -