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

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


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.

Thanks,
-Ryan