# Coding rules

## Naming conventions

### Functions

All functions are named accordingly : module name (in lower case) + _ + function name (in mixed case, without underscores). For instance : `intf_FooFunction`. Static functions don't need usage of the module name.

### Variables

Hungarian notations are used, that means we have the following prefixes :

- i_ for integers (sometimes l_ for long integers) ;

- b_ for booleans ;

- d_ for doubles (sometimes f_ for floats) ;

- pf_ for function pointers ;

- psz_ for a Pointer to a String terminated by a Zero (C-string) ;

- More generally, we add a p when the variable is a pointer to a type.

If one variable has no basic type (for instance a complex structure), don't put any prefix (except p_* if it's a pointer). After one prefix, put an explicit variable name in lower case. If several words are required, join them with an underscore (no mixed case). Examples :

- data_packet_t * `p_buffer;`

- char `psz_msg_date[42];`

- int `pi_es_refcount[MAX_ES];`

- void `(* pf_next_data_packet)( int * );`

## Code indentation

Code is indented with 4 spaces. Never use tabs in the source code. If you are using Vim as your editor, you can use `set expandtab`.

Please put spaces before and after operators, and inside brackets. For instance :

     for( i = 0; i < 12; i++, j += 42 );

Third, leave braces alone on their lines (GNU style). For instance :

    if( i_es == 42 )
    {
       p_buffer[0] = 0x12;
    }

We write C, so use C-style comments /* ... */.