diff options
author | Andrey Nazarov <skuller@skuller.net> | 2007-12-21 21:24:49 +0000 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2007-12-21 21:24:49 +0000 |
commit | b1fa1be8b67e6d34a3d11fe4bfb9cd27191e2b28 (patch) | |
tree | 878887f017a82f7b861464c683d9a908e6d0a18e /source/sys_unix.c | |
parent | a79ed051848531afb9a479f280bbcc39a4c29f44 (diff) |
Use Sys_Setenv for setting environment variables in a safe way.
Moved `writeconfig' command to client code section.
Moved `setenv' command to common code section.
Properly handle `--help' -and `--version' arguments on Unix.
Diffstat (limited to 'source/sys_unix.c')
-rw-r--r-- | source/sys_unix.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/source/sys_unix.c b/source/sys_unix.c index 6f36c61..071c9c4 100644 --- a/source/sys_unix.c +++ b/source/sys_unix.c @@ -679,6 +679,10 @@ void Sys_Sleep( int msec ) { nanosleep( &req, NULL ); } +void Sys_Setenv( const char *name, const char *value ) { + setenv( name, value, 1 ); +} + /* ================ Sys_FillAPI @@ -1101,19 +1105,22 @@ main ================= */ int main( int argc, char **argv ) { - int i; - - for( i = 1; i < argc; i++ ) { + if( argc > 1 ) { if( !strcmp( argv[1], "-v" ) || !strcmp( argv[1], "--version" ) ) { printf( APPLICATION " " VERSION " " __DATE__ " " BUILDSTRING " " CPUSTRING "\n" ); return 0; } + if( !strcmp( argv[1], "-h" ) || !strcmp( argv[1], "--help" ) ) { + printf( "Usage: %s [+command arguments] [...]\n", argv[0] ); + return 0; + } } if( !getuid() || !geteuid() ) { - Sys_Error( "You can not run " APPLICATION " as superuser " - "for security reasons!" ); + printf( "You can not run " APPLICATION " as superuser " + "for security reasons!" ); + return 1; } Qcommon_Init( argc, argv ); |