diff options
author | yaworsky <yaworsky> | 2005-11-15 11:59:52 +0000 |
---|---|---|
committer | yaworsky <yaworsky> | 2005-11-15 11:59:52 +0000 |
commit | a704fc5981f7f2c0a3179f62f0ce818f75467078 (patch) | |
tree | defbda9e65bb85f1cdb0fc3e3e91f441c80df57d /daemon/main.c | |
parent | a7085384027284f3eb55e48b4c0d4a93bea131b4 (diff) | |
download | syslog-win32-a704fc5981f7f2c0a3179f62f0ce818f75467078.tar.gz syslog-win32-a704fc5981f7f2c0a3179f62f0ce818f75467078.tar.xz syslog-win32-a704fc5981f7f2c0a3179f62f0ce818f75467078.zip |
Replaced 0-terminated strings with reference counted ones
Diffstat (limited to '')
-rw-r--r-- | daemon/main.c | 18 |
1 files changed, 14 insertions, 4 deletions
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 ) |