pbx: Make function and application containers take advantage of being sorted.

* Fixed "core show function" tab completion and token count checking.

* Refactored function and application container handling code to reduce
redundancy.

* Made __ast_pbx_run() return using the defines the caller should expect.
Doesn't change the returned values.  Just made use the defines.


git-svn-id: http://svn.asterisk.org/svn/asterisk/trunk@381102 f38db490-d61c-443f-a65b-d21fe96a405b