From 50f7aaef6b7742263a3212264cb746f456d55168 Mon Sep 17 00:00:00 2001 From: Niels Provos Date: Fri, 9 Sep 2005 06:56:12 +0000 Subject: [PATCH] make it compile on mac os x svn:r183 --- evbuffer.c | 2 +- event.h | 32 +++++++++++++------------ event_rpcgen.py | 36 ++++++++++++++-------------- event_tagging.c | 64 +++++++++++++++++++++++++------------------------ test/regress.c | 6 ++--- 5 files changed, 72 insertions(+), 68 deletions(-) diff --git a/evbuffer.c b/evbuffer.c index e9f7e43a..f9109c79 100644 --- a/evbuffer.c +++ b/evbuffer.c @@ -74,7 +74,7 @@ bufferevent_read_pressure_cb(struct evbuffer *buf, size_t old, size_t now, void *arg) { struct bufferevent *bufev = arg; /* - * If we are below the watermak then reschedule reading if it's + * If we are below the watermark then reschedule reading if it's * still enabled. */ if (bufev->wm_read.high == 0 || now < bufev->wm_read.high) { diff --git a/event.h b/event.h index 31bcbd16..ed478ea5 100644 --- a/event.h +++ b/event.h @@ -278,37 +278,39 @@ void evbuffer_setcb(struct evbuffer *, void (*)(struct evbuffer *, size_t, size_ void evtag_init(void); -void evtag_marshal(struct evbuffer *evbuf, uint8_t tag, const void *data, - uint16_t len); +void evtag_marshal(struct evbuffer *evbuf, u_int8_t tag, const void *data, + u_int16_t len); -void encode_int(struct evbuffer *evbuf, uint32_t number); +void encode_int(struct evbuffer *evbuf, u_int32_t number); -void evtag_marshal_int(struct evbuffer *evbuf, uint8_t tag, uint32_t integer); +void evtag_marshal_int(struct evbuffer *evbuf, u_int8_t tag, + u_int32_t integer); -void evtag_marshal_string(struct evbuffer *buf, uint8_t tag, +void evtag_marshal_string(struct evbuffer *buf, u_int8_t tag, const char *string); -void evtag_marshal_timeval(struct evbuffer *evbuf, uint8_t tag, +void evtag_marshal_timeval(struct evbuffer *evbuf, u_int8_t tag, struct timeval *tv); void evtag_test(void); -int evtag_unmarshal(struct evbuffer *src, uint8_t *ptag, struct evbuffer *dst); -int evtag_peek(struct evbuffer *evbuf, uint8_t *ptag); -int evtag_peek_length(struct evbuffer *evbuf, uint32_t *plength); -int evtag_payload_length(struct evbuffer *evbuf, uint32_t *plength); +int evtag_unmarshal(struct evbuffer *src, u_int8_t *ptag, + struct evbuffer *dst); +int evtag_peek(struct evbuffer *evbuf, u_int8_t *ptag); +int evtag_peek_length(struct evbuffer *evbuf, u_int32_t *plength); +int evtag_payload_length(struct evbuffer *evbuf, u_int32_t *plength); int evtag_consume(struct evbuffer *evbuf); -int evtag_unmarshal_int(struct evbuffer *evbuf, uint8_t need_tag, - uint32_t *pinteger); +int evtag_unmarshal_int(struct evbuffer *evbuf, u_int8_t need_tag, + u_int32_t *pinteger); -int evtag_unmarshal_fixed(struct evbuffer *src, uint8_t need_tag, void *data, +int evtag_unmarshal_fixed(struct evbuffer *src, u_int8_t need_tag, void *data, size_t len); -int evtag_unmarshal_string(struct evbuffer *evbuf, uint8_t need_tag, +int evtag_unmarshal_string(struct evbuffer *evbuf, u_int8_t need_tag, char **pstring); -int evtag_unmarshal_timeval(struct evbuffer *evbuf, uint8_t need_tag, +int evtag_unmarshal_timeval(struct evbuffer *evbuf, u_int8_t need_tag, struct timeval *ptv); #ifdef __cplusplus diff --git a/event_rpcgen.py b/event_rpcgen.py index af842994..bb57835b 100755 --- a/event_rpcgen.py +++ b/event_rpcgen.py @@ -83,7 +83,7 @@ class Struct: self.PrintIdented(file, ' ', dcl) print >>file, '' for entry in self._entries: - print >>file, ' uint8_t %s_set;' % entry.Name() + print >>file, ' u_int8_t %s_set;' % entry.Name() print >>file, '};\n' print >>file, ( @@ -96,9 +96,9 @@ class Struct: self._name, self._name) + 'int %s_complete(struct %s *);' % (self._name, self._name) ) - print >>file, ('void evtag_marshal_%s(struct evbuffer *, uint8_t, ' + print >>file, ('void evtag_marshal_%s(struct evbuffer *, u_int8_t, ' 'const struct %s *);') % ( self._name, self._name) - print >>file, ('int evtag_unmarshal_%s(struct evbuffer *, uint8_t, ' + print >>file, ('int evtag_unmarshal_%s(struct evbuffer *, u_int8_t, ' 'struct %s *);') % ( self._name, self._name) # Write a setting function of every variable @@ -199,7 +199,7 @@ class Struct: ' struct evbuffer *evbuf)\n' % ( self._name, self._name) + '{\n' - ' uint8_t tag;\n' + ' u_int8_t tag;\n' ' while (EVBUFFER_LENGTH(evbuf) > 0) {\n' ' if (evtag_peek(evbuf, &tag) == -1)\n' ' return (-1);\n' @@ -248,12 +248,12 @@ class Struct: # Complete message unmarshaling print >>file, ( 'int\n' - 'evtag_unmarshal_%s(struct evbuffer *evbuf, uint8_t need_tag, ' + 'evtag_unmarshal_%s(struct evbuffer *evbuf, u_int8_t need_tag, ' ' struct %s *msg)' ) % (self._name, self._name) print >>file, ( '{\n' - ' uint8_t tag;\n' + ' u_int8_t tag;\n' ' int res = -1;\n' '\n' ' struct evbuffer *tmp = evbuffer_new();\n' @@ -275,7 +275,7 @@ class Struct: # Complete message marshaling print >>file, ( 'void\n' - 'evtag_marshal_%s(struct evbuffer *evbuf, uint8_t tag, ' + 'evtag_marshal_%s(struct evbuffer *evbuf, u_int8_t tag, ' 'const struct %s *msg)\n' % (self._name, self._name) + '{\n' ' struct evbuffer *_buf = evbuffer_new();\n' @@ -426,7 +426,7 @@ class EntryBytes(Entry): Entry.__init__(self, type, name, tag) self._length = length - self._ctype = 'uint8_t' + self._ctype = 'u_int8_t' def GetDeclaration(self, funcname): code = [ 'int %s(struct %s *, %s **);' % ( @@ -439,7 +439,7 @@ class EntryBytes(Entry): return code def Declaration(self): - dcl = ['uint8_t %s_data[%s];' % (self._name, self._length)] + dcl = ['u_int8_t %s_data[%s];' % (self._name, self._length)] return dcl @@ -514,7 +514,7 @@ class EntryInt(Entry): # Init base class Entry.__init__(self, type, name, tag) - self._ctype = 'uint32_t' + self._ctype = 'u_int32_t' def CodeUnmarshal(self, buf, tag_name, var_name): code = ['if (evtag_unmarshal_int(%s, %s, &%s->%s_data) == -1) {' % ( @@ -531,7 +531,7 @@ class EntryInt(Entry): return code def Declaration(self): - dcl = ['uint32_t %s_data;' % self._name] + dcl = ['u_int32_t %s_data;' % self._name] return dcl @@ -745,15 +745,15 @@ class EntryVarBytes(Entry): # Init base class Entry.__init__(self, type, name, tag) - self._ctype = 'uint8_t *' + self._ctype = 'u_int8_t *' def GetDeclaration(self, funcname): - code = [ 'int %s(struct %s *, %s *, uint32_t *);' % ( + code = [ 'int %s(struct %s *, %s *, u_int32_t *);' % ( funcname, self._struct.Name(), self._ctype ) ] return code def AssignDeclaration(self, funcname): - code = [ 'int %s(struct %s *, const %s, uint32_t);' % ( + code = [ 'int %s(struct %s *, const %s, u_int32_t);' % ( funcname, self._struct.Name(), self._ctype ) ] return code @@ -761,7 +761,7 @@ class EntryVarBytes(Entry): name = self._name code = [ 'int', '%s_%s_assign(struct %s *msg, ' - 'const %s value, uint32_t len)' % ( + 'const %s value, u_int32_t len)' % ( self._struct.Name(), name, self._struct.Name(), self._ctype), '{', @@ -780,7 +780,7 @@ class EntryVarBytes(Entry): def CodeGet(self): name = self._name code = [ 'int', - '%s_%s_get(struct %s *msg, %s *value, uint32_t *plen)' % ( + '%s_%s_get(struct %s *msg, %s *value, u_int32_t *plen)' % ( self._struct.Name(), name, self._struct.Name(), self._ctype), '{', @@ -842,8 +842,8 @@ class EntryVarBytes(Entry): return code def Declaration(self): - dcl = ['uint8_t *%s_data;' % self._name, - 'uint32_t %s_length;' % self._name] + dcl = ['u_int8_t *%s_data;' % self._name, + 'u_int32_t %s_length;' % self._name] return dcl diff --git a/event_tagging.c b/event_tagging.c index c8dbac16..b923ad3c 100644 --- a/event_tagging.c +++ b/event_tagging.c @@ -49,7 +49,7 @@ #include "event.h" -int decode_int(uint32_t *pnumber, struct evbuffer *evbuf); +int decode_int(u_int32_t *pnumber, struct evbuffer *evbuf); static struct evbuffer *_buf; @@ -67,10 +67,10 @@ evtag_init() */ void -encode_int(struct evbuffer *evbuf, uint32_t number) +encode_int(struct evbuffer *evbuf, u_int32_t number) { int off = 1, nibbles = 0; - uint8_t data[5]; + u_int8_t data[5]; memset(data, 0, sizeof(data)); while (number) { @@ -99,8 +99,8 @@ encode_int(struct evbuffer *evbuf, uint32_t number) */ void -evtag_marshal(struct evbuffer *evbuf, uint8_t tag, - const void *data, uint16_t len) +evtag_marshal(struct evbuffer *evbuf, u_int8_t tag, + const void *data, u_int16_t len) { evbuffer_add(evbuf, &tag, sizeof(tag)); encode_int(evbuf, len); @@ -109,7 +109,7 @@ evtag_marshal(struct evbuffer *evbuf, uint8_t tag, /* Marshaling for integers */ void -evtag_marshal_int(struct evbuffer *evbuf, uint8_t tag, uint32_t integer) +evtag_marshal_int(struct evbuffer *evbuf, u_int8_t tag, u_int32_t integer) { evbuffer_drain(_buf, EVBUFFER_LENGTH(_buf)); encode_int(_buf, integer); @@ -120,13 +120,13 @@ evtag_marshal_int(struct evbuffer *evbuf, uint8_t tag, uint32_t integer) } void -evtag_marshal_string(struct evbuffer *buf, uint8_t tag, const char *string) +evtag_marshal_string(struct evbuffer *buf, u_int8_t tag, const char *string) { evtag_marshal(buf, tag, string, strlen(string)); } void -evtag_marshal_timeval(struct evbuffer *evbuf, uint8_t tag, struct timeval *tv) +evtag_marshal_timeval(struct evbuffer *evbuf, u_int8_t tag, struct timeval *tv) { evbuffer_drain(_buf, EVBUFFER_LENGTH(_buf)); @@ -138,10 +138,10 @@ evtag_marshal_timeval(struct evbuffer *evbuf, uint8_t tag, struct timeval *tv) } static int __inline -decode_int_internal(uint32_t *pnumber, struct evbuffer *evbuf, int dodrain) +decode_int_internal(u_int32_t *pnumber, struct evbuffer *evbuf, int dodrain) { - uint32_t number = 0; - uint8_t *data = EVBUFFER_DATA(evbuf); + u_int32_t number = 0; + u_int8_t *data = EVBUFFER_DATA(evbuf); int len = EVBUFFER_LENGTH(evbuf); int nibbles = 0, off; @@ -172,13 +172,13 @@ decode_int_internal(uint32_t *pnumber, struct evbuffer *evbuf, int dodrain) } int -decode_int(uint32_t *pnumber, struct evbuffer *evbuf) +decode_int(u_int32_t *pnumber, struct evbuffer *evbuf) { return (decode_int_internal(pnumber, evbuf, 1) == -1 ? -1 : 0); } int -evtag_peek(struct evbuffer *evbuf, uint8_t *ptag) +evtag_peek(struct evbuffer *evbuf, u_int8_t *ptag) { if (EVBUFFER_LENGTH(evbuf) < 2) return (-1); @@ -188,7 +188,7 @@ evtag_peek(struct evbuffer *evbuf, uint8_t *ptag) } int -evtag_peek_length(struct evbuffer *evbuf, uint32_t *plength) +evtag_peek_length(struct evbuffer *evbuf, u_int32_t *plength) { struct evbuffer tmp; int res; @@ -210,7 +210,7 @@ evtag_peek_length(struct evbuffer *evbuf, uint32_t *plength) } int -evtag_payload_length(struct evbuffer *evbuf, uint32_t *plength) +evtag_payload_length(struct evbuffer *evbuf, u_int32_t *plength) { struct evbuffer tmp; int res; @@ -232,7 +232,7 @@ evtag_payload_length(struct evbuffer *evbuf, uint32_t *plength) int evtag_consume(struct evbuffer *evbuf) { - uint32_t len; + u_int32_t len; evbuffer_drain(evbuf, 1); if (decode_int(&len, evbuf) == -1) return (-1); @@ -244,11 +244,11 @@ evtag_consume(struct evbuffer *evbuf) /* Reads the data type from an event buffer */ int -evtag_unmarshal(struct evbuffer *src, uint8_t *ptag, struct evbuffer *dst) +evtag_unmarshal(struct evbuffer *src, u_int8_t *ptag, struct evbuffer *dst) { - uint8_t tag; - uint16_t len; - uint32_t integer; + u_int8_t tag; + u_int16_t len; + u_int32_t integer; if (evbuffer_remove(src, &tag, sizeof(tag)) != sizeof(tag)) return (-1); @@ -271,11 +271,12 @@ evtag_unmarshal(struct evbuffer *src, uint8_t *ptag, struct evbuffer *dst) /* Marshaling for integers */ int -evtag_unmarshal_int(struct evbuffer *evbuf, uint8_t need_tag, uint32_t *pinteger) +evtag_unmarshal_int(struct evbuffer *evbuf, u_int8_t need_tag, + u_int32_t *pinteger) { - uint8_t tag; - uint16_t len; - uint32_t integer; + u_int8_t tag; + u_int16_t len; + u_int32_t integer; if (evbuffer_remove(evbuf, &tag, sizeof(tag)) != sizeof(tag) || tag != need_tag) @@ -299,10 +300,10 @@ evtag_unmarshal_int(struct evbuffer *evbuf, uint8_t need_tag, uint32_t *pinteger /* Unmarshal a fixed length tag */ int -evtag_unmarshal_fixed(struct evbuffer *src, uint8_t need_tag, void *data, +evtag_unmarshal_fixed(struct evbuffer *src, u_int8_t need_tag, void *data, size_t len) { - uint8_t tag; + u_int8_t tag; /* Initialize this event buffer so that we can read into it */ evbuffer_drain(_buf, EVBUFFER_LENGTH(_buf)); @@ -319,9 +320,10 @@ evtag_unmarshal_fixed(struct evbuffer *src, uint8_t need_tag, void *data, } int -evtag_unmarshal_string(struct evbuffer *evbuf, uint8_t need_tag, char **pstring) +evtag_unmarshal_string(struct evbuffer *evbuf, u_int8_t need_tag, + char **pstring) { - uint8_t tag; + u_int8_t tag; evbuffer_drain(_buf, EVBUFFER_LENGTH(_buf)); @@ -337,11 +339,11 @@ evtag_unmarshal_string(struct evbuffer *evbuf, uint8_t need_tag, char **pstring) } int -evtag_unmarshal_timeval(struct evbuffer *evbuf, uint8_t need_tag, +evtag_unmarshal_timeval(struct evbuffer *evbuf, u_int8_t need_tag, struct timeval *ptv) { - uint8_t tag; - uint32_t integer; + u_int8_t tag; + u_int32_t integer; evbuffer_drain(_buf, EVBUFFER_LENGTH(_buf)); if (evtag_unmarshal(evbuf, &tag, _buf) == -1 || tag != need_tag) diff --git a/test/regress.c b/test/regress.c index ec6a033c..519a7a02 100644 --- a/test/regress.c +++ b/test/regress.c @@ -639,7 +639,7 @@ test_multiple_events_for_same_fd(void) cleanup_test(); } -int decode_int(uint32_t *pnumber, struct evbuffer *evbuf); +int decode_int(u_int32_t *pnumber, struct evbuffer *evbuf); #define TEST_MAX_INT 6 @@ -647,10 +647,10 @@ void evtag_int_test(void) { struct evbuffer *tmp = evbuffer_new(); - uint32_t integers[TEST_MAX_INT] = { + u_int32_t integers[TEST_MAX_INT] = { 0xaf0, 0x1000, 0x1, 0xdeadbeef, 0x00, 0xbef000 }; - uint32_t integer; + u_int32_t integer; int i; for (i = 0; i < TEST_MAX_INT; i++) {