Version 2.7

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2008-05-18 00:00:00 +02:00
parent 4f000e7ab6
commit 625cde6b9c
26 changed files with 13445 additions and 1465 deletions

View file

@ -58,6 +58,7 @@ parse_leases (void)
char *line, *ipstring;
struct in_addr inp;
struct stat lease_file_stats;
num_touches = num_leases = 0;
dhcpd_leases = fopen (config.dhcpdlease_file, "r");
@ -81,7 +82,7 @@ parse_leases (void)
safe_malloc (sizeof (long int) *
((lease_file_stats.st_size / 250) + MAXLEN));
touches =
safe_malloc (sizeof (long int) *
safe_malloc ((size_t) sizeof (long int) *
((lease_file_stats.st_size / 250) + MAXLEN));
line = safe_malloc (sizeof (long int) * MAXLEN);
@ -93,7 +94,7 @@ parse_leases (void)
/* It's a lease */
if (strstr (line, "lease") == line)
{
strncpy (ipstring, line, MAXLEN - 1);
strncpy (ipstring, line, (size_t) MAXLEN - 1);
}
/* And this is lease state which we are interested about */
if (strstr (line, "binding state active"))
@ -120,34 +121,36 @@ parse_leases (void)
* have. Question of semantics, send mail to author if this
* annoys. All performance boosts for this function are well
* come. */
int
nth_field (int n, char *dest, const char *src)
{
int i, j, k, th;
i = j = k = th = 0;
int i, j = 0, wordn = 0;
for (; i < MAXLEN && th < n; i++)
for (i = 0; i < MAXLEN; i++)
{
if (src[i] == ' ' || src[i] == '\t')
if (isspace (src[i]))
{
if (j == 0 && i != 0)
if (!(wordn < n))
{
th++;
dest[j] = '\0';
break;
}
j = 1;
}
else if (th + 1 == n)
{
dest[k] = src[i];
k++;
j = 0;
}
else
{
j = 0;
if (j == 0)
{
wordn++;
}
if (wordn == n)
{
dest[j] = src[i];
}
j++;
}
}
dest[k] = '\0';
return 0;
}
@ -191,9 +194,6 @@ parse_config (char *config_file, char *current_shared_name,
/* Default place holder for ranges "All networks".
* If this is include file basicly nothing happens. */
shared_p->name = current_shared_name;
shared_p->available = 0;
shared_p->used = 0;
shared_p->touched = 0;
/* Open configuration file */
dhcpd_config = fopen (config_file, "r");
@ -267,6 +267,7 @@ parse_config (char *config_file, char *current_shared_name,
if (braces_shared == braces)
{
current_shared_name = shared_net_names;
/* TODO: Using 1000 is lame, but works. */
braces_shared = 1000;
shared_p = shared_networks;
}
@ -289,7 +290,8 @@ parse_config (char *config_file, char *current_shared_name,
continue;
}
/* Save to word which clause this is. */
if ((newclause == true || argument != 0) && (!isspace (c) || quote == true))
if ((newclause == true || argument != 0)
&& (!isspace (c) || quote == true))
{
word[i] = c;
i++;
@ -345,7 +347,7 @@ parse_config (char *config_file, char *current_shared_name,
{
/* TODO: make this go away by reallocationg more space. */
eprintf
("End of shared-network space, increase SHARED_NETWORKS_NAMES and recompile");
("parse_config: End of shared-network space, increase SHARED_NETWORKS_NAMES and recompile");
}
argument = 0;
break;
@ -382,7 +384,7 @@ parse_config (char *config_file, char *current_shared_name,
newclause = true;
break;
default:
eprintf ("This cannot happpen, report a bug!");
eprintf ("parse_config: This cannot happen, report a bug!");
exit (EXIT_FAILURE);
}
}