Fixed global variable declaration
added params for custom functions.

Signed-off-by: Johny Jose <johny@playlyfe.com>
all parameters are returned on error if any additional data is present.

Signed-off-by: Johny Jose <johny@playlyfe.com>