[Aggregator] Get rid of the last indent tabs

This commit is contained in:
Matteo Cypriani 2011-02-24 14:53:25 +01:00
parent 719514eab6
commit bbe43536ad
1 changed files with 140 additions and 140 deletions

View File

@ -171,7 +171,7 @@ void parse_command_line(int argc, char **argv)
while ((opt = getopt(argc, argv, OPTIONS)) != -1)
{
switch (opt)
{
{
case 'A' :
cfg_setbool(cfg, "autocalibration", cfg_true) ;
break ;
@ -179,45 +179,45 @@ void parse_command_line(int argc, char **argv)
cfg_setint(cfg, "autocalibration_port",
strtol(optarg, NULL, 0)) ;
break ;
case 'c' :
cfg_setint(cfg, "check_interval", strtol(optarg, NULL, 0)) ;
break ;
case 'c' :
cfg_setint(cfg, "check_interval", strtol(optarg, NULL, 0)) ;
break ;
case 'C' :
cfg_setint(cfg, "ap_check_interval", strtol(optarg, NULL, 0)) ;
break ;
case 'f' : // Config file
break ; // (already parsed)
case 'f' : // Config file
break ; // (already parsed)
case 'h' :
print_usage() ;
exit(0) ;
case 'i' :
cfg_setstr(cfg, "positioner_ip", optarg) ;
break ;
case 'k' :
cfg_setint(cfg, "keep_timeout", strtol(optarg, NULL, 0)) ;
break ;
case 'i' :
cfg_setstr(cfg, "positioner_ip", optarg) ;
break ;
case 'k' :
cfg_setint(cfg, "keep_timeout", strtol(optarg, NULL, 0)) ;
break ;
case 'K' :
cfg_setint(cfg, "ap_keep_timeout", strtol(optarg, NULL, 0)) ;
break ;
case 'l' :
cfg_setint(cfg, "listening_port", strtol(optarg, NULL, 0)) ;
break ;
case 'o' :
cfg_setstr(cfg, "output_file", optarg) ;
break ;
case 'p' :
cfg_setint(cfg, "positioner_port", strtol(optarg, NULL, 0)) ;
break ;
case 't' :
cfg_setint(cfg, "aggregate_timeout", strtol(optarg, NULL, 0)) ;
break ;
case 'l' :
cfg_setint(cfg, "listening_port", strtol(optarg, NULL, 0)) ;
break ;
case 'o' :
cfg_setstr(cfg, "output_file", optarg) ;
break ;
case 'p' :
cfg_setint(cfg, "positioner_port", strtol(optarg, NULL, 0)) ;
break ;
case 't' :
cfg_setint(cfg, "aggregate_timeout", strtol(optarg, NULL, 0)) ;
break ;
case 'v' :
cfg_setbool(cfg, "verbose", cfg_true) ;
break ;
default :
print_usage() ;
exit(ERR_BAD_USAGE) ;
}
default :
print_usage() ;
exit(ERR_BAD_USAGE) ;
}
}
}
@ -315,14 +315,14 @@ int read_loop(int sockfd)
(struct sockaddr *) &client, &client_len) ;
if (nread <= 0)
{
if (run)
{
fprintf(stderr, "No message received from client!\n") ;
ret = ERR_NO_MESSAGE_RECEIVED ;
}
break ;
}
{
if (run)
{
fprintf(stderr, "No message received from client!\n") ;
ret = ERR_NO_MESSAGE_RECEIVED ;
}
break ;
}
if (cfg_getbool(cfg, "verbose"))
{
@ -429,107 +429,107 @@ void* monitor_couples()
gettimeofday(&current_time, NULL) ;
while (couple_ptr != NULL) // Parsing list
{
sub = sub_date(couple_ptr->start_time, current_time) ;
{
sub = sub_date(couple_ptr->start_time, current_time) ;
// If the couple was not treated already
if (couple_ptr->info != NULL)
{
if (couple_ptr->info != NULL)
{
// If the timeout is reached
if (sub > aggregate_timeout)
{
printf("* Timeout reached.") ;
if (sub > aggregate_timeout)
{
printf("* Timeout reached.") ;
#ifdef DEBUG
printf(" sub=%lu > aggregate_timeout=%ld\n",
printf(" sub=%lu > aggregate_timeout=%ld\n",
sub, aggregate_timeout) ;
#else // DEBUG
putchar('\n') ;
putchar('\n') ;
#endif // DEBUG
#ifdef TIMESTAMP
// Print request mobile timestamp to the output file
fprintf(fd, "%llu;",
fprintf(fd, "%llu;",
timeval_to_ms(couple_ptr->request_time)) ;
#endif // TIMESTAMP
// Print couple info to the output file
fprintf(fd, "%0.2f;%0.2f;%0.2f;%hhd",
fprintf(fd, "%0.2f;%0.2f;%0.2f;%hhd",
couple_ptr->x_position, couple_ptr->y_position,
couple_ptr->z_position, couple_ptr->direction) ;
memcpy(demande.mobile_mac_addr_bytes,
memcpy(demande.mobile_mac_addr_bytes,
couple_ptr->mobile_mac_addr_bytes, 6) ;
demande.request_time = couple_ptr->request_time ;
demande.nb_couples = 0 ;
demande.request_time = couple_ptr->request_time ;
demande.nb_couples = 0 ;
couple_info_ptr = couple_ptr->info ;
while (couple_info_ptr != NULL)
{
demande.nb_couples++;
couple_info_ptr = couple_info_ptr->next ;
couple_info_ptr = couple_ptr->info ;
while (couple_info_ptr != NULL)
{
demande.nb_couples++;
couple_info_ptr = couple_info_ptr->next ;
}
sendto(sockfd, (void *)&demande, sizeof(request), 0,
sendto(sockfd, (void *)&demande, sizeof(request), 0,
(struct sockaddr *)&serv, serv_len) ;
// Send couples to the server and empty the list
couple_info_ptr = couple_ptr->info ;
while (couple_info_ptr != NULL)
{
// Send AP info to the localisation server
memcpy(info.ap_mac_addr_bytes,
couple_info_ptr = couple_ptr->info ;
while (couple_info_ptr != NULL)
{
// Send AP info to the localisation server
memcpy(info.ap_mac_addr_bytes,
couple_info_ptr->ap_mac_addr_bytes, 6) ;
info.antenna_signal_dbm =
info.antenna_signal_dbm =
couple_info_ptr->antenna_signal_dbm - 0x100 ;
sendto(sockfd, (void *)&info, sizeof(couple_info),
sendto(sockfd, (void *)&info, sizeof(couple_info),
0, (struct sockaddr *)&serv, serv_len) ;
// Print AP info to the output file
ap_mac_string =
// Print AP info to the output file
ap_mac_string =
mac_bytes_to_string(couple_info_ptr
->ap_mac_addr_bytes) ;
fprintf(fd, ";%s;%d", ap_mac_string,
fprintf(fd, ";%s;%d", ap_mac_string,
couple_info_ptr->antenna_signal_dbm - 0x100) ;
free(ap_mac_string) ;
free(ap_mac_string) ;
// Delete couple
couple_info_ptr = couple_info_ptr->next ;
free(couple_ptr->info) ;
couple_ptr->info = couple_info_ptr ;
}
// Delete couple
couple_info_ptr = couple_info_ptr->next ;
free(couple_ptr->info) ;
couple_ptr->info = couple_info_ptr ;
}
fprintf(fd, "\n") ;
}
}
fprintf(fd, "\n") ;
}
}
// If the couple was treated and keep timeout is reached
else if (sub > keep_timeout)
{
couple_list *couple_tmp = couple_ptr ;
else if (sub > keep_timeout)
{
couple_list *couple_tmp = couple_ptr ;
printf("* Keep timeout reached.") ;
printf("* Keep timeout reached.") ;
#ifdef DEBUG
printf(" sub=%lu > keep_timeout=%ld\n",
printf(" sub=%lu > keep_timeout=%ld\n",
sub, keep_timeout) ;
#else // DEBUG
putchar('\n') ;
putchar('\n') ;
#endif // DEBUG
couple_ptr = couple_ptr->next ;
couple_ptr = couple_ptr->next ;
// If it is the first couple of the list
if (couple_prev == NULL)
couples = couple_ptr ; // we shift the head
else // else we put the next of the previous on the next
couple_prev->next = couple_ptr ;
if (couple_prev == NULL)
couples = couple_ptr ; // we shift the head
else // else we put the next of the previous on the next
couple_prev->next = couple_ptr ;
free(couple_tmp) ;
free(couple_tmp) ;
continue ;
}
continue ;
}
// Next couple
couple_prev = couple_ptr ;
couple_ptr = couple_ptr->next ;
}
// Next couple
couple_prev = couple_ptr ;
couple_ptr = couple_ptr->next ;
}
fflush(NULL) ;
usleep(cfg_getint(cfg, "check_interval")) ; // Wait to check again
@ -618,10 +618,10 @@ void got_couple_info(couple_message message)
}
if (tmp_couple == NULL) // If the couple does not exist in the list,
{
printf("Create new couple.\n") ;
tmp_couple = malloc(sizeof(couple_list)) ; // create it.
memcpy(tmp_couple->mobile_mac_addr_bytes,
{
printf("Create new couple.\n") ;
tmp_couple = malloc(sizeof(couple_list)) ; // create it.
memcpy(tmp_couple->mobile_mac_addr_bytes,
message.mobile_mac_addr_bytes, 6) ;
if (timeval_to_ms(message.request_time) != 0) // Explicit packet
// Transmission time on the mobile:
@ -631,29 +631,29 @@ void got_couple_info(couple_message message)
tmp_couple->request_time = message.start_time ;
// Save locale time on the aggregator (not the reception time
// on the AP):
tmp_couple->start_time = start_time ;
tmp_couple->x_position = message.x_position ;
tmp_couple->y_position = message.y_position ;
tmp_couple->z_position = message.z_position ;
tmp_couple->direction = message.direction ;
tmp_couple->next = couples ;
tmp_couple->info = tmp_info ;
couples = tmp_couple ;
}
tmp_couple->start_time = start_time ;
tmp_couple->x_position = message.x_position ;
tmp_couple->y_position = message.y_position ;
tmp_couple->z_position = message.z_position ;
tmp_couple->direction = message.direction ;
tmp_couple->next = couples ;
tmp_couple->info = tmp_info ;
couples = tmp_couple ;
}
else // If the couple was found in the list
{
if (tmp_couple->info == NULL)
{ // We already sent to the server data for this couple
printf("Request already treated.\n") ;
free(tmp_info) ;
}
else
{
printf("Add information to the couple.\n") ;
tmp_info->next = tmp_couple->info ; // Add data
tmp_couple->info = tmp_info ;
}
}
{
if (tmp_couple->info == NULL)
{ // We already sent to the server data for this couple
printf("Request already treated.\n") ;
free(tmp_info) ;
}
else
{
printf("Add information to the couple.\n") ;
tmp_info->next = tmp_couple->info ; // Add data
tmp_couple->info = tmp_info ;
}
}
}
}
@ -1018,19 +1018,19 @@ void print_couple_list()
"Sequence number: %llu\n"
"Reception timestamp: %llu\n"
"\n",
mobile_mac_string,
timeval_to_ms(couple_ptr->request_time),
timeval_to_ms(couple_ptr->start_time)
) ;
mobile_mac_string,
timeval_to_ms(couple_ptr->request_time),
timeval_to_ms(couple_ptr->start_time)
) ;
free(mobile_mac_string) ;
// Parse information relative to the current couple
while (info_ptr != NULL)
{
print_couple_info(info_ptr) ;
putchar('\n') ;
info_ptr = info_ptr->next ;
}
{
print_couple_info(info_ptr) ;
putchar('\n') ;
info_ptr = info_ptr->next ;
}
printf("\n\n") ;
@ -1052,9 +1052,9 @@ void print_couple_info(couple_info_list *info)
ap_mac_string = mac_bytes_to_string(info->ap_mac_addr_bytes) ;
printf("\tAP MAC: %s\n"
"\tSignal strength: %d dBm\n",
ap_mac_string,
info->antenna_signal_dbm - 0x100
) ;
ap_mac_string,
info->antenna_signal_dbm - 0x100
) ;
free(ap_mac_string) ;
}
#endif // DEBUG
@ -1070,9 +1070,9 @@ char* ip_bytes_to_string(unsigned char *ip_binary)
for (i = 0 ; i < 4 ; ++i)
{
if (ip_binary[i] < 0x64)
size-- ;
size-- ;
if (ip_binary[i] < 0x10)
size-- ;
size-- ;
}
char *ret = malloc(sizeof(char) * size) ;
@ -1139,15 +1139,15 @@ void print_usage()
"\t-C ap_check_interval\tTime (in milliseconds) between two"
" checks of the stored APs (default: %d ms).\n"
,
program_name,
AGGREGATE_DEFAULT_PORT,
POSITIONER_DEFAULT_IP,
POSITIONER_DEFAULT_PORT,
DEFAULT_AGGREGATE_TIMEOUT,
DEFAULT_KEEP_TIMEOUT,
program_name,
AGGREGATE_DEFAULT_PORT,
POSITIONER_DEFAULT_IP,
POSITIONER_DEFAULT_PORT,
DEFAULT_AGGREGATE_TIMEOUT,
DEFAULT_KEEP_TIMEOUT,
DEFAULT_CHECK_INTERVAL,
DEFAULT_AUTOCALIBRATION_PORT,
DEFAULT_AP_KEEP_TIMEOUT,
DEFAULT_AP_CHECK_INTERVAL
) ;
) ;
}