From a704fc5981f7f2c0a3179f62f0ce818f75467078 Mon Sep 17 00:00:00 2001 From: yaworsky Date: Tue, 15 Nov 2005 11:59:52 +0000 Subject: Replaced 0-terminated strings with reference counted ones --- daemon/main.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'daemon/main.c') diff --git a/daemon/main.c b/daemon/main.c index 91e9087..ee91238 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -28,7 +28,10 @@ HANDLE service_stop_event; -char local_hostname[ MAX_COMPUTERNAME_LENGTH + 1 ]; +struct string *local_hostname; +struct string *self_program_name; +struct string *space; +struct string *line_feed; int verbosity_level = 0; @@ -468,10 +471,15 @@ int main( int argc, char* argv[] ) char *priority = NULL; int getopt_failure = 0; WSADATA wsd; + char name_buf[ MAX_COMPUTERNAME_LENGTH + 1 ]; DWORD size; SetUnhandledExceptionFilter( exception_handler ); + self_program_name = string_new( "syslog" ); + space = string_new( " " ); + line_feed = string_new( "\n" ); + if( WSAStartup( MAKEWORD( 2, 2 ), &wsd ) ) { ERR( "Cannot initialize winsock; error %lu\n", WSAGetLastError() ); @@ -479,13 +487,13 @@ int main( int argc, char* argv[] ) } /* get local host name */ - size = sizeof(local_hostname); - if( !GetComputerName( local_hostname, &size ) ) + size = sizeof(name_buf); + if( !GetComputerName( name_buf, &size ) ) { ERR( "Cannot get computer name; error %lu\n", GetLastError() ); return 1; } - TRACE( "local host name=%s\n", local_hostname ); + local_hostname = string_new_len( name_buf, size ); /* get windows version */ vi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); @@ -581,6 +589,8 @@ int main( int argc, char* argv[] ) if( getopt_failure ) return 1; + TRACE( "local host name=%s\n", local_hostname->gstr->str ); + /* handle flags in order of priority */ /* at first, check instance name */ if( instance_name ) -- cgit v1.2.3