#!/usr/local/bin/perl # # AllDJGPP # V1.0 pl 00 - 23 Aug 1997 # # Written by # Jouko Valta (jopi@x2ftp.oulu.fi) # # # Collect 00_index.txt files from djgpp/ and all it's subdirectories. # Paste them into a collection file djgpp/00allindex.txt. # This program is based on 'monthindex' because we have to create the standard # short descriptions from index files provided with DJGPP. # # # Revision History # V1.0 pl 00 - 23 Aug 1997 # # $Usage = "\ Options:\ -h show help page and exit\ -c,-nw don't update index file\ \n\n"; # ----------------------------------------------------------------------------- ## Default Filenames $FTPDIR = "/ftp-service/ftp/pub/msdos/programming"; $DJGPP = "$FTPDIR/djgpp"; $MASTER_INDEX = "00index.txt"; $TARGET = "00allindex.txt"; # $BACKUPHOME= ##cp 00index.all $BACKUPHOME/backup/00index.all $FIND = "/bin/find \. -type f -print | /bin/cut -c3-"; $SORT = "/bin/sort"; ## Defaults ## Command line options #while ($_ = $ARGV[0], /^-/) { # shift; # last if /^--$/; # if (/^-h/) { print $Usage; exit 2; } # # if (/^-/) { die "\nUnsupported argument near $_\n Stopped"; } #} print "\n"; # ----------------------------------------------------------------------------- # # Create the All DJGPP Files Index. # chdir $DJGPP; ## Title # This info has to be in 00allindex.txt file system ("/bin/cat .message 00index.txt > $TARGET"); open (foo, "$FIND | $SORT |") || die "Can't excute '$FIND | $SORT'"; open (OF, ">>$TARGET"); print "Writing to $DJGPP/$TARGET\n\n"; # Get the directory descriptions ... open (M, "<$MASTER_INDEX"); while () { if (/^\s*$/) { next; } elsif (/^Index of all/) { next; } elsif (/\s*(\S+)\/(.*)/) { # Real directory declaration. $DIRSPEC{$1} = $2; # print "\t$1:$DIRSPEC{$1}\n"; # any TABs inclusive } } close (M); # ----------------------------------------------------------------------------- $newdir = 0; line: while () { if (/^\s*$/) { next line; } # Empty line # if (/^00|\/00|00\_*index|index.html/) { next line; } # Index files elsif (/(\S+)\/([A-Za-z0-9_\-\.]+)/) { # File in any FTP directory $tmp = $1; # May contain subdir ... $file = $2; # Directory was not updated at the same time as the file (touch file). if ($tmp ne $dir) { $dir = $tmp; read_00index(); ++$newdir; } if ($newdir) { printf OF ("\n$dir/$DIRSPEC{$dir}\n"); $newdir = 0; } if ($FILESPEC{$file}) { printf OF ("$FILESPEC{$file}\n"); } else { # Create descriptions for index files. if ($file =~ /(00\_*index.txt)/) { # Original txt index files printf OF ("$1\tDJGPP $dir/ index file.\n"); next line; } else { printf "*** No description for '$dir/$file'. ***\n"; } } next line; } # This rule only handles directories where no new files exist. elsif (/^(\S+)$/) { # FTP Directory $dir = $1; read_00index(); ++$newdir; next line; } } printf OF "\n"; close OF; chmod 0664, $TARGET; print "done.\n"; # ----------------------------------------------------------------------------- sub read_00index { $FileCnt = 0; # Try all ascii index file names if (!open (M, "$dir/00index.txt") && !open (M, "$dir/00_index.txt") && !open (M, "$dir/00index") && !open (M, "$dir/00INDEX") ) { printf STDERR "Cannot read index file for '$dir'\n"; return; } while () { chop; if (/\s*(\S+)(.*)/) { $FILESPEC{$1} = $_; # Any TABs inclusive ++$FileCnt; } } close (M); print "Read file specs for '$dir'\t($FileCnt files)\n"; }