#!/bin/sh
: ; exec klone $0 "$@"
; The above line finds the klone executable in the $PATH
;;Skeleton of a typical klone script

(setq args (getopts "USAGE: %0 [options] 
extracts URL anchors from an html document on stdin"
    ("-v" () verbose "verbose operation")
    ("-debug" () enter-debugger-on-error "enter klone debugger on error")
    ("-stackdump" () stackdump-on-error "verbose stack dump on error")
))

(if enter-debugger-on-error (kdb t))
(if stackdump-on-error (stack-dump-on-error t))

(defun main (&aux
  )
  (setq re (regcomp 
      "<[ \t\n]*[aA][ \t\n]+[hH][rR][eE][fF][ \t\n]*=[ \t\n]*\"([^\"]+)\"[ \t\n]*>"))
  (setq offset 0)
  (setq buffer (String *standard-input*))
  (while (regexec re buffer offset)
    (print-format "%n0\n" (regsub re 1))
    (setq offset (get (get re 1) 1))
  )
)

(main)

;;; EMACS MODES
;;; Local Variables: ***
;;; mode:lisp ***
;;; End: ***

