1 <chapter><title>Coding rules</title>
3 <sect1><title>Naming conventions</title>
5 <sect2><title>Functions</title>
8 All functions are named accordingly : module name (in lower case) + _ +
9 function name (in mixed case, <emphasis> without underscores</emphasis>).
10 For instance : <function>intf_FooFunction</function>. Static functions
11 don't need usage of the module name.
16 <sect2><title>Variables</title>
19 Hungarian notations are used, that means we have the following prefixes :
23 <listitem> <para> i_ for integers (sometimes l_ for long integers) ;
25 <listitem> <para> b_ for booleans ; </para> </listitem>
26 <listitem> <para> d_ for doubles (sometimes f_ for floats) ;
28 <listitem> <para> pf_ for function pointers ; </para> </listitem>
29 <listitem> <para> psz_ for a Pointer to a String terminated by a
32 <listitem> <para> More generally, we add a p when the variable is
33 a pointer to a type. </para> </listitem>
37 If one variable has no basic type (for instance a complex structure), don't
38 put any prefix (except p_* if it's a pointer). After one prefix, put
39 an <emphasis> explicit </emphasis> variable name <emphasis> in lower
40 case</emphasis>. If several words are required, join them with an
41 underscore (no mixed case). Examples :
46 <type> data_packet_t * </type> <varname> p_buffer; </varname>
47 </para> </listitem> <listitem> <para>
48 <type> char </type> <varname> psz_msg_date[42]; </varname>
49 </para> </listitem> <listitem> <para>
50 <type> int </type> <varname> pi_es_refcount[MAX_ES]; </varname>
51 </para> </listitem> <listitem> <para>
52 <type> void </type> <varname> (* pf_next_data_packet)( int * ); </varname>
62 <sect1><title>Code indentation</title>
64 <para>Code is indented with 4 spaces. Never use tabs in the source
65 code. If you are using Vim as your editor, you can use <command>set
66 expandtab</command>.</para>
68 <para>Please put spaces <emphasis> before and after </emphasis> operators, and
69 inside brackets. For instance :
70 <programlisting> for( i = 0; i < 12; i++, j += 42 ); </programlisting>
74 Third, leave braces alone on their lines (GNU style). For instance :
84 We write C, so use C-style comments /* ... */.