#!/bin/perl # # SYNOPSIS # @(#) Generates a hotlist file from a Netscape Bookmarks file. # # USAGE # b2h [-h] [-s] # # DESCRIPTION # A Netscape bookmarks file is split into HTML files, one per section. # Sections containing "private" in the name will be ignored. Created # files are named "hotlist.html" for the main file, "n.html" for section # files, where `n' is a number. # # By default, the file "$HOME/.netscape/bookmarks.html" will be used as # input, and the directory "$HOME/WWWHome/" will be the location of # output files. If option "-s" is given, input is read from STDIN and # output files are written to the current directory. # # OPTIONS # -s ... read from STDIN, write to the current directory. # # FILES # $HOME/.netscape/bookmarks.html ... default input file # $HOME/WWWHome/ ... default location of output files # hotlist.html ... main file # hotlist.head ... beginning of hotlist file # hotlist.tail ... end of hotlist file # # EXIT CODES $ERR_ARGS=1; # Error on arguments. $ERR_BFILE=2; # Bookmarks file not readable. $ERR_OFILE=3; # Output file not writeable. # # REVISION HISTORY # 95-11-20 Neubacher : Created this file. # 96-01-08 Neubacher : Switched to ".netscape/bookmarks.html". # # Set $opt_x variable according to options # require "getopts.pl"; if( ! &Getopts('hs') ) { print "\n"; do usage(); exit $ERR_ARGS; } # # Process -h option # if( $opt_h ) { do usage(); do help(); exit 0; } # # Process other options # $outdir = $ENV{"HOME"} . "/WWWHome/"; $infile="INFILE"; if ($opt_s) { $outdir="./"; $infile="STDIN"; } else { if (!open($infile, "<" . $ENV{"HOME"} . "/.netscape/bookmarks.html")) { print STDERR "Could not open file '" . $ENV{"HOME"} . "/.netscape/bookmarks.html" . "'!\n"; exit $ERR_BFILE; } } # # Process bookmarks file. # if (system("cp " . $outdir . "hotlist.head " . $outdir . "hotlist.html")) { print STDERR "Could not copy '%s' to '%s'!\n", $outdir . "hotlist.head", $outdir . "hotlist.html"; exit $ERR_OFILE; } if (!open(HOTOUT, ">>" . $outdir . "hotlist.html")) { print STDERR "Could not open file '%s'!\n", $outdir . "hotlist.html"; exit $ERR_OFILE; } $section=0; $nesting = 0; while (<$infile>) { if ($nesting > 0) { print SUBOUT if (!$ignore); if (/
aneubach\@geocities.com