chiark
/
gitweb
/
~mdw
/
adns
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Licensing: Delete FSF address from INSTALL
[adns]
/
src
/
query.c
diff --git
a/src/query.c
b/src/query.c
index 771a985061fd8da96d0f7e8623662176c4c8271c..2ae3a5b7b2c8ba23ad5454b11e4127918e59ff9f 100644
(file)
--- a/
src/query.c
+++ b/
src/query.c
@@
-13,7
+13,7
@@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version
2
, or (at your option)
+ * the Free Software Foundation; either version
3
, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* any later version.
*
* This program is distributed in the hope that it will be useful,
@@
-22,8
+22,7
@@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with this program; if not, write to the Free Software Foundation.
*/
#include "internal.h"
*/
#include "internal.h"
@@
-181,22
+180,22
@@
static void query_simple(adns_state ads, adns_query qu,
struct timeval now) {
vbuf vb_new;
int id;
struct timeval now) {
vbuf vb_new;
int id;
- adns_status st
at
;
+ adns_status st;
- st
at
= adns__mkquery(ads,&qu->vb,&id, owner,ol,
+ st= adns__mkquery(ads,&qu->vb,&id, owner,ol,
typei,qu->answer->type, flags);
typei,qu->answer->type, flags);
- if (st
at
) {
- if (st
at
== adns_s_querydomaintoolong && (flags & adns_qf_search)) {
+ if (st) {
+ if (st == adns_s_querydomaintoolong && (flags & adns_qf_search)) {
adns__search_next(ads,qu,now);
return;
} else {
adns__search_next(ads,qu,now);
return;
} else {
- adns__query_fail(qu,st
at
);
+ adns__query_fail(qu,st);
return;
}
}
return;
}
}
- st
at
= check_domain_name(ads, flags,&qu->ctx,typei, qu->vb.buf,qu->vb.used);
- if (st
at) { adns__query_fail(qu,sta
t); return; }
+ st= check_domain_name(ads, flags,&qu->ctx,typei, qu->vb.buf,qu->vb.used);
+ if (st
) { adns__query_fail(qu,s
t); return; }
vb_new= qu->vb;
adns__vbuf_init(&qu->vb);
vb_new= qu->vb;
adns__vbuf_init(&qu->vb);
@@
-205,7
+204,7
@@
static void query_simple(adns_state ads, adns_query qu,
void adns__search_next(adns_state ads, adns_query qu, struct timeval now) {
const char *nextentry;
void adns__search_next(adns_state ads, adns_query qu, struct timeval now) {
const char *nextentry;
- adns_status st
at
;
+ adns_status st;
if (qu->search_doneabs<0) {
nextentry= 0;
if (qu->search_doneabs<0) {
nextentry= 0;
@@
-214,7
+213,7
@@
void adns__search_next(adns_state ads, adns_query qu, struct timeval now) {
if (qu->search_pos >= ads->nsearchlist) {
if (qu->search_doneabs) {
qu->search_vb.used= qu->search_origlen;
if (qu->search_pos >= ads->nsearchlist) {
if (qu->search_doneabs) {
qu->search_vb.used= qu->search_origlen;
- st
at
= adns_s_nxdomain; goto x_fail;
+ st= adns_s_nxdomain; goto x_fail;
} else {
nextentry= 0;
qu->search_doneabs= 1;
} else {
nextentry= 0;
qu->search_doneabs= 1;
@@
-239,9
+238,9
@@
void adns__search_next(adns_state ads, adns_query qu, struct timeval now) {
return;
x_nomemory:
return;
x_nomemory:
- st
at
= adns_s_nomemory;
+ st= adns_s_nomemory;
x_fail:
x_fail:
- adns__query_fail(qu,st
at
);
+ adns__query_fail(qu,st);
}
static int save_owner(adns_query qu, const char *owner, int ol) {
}
static int save_owner(adns_query qu, const char *owner, int ol) {
@@
-267,7
+266,7
@@
int adns_submit(adns_state ads,
void *context,
adns_query *query_r) {
int r, ol, ndots;
void *context,
adns_query *query_r) {
int r, ol, ndots;
- adns_status st
at
;
+ adns_status st;
const typeinfo *typei;
struct timeval now;
adns_query qu;
const typeinfo *typei;
struct timeval now;
adns_query qu;
@@
-289,8
+288,8
@@
int adns_submit(adns_state ads,
*query_r= qu;
ol= strlen(owner);
*query_r= qu;
ol= strlen(owner);
- if (!ol) { st
at
= adns_s_querydomaininvalid; goto x_adnsfail; }
- if (ol>DNS_MAXDOMAIN+1) { st
at
= adns_s_querydomaintoolong; goto x_adnsfail; }
+ if (!ol) { st= adns_s_querydomaininvalid; goto x_adnsfail; }
+ if (ol>DNS_MAXDOMAIN+1) { st= adns_s_querydomaintoolong; goto x_adnsfail; }
if (ol>=1 && owner[ol-1]=='.' && (ol<2 || owner[ol-2]!='\\')) {
flags &= ~adns_qf_search;
if (ol>=1 && owner[ol-1]=='.' && (ol<2 || owner[ol-2]!='\\')) {
flags &= ~adns_qf_search;
@@
-300,7
+299,7
@@
int adns_submit(adns_state ads,
if (flags & adns_qf_search) {
r= adns__vbuf_append(&qu->search_vb,owner,ol);
if (flags & adns_qf_search) {
r= adns__vbuf_append(&qu->search_vb,owner,ol);
- if (!r) { st
at
= adns_s_nomemory; goto x_adnsfail; }
+ if (!r) { st= adns_s_nomemory; goto x_adnsfail; }
for (ndots=0, p=owner; (p= strchr(p,'.')); p++, ndots++);
qu->search_doneabs= (ndots >= ads->searchndots) ? -1 : 0;
for (ndots=0, p=owner; (p= strchr(p,'.')); p++, ndots++);
qu->search_doneabs= (ndots >= ads->searchndots) ? -1 : 0;
@@
-308,7
+307,7
@@
int adns_submit(adns_state ads,
adns__search_next(ads,qu,now);
} else {
if (flags & adns_qf_owner) {
adns__search_next(ads,qu,now);
} else {
if (flags & adns_qf_owner) {
- if (!save_owner(qu,owner,ol)) { st
at
= adns_s_nomemory; goto x_adnsfail; }
+ if (!save_owner(qu,owner,ol)) { st= adns_s_nomemory; goto x_adnsfail; }
}
query_simple(ads,qu, owner,ol, typei,flags, now);
}
}
query_simple(ads,qu, owner,ol, typei,flags, now);
}
@@
-317,7
+316,7
@@
int adns_submit(adns_state ads,
return 0;
x_adnsfail:
return 0;
x_adnsfail:
- adns__query_fail(qu,st
at
);
+ adns__query_fail(qu,st);
adns__returning(ads,qu);
return 0;
adns__returning(ads,qu);
return 0;
@@
-410,7
+409,7
@@
void *adns__alloc_preserved(adns_query qu, size_t sz) {
return rv;
}
return rv;
}
-static allocnode *alloc_info(adns_query qu, void *p, size_t *sz_r) {
+static allocnode *alloc_
_
info(adns_query qu, void *p, size_t *sz_r) {
allocnode *an;
if (!p || p == qu) { *sz_r= 0; return 0; }
allocnode *an;
if (!p || p == qu) { *sz_r= 0; return 0; }
@@
-421,13
+420,14
@@
static allocnode *alloc_info(adns_query qu, void *p, size_t *sz_r) {
void adns__free_interim(adns_query qu, void *p) {
size_t sz;
void adns__free_interim(adns_query qu, void *p) {
size_t sz;
- allocnode *an= alloc_info(qu, p, &sz);
+ allocnode *an= alloc_
_
info(qu, p, &sz);
if (!an) return;
assert(!qu->final_allocspace);
LIST_UNLINK(qu->allocations, an);
free(an);
qu->interim_allocd -= sz;
if (!an) return;
assert(!qu->final_allocspace);
LIST_UNLINK(qu->allocations, an);
free(an);
qu->interim_allocd -= sz;
+ assert(!qu->interim_allocd >= 0);
}
void *adns__alloc_mine(adns_query qu, size_t sz) {
}
void *adns__alloc_mine(adns_query qu, size_t sz) {
@@
-436,7
+436,7
@@
void *adns__alloc_mine(adns_query qu, size_t sz) {
void adns__transfer_interim(adns_query from, adns_query to, void *block) {
size_t sz;
void adns__transfer_interim(adns_query from, adns_query to, void *block) {
size_t sz;
- allocnode *an= alloc_info(from, block, &sz);
+ allocnode *an= alloc_
_
info(from, block, &sz);
if (!an) return;
if (!an) return;
@@
-641,9
+641,9
@@
void adns__query_done(adns_query qu) {
}
}
}
}
-void adns__query_fail(adns_query qu, adns_status st
at
) {
+void adns__query_fail(adns_query qu, adns_status st) {
adns__reset_preserved(qu);
adns__reset_preserved(qu);
- qu->answer->status= st
at
;
+ qu->answer->status= st;
adns__query_done(qu);
}
adns__query_done(qu);
}