#!/p/kd/fdc/solaris9/wermit + # # Script to build a clickable HTTP index of the Kermit FTP archive. # F. da Cruz, Columbia University, December 2006 # set flag on # debugging if flag echo \%0 | \v(timestamp) | Debugging... .title = Kermit FTP archive Web access # Title for index page .index = ~kermit/index.html.tmp # Working copy of index .final = ~kermit/index.html # Final name for index if flag .final = ~kermit/testing123.html # Different name for testing .tmp = ~/tmp/index.txt # Directory listing file .skip = 0 # Flag to skip a directory cd ~kermit # CD to Kermit tree if fail exit 1 "CD ~kermit failed" # Check directory /nobackup /recursive /output:\m(tmp) # Get directory tree listing if fail exit 1 # Check if flag echo Directory OK... fopen /read \%c \m(tmp) # Open the listing if fail exit 1 # Check fopen /write \%o \m(index) # Start the index file if fail exit 1 # Check # Write the HTML header fwrite /line \%o fwrite /line \%o fwrite /line \%o fwrite /line \%o \m(title) fwrite /line \%o - fwrite /line \%o fwrite /line \%o # Write the beginning of the contents fwrite /line \%o fwrite /line \%o

\m(title)

fwrite /line \%o
fwrite /line \%o This page created \v(timestamp) by - index.ksc fwrite /line \%o
fwrite /line \%o

fwrite /line \%o Click on any link to download a file with HTTP. fwrite /line \%o You might need to right-click and choose "save link as" or fwrite /line \%o "save target as" to prevent your browser from feeding the fwrite /line \%o file to some random helper application. The "daily" fwrite /line \%o fwrite /line \%o C-Kermit development build tarball is fwrite /line \%o HERE. For other files, fwrite /line \%o scroll down the long list or use the links just below for fwrite /line \%o quick access to the main areas. fwrite /line \%o

# Write a quick index to the main sections fwrite /line \%o [ a ]   fwrite /line \%o [ b ]   fwrite /line \%o [ c ]   fwrite /line \%o [ d ]   fwrite /line \%o [ e ]   fwrite /line \%o [ c-kermit ]   fwrite /line \%o [ archives ]   fwrite /line \%o [ binaries ]   fwrite /line \%o [ scripts ]   fwrite /line \%o [ test ]   fwrite /line \%o [ charsets ]   fwrite /line \%o [ newsgroups ] # Write the file listing fwrite /line \%o

.prev = xxx

while 1 {
    fread /line \%c line                # Read a directory listing line
    if fail break                       # Check for end of file
    .s2 := \s(line[44])                 # Get the filename
    if eq "\s(line[1:1])" "d" {         # If it's a directory....
        if flag {
            echo \m(line)
            echo line[8] = '\s(line[8:1])'
        }
        # Don't list the contents of directories that lack read access
        if \m(skip) if == 1 \findex(\m(root),\m(s2)) continue
        .skip = 0
        if eq "-" "\s(line[8:1])" {     # If no world-read permission
            .skip = 1                   # don't show this directory
        } else {
            # Also skip these specific directories...
            if equ \m(s2) public_html .skip = 1
            if equ \m(s2) old .skip = 1
            if equ \m(s2) cu .skip = 1
        }
        # If we're skipping this directory also skip all its subdirectories
        undef root
        if skip .root := \m(s2)
        if flag sho mac skip root
        continue                        # Don't list directories themselves
    } else {                            # Just popped out of a closed subdir
        if \m(skip) if != 1 \findex(\m(root),\m(s2)) .skip = 0
    }
    # If we're skipping this directory don't list this file
    if \m(skip) continue
    if not \findex(->,\m(line)) {       # Don't make links to symlinks
        .s1 := \s(line[1:43])           # 1st part of line
        .s3 := \fword(\m(s2),1,/,-)     # Top-level subdirectory
        if not eq "\m(s3)" "\m(prev)" {
            # If entering a new directory put a line and an anchor
            fwrite /line \%o 


} .prev := \m(s3) # Remember for next time .line := \m(s1)\m(s2) # Construct line with link } fwrite /line \%o \m(line) # Write the line to the index } # Done - Finish the page, close the files, install the index. fwrite /line \%o
fwrite /line \%o
fwrite /line \%o [ Top ]   - index.ksc / \v(timestamp) fwrite /line \%o fwrite /line \%o fclose \%c fclose \%o chmod 644 \m(index) rename \m(index) \m(final) if flag directory \m(final) exit 0