[BACK]Return to support.awk CVS log [TXT][DIR] Up to [local] / www

Annotation of www/support.awk, Revision 1.5

1.1       ian         1: #!/usr/bin/nawk -f
                      2:
1.4       ian         3: # used by support.bld to generate the table in support.html
1.3       ian         4:
1.1       ian         5: # convert data like this (order doesn't matter except 0 at front)
                      6: # 0
                      7: # C Canada
                      8: # P Ontario
                      9: # T Palgrave
                     10: # A R R # 1
1.4       ian        11: # Z L0N 1P0
1.1       ian        12: # O Consultant
                     13: # I Ian F. Darwin
                     14: # M ian@darwinsys.com
                     15: # U http://www.darwinsys.com
                     16: # N Author of lots of kool stuff.
                     17:
                     18: # into HTML to make nice neat tables.
                     19:
                     20:
1.2       ian        21: $1 ~ /^#/ { next; }
                     22:
1.1       ian        23: $1 == "0" {
                     24:        if (FNR != 1)
                     25:                dump();
                     26:        reset();
                     27:        next;
                     28:        }
                     29:
1.5     ! ian        30: $1 == "C" { country = substr($0, 3);
1.1       ian        31:        if (country != oldCountry) {
1.4       ian        32:                print "<TR><TD BGCOLOR=\"#FFFF00\" COLSPAN=2 ALIGN=CENTER><B>" country "</B>"
1.1       ian        33:         }
                     34:        oldCountry = country
                     35:        next
                     36: }
1.5     ! ian        37: $1 == "P" { prov = substr($0, 3); next }
        !            38: $1 == "T" { city = substr($0, 3); next }
        !            39: $1 == "A" { addr = substr($0, 3); next }
        !            40: $1 == "Z" { zip = substr($0, 3); next }
        !            41: $1 == "O" { org = substr($0, 3); next }
        !            42: $1 == "I" { indv = substr($0, 3); next }
        !            43: $1 == "B" { phone = substr($0, 3); next }
        !            44: $1 == "F" { fax = substr($0, 3); next }
        !            45: $1 == "M" { email = substr($0, 3); next }
        !            46: $1 == "U" { url = substr($0, 3); next }
        !            47: $1 == "N" { note = substr($0, 3); next }
1.1       ian        48:
                     49: # left over - must be part of note?
                     50:        {
                     51:        note = note "\n" $0
                     52:        next
                     53:        }
                     54:
                     55: function dump() {
1.3       ian        56:        print "<TR>"
                     57:        print "<TD>"
                     58:                if (indv != "")
1.4       ian        59:                        print "Name: " indv "<BR>"
                     60:                if (org != "")
                     61:                        print "Organization: " org "<BR>"
                     62:                if (addr != "")
                     63:                        print "Address: " addr "<BR>"
                     64:                if (city != "") {
                     65:                        print "City: " city
                     66:                        if (prov != "")
                     67:                                print ", " prov
                     68:                        if (zip != "")
                     69:                                print " " zip
                     70:                        print "<BR>"
                     71:                }
1.3       ian        72:                if (phone != "")
1.4       ian        73:                        print "Phone: " phone "<BR>"
                     74:                if (fax != "")
                     75:                        print "FAX: " fax "<BR>"
1.3       ian        76:                if (email != "")
1.4       ian        77:                        print "Email: <A HREF=\"mailto:" email "\">" email "</A>" "<BR>"
                     78:                if (url != "")
                     79:                        print "URL: <A HREF=\"" url "\">" url "</A>"
1.1       ian        80:        print " <TD>" note
                     81: }
                     82:
                     83: function reset() {
                     84:        prov = ""
                     85:        city = ""
                     86:        addr = ""
1.4       ian        87:        zip = ""
1.1       ian        88:        org = ""
                     89:        indv = ""
                     90:        email = ""
                     91:        phone = ""
                     92:        fax = ""
                     93:        url = ""
                     94:        note = ""
                     95: }
                     96:
                     97: END {
                     98:        dump();         # don't forget the last guy!
                     99: }