2003-03-18 04:28:03 +01:00
|
|
|
|
2007-01-09 06:41:48 +01:00
|
|
|
0. The buildbot.
|
|
|
|
|
|
|
|
http://tor-buildbot.freehaven.net:8010/
|
|
|
|
|
2005-06-11 08:07:43 +02:00
|
|
|
1. Coding conventions
|
2003-03-18 04:28:03 +01:00
|
|
|
|
2005-06-11 08:07:43 +02:00
|
|
|
1.1. Details
|
2003-10-09 04:05:13 +02:00
|
|
|
|
2005-05-17 03:38:25 +02:00
|
|
|
Use tor_malloc, tor_free, tor_snprintf, tor_strdup, and tor_gettimeofday
|
|
|
|
instead of their generic equivalents. (They always succeed or exit.)
|
2003-10-09 04:05:13 +02:00
|
|
|
|
2006-07-04 05:33:17 +02:00
|
|
|
You can get a full list of the compatibility functions that Tor provides
|
|
|
|
by looking through src/common/util.h and src/common/compat.h.
|
|
|
|
|
|
|
|
Use 'INLINE' instead of 'inline', so that we work properly on Windows.
|
2003-10-09 04:05:13 +02:00
|
|
|
|
2005-06-11 08:07:43 +02:00
|
|
|
1.2. Calling and naming conventions
|
2003-10-09 04:05:13 +02:00
|
|
|
|
2006-07-04 05:33:17 +02:00
|
|
|
Whenever possible, functions should return -1 on error and 0 on success.
|
2003-10-09 04:05:13 +02:00
|
|
|
|
|
|
|
For multi-word identifiers, use lowercase words combined with
|
|
|
|
underscores. (e.g., "multi_word_identifier"). Use ALL_CAPS for macros and
|
|
|
|
constants.
|
|
|
|
|
|
|
|
Typenames should end with "_t".
|
|
|
|
|
|
|
|
Function names should be prefixed with a module name or object name. (In
|
|
|
|
general, code to manipulate an object should be a module with the same
|
|
|
|
name as the object, so it's hard to tell which convention is used.)
|
|
|
|
|
|
|
|
Functions that do things should have imperative-verb names
|
|
|
|
(e.g. buffer_clear, buffer_resize); functions that return booleans should
|
|
|
|
have predicate names (e.g. buffer_is_empty, buffer_needs_resizing).
|
|
|
|
|
2005-06-11 08:07:43 +02:00
|
|
|
1.3. What To Optimize
|
2003-10-09 04:05:13 +02:00
|
|
|
|
|
|
|
Don't optimize anything if it's not in the critical path. Right now,
|
|
|
|
the critical path seems to be AES, logging, and the network itself.
|
|
|
|
Feel free to do your own profiling to determine otherwise.
|
|
|
|
|
2005-06-11 08:07:43 +02:00
|
|
|
1.4. Log conventions
|
2003-10-09 04:05:13 +02:00
|
|
|
|
2006-10-11 22:45:01 +02:00
|
|
|
http://wiki.noreply.org/noreply/TheOnionRouter/TorFAQ#LogLevels
|
|
|
|
|
|
|
|
No error or warning messages should be expected during normal OR or OP
|
|
|
|
operation.
|
|
|
|
|
|
|
|
If a library function is currently called such that failure always
|
|
|
|
means ERR, then the library function should log WARN and let the caller
|
|
|
|
log ERR.
|
2003-10-09 04:05:13 +02:00
|
|
|
|
2006-07-04 05:33:17 +02:00
|
|
|
[XXX Proposed convention: every message of severity INFO or higher should
|
2003-10-09 04:05:13 +02:00
|
|
|
either (A) be intelligible to end-users who don't know the Tor source; or
|
|
|
|
(B) somehow inform the end-users that they aren't expected to understand
|
|
|
|
the message (perhaps with a string like "internal error"). Option (A) is
|
|
|
|
to be preferred to option (B). -NM]
|
|
|
|
|
2005-06-11 08:07:43 +02:00
|
|
|
1.5. Doxygen
|
2004-05-07 19:03:52 +02:00
|
|
|
|
2006-07-04 05:33:17 +02:00
|
|
|
We use the 'doxygen' utility to generate documentation from our
|
|
|
|
source code. Here's how to use it:
|
2004-05-07 19:03:52 +02:00
|
|
|
|
|
|
|
1. Begin every file that should be documented with
|
|
|
|
/**
|
|
|
|
* \file filename.c
|
2005-06-16 22:32:40 +02:00
|
|
|
* \brief Short desccription of the file.
|
|
|
|
**/
|
2004-05-07 19:03:52 +02:00
|
|
|
|
|
|
|
(Doxygen will recognize any comment beginning with /** as special.)
|
|
|
|
|
|
|
|
2. Before any function, structure, #define, or variable you want to
|
|
|
|
document, add a comment of the form:
|
|
|
|
|
|
|
|
/** Describe the function's actions in imperative sentences.
|
|
|
|
*
|
|
|
|
* Use blank lines for paragraph breaks
|
|
|
|
* - and
|
|
|
|
* - hyphens
|
|
|
|
* - for
|
|
|
|
* - lists.
|
|
|
|
*
|
|
|
|
* Write <b>argument_names</b> in boldface.
|
|
|
|
*
|
|
|
|
* \code
|
|
|
|
* place_example_code();
|
|
|
|
* between_code_and_endcode_commands();
|
|
|
|
* \endcode
|
|
|
|
*/
|
|
|
|
|
|
|
|
3. Make sure to escape the characters "<", ">", "\", "%" and "#" as "\<",
|
|
|
|
"\>", "\\", "\%", and "\#".
|
|
|
|
|
|
|
|
4. To document structure members, you can use two forms:
|
|
|
|
|
|
|
|
struct foo {
|
|
|
|
/** You can put the comment before an element; */
|
|
|
|
int a;
|
2006-07-04 05:33:17 +02:00
|
|
|
int b; /**< Or use the less-than symbol to put the comment
|
|
|
|
* after the element. */
|
2004-05-07 19:03:52 +02:00
|
|
|
};
|
|
|
|
|
2005-05-17 03:38:25 +02:00
|
|
|
5. To generate documentation from the Tor source code, type:
|
|
|
|
|
|
|
|
$ doxygen -g
|
|
|
|
|
2006-07-04 05:33:17 +02:00
|
|
|
To generate a file called 'Doxyfile'. Edit that file and run
|
|
|
|
'doxygen' to generate the API documentation.
|
2005-05-17 03:38:25 +02:00
|
|
|
|
2006-07-04 05:33:17 +02:00
|
|
|
6. See the Doxygen manual for more information; this summary just
|
|
|
|
scratches the surface.
|
2004-05-07 19:03:52 +02:00
|
|
|
|