urlview patches
diff --git a/system.urlview b/system.urlview
new file mode 100644
--- /dev/null
+++ b/system.urlview
@@ -0,0 +1,10 @@
+#
+# Sample urlview(1) configuration file
+#
+
+# regular expression to use to match URLs
+REGEXP (((http|https|ftp|gopher)|mailto):(//)?[^ <>"\t]*|www\.[-a-z0-9.]+)[^ .,;\t<">\):]
+
+# command to invoke for selected URL
+COMMAND /etc/urlview/url_handler.sh
+
diff --git a/url_handler.sh.fink b/url_handler.sh.fink
new file mode 100644
--- /dev/null
+++ b/url_handler.sh.fink
@@ -0,0 +1,120 @@
+#! /bin/bash
+
+# Copyright (c) 1998 Martin Schulze
+# Slightly modified by Luis Francisco Gonzalez
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+###########################################################################
+# Configurable section
+###########################################################################
+#
+# Any entry in the lists of programs that urlview handler will try out will
+# be made of /path/to/program + ':' + TAG where TAG is one of
+# XW: XWindows program
+# XT: Launch with an xterm if possible or as VT if not
+# VT: Launch in the same terminal
+
+# The lists of programs to be executed are
+https_prgs="/usr/X11R6/bin/netscape:XW /usr/bin/lynx:XT"
+http_prgs="/usr/bin/lynx:XT /usr/X11R6/bin/netscape:XW"
+mailto_prgs="/usr/bin/mutt:VT /usr/bin/elm:VT /usr/bin/pine:VT /usr/bin/mail:VT"
+gopher_prgs="/usr/bin/lynx:XT /usr/bin/gopher:XT"
+ftp_prgs="/usr/bin/lynx:XT /usr/bin/ncftp:XT"
+
+# Program used as an xterm (if it doesn't support -T you'll need to change
+# the command line in getprg)
+XTERM=/usr/X11R6/bin/xterm
+
+
+###########################################################################
+# Change bellow this at your own risk
+###########################################################################
+function getprg()
+{
+ local ele tag prog
+
+ for ele in $*
+ do
+ tag=${ele##*:}
+ prog=${ele%%:*}
+ if [ -x $prog ]; then
+ case $tag in
+ XW)
+ [ -n "$DISPLAY" ] && echo "X:$prog" && return 0
+ ;;
+ XT)
+ [ -n "$DISPLAY" ] && [ -x "$XTERM" ] && \
+ echo "X:$XTERM -e $prog" && return 0
+ echo "$prog" && return 0
+ ;;
+ VT)
+ echo "$prog" && return 0
+ ;;
+ esac
+ fi
+ done
+}
+
+url="$1"; shift
+
+type="${url%%:*}"
+
+if [ "$url" = "$type" ]; then
+ type="${url%%.*}"
+ case "$type" in
+ www|web)
+ type=http
+ ;;
+ esac
+ url="$type://$url"
+fi
+
+case $type in
+https)
+ prg=`getprg $https_prgs`
+ ;;
+http)
+ prg=`getprg $http_prgs`
+ ;;
+ftp)
+ prg=`getprg $ftp_prgs`
+ ;;
+mailto)
+ prg=`getprg $mailto_prgs`
+ url="${url#mailto:}"
+ ;;
+gopher)
+ prg=`getprg $gopher_prgs`
+ ;;
+*)
+ echo "Unknown URL type. Please report URL and viewer to:"
+ echo "joey@debian.org."
+ /bin/echo "Press enter to continue.\c"; read x
+ exit
+ ;;
+esac
+
+if [ -n "$prg" ]; then
+ if [ "${prg%:*}" = "X" ]; then
+ ${prg#*:} "$url" 2>/dev/null &
+ else
+ $prg "$url"
+ fi
+fi
+
+
+
+
diff --git a/urlview.c b/urlview.c
--- a/urlview.c
+++ b/urlview.c
@@ -48,7 +48,7 @@
#define DEFAULT_REGEXP "(((https?|ftp|gopher)://|(mailto|file|news):)[^' \t<>\"]+|(www|web|w3)\\.[-a-z0-9.]+)[^' \t.,;<>\"\\):]"
#define DEFAULT_COMMAND "url_handler.sh %s"
-#define SYSTEM_INITFILE "/etc/urlview.conf"
+#define SYSTEM_INITFILE "@PREFIX@/etc/urlview.conf"
#define OFFSET 2
#define PAGELEN (LINES - 1 - OFFSET)
@@ -506,10 +506,11 @@
free (url[current]);
url[current] = strdup (buf);
endwin ();
+ quote (scratch, sizeof (scratch), url[current]);
if (strstr (command, "%s"))
- snprintf (buf, sizeof (buf), command, quote (scratch, sizeof (scratch), url[current]));
+ snprintf (buf, sizeof (buf), command, scratch);
else
- snprintf (buf, sizeof (buf), "%s %s", command, quote (scratch, sizeof (scratch), url[current]));
+ snprintf (buf, sizeof (buf), "%s %s", command, scratch);
printf ("Executing: %s...\n", buf);
fflush (stdout);
system (buf);
diff --git a/urlview.html b/urlview.html
new file mode 100644
--- /dev/null
+++ b/urlview.html
@@ -0,0 +1,90 @@
+
+urlview - URL extractor/launcher
+
+
+
+urlview - URL extractor/launcher
+
+
+
+urlview <filename> [ <filename> ... ]
+
+
+
+urlview is a screen oriented program for extracting URLs from text
+files and displaying a menu from which you may launch a command to view a
+specific item.
+
+
+
+urlview attempts to read ~/.urlview upon startup.
+If this file doesn't exist, it will try to read a system wide file
+in /etc/urlview/system.urlview. There are
+two configuration commands (order does not matter):
+REGEXP <regular expression to use for URL matching>
+
+urlview uses a regular expression to extract URLs from the specified
+text files. \r, \t, \n and \f are all converted to
+their normal printf(2) meanings. The default REGEXP is
+
+
+(((https?|ftp|gopher)://|(mailto|file|news):)[^' \t<>"]+|(www|web|w3)\.[-a-z0-9.]+)[^' \t.,;<>"\):]
+
+
+
+COMMAND <command to launch with URL>
+If the specified command contains a ``%s'', it will be subsituted
+with the URL that was requested, otherwise the URL is appended to the
+COMMAND string. The default COMMAND is
+
+ url_handler.sh '%s'
+
+
+another possibility would be
+
+ Netscape -remote 'openURL(%s)'
+
+
+NOTE: you should always put single quotes ('') around usage of
+``%s'' and never let the REGEXP to match any string containing
+a single quote (note [⁁'...]
in the default REGEXP)
+to avoid characters in the selected URL from being interpreted
+by your shell. For example, I could put the following URL in my email
+messages:
+
+ X-Nasty-Url: http://www.`program_to_execute_as_you`.com
+
+
+If you pass this URL to your shell, it could have nasty consequences.
+
+
+
+
+
+- /etc/urlview/system.urlview
system-wide urlview configuration file
+- ~/.urlview
urlview configuration file
+
+
+
+
+
+regcomp(3)
+
+
+
+Michael Elkins <me@cs.hmc.edu>.
+Modified for Debian by Luis Francisco Gonzalez <luisgh@debian.org>.
+Modified for SuSE by Dr. Werner Fink <werner@suse.de> and Stepan Kasal <kasal@suse.cz>.
+
+Next
+Previous
+Contents
+
+
diff --git a/urlview.man b/urlview.man
--- a/urlview.man
+++ b/urlview.man
@@ -34,7 +34,7 @@
upon startup. If this file
doesn't exist, it will try to read a system wide file
in
-.IR /etc/urlview.conf .
+.IR @PREFIX@/etc/urlview.conf .
There are two configuration commands (order does not matter):
.TP
REGEXP \fIregexp\fP
@@ -76,7 +76,7 @@
explicitly excludes single quotes.)
.SH FILES
.PP
-.IP "/etc/urlview.conf"
+.IP "@PREFIX@/etc/urlview.conf"
system-wide urlview configuration file
.IP "~/.urlview"
urlview configuration file
diff --git a/urlview.sgml b/urlview.sgml
--- a/urlview.sgml
+++ b/urlview.sgml
@@ -20,7 +20,7 @@
˜/.urlview upon startup.
If this file doesn't exist, it will try to read a system wide file
-in /etc/urlview.conf. There are
+in /@PREFIX@etc/urlview.conf. There are
two configuration commands (order does not matter):
REGEXP <regular expression to use for URL matching>
@@ -62,7 +62,7 @@
-/etc/urlview.conf
+@PREFIX@/etc/urlview.conf
system-wide urlview configuration file