use zend_parse_parameters() instead of ZEND_NUM_ARGS()

also don't use WRONG_PARAM_COUNT, zend_parse_parameters() provides nice
and clear error messages itself
return array() instead of array(array())

and remove debug printf..
more minor fixes
use macro to check the global resource
use RETVAL instead of RETURN

if you really want that free call to free anything..
tabs 4ever
add missing free call
Merge pull request #1 from tony2001/master

Misc fixes without a major API change