summaryrefslogtreecommitdiff
path: root/src/sys_win.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2011-12-20 14:37:44 +0400
committerAndrey Nazarov <skuller@skuller.net>2012-04-03 01:25:47 +0400
commitb3e271a53de2610de173f9b2bda5d15dd4d78909 (patch)
treed567b91dadac42e168bcb13db5fe93ffbc7e1533 /src/sys_win.c
parentca4a019a74b11aa21fea2a03c6dff3b183463aab (diff)
Massive coding style change.
Use linux style brackets. Pad operators with spaces. Unpad parenthesis, except for ‘if’, ‘for’, ‘while’ constructs.
Diffstat (limited to 'src/sys_win.c')
-rw-r--r--src/sys_win.c784
1 files changed, 410 insertions, 374 deletions
diff --git a/src/sys_win.c b/src/sys_win.c
index 31961f9..844c92a 100644
--- a/src/sys_win.c
+++ b/src/sys_win.c
@@ -8,7 +8,7 @@ of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
@@ -78,32 +78,35 @@ static int sys_hidden;
static CONSOLE_SCREEN_BUFFER_INFO sbinfo;
static qboolean gotConsole;
-static void write_console_data( void *data, size_t len ) {
+static void write_console_data(void *data, size_t len)
+{
DWORD dummy;
- WriteFile( houtput, data, len, &dummy, NULL );
+ WriteFile(houtput, data, len, &dummy, NULL);
}
-static void hide_console_input( void ) {
+static void hide_console_input(void)
+{
int i;
- if( !sys_hidden ) {
- for( i = 0; i <= sys_con.inputLine.cursorPos; i++ ) {
- write_console_data( "\b \b", 3 );
+ if (!sys_hidden) {
+ for (i = 0; i <= sys_con.inputLine.cursorPos; i++) {
+ write_console_data("\b \b", 3);
}
}
sys_hidden++;
}
-static void show_console_input( void ) {
- if( !sys_hidden ) {
+static void show_console_input(void)
+{
+ if (!sys_hidden) {
return;
}
sys_hidden--;
- if( !sys_hidden ) {
- write_console_data( "]", 1 );
- write_console_data( sys_con.inputLine.text, sys_con.inputLine.cursorPos );
+ if (!sys_hidden) {
+ write_console_data("]", 1);
+ write_console_data(sys_con.inputLine.text, sys_con.inputLine.cursorPos);
}
}
@@ -112,7 +115,8 @@ static void show_console_input( void ) {
Sys_ConsoleInput
================
*/
-void Sys_RunConsole( void ) {
+void Sys_RunConsole(void)
+{
INPUT_RECORD recs[MAX_CONSOLE_INPUT_EVENTS];
int ch;
DWORD numread, numevents;
@@ -120,118 +124,118 @@ void Sys_RunConsole( void ) {
inputField_t *f;
char *s;
- if( hinput == INVALID_HANDLE_VALUE ) {
+ if (hinput == INVALID_HANDLE_VALUE) {
return;
}
- if( !gotConsole ) {
+ if (!gotConsole) {
return;
}
f = &sys_con.inputLine;
- while( 1 ) {
- if( !GetNumberOfConsoleInputEvents( hinput, &numevents ) ) {
- Com_EPrintf( "Error %lu getting number of console events.\n", GetLastError() );
+ while (1) {
+ if (!GetNumberOfConsoleInputEvents(hinput, &numevents)) {
+ Com_EPrintf("Error %lu getting number of console events.\n", GetLastError());
gotConsole = qfalse;
return;
}
- if( numevents <= 0 )
+ if (numevents <= 0)
break;
- if( numevents > MAX_CONSOLE_INPUT_EVENTS ) {
+ if (numevents > MAX_CONSOLE_INPUT_EVENTS) {
numevents = MAX_CONSOLE_INPUT_EVENTS;
}
- if( !ReadConsoleInput( hinput, recs, numevents, &numread ) ) {
- Com_EPrintf( "Error %lu reading console input.\n", GetLastError() );
+ if (!ReadConsoleInput(hinput, recs, numevents, &numread)) {
+ Com_EPrintf("Error %lu reading console input.\n", GetLastError());
gotConsole = qfalse;
return;
}
-
- for( i = 0; i < numread; i++ ) {
- if( recs[i].EventType == WINDOW_BUFFER_SIZE_EVENT ) {
+
+ for (i = 0; i < numread; i++) {
+ if (recs[i].EventType == WINDOW_BUFFER_SIZE_EVENT) {
// determine terminal width
size_t width = recs[i].Event.WindowBufferSizeEvent.dwSize.X;
- if( !width ) {
- Com_EPrintf( "Invalid console buffer width.\n" );
+ if (!width) {
+ Com_EPrintf("Invalid console buffer width.\n");
gotConsole = qfalse;
return;
}
-
+
sys_con.widthInChars = width;
-
+
// figure out input line width
width--;
- if( width > MAX_FIELD_TEXT - 1 ) {
+ if (width > MAX_FIELD_TEXT - 1) {
width = MAX_FIELD_TEXT - 1;
}
hide_console_input();
- IF_Init( &sys_con.inputLine, width, width );
+ IF_Init(&sys_con.inputLine, width, width);
show_console_input();
continue;
}
- if( recs[i].EventType != KEY_EVENT ) {
+ if (recs[i].EventType != KEY_EVENT) {
continue;
}
-
- if( !recs[i].Event.KeyEvent.bKeyDown ) {
+
+ if (!recs[i].Event.KeyEvent.bKeyDown) {
continue;
}
- switch( recs[i].Event.KeyEvent.wVirtualKeyCode ) {
+ switch (recs[i].Event.KeyEvent.wVirtualKeyCode) {
case VK_UP:
hide_console_input();
- Prompt_HistoryUp( &sys_con );
+ Prompt_HistoryUp(&sys_con);
show_console_input();
break;
case VK_DOWN:
hide_console_input();
- Prompt_HistoryDown( &sys_con );
+ Prompt_HistoryDown(&sys_con);
show_console_input();
break;
case VK_RETURN:
hide_console_input();
- s = Prompt_Action( &sys_con );
- if( s ) {
- if( *s == '\\' || *s == '/' ) {
+ s = Prompt_Action(&sys_con);
+ if (s) {
+ if (*s == '\\' || *s == '/') {
s++;
}
- Sys_Printf( "]%s\n", s );
- Cbuf_AddText( &cmd_buffer, s );
- Cbuf_AddText( &cmd_buffer, "\n" );
+ Sys_Printf("]%s\n", s);
+ Cbuf_AddText(&cmd_buffer, s);
+ Cbuf_AddText(&cmd_buffer, "\n");
} else {
- write_console_data( "\n", 1 );
+ write_console_data("\n", 1);
}
show_console_input();
break;
case VK_BACK:
- if( f->cursorPos ) {
+ if (f->cursorPos) {
f->text[--f->cursorPos] = 0;
- write_console_data( "\b \b", 3 );
+ write_console_data("\b \b", 3);
}
break;
case VK_TAB:
hide_console_input();
- Prompt_CompleteCommand( &sys_con, qfalse );
- f->cursorPos = strlen( f->text );
+ Prompt_CompleteCommand(&sys_con, qfalse);
+ f->cursorPos = strlen(f->text);
show_console_input();
break;
default:
ch = recs[i].Event.KeyEvent.uChar.AsciiChar;
- if( ch < 32 ) {
+ if (ch < 32) {
break;
}
- if( f->cursorPos < f->maxChars - 1 ) {
- write_console_data( &ch, 1 );
+ if (f->cursorPos < f->maxChars - 1) {
+ write_console_data(&ch, 1);
f->text[f->cursorPos] = ch;
f->text[++f->cursorPos] = 0;
}
break;
}
}
- }
+ }
}
#define FOREGROUND_BLACK 0
@@ -241,27 +245,28 @@ static const WORD textColors[8] = {
FOREGROUND_BLACK,
FOREGROUND_RED,
FOREGROUND_GREEN,
- FOREGROUND_RED|FOREGROUND_GREEN,
+ FOREGROUND_RED | FOREGROUND_GREEN,
FOREGROUND_BLUE,
- FOREGROUND_BLUE|FOREGROUND_GREEN,
- FOREGROUND_RED|FOREGROUND_BLUE,
+ FOREGROUND_BLUE | FOREGROUND_GREEN,
+ FOREGROUND_RED | FOREGROUND_BLUE,
FOREGROUND_WHITE
};
-void Sys_SetConsoleColor( color_index_t color ) {
+void Sys_SetConsoleColor(color_index_t color)
+{
WORD attr, w;
- if( houtput == INVALID_HANDLE_VALUE ) {
+ if (houtput == INVALID_HANDLE_VALUE) {
return;
}
- if( !gotConsole ) {
+ if (!gotConsole) {
return;
}
attr = sbinfo.wAttributes & ~FOREGROUND_WHITE;
- switch( color ) {
+ switch (color) {
case COLOR_NONE:
w = sbinfo.wAttributes;
break;
@@ -273,28 +278,29 @@ void Sys_SetConsoleColor( color_index_t color ) {
break;
}
- if( color != COLOR_NONE ) {
+ if (color != COLOR_NONE) {
hide_console_input();
}
- SetConsoleTextAttribute( houtput, w );
- if( color == COLOR_NONE ) {
+ SetConsoleTextAttribute(houtput, w);
+ if (color == COLOR_NONE) {
show_console_input();
}
}
-static void write_console_output( const char *text ) {
+static void write_console_output(const char *text)
+{
char buf[MAXPRINTMSG];
size_t len;
- for( len = 0; len < MAXPRINTMSG; len++ ) {
+ for (len = 0; len < MAXPRINTMSG; len++) {
int c = *text++;
- if( !c ) {
+ if (!c) {
break;
}
- buf[len] = Q_charascii( c );
+ buf[len] = Q_charascii(c);
}
- write_console_data( buf, len );
+ write_console_data(buf, len);
}
/*
@@ -304,81 +310,85 @@ Sys_ConsoleOutput
Print text to the dedicated console
================
*/
-void Sys_ConsoleOutput( const char *text ) {
- if( houtput == INVALID_HANDLE_VALUE ) {
+void Sys_ConsoleOutput(const char *text)
+{
+ if (houtput == INVALID_HANDLE_VALUE) {
return;
}
- if( !gotConsole ) {
- write_console_output( text );
+ if (!gotConsole) {
+ write_console_output(text);
} else {
hide_console_input();
- write_console_output( text );
+ write_console_output(text);
show_console_input();
}
}
-void Sys_SetConsoleTitle( const char *title ) {
- if( gotConsole ) {
- SetConsoleTitle( title );
+void Sys_SetConsoleTitle(const char *title)
+{
+ if (gotConsole) {
+ SetConsoleTitle(title);
}
}
-static BOOL WINAPI Sys_ConsoleCtrlHandler( DWORD dwCtrlType ) {
- if( errorEntered ) {
- exit( 1 );
+static BOOL WINAPI Sys_ConsoleCtrlHandler(DWORD dwCtrlType)
+{
+ if (errorEntered) {
+ exit(1);
}
shouldExit = SE_FULL;
return TRUE;
}
-static void Sys_ConsoleInit( void ) {
+static void Sys_ConsoleInit(void)
+{
DWORD mode;
size_t width;
#if USE_CLIENT
- if( !AllocConsole() ) {
- Com_EPrintf( "Couldn't create system console.\n" );
+ if (!AllocConsole()) {
+ Com_EPrintf("Couldn't create system console.\n");
return;
}
#elif USE_WINSVC
- if( statusHandle ) {
+ if (statusHandle) {
return;
}
#endif
- hinput = GetStdHandle( STD_INPUT_HANDLE );
- houtput = GetStdHandle( STD_OUTPUT_HANDLE );
- if( !GetConsoleScreenBufferInfo( houtput, &sbinfo ) ) {
- Com_EPrintf( "Couldn't get console buffer info.\n" );
+ hinput = GetStdHandle(STD_INPUT_HANDLE);
+ houtput = GetStdHandle(STD_OUTPUT_HANDLE);
+ if (!GetConsoleScreenBufferInfo(houtput, &sbinfo)) {
+ Com_EPrintf("Couldn't get console buffer info.\n");
return;
}
// determine terminal width
width = sbinfo.dwSize.X;
- if( !width ) {
- Com_EPrintf( "Invalid console buffer width.\n" );
+ if (!width) {
+ Com_EPrintf("Invalid console buffer width.\n");
return;
}
sys_con.widthInChars = width;
sys_con.printf = Sys_Printf;
gotConsole = qtrue;
- SetConsoleTitle( PRODUCT " console" );
- SetConsoleCtrlHandler( Sys_ConsoleCtrlHandler, TRUE );
- GetConsoleMode( hinput, &mode );
+ SetConsoleTitle(PRODUCT " console");
+ SetConsoleCtrlHandler(Sys_ConsoleCtrlHandler, TRUE);
+ GetConsoleMode(hinput, &mode);
mode |= ENABLE_WINDOW_INPUT;
- SetConsoleMode( hinput, mode );
+ SetConsoleMode(hinput, mode);
// figure out input line width
width--;
- if( width > MAX_FIELD_TEXT - 1 ) {
+ if (width > MAX_FIELD_TEXT - 1) {
width = MAX_FIELD_TEXT - 1;
}
- IF_Init( &sys_con.inputLine, width, width );
+ IF_Init(&sys_con.inputLine, width, width);
- Com_DPrintf( "System console initialized (%d cols, %d rows).\n",
- sbinfo.dwSize.X, sbinfo.dwSize.Y );
+ Com_DPrintf("System console initialized (%d cols, %d rows).\n",
+ sbinfo.dwSize.X, sbinfo.dwSize.Y);
}
#endif // USE_SYSCON
@@ -393,133 +403,135 @@ SERVICE CONTROL
#if USE_WINSVC
-static void Sys_InstallService_f( void ) {
+static void Sys_InstallService_f(void)
+{
char servicePath[256];
char serviceName[1024];
SC_HANDLE scm, service;
DWORD error, length;
char *commandline;
- if( Cmd_Argc() < 3 ) {
- Com_Printf( "Usage: %s <servicename> <+command> [...]\n"
- "Example: %s test +set net_port 27910 +map q2dm1\n",
- Cmd_Argv( 0 ), Cmd_Argv( 0 ) );
+ if (Cmd_Argc() < 3) {
+ Com_Printf("Usage: %s <servicename> <+command> [...]\n"
+ "Example: %s test +set net_port 27910 +map q2dm1\n",
+ Cmd_Argv(0), Cmd_Argv(0));
return;
}
- scm = OpenSCManager( NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ALL_ACCESS );
- if( !scm ) {
+ scm = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ALL_ACCESS);
+ if (!scm) {
error = GetLastError();
- if( error == ERROR_ACCESS_DENIED ) {
- Com_Printf( "Insufficient privileges for opening Service Control Manager.\n" );
+ if (error == ERROR_ACCESS_DENIED) {
+ Com_Printf("Insufficient privileges for opening Service Control Manager.\n");
} else {
- Com_EPrintf( "%#lx opening Service Control Manager.\n", error );
+ Com_EPrintf("%#lx opening Service Control Manager.\n", error);
}
return;
}
- Q_concat( serviceName, sizeof( serviceName ), "Q2PRO - ", Cmd_Argv( 1 ), NULL );
+ Q_concat(serviceName, sizeof(serviceName), "Q2PRO - ", Cmd_Argv(1), NULL);
- length = GetModuleFileName( NULL, servicePath, MAX_PATH );
- if( !length ) {
+ length = GetModuleFileName(NULL, servicePath, MAX_PATH);
+ if (!length) {
error = GetLastError();
- Com_EPrintf( "%#lx getting module file name.\n", error );
+ Com_EPrintf("%#lx getting module file name.\n", error);
goto fail;
}
- commandline = Cmd_RawArgsFrom( 2 );
- if( length + strlen( commandline ) + 10 > sizeof( servicePath ) - 1 ) {
- Com_Printf( "Oversize service command line.\n" );
+ commandline = Cmd_RawArgsFrom(2);
+ if (length + strlen(commandline) + 10 > sizeof(servicePath) - 1) {
+ Com_Printf("Oversize service command line.\n");
goto fail;
}
- strcpy( servicePath + length, " -service " );
- strcpy( servicePath + length + 10, commandline );
+ strcpy(servicePath + length, " -service ");
+ strcpy(servicePath + length + 10, commandline);
service = CreateService(
- scm,
- serviceName,
- serviceName,
- SERVICE_START,
- SERVICE_WIN32_OWN_PROCESS,
- SERVICE_AUTO_START,
- SERVICE_ERROR_IGNORE,
- servicePath,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL );
-
- if( !service ) {
+ scm,
+ serviceName,
+ serviceName,
+ SERVICE_START,
+ SERVICE_WIN32_OWN_PROCESS,
+ SERVICE_AUTO_START,
+ SERVICE_ERROR_IGNORE,
+ servicePath,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+
+ if (!service) {
error = GetLastError();
- if( error == ERROR_SERVICE_EXISTS || error == ERROR_DUPLICATE_SERVICE_NAME ) {
- Com_Printf( "Service already exists.\n" );
+ if (error == ERROR_SERVICE_EXISTS || error == ERROR_DUPLICATE_SERVICE_NAME) {
+ Com_Printf("Service already exists.\n");
} else {
- Com_EPrintf( "%#lx creating service.\n", error );
+ Com_EPrintf("%#lx creating service.\n", error);
}
goto fail;
}
- Com_Printf( "Service created successfully.\n" );
+ Com_Printf("Service created successfully.\n");
- CloseServiceHandle( service );
+ CloseServiceHandle(service);
fail:
- CloseServiceHandle( scm );
+ CloseServiceHandle(scm);
}
-static void Sys_DeleteService_f( void ) {
+static void Sys_DeleteService_f(void)
+{
char serviceName[256];
SC_HANDLE scm, service;
DWORD error;
- if( Cmd_Argc() < 2 ) {
- Com_Printf( "Usage: %s <servicename>\n", Cmd_Argv( 0 ) );
+ if (Cmd_Argc() < 2) {
+ Com_Printf("Usage: %s <servicename>\n", Cmd_Argv(0));
return;
}
- scm = OpenSCManager( NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ALL_ACCESS );
- if( !scm ) {
+ scm = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ALL_ACCESS);
+ if (!scm) {
error = GetLastError();
- if( error == ERROR_ACCESS_DENIED ) {
- Com_Printf( "Insufficient privileges for opening Service Control Manager.\n" );
+ if (error == ERROR_ACCESS_DENIED) {
+ Com_Printf("Insufficient privileges for opening Service Control Manager.\n");
} else {
- Com_EPrintf( "%#lx opening Service Control Manager.\n", error );
+ Com_EPrintf("%#lx opening Service Control Manager.\n", error);
}
return;
}
- Q_concat( serviceName, sizeof( serviceName ), "Q2PRO - ", Cmd_Argv( 1 ), NULL );
+ Q_concat(serviceName, sizeof(serviceName), "Q2PRO - ", Cmd_Argv(1), NULL);
service = OpenService(
- scm,
- serviceName,
- DELETE );
+ scm,
+ serviceName,
+ DELETE);
- if( !service ) {
+ if (!service) {
error = GetLastError();
- if( error == ERROR_SERVICE_DOES_NOT_EXIST ) {
- Com_Printf( "Service doesn't exist.\n" );
+ if (error == ERROR_SERVICE_DOES_NOT_EXIST) {
+ Com_Printf("Service doesn't exist.\n");
} else {
- Com_EPrintf( "%#lx opening service.\n", error );
+ Com_EPrintf("%#lx opening service.\n", error);
}
goto fail;
}
- if( !DeleteService( service ) ) {
+ if (!DeleteService(service)) {
error = GetLastError();
- if( error == ERROR_SERVICE_MARKED_FOR_DELETE ) {
- Com_Printf( "Service has already been marked for deletion.\n" );
+ if (error == ERROR_SERVICE_MARKED_FOR_DELETE) {
+ Com_Printf("Service has already been marked for deletion.\n");
} else {
- Com_EPrintf( "%#lx deleting service.\n", error );
+ Com_EPrintf("%#lx deleting service.\n", error);
}
} else {
- Com_Printf( "Service deleted successfully.\n" );
+ Com_Printf("Service deleted successfully.\n");
}
- CloseServiceHandle( service );
+ CloseServiceHandle(service);
fail:
- CloseServiceHandle( scm );
+ CloseServiceHandle(scm);
}
#endif // USE_WINSVC
@@ -532,53 +544,57 @@ HUNK
===============================================================================
*/
-void Hunk_Begin( mempool_t *pool, size_t maxsize ) {
+void Hunk_Begin(mempool_t *pool, size_t maxsize)
+{
// reserve a huge chunk of memory, but don't commit any yet
pool->cursize = 0;
- pool->maxsize = ( maxsize + 4095 ) & ~4095;
- pool->base = VirtualAlloc( NULL, pool->maxsize, MEM_RESERVE, PAGE_NOACCESS );
- if( !pool->base ) {
- Com_Error( ERR_FATAL,
- "VirtualAlloc reserve %"PRIz" bytes failed. GetLastError() = %lu",
- pool->maxsize, GetLastError() );
+ pool->maxsize = (maxsize + 4095) & ~4095;
+ pool->base = VirtualAlloc(NULL, pool->maxsize, MEM_RESERVE, PAGE_NOACCESS);
+ if (!pool->base) {
+ Com_Error(ERR_FATAL,
+ "VirtualAlloc reserve %"PRIz" bytes failed. GetLastError() = %lu",
+ pool->maxsize, GetLastError());
}
}
-void *Hunk_Alloc( mempool_t *pool, size_t size ) {
+void *Hunk_Alloc(mempool_t *pool, size_t size)
+{
void *buf;
// round to cacheline
- size = ( size + 63 ) & ~63;
+ size = (size + 63) & ~63;
pool->cursize += size;
- if( pool->cursize > pool->maxsize )
- Com_Error( ERR_FATAL, "%s: couldn't allocate %"PRIz" bytes", __func__, size );
+ if (pool->cursize > pool->maxsize)
+ Com_Error(ERR_FATAL, "%s: couldn't allocate %"PRIz" bytes", __func__, size);
// commit pages as needed
- buf = VirtualAlloc( pool->base, pool->cursize, MEM_COMMIT, PAGE_READWRITE );
- if( !buf ) {
- Com_Error( ERR_FATAL,
- "VirtualAlloc commit %"PRIz" bytes failed. GetLastError() = %lu",
- pool->cursize, GetLastError() );
+ buf = VirtualAlloc(pool->base, pool->cursize, MEM_COMMIT, PAGE_READWRITE);
+ if (!buf) {
+ Com_Error(ERR_FATAL,
+ "VirtualAlloc commit %"PRIz" bytes failed. GetLastError() = %lu",
+ pool->cursize, GetLastError());
}
- return ( byte * )pool->base + pool->cursize - size;
+ return (byte *)pool->base + pool->cursize - size;
}
-void Hunk_End( mempool_t *pool ) {
+void Hunk_End(mempool_t *pool)
+{
// for statistics
- pool->mapped = ( pool->cursize + 4095 ) & ~4095;
+ pool->mapped = (pool->cursize + 4095) & ~4095;
}
-void Hunk_Free( mempool_t *pool ) {
- if( pool->base ) {
- if( !VirtualFree( pool->base, 0, MEM_RELEASE ) ) {
- Com_Error( ERR_FATAL, "VirtualFree failed. GetLastError() = %lu",
- GetLastError() );
+void Hunk_Free(mempool_t *pool)
+{
+ if (pool->base) {
+ if (!VirtualFree(pool->base, 0, MEM_RELEASE)) {
+ Com_Error(ERR_FATAL, "VirtualFree failed. GetLastError() = %lu",
+ GetLastError());
}
}
- memset( pool, 0, sizeof( *pool ) );
+ memset(pool, 0, sizeof(*pool));
}
/*
@@ -595,15 +611,16 @@ MISC
Sys_Printf
================
*/
-void Sys_Printf( const char *fmt, ... ) {
+void Sys_Printf(const char *fmt, ...)
+{
va_list argptr;
char msg[MAXPRINTMSG];
- va_start( argptr, fmt );
- Q_vsnprintf( msg, sizeof( msg ), fmt, argptr );
- va_end( argptr );
+ va_start(argptr, fmt);
+ Q_vsnprintf(msg, sizeof(msg), fmt, argptr);
+ va_end(argptr);
- Sys_ConsoleOutput( msg );
+ Sys_ConsoleOutput(msg);
}
#endif
@@ -612,37 +629,38 @@ void Sys_Printf( const char *fmt, ... ) {
Sys_Error
================
*/
-void Sys_Error( const char *error, ... ) {
+void Sys_Error(const char *error, ...)
+{
va_list argptr;
char text[MAXERRORMSG];
- va_start( argptr, error );
- Q_vsnprintf( text, sizeof( text ), error, argptr );
- va_end( argptr );
+ va_start(argptr, error);
+ Q_vsnprintf(text, sizeof(text), error, argptr);
+ va_end(argptr);
errorEntered = qtrue;
#if USE_SYSCON
- Sys_SetConsoleColor( COLOR_RED );
- Sys_Printf( "********************\n"
- "FATAL: %s\n"
- "********************\n", text );
- Sys_SetConsoleColor( COLOR_NONE );
+ Sys_SetConsoleColor(COLOR_RED);
+ Sys_Printf("********************\n"
+ "FATAL: %s\n"
+ "********************\n", text);
+ Sys_SetConsoleColor(COLOR_NONE);
#endif
#if USE_WINSVC
- if( !statusHandle )
+ if (!statusHandle)
#endif
{
#if USE_SYSCON
- if( gotConsole ) {
- Sleep( INFINITE );
+ if (gotConsole) {
+ Sleep(INFINITE);
}
#endif
- MessageBoxA( NULL, text, PRODUCT " Fatal Error", MB_ICONERROR | MB_OK );
+ MessageBoxA(NULL, text, PRODUCT " Fatal Error", MB_ICONERROR | MB_OK);
}
- exit( 1 );
+ exit(1);
}
/*
@@ -652,38 +670,43 @@ Sys_Quit
This function never returns.
================
*/
-void Sys_Quit( void ) {
- timeEndPeriod( 1 );
+void Sys_Quit(void)
+{
+ timeEndPeriod(1);
#if USE_CLIENT
#if USE_SYSCON
- if( dedicated && dedicated->integer ) {
+ if (dedicated && dedicated->integer) {
FreeConsole();
}
#endif
#elif USE_WINSVC
- if( statusHandle && !shouldExit ) {
+ if (statusHandle && !shouldExit) {
shouldExit = SE_YES;
Com_AbortFrame();
}
#endif
- exit( 0 );
+ exit(0);
}
-void Sys_DebugBreak( void ) {
+void Sys_DebugBreak(void)
+{
DebugBreak();
}
-unsigned Sys_Milliseconds( void ) {
+unsigned Sys_Milliseconds(void)
+{
return timeGetTime();
}
-void Sys_AddDefaultConfig( void ) {
+void Sys_AddDefaultConfig(void)
+{
}
-void Sys_Sleep( int msec ) {
- Sleep( msec );
+void Sys_Sleep(int msec)
+{
+ Sleep(msec);
}
/*
@@ -691,79 +714,80 @@ void Sys_Sleep( int msec ) {
Sys_Init
================
*/
-void Sys_Init( void ) {
+void Sys_Init(void)
+{
OSVERSIONINFO vinfo;
#ifndef _WIN64
HMODULE module;
- BOOL (WINAPI *pSetProcessDEPPolicy)( DWORD );
+ BOOL (WINAPI * pSetProcessDEPPolicy)(DWORD);
#endif
cvar_t *var = NULL;
- timeBeginPeriod( 1 );
+ timeBeginPeriod(1);
// check windows version
- vinfo.dwOSVersionInfoSize = sizeof( vinfo );
- if( !GetVersionEx( &vinfo ) ) {
- Sys_Error( "Couldn't get OS info" );
+ vinfo.dwOSVersionInfoSize = sizeof(vinfo);
+ if (!GetVersionEx(&vinfo)) {
+ Sys_Error("Couldn't get OS info");
}
- if( vinfo.dwPlatformId != VER_PLATFORM_WIN32_NT ) {
- Sys_Error( PRODUCT " requires Windows NT" );
+ if (vinfo.dwPlatformId != VER_PLATFORM_WIN32_NT) {
+ Sys_Error(PRODUCT " requires Windows NT");
}
- if( vinfo.dwMajorVersion < 5 ) {
- Sys_Error( PRODUCT " requires Windows 2000 or greater" );
+ if (vinfo.dwMajorVersion < 5) {
+ Sys_Error(PRODUCT " requires Windows 2000 or greater");
}
// basedir <path>
// allows the game to run from outside the data tree
- sys_basedir = Cvar_Get( "basedir", currentDirectory, CVAR_NOSET );
- sys_libdir = Cvar_Get( "libdir", currentDirectory, CVAR_NOSET );
-
+ sys_basedir = Cvar_Get("basedir", currentDirectory, CVAR_NOSET);
+ sys_libdir = Cvar_Get("libdir", currentDirectory, CVAR_NOSET);
+
// homedir <path>
// specifies per-user writable directory for demos, screenshots, etc
- sys_homedir = Cvar_Get( "homedir", "", CVAR_NOSET );
+ sys_homedir = Cvar_Get("homedir", "", CVAR_NOSET);
- sys_forcegamelib = Cvar_Get( "sys_forcegamelib", "", CVAR_NOSET );
+ sys_forcegamelib = Cvar_Get("sys_forcegamelib", "", CVAR_NOSET);
#if USE_WINSVC
- Cmd_AddCommand( "installservice", Sys_InstallService_f );
- Cmd_AddCommand( "deleteservice", Sys_DeleteService_f );
+ Cmd_AddCommand("installservice", Sys_InstallService_f);
+ Cmd_AddCommand("deleteservice", Sys_DeleteService_f);
#endif
#if USE_SYSCON
- houtput = GetStdHandle( STD_OUTPUT_HANDLE );
+ houtput = GetStdHandle(STD_OUTPUT_HANDLE);
#if USE_CLIENT
- sys_viewlog = Cvar_Get( "sys_viewlog", "0", CVAR_NOSET );
+ sys_viewlog = Cvar_Get("sys_viewlog", "0", CVAR_NOSET);
- if( dedicated->integer || sys_viewlog->integer )
+ if (dedicated->integer || sys_viewlog->integer)
#endif
Sys_ConsoleInit();
#endif // USE_SYSCON
#if USE_DBGHELP
- var = Cvar_Get( "sys_disablecrashdump", "0", CVAR_NOSET );
+ var = Cvar_Get("sys_disablecrashdump", "0", CVAR_NOSET);
// install our exception filter
- if( !var->integer ) {
+ if (!var->integer) {
mainProcessThread = GetCurrentThread();
prevExceptionFilter = SetUnhandledExceptionFilter(
- Sys_ExceptionFilter );
+ Sys_ExceptionFilter);
}
#endif
#ifndef _WIN64
- module = GetModuleHandle( "kernel32.dll" );
- if( module ) {
- pSetProcessDEPPolicy = GetProcAddress( module, "SetProcessDEPPolicy" );
- if( pSetProcessDEPPolicy ) {
- var = Cvar_Get( "sys_disabledep", "0", CVAR_NOSET );
+ module = GetModuleHandle("kernel32.dll");
+ if (module) {
+ pSetProcessDEPPolicy = GetProcAddress(module, "SetProcessDEPPolicy");
+ if (pSetProcessDEPPolicy) {
+ var = Cvar_Get("sys_disabledep", "0", CVAR_NOSET);
// opt-in or opt-out for DEP
- if( !var->integer ) {
+ if (!var->integer) {
pSetProcessDEPPolicy(
PROCESS_DEP_ENABLE |
- PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION );
- } else if( var->integer == 2 ) {
- pSetProcessDEPPolicy( 0 );
+ PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION);
+ } else if (var->integer == 2) {
+ pSetProcessDEPPolicy(0);
}
}
}
@@ -778,34 +802,36 @@ DLL LOADING
========================================================================
*/
-void Sys_FreeLibrary( void *handle ) {
- if( !handle ) {
+void Sys_FreeLibrary(void *handle)
+{
+ if (!handle) {
return;
}
- if( !FreeLibrary( handle ) ) {
- Com_Error( ERR_FATAL, "FreeLibrary failed on %p", handle );
+ if (!FreeLibrary(handle)) {
+ Com_Error(ERR_FATAL, "FreeLibrary failed on %p", handle);
}
}
-void *Sys_LoadLibrary( const char *path, const char *sym, void **handle ) {
+void *Sys_LoadLibrary(const char *path, const char *sym, void **handle)
+{
HMODULE module;
void *entry;
*handle = NULL;
- module = LoadLibraryA( path );
- if( !module ) {
- Com_DPrintf( "%s failed: LoadLibrary returned %lu on %s\n",
- __func__, GetLastError(), path );
+ module = LoadLibraryA(path);
+ if (!module) {
+ Com_DPrintf("%s failed: LoadLibrary returned %lu on %s\n",
+ __func__, GetLastError(), path);
return NULL;
}
- if( sym ) {
- entry = GetProcAddress( module, sym );
- if( !entry ) {
- Com_DPrintf( "%s failed: GetProcAddress returned %lu on %s\n",
- __func__, GetLastError(), path );
- FreeLibrary( module );
+ if (sym) {
+ entry = GetProcAddress(module, sym);
+ if (!entry) {
+ Com_DPrintf("%s failed: GetProcAddress returned %lu on %s\n",
+ __func__, GetLastError(), path);
+ FreeLibrary(module);
return NULL;
}
} else {
@@ -814,13 +840,14 @@ void *Sys_LoadLibrary( const char *path, const char *sym, void **handle ) {
*handle = module;
- Com_DPrintf( "%s succeeded: %s\n", __func__, path );
+ Com_DPrintf("%s succeeded: %s\n", __func__, path);
return entry;
}
-void *Sys_GetProcAddress( void *handle, const char *sym ) {
- return GetProcAddress( handle, sym );
+void *Sys_GetProcAddress(void *handle, const char *sym)
+{
+ return GetProcAddress(handle, sym);
}
/*
@@ -831,9 +858,10 @@ FILESYSTEM
========================================================================
*/
-static inline time_t file_time_to_unix( FILETIME *f ) {
- ULARGE_INTEGER u = *( ULARGE_INTEGER * )f;
- return ( time_t )( ( u.QuadPart - 116444736000000000ULL ) / 10000000 );
+static inline time_t file_time_to_unix(FILETIME *f)
+{
+ ULARGE_INTEGER u = *(ULARGE_INTEGER *)f;
+ return (time_t)((u.QuadPart - 116444736000000000ULL) / 10000000);
}
/*
@@ -841,30 +869,32 @@ static inline time_t file_time_to_unix( FILETIME *f ) {
Sys_GetPathInfo
================
*/
-qerror_t Sys_GetPathInfo( const char *path, file_info_t *info ) {
+qerror_t Sys_GetPathInfo(const char *path, file_info_t *info)
+{
WIN32_FILE_ATTRIBUTE_DATA data;
- if( !GetFileAttributesExA( path, GetFileExInfoStandard, &data ) ) {
+ if (!GetFileAttributesExA(path, GetFileExInfoStandard, &data)) {
return Q_ERR_NOENT; // TODO: return proper error code
}
- if( info ) {
+ if (info) {
info->size = data.nFileSizeLow;
- info->ctime = file_time_to_unix( &data.ftCreationTime );
- info->mtime = file_time_to_unix( &data.ftLastWriteTime );
+ info->ctime = file_time_to_unix(&data.ftCreationTime);
+ info->mtime = file_time_to_unix(&data.ftLastWriteTime);
}
return Q_ERR_SUCCESS;
}
-qerror_t Sys_GetFileInfo( FILE *fp, file_info_t *info ) {
+qerror_t Sys_GetFileInfo(FILE *fp, file_info_t *info)
+{
int pos, end;
// TODO: check for errors
- pos = ftell( fp );
- fseek( fp, 0, SEEK_END );
- end = ftell( fp );
- fseek( fp, pos, SEEK_SET );
+ pos = ftell(fp);
+ fseek(fp, 0, SEEK_END);
+ end = ftell(fp);
+ fseek(fp, pos, SEEK_SET);
info->size = end;
info->ctime = 0;
@@ -873,11 +903,12 @@ qerror_t Sys_GetFileInfo( FILE *fp, file_info_t *info ) {
return Q_ERR_SUCCESS;
}
-static void *copy_info( const char *name, const LPWIN32_FIND_DATAA data ) {
- time_t ctime = file_time_to_unix( &data->ftCreationTime );
- time_t mtime = file_time_to_unix( &data->ftLastWriteTime );
+static void *copy_info(const char *name, const LPWIN32_FIND_DATAA data)
+{
+ time_t ctime = file_time_to_unix(&data->ftCreationTime);
+ time_t mtime = file_time_to_unix(&data->ftLastWriteTime);
- return FS_CopyInfo( name, data->nFileSizeLow, ctime, mtime );
+ return FS_CopyInfo(name, data->nFileSizeLow, ctime, mtime);
}
/*
@@ -890,13 +921,13 @@ Internal function to filesystem. Conventions apply:
- depth must be 0 on the first call
=================
*/
-void Sys_ListFiles_r( const char *path,
- const char *filter,
- unsigned flags,
- size_t baselen,
- int *count_p,
- void **files,
- int depth )
+void Sys_ListFiles_r(const char *path,
+ const char *filter,
+ unsigned flags,
+ size_t baselen,
+ int *count_p,
+ void **files,
+ int depth)
{
WIN32_FIND_DATAA data;
HANDLE handle;
@@ -906,121 +937,118 @@ void Sys_ListFiles_r( const char *path,
void *info;
// optimize single extension search
- if( !( flags & FS_SEARCH_BYFILTER ) &&
- filter && !strchr( filter, ';' ) )
- {
- if( *filter == '.' ) {
+ if (!(flags & FS_SEARCH_BYFILTER) &&
+ filter && !strchr(filter, ';')) {
+ if (*filter == '.') {
filter++;
}
- len = Q_concat( fullpath, sizeof( fullpath ),
- path, "\\*.", filter, NULL );
+ len = Q_concat(fullpath, sizeof(fullpath),
+ path, "\\*.", filter, NULL);
filter = NULL; // do not check it later
} else {
- len = Q_concat( fullpath, sizeof( fullpath ),
- path, "\\*", NULL );
+ len = Q_concat(fullpath, sizeof(fullpath),
+ path, "\\*", NULL);
}
- if( len >= sizeof( fullpath ) ) {
+ if (len >= sizeof(fullpath)) {
return;
}
// format path to windows style
// done on the first run only
- if( !depth ) {
- FS_ReplaceSeparators( fullpath, '\\' );
+ if (!depth) {
+ FS_ReplaceSeparators(fullpath, '\\');
}
- handle = FindFirstFileA( fullpath, &data );
- if( handle == INVALID_HANDLE_VALUE ) {
+ handle = FindFirstFileA(fullpath, &data);
+ if (handle == INVALID_HANDLE_VALUE) {
return;
}
// make it point right after the slash
- pathlen = strlen( path ) + 1;
+ pathlen = strlen(path) + 1;
do {
- if( !strcmp( data.cFileName, "." ) ||
- !strcmp( data.cFileName, ".." ) )
- {
+ if (!strcmp(data.cFileName, ".") ||
+ !strcmp(data.cFileName, "..")) {
continue; // ignore special entries
}
// construct full path
- len = strlen( data.cFileName );
- if( pathlen + len >= sizeof( fullpath ) ) {
+ len = strlen(data.cFileName);
+ if (pathlen + len >= sizeof(fullpath)) {
continue;
}
- memcpy( fullpath + pathlen, data.cFileName, len + 1 );
+ memcpy(fullpath + pathlen, data.cFileName, len + 1);
- if( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) {
+ if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
mask = FS_SEARCH_DIRSONLY;
} else {
mask = 0;
}
// pattern search implies recursive search
- if( ( flags & FS_SEARCH_BYFILTER ) && mask &&
- depth < MAX_LISTED_DEPTH )
- {
- Sys_ListFiles_r( fullpath, filter, flags, baselen,
- count_p, files, depth + 1 );
+ if ((flags & FS_SEARCH_BYFILTER) && mask &&
+ depth < MAX_LISTED_DEPTH) {
+ Sys_ListFiles_r(fullpath, filter, flags, baselen,
+ count_p, files, depth + 1);
// re-check count
- if( *count_p >= MAX_LISTED_FILES ) {
+ if (*count_p >= MAX_LISTED_FILES) {
break;
}
}
// check type
- if( ( flags & FS_SEARCH_DIRSONLY ) != mask ) {
+ if ((flags & FS_SEARCH_DIRSONLY) != mask) {
continue;
}
// check filter
- if( filter ) {
- if( flags & FS_SEARCH_BYFILTER ) {
- if( !FS_WildCmp( filter, fullpath + baselen ) ) {
+ if (filter) {
+ if (flags & FS_SEARCH_BYFILTER) {
+ if (!FS_WildCmp(filter, fullpath + baselen)) {
continue;
}
} else {
- if( !FS_ExtCmp( filter, data.cFileName ) ) {
+ if (!FS_ExtCmp(filter, data.cFileName)) {
continue;
}
}
}
// strip path
- if( flags & FS_SEARCH_SAVEPATH ) {
+ if (flags & FS_SEARCH_SAVEPATH) {
name = fullpath + baselen;
} else {
name = data.cFileName;
}
// reformat it back to quake filesystem style
- FS_ReplaceSeparators( name, '/' );
+ FS_ReplaceSeparators(name, '/');
// strip extension
- if( flags & FS_SEARCH_STRIPEXT ) {
- *COM_FileExtension( name ) = 0;
+ if (flags & FS_SEARCH_STRIPEXT) {
+ *COM_FileExtension(name) = 0;
- if( !*name ) {
+ if (!*name) {
continue;
}
}
// copy info off
- if( flags & FS_SEARCH_EXTRAINFO ) {
- info = copy_info( name, &data );
+ if (flags & FS_SEARCH_EXTRAINFO) {
+ info = copy_info(name, &data);
} else {
- info = FS_CopyString( name );
+ info = FS_CopyString(name);
}
files[(*count_p)++] = info;
- } while( *count_p < MAX_LISTED_FILES &&
- FindNextFileA( handle, &data ) != FALSE );
+ } while (*count_p < MAX_LISTED_FILES &&
+ FindNextFileA(handle, &data) != FALSE);
- FindClose( handle );
+ FindClose(handle);
}
/*
@@ -1031,19 +1059,20 @@ MAIN
========================================================================
*/
-static BOOL fix_current_directory( void ) {
+static BOOL fix_current_directory(void)
+{
char *p;
- if( !GetModuleFileNameA( NULL, currentDirectory, sizeof( currentDirectory ) - 1 ) ) {
+ if (!GetModuleFileNameA(NULL, currentDirectory, sizeof(currentDirectory) - 1)) {
return FALSE;
}
- if( ( p = strrchr( currentDirectory, '\\' ) ) != NULL ) {
+ if ((p = strrchr(currentDirectory, '\\')) != NULL) {
*p = 0;
}
#ifndef UNDER_CE
- if( !SetCurrentDirectoryA( currentDirectory ) ) {
+ if (!SetCurrentDirectoryA(currentDirectory)) {
return FALSE;
}
#endif
@@ -1051,34 +1080,36 @@ static BOOL fix_current_directory( void ) {
return TRUE;
}
-#if ( _MSC_VER >= 1400 )
-static void msvcrt_sucks( const wchar_t *expr, const wchar_t *func,
- const wchar_t *file, unsigned int line, uintptr_t unused ) {
+#if (_MSC_VER >= 1400)
+static void msvcrt_sucks(const wchar_t *expr, const wchar_t *func,
+ const wchar_t *file, unsigned int line, uintptr_t unused)
+{
}
#endif
-static int Sys_Main( int argc, char **argv ) {
+static int Sys_Main(int argc, char **argv)
+{
// fix current directory to point to the basedir
- if( !fix_current_directory() ) {
+ if (!fix_current_directory()) {
return 1;
}
-#if ( _MSC_VER >= 1400 )
+#if (_MSC_VER >= 1400)
// work around strftime given invalid format string
// killing the whole fucking process :((
- _set_invalid_parameter_handler( msvcrt_sucks );
+ _set_invalid_parameter_handler(msvcrt_sucks);
#endif
- Qcommon_Init( argc, argv );
+ Qcommon_Init(argc, argv);
// main program loop
- while( 1 ) {
+ while (1) {
Qcommon_Frame();
- if( shouldExit ) {
+ if (shouldExit) {
#if USE_WINSVC
- if( shouldExit == SE_FULL )
+ if (shouldExit == SE_FULL)
#endif
- Com_Quit( NULL, ERR_DISCONNECT );
+ Com_Quit(NULL, ERR_DISCONNECT);
break;
}
}
@@ -1100,25 +1131,26 @@ Sys_ParseCommandLine
===============
*/
-static void Sys_ParseCommandLine( char *line ) {
+static void Sys_ParseCommandLine(char *line)
+{
sys_argc = 1;
sys_argv[0] = APPLICATION;
- while( *line ) {
- while( *line && *line <= 32 ) {
+ while (*line) {
+ while (*line && *line <= 32) {
line++;
}
- if( *line == 0 ) {
+ if (*line == 0) {
break;
}
sys_argv[sys_argc++] = line;
- while( *line > 32 ) {
+ while (*line > 32) {
line++;
}
- if( *line == 0 ) {
+ if (*line == 0) {
break;
}
*line = 0;
- if( sys_argc == MAX_LINE_TOKENS ) {
+ if (sys_argc == MAX_LINE_TOKENS) {
break;
}
line++;
@@ -1131,18 +1163,19 @@ WinMain
==================
*/
-int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow ) {
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
+{
// previous instances do not exist in Win32
- if( hPrevInstance ) {
+ if (hPrevInstance) {
return 1;
}
hGlobalInstance = hInstance;
#ifndef UNICODE
// TODO: wince support
- Sys_ParseCommandLine( lpCmdLine );
+ Sys_ParseCommandLine(lpCmdLine);
#endif
- return Sys_Main( sys_argc, sys_argv );
+ return Sys_Main(sys_argc, sys_argv);
}
#else // USE_CLIENT
@@ -1152,31 +1185,33 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLi
static char **sys_argv;
static int sys_argc;
-static VOID WINAPI ServiceHandler( DWORD fdwControl ) {
- if( fdwControl == SERVICE_CONTROL_STOP ) {
+static VOID WINAPI ServiceHandler(DWORD fdwControl)
+{
+ if (fdwControl == SERVICE_CONTROL_STOP) {
shouldExit = SE_FULL;
}
}
-static VOID WINAPI ServiceMain( DWORD argc, LPTSTR *argv ) {
+static VOID WINAPI ServiceMain(DWORD argc, LPTSTR *argv)
+{
SERVICE_STATUS status;
- statusHandle = RegisterServiceCtrlHandler( APPLICATION, ServiceHandler );
- if( !statusHandle ) {
+ statusHandle = RegisterServiceCtrlHandler(APPLICATION, ServiceHandler);
+ if (!statusHandle) {
return;
}
- memset( &status, 0, sizeof( status ) );
+ memset(&status, 0, sizeof(status));
status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
status.dwCurrentState = SERVICE_RUNNING;
status.dwControlsAccepted = SERVICE_ACCEPT_STOP;
- SetServiceStatus( statusHandle, &status );
+ SetServiceStatus(statusHandle, &status);
- Sys_Main( sys_argc, sys_argv );
+ Sys_Main(sys_argc, sys_argv);
status.dwCurrentState = SERVICE_STOPPED;
status.dwControlsAccepted = 0;
- SetServiceStatus( statusHandle, &status );
+ SetServiceStatus(statusHandle, &status);
}
static SERVICE_TABLE_ENTRY serviceTable[] = {
@@ -1192,31 +1227,32 @@ main
==================
*/
-int QDECL main( int argc, char **argv ) {
+int QDECL main(int argc, char **argv)
+{
#if USE_WINSVC
int i;
#endif
- hGlobalInstance = GetModuleHandle( NULL );
+ hGlobalInstance = GetModuleHandle(NULL);
#if USE_WINSVC
- for( i = 1; i < argc; i++ ) {
- if( !strcmp( argv[i], "-service" ) ) {
+ for (i = 1; i < argc; i++) {
+ if (!strcmp(argv[i], "-service")) {
argv[i] = NULL;
sys_argc = argc;
sys_argv = argv;
- if( StartServiceCtrlDispatcher( serviceTable ) ) {
+ if (StartServiceCtrlDispatcher(serviceTable)) {
return 0;
}
- if( GetLastError() == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT ) {
+ if (GetLastError() == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) {
break; // fall back to normal server startup
}
return 1;
}
}
#endif
-
- return Sys_Main( argc, argv );
+
+ return Sys_Main(argc, argv);
}
#endif // !USE_CLIENT