added files
[bcm963xx.git] / userapps / opensource / net-snmp / CodingStyle
1 The discussion about coding style on the net-snmp-coders mailing list
2 can be found at the following web address:
3   http://www.geocrawler.com/mail/thread.php3?subject=design+proposal+-+coding+style&list=6845
4
5 ----------------------------------------------------------------------
6 Indentation: 
7
8 We've adopted the following indent style:
9
10    indent -orig -nbc -bap -nut -nfca -T netsnmp_mib_handler -T netsnmp_handler_registration -T netsnmp_delegated_cache -T netsnmp_mib_handler_methods -T netsnmp_old_api_info -T netsnmp_old_api_cache -T netsnmp_set_info -T netsnmp_request_info -T netsnmp_set_info -T netsnmp_tree_cache -T netsnmp_agent_request_info -T netsnmp_cachemap -T netsnmp_agent_session -T netsnmp_array_group_item -T netsnmp_array_group -T netsnmp_table_array_callbacks -T netsnmp_table_row -T netsnmp_table_data -T netsnmp_table_data_set_storage -T netsnmp_table_data_set -T netsnmp_column_info -T netsnmp_table_registration_info -T netsnmp_table_request_info -T netsnmp_iterator_info -T netsnmp_data_list -T netsnmp_oid_array_header -T netsnmp_oid_array_header_wrapper -T netsnmp_oid_stash_node -T netsnmp_pdu -T netsnmp_request_list -T netsnmp_callback_pass -T netsnmp_callback_info -T netsnmp_transport -T netsnmp_transport_list -T netsnmp_tdomain
11
12 [wow, what an annoying list!  The above -T list can be (re)generated by
13 running:
14   perl -n -e 'print "-T $1 " if (/}\s*(netsnmp_\w+)\s*;/);' */*.h
15 in the include/net-snmp directory]
16
17 If possible, please run all new code submitted to the project through
18 the above command.  However, if sending a patch, please do *not* send
19 a patch that reformats the entire file.  Just the new sections of code
20 should be in the above style to make it easier for us to dissect what
21 you did in your patch.
22
23 Briefly, here's a description of the style:
24
25         Blank lines:
26                 after procedures
27                 not (forced) after blocks of declarations or block comments
28                 multiple declarations not split onto separate lines
29
30         Comments:
31                 Block comments indented 4 spaces from surrounding code
32                 Start/End on separate lines
33                 Solid '*' on the left of block comments
34                 "One-line" comments start in column 33
35
36         Bracing/Indent/etc:
37                 K&R-style bracing (including "cuddle-else")
38                 'case' statements in line with 'switch'
39                 No space between procedure name and opening parenthesis
40                 variable declarations lined up, and start in column 16
41                 Procedure return type on a separate line to the procedure name
42                 Four character basic and continuation line indent
43                 No tabs used in the file, always use 8 spaces instead.
44                 Continuation paramters lined up with opening parenthesis
45
46 ----------------------------------------------------------------------
47 Function names and Variable names:
48
49 should_be_like_this and notLikeThis
50
51 ----------------------------------------------------------------------
52 Structures:
53
54 We have decided to typedef all structures into names using the
55 following convention:
56
57 typedef struct netsnmp_wombat_s {
58   int something_cool;
59 } netsnmp_wombat;
60
61 The important things to note here are that the struct name ends in a
62 "_s", the typedef name doesn't end in "_t", and the typedef is not to a
63 pointer and everything begins with "netsnmp_".
64