blob: d605b55094cfce06ebcf6895dde15ed4400a0cea [file] [log] [blame]
<html>
<head>
<meta http-equiv="Content-Type" content="">
<title>Axis2/C Coding Convention</title>
</head>
<body>
<h1>Axis2/C Coding Convention</h1>
<p> </p>
<h2>1 Naming Conventions </h2>
<p></p>
<p>Namespace validation is done using <strong>axis2_</strong> prefix.
Underscore should be used to separate individuals words in identifiers.</p>
<p>All identifiers should be meaningful and abbreviations must be avoided
whenever possible.</p>
<p></p>
<h3> 1.1 Variables</h3>
<p>Use meaningful nouns. Use all lower case letters for private & public variables.
Use uppercase names for constant. If it is a local variable or a member of a struct,
no need to prefix it with axis2_</p>
<p>e.g. </p>
<pre>
int count = 0;
char *prefix = NULL;
</pre>
<h3>1.2 Functions </h3>
<p>Function names should always start with the prefix axis2_ except it is a
member of a struct.</p>
<p></p>
<p>e.g. </p>
<pre>
<p>axis2_om_node_t * axis2_om_node_create(axis2_environment_t *environment);</p>
</pre>
<p></p>
<h3>1.3 Structures and User Defined Data Types </h3>
<p>e.g.</p>
<pre>
typedef struct axis2_om_namespace {
char *uri;
char *prefix;
} axis2_om_namespace_t;
</pre>
<p></p>
<p>Note the _t suffix in the type name.</p>
<p></p>
<h3>1.4 Macros</h3>
<p> </p>
<p>Macro names should be in all upper case letter, except that it is a macro
to help hide the complexity of the use of function pointers in operation
structs or is a type definition.</p>
<p>e.g.</p>
<pre>
<p>#define AXIS2_H</p>
<p>#define axis2_error_get_message(error) ((error)-&gt;ops-&gt;get_message())</p>
</pre>
<p></p>
<h3>1.5 Enumerations</h3>
<p>e.g.</p>
<pre>
typedef enum axis2_status_codes {
AXIS2_FAILURE = 0,
AXIS2_SUCCESS
} axis2_status_codes_t;
</pre>
<p></p>
<h2>2 Indentation</h2>
<p> </p>
<p>Indentation rules are defined in terms of GNU indent options:</p>
<p>indent -nbad -bap -nbc -bbo -bl -bli0 -bls -ncdb -nce -cp1 -cs -di2 -ndj
-nfc1 -nfca -hnl -i4 -ip5 -lp -pcs -nprs -psl -saf -sai -saw -nsc -nsob -ts4
-nut -nbfda </p>
<p></p>
<h2>3 Comments</h2>
<p><a href="http://www.stack.nl/~dimitri/doxygen/docblocks.html">Doxygen
style comments</a> should be used to help auto generate API documentation.
All structs as well as functions including parameters and return types should
be documented.</p>
<p></p>
<h2>4 Function Parameters and Return Value Conventions</h2>
<p>Each function should be passed a pointer to an instance of
axis2_environment_t struct as the first parameter. If the function is tightly
bound to a struct, the second parameter is a pointer to an instance of that
struct.</p>
<p>Functions returning pointers should return NULL in case of an error. The
developer should make sure to set the relavant error code in environment's
error struct.</p>
<p>Functions returning none pointer values should always return AXIS2_FAILURE
status code on error whenever possible, or some defined error value (in case
of returning a struct may be). A relavant error code must also be set in
environment's error struct.</p>
<h2>5 Include Directives</h2>
<p>It is prefereable to include header files in following fashion:</p>
<pre>
&lt;standard header files&gt;
&lt;other system headers&gt;
"local header files"
</pre>
</body>
</html>