1*aa24f48bSBruce Evans# 2*aa24f48bSBruce Evans# awk script to convert a bdf file to C declarations in a form specialized 3*aa24f48bSBruce Evans# for the mouse cursors in syscons/scvgarndr.c. Usage: 4*aa24f48bSBruce Evans# awk -f thisfile < file.bdf < file.c 5*aa24f48bSBruce Evans# The accompanying syscons mouse cursor bdf file has specialized comments 6*aa24f48bSBruce Evans# which this script converts to details in the C declarations. 7*aa24f48bSBruce Evans# This is not a general conversion utility, but produces reasonable output 8*aa24f48bSBruce Evans# if the input is for a monospaced font of size between 9x16 and 16x16. 9*aa24f48bSBruce Evans 10*aa24f48bSBruce Evans/^COMMENT cn.*mouse/ { 11*aa24f48bSBruce Evans gsub("[(),]", "") 12*aa24f48bSBruce Evans i = index($3, "-") 13*aa24f48bSBruce Evans n = substr($3, 1, i - 1) 14*aa24f48bSBruce Evans name[n] = $4 15*aa24f48bSBruce Evans i = index($4, "e") 16*aa24f48bSBruce Evans j = index($4, "x") 17*aa24f48bSBruce Evans k = index($4, "_") 18*aa24f48bSBruce Evans width[n] = substr($4, i + 1, j - i - 1) 19*aa24f48bSBruce Evans height[n] = substr($4, j + 1, k - j - 1) 20*aa24f48bSBruce Evans baspect[n] = $6 21*aa24f48bSBruce Evans iaspect[n] = $8 22*aa24f48bSBruce Evans} 23*aa24f48bSBruce Evansstate == 0 && /^STARTCHAR/ { 24*aa24f48bSBruce Evans n = substr($2, 5) 25*aa24f48bSBruce Evans printf("static const struct mousedata %s = { {\n\t", name[n]) 26*aa24f48bSBruce Evans state = 1 27*aa24f48bSBruce Evans} 28*aa24f48bSBruce Evansstate >= 1 && state < 7 || state >= 7 + 16 && state < 7 + 16 + 7 { 29*aa24f48bSBruce Evans state++ 30*aa24f48bSBruce Evans next 31*aa24f48bSBruce Evans} 32*aa24f48bSBruce Evansstate >= 7 && state < 7 + 16 || state >= 7 + 16 + 7 && state < 7 + 16 + 7 +16 { 33*aa24f48bSBruce Evans printf("0x%s,", $1) 34*aa24f48bSBruce Evans if (state == 7 + 7 || state == 7 + 16 + 7 + 7) 35*aa24f48bSBruce Evans printf("\n\t") 36*aa24f48bSBruce Evans else if (state == 7 + 15) 37*aa24f48bSBruce Evans printf(" }, {\n\t") 38*aa24f48bSBruce Evans else if (state == 7 + 16 + 7 + 15) { 39*aa24f48bSBruce Evans printf(" },\n\t%s, %s, %s, %s, \"%s\",", 40*aa24f48bSBruce Evans width[n], height[n], baspect[n], iaspect[n], name[n]) 41*aa24f48bSBruce Evans printf("\n};\n\n") 42*aa24f48bSBruce Evans state = -1 43*aa24f48bSBruce Evans } else 44*aa24f48bSBruce Evans printf(" ") 45*aa24f48bSBruce Evans state++ 46*aa24f48bSBruce Evans next 47*aa24f48bSBruce Evans} 48