tools: add indent command configuration file

And reindent all files.

Reference: http://www.gnu.org/software/indent/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2012-11-28 19:50:42 +00:00
parent 761c9560d7
commit 6684772550
6 changed files with 48 additions and 38 deletions

2
src/.indent.pro vendored Normal file
View file

@ -0,0 +1,2 @@
-linux -Tuintmax_t -TFILE -Tsize_t -Toff_t -Ttime_t -ppi1

View file

@ -42,7 +42,8 @@
#include "dhcpd-pools.h"
/* Clean up data */
static int ip_sort(const struct leases_t *restrict a, const struct leases_t *restrict b)
static int ip_sort(const struct leases_t *restrict a,
const struct leases_t *restrict b)
{
if (a->ip < b->ip)
return -1;
@ -56,7 +57,7 @@ int prepare_data(void)
/* Sort leases */
HASH_SORT(leases, ip_sort);
/* Sort ranges */
qsort(ranges, (size_t) num_ranges, sizeof(struct range_t), &rangecomp);
qsort(ranges, (size_t)num_ranges, sizeof(struct range_t), &rangecomp);
return 0;
}

View file

@ -101,7 +101,7 @@ int main(int argc, char **argv)
fullhtml = false;
/* Make sure some output format is selected by default */
strncpy(config.output_format, OUTPUT_FORMAT, (size_t) 1);
strncpy(config.output_format, OUTPUT_FORMAT, (size_t)1);
/* Default sort order is by IPs small to big */
config.reverse_order = false;
@ -125,7 +125,7 @@ int main(int argc, char **argv)
break;
case 'f':
/* Output format */
strncpy(config.output_format, optarg, (size_t) 1);
strncpy(config.output_format, optarg, (size_t)1);
break;
case 's':
/* Output sorting option */
@ -133,10 +133,10 @@ int main(int argc, char **argv)
if (5 < sorts) {
warnx
("main: only first 5 sort orders will be used");
strncpy(config.sort, optarg, (size_t) 5);
strncpy(config.sort, optarg, (size_t)5);
sorts = 5;
} else {
strncpy(config.sort, optarg, (size_t) sorts);
strncpy(config.sort, optarg, (size_t)sorts);
}
for (i = 0; i < sorts; i++) {
field_selector(config.sort[i]);
@ -165,11 +165,13 @@ int main(int argc, char **argv)
break;
case OPT_WARN:
strcpy(config.output_format, "a");
config.warning = strtod_or_err(optarg, "illegal argument");
config.warning =
strtod_or_err(optarg, "illegal argument");
break;
case OPT_CRIT:
strcpy(config.output_format, "a");
config.critical = strtod_or_err(optarg, "illegal argument");
config.critical =
strtod_or_err(optarg, "illegal argument");
break;
case 'v':
/* Print version */

View file

@ -36,20 +36,20 @@
#ifndef DHCPD_POOLS_H
# define DHCPD_POOLS_H 1
#include <config.h>
#include <arpa/inet.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <uthash.h>
# include <config.h>
# include <arpa/inet.h>
# include <stddef.h>
# include <stdio.h>
# include <string.h>
# include <uthash.h>
#ifdef HAVE_BUILTIN_EXPECT
# define likely(x) __builtin_expect(!!(x), 1)
# define unlikely(x) __builtin_expect(!!(x), 0)
#else
# define likely(x) (x)
# define unlikely(x) (x)
#endif
# ifdef HAVE_BUILTIN_EXPECT
# define likely(x) __builtin_expect(!!(x), 1)
# define unlikely(x) __builtin_expect(!!(x), 0)
# else
# define likely(x) (x)
# define unlikely(x) (x)
# endif
/* Structures and unions */
struct configuration_t {
@ -89,7 +89,7 @@ enum ltype {
BACKUP
};
struct leases_t {
uint32_t ip; /* ip as key */
uint32_t ip; /* ip as key */
enum ltype type;
UT_hash_handle hh;
};
@ -113,31 +113,35 @@ struct macaddr_t *macaddr;
/* Function prototypes */
int prepare_memory(void);
int parse_leases(void);
void parse_config(int, const char *__restrict, struct shared_network_t *__restrict)
void parse_config(int, const char *__restrict,
struct shared_network_t *__restrict)
__attribute__ ((nonnull(2, 3)));
void nth_field(char *__restrict dest, const char *__restrict src)
__attribute__ ((nonnull(1, 2)))
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
__attribute__ ((__hot__))
#endif
# endif
;
int prepare_data(void);
int do_counting(void);
void flip_ranges(struct range_t *__restrict ranges, struct range_t *__restrict tmp_ranges)
void flip_ranges(struct range_t *__restrict ranges,
struct range_t *__restrict tmp_ranges)
__attribute__ ((nonnull(1, 2)));
/* support functions */
int xstrstr(const char *__restrict a, const char *__restrict b, int len)
__attribute__ ((nonnull(1, 2)))
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
__attribute__ ((__hot__))
#endif
# endif
;
double strtod_or_err(const char *__restrict str, const char *__restrict errmesg);
double strtod_or_err(const char *__restrict str,
const char *__restrict errmesg);
void print_version(void) __attribute__ ((noreturn));
void usage(int status) __attribute__ ((noreturn));
/* qsort required functions... */
/* ...for ranges and... */
int intcomp(const void *__restrict x, const void *__restrict y) __attribute__ ((nonnull(1, 2)));
int intcomp(const void *__restrict x, const void *__restrict y)
__attribute__ ((nonnull(1, 2)));
int rangecomp(const void *__restrict r1, const void *__restrict r2)
__attribute__ ((nonnull(1, 2)));
/* sort function pointer and functions */
@ -153,7 +157,8 @@ unsigned long int ret_tcperc(struct range_t r);
void field_selector(char c);
int get_order(struct range_t *__restrict left, struct range_t *__restrict right)
__attribute__ ((nonnull(1, 2)));
void mergesort_ranges(struct range_t *__restrict orig, int size, struct range_t *__restrict temp)
void mergesort_ranges(struct range_t *__restrict orig, int size,
struct range_t *__restrict temp)
__attribute__ ((nonnull(1, 3)));
/* output function pointer and functions */
int (*output_analysis) (void);
@ -166,8 +171,8 @@ int output_alarming(void);
void clean_up(void);
/* Hash functions */
void add_lease(int ip, enum ltype type);
struct leases_t * find_lease(int ip);
void delete_lease(struct leases_t * lease);
struct leases_t *find_lease(int ip);
void delete_lease(struct leases_t *lease);
void delete_all_leases();
#endif /* DHCPD_POOLS_H */

View file

@ -368,9 +368,8 @@ void parse_config(int is_include, const char *restrict config_file,
RANGES *= 2;
ranges =
xrealloc(ranges,
sizeof(struct
range_t) *
RANGES);
sizeof(struct
range_t) * RANGES);
range_p = ranges + num_ranges;
}
newclause = true;

View file

@ -59,7 +59,7 @@ int rangecomp(const void *restrict r1, const void *restrict r2)
(((struct range_t *)r2)->first_ip))
return -1;
if ((((struct range_t *)r2)->first_ip) <
(((struct range_t *)r1)->first_ip))
(((struct range_t *)r1)->first_ip))
return 1;
return 0;
}
@ -174,7 +174,8 @@ int get_order(struct range_t *restrict left, struct range_t *restrict right)
return (0);
}
void mergesort_ranges(struct range_t *restrict orig, int size, struct range_t *restrict temp)
void mergesort_ranges(struct range_t *restrict orig, int size,
struct range_t *restrict temp)
{
int left, right, i;
struct range_t hold;