< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index  

Re: [reSIProcate] Accessing a header by name determined at runtime


Hi Ryan,

On Tue, 10 Jul 2007, Ryan Kereliuk wrote:

On 2007-07-10 at 20h34, Matthew Hodgson wrote:

I'm trying to access a header's value by name - but with a name
determined at runtime (e.g. Data headerName) rather than by a header
token (e.g. h_To).  I was assuming that ExtensionHeader could be used
for this by passing in the name of the header when constructing the
ExtensionHeader - but I just realised that it asserts that you're not
trying to define a header which already exists, and so can't be used for
dynamically accessing wellknown header types.

I appreciate this is a bit perverse & contrary to the way resip takes
pains to nicely type & parse known header types - but can anyone suggest
how I might do this?

You could turn your string into a header token first and then use
the standard interface.  Since this uses the gperf perfect hash
function, I can't imagine a cheaper way of accomplishing your goal.
Headers::getType(const char* name, int len) does this if my quick grep
through the code is to be believed.

Oops - given that I saw that Headers::getType() is used by ExtensionHeader to determine whether a specific header type already exists for a given header name, I should probably have realised that it does so by mapping to a header token :)

thanks for the assistance!

Matthew.

--
Matthew Hodgson <matthew@xxxxxxxxxxxxx>
Media & Systems Project Manager
Tel: +44 (0) 845 666 7778
http://www.mxtelecom.com