BEGIN { FS = " " }
NR == 1 {
dc = 0
top = "" prefix ".html"
f = top
print top
}
/MASTER INDEX/ {
lastupdate=substr($0, index($0, $2))
printf("
Index of files in the CICA\n")>top
printf("Files from CICA Archive
\n")>>top
printf("
These indexes are updated at approximate 7 days intervals. ")>>top
printf("You can use our search form if you are looking for a file.
")>>top
printf("%s
\n", lastupdate)>>top
printf("
\n")>>top
next
}
/Index of:/ {
getline
title=substr($0,index($0,$2))
next
}
/In Directory:/ {
dir=substr($0,index($0,root)+length(root)+1)
olddir=dir
next
}
/On Archive:/ {
site=$4
next
}
/Last Updated:/ {
lastupdate=substr($0,index($0,$2))
next
}
/\*\*/ {
next
}
{
if (length == 0) next
if (olddir == dir) {
dc++
if (dc != 1) printf("\n")>>f
close(f)
n=split(dir,p,"/")
d=p[1]
for (i=2; i<=n; i++) d=d "_" p[i]
f= "" prefix "_" d ".html"
printf("- %s",title) >> top
printf("
- %s
\n", 34, f, 34, dir)>>top
printf("
CICA index: %s\n", title)>f
printf("", title, site, root, dir, dir) >> f
printf("
%s\n", lastupdate)>>f
print "Creating ",f
olddir=""
}
nw=split($0,word," ")
comment=substr($0,index($0,word[3]))
printf("- %-12.12s %s %s.\n",34, site, root, dir, word[1], 34, word[1] "____________", word[2], comment)>>f
}
END {
printf("
\n")>>f
printf("
\n")>>top
printf("
Generated by Ozgur BALSOY.
\n", thisfile)>>top
}