Skip to content

Commit b7fdd12

Browse files
committed
Cleanup Sys_[Do]StartProcess + Sys_OpenURL on Linux
This now uses the universal xdg-open for openurl instead of shipping a half-assed shell script. Consequently this disables usage on dedicated servers but it isn't much use there or anywhere really.
1 parent b05beb8 commit b7fdd12

File tree

1 file changed

+5
-37
lines changed

1 file changed

+5
-37
lines changed

src/unix/unix_main.c

+5-37
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ void CON_SigTStp( int signum )
295295

296296
#define MAX_CMD 1024
297297
static char exit_cmdline[MAX_CMD] = "";
298-
void Sys_DoStartProcess( char *cmdline );
298+
void Sys_DoStartProcess( const char *cmdline );
299299

300300
// single exit point (regular exit or in case of signal fault)
301301
void Sys_Exit( int code ) __attribute((noreturn));
@@ -1159,7 +1159,7 @@ UGLY HACK:
11591159
The clean solution would be Sys_StartProcess and Sys_StartProcess_Args..
11601160
==================
11611161
*/
1162-
void Sys_DoStartProcess( char *cmdline ) {
1162+
void Sys_DoStartProcess( const char *cmdline ) {
11631163
switch ( fork() )
11641164
{
11651165
case - 1:
@@ -1205,9 +1205,7 @@ Sys_OpenURL
12051205
=================
12061206
*/
12071207
void Sys_OpenURL( const char *url, qboolean doexit ) {
1208-
char *basepath, *homepath, *pwdpath;
1209-
char fname[20];
1210-
char fn[MAX_OSPATH];
1208+
#ifndef DEDICATED
12111209
char cmdline[MAX_CMD];
12121210

12131211
static qboolean doexit_spamguard = qfalse;
@@ -1221,44 +1219,14 @@ void Sys_OpenURL( const char *url, qboolean doexit ) {
12211219
// opening an URL on *nix can mean a lot of things ..
12221220
// just spawn a script instead of deciding for the user :-)
12231221

1224-
// do the setup before we fork
1225-
// search for an openurl.sh script
1226-
// search procedure taken from Sys_LoadDll
1227-
Q_strncpyz( fname, "openurl.sh", 20 );
1228-
1229-
pwdpath = Sys_Pwd();
1230-
Com_sprintf( fn, MAX_OSPATH, "%s/%s", pwdpath, fname );
1231-
if ( access( fn, X_OK ) == -1 ) {
1232-
Com_DPrintf( "%s not found\n", fn );
1233-
// try in home path
1234-
homepath = Cvar_VariableString( "fs_homepath" );
1235-
Com_sprintf( fn, MAX_OSPATH, "%s/%s", homepath, fname );
1236-
if ( access( fn, X_OK ) == -1 ) {
1237-
Com_DPrintf( "%s not found\n", fn );
1238-
// basepath, last resort
1239-
basepath = Cvar_VariableString( "fs_basepath" );
1240-
Com_sprintf( fn, MAX_OSPATH, "%s/%s", basepath, fname );
1241-
if ( access( fn, X_OK ) == -1 ) {
1242-
Com_DPrintf( "%s not found\n", fn );
1243-
Com_Printf( "Can't find script '%s' to open requested URL (use +set developer 1 for more verbosity)\n", fname );
1244-
// we won't quit
1245-
return;
1246-
}
1247-
}
1248-
}
1222+
Com_sprintf( cmdline, sizeof(cmdline), "xdg-open '%s' &", url );
12491223

1250-
// show_bug.cgi?id=612
12511224
if ( doexit ) {
12521225
doexit_spamguard = qtrue;
12531226
}
12541227

1255-
Com_DPrintf( "URL script: %s\n", fn );
1256-
1257-
// build the command line
1258-
Com_sprintf( cmdline, MAX_CMD, "%s '%s' &", fn, url );
1259-
12601228
Sys_StartProcess( cmdline, doexit );
1261-
1229+
#endif
12621230
}
12631231

12641232

0 commit comments

Comments
 (0)