OSSEC Coding Style Guide
Name |
OSSEC Style Guide |
Editor |
|
State |
Draft |
Origin |
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119 1.
The OSSEC Style Guide is meant to provide framework and guide of formating code contributor to OSSEC. The overall goals are:
Maximize Readability of code in OSSEC;
Reduction in the number of bugs by removing ambiguity in code and logic flow;
Be as minimally invasive as possible while achieving the stated goals;
Trust the contributor.
Artistic Style should be used to format the source code.
Every code style should be achieved by a astyle command argument.
4 spaces shall be used per indentation level. –indent=spaces=4
Switch and case blocks shall be indented. –indent-switches
Preprocessor conditional statements shall be indented to the same level as the source code. –indent-preproc-cond
Every files shall end with a newline.
Every files shall have linux like line endings (\n). –lineend=linux
Braces shall be placed according to the stroustrup style. –style=stroustrup
Operators shall be padded by a space. –pad-oper
Every branch of conditional statements shall be surrounded by brackets. –add-brackets
Pointer and reference operators shall be attached to the variable name. –align-pointer=name
Variables
Functions
Typedefs
Structs
“Key words for use in RFCs to Indicate Requirement Levels” - http://tools.ietf.org/html/rfc2119