Commit Graph

7 Commits

Author SHA1 Message Date
Andrew Bettison
27a0a6eeb5 Introduce struct __sourceloc
Replaces (const char *file, unsigned int line, const char *function) arguments
to all logging functions, simplifies malloc/free tracking code in
overlay_buffer.c and Rhizome manifest alloc/free tracking in rhizome_bundle.c.

Use __HERE__ macro instead of (__FILE__, __LINE__, __FUNCTION__) everywhere.

Special __NOWHERE__ macro is equivalent to (NULL, 0, NULL).

Declare net.c functions in new "net.h" header, so log.c doesn't have to pull
in the entire "serval.h" just to use write_str().

Facilitates progress on issue #2.
2012-08-23 12:31:07 +09:30
Andrew Bettison
3b44bb6e58 More progress on dnahelper 2012-07-19 17:59:45 +09:30
Andrew Bettison
dcf7209304 Add read_nonblock() function
Deal with platforms where EWOULDBLOCK != EAGAIN
2012-07-13 11:04:50 +09:30
Andrew Bettison
a15a9146c3 Improve toprint() and alloca_toprint() 2012-07-11 14:17:53 +09:30
Andrew Bettison
e8eab5b27e Improve diagnostics from write_all(), write_nonblock() etc.
Add toprint() function and alloca_toprint() macro.
2012-07-10 19:57:56 +09:30
Andrew Bettison
7c2090e61c Improve error reports for write_str() etc.
Now write_str(), write_nonblock(), write_all(), set_nonblock() etc. report the
file/line/function of their caller, rather than the function in net.c.  Done
using macros, similar in style to WHY() etc.
2012-07-10 18:51:41 +09:30
Andrew Bettison
86eb482ed9 Replace macros with functions
SET_NONBLOCKING(), SET_BLOCKING(), WRITE_STR() are now set_nonblock(),
set_block() and write_str() respectively, all of which log an error before
returning -1.  There are other useful methods: write_all() treats anything less
than all bytes written as an error; write_nonblock() treats EAGAIN and EINTR as
zero bytes written, and a combination: write_all_nonblock().
2012-07-10 16:33:39 +09:30