# # AWK script to interpret the cmc14.h file. # BEGIN { types = "int1=I1 int2=I2 int4=I4 int8=I8 float=R4 double=R8 char=A1"; n = split(types, a); for (i=1; i<=n; i++) { split(a[i], t, "="); type[t[1]] = t[2] } offset = 0 #for (i in type) printf "# type[%s]=%s\n", i, type[i] } END { print "#binreclen=" offset for (i=1; i<=iswap; i++) print "%#", swap[i] } /^typedef/ { scan=1; next } /[\/][*]--*[*][\/] *$/ { if(scan>0) scan=2; next } /^[}]/ { if(scan>=1) exit; next } { if (scan != 1) next dbtype = type[$1] # Type of data otype = dbtype # Keep original data type sub(";", "", $2); ip = index($2, "["); if (ip>0) { ir = index($2, "]"); dbname = substr($2, 1, ip-1); dbtype = substr(dbtype,1,1) substr($2, ip+1, ir-ip-1); } else dbname = $2 if (substr(dbtype, 1, 1) != "A") { len = substr(dbtype, 2)+0; if (len>1) swap[++iswap] = sprintf("swap%d((%s*)(abin+%d),1)", len, $1, offset); } # Get the dbunit for (w=3; w<=NF; w++) { if ($w == "/*") break; } w++; if (substr($w,1,1) == "(") dbunit = substr($w, 2, length($w)-2); else dbunit = "" # Look for name while ((w<=NF) && (substr($w,1,3) != "/*=")) w++; if (substr($w,1,3) == "/*=") name = substr($w, 4); else name = dbname; #print "#...name=" name ", n=" n n = split(name, a, ","); if (n>1) dbtype = otype; # Write the definition for (i=1; i<=n; i++) { printf "\\vizSet{ out }{ %-7s }{ offset=%-3d dbtype=%-3s", a[i], offset, dbtype; if (dbunit != "") printf " dbunit=%s", dbunit; if (dbname != name){printf " dbname=%s", dbname; if(n>1) printf "[%d]", i-1} print " }"; offset += substr(dbtype, 2); } }