Craftd:Coding Style

Commit Messages
Read this: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html

assert
Use of assertions is advised whenever undefined or dangerous state is encountered with internal constructions and declarations. This includes internal string constructions, thread starting, NULL pointer checks, etc.

Runtime states that come from the network or user should instead use the error handling functions and attempt to punt the client.

Code Formatting

 * Use LF endings. If you're contributing from Windows, get a text editor capable of outputting UNIX-style line endings.
 * Each indent should be four (4) spaces. No tab characters.
 * As a general rule, limit C code to 80/100-column lines.
 * Avoid incomprensible names with abbreviations, use extended names for everything.
 * Instead of pointers to void* use CDPointer, and remember to explicitly typecast to CDPointer or the other way around.
 * To state that a function didn't work well return false and set errno to the value saying what happened, DO NOT use 0 and -1 to state errors, please.
 * Put brackets on the same line separated by a space except for function definitions, like so:

Internal Documentation
Methods, structs, and unions should have Doxygen/JavaDoc style documentation.

e.g.

stdbool
Use of the C99 bool type in  is encouraged for internal boolean values within craftd. Platforms that do not define this can be worked around with Autoconf and preprocessor.

Logging
Logging is handled via a function pointer that enables runtime switching of logging between stdout and syslog. The function signature is identical to syslog(3) and all POSIX levels are supported.

Available functions
Tries logging with the CDMainServer or CDDefaultLogger
 * LOG(int priority, const char* format, ...) - The basic abstract logging function used throughout craftd.
 * DEBUG(const char* format, ...) - Debugging logging
 * ERR(const char* format, ...) - Fatal conditions

Use CDConsoleLogger
 * CLOG(int priority, const char* format, ...) - The basic abstract logging function used throughout craftd.
 * CDEBUG(const char* format, ...) - Debugging logging
 * CERR(const char* format, ...) - Fatal conditions

Use the given server and its logger
 * SLOG(CDServer* server, int priority, const char* format, ...) - The basic abstract logging function used throughout craftd.
 * SDEBUG(CDServer* server, const char* format, ...) - Debugging logging
 * SERR(CDServer* server, const char* format, ...) - Fatal conditions

Unknown State
Fail early, kick hard. Do not try to massage the data stream or recover. Use of goto is recommended, especially for breaking out of large loop and conditional chains. Free all allocated resources and close the bufferevent.