generating click configs with cpp. Classifier?

Douglas S. J. De Couto decouto at lcs.mit.edu
Tue Nov 6 12:57:28 EST 2001


Hi,

I am trying to generate click configuration files using cpp, and am 
having a problem with the Classifier parameter syntax.

i have a click config that runs on several machines.  on every machine, 
several parts of that configuration are different. also, the 
configuration has all kinds of parameters that depend on header offsets 
and structure sizes.

so i have created ``header file'' that includes all these parameters in 
one central place, including documentation...

I include the file in my click config and run it through cpp.

i used to use perl, but i wasn't enough of a regexp master to get it to 
do the right thing with tokens, and i got tired of trying to make sure 
that i picked parameter names that didn't conflict with each other when 
i applied the regexps to the click config.  plus perl is big, and i also 
want this to fit on an ipaq.

Here's my problem:  I want to write this in my config file:

... -> Classifier(OFFSET_X/PATTERN_X) -> ...

where OFFSET_X and PATTERN_X are defined in my include file, e.g. as 02 
and 06.  But when I run it thrugh cpp, i get:

... -> Classifier( 02 / 06 ) -> ...

So I thought I could use the ## operator in cpp to fix this, with a 
macro like:

#define build_classifier_input(off, pat) off##/##pat

But it turns out that cpp retokenizes the result of that macro, so you 
still get the spaces around the `/'.

because cpp wants to tokenize out that `/'.  I can then run through sed 
to fix this, converting all `` / '' to ``/'', with the following line:

sed -e "s/\ \/\ /\//

But this seems kludgy.


What ideas do people have for doing these sorts of dynamic configuration 
generation?

d

-- 
Douglas S. J. De Couto    decouto at lcs.mit.edu





More information about the click mailing list