src/tremashark/syslog_relay.c in trema-0.2.5 vs src/tremashark/syslog_relay.c in trema-0.2.6
- old
+ new
@@ -1,8 +1,8 @@
/*
* syslog_relay: An application that relays syslog messages to tremashark
- *
+ *
* Author: Yasunobu Chiba
*
* Copyright (C) 2008-2012 NEC Corporation
*
* This program is free software; you can redistribute it and/or modify
@@ -22,12 +22,12 @@
#include <errno.h>
#include <getopt.h>
#include <inttypes.h>
#include <string.h>
-#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/types.h>
#include <unistd.h>
#include "trema.h"
static char *dump_service_name = NULL;
@@ -110,16 +110,18 @@
void
usage( void ) {
printf(
"Usage: syslog_relay [OPTION]...\n"
"\n"
- " -p LISTEN_PORT listen port for receiving syslog messages\n"
- " -s DUMP_SERVICE_NAME dump service name\n"
- " -n, --name=SERVICE_NAME service name\n"
- " -d, --daemonize run in the background\n"
- " -l, --logging_level=LEVEL set logging level\n"
- " -h, --help display this help and exit\n"
+ " -p LISTEN_PORT listen port for receiving syslog messages\n"
+ " -s DUMP_SERVICE_NAME dump service name\n"
+ " -n, --name=SERVICE_NAME service name\n"
+ " -d, --daemonize run in the background\n"
+ " -l, --logging_level=LEVEL set logging level\n"
+ " -g, --syslog output log messages to syslog\n"
+ " -f, --logging_facility=FACILITY set syslog facility\n"
+ " -h, --help display this help and exit\n"
);
}
static void
@@ -131,18 +133,18 @@
static void
parse_options( int *argc, char **argv[] ) {
int opt;
- while( 1 ) {
+ while ( 1 ) {
opt = getopt( *argc, *argv, "p:s:" );
- if( opt < 0 ){
+ if ( opt < 0 ) {
break;
}
- switch ( opt ){
+ switch ( opt ) {
case 'p':
if ( ( optarg != NULL ) && ( atoi( optarg ) <= UINT16_MAX ) && ( atoi ( optarg ) >= 0 ) ) {
listen_port = ( uint16_t ) atoi( optarg );
}
else {
@@ -176,10 +178,10 @@
if ( syslog_fd >= 0 ) {
close( syslog_fd );
syslog_fd = -1;
}
-
+
syslog_fd = socket( PF_INET, SOCK_DGRAM, 0 );
if ( syslog_fd < 0 ) {
error( "Failed to create socket ( errno = %s [%d] ).", strerror( errno ), errno );
return false;
}