# rgy_to_txt.awk # # Awk script for mapping cs_registry --> code_set_registry.txt. # Invoke as: # awk -f rgy_to_txt.awk cs_registry | \ # sed -e 's/[ ][ ]*/ /' > code_set_registry.txt # (The sed script merely beautifies the awk output.) # # See OSF-RFC 40.1. # Here's the picture of relationships among the things involved: # # cs_registry # | # | awk -f rgy_to_txt.awk | sed # | # V # code_set_registry.txt # | # | Vendor customizes NONE's. # | # V # code_set_registry.txt # | # | csrc # | # V # code_set_registry.db # | # | dce_cs_loc_to_rgy() # | dce_cs_rgy_to_loc() # | # V # application code # # This is a *rudimentary* tool, not very robust: it *assumes* cs_registry is # correctly formatted, and the output file must be inspected for "goodness" # (e.g., acceptable line-length on a given system). This isn't unreasonable, # since the output file must be edited by hand (or a vendor-customized tool) # in any case, to replace the NONE's with system-specific names. # Ignore comment lines (blank lines and lines beginning with "#" or whitespace). $0 ~ /^$/ {continue} $0 ~ /^[# ]/ {continue} # Map non-comment lines. These are the only allowed non-comment lines. $0 ~ /^start/ {print "start" continue} $0 ~ /^Short Description/ {sub("Short Description"," ") print "description ",$0 print "loc_name ","NONE" continue} $0 ~ /^Registered Value/ {sub("Registered Value"," ") print "rgy_value ",$0 continue} $0 ~ /^Character Set ID\(s\)/ {sub("Character Set ID\\(s\\)"," ") print "char_values ",$0 continue} $0 ~ /^Max Bytes per Character/ {sub("Max Bytes per Character"," ") print "max_bytes ",$0 continue} $0 ~ /^Ordering Information/ {continue} $0 ~ /^Comments/ {continue} $0 ~ /^end/ {print "end\n" continue} # All lines not matched by any of the above are ignored, by awk default. # In a well-formed cs_registry file, there shouldn't be any such lines.