4 http://tor-buildbot.freehaven.net:8010/
10 Use tor_malloc, tor_free, tor_snprintf, tor_strdup, and tor_gettimeofday
11 instead of their generic equivalents. (They always succeed or exit.)
13 You can get a full list of the compatibility functions that Tor provides
14 by looking through src/common/util.h and src/common/compat.h.
16 Use 'INLINE' instead of 'inline', so that we work properly on Windows.
18 1.2. Calling and naming conventions
20 Whenever possible, functions should return -1 on error and 0 on success.
22 For multi-word identifiers, use lowercase words combined with
23 underscores. (e.g., "multi_word_identifier"). Use ALL_CAPS for macros and
26 Typenames should end with "_t".
28 Function names should be prefixed with a module name or object name. (In
29 general, code to manipulate an object should be a module with the same
30 name as the object, so it's hard to tell which convention is used.)
32 Functions that do things should have imperative-verb names
33 (e.g. buffer_clear, buffer_resize); functions that return booleans should
34 have predicate names (e.g. buffer_is_empty, buffer_needs_resizing).
38 Don't optimize anything if it's not in the critical path. Right now,
39 the critical path seems to be AES, logging, and the network itself.
40 Feel free to do your own profiling to determine otherwise.
44 http://wiki.noreply.org/noreply/TheOnionRouter/TorFAQ#LogLevels
46 No error or warning messages should be expected during normal OR or OP
49 If a library function is currently called such that failure always
50 means ERR, then the library function should log WARN and let the caller
53 [XXX Proposed convention: every message of severity INFO or higher should
54 either (A) be intelligible to end-users who don't know the Tor source; or
55 (B) somehow inform the end-users that they aren't expected to understand
56 the message (perhaps with a string like "internal error"). Option (A) is
57 to be preferred to option (B). -NM]
61 We use the 'doxygen' utility to generate documentation from our
62 source code. Here's how to use it:
64 1. Begin every file that should be documented with
67 * \brief Short desccription of the file.
70 (Doxygen will recognize any comment beginning with /** as special.)
72 2. Before any function, structure, #define, or variable you want to
73 document, add a comment of the form:
75 /** Describe the function's actions in imperative sentences.
77 * Use blank lines for paragraph breaks
83 * Write <b>argument_names</b> in boldface.
86 * place_example_code();
87 * between_code_and_endcode_commands();
91 3. Make sure to escape the characters "<", ">", "\", "%" and "#" as "\<",
92 "\>", "\\", "\%", and "\#".
94 4. To document structure members, you can use two forms:
97 /** You can put the comment before an element; */
99 int b; /**< Or use the less-than symbol to put the comment
100 * after the element. */
103 5. To generate documentation from the Tor source code, type:
107 To generate a file called 'Doxyfile'. Edit that file and run
108 'doxygen' to generate the API documentation.
110 6. See the Doxygen manual for more information; this summary just
111 scratches the surface.