Merge branch 'each-style-tweak' into 'master'

adjust clang-format options to get closer to ISC style

See merge request isc-projects/bind9!3061

(cherry picked from commit d3b49b6675)

0255a974 revise .clang-format and add a C formatting script in util
e851ed0b apply the modified style
This commit is contained in:
Ondřej Surý
2020-02-14 05:35:17 +00:00
parent c646c20e79
commit cdef20bb66
672 changed files with 36044 additions and 42228 deletions

View File

@@ -40,15 +40,14 @@
#define CAR(s) (s)->value.as_dottedpair.car
#define CDR(s) (s)->value.as_dottedpair.cdr
#define ALIST_TAG "*alist*"
#define ALIST_TAG "*alist*"
#define MAX_INDENT 64
static char spaces[MAX_INDENT + 1] = " "
" ";
isccc_sexpr_t *
isccc_alist_create(void)
{
isccc_alist_create(void) {
isccc_sexpr_t *alist, *tag;
tag = isccc_sexpr_fromstring(ALIST_TAG);
@@ -65,8 +64,7 @@ isccc_alist_create(void)
}
bool
isccc_alist_alistp(isccc_sexpr_t *alist)
{
isccc_alist_alistp(isccc_sexpr_t *alist) {
isccc_sexpr_t *car;
if (alist == NULL || alist->type != ISCCC_SEXPRTYPE_DOTTEDPAIR) {
@@ -83,8 +81,7 @@ isccc_alist_alistp(isccc_sexpr_t *alist)
}
bool
isccc_alist_emptyp(isccc_sexpr_t *alist)
{
isccc_alist_emptyp(isccc_sexpr_t *alist) {
REQUIRE(isccc_alist_alistp(alist));
if (CDR(alist) == NULL) {
@@ -94,16 +91,14 @@ isccc_alist_emptyp(isccc_sexpr_t *alist)
}
isccc_sexpr_t *
isccc_alist_first(isccc_sexpr_t *alist)
{
isccc_alist_first(isccc_sexpr_t *alist) {
REQUIRE(isccc_alist_alistp(alist));
return (CDR(alist));
}
isccc_sexpr_t *
isccc_alist_assq(isccc_sexpr_t *alist, const char *key)
{
isccc_alist_assq(isccc_sexpr_t *alist, const char *key) {
isccc_sexpr_t *car, *caar;
REQUIRE(isccc_alist_alistp(alist));
@@ -119,7 +114,8 @@ isccc_alist_assq(isccc_sexpr_t *alist, const char *key)
INSIST(car->type == ISCCC_SEXPRTYPE_DOTTEDPAIR);
caar = CAR(car);
if (caar->type == ISCCC_SEXPRTYPE_STRING &&
strcmp(caar->value.as_string, key) == 0) {
strcmp(caar->value.as_string, key) == 0)
{
return (car);
}
alist = CDR(alist);
@@ -129,8 +125,7 @@ isccc_alist_assq(isccc_sexpr_t *alist, const char *key)
}
void
isccc_alist_delete(isccc_sexpr_t *alist, const char *key)
{
isccc_alist_delete(isccc_sexpr_t *alist, const char *key) {
isccc_sexpr_t *car, *caar, *rest, *prev;
REQUIRE(isccc_alist_alistp(alist));
@@ -143,7 +138,8 @@ isccc_alist_delete(isccc_sexpr_t *alist, const char *key)
INSIST(car != NULL && car->type == ISCCC_SEXPRTYPE_DOTTEDPAIR);
caar = CAR(car);
if (caar->type == ISCCC_SEXPRTYPE_STRING &&
strcmp(caar->value.as_string, key) == 0) {
strcmp(caar->value.as_string, key) == 0)
{
CDR(prev) = CDR(rest);
CDR(rest) = NULL;
isccc_sexpr_free(&rest);
@@ -155,8 +151,8 @@ isccc_alist_delete(isccc_sexpr_t *alist, const char *key)
}
isccc_sexpr_t *
isccc_alist_define(isccc_sexpr_t *alist, const char *key, isccc_sexpr_t *value)
{
isccc_alist_define(isccc_sexpr_t *alist, const char *key,
isccc_sexpr_t *value) {
isccc_sexpr_t *kv, *k, *elt;
kv = isccc_alist_assq(alist, key);
@@ -190,8 +186,8 @@ isccc_alist_define(isccc_sexpr_t *alist, const char *key, isccc_sexpr_t *value)
}
isccc_sexpr_t *
isccc_alist_definestring(isccc_sexpr_t *alist, const char *key, const char *str)
{
isccc_alist_definestring(isccc_sexpr_t *alist, const char *key,
const char *str) {
isccc_sexpr_t *v, *kv;
v = isccc_sexpr_fromstring(str);
@@ -208,8 +204,7 @@ isccc_alist_definestring(isccc_sexpr_t *alist, const char *key, const char *str)
isccc_sexpr_t *
isccc_alist_definebinary(isccc_sexpr_t *alist, const char *key,
isccc_region_t *r)
{
isccc_region_t *r) {
isccc_sexpr_t *v, *kv;
v = isccc_sexpr_frombinary(r);
@@ -225,8 +220,7 @@ isccc_alist_definebinary(isccc_sexpr_t *alist, const char *key,
}
isccc_sexpr_t *
isccc_alist_lookup(isccc_sexpr_t *alist, const char *key)
{
isccc_alist_lookup(isccc_sexpr_t *alist, const char *key) {
isccc_sexpr_t *kv;
kv = isccc_alist_assq(alist, key);
@@ -237,8 +231,7 @@ isccc_alist_lookup(isccc_sexpr_t *alist, const char *key)
}
isc_result_t
isccc_alist_lookupstring(isccc_sexpr_t *alist, const char *key, char **strp)
{
isccc_alist_lookupstring(isccc_sexpr_t *alist, const char *key, char **strp) {
isccc_sexpr_t *kv, *v;
kv = isccc_alist_assq(alist, key);
@@ -259,8 +252,7 @@ isccc_alist_lookupstring(isccc_sexpr_t *alist, const char *key, char **strp)
isc_result_t
isccc_alist_lookupbinary(isccc_sexpr_t *alist, const char *key,
isccc_region_t **r)
{
isccc_region_t **r) {
isccc_sexpr_t *kv, *v;
kv = isccc_alist_assq(alist, key);
@@ -280,8 +272,8 @@ isccc_alist_lookupbinary(isccc_sexpr_t *alist, const char *key,
}
void
isccc_alist_prettyprint(isccc_sexpr_t *sexpr, unsigned int indent, FILE *stream)
{
isccc_alist_prettyprint(isccc_sexpr_t *sexpr, unsigned int indent,
FILE *stream) {
isccc_sexpr_t *elt, *kv, *k, *v;
if (isccc_alist_alistp(sexpr)) {

View File

@@ -36,8 +36,7 @@
isc_result_t
isccc_base64_encode(isccc_region_t *source, int wordlength,
const char *wordbreak, isccc_region_t *target)
{
const char *wordbreak, isccc_region_t *target) {
isc_region_t sr;
isc_buffer_t tb;
isc_result_t result;
@@ -57,8 +56,7 @@ isccc_base64_encode(isccc_region_t *source, int wordlength,
}
isc_result_t
isccc_base64_decode(const char *cstr, isccc_region_t *target)
{
isccc_base64_decode(const char *cstr, isccc_region_t *target) {
isc_buffer_t b;
isc_result_t result;

View File

@@ -46,7 +46,7 @@
#include <isccc/util.h>
#include <pk11/site.h>
#define MAX_TAGS 256
#define MAX_TAGS 256
#define DUP_LIFETIME 900
typedef isccc_sexpr_t *sexpr_ptr;
@@ -94,18 +94,15 @@ static unsigned char auth_hsha[] = {
#define HSHA_OFFSET 22 /*%< 21 = 6 + 1 + 4 + 5 + 1 + 4 + 1 */
#define HSHA_LENGTH 88
static isc_result_t
table_towire(isccc_sexpr_t *alist, isc_buffer_t **buffer);
static isc_result_t table_towire(isccc_sexpr_t *alist, isc_buffer_t **buffer);
static isc_result_t list_towire(isccc_sexpr_t *alist, isc_buffer_t **buffer);
static isc_result_t
list_towire(isccc_sexpr_t *alist, isc_buffer_t **buffer);
static isc_result_t
value_towire(isccc_sexpr_t *elt, isc_buffer_t **buffer)
{
unsigned int len;
value_towire(isccc_sexpr_t *elt, isc_buffer_t **buffer) {
unsigned int len;
isccc_region_t *vr;
isc_result_t result;
isc_result_t result;
if (isccc_sexpr_binaryp(elt)) {
vr = isccc_sexpr_tobinary(elt);
@@ -196,12 +193,11 @@ value_towire(isccc_sexpr_t *elt, isc_buffer_t **buffer)
}
static isc_result_t
table_towire(isccc_sexpr_t *alist, isc_buffer_t **buffer)
{
table_towire(isccc_sexpr_t *alist, isc_buffer_t **buffer) {
isccc_sexpr_t *kv, *elt, *k, *v;
char * ks;
isc_result_t result;
unsigned int len;
char *ks;
isc_result_t result;
unsigned int len;
for (elt = isccc_alist_first(alist); elt != NULL;
elt = ISCCC_SEXPR_CDR(elt)) {
@@ -233,8 +229,7 @@ table_towire(isccc_sexpr_t *alist, isc_buffer_t **buffer)
}
static isc_result_t
list_towire(isccc_sexpr_t *list, isc_buffer_t **buffer)
{
list_towire(isccc_sexpr_t *list, isc_buffer_t **buffer) {
isc_result_t result;
while (list != NULL) {
@@ -250,14 +245,13 @@ list_towire(isccc_sexpr_t *list, isc_buffer_t **buffer)
static isc_result_t
sign(unsigned char *data, unsigned int length, unsigned char *hmac,
uint32_t algorithm, isccc_region_t *secret)
{
isc_md_type_t md_type;
isc_result_t result;
uint32_t algorithm, isccc_region_t *secret) {
isc_md_type_t md_type;
isc_result_t result;
isccc_region_t source, target;
unsigned char digest[ISC_MAX_MD_SIZE];
unsigned int digestlen;
unsigned char digestb64[HSHA_LENGTH + 4];
unsigned char digest[ISC_MAX_MD_SIZE];
unsigned int digestlen;
unsigned char digestb64[HSHA_LENGTH + 4];
source.rstart = digest;
@@ -308,15 +302,14 @@ sign(unsigned char *data, unsigned int length, unsigned char *hmac,
isc_result_t
isccc_cc_towire(isccc_sexpr_t *alist, isc_buffer_t **buffer, uint32_t algorithm,
isccc_region_t *secret)
{
isccc_region_t *secret) {
unsigned int hmac_base, signed_base;
isc_result_t result;
result =
isc_buffer_reserve(buffer, 4 + ((algorithm == ISCCC_ALG_HMACMD5)
? sizeof(auth_hmd5)
: sizeof(auth_hsha)));
result = isc_buffer_reserve(buffer,
4 + ((algorithm == ISCCC_ALG_HMACMD5)
? sizeof(auth_hmd5)
: sizeof(auth_hsha)));
if (result != ISC_R_SUCCESS) {
return (ISC_R_NOSPACE);
}
@@ -373,16 +366,15 @@ isccc_cc_towire(isccc_sexpr_t *alist, isc_buffer_t **buffer, uint32_t algorithm,
static isc_result_t
verify(isccc_sexpr_t *alist, unsigned char *data, unsigned int length,
uint32_t algorithm, isccc_region_t *secret)
{
isc_md_type_t md_type;
uint32_t algorithm, isccc_region_t *secret) {
isc_md_type_t md_type;
isccc_region_t source;
isccc_region_t target;
isc_result_t result;
isc_result_t result;
isccc_sexpr_t *_auth, *hmac;
unsigned char digest[ISC_MAX_MD_SIZE];
unsigned int digestlen;
unsigned char digestb64[HSHA_LENGTH * 4];
unsigned char digest[ISC_MAX_MD_SIZE];
unsigned int digestlen;
unsigned char digestb64[HSHA_LENGTH * 4];
/*
* Extract digest.
@@ -447,7 +439,7 @@ verify(isccc_sexpr_t *alist, unsigned char *data, unsigned int length,
*/
if (algorithm == ISCCC_ALG_HMACMD5) {
isccc_region_t *region;
unsigned char * value;
unsigned char *value;
region = isccc_sexpr_tobinary(hmac);
if ((region->rend - region->rstart) != HMD5_LENGTH) {
@@ -459,8 +451,8 @@ verify(isccc_sexpr_t *alist, unsigned char *data, unsigned int length,
}
} else {
isccc_region_t *region;
unsigned char * value;
uint32_t valalg;
unsigned char *value;
uint32_t valalg;
region = isccc_sexpr_tobinary(hmac);
@@ -482,21 +474,20 @@ verify(isccc_sexpr_t *alist, unsigned char *data, unsigned int length,
return (ISC_R_SUCCESS);
}
static isc_result_t
table_fromwire(isccc_region_t *source, isccc_region_t *secret,
uint32_t algorithm, isccc_sexpr_t **alistp);
static isc_result_t table_fromwire(isccc_region_t *source,
isccc_region_t *secret, uint32_t algorithm,
isccc_sexpr_t **alistp);
static isc_result_t list_fromwire(isccc_region_t *source,
isccc_sexpr_t **listp);
static isc_result_t
list_fromwire(isccc_region_t *source, isccc_sexpr_t **listp);
static isc_result_t
value_fromwire(isccc_region_t *source, isccc_sexpr_t **valuep)
{
unsigned int msgtype;
uint32_t len;
value_fromwire(isccc_region_t *source, isccc_sexpr_t **valuep) {
unsigned int msgtype;
uint32_t len;
isccc_sexpr_t *value;
isccc_region_t active;
isc_result_t result;
isc_result_t result;
if (REGION_SIZE(*source) < 1 + 4) {
return (ISC_R_UNEXPECTEDEND);
@@ -530,13 +521,12 @@ value_fromwire(isccc_region_t *source, isccc_sexpr_t **valuep)
static isc_result_t
table_fromwire(isccc_region_t *source, isccc_region_t *secret,
uint32_t algorithm, isccc_sexpr_t **alistp)
{
char key[256];
uint32_t len;
isc_result_t result;
uint32_t algorithm, isccc_sexpr_t **alistp) {
char key[256];
uint32_t len;
isc_result_t result;
isccc_sexpr_t *alist, *value;
bool first_tag;
bool first_tag;
unsigned char *checksum_rstart;
REQUIRE(alistp != NULL && *alistp == NULL);
@@ -595,10 +585,9 @@ bad:
}
static isc_result_t
list_fromwire(isccc_region_t *source, isccc_sexpr_t **listp)
{
list_fromwire(isccc_region_t *source, isccc_sexpr_t **listp) {
isccc_sexpr_t *list, *value;
isc_result_t result;
isc_result_t result;
list = NULL;
while (!REGION_EMPTY(*source)) {
@@ -622,10 +611,9 @@ list_fromwire(isccc_region_t *source, isccc_sexpr_t **listp)
isc_result_t
isccc_cc_fromwire(isccc_region_t *source, isccc_sexpr_t **alistp,
uint32_t algorithm, isccc_region_t *secret)
{
uint32_t algorithm, isccc_region_t *secret) {
unsigned int size;
uint32_t version;
uint32_t version;
size = REGION_SIZE(*source);
if (size < 4) {
@@ -642,10 +630,9 @@ isccc_cc_fromwire(isccc_region_t *source, isccc_sexpr_t **alistp,
static isc_result_t
createmessage(uint32_t version, const char *from, const char *to,
uint32_t serial, isccc_time_t now, isccc_time_t expires,
isccc_sexpr_t **alistp, bool want_expires)
{
isccc_sexpr_t **alistp, bool want_expires) {
isccc_sexpr_t *alist, *_ctrl, *_data;
isc_result_t result;
isc_result_t result;
REQUIRE(alistp != NULL && *alistp == NULL);
@@ -681,11 +668,12 @@ createmessage(uint32_t version, const char *from, const char *to,
if (isccc_cc_defineuint32(_ctrl, "_ser", serial) == NULL ||
isccc_cc_defineuint32(_ctrl, "_tim", now) == NULL ||
(want_expires &&
isccc_cc_defineuint32(_ctrl, "_exp", expires) == NULL)) {
isccc_cc_defineuint32(_ctrl, "_exp", expires) == NULL))
{
goto bad;
}
if (from != NULL &&
isccc_cc_definestring(_ctrl, "_frm", from) == NULL) {
if (from != NULL && isccc_cc_definestring(_ctrl, "_frm", from) == NULL)
{
goto bad;
}
if (to != NULL && isccc_cc_definestring(_ctrl, "_to", to) == NULL) {
@@ -705,27 +693,26 @@ bad:
isc_result_t
isccc_cc_createmessage(uint32_t version, const char *from, const char *to,
uint32_t serial, isccc_time_t now, isccc_time_t expires,
isccc_sexpr_t **alistp)
{
isccc_sexpr_t **alistp) {
return (createmessage(version, from, to, serial, now, expires, alistp,
true));
}
isc_result_t
isccc_cc_createack(isccc_sexpr_t *message, bool ok, isccc_sexpr_t **ackp)
{
char * _frm, *_to;
uint32_t serial;
isccc_cc_createack(isccc_sexpr_t *message, bool ok, isccc_sexpr_t **ackp) {
char *_frm, *_to;
uint32_t serial;
isccc_sexpr_t *ack, *_ctrl;
isc_result_t result;
isccc_time_t t;
isc_result_t result;
isccc_time_t t;
REQUIRE(ackp != NULL && *ackp == NULL);
_ctrl = isccc_alist_lookup(message, "_ctrl");
if (!isccc_alist_alistp(_ctrl) ||
isccc_cc_lookupuint32(_ctrl, "_ser", &serial) != ISC_R_SUCCESS ||
isccc_cc_lookupuint32(_ctrl, "_tim", &t) != ISC_R_SUCCESS) {
isccc_cc_lookupuint32(_ctrl, "_tim", &t) != ISC_R_SUCCESS)
{
return (ISC_R_FAILURE);
}
/*
@@ -765,8 +752,7 @@ bad:
}
bool
isccc_cc_isack(isccc_sexpr_t *message)
{
isccc_cc_isack(isccc_sexpr_t *message) {
isccc_sexpr_t *_ctrl;
_ctrl = isccc_alist_lookup(message, "_ctrl");
@@ -780,8 +766,7 @@ isccc_cc_isack(isccc_sexpr_t *message)
}
bool
isccc_cc_isreply(isccc_sexpr_t *message)
{
isccc_cc_isreply(isccc_sexpr_t *message) {
isccc_sexpr_t *_ctrl;
_ctrl = isccc_alist_lookup(message, "_ctrl");
@@ -796,12 +781,11 @@ isccc_cc_isreply(isccc_sexpr_t *message)
isc_result_t
isccc_cc_createresponse(isccc_sexpr_t *message, isccc_time_t now,
isccc_time_t expires, isccc_sexpr_t **alistp)
{
char * _frm, *_to, *type = NULL;
uint32_t serial;
isccc_time_t expires, isccc_sexpr_t **alistp) {
char *_frm, *_to, *type = NULL;
uint32_t serial;
isccc_sexpr_t *alist, *_ctrl, *_data;
isc_result_t result;
isc_result_t result;
REQUIRE(alistp != NULL && *alistp == NULL);
@@ -809,7 +793,8 @@ isccc_cc_createresponse(isccc_sexpr_t *message, isccc_time_t now,
_data = isccc_alist_lookup(message, "_data");
if (!isccc_alist_alistp(_ctrl) || !isccc_alist_alistp(_data) ||
isccc_cc_lookupuint32(_ctrl, "_ser", &serial) != ISC_R_SUCCESS ||
isccc_cc_lookupstring(_data, "type", &type) != ISC_R_SUCCESS) {
isccc_cc_lookupstring(_data, "type", &type) != ISC_R_SUCCESS)
{
return (ISC_R_FAILURE);
}
/*
@@ -842,7 +827,8 @@ isccc_cc_createresponse(isccc_sexpr_t *message, isccc_time_t now,
}
if (isccc_cc_definestring(_ctrl, "_rpl", "1") == NULL ||
isccc_cc_definestring(_data, "type", type) == NULL) {
isccc_cc_definestring(_data, "type", type) == NULL)
{
result = ISC_R_NOMEMORY;
goto bad;
}
@@ -857,9 +843,8 @@ bad:
}
isccc_sexpr_t *
isccc_cc_definestring(isccc_sexpr_t *alist, const char *key, const char *str)
{
size_t len;
isccc_cc_definestring(isccc_sexpr_t *alist, const char *key, const char *str) {
size_t len;
isccc_region_t r;
len = strlen(str);
@@ -870,10 +855,9 @@ isccc_cc_definestring(isccc_sexpr_t *alist, const char *key, const char *str)
}
isccc_sexpr_t *
isccc_cc_defineuint32(isccc_sexpr_t *alist, const char *key, uint32_t i)
{
char b[100];
size_t len;
isccc_cc_defineuint32(isccc_sexpr_t *alist, const char *key, uint32_t i) {
char b[100];
size_t len;
isccc_region_t r;
snprintf(b, sizeof(b), "%u", i);
@@ -885,8 +869,7 @@ isccc_cc_defineuint32(isccc_sexpr_t *alist, const char *key, uint32_t i)
}
isc_result_t
isccc_cc_lookupstring(isccc_sexpr_t *alist, const char *key, char **strp)
{
isccc_cc_lookupstring(isccc_sexpr_t *alist, const char *key, char **strp) {
isccc_sexpr_t *kv, *v;
REQUIRE(strp == NULL || *strp == NULL);
@@ -908,8 +891,7 @@ isccc_cc_lookupstring(isccc_sexpr_t *alist, const char *key, char **strp)
}
isc_result_t
isccc_cc_lookupuint32(isccc_sexpr_t *alist, const char *key, uint32_t *uintp)
{
isccc_cc_lookupuint32(isccc_sexpr_t *alist, const char *key, uint32_t *uintp) {
isccc_sexpr_t *kv, *v;
kv = isccc_alist_assq(alist, key);
@@ -930,8 +912,8 @@ isccc_cc_lookupuint32(isccc_sexpr_t *alist, const char *key, uint32_t *uintp)
}
static void
symtab_undefine(char *key, unsigned int type, isccc_symvalue_t value, void *arg)
{
symtab_undefine(char *key, unsigned int type, isccc_symvalue_t value,
void *arg) {
UNUSED(type);
UNUSED(value);
UNUSED(arg);
@@ -940,8 +922,7 @@ symtab_undefine(char *key, unsigned int type, isccc_symvalue_t value, void *arg)
}
static bool
symtab_clean(char *key, unsigned int type, isccc_symvalue_t value, void *arg)
{
symtab_clean(char *key, unsigned int type, isccc_symvalue_t value, void *arg) {
isccc_time_t *now;
UNUSED(key);
@@ -959,21 +940,18 @@ symtab_clean(char *key, unsigned int type, isccc_symvalue_t value, void *arg)
}
isc_result_t
isccc_cc_createsymtab(isccc_symtab_t **symtabp)
{
isccc_cc_createsymtab(isccc_symtab_t **symtabp) {
return (isccc_symtab_create(11897, symtab_undefine, NULL, false,
symtabp));
}
void
isccc_cc_cleansymtab(isccc_symtab_t *symtab, isccc_time_t now)
{
isccc_cc_cleansymtab(isccc_symtab_t *symtab, isccc_time_t now) {
isccc_symtab_foreach(symtab, symtab_clean, &now);
}
static bool
has_whitespace(const char *str)
{
has_whitespace(const char *str) {
char c;
if (str == NULL) {
@@ -989,21 +967,21 @@ has_whitespace(const char *str)
isc_result_t
isccc_cc_checkdup(isccc_symtab_t *symtab, isccc_sexpr_t *message,
isccc_time_t now)
{
const char * _frm;
const char * _to;
char * _ser = NULL, *_tim = NULL, *tmp;
isc_result_t result;
char * key;
size_t len;
isccc_time_t now) {
const char *_frm;
const char *_to;
char *_ser = NULL, *_tim = NULL, *tmp;
isc_result_t result;
char *key;
size_t len;
isccc_symvalue_t value;
isccc_sexpr_t * _ctrl;
isccc_sexpr_t *_ctrl;
_ctrl = isccc_alist_lookup(message, "_ctrl");
if (!isccc_alist_alistp(_ctrl) ||
isccc_cc_lookupstring(_ctrl, "_ser", &_ser) != ISC_R_SUCCESS ||
isccc_cc_lookupstring(_ctrl, "_tim", &_tim) != ISC_R_SUCCESS) {
isccc_cc_lookupstring(_ctrl, "_tim", &_tim) != ISC_R_SUCCESS)
{
return (ISC_R_FAILURE);
}
@@ -1030,7 +1008,8 @@ isccc_cc_checkdup(isccc_symtab_t *symtab, isccc_sexpr_t *message,
* we can write them to a file later.
*/
if (has_whitespace(_frm) || has_whitespace(_to) ||
has_whitespace(_ser) || has_whitespace(_tim)) {
has_whitespace(_ser) || has_whitespace(_tim))
{
return (ISC_R_FAILURE);
}
len = strlen(_frm) + strlen(_to) + strlen(_ser) + strlen(_tim) + 4;

View File

@@ -35,22 +35,19 @@
#include <isccc/ccmsg.h>
#include <isccc/events.h>
#define CCMSG_MAGIC ISC_MAGIC('C', 'C', 'm', 's')
#define CCMSG_MAGIC ISC_MAGIC('C', 'C', 'm', 's')
#define VALID_CCMSG(foo) ISC_MAGIC_VALID(foo, CCMSG_MAGIC)
static void
recv_length(isc_task_t *, isc_event_t *);
static void
recv_message(isc_task_t *, isc_event_t *);
static void recv_length(isc_task_t *, isc_event_t *);
static void recv_message(isc_task_t *, isc_event_t *);
static void
recv_length(isc_task_t *task, isc_event_t *ev_in)
{
recv_length(isc_task_t *task, isc_event_t *ev_in) {
isc_socketevent_t *ev = (isc_socketevent_t *)ev_in;
isc_event_t * dev;
isccc_ccmsg_t * ccmsg = ev_in->ev_arg;
isc_region_t region;
isc_result_t result;
isc_event_t *dev;
isccc_ccmsg_t *ccmsg = ev_in->ev_arg;
isc_region_t region;
isc_result_t result;
INSIST(VALID_CCMSG(ccmsg));
@@ -100,11 +97,10 @@ send_and_free:
}
static void
recv_message(isc_task_t *task, isc_event_t *ev_in)
{
recv_message(isc_task_t *task, isc_event_t *ev_in) {
isc_socketevent_t *ev = (isc_socketevent_t *)ev_in;
isc_event_t * dev;
isccc_ccmsg_t * ccmsg = ev_in->ev_arg;
isc_event_t *dev;
isccc_ccmsg_t *ccmsg = ev_in->ev_arg;
(void)task;
@@ -128,8 +124,7 @@ send_and_free:
}
void
isccc_ccmsg_init(isc_mem_t *mctx, isc_socket_t *sock, isccc_ccmsg_t *ccmsg)
{
isccc_ccmsg_init(isc_mem_t *mctx, isc_socket_t *sock, isccc_ccmsg_t *ccmsg) {
REQUIRE(mctx != NULL);
REQUIRE(sock != NULL);
REQUIRE(ccmsg != NULL);
@@ -150,8 +145,7 @@ isccc_ccmsg_init(isc_mem_t *mctx, isc_socket_t *sock, isccc_ccmsg_t *ccmsg)
}
void
isccc_ccmsg_setmaxsize(isccc_ccmsg_t *ccmsg, unsigned int maxsize)
{
isccc_ccmsg_setmaxsize(isccc_ccmsg_t *ccmsg, unsigned int maxsize) {
REQUIRE(VALID_CCMSG(ccmsg));
ccmsg->maxsize = maxsize;
@@ -159,8 +153,7 @@ isccc_ccmsg_setmaxsize(isccc_ccmsg_t *ccmsg, unsigned int maxsize)
isc_result_t
isccc_ccmsg_readmessage(isccc_ccmsg_t *ccmsg, isc_task_t *task,
isc_taskaction_t action, void *arg)
{
isc_taskaction_t action, void *arg) {
isc_result_t result;
isc_region_t region;
@@ -196,8 +189,7 @@ isccc_ccmsg_readmessage(isccc_ccmsg_t *ccmsg, isc_task_t *task,
}
void
isccc_ccmsg_cancelread(isccc_ccmsg_t *ccmsg)
{
isccc_ccmsg_cancelread(isccc_ccmsg_t *ccmsg) {
REQUIRE(VALID_CCMSG(ccmsg));
isc_socket_cancel(ccmsg->sock, NULL, ISC_SOCKCANCEL_RECV);
@@ -219,8 +211,7 @@ isccc_ccmsg_freebuffer(isccc_ccmsg_t*ccmsg) {
#endif /* if 0 */
void
isccc_ccmsg_invalidate(isccc_ccmsg_t *ccmsg)
{
isccc_ccmsg_invalidate(isccc_ccmsg_t *ccmsg) {
REQUIRE(VALID_CCMSG(ccmsg));
ccmsg->magic = 0;

View File

@@ -40,9 +40,9 @@ ISC_LANG_BEGINDECLS
/*% from lib/dns/include/dst/dst.h */
#define ISCCC_ALG_UNKNOWN 0
#define ISCCC_ALG_HMACMD5 157
#define ISCCC_ALG_HMACSHA1 161
#define ISCCC_ALG_UNKNOWN 0
#define ISCCC_ALG_HMACMD5 157
#define ISCCC_ALG_HMACSHA1 161
#define ISCCC_ALG_HMACSHA224 162
#define ISCCC_ALG_HMACSHA256 163
#define ISCCC_ALG_HMACSHA384 164

View File

@@ -37,6 +37,6 @@
#define ISCCC_EVENT_CCMSG (ISC_EVENTCLASS_ISCCC + 0)
#define ISCCC_EVENT_FIRSTEVENT (ISC_EVENTCLASS_ISCCC + 0)
#define ISCCC_EVENT_LASTEVENT (ISC_EVENTCLASS_ISCCC + 65535)
#define ISCCC_EVENT_LASTEVENT (ISC_EVENTCLASS_ISCCC + 65535)
#endif /* ISCCC_EVENTS_H */

View File

@@ -53,11 +53,11 @@ struct isccc_sexpr {
} value;
};
#define ISCCC_SEXPRTYPE_NONE 0x00 /*%< Illegal. */
#define ISCCC_SEXPRTYPE_T 0x01
#define ISCCC_SEXPRTYPE_STRING 0x02
#define ISCCC_SEXPRTYPE_NONE 0x00 /*%< Illegal. */
#define ISCCC_SEXPRTYPE_T 0x01
#define ISCCC_SEXPRTYPE_STRING 0x02
#define ISCCC_SEXPRTYPE_DOTTEDPAIR 0x03
#define ISCCC_SEXPRTYPE_BINARY 0x04
#define ISCCC_SEXPRTYPE_BINARY 0x04
#define ISCCC_SEXPR_CAR(s) (s)->value.as_dottedpair.car
#define ISCCC_SEXPR_CDR(s) (s)->value.as_dottedpair.cdr

View File

@@ -28,9 +28,9 @@
/*! \file isccc/symtype.h */
#define ISCCC_SYMTYPE_ZONESTATS 0x0001
#define ISCCC_SYMTYPE_CCDUP 0x0002
#define ISCCC_SYMTYPE_TELLSERVICE 0x0003
#define ISCCC_SYMTYPE_ZONESTATS 0x0001
#define ISCCC_SYMTYPE_CCDUP 0x0002
#define ISCCC_SYMTYPE_TELLSERVICE 0x0003
#define ISCCC_SYMTYPE_TELLRESPONSE 0x0004
#endif /* ISCCC_SYMTYPE_H */

View File

@@ -194,7 +194,7 @@
/*
* Regions.
*/
#define REGION_SIZE(r) ((unsigned int)((r).rend - (r).rstart))
#define REGION_SIZE(r) ((unsigned int)((r).rend - (r).rstart))
#define REGION_EMPTY(r) ((r).rstart == (r).rend)
#define REGION_FROMSTRING(r, s) \
do { \

View File

@@ -49,8 +49,7 @@ static const char *ids[ISCCC_R_NRESULTS] = {
static isc_once_t once = ISC_ONCE_INIT;
static void
initialize_action(void)
{
initialize_action(void) {
isc_result_t result;
result = isc_result_register(ISC_RESULTCLASS_ISCCC, ISCCC_R_NRESULTS,
@@ -69,21 +68,18 @@ initialize_action(void)
}
static void
initialize(void)
{
initialize(void) {
RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
}
const char *
isccc_result_totext(isc_result_t result)
{
isccc_result_totext(isc_result_t result) {
initialize();
return (isc_result_totext(result));
}
void
isccc_result_register(void)
{
isccc_result_register(void) {
initialize();
}

View File

@@ -42,8 +42,7 @@ static isccc_sexpr_t sexpr_t = { ISCCC_SEXPRTYPE_T, { NULL } };
#define CDR(s) (s)->value.as_dottedpair.cdr
isccc_sexpr_t *
isccc_sexpr_cons(isccc_sexpr_t *car, isccc_sexpr_t *cdr)
{
isccc_sexpr_cons(isccc_sexpr_t *car, isccc_sexpr_t *cdr) {
isccc_sexpr_t *sexpr;
sexpr = malloc(sizeof(*sexpr));
@@ -58,14 +57,12 @@ isccc_sexpr_cons(isccc_sexpr_t *car, isccc_sexpr_t *cdr)
}
isccc_sexpr_t *
isccc_sexpr_tconst(void)
{
isccc_sexpr_tconst(void) {
return (&sexpr_t);
}
isccc_sexpr_t *
isccc_sexpr_fromstring(const char *str)
{
isccc_sexpr_fromstring(const char *str) {
isccc_sexpr_t *sexpr;
sexpr = malloc(sizeof(*sexpr));
@@ -83,10 +80,9 @@ isccc_sexpr_fromstring(const char *str)
}
isccc_sexpr_t *
isccc_sexpr_frombinary(const isccc_region_t *region)
{
isccc_sexpr_frombinary(const isccc_region_t *region) {
isccc_sexpr_t *sexpr;
unsigned int region_size;
unsigned int region_size;
sexpr = malloc(sizeof(*sexpr));
if (sexpr == NULL) {
@@ -106,8 +102,8 @@ isccc_sexpr_frombinary(const isccc_region_t *region)
free(sexpr);
return (NULL);
}
sexpr->value.as_region.rend =
sexpr->value.as_region.rstart + region_size;
sexpr->value.as_region.rend = sexpr->value.as_region.rstart +
region_size;
memmove(sexpr->value.as_region.rstart, region->rstart, region_size);
/*
* NUL terminate.
@@ -118,8 +114,7 @@ isccc_sexpr_frombinary(const isccc_region_t *region)
}
void
isccc_sexpr_free(isccc_sexpr_t **sexprp)
{
isccc_sexpr_free(isccc_sexpr_t **sexprp) {
isccc_sexpr_t *sexpr;
isccc_sexpr_t *item;
@@ -150,8 +145,7 @@ isccc_sexpr_free(isccc_sexpr_t **sexprp)
}
static bool
printable(isccc_region_t *r)
{
printable(isccc_region_t *r) {
unsigned char *curr;
curr = r->rstart;
@@ -166,10 +160,9 @@ printable(isccc_region_t *r)
}
void
isccc_sexpr_print(isccc_sexpr_t *sexpr, FILE *stream)
{
isccc_sexpr_print(isccc_sexpr_t *sexpr, FILE *stream) {
isccc_sexpr_t *cdr;
unsigned int size, i;
unsigned int size, i;
unsigned char *curr;
if (sexpr == NULL) {
@@ -220,40 +213,35 @@ isccc_sexpr_print(isccc_sexpr_t *sexpr, FILE *stream)
}
isccc_sexpr_t *
isccc_sexpr_car(isccc_sexpr_t *list)
{
isccc_sexpr_car(isccc_sexpr_t *list) {
REQUIRE(list->type == ISCCC_SEXPRTYPE_DOTTEDPAIR);
return (CAR(list));
}
isccc_sexpr_t *
isccc_sexpr_cdr(isccc_sexpr_t *list)
{
isccc_sexpr_cdr(isccc_sexpr_t *list) {
REQUIRE(list->type == ISCCC_SEXPRTYPE_DOTTEDPAIR);
return (CDR(list));
}
void
isccc_sexpr_setcar(isccc_sexpr_t *pair, isccc_sexpr_t *car)
{
isccc_sexpr_setcar(isccc_sexpr_t *pair, isccc_sexpr_t *car) {
REQUIRE(pair->type == ISCCC_SEXPRTYPE_DOTTEDPAIR);
CAR(pair) = car;
}
void
isccc_sexpr_setcdr(isccc_sexpr_t *pair, isccc_sexpr_t *cdr)
{
isccc_sexpr_setcdr(isccc_sexpr_t *pair, isccc_sexpr_t *cdr) {
REQUIRE(pair->type == ISCCC_SEXPRTYPE_DOTTEDPAIR);
CDR(pair) = cdr;
}
isccc_sexpr_t *
isccc_sexpr_addtolist(isccc_sexpr_t **l1p, isccc_sexpr_t *l2)
{
isccc_sexpr_addtolist(isccc_sexpr_t **l1p, isccc_sexpr_t *l2) {
isccc_sexpr_t *last, *elt, *l1;
REQUIRE(l1p != NULL);
@@ -277,8 +265,7 @@ isccc_sexpr_addtolist(isccc_sexpr_t **l1p, isccc_sexpr_t *l2)
}
bool
isccc_sexpr_listp(isccc_sexpr_t *sexpr)
{
isccc_sexpr_listp(isccc_sexpr_t *sexpr) {
if (sexpr == NULL || sexpr->type == ISCCC_SEXPRTYPE_DOTTEDPAIR) {
return (true);
}
@@ -286,8 +273,7 @@ isccc_sexpr_listp(isccc_sexpr_t *sexpr)
}
bool
isccc_sexpr_emptyp(isccc_sexpr_t *sexpr)
{
isccc_sexpr_emptyp(isccc_sexpr_t *sexpr) {
if (sexpr == NULL) {
return (true);
}
@@ -295,8 +281,7 @@ isccc_sexpr_emptyp(isccc_sexpr_t *sexpr)
}
bool
isccc_sexpr_stringp(isccc_sexpr_t *sexpr)
{
isccc_sexpr_stringp(isccc_sexpr_t *sexpr) {
if (sexpr != NULL && sexpr->type == ISCCC_SEXPRTYPE_STRING) {
return (true);
}
@@ -304,8 +289,7 @@ isccc_sexpr_stringp(isccc_sexpr_t *sexpr)
}
bool
isccc_sexpr_binaryp(isccc_sexpr_t *sexpr)
{
isccc_sexpr_binaryp(isccc_sexpr_t *sexpr) {
if (sexpr != NULL && sexpr->type == ISCCC_SEXPRTYPE_BINARY) {
return (true);
}
@@ -313,8 +297,7 @@ isccc_sexpr_binaryp(isccc_sexpr_t *sexpr)
}
char *
isccc_sexpr_tostring(isccc_sexpr_t *sexpr)
{
isccc_sexpr_tostring(isccc_sexpr_t *sexpr) {
REQUIRE(sexpr != NULL && (sexpr->type == ISCCC_SEXPRTYPE_STRING ||
sexpr->type == ISCCC_SEXPRTYPE_BINARY));
@@ -325,8 +308,7 @@ isccc_sexpr_tostring(isccc_sexpr_t *sexpr)
}
isccc_region_t *
isccc_sexpr_tobinary(isccc_sexpr_t *sexpr)
{
isccc_sexpr_tobinary(isccc_sexpr_t *sexpr) {
REQUIRE(sexpr != NULL && sexpr->type == ISCCC_SEXPRTYPE_BINARY);
return (&sexpr->value.as_region);
}

View File

@@ -38,34 +38,33 @@
#include <isccc/util.h>
typedef struct elt {
char * key;
unsigned int type;
char *key;
unsigned int type;
isccc_symvalue_t value;
ISC_LINK(struct elt) link;
} elt_t;
typedef ISC_LIST(elt_t) eltlist_t;
#define SYMTAB_MAGIC ISC_MAGIC('S', 'y', 'm', 'T')
#define SYMTAB_MAGIC ISC_MAGIC('S', 'y', 'm', 'T')
#define VALID_SYMTAB(st) ISC_MAGIC_VALID(st, SYMTAB_MAGIC)
struct isccc_symtab {
unsigned int magic;
unsigned int size;
eltlist_t * table;
unsigned int magic;
unsigned int size;
eltlist_t *table;
isccc_symtabundefaction_t undefine_action;
void * undefine_arg;
bool case_sensitive;
void *undefine_arg;
bool case_sensitive;
};
isc_result_t
isccc_symtab_create(unsigned int size,
isccc_symtab_create(unsigned int size,
isccc_symtabundefaction_t undefine_action,
void *undefine_arg, bool case_sensitive,
isccc_symtab_t **symtabp)
{
isccc_symtab_t **symtabp) {
isccc_symtab_t *symtab;
unsigned int i;
unsigned int i;
REQUIRE(symtabp != NULL && *symtabp == NULL);
REQUIRE(size > 0); /* Should be prime. */
@@ -94,8 +93,7 @@ isccc_symtab_create(unsigned int size,
}
static inline void
free_elt(isccc_symtab_t *symtab, unsigned int bucket, elt_t *elt)
{
free_elt(isccc_symtab_t *symtab, unsigned int bucket, elt_t *elt) {
ISC_LIST_UNLINK(symtab->table[bucket], elt, link);
if (symtab->undefine_action != NULL) {
(symtab->undefine_action)(elt->key, elt->type, elt->value,
@@ -105,11 +103,10 @@ free_elt(isccc_symtab_t *symtab, unsigned int bucket, elt_t *elt)
}
void
isccc_symtab_destroy(isccc_symtab_t **symtabp)
{
isccc_symtab_destroy(isccc_symtab_t **symtabp) {
isccc_symtab_t *symtab;
unsigned int i;
elt_t * elt, *nelt;
unsigned int i;
elt_t *elt, *nelt;
REQUIRE(symtabp != NULL);
symtab = *symtabp;
@@ -129,12 +126,11 @@ isccc_symtab_destroy(isccc_symtab_t **symtabp)
}
static inline unsigned int
hash(const char *key, bool case_sensitive)
{
const char * s;
hash(const char *key, bool case_sensitive) {
const char *s;
unsigned int h = 0;
unsigned int g;
int c;
int c;
/*
* P. J. Weinberger's hash function, adapted from p. 436 of
@@ -185,10 +181,9 @@ hash(const char *key, bool case_sensitive)
isc_result_t
isccc_symtab_lookup(isccc_symtab_t *symtab, const char *key, unsigned int type,
isccc_symvalue_t *value)
{
isccc_symvalue_t *value) {
unsigned int bucket;
elt_t * elt;
elt_t *elt;
REQUIRE(VALID_SYMTAB(symtab));
REQUIRE(key != NULL);
@@ -208,10 +203,9 @@ isccc_symtab_lookup(isccc_symtab_t *symtab, const char *key, unsigned int type,
isc_result_t
isccc_symtab_define(isccc_symtab_t *symtab, char *key, unsigned int type,
isccc_symvalue_t value, isccc_symexists_t exists_policy)
{
isccc_symvalue_t value, isccc_symexists_t exists_policy) {
unsigned int bucket;
elt_t * elt;
elt_t *elt;
REQUIRE(VALID_SYMTAB(symtab));
REQUIRE(key != NULL);
@@ -252,10 +246,9 @@ isccc_symtab_define(isccc_symtab_t *symtab, char *key, unsigned int type,
isc_result_t
isccc_symtab_undefine(isccc_symtab_t *symtab, const char *key,
unsigned int type)
{
unsigned int type) {
unsigned int bucket;
elt_t * elt;
elt_t *elt;
REQUIRE(VALID_SYMTAB(symtab));
REQUIRE(key != NULL);
@@ -273,10 +266,9 @@ isccc_symtab_undefine(isccc_symtab_t *symtab, const char *key,
void
isccc_symtab_foreach(isccc_symtab_t *symtab, isccc_symtabforeachaction_t action,
void *arg)
{
void *arg) {
unsigned int i;
elt_t * elt, *nelt;
elt_t *elt, *nelt;
REQUIRE(VALID_SYMTAB(symtab));
REQUIRE(action != NULL);

View File

@@ -29,9 +29,8 @@
* Check tables are populated.
*/
static void
tables(void **state)
{
const char * str;
tables(void **state) {
const char *str;
isc_result_t result;
UNUSED(state);
@@ -39,7 +38,8 @@ tables(void **state)
isccc_result_register();
for (result = ISC_RESULTCLASS_ISCCC;
result < (ISC_RESULTCLASS_ISCCC + ISCCC_R_NRESULTS); result++) {
result < (ISC_RESULTCLASS_ISCCC + ISCCC_R_NRESULTS); result++)
{
str = isc_result_toid(result);
assert_non_null(str);
assert_string_not_equal(str, "(result code text not "
@@ -61,8 +61,7 @@ tables(void **state)
}
int
main(void)
{
main(void) {
const struct CMUnitTest tests[] = {
cmocka_unit_test(tables),
};
@@ -75,8 +74,7 @@ main(void)
#include <stdio.h>
int
main(void)
{
main(void) {
printf("1..0 # Skipped: cmocka not available\n");
return (0);
}

View File

@@ -16,8 +16,7 @@
* Called when we enter the DLL
*/
__declspec(dllexport) BOOL WINAPI
DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
switch (fdwReason) {
/*
* The DLL is loading due to process