[Aggregator] Print version info with -V

This commit is contained in:
Matteo Cypriani 2011-04-12 22:45:18 +02:00
parent 7a95851795
commit 7123f02e82
3 changed files with 32 additions and 4 deletions

View File

@ -1,3 +1,8 @@
# Source version
ifndef OWLPS_VERSION
OWLPS_VERSION = $$(git describe || echo 'UNKNOWN_VERSION')
endif
# Répertoire d'installation
PREFIX=/usr/local
INSTALL_DIR= $(PREFIX)/bin
@ -25,7 +30,7 @@ CFLAGS = -O2 -Wall -Wextra -Wstrict-prototypes -O -I$(LIBOWLPS_DIR)
DEPFLAGS=-MMD
XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS)
PICFLAG=-fPIC
#OWLPSFLAGS =
OWLPSFLAGS = -D OWLPS_VERSION=\"$(OWLPS_VERSION)\"
LIBS = -pthread -lconfuse -L$(LIBOWLPS_DIR) -lowlps
LDFLAGS = $(LIBS) $(OWLPSFLAGS)

View File

@ -11,7 +11,7 @@
/* Arguments & program configuration */
#define OPTIONS "Aa:c:C:f:hi:k:K:l:o:p:t:v" // getopt string
#define OPTIONS "Aa:c:C:f:hi:k:K:l:o:p:t:vV" // getopt string
#define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-aggregator.conf"
#define DEFAULT_AGGREGATE_TIMEOUT 1500 // milliseconds
#define DEFAULT_KEEP_TIMEOUT 3000 // milliseconds
@ -112,5 +112,6 @@ void order_send(ap_list *ap) ;
void free_ap_list(void) ;
void print_usage(void) ;
void print_version(void) ;
#endif // _OWLPS_AGGREGATOR_H_

View File

@ -190,7 +190,7 @@ void parse_config_file(int argc, char **argv)
char *config_file = NULL ; // Configuration file name
// Option -f specifies a config file, -h exits the
// Option -f specifies a config file, options -h and -V exit the
// program, so we search for them first
int opt ;
while ((opt = getopt(argc, argv, OPTIONS)) != -1)
@ -204,6 +204,9 @@ void parse_config_file(int argc, char **argv)
case 'h' :
print_usage() ;
exit(0) ;
case 'V' :
print_version() ;
exit(0) ;
}
}
@ -1239,9 +1242,12 @@ void print_usage()
" [-K ap_keep_timeout]"
" [-C ap_check_interval]"
"\n"
"\t%s -h\n"
"\t%s -V\n"
"Main options:\n"
"\t-h\t\tPrint this help.\n"
"\t-V\t\tShow version information.\n"
"\t-f config_file\tUse 'config_file' instead of the default"
" configuration file (%s).\n"
"\t-v\t\tBe verbose (print detailed info on each received"
@ -1260,7 +1266,7 @@ void print_usage()
" treated (default: %d).\n"
"\t-t aggregate_timeout\tRequests are stored during"
" 'aggregate_timeout' milliseconds before to be grouped"
" (default: %d ms).\n"
" (default: %d ms).\n"
"\t-k keep_timeout\t\tAggregated requests are kept during"
" 'keep_timeout' milliseconds (default: %d ms).\n"
"\t-c check_interval\tTime between two checks of the stored"
@ -1276,6 +1282,8 @@ void print_usage()
" checks of the stored APs (default: %d ms).\n"
,
program_name,
program_name,
program_name,
DEFAULT_CONFIG_FILE,
POSITIONER_DEFAULT_IP,
POSITIONER_DEFAULT_PORT,
@ -1288,3 +1296,17 @@ void print_usage()
DEFAULT_AP_CHECK_INTERVAL
) ;
}
void print_version()
{
printf("This is OwlPS Aggregator, part of the Open Wireless"
" Positioning System project.\n"
"Version: %s.\n",
#ifdef OWLPS_VERSION
OWLPS_VERSION
#else // OWLPS_VERSION
"unknown version"
#endif // OWLPS_VERSION
) ;
}