Axis2/C Coding Convention

1 Naming Conventions

Namespace validation is done using axis2_ prefix. Underscore should be used to separate individuals words in identifiers.

All identifiers should be meaningful and abbreviations must be avoided whenever possible.

1.1 Variables

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_

e.g.

int count = 0;
char *prefix = NULL;

1.2 Functions

Function names should always start with the prefix axis2_ except it is a member of a struct.

e.g.

axis2_om_node_t * axis2_om_node_create(axis2_environment_t *environment);

1.3 Structures and User Defined Data Types

e.g.

typedef struct axis2_om_namespace {
	char *uri;
	char *prefix;
} axis2_om_namespace_t;

Note the _t suffix in the type name.

1.4 Macros

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.

e.g.

#define AXIS2_H

#define axis2_error_get_message(error) ((error)->ops->get_message())

1.5 Enumerations

e.g.

typedef enum axis2_status_codes {
	AXIS2_FAILURE = 0,
	AXIS2_SUCCESS
} axis2_status_codes_t;

2 Indentation

Indentation rules are defined in terms of GNU indent options:

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

3 Comments

Doxygen style comments should be used to help auto generate API documentation. All structs as well as functions including parameters and return types should be documented.

4 Function Parameters and Return Value Conventions

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.

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.

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.

5 Include Directives

It is prefereable to include header files in following fashion:

<standard header files>
<other system headers>
"local header files"