Replace direct access to channel name with accessor functions
authorTerry Wilson <twilson@digium.com>
Mon, 9 Jan 2012 22:15:50 +0000 (22:15 +0000)
committerTerry Wilson <twilson@digium.com>
Mon, 9 Jan 2012 22:15:50 +0000 (22:15 +0000)
commit04da92c3799e546fa4d84bdaeebd499fb64aea7a
tree9617b8b2d6d06f96ba27c0baefc5b93eb9e3bc5b
parent64d1b247c407de2af029392a6c32a99bf11c7ded
Replace direct access to channel name with accessor functions

There are many benefits to making the ast_channel an opaque handle, from
increasing maintainability to presenting ways to kill masquerades. This patch
kicks things off by taking things a field at a time, renaming the field to
'__do_not_use_${fieldname}' and then writing setters/getters and converting the
existing code to using them. When all fields are done, we can move ast_channel
to a C file from channel.h and lop off the '__do_not_use_'.

This patch sets up main/channel_interal_api.c to be the only file that actually
accesses the ast_channel's fields directly. The intent would be for any API
functions in channel.c to use the accessor functions. No more monkeying around
with channel internals. We should use our own APIs.

The interesting changes in this patch are the addition of
channel_internal_api.c, the moving of the AST_DATA stuff from channel.c to
channel_internal_api.c (note: the AST_DATA stuff will have to be reworked to
use accessor functions when ast_channel is really opaque), and some re-working
of the way channel iterators/callbacks are handled so as to avoid creating fake
ast_channels on the stack to pass in matching data by directly accessing fields
(since "name" is a stringfield and the fake channel doesn't init the
stringfields, you can't use the ast_channel_name_set() function). I went with
ast_channel_name(chan) for a getter, and ast_channel_name_set(chan, name) for a
setter.

The majority of the grunt-work for this change was done by writing a semantic
patch using Coccinelle ( http://coccinelle.lip6.fr/ ).

Review: https://reviewboard.asterisk.org/r/1655/

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@350223 65c4cc65-6c06-0410-ace0-fbb531ad65f3
103 files changed:
addons/chan_mobile.c
addons/chan_ooh323.c
apps/app_adsiprog.c
apps/app_alarmreceiver.c
apps/app_amd.c
apps/app_chanisavail.c
apps/app_chanspy.c
apps/app_confbridge.c
apps/app_dahdibarge.c
apps/app_dahdiras.c
apps/app_dial.c
apps/app_directed_pickup.c
apps/app_disa.c
apps/app_dumpchan.c
apps/app_externalivr.c
apps/app_fax.c
apps/app_flash.c
apps/app_followme.c
apps/app_getcpeid.c
apps/app_jack.c
apps/app_macro.c
apps/app_meetme.c
apps/app_milliwatt.c
apps/app_minivm.c
apps/app_mixmonitor.c
apps/app_page.c
apps/app_parkandannounce.c
apps/app_playback.c
apps/app_queue.c
apps/app_readexten.c
apps/app_record.c
apps/app_rpt.c
apps/app_sms.c
apps/app_softhangup.c
apps/app_stack.c
apps/app_talkdetect.c
apps/app_test.c
apps/app_voicemail.c
apps/app_waitforsilence.c
bridges/bridge_multiplexed.c
channels/chan_agent.c
channels/chan_alsa.c
channels/chan_console.c
channels/chan_dahdi.c
channels/chan_gtalk.c
channels/chan_h323.c
channels/chan_iax2.c
channels/chan_jingle.c
channels/chan_local.c
channels/chan_mgcp.c
channels/chan_misdn.c
channels/chan_nbs.c
channels/chan_oss.c
channels/chan_phone.c
channels/chan_sip.c
channels/chan_skinny.c
channels/chan_unistim.c
channels/chan_usbradio.c
channels/chan_vpb.cc
channels/console_video.c
channels/sig_analog.c
channels/sig_pri.c
channels/sig_ss7.c
funcs/func_audiohookinherit.c
funcs/func_channel.c
funcs/func_frame_trace.c
funcs/func_global.c
funcs/func_groupcount.c
funcs/func_lock.c
include/asterisk/channel.h
main/abstract_jb.c
main/aoc.c
main/app.c
main/autochan.c
main/bridging.c
main/ccss.c
main/cdr.c
main/cel.c
main/channel.c
main/channel_internal_api.c [new file with mode: 0644]
main/cli.c
main/dial.c
main/dsp.c
main/features.c
main/file.c
main/indications.c
main/manager.c
main/pbx.c
main/rtp_engine.c
main/say.c
main/udptl.c
pbx/pbx_dundi.c
pbx/pbx_lua.c
pbx/pbx_realtime.c
res/res_adsi.c
res/res_agi.c
res/res_calendar.c
res/res_fax.c
res/res_jabber.c
res/res_monitor.c
res/res_musiconhold.c
res/res_mutestream.c
res/snmp/agent.c