On Tue, Nov 6, 2012 at 11:28 PM, Tay Ray Chuan <rcta...@gmail.com> wrote:
> Hi, > > I'm calling evbuffer_readln(..., EVBUFFER_EOL_LF), but I have to > support 1.4 as well. Is there an equivalent invocation? > evbuffer_readline()? > I'm a little confused; looking at 1.4.14b, it appears that EVBUFFER_EOL_LF is in the source code. Maybe you mean an earlier version? evbuffer_readline() is a deprecated synonym for EVBUFFER_EOL_ANY. To read up to a LF character without EVBUFFER_EOL_LF in 1.4 or earlier, you could use EVBUFFER_DATA() and EVBUFFER_LENGTH() to get a get a view of the raw buffer's contents, and then use memchr to see if there is an LF character there, then drain bytes accordingly. (Don't try that in 2.0 -- the buffer is no longer implemented as a single big extent, so EVBUFFER_DATA() is no longer a remotely cheap operation.) > In addition, how do I check for the libevent version? I thought of > _EVENT_VERSION, but it looks like a string, so I can't do a > > #if _EVENT_VERSION >= 1.4 > ... > #endif > > straight up, so that's out. (Or could I?) _EVENT_NUMERIC_VERSION seems likelier to be closer to what you want. hth, -- Nick