Some minor refactoring of the TIME_OFFSET handling. Other minor code formatting tweaks.

git-svn-id: file:///home/mbr/svn/fwknop/trunk@130 510a4753-2344-4c79-9c09-4d669213fbeb
This commit is contained in:
Damien Stuart
2009-08-09 16:33:02 +00:00
parent 1da9ea0f6b
commit 78fb936a55
2 changed files with 10 additions and 24 deletions
+8 -12
View File
@@ -100,29 +100,25 @@ parse_time_offset(char *offset_str)
break;
}
}
offset_digits[j] = '\0';
if (j < 1) {
fprintf(stderr, "[*] Invalid time offset: %s", offset_str);
exit(EXIT_FAILURE);
}
offset = atoi(offset_digits);
if (offset < 0) {
fprintf(stderr, "[*] Invalid time offset: %s", offset_str);
exit(EXIT_FAILURE);
}
switch (offset_type) {
case TIME_OFFSET_MINUTES:
offset *= 60;
break;
case TIME_OFFSET_HOURS:
offset *= 60 * 60;
break;
case TIME_OFFSET_DAYS:
offset *= 60 * 60 * 24;
break;
}
/* Apply the offset_type value
*/
offset *= offset_type;
return offset;
}
@@ -183,7 +179,7 @@ parse_config_file(fko_cli_options_t *options, struct opts_track* ot)
if (*lptr == '#' || *lptr == '\n' || *lptr == '\r' || *lptr == '\0' || *lptr == ';')
continue;
/*--DSS TODO: Figure out what to put here
/*--DSS TODO: Figure out what to put here (these are just samples below)
if (ot->got_device == 0 || options->interface.name[0] == '\0')
get_char_val("XXXX", options->interface.name, lptr);
+2 -12
View File
@@ -506,6 +506,7 @@ get_save_file(char *args_save_file)
homedir, "/", ".fwknop.run");
rv = 1;
}
return rv;
}
@@ -598,37 +599,26 @@ set_message_type(fko_ctx_t ctx, fko_cli_options_t *options)
if (options->nat_local)
{
if (options->fw_timeout >= 0)
{
message_type = FKO_CLIENT_TIMEOUT_LOCAL_NAT_ACCESS_MSG;
}
else
{
message_type = FKO_LOCAL_NAT_ACCESS_MSG;
}
}
else
{
if (options->fw_timeout >= 0)
{
message_type = FKO_CLIENT_TIMEOUT_NAT_ACCESS_MSG;
}
else
{
message_type = FKO_NAT_ACCESS_MSG;
}
}
}
else
{
if (options->fw_timeout >= 0)
{
message_type = FKO_CLIENT_TIMEOUT_ACCESS_MSG;
}
else
{
message_type = FKO_ACCESS_MSG;
}
}
return fko_set_spa_message_type(ctx, message_type);
}