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

Annotation of www/support.awk, Revision 1.3

1.1       ian         1: #!/usr/bin/nawk -f
                      2:
1.3     ! ian         3: # used both by support.bld and by groups.bld, since the formats are similar
        !             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
                     11: # O Consultant
                     12: # I Ian F. Darwin
                     13: # M ian@darwinsys.com
                     14: # U http://www.darwinsys.com
                     15: # N Author of lots of kool stuff.
                     16:
                     17: # into HTML to make nice neat tables.
                     18:
                     19:
1.2       ian        20: $1 ~ /^#/ { next; }
                     21:
1.1       ian        22: $1 == "0" {
                     23:        if (FNR != 1)
                     24:                dump();
                     25:        reset();
                     26:        next;
                     27:        }
                     28:
                     29: $1 == "C" { country = substr($0, 2);
                     30:        if (country != oldCountry) {
                     31:                print "<TR><TD BGCOLOR=\"#FFFF00\" COLSPAN=6 ALIGN=CENTER><B>" country "</B>"
                     32:         }
                     33:        oldCountry = country
                     34:        next
                     35: }
                     36: $1 == "P" { prov = substr($0, 2); next }
                     37: $1 == "T" { city = substr($0, 2); next }
                     38: $1 == "A" { addr = substr($0, 2); next }
                     39: $1 == "O" { org = substr($0, 2); next }
                     40: $1 == "I" { indv = substr($0, 2); next }
                     41: $1 == "B" { phone = substr($0, 2); next }
                     42: $1 == "F" { fax = substr($0, 2); next }
                     43: $1 == "M" { email = substr($0, 2); next }
                     44: $1 == "U" { url = substr($0, 2); next }
                     45: $1 == "N" { note = substr($0, 2); next }
                     46:
                     47: # left over - must be part of note?
                     48:        {
                     49:        note = note "\n" $0
                     50:        next
                     51:        }
                     52:
                     53: function dump() {
1.3     ! ian        54:        print "<TR>"
        !            55:        print "<TD>"
        !            56:                if (indv != "")
        !            57:                        print indv "<BR>"
        !            58:                print org "<BR>" addr
1.1       ian        59:        print " <TD>" city "<BR>" prov
1.3     ! ian        60:        print " <TD>"
        !            61:                if (phone != "")
        !            62:                        print phone "<BR>"
        !            63:                print fax
1.1       ian        64:        print " <TD>"
1.3     ! ian        65:                if (email != "")
        !            66:                        print "<A HREF=\"mailto:" email "\">" email "</A>" "<BR>"
1.1       ian        67:                print "<A HREF=\"" url "\">" url "</A>"
                     68:        print " <TD>" note
                     69: }
                     70:
                     71: function reset() {
                     72:        prov = ""
                     73:        city = ""
                     74:        addr = ""
                     75:        org = ""
                     76:        indv = ""
                     77:        email = ""
                     78:        phone = ""
                     79:        fax = ""
                     80:        url = ""
                     81:        note = ""
                     82: }
                     83:
                     84: END {
                     85:        dump();         # don't forget the last guy!
                     86: }