6 Use tor_malloc, tor_free, tor_snprintf, tor_strdup, and tor_gettimeofday
7 instead of their generic equivalents. (They always succeed or exit.)
9 Use INLINE instead of 'inline', so that we work properly on windows.
11 1.2. Calling and naming conventions
13 Whenever possible, functions should return -1 on error and and 0 on
16 For multi-word identifiers, use lowercase words combined with
17 underscores. (e.g., "multi_word_identifier"). Use ALL_CAPS for macros and
20 Typenames should end with "_t".
22 Function names should be prefixed with a module name or object name. (In
23 general, code to manipulate an object should be a module with the same
24 name as the object, so it's hard to tell which convention is used.)
26 Functions that do things should have imperative-verb names
27 (e.g. buffer_clear, buffer_resize); functions that return booleans should
28 have predicate names (e.g. buffer_is_empty, buffer_needs_resizing).
32 Don't optimize anything if it's not in the critical path. Right now,
33 the critical path seems to be AES, logging, and the network itself.
34 Feel free to do your own profiling to determine otherwise.
38 Log convention: use only these four log severities.
40 ERR is if something fatal just happened.
41 WARN if something bad happened, but we're still running. The
42 bad thing is either a bug in the code, an attack or buggy
43 protocol/implementation of the remote peer, etc. The operator should
44 examine the bad thing and try to correct it.
45 NOTICE if it's something the operator will want to know about.
46 (No error or warning messages should be expected during normal OR or OP
47 operation. I expect most people to run on -l notice eventually. If a
48 library function is currently called such that failure always means
49 ERR, then the library function should log WARN and let the caller
51 INFO means something happened (maybe bad, maybe ok), but there's nothing
52 you need to (or can) do about it.
53 DEBUG is for everything louder than INFO.
55 [XXX Proposed convention: every messages of severity INFO or higher should
56 either (A) be intelligible to end-users who don't know the Tor source; or
57 (B) somehow inform the end-users that they aren't expected to understand
58 the message (perhaps with a string like "internal error"). Option (A) is
59 to be preferred to option (B). -NM]
63 We use the 'doxygen' utility to generate documentation from our source code.
66 1. Begin every file that should be documented with
69 * \brief Short desccription of the file.
72 (Doxygen will recognize any comment beginning with /** as special.)
74 2. Before any function, structure, #define, or variable you want to
75 document, add a comment of the form:
77 /** Describe the function's actions in imperative sentences.
79 * Use blank lines for paragraph breaks
85 * Write <b>argument_names</b> in boldface.
88 * place_example_code();
89 * between_code_and_endcode_commands();
93 3. Make sure to escape the characters "<", ">", "\", "%" and "#" as "\<",
94 "\>", "\\", "\%", and "\#".
96 4. To document structure members, you can use two forms:
99 /** You can put the comment before an element; */
101 int b; /**< Or use the less-than symbol to put the comment after the element. */
104 5. To generate documentation from the Tor source code, type:
108 To generate a file called 'Doxyfile'. Edit that file and run 'doxygen' to
109 generate the API documentation.
111 6. See the Doxygen manual for more information; this summary just scratches