NEWBIE: find out if extension exists in any context

Hi all,

I’m a total newbie in asterisk programming and have no clue whatsoever on which function goes together with any function. I’m working on my custom cdr going from cdr_odbc and i need to know if a specified extension is a local extension (i.e extension of a localy registered user)
i tried ast_exists_extension but it needs a context as a prameter.

Can anyone suggest a correct function?
Is there a reference to asterisk programming?

Thanks, Jozza