#!/bin/rc if(! ~ $#* 1){ echo usage: mkconftab file >[2=1] exit 1 } file=$1 fn mkextract{ if(! ~ $#* 2){ echo usage: mkextract field file >[2=1] exit 1 } sed '/^$/d; /^#/d' $2 | awk ' BEGIN { doprint=0 } doprint && /^[^ ]/ { doprint=0 } doprint { print substr($0, 2) } $0 ~ field { doprint=1; getline; next; } ' 'field=^'$1 } fn gen{ mkextract 'struct Conf' $file } gen | awk ' BEGIN { print "Conftab conftab[] = {" } { sub(";", "", $2); print " {\"" $2 "\", &conf." $2 " }," } END { print " { 0, 0 },"; print "};" } ' echo