prefix {encode,decode}_tag functions with evtag to avoid collisions

svn:r587
This commit is contained in:
Niels Provos 2007-12-13 06:14:18 +00:00
parent 3b345f3e2d
commit ffd606cd6d
3 changed files with 20 additions and 19 deletions

View File

@ -23,6 +23,7 @@ Changes in current version:
o Removed obsoleted recalc code
o support for 32-bit tag numbers in rpc structures; this is wire compatible, but changes the API slightly.
o pull setters/getters out of RPC structures into a base class to which we just need to store a pointer; this reduces the memory footprint of these structures.
o prefix {encode,decode}_tag functions with evtag to avoid collisions
Changes in 1.4.0:

View File

@ -65,7 +65,7 @@
#include "log.h"
#include "mm-internal.h"
int decode_int(uint32_t *pnumber, struct evbuffer *evbuf);
int evtag_decode_int(uint32_t *pnumber, struct evbuffer *evbuf);
static struct evbuffer *_buf; /* not thread safe */
@ -117,7 +117,7 @@ encode_int(struct evbuffer *evbuf, uint32_t number)
*/
int
encode_tag(struct evbuffer *evbuf, uint32_t tag)
evtag_encode_tag(struct evbuffer *evbuf, uint32_t tag)
{
int bytes = 0;
uint8_t data[5];
@ -139,7 +139,7 @@ encode_tag(struct evbuffer *evbuf, uint32_t tag)
return (bytes);
}
int
static int
decode_tag_internal(uint32_t *ptag, struct evbuffer *evbuf, int dodrain)
{
uint32_t number = 0;
@ -171,7 +171,7 @@ decode_tag_internal(uint32_t *ptag, struct evbuffer *evbuf, int dodrain)
}
int
decode_tag(uint32_t *ptag, struct evbuffer *evbuf)
evtag_decode_tag(uint32_t *ptag, struct evbuffer *evbuf)
{
return (decode_tag_internal(ptag, evbuf, 1 /* dodrain */));
}
@ -186,7 +186,7 @@ void
evtag_marshal(struct evbuffer *evbuf, uint32_t tag,
const void *data, uint32_t len)
{
encode_tag(evbuf, tag);
evtag_encode_tag(evbuf, tag);
encode_int(evbuf, len);
evbuffer_add(evbuf, (void *)data, len);
}
@ -198,7 +198,7 @@ evtag_marshal_int(struct evbuffer *evbuf, uint32_t tag, uint32_t integer)
evbuffer_drain(_buf, EVBUFFER_LENGTH(_buf));
encode_int(_buf, integer);
encode_tag(evbuf, tag);
evtag_encode_tag(evbuf, tag);
encode_int(evbuf, EVBUFFER_LENGTH(_buf));
evbuffer_add_buffer(evbuf, _buf);
}
@ -255,7 +255,7 @@ decode_int_internal(uint32_t *pnumber, struct evbuffer *evbuf, int dodrain)
}
int
decode_int(uint32_t *pnumber, struct evbuffer *evbuf)
evtag_decode_int(uint32_t *pnumber, struct evbuffer *evbuf)
{
return (decode_int_internal(pnumber, evbuf, 1) == -1 ? -1 : 0);
}
@ -316,7 +316,7 @@ evtag_consume(struct evbuffer *evbuf)
uint32_t len;
if (decode_tag_internal(NULL, evbuf, 1 /* dodrain */) == -1)
return (-1);
if (decode_int(&len, evbuf) == -1)
if (evtag_decode_int(&len, evbuf) == -1)
return (-1);
evbuffer_drain(evbuf, len);
@ -333,7 +333,7 @@ evtag_unmarshal(struct evbuffer *src, uint32_t *ptag, struct evbuffer *dst)
if (decode_tag_internal(ptag, src, 1 /* dodrain */) == -1)
return (-1);
if (decode_int(&integer, src) == -1)
if (evtag_decode_int(&integer, src) == -1)
return (-1);
len = integer;
@ -362,7 +362,7 @@ evtag_unmarshal_int(struct evbuffer *evbuf, uint32_t need_tag,
return (-1);
if (need_tag != tag)
return (-1);
if (decode_int(&integer, evbuf) == -1)
if (evtag_decode_int(&integer, evbuf) == -1)
return (-1);
len = integer;
@ -375,7 +375,7 @@ evtag_unmarshal_int(struct evbuffer *evbuf, uint32_t need_tag,
evbuffer_drain(evbuf, len);
return (decode_int(pinteger, _buf));
return (evtag_decode_int(pinteger, _buf));
}
/* Unmarshal a fixed length tag */
@ -430,10 +430,10 @@ evtag_unmarshal_timeval(struct evbuffer *evbuf, uint32_t need_tag,
if (evtag_unmarshal(evbuf, &tag, _buf) == -1 || tag != need_tag)
return (-1);
if (decode_int(&integer, _buf) == -1)
if (evtag_decode_int(&integer, _buf) == -1)
return (-1);
ptv->tv_sec = integer;
if (decode_int(&integer, _buf) == -1)
if (evtag_decode_int(&integer, _buf) == -1)
return (-1);
ptv->tv_usec = integer;

View File

@ -1205,9 +1205,9 @@ test_multiple_events_for_same_fd(void)
cleanup_test();
}
int decode_int(uint32_t *pnumber, struct evbuffer *evbuf);
int encode_tag(struct evbuffer *evbuf, uint32_t number);
int decode_tag(uint32_t *pnumber, struct evbuffer *evbuf);
int evtag_decode_int(uint32_t *pnumber, struct evbuffer *evbuf);
int evtag_encode_tag(struct evbuffer *evbuf, uint32_t number);
int evtag_decode_tag(uint32_t *pnumber, struct evbuffer *evbuf);
static void
read_once_cb(int fd, short event, void *arg)
@ -1274,7 +1274,7 @@ evtag_int_test(void)
}
for (i = 0; i < TEST_MAX_INT; i++) {
if (decode_int(&integer, tmp) == -1) {
if (evtag_decode_int(&integer, tmp) == -1) {
fprintf(stderr, "decode %d failed", i);
exit(1);
}
@ -1350,14 +1350,14 @@ evtag_tag_encoding(void)
for (i = 0; i < TEST_MAX_INT; i++) {
int oldlen, newlen;
oldlen = EVBUFFER_LENGTH(tmp);
encode_tag(tmp, integers[i]);
evtag_encode_tag(tmp, integers[i]);
newlen = EVBUFFER_LENGTH(tmp);
fprintf(stdout, "\t\tencoded 0x%08x with %d bytes\n",
integers[i], newlen - oldlen);
}
for (i = 0; i < TEST_MAX_INT; i++) {
if (decode_tag(&integer, tmp) == -1) {
if (evtag_decode_tag(&integer, tmp) == -1) {
fprintf(stderr, "decode %d failed", i);
exit(1);
}