Skip to content

Commit

Permalink
Reindent and remove trailing whitespace.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@517 e88ac4ed-0b26-0410-9574-a7f39faa03bf
  • Loading branch information
linus authored and linus committed Mar 8, 2010
1 parent 317902c commit d3815df
Show file tree
Hide file tree
Showing 15 changed files with 403 additions and 403 deletions.
4 changes: 2 additions & 2 deletions debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int debug_set_destination(char *dest) {
LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7 };
extern int errno;
int i;

if (!strncasecmp(dest, "file:///", 8)) {
debug_filepath = stringcopy(dest + 7, 0);
debug_file = fopen(debug_filepath, "a");
Expand Down Expand Up @@ -127,7 +127,7 @@ void debug_logit(uint8_t level, const char *format, va_list ap) {
struct timeval now;
char *timebuf;
int priority;

if (debug_syslogfacility) {
switch (level) {
case DBG_DBG:
Expand Down
48 changes: 24 additions & 24 deletions dtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ struct sessioncacheentry {
struct dtlsservernewparams {
struct sessioncacheentry *sesscache;
int sock;
struct sockaddr_storage addr;
struct sockaddr_storage addr;
};

void dtlssetsrcres() {
Expand All @@ -109,7 +109,7 @@ int udp2bio(int s, struct gqueue *q, int cnt) {

if (cnt < 1)
return 0;

buf = malloc(cnt);
if (!buf) {
unsigned char err;
Expand Down Expand Up @@ -162,7 +162,7 @@ BIO *getrbio(SSL *ssl, struct gqueue *q, int timeout) {
int dtlsread(SSL *ssl, struct gqueue *q, unsigned char *buf, int num, int timeout) {
int len, cnt;
BIO *rbio;

for (len = 0; len < num; len += cnt) {
cnt = SSL_read(ssl, buf + len, num - len);
if (cnt <= 0)
Expand All @@ -171,7 +171,7 @@ int dtlsread(SSL *ssl, struct gqueue *q, unsigned char *buf, int num, int timeou
rbio = getrbio(ssl, q, timeout);
if (!rbio)
return 0;
BIO_free(ssl->rbio);
BIO_free(ssl->rbio);
ssl->rbio = rbio;
cnt = 0;
continue;
Expand Down Expand Up @@ -199,7 +199,7 @@ SSL *dtlsacccon(uint8_t acc, SSL_CTX *ctx, int s, struct sockaddr *addr, struct
ssl = SSL_new(ctx);
if (!ssl)
return NULL;

mem0bio = BIO_new(BIO_s_mem());
BIO_set_mem_eof_return(mem0bio, -1);
wbio = BIO_new_dgram(s, BIO_NOCLOSE);
Expand Down Expand Up @@ -244,21 +244,21 @@ unsigned char *raddtlsget(SSL *ssl, struct gqueue *rbios, int timeout) {
continue;
}
memcpy(rad, buf, 4);

cnt = dtlsread(ssl, rbios, rad + 4, len - 4, timeout);
if (cnt < 1) {
debug(DBG_DBG, cnt ? "raddtlsget: connection lost" : "raddtlsget: timeout");
free(rad);
return NULL;
}

if (len >= 20)
break;

free(rad);
debug(DBG_WARN, "raddtlsget: packet smaller than minimum radius size");
}

debug(DBG_DBG, "raddtlsget: got %d bytes", len);
return rad;
}
Expand All @@ -269,13 +269,13 @@ void *dtlsserverwr(void *arg) {
struct client *client = (struct client *)arg;
struct gqueue *replyq;
struct request *reply;

debug(DBG_DBG, "dtlsserverwr: starting for %s", addr2string(client->addr));
replyq = client->replyq;
for (;;) {
pthread_mutex_lock(&replyq->mutex);
while (!list_first(replyq->entries)) {
if (client->ssl) {
if (client->ssl) {
debug(DBG_DBG, "dtlsserverwr: waiting for signal");
pthread_cond_wait(&replyq->cond, &replyq->mutex);
debug(DBG_DBG, "dtlsserverwr: got signal");
Expand Down Expand Up @@ -305,7 +305,7 @@ void dtlsserverrd(struct client *client) {
struct request *rq;
uint8_t *buf;
pthread_t dtlsserverwrth;

debug(DBG_DBG, "dtlsserverrd: starting for %s", addr2string(client->addr));

if (pthread_create(&dtlsserverwrth, NULL, dtlsserverwr, (void *)client)) {
Expand All @@ -332,7 +332,7 @@ void dtlsserverrd(struct client *client) {
break;
}
}

/* stop writer by setting ssl to NULL and give signal in case waiting for data */
client->ssl = NULL;

Expand Down Expand Up @@ -392,7 +392,7 @@ void *dtlsservernew(void *arg) {
if (cert)
X509_free(cert);

exit:
exit:
if (ssl) {
SSL_shutdown(ssl);
SSL_free(ssl);
Expand All @@ -413,7 +413,7 @@ void cacheexpire(struct hash *cache, struct timeval *last) {
struct timeval now;
struct hash_entry *he;
struct sessioncacheentry *e;

gettimeofday(&now, NULL);
if (now.tv_sec - last->tv_sec < 19)
return;
Expand Down Expand Up @@ -448,12 +448,12 @@ void *udpdtlsserverrd(void *arg) {
pthread_t dtlsserverth;
struct hash *sessioncache;
struct sessioncacheentry *cacheentry;

sessioncache = hash_create();
if (!sessioncache)
debugx(1, DBG_ERR, "udpdtlsserverrd: malloc failed");
gettimeofday(&lastexpiry, NULL);

for (;;) {
FD_ZERO(&readfds);
FD_SET(s, &readfds);
Expand Down Expand Up @@ -532,7 +532,7 @@ int dtlsconnect(struct server *server, struct timeval *when, int timeout, char *
X509 *cert;
SSL_CTX *ctx = NULL;
struct hostportres *hp;

debug(DBG_DBG, "dtlsconnect: called from %s", text);
pthread_mutex_lock(&server->lock);
if (when && memcmp(&server->lastconnecttry, when, sizeof(struct timeval))) {
Expand Down Expand Up @@ -579,11 +579,11 @@ int dtlsconnect(struct server *server, struct timeval *when, int timeout, char *
if (!server->ssl)
continue;
debug(DBG_DBG, "dtlsconnect: DTLS: ok");

cert = verifytlscert(server->ssl);
if (!cert)
continue;

if (verifyconfcert(cert, server->conf))
break;
X509_free(cert);
Expand Down Expand Up @@ -622,7 +622,7 @@ void *udpdtlsclientrd(void *arg) {
socklen_t fromlen = sizeof(from);
struct clsrvconf *conf;
fd_set readfds;

for (;;) {
FD_ZERO(&readfds);
FD_SET(s, &readfds);
Expand All @@ -633,7 +633,7 @@ void *udpdtlsclientrd(void *arg) {
debug(DBG_WARN, "udpdtlsclientrd: recv failed");
continue;
}

conf = find_srvconf(handle, (struct sockaddr *)&from, NULL);
if (!conf) {
debug(DBG_WARN, "udpdtlsclientrd: got packet from wrong or unknown DTLS peer %s, ignoring", addr2string((struct sockaddr *)&from));
Expand All @@ -650,7 +650,7 @@ void *dtlsclientrd(void *arg) {
unsigned char *buf;
struct timeval lastconnecttry;
int secs;

for (;;) {
/* yes, lastconnecttry is really necessary */
lastconnecttry = server->lastconnecttry;
Expand Down Expand Up @@ -696,7 +696,7 @@ void initextradtls() {
freeaddrinfo(srcres);
srcres = NULL;
}

if (client4_sock >= 0)
if (pthread_create(&cl4th, NULL, udpdtlsclientrd, (void *)&client4_sock))
debugx(1, DBG_ERR, "pthread_create failed");
Expand Down
40 changes: 20 additions & 20 deletions gconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ FILE *pushgconffile(struct gconffile **cf, FILE *file, const char *description)
desc = stringcopy(description, 0);
if (!desc)
goto errmalloc;

if (!*cf) {
newcf = malloc(sizeof(struct gconffile) * 2);
if (!newcf)
Expand All @@ -105,8 +105,8 @@ FILE *pushgconffile(struct gconffile **cf, FILE *file, const char *description)
newcf[0].path = desc;
*cf = newcf;
return file;
errmalloc:

errmalloc:
free(desc);
fclose(file);
debug(DBG_ERR, "malloc failed");
Expand All @@ -125,7 +125,7 @@ FILE *pushgconfpaths(struct gconffile **cf, const char *cfgpath) {
FILE *f = NULL;
glob_t globbuf;
char *path, *curfile = NULL, *dir;

/* if cfgpath is relative, make it relative to current config */
if (*cfgpath == '/')
path = (char *)cfgpath;
Expand Down Expand Up @@ -156,10 +156,10 @@ FILE *pushgconfpaths(struct gconffile **cf, const char *cfgpath) {
f = pushgconfpath(cf, globbuf.gl_pathv[i]);
if (!f)
break;
}
}
globfree(&globbuf);

exit:
exit:
if (curfile) {
free(curfile);
free(path);
Expand Down Expand Up @@ -204,7 +204,7 @@ void freegconf(struct gconffile **cf) {

if (!*cf)
return;

for (i = 0; (*cf)[i].data || (*cf)[i].path; i++) {
if ((*cf)[i].file) {
fclose((*cf)[i].file);
Expand Down Expand Up @@ -242,10 +242,10 @@ struct gconffile *openconfigfile(const char *file) {

int getlinefromcf(struct gconffile *cf, char *line, const size_t size) {
size_t i, pos;

if (!cf)
return 0;

if (cf->file)
return fgets(line, size, cf->file) ? 1 : 0;
else if (cf->data) {
Expand All @@ -269,11 +269,11 @@ int getconfigline(struct gconffile **cf, char *block, char **opt, char **val, in
char line[1024];
char *tokens[3], *s;
int tcount;

*opt = NULL;
*val = NULL;
*conftype = 0;

if (!cf || !*cf || (!(*cf)->file && !(*cf)->data))
return 1;

Expand Down Expand Up @@ -304,7 +304,7 @@ int getconfigline(struct gconffile **cf, char *block, char **opt, char **val, in
}
break;
}

switch (tcount) {
case 2:
*opt = stringcopy(tokens[0], 0);
Expand Down Expand Up @@ -347,13 +347,13 @@ int getconfigline(struct gconffile **cf, char *block, char **opt, char **val, in

if (**val)
return 1;

debug(DBG_ERR, "configuration error, option %s needs a non-empty value", *opt);
goto errexit;

errmalloc:
errmalloc:
debug(DBG_ERR, "malloc failed");
errexit:
errexit:
free(*opt);
*opt = NULL;
free(*val);
Expand Down Expand Up @@ -411,7 +411,7 @@ int getgenericconfig(struct gconffile **cf, char *block, ...) {
free(val);
continue;
}

va_start(ap, block);
while ((word = va_arg(ap, char *))) {
type = va_arg(ap, int);
Expand Down Expand Up @@ -449,7 +449,7 @@ int getgenericconfig(struct gconffile **cf, char *block, ...) {
break;
}
va_end(ap);

if (!word) {
if (block)
debug(DBG_ERR, "configuration error in block %s, unknown option %s", block, opt);
Expand Down Expand Up @@ -532,15 +532,15 @@ int getgenericconfig(struct gconffile **cf, char *block, ...) {
}
if (block)
debug(DBG_DBG, "getgenericconfig: block %s: %s = %s", block, opt, val);
else
else
debug(DBG_DBG, "getgenericconfig: %s = %s", opt, val);
if (type == CONF_BLN || type == CONF_LINT)
free(val);
}

errparam:
errparam:
debug(DBG_ERR, "getgenericconfig: internal parameter error");
errexit:
errexit:
free(opt);
free(val);
return 0;
Expand Down
10 changes: 5 additions & 5 deletions hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct hash *hash_create() {
/* frees all memory associated with the hash */
void hash_destroy(struct hash *h) {
struct list_node *ln;

if (!h)
return;
for (ln = list_first(h->hashlist); ln; ln = list_next(ln)) {
Expand Down Expand Up @@ -73,15 +73,15 @@ int hash_insert(struct hash *h, void *key, uint32_t keylen, void *data) {
void *hash_read(struct hash *h, void *key, uint32_t keylen) {
struct list_node *ln;
struct hash_entry *e;

if (!h)
return 0;
pthread_mutex_lock(&h->mutex);
for (ln = list_first(h->hashlist); ln; ln = list_next(ln)) {
e = (struct hash_entry *)ln->data;
if (e->keylen == keylen && !memcmp(e->key, key, keylen)) {
pthread_mutex_unlock(&h->mutex);
return e->data;
pthread_mutex_unlock(&h->mutex);
return e->data;
}
}
pthread_mutex_unlock(&h->mutex);
Expand All @@ -92,7 +92,7 @@ void *hash_read(struct hash *h, void *key, uint32_t keylen) {
void *hash_extract(struct hash *h, void *key, uint32_t keylen) {
struct list_node *ln;
struct hash_entry *e;

if (!h)
return 0;
pthread_mutex_lock(&h->mutex);
Expand Down
Loading

0 comments on commit d3815df

Please sign in to comment.