[Client] Compile-time option ENABLE_RECEIVE_POSITION
Enables or disables the -l option at compile-time.
This commit is contained in:
parent
a81b539a05
commit
c9c82211d8
|
@ -39,15 +39,18 @@ XCFLAGS = $(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS)
|
|||
PICFLAG = -fPIC
|
||||
OWLPSFLAGS = -D OWLPS_VERSION=\"$(OWLPS_VERSION)\"
|
||||
OWLPSFLAGS += -D DEBUG
|
||||
LIBS = -L$(LIBOWLPS_DIR) -lowlps \
|
||||
-L$(LIBOWLPSCLIENT_DIR) -lowlps-client \
|
||||
OWLPSFLAGS += -D ENABLE_RECEIVE_POSITION \
|
||||
-L$(LIBOWLPSRESULTREADER_DIR) -lowlps-resultreader
|
||||
LIBS = -L$(LIBOWLPS_DIR) -lowlps \
|
||||
-L$(LIBOWLPSCLIENT_DIR) -lowlps-client
|
||||
|
||||
OS := $(shell uname)
|
||||
ifeq ("$(OS)", "Linux")
|
||||
LIBS += -lrt
|
||||
endif
|
||||
|
||||
LDFLAGS = $(LIBS) $(OWLPSFLAGS)
|
||||
|
||||
STATIC_LIBS =
|
||||
|
||||
|
||||
|
@ -63,7 +66,7 @@ all : dynamic static
|
|||
%: %.c
|
||||
|
||||
%: %.o
|
||||
$(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
|
||||
$(CC) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LDFLAGS)
|
||||
%.static: %.o
|
||||
$(CC) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ \
|
||||
$(LDFLAGS) $(LIBS) $(STATIC_LIBS) -static
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
*/
|
||||
|
||||
#include <owlps-client.h>
|
||||
#include <owlps-resultreader.h>
|
||||
|
||||
#ifdef ENABLE_RECEIVE_POSITION
|
||||
# include <owlps-resultreader.h>
|
||||
#endif // ENABLE_RECEIVE_POSITION
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -42,7 +45,9 @@ void print_configuration(void) ;
|
|||
void create_socket(void) ;
|
||||
void make_packet(void) ;
|
||||
void send_request(void) ;
|
||||
#ifdef ENABLE_RECEIVE_POSITION
|
||||
int receive_position(void) ;
|
||||
#endif // ENABLE_RECEIVE_POSITION
|
||||
void print_usage(void) ;
|
||||
void print_version(void) ;
|
||||
|
||||
|
@ -122,8 +127,10 @@ int main(int argc, char *argv[])
|
|||
|
||||
close(sockfd) ;
|
||||
|
||||
#ifdef ENABLE_RECEIVE_POSITION
|
||||
if (options.listening_port > 0)
|
||||
ret = receive_position() ;
|
||||
#endif // ENABLE_RECEIVE_POSITION
|
||||
|
||||
return ret ;
|
||||
}
|
||||
|
@ -187,6 +194,7 @@ void parse_main_options(int argc, char **argv)
|
|||
strncpy(options.dest_ip, optarg, INET_ADDRSTRLEN) ;
|
||||
break ;
|
||||
case 'l' :
|
||||
#ifdef ENABLE_RECEIVE_POSITION
|
||||
/* Facultative getopt options do not handle separated values
|
||||
* (like -l <port>), so we have to test separately.
|
||||
*/
|
||||
|
@ -207,6 +215,11 @@ void parse_main_options(int argc, char **argv)
|
|||
++optind ;
|
||||
}
|
||||
}
|
||||
#else // ENABLE_RECEIVE_POSITION
|
||||
fprintf(stderr, "Warning! The program was compiled without"
|
||||
" enabling the -l option (receive the position from"
|
||||
" the positioning server).\n") ;
|
||||
#endif // ENABLE_RECEIVE_POSITION
|
||||
break ;
|
||||
case 'n' :
|
||||
options.nb_pkt = strtoul(optarg, NULL, 0) ;
|
||||
|
@ -477,6 +490,7 @@ void make_packet()
|
|||
|
||||
|
||||
|
||||
#ifdef ENABLE_RECEIVE_POSITION
|
||||
/*
|
||||
* Receives a position computed by the infrastructure.
|
||||
* Note that it is currently not guaranteed that the received result
|
||||
|
@ -503,6 +517,7 @@ int receive_position()
|
|||
|
||||
return 0 ;
|
||||
}
|
||||
#endif // ENABLE_RECEIVE_POSITION
|
||||
|
||||
|
||||
|
||||
|
@ -550,8 +565,8 @@ void print_usage()
|
|||
"\t-D\t\tDaemon mode. Useful only in flood mode.\n"
|
||||
"\t-l [port]\tWait for the computed position and display it."
|
||||
" The Optional argument <port> allows to specify the listening"
|
||||
" port (default: %d).\n"
|
||||
,
|
||||
" port (default: %d). Available only if the program was"
|
||||
" compiled with the option ENABLE_RECEIVE_POSITION.\n",
|
||||
program_name,
|
||||
program_name,
|
||||
OWL_DEFAULT_REQUEST_PORT,
|
||||
|
@ -569,11 +584,19 @@ void print_version()
|
|||
{
|
||||
printf("This is OwlPS Client, part of the Open Wireless"
|
||||
" Positioning System project.\n"
|
||||
"Version: %s.\n",
|
||||
"Version: %s.\n"
|
||||
"Compilation-time options:\n"
|
||||
"\tOption -l: %s.\n",
|
||||
#ifdef OWLPS_VERSION
|
||||
OWLPS_VERSION
|
||||
#else // OWLPS_VERSION
|
||||
"unknown version"
|
||||
#endif // OWLPS_VERSION
|
||||
,
|
||||
#ifdef ENABLE_RECEIVE_POSITION
|
||||
"YES"
|
||||
#else // ENABLE_RECEIVE_POSITION
|
||||
"NO"
|
||||
#endif // ENABLE_RECEIVE_POSITION
|
||||
) ;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue