Merge branch '2118_mcext_enhancement'

* 2118_mcext_enhancement:
  lib/vfs/interface.c: Added checking if super->path_element is not NULL
  Use xdg-open by default in mc.ext.in if present to open files, fallback on current scheme otherwise.
  src/filemanager/ext.c: Added ability to export global variables to external programs called from mc.ext file.
  src/filemanager/ext.c: Code optimization. avoid few actions while %cd called from ext-file.
  Ticket #2118: split exec_extention() function to few functions.
This commit is contained in:
Slava Zanko 2012-05-18 13:45:14 +03:00
commit ff6d7b2b08
15 changed files with 1255 additions and 355 deletions

View File

@ -481,6 +481,10 @@ AC_SUBST(LIBS)
dnl Libraries used only when building the mc binary
AC_SUBST(MCLIBS)
EXTHELPERSDIR=${prefix}/libexec/${PACKAGE}/ext.d
AC_SUBST(EXTHELPERSDIR)
MAN_DATE="$(LC_ALL=C date "+%B %Y")"
AC_SUBST(MAN_DATE)
@ -514,6 +518,10 @@ contrib/dist/prototype
misc/Makefile
misc/skins/Makefile
misc/ext.d/Makefile
misc/ext.d/doc.sh
misc/ext.d/text.sh
misc/ext.d/web.sh
misc/macros.d/Makefile
misc/mc.ext

View File

@ -711,7 +711,7 @@ mc_chdir (const vfs_path_t * vpath)
}
super = vfs_get_super_by_vpath (vpath);
if (super != NULL)
if (super != NULL && super->path_element != NULL)
{
g_free (super->path_element->path);
super->path_element->path = g_strdup (path_element->path);

View File

@ -1,6 +1,6 @@
## Process this file with automake to create Makefile.in.
SUBDIRS = macros.d skins syntax
SUBDIRS = ext.d macros.d skins syntax
LIBFILES_OUT = mc.ext

28
misc/ext.d/Makefile.am Normal file
View File

@ -0,0 +1,28 @@
extdir = $(EXTHELPERSDIR)
SCRIPTS_IN = \
doc.sh.in \
text.sh.in \
web.sh.in
SCRIPTS_OUT = \
doc.sh \
text.sh \
web.sh
SCRIPTS_UNTOUCHED = \
archive.sh \
image.sh \
misc.sh \
package.sh \
sound.sh \
video.sh
ext_SCRIPTS = \
$(SCRIPTS_UNTOUCHED) \
$(SCRIPTS_OUT)
EXTRA_DIST = \
$(SCRIPTS_UNTOUCHED) \
$(SCRIPTS_IN)

143
misc/ext.d/archive.sh Normal file
View File

@ -0,0 +1,143 @@
#!/bin/sh
# $1 - action
# $2 - type of file
# $3 - pager
action=$1
filetype=$2
pager=$3
do_view_action() {
filetype=$1
case "${filetype}" in
gz)
gzip -dc "${MC_EXT_FILENAME}" 2>/dev/null
;;
bz2)
bzip2 -dc "${MC_EXT_FILENAME}" 2>/dev/null
;;
bzip)
bzip2 -dc "${MC_EXT_FILENAME}" 2>/dev/null
;;
lzma)
lzma -dc "${MC_EXT_FILENAME}" 2>/dev/null
;;
xz)
xz -dc "${MC_EXT_FILENAME}" 2>/dev/null
;;
tar)
tar tvvf - < "${MC_EXT_FILENAME}"
;;
tar.gz|tar.qpr)
gzip -dc "${MC_EXT_FILENAME}" 2>/dev/null | \
tar tvvf -
;;
tar.bzip)
bzip -dc "${MC_EXT_FILENAME}" 2>/dev/null | \
tar tvvf -
;;
tar.bzip2)
bzip2 -dc "${MC_EXT_FILENAME}" 2>/dev/null | \
tar tvvf -
;;
tar.lzma)
lzma -dc "${MC_EXT_FILENAME}" 2>/dev/null | \
tar tvvf -
;;
tar.xz)
xz -dc "${MC_EXT_FILENAME}" 2>/dev/null | \
tar tvvf -
;;
tar.F)
freeze -dc "${MC_EXT_FILENAME}" 2>/dev/null | \
tar tvvf -
;;
lha)
lha l "${MC_EXT_FILENAME}"
;;
arj)
unarj l "${MC_EXT_FILENAME}"
;;
cab)
cabextract -l "${MC_EXT_FILENAME}"
;;
ha)
ha lf "${MC_EXT_FILENAME}"
;;
rar)
rar v -c- "${MC_EXT_FILENAME}" 2>/dev/null || \
unrar v -c- "${MC_EXT_FILENAME}"
;;
alz)
unalz -l "${MC_EXT_FILENAME}"
;;
cpio.z|cpio.gz)
gzip -dc "${MC_EXT_FILENAME}" | \
cpio -itv 2>/dev/null
;;
cpio.xz)
xz -dc "${MC_EXT_FILENAME}" | \
cpio -itv 2>/dev/null
;;
cpio)
cpio -itv < "${MC_EXT_FILENAME}" 2>/dev/null
;;
7z)
7za l "${MC_EXT_FILENAME}" 2>/dev/null
;;
ace)
unace l "${MC_EXT_FILENAME}"
;;
arc)
arc l "${MC_EXT_FILENAME}"
;;
zip)
unzip -v "${MC_EXT_FILENAME}"
;;
zoo)
zoo l "${MC_EXT_FILENAME}"
;;
*)
;;
esac
}
do_open_action() {
filetype=$1
pager=$2
case "${filetype}" in
bzip2)
bzip2 -dc "${MC_EXT_FILENAME}" | ${pager}
;;
bzip)
bzip -dc "${MC_EXT_FILENAME}" | ${pager}
;;
gz)
gz -dc "${MC_EXT_FILENAME}" | ${pager}
;;
lzma)
lzma -dc "${MC_EXT_FILENAME}" | ${pager}
;;
xz)
xz -dc "${MC_EXT_FILENAME}" | ${pager}
;;
*)
;;
esac
}
case "${action}" in
view)
do_view_action "${filetype}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}" "${pager}"
;;
*)
;;
esac

96
misc/ext.d/doc.sh.in Normal file
View File

@ -0,0 +1,96 @@
#!/bin/sh
# $1 - action
# $2 - type of file
action=$1
filetype=$2
do_view_action() {
filetype=$1
case "${filetype}" in
ps)
ps2ascii "${MC_EXT_FILENAME}"
;;
pdf)
pdftotext "${MC_EXT_FILENAME}" -
;;
odt)
odt2txt "${MC_EXT_FILENAME}"
;;
msdoc)
antiword -t "${MC_EXT_FILENAME}" || \
catdoc -w "${MC_EXT_FILENAME}" || \
word2x -f text "${MC_EXT_FILENAME}" - || \
strings "${MC_EXT_FILENAME}"
;;
msxls)
xls2csv "${MC_EXT_FILENAME}" || \
strings "${MC_EXT_FILENAME}"
;;
dvi)
dvi2tty "${MC_EXT_FILENAME}"
;;
djvu)
djvused -e print-pure-txt "${MC_EXT_FILENAME}"
;;
*)
;;
esac
}
do_open_action() {
filetype=$1
case "${filetype}" in
ps)
(gv "${MC_EXT_FILENAME}" &)
;;
pdf)
(xpdf "${MC_EXT_FILENAME}" &)
#(acroread "${MC_EXT_FILENAME}" &)
#(ghostview "${MC_EXT_FILENAME}" &)
;;
ooffice)
(ooffice "${MC_EXT_FILENAME}" &)
;;
abw)
(abiword "${MC_EXT_FILENAME}" &)
;;
msdoc)
(abiword "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
;;
msxls)
(gnumeric "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
;;
framemaker)
fmclient -f "${MC_EXT_FILENAME}"
;;
dvi)
if [ x$DISPLAY = x ]; then
dvisvga "${MC_EXT_FILENAME}"
else
(xdvi "${MC_EXT_FILENAME}" &)
fi
;;
djvu)
djview "${MC_EXT_FILENAME}" &
;;
*)
;;
esac
}
case "${action}" in
view)
do_view_action "${filetype}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}"
;;
*)
;;
esac

55
misc/ext.d/image.sh Normal file
View File

@ -0,0 +1,55 @@
#!/bin/sh
# $1 - action
# $2 - type of file
action=$1
filetype=$2
do_view_action() {
filetype=$1
case "${filetype}" in
jpeg)
identify "${MC_EXT_FILENAME}"; test -x /usr/bin/exif && echo && exif "${MC_EXT_FILENAME}" 2>/dev/null
;;
xpm)
sxpm "${MC_EXT_FILENAME}"
;;
*)
identify "${MC_EXT_FILENAME}"
;;
esac
}
do_open_action() {
filetype=$1
case "${filetype}" in
xbm)
bitmap "${MC_EXT_FILENAME}"
;;
xcf)
(gimp "${MC_EXT_FILENAME}" &)
;;
*)
if [ "$DISPLAY" = "" ]; then
zgv "${MC_EXT_FILENAME}"
else
(gqview "${MC_EXT_FILENAME}" &)
fi
;;
esac
}
case "${action}" in
view)
do_view_action "${filetype}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}"
;;
*)
;;
esac

82
misc/ext.d/misc.sh Normal file
View File

@ -0,0 +1,82 @@
#!/bin/sh
# $1 - action
# $2 - type of file
action=$1
filetype=$2
do_view_action() {
filetype=$1
filename=$2
case "${filetype}" in
iso9660)
isoinfo -l -i "${MC_EXT_FILENAME}"
;;
cat)
/bin/cat "${MC_EXT_FILENAME}" 2>/dev/null
;;
ar)
file "${MC_EXT_FILENAME}" && nm -C "${MC_EXT_FILENAME}"
;;
so)
file "${MC_EXT_FILENAME}" && nm -C -D "${MC_EXT_FILENAME}"
;;
elf)
file "${MC_EXT_FILENAME}" && nm -C "${MC_EXT_FILENAME}"
;;
dbf)
dbview -b "${MC_EXT_FILENAME}"
;;
mo)
msgunfmt "${MC_EXT_FILENAME}" || \
cat "${MC_EXT_FILENAME}"
;;
lyx)
lyxcat "${MC_EXT_FILENAME}"
;;
torrent)
ctorrent -x "${MC_EXT_FILENAME}" 2>/dev/null
;;
*)
;;
esac
}
do_open_action() {
filetype=$1
case "${filetype}" in
imakefile)
xmkmf -a
;;
dbf)
dbview "${MC_EXT_FILENAME}"
;;
glade)
if glade-3 --version >/dev/null 2>&1; then
(glade-3 "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
else
(glade-2 "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
fi
;;
lyx)
lyx "${MC_EXT_FILENAME}"
;;
*)
;;
esac
}
case "${action}" in
view)
do_view_action "${filetype}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}"
;;
*)
;;
esac

59
misc/ext.d/package.sh Normal file
View File

@ -0,0 +1,59 @@
#!/bin/sh
# $1 - action
# $2 - type of file
action=$1
filetype=$2
do_view_action() {
filetype=$1
filename=$2
case "${filetype}" in
trpm)
rpm -qivl --scripts `basename "${MC_EXT_BASENAME}" .trpm`
;;
src.rpm|rpm)
if rpm --nosignature --version >/dev/null 2>&1; then
RPM="rpm --nosignature"
else
RPM="rpm"
fi
$RPM -qivlp --scripts "${MC_EXT_FILENAME}"
;;
deb)
dpkg-deb -I "${filename}" && echo && dpkg-deb -c "${MC_EXT_FILENAME}"
;;
debd)
dpkg -s `echo "${MC_EXT_BASENAME}" | sed 's/\([0-9a-z.-]*\).*/\1/'`
;;
deba)
apt-cache show `echo "${MC_EXT_BASENAME}" | sed 's/\([0-9a-z.-]*\).*/\1/'`
;;
*)
;;
esac
}
do_open_action() {
filetype=$1
case "${filetype}" in
*)
;;
esac
}
case "${action}" in
view)
do_view_action "${filetype}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}"
;;
*)
;;
esac

89
misc/ext.d/sound.sh Normal file
View File

@ -0,0 +1,89 @@
#!/bin/sh
# $1 - action
# $2 - type of file
action=$1
filetype=$2
do_view_action() {
filetype=$1
case "${filetype}" in
mp3)
mpg123 -vtn1 "${MC_EXT_FILENAME}" 2>&1 | \
sed -n '/^Title/,/^Comment/p;/^MPEG/,/^Audio/p'
;;
ogg)
ogginfo "${MC_EXT_SELECTED}"
;;
wma)
mplayer -quiet -slave -frames 0 -vo null -ao null -identify "${MC_EXT_FILENAME}" 2>/dev/null | \
tail +13 || file "${MC_EXT_FILENAME}"
;;
*)
;;
esac
}
do_open_action() {
filetype=$1
case "${filetype}" in
common)
if [ "$DISPLAY" = "" ]; then
play "${MC_EXT_FILENAME}"
else
(xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
fi
;;
mod)
mikmod "${MC_EXT_FILENAME}"
#tracker "${MC_EXT_FILENAME}"
;;
wav22)
vplay -s 22 "${MC_EXT_FILENAME}"
;;
mp3)
if [ "$DISPLAY" = "" ]; then
mpg123 "${MC_EXT_FILENAME}"
else
(xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
fi
;;
ogg)
if [ "$DISPLAY" = "" ]; then
ogg123 "${MC_EXT_FILENAME}"
else
(xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
fi
;;
midi)
timidity "${MC_EXT_FILENAME}"
;;
wma)
mplayer -vo null "${MC_EXT_FILENAME}"
;;
playlist)
if [ -z "$DISPLAY" ]; then
mplayer -vo null -playlist "${MC_EXT_FILENAME}"
else
(xmms -p "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
fi
;;
*)
;;
esac
}
case "${action}" in
view)
do_view_action "${filetype}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}"
;;
*)
;;
esac

133
misc/ext.d/text.sh.in Normal file
View File

@ -0,0 +1,133 @@
#!/bin/sh
# $1 - action
# $2 - type of archive
# $3 - pager
action=$1
filetype=$2
pager=$3
get_unpacker() {
filetype=$1
case "${filetype}" in
man.gz)
unpacker="gzip -dc"
;;
man.bz)
unpacker="bzip -dc"
;;
man.bz2)
unpacker="bzip2 -dc"
;;
man.lzma)
unpacker="lzma -dc"
;;
man.xz)
unpacker="xz -dc"
;;
esac
echo ${unpacker}
}
do_view_action() {
filetype=$1
pager=$2
unpacker=`get_unpacker ${filetype}`
case "${filetype}" in
man)
case "${MC_EXT_CURRENTDIR}"/"${MC_EXT_FILENAME}" in
*/log/*|*/logs/*)
cat "${MC_EXT_FILENAME}"
;;
*)
{ zsoelim "${MC_EXT_FILENAME}" 2>/dev/null || cat "${MC_EXT_FILENAME}"; } | nroff @MAN_FLAGS@ @MANDOC@
;;
esac
;;
pod)
pod2man "${MC_EXT_FILENAME}" | nroff @MAN_FLAGS@ @MANDOC@
;;
nroff.me)
nroff @MAN_FLAGS@ -me "${MC_EXT_FILENAME}"
;;
nroff.ms)
nroff @MAN_FLAGS@ -ms "${MC_EXT_FILENAME}"
;;
man.gz|man.bz|man.bz2|man.lzma|man.xz)
case "${MC_EXT_CURRENTDIR}"/"${MC_EXT_FILENAME}" in
*/log/*|*/logs/*)
${unpacker} %f
;;
*)
${unpacker} ${filename} | nroff @MAN_FLAGS@ @MANDOC@
;;
esac
;;
*)
;;
esac
}
do_open_action() {
filetype=$1
pager=$2
unpacker=`get_unpacker ${filetype}`
case "${filetype}" in
info)
info -f "${MC_EXT_FILENAME}"
;;
man)
case "${MC_EXT_CURRENTDIR}"/"${MC_EXT_FILENAME}" in
*/log/*|*/logs/*)
cat "${MC_EXT_FILENAME}"
;;
*)
{ zsoelim "${MC_EXT_FILENAME}" 2>/dev/null || cat "${MC_EXT_FILENAME}"; } | \
nroff @MAN_FLAGS@ @MANDOC@
;;
esac | ${pager}
;;
pod)
pod2man "${MC_EXT_FILENAME}" | nroff @MAN_FLAGS@ @MANDOC@ | ${pager}
;;
nroff.me)
nroff @MAN_FLAGS@ -me "${MC_EXT_FILENAME}" | ${pager}
;;
nroff.ms)
nroff @MAN_FLAGS@ -ms "${MC_EXT_FILENAME}" | ${pager}
;;
man.gz|man.bz|man.bz2|man.lzma|man.xz)
case "${MC_EXT_CURRENTDIR}"/"${MC_EXT_FILENAME}" in
*/log/*|*/logs/*)
${unpacker} "${MC_EXT_FILENAME}"
;;
*)
${unpacker} "${MC_EXT_FILENAME}" | nroff @MAN_FLAGS@ @MANDOC@
;;
esac | ${pager}
;;
chm)
which kchmviewer > /dev/null 2>&1 && (kchmviewer "${MC_EXT_FILENAME}" &) || (xchm "${MC_EXT_FILENAME}" &)
;;
*)
;;
esac
}
case "${action}" in
view)
do_view_action "${filetype}" "${pager}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}" "${pager}"
;;
*)
;;
esac

44
misc/ext.d/video.sh Normal file
View File

@ -0,0 +1,44 @@
#!/bin/sh
# $1 - action
# $2 - type of file
action=$1
filetype=$2
do_view_action() {
filetype=$1
case "${filetype}" in
*)
;;
esac
}
do_open_action() {
filetype=$1
case "${filetype}" in
ram)
(realplay "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
;;
*)
(mplayer "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
#(gtv "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
#(xanim "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
;;
esac
}
case "${action}" in
view)
do_view_action "${filetype}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}"
;;
*)
;;
esac

53
misc/ext.d/web.sh.in Normal file
View File

@ -0,0 +1,53 @@
#!/bin/sh
# $1 - action
# $2 - type of file
action=$1
filetype=$2
do_view_action() {
filetype=$1
case "${filetype}" in
html)
links -dump "${MC_EXT_FILENAME}" 2>/dev/null || \
w3m -dump "${MC_EXT_FILENAME}" 2>/dev/null || \
lynx -dump -force_html "${MC_EXT_FILENAME}"
;;
*)
;;
esac
}
do_open_action() {
filetype=$1
case "${filetype}" in
html)
(if test -n "@X11_WWW@" && test -n "$DISPLAY"; then
(@X11_WWW@ file://"${MC_EXT_CURRENTDIR}"/"${MC_EXT_BASENAME}" &) 1>&2
else
links "${MC_EXT_FILENAME}" || \
lynx -force_html "${MC_EXT_FILENAME}" || \
${PAGER:-more} "${MC_EXT_FILENAME}"
fi) 2>/dev/null
;;
*)
;;
esac
}
case "${action}" in
view)
do_view_action "${filetype}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}"
;;
*)
;;
esac

View File

@ -40,7 +40,9 @@
# command is any one-line shell command, with the following substitutions:
#
# %% -> % character
# %p -> name of the current file (without path, but pwd is its path)
# %p -> name of the current file (without path, but pwd is its path).
# Also provided to external application as MC_EXT_BASENAME
# global variable
# %f -> name of the current file. Unlike %p, if file is located on a
# non-local virtual filesystem, i.e. either tarfs or ftpfs,
# then the file will be temporarily copied into a local directory
@ -48,10 +50,18 @@
# If you don't want to get a local copy and want to get the
# virtual fs path (like /#ftp:ftp.cvut.cz/pub/hungry/xword), then
# use %d/%p instead of %f.
# Also provided to external application as MC_EXT_FILENAME
# global variable
# %d -> name of the current directory (pwd, without trailing slash)
# Also provided to external application as MC_EXT_CURRENTDIR
# global variable
# %s -> "selected files", i.e. space separated list of tagged files if any
# or name of the current file
# or name of the current file.
# Also provided to external application as MC_EXT_SELECTED
# global variable
# %t -> list of tagged files
# Also provided to external application as MC_EXT_ONLYTAGGED
# global variable
# %u -> list of tagged files (they'll be untaged after the command)
#
# (If these 6 letters are in uppercase, they refer to the other panel.
@ -115,148 +125,150 @@ regex/^\[git\]
# .tgz, .tpz, .tar.gz, .tar.z, .tar.Z, .ipk
regex/\.t([gp]?z|ar\.g?[zZ])$|\.ipk|\.gem$
Open=%cd %p/utar://
View=%view{ascii} gzip -dc %f 2>/dev/null | tar tvvf -
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar.gz
regex/\.tar\.bz$
# Open=%cd %p/utar://
View=%view{ascii} bzip -dc %f 2>/dev/null | tar tvvf -
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar.bzip
regex/\.t(ar\.bz2|bz2?|b2)$
Open=%cd %p/utar://
View=%view{ascii} bzip2 -dc %f 2>/dev/null | tar tvvf -
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar.bzip2
# .tar.lzma, .tlz
regex/\.t(ar\.lzma|lz)$
Open=%cd %p/utar://
View=%view{ascii} lzma -dc %f 2>/dev/null | tar tvvf -
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar.lzma
# .tar.xz, .txz
regex/\.t(ar\.xz|xz)$
Open=%cd %p/utar://
View=%view{ascii} xz -dc %f 2>/dev/null | tar tvvf -
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar.xz
# .tar.F - used in QNX
regex/\.tar\.F$
# Open=%cd %p/utar://
View=%view{ascii} freeze -dc %f 2>/dev/null | tar tvvf -
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar.F
# .qpr/.qpk - QNX Neutrino package installer files
regex/\.(qp[rk])$
Open=%cd %p/utar://
View=%view{ascii} gzip -dc %f 2>/dev/null | tar tvvf -
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar.qpr
# tar
regex/\.(tar|TAR)$
Open=%cd %p/utar://
View=%view{ascii} tar tvvf - < %f
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar
# lha
type/^LHa\ .*archive
Open=%cd %p/ulha://
View=%view{ascii} lha l %f
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view lha
# arj
regex/\.a(rj|[0-9][0-9])$
Open=%cd %p/uarj://
View=%view{ascii} unarj l %f
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view arj
# cab
regex/\.([cC][aA][bB])$
Open=%cd %p/ucab://
View=%view{ascii} cabextract -l %f
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view cab
# ha
regex/\.([Hh][Aa])$
Open=%cd %p/uha://
View=%view{ascii} ha lf %f
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view ha
# rar
regex/\.[rR]([aA][rR]|[0-9][0-9])$
Open=%cd %p/urar://
View=%view{ascii} rar v -c- %f
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view rar
# ALZip
regex/\.(alz|ALZ)$
Open=%cd %p/ualz://
View=%view{ascii} unalz -l %f
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view alz
# cpio
shell/.cpio.Z
Open=%cd %p/ucpio://
View=%view{ascii} gzip -dc %f | cpio -itv 2>/dev/null
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view cpio.z
shell/.cpio.xz
Open=%cd %p/ucpio://
View=%view{ascii} xz -dc %f | cpio -itv 2>/dev/null
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view cpio.xz
shell/.cpio.gz
Open=%cd %p/ucpio://
View=%view{ascii} gzip -dc %f | cpio -itv 2>/dev/null
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view cpio.gz
shell/.cpio
Open=%cd %p/ucpio://
View=%view{ascii} cpio -itv < %f 2>/dev/null
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view cpio
# 7zip archives (they are not man pages)
regex/\.(7z|7Z)$
Open=%cd %p/u7z://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view 7z
# patch
regex/\.(diff|patch)(\.bz2)$
Open=%cd %p/patchfs://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view bz2
regex/\.(diff|patch)(\.(gz|Z))$
Open=%cd %p/patchfs://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view gz
# ls-lR
regex/(^|\.)ls-?lR(\.gz|Z|bz2)$
Open=%cd %p/lslR://
# patch
regex/\.(diff|patch)(\.bz2)$
Open=%cd %p/patchfs://
View=%view{ascii} bzip2 -dc %f 2>/dev/null
# trpm
regex/\.trpm$
Open=%cd %p/trpm://
View=%view{ascii} @EXTHELPERSDIR@/package.sh view trpm
# RPM packages (SuSE uses *.spm for source packages)
regex/\.(src\.rpm|spm)$
Open=%cd %p/rpm://
View=%view{ascii} @EXTHELPERSDIR@/package.sh view src.rpm
regex/\.rpm$
Open=%cd %p/rpm://
View=%view{ascii} @EXTHELPERSDIR@/package.sh view rpm
# deb
regex/\.u?deb$
Open=%cd %p/deb://
View=%view{ascii} @EXTHELPERSDIR@/package.sh view deb
# dpkg
shell/.debd
Open=%cd %p/debd://
View=%view{ascii} @EXTHELPERSDIR@/package.sh view debd
# apt
shell/.deba
Open=%cd %p/deba://
View=%view{ascii} @EXTHELPERSDIR@/package.sh view deba
# ISO9660
regex/\.([iI][sS][oO])$
Open=%cd %p/iso9660://
View=%view{ascii} @EXTHELPERSDIR@/misc.sh view iso9660
regex/\.(diff|patch)(\.(gz|Z))$
Open=%cd %p/patchfs://
View=%view{ascii} gzip -dc %f 2>/dev/null
regex/\.(diff|patch)$
Open=%cd %p/patchfs://
View=%view{ascii} /bin/cat %f 2>/dev/null
View=%view{ascii} @EXTHELPERSDIR@/misc.sh view cat
# ar library
regex/\.s?a$
Open=%cd %p/uar://
#Open=%view{ascii} ar tv %f
View=%view{ascii} file %f && nm -C %f
# trpm
regex/\.trpm$
Open=%cd %p/trpm://
View=%view{ascii} rpm -qivl --scripts `basename %p .trpm`
# RPM packages (SuSE uses *.spm for source packages)
regex/\.(src\.rpm|spm)$
Open=%cd %p/rpm://
View=%view{ascii} if rpm --nosignature --version >/dev/null 2>&1; then RPM="rpm --nosignature" ; else RPM="rpm" ; fi ; $RPM -qivlp --scripts %f
regex/\.rpm$
Open=%cd %p/rpm://
View=%view{ascii} if rpm --nosignature --version >/dev/null 2>&1; then RPM="rpm --nosignature" ; else RPM="rpm" ; fi ; $RPM -qivlp --scripts %f
# deb
regex/\.u?deb$
Open=%cd %p/deb://
View=%view{ascii} dpkg-deb -I %f && echo && dpkg-deb -c %f
# dpkg
shell/.debd
Open=%cd %p/debd://
View=%view{ascii} dpkg -s `echo %p | sed 's/\([0-9a-z.-]*\).*/\1/'`
# apt
shell/.deba
Open=%cd %p/deba://
View=%view{ascii} apt-cache show `echo %p | sed 's/\([0-9a-z.-]*\).*/\1/'`
# ISO9660
regex/\.([iI][sS][oO])$
Open=%cd %p/iso9660://
View=%view{ascii} isoinfo -l -i %f
# 7zip archives (they are not man pages)
regex/\.(7z|7Z)$
Open=%cd %p/u7z://
View=%view{ascii} 7za l %f 2>/dev/null
View=%view{ascii} @EXTHELPERSDIR@/misc.sh view ar
# Mailboxes
type/^ASCII\ mail\ text
@ -290,12 +302,12 @@ include/editor
# .so libraries
regex/\.(so|so\.[0-9\.]*)$
View=%view{ascii} file %f && nm -C -D %f
View=%view{ascii} @EXTHELPERSDIR@/misc.sh view so
# Object
type/^ELF
#Open=%var{PAGER:more} %f
View=%view{ascii} file %f && nm -C %f
View=%view{ascii} @EXTHELPERSDIR@/misc.sh view elf
### Documentation ###
@ -304,10 +316,10 @@ type/^ELF
# GNU Info page
type/^Info\ text
Open=info -f %f
Open=@EXTHELPERSDIR@/text.sh open info
shell/.info
Open=info -f %f
Open=@EXTHELPERSDIR@/text.sh open info
# Exception: .3gp are video files not manual pages
regex/\.(3[gG][pP])$
@ -315,13 +327,13 @@ regex/\.(3[gG][pP])$
# Manual page
regex/(([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])|\.man)$
Open=case %d/%f in */log/*|*/logs/*) cat %f ;; *) { zsoelim %f 2>/dev/null || cat %f; } | nroff @MAN_FLAGS@ @MANDOC@ ;; esac | %var{PAGER:more}
View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) cat %f ;; *) { zsoelim %f 2>/dev/null || cat %f; } | nroff @MAN_FLAGS@ @MANDOC@ ;; esac
Open=@EXTHELPERSDIR@/text.sh open man %var{PAGER:more}
View=%view{ascii,nroff} @EXTHELPERSDIR@/text.sh view man %var{PAGER:more}
# Perl pod page
shell/.pod
Open=pod2man %f | nroff @MAN_FLAGS@ @MANDOC@ | %var{PAGER:more}
View=%view{ascii,nroff} pod2man %f | nroff @MAN_FLAGS@ @MANDOC@
Open=@EXTHELPERSDIR@/text.sh open pod %var{PAGER:more}
View=%view{ascii,nroff} @EXTHELPERSDIR@/text.sh view pod %var{PAGER:more}
# Troff with me macros.
# Exception - "read.me" is not a nroff file.
@ -330,38 +342,38 @@ shell/read.me
View=
shell/.me
Open=nroff @MAN_FLAGS@ -me %f | %var{PAGER:more}
View=%view{ascii,nroff} nroff @MAN_FLAGS@ -me %f
Open=@EXTHELPERSDIR@/text.sh open nroff.me %var{PAGER:more}
View=%view{ascii,nroff} @EXTHELPERSDIR@/text.sh view nroff.me %var{PAGER:more}
# Troff with ms macros.
shell/.ms
Open=nroff @MAN_FLAGS@ -ms %f | %var{PAGER:more}
View=%view{ascii,nroff} nroff @MAN_FLAGS@ -ms %f
Open=@EXTHELPERSDIR@/text.sh open nroff.ms %var{PAGER:more}
View=%view{ascii,nroff} @EXTHELPERSDIR@/text.sh view nroff.ms %var{PAGER:more}
# Manual page - compressed
regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.g?[Zz]$
Open=case %d/%f in */log/*|*/logs/*) gzip -dc %f ;; *) gzip -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac | %var{PAGER:more}
View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) gzip -dc %f ;; *) gzip -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac
Open=@EXTHELPERSDIR@/text.sh open man.gz %var{PAGER:more}
View=%view{ascii,nroff} @EXTHELPERSDIR@/text.sh view man.gz %var{PAGER:more}
regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.bz$
Open=case %d/%f in */log/*|*/logs/*) bzip -dc %f ;; *) bzip -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac | %var{PAGER:more}
View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) bzip -dc %f ;; *) bzip -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac
Open=@EXTHELPERSDIR@/text.sh open man.bz %var{PAGER:more}
View=%view{ascii,nroff} @EXTHELPERSDIR@/text.sh view man.bz %var{PAGER:more}
regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.bz2$
Open=case %d/%f in */log/*|*/logs/*) bzip2 -dc %f ;; *) bzip2 -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac | %var{PAGER:more}
View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) bzip2 -dc %f ;; *) bzip2 -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac
Open=@EXTHELPERSDIR@/text.sh open man.bz2 %var{PAGER:more}
View=%view{ascii,nroff} @EXTHELPERSDIR@/text.sh view man.bz2 %var{PAGER:more}
regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.lzma$
Open=case %d/%f in */log/*|*/logs/*) lzma -dc %f ;; *) lzma -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac | %var{PAGER:more}
View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) lzma -dc %f ;; *) lzma -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac
Open=@EXTHELPERSDIR@/text.sh open man.lzma %var{PAGER:more}
View=%view{ascii,nroff} @EXTHELPERSDIR@/text.sh view man.lzma %var{PAGER:more}
regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.xz$
Open=case %d/%f in */log/*|*/logs/*) xz -dc %f ;; *) xz -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac | %var{PAGER:more}
View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) xz -dc %f ;; *) xz -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac
Open=@EXTHELPERSDIR@/text.sh open man.xz %var{PAGER:more}
View=%view{ascii,nroff} @EXTHELPERSDIR@/text.sh view man.xz %var{PAGER:more}
# CHM
regex/\.(chm|CHM)$
Open=which kchmviewer > /dev/null 2>&1 && (kchmviewer %f &) || (xchm %f &)
Open=@EXTHELPERSDIR@/text.sh open chm
### Images ###
@ -369,7 +381,7 @@ type/^GIF
Include=image
type/^JPEG
View=%view{ascii} identify %f; test -x /usr/bin/exif && echo && exif %f 2>/dev/null
View=%view{ascii} @EXTHELPERSDIR@/image.sh view jpeg
Include=image
type/^PC\ bitmap
@ -394,59 +406,57 @@ type/^Netpbm
Include=image
shell/.xcf
Open=(gimp %f &)
Open=@EXTHELPERSDIR@/image.sh open xcf
shell/.xbm
Open=bitmap %f
Open=@EXTHELPERSDIR@/image.sh open xbm
shell/.xpm
Include=image
View=sxpm %f
View=@EXTHELPERSDIR@/image.sh view xpm %f
shell/.ico
Include=image
include/image
Open=if [ "$DISPLAY" = "" ]; then zgv %f; else (gqview %f &); fi
View=%view{ascii} identify %f
#View=%view{ascii} asciiview %f
Open=@EXTHELPERSDIR@/image.sh open ALL_FORMATS
View=%view{ascii} @EXTHELPERSDIR@/image.sh view ALL_FORMATS
### Sound files ###
regex/\.([wW][aA][vV]|[sS][nN][dD]|[vV][oO][cC]|[aA][uU]|[sS][mM][pP]|[aA][iI][fF][fF]|[sS][nN][dD])$
Open=if [ "$DISPLAY" = "" ]; then play %f; else (xmms %f >/dev/null 2>&1 &); fi
Open=@EXTHELPERSDIR@/sound.sh open common
regex/\.([mM][oO][dD]|[sS]3[mM]|[xX][mM]|[iI][tT]|[mM][tT][mM]|669|[sS][tT][mM]|[uU][lL][tT]|[fF][aA][rR])$
Open=mikmod %f
#Open=tracker %f
Open=@EXTHELPERSDIR@/sound.sh open mod
regex/\.([wW][aA][wW]22)$
Open=vplay -s 22 %f
Open=@EXTHELPERSDIR@/sound.sh open wav22
regex/\.([mM][pP]3)$
Open=if [ "$DISPLAY" = "" ]; then mpg123 %f; else (xmms %f >/dev/null 2>&1 &); fi
View=%view{ascii} mpg123 -vtn1 %f 2>&1 | sed -n '/^Title/,/^Comment/p;/^MPEG/,/^Audio/p'
Open=@EXTHELPERSDIR@/sound.sh open mp3
View=%view{ascii} @EXTHELPERSDIR@/sound.sh view mp3
regex/\.([oO][gG][gG|aA|vV|xX])$
Open=if [ "$DISPLAY" = "" ]; then ogg123 %f; else (xmms %f >/dev/null 2>&1 &); fi
View=%view{ascii} ogginfo %s
Open=@EXTHELPERSDIR@/sound.sh open ogg
View=%view{ascii} @EXTHELPERSDIR@/sound.sh view ogg
regex/\.([sS][pP][xX]|[fF][lL][aA][cC])$
Open=if [ "$DISPLAY" = "" ]; then play %f; else (xmms %f >/dev/null 2>&1 &); fi
Open=@EXTHELPERSDIR@/sound.sh open common
regex/\.([mM][iI][dD][iI]?|[rR][mM][iI][dD]?)$
Open=timidity %f
Open=@EXTHELPERSDIR@/sound.sh open midi
regex/\.([wW][mM][aA])$
Open=mplayer -vo null %f
View=%view{ascii} mplayer -quiet -slave -frames 0 -vo null -ao null -identify %f 2>/dev/null | tail +13 || file %f
Open=@EXTHELPERSDIR@/sound.sh open wma
View=%view{ascii} @EXTHELPERSDIR@/sound.sh view wma
### Play lists ###
regex/\.([mM]3[uU]|[pP][lL][sS])$
Open=if [ -z "$DISPLAY" ]; then mplayer -vo null -playlist %f; else (xmms -p %f >/dev/null 2>&1 &); fi
Open=@EXTHELPERSDIR@/sound.sh open playlist
### Video ###
@ -489,81 +499,74 @@ regex/\.([oO][gG][mM])$
Include=video
regex/\.([rR][aA]?[mM])$
Open=(realplay %f >/dev/null 2>&1 &)
Open=@EXTHELPERSDIR@/video.sh open ram
include/video
Open=(mplayer %f >/dev/null 2>&1 &)
#Open=(gtv %f >/dev/null 2>&1 &)
#Open=(xanim %f >/dev/null 2>&1 &)
Open=@EXTHELPERSDIR@/video.sh open ALL_FORMATS
### Documents ###
# Postscript
type/^PostScript
Open=(gv %f &)
View=%view{ascii} ps2ascii %f
Open=@EXTHELPERSDIR@/doc.sh open ps
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view ps
# PDF
type/^PDF
Open=(xpdf %f &)
#Open=(acroread %f &)
#Open=(ghostview %f &)
View=%view{ascii} pdftotext %f -
# The following code very ugly and should not be taken as example.
# It should be cleaned up when the new format of mc.ext is developed.
Open=@EXTHELPERSDIR@/doc.sh open pdf
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view pdf
# html
regex/\.([hH][tT][mM][lL]?)$
Open=(if test -n "@X11_WWW@" && test -n "$DISPLAY"; then (@X11_WWW@ file://%d/%p &) 1>&2; else links %f || lynx -force_html %f || ${PAGER:-more} %f; fi) 2>/dev/null
View=%view{ascii} links -dump %f 2>/dev/null || w3m -dump %f 2>/dev/null || lynx -dump -force_html %f
Open=@EXTHELPERSDIR@/web.sh open html
View=%view{ascii} @EXTHELPERSDIR@/web.sh view html
# StarOffice 5.2
shell/.sdw
Open=(ooffice %f &)
Open=@EXTHELPERSDIR@/doc.sh open oofice
# StarOffice 6 and OpenOffice.org formats
regex/\.(odt|ott|sxw|stw|ods|ots|sxc|stc|odp|otp|sxi|sti|odg|otg|sxd|std|odb|odf|sxm|odm|sxg)$
Open=(ooffice %f &)
View=%view{ascii} odt2txt %f
Open=@EXTHELPERSDIR@/doc.sh open oofice
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view odt
# AbiWord
shell/.abw
Open=(abiword %f &)
Open=@EXTHELPERSDIR@/doc.sh open abw
# Microsoft Word Document
regex/\.([Dd][oO][cCtT]|[Ww][rR][iI])$
Open=(abiword %f >/dev/null 2>&1 &)
View=%view{ascii} antiword -t %f || catdoc -w %f || word2x -f text %f - || strings %f
Open=@EXTHELPERSDIR@/doc.sh open msdoc
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msdoc
type/^Microsoft\ Word
Open=(abiword %f >/dev/null 2>&1 &)
View=%view{ascii} antiword -t %f || catdoc -w %f || word2x -f text %f - || strings %f
Open=@EXTHELPERSDIR@/doc.sh open msdoc
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msdoc
# RTF document
regex/\.([rR][tT][fF])$
Open=(abiword %f >/dev/null 2>&1 &)
Open=@EXTHELPERSDIR@/doc.sh open msdoc
# Microsoft Excel Worksheet
regex/\.([xX][lL][sSwW])$
Open=(gnumeric %f >/dev/null 2>&1 &)
View=%view{ascii} xls2csv %f || strings %f
Open=@EXTHELPERSDIR@/doc.sh open msxls
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msxls
type/^Microsoft\ Excel
Open=(gnumeric %f >/dev/null 2>&1 &)
View=%view{ascii} xls2csv %f || strings %f
Open=@EXTHELPERSDIR@/doc.sh open msxls
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msxls
# Use OpenOffice.org to open any MS Office documents
type/^Microsoft\ Office\ Document
Open=(ooffice %f &)
Open=@EXTHELPERSDIR@/doc.sh open oofice
# Framemaker
type/^FrameMaker
Open=fmclient -f %f
Open=@EXTHELPERSDIR@/doc.sh open framemaker
# DVI
regex/\.([dD][vV][iI])$
Open=if [ x$DISPLAY = x ]; then dvisvga %f; else (xdvi %f &); fi
View=%view{ascii} dvi2tty %f
Open=@EXTHELPERSDIR@/doc.sh open dvi
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view dvi
# TeX
regex/\.([Tt][Ee][Xx])$
@ -571,8 +574,8 @@ regex/\.([Tt][Ee][Xx])$
# DjVu
regex/\.(djvu?|DJVU?)$
Open=djview %f &
View=%view{ascii} djvused -e print-pure-txt %f
Open=@EXTHELPERSDIR@/doc.sh open djvu
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view djvu
### Miscellaneous ###
@ -582,7 +585,7 @@ regex/[Mm]akefile$
# Imakefile
shell/Imakefile
Open=xmkmf -a
Open=@EXTHELPERSDIR@/misc.sh open imakefile
# Makefile.PL (MakeMaker)
regex/^Makefile.(PL|pl)$
@ -590,8 +593,8 @@ regex/^Makefile.(PL|pl)$
# dbf
regex/\.([dD][bB][fF])$
Open=%view{ascii} dbview %f
View=%view{ascii} dbview -b %f
Open=%view{ascii} @EXTHELPERSDIR@/misc.sh open dbf
View=%view{ascii} @EXTHELPERSDIR@/misc.sh view dbf
# REXX script
regex/\.(rexx?|cmd)$
@ -605,81 +608,81 @@ regex/\.(d64|D64)$
# Glade, a user interface designer for GTK+ and GNOME
regex/\.([Gg][Ll][Aa][Dd][Ee])$
Open=if glade-3 --version >/dev/null 2>&1; then (glade-3 %f >/dev/null 2>&1 &); else (glade-2 %f >/dev/null 2>&1 &); fi
Open=@EXTHELPERSDIR@/misc.sh open glade
# Gettext Catalogs
shell/.mo
View=%view{ascii} msgunfmt %f || cat %f
View=%view{ascii} @EXTHELPERSDIR@/misc.sh view mo
# lyx
regex/\.(lyx|LYX)$
Open=lyx %f
View=%view{ascii} lyxcat %f
Open=@EXTHELPERSDIR@/misc.sh open lyx
View=%view{ascii} @EXTHELPERSDIR@/misc.sh view lyx
# torrent
regex/\.([tT][oO][rR][rR][eE][nN][tT])$
View=%view{ascii} ctorrent -x %f 2>/dev/null
View=%view{ascii} @EXTHELPERSDIR@/misc.sh view torrent
### Plain compressed files ###
# ace
regex/\.(ace|ACE)$
Open=%cd %p/uace://
View=%view{ascii} unace l %f
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view ace
Extract=unace x %f
# arc
regex/\.(arc|ARC)$
Open=%cd %p/uarc://
View=%view{ascii} arc l %f
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view arc
Extract=arc x %f '*'
Extract (with flags)=I=%{Enter any Arc flags:}; if test -n "$I"; then arc x $I %f; fi
# zip
type/^([Zz][Ii][Pp])\ archive
Open=%cd %p/uzip://
View=%view{ascii} unzip -v %f
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zip
# zoo
regex/\.([Zz][Oo][Oo])$
Open=%cd %p/uzoo://
View=%view{ascii} zoo l %f
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zoo
# gzip
type/^gzip
Open=gzip -dc %f | %var{PAGER:more}
View=%view{ascii} gzip -dc %f 2>/dev/null
Open=@EXTHELPERSDIR@/archive.sh view gz %var{PAGER:more}
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view gz
regex/\.(gz|Z)$
View=%view{ascii} gzip -dc %f 2>/dev/null
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view gz
# bzip2
type/^bzip2
Open=bzip2 -dc %f | %var{PAGER:more}
View=%view{ascii} bzip2 -dc %f 2>/dev/null
Open=@EXTHELPERSDIR@/archive.sh view bzip2 %var{PAGER:more}
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view bz2
regex/\.bz2?$
View=%view{ascii} bzip2 -dc %f 2>/dev/null
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view bz2
# bzip
type/^bzip
Open=bzip -dc %f | %var{PAGER:more}
View=%view{ascii} bzip -dc %f 2>/dev/null
Open=@EXTHELPERSDIR@/archive.sh view bzip %var{PAGER:more}
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view bzip
# compress
type/^compress
Open=gzip -dc %f | %var{PAGER:more}
View=%view{ascii} gzip -dc %f 2>/dev/null
Open=@EXTHELPERSDIR@/archive.sh view gz %var{PAGER:more}
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view gz
# lzma
regex/\.lzma$
Open=lzma -dc %f | %var{PAGER:more}
View=%view{ascii} lzma -dc %f 2>/dev/null
Open=@EXTHELPERSDIR@/archive.sh view lzma %var{PAGER:more}
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view lzma
# xz
regex/\.xz$
Open=xz -dc %f | %var{PAGER:more}
View=%view{ascii} xz -dc %f 2>/dev/null
Open=@EXTHELPERSDIR@/archive.sh view xz %var{PAGER:more}
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view xz
### Default ###

View File

@ -85,61 +85,117 @@ typedef char *(*quote_func_t) (const char *name, int quote_percent);
* need it
*/
static char *data = NULL;
static vfs_path_t *localfilecopy_vpath = NULL;
static char buffer[BUF_1K];
static char *pbuffer = NULL;
static time_t localmtime = 0;
static quote_func_t quote_func = name_quote;
static gboolean run_view = FALSE;
static gboolean is_cd = FALSE;
static gboolean written_nonspace = FALSE;
static gboolean do_local_copy = FALSE;
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
static void
exec_extension (const char *filename, const char *lc_data, int *move_dir, int start_line)
exec_cleanup_file_name (vfs_path_t * filename_vpath, gboolean has_changed)
{
vfs_path_t *file_name_vpath;
int cmd_file_fd;
FILE *cmd_file;
char *cmd = NULL;
int expand_prefix_found = 0;
int parameter_found = 0;
char lc_prompt[80];
int run_view = 0;
int def_hex_mode = mcview_default_hex_mode, changed_hex_mode = 0;
int def_nroff_flag = mcview_default_nroff_flag, changed_nroff_flag = 0;
int written_nonspace = 0;
int is_cd = 0;
char buffer[1024];
char *p = 0;
vfs_path_t *localcopy_vpath = NULL;
int do_local_copy;
time_t localmtime = 0;
struct stat mystat;
quote_func_t quote_func = name_quote;
vfs_path_t *vpath;
if (localfilecopy_vpath == NULL)
return;
g_return_if_fail (filename != NULL);
g_return_if_fail (lc_data != NULL);
vpath = vfs_path_from_str (filename);
/* Avoid making a local copy if we are doing a cd */
do_local_copy = vfs_file_is_local (vpath) ? 0 : 1;
/*
* All commands should be run in /bin/sh regardless of user shell.
* To do that, create temporary shell script and run it.
* Sometimes it's not needed (e.g. for %cd and %view commands),
* but it's easier to create it anyway.
*/
cmd_file_fd = mc_mkstemps (&file_name_vpath, "mcext", SCRIPT_SUFFIX);
if (cmd_file_fd == -1)
if (has_changed)
{
message (D_ERROR, MSG_ERROR,
_("Cannot create temporary command file\n%s"), unix_error_string (errno));
goto ret;
struct stat mystat;
mc_stat (localfilecopy_vpath, &mystat);
has_changed = localmtime != mystat.st_mtime;
}
mc_ungetlocalcopy (filename_vpath, localfilecopy_vpath, has_changed);
vfs_path_free (localfilecopy_vpath);
localfilecopy_vpath = NULL;
}
/* --------------------------------------------------------------------------------------------- */
static char *
exec_get_file_name (vfs_path_t * filename_vpath)
{
if (!do_local_copy)
return quote_func (vfs_path_get_last_path_str (filename_vpath), 0);
if (localfilecopy_vpath == NULL)
{
struct stat mystat;
localfilecopy_vpath = mc_getlocalcopy (filename_vpath);
if (localfilecopy_vpath == NULL)
return NULL;
mc_stat (localfilecopy_vpath, &mystat);
localmtime = mystat.st_mtime;
}
cmd_file = fdopen (cmd_file_fd, "w");
fputs ("#! /bin/sh\n", cmd_file);
return quote_func (vfs_path_get_last_path_str (localfilecopy_vpath), 0);
}
/* --------------------------------------------------------------------------------------------- */
static char *
exec_get_export_variables (vfs_path_t * filename_vpath)
{
char *text;
GString *export_vars_string;
size_t i;
/* *INDENT-OFF* */
struct
{
const char symbol;
const char *name;
} export_variables[] = {
{'p', "MC_EXT_BASENAME"},
{'d', "MC_EXT_CURRENTDIR"},
{'s', "MC_EXT_SELECTED"},
{'t', "MC_EXT_ONLYTAGGED"},
{'\0', NULL}
};
/* *INDENT-ON* */
text = exec_get_file_name (filename_vpath);
if (text == NULL)
return NULL;
export_vars_string = g_string_new ("MC_EXT_FILENAME=");
g_string_append_printf (export_vars_string, "\"%s\"\nexport MC_EXT_FILENAME\n", text);
g_free (text);
for (i = 0; export_variables[i].name != NULL; i++)
{
text = expand_format (NULL, export_variables[i].symbol, TRUE);
if (text != NULL)
{
g_string_append_printf (export_vars_string,
"%s=\"%s\"\nexport %s\n", export_variables[i].name, text,
export_variables[i].name);
g_free (text);
}
}
return g_string_free (export_vars_string, FALSE);
}
/* --------------------------------------------------------------------------------------------- */
static char *
exec_make_shell_string (const char *lc_data, vfs_path_t * filename_vpath)
{
GString *shell_string;
char lc_prompt[80] = "\0";
gboolean parameter_found = FALSE;
gboolean expand_prefix_found = FALSE;
shell_string = g_string_new ("");
lc_prompt[0] = '\0';
for (; *lc_data != '\0' && *lc_data != '\n'; lc_data++)
{
if (parameter_found)
@ -148,22 +204,17 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
{
char *parameter;
parameter_found = 0;
parameter_found = FALSE;
parameter = input_dialog (_("Parameter"), lc_prompt, MC_HISTORY_EXT_PARAMETER, "");
if (parameter == NULL)
{
/* User canceled */
fclose (cmd_file);
mc_unlink (file_name_vpath);
if (localcopy_vpath != NULL)
{
mc_ungetlocalcopy (vpath, localcopy_vpath, FALSE);
vfs_path_free (localcopy_vpath);
}
goto ret;
g_string_free (shell_string, TRUE);
exec_cleanup_file_name (filename_vpath, FALSE);
return NULL;
}
fputs (parameter, cmd_file);
written_nonspace = 1;
g_string_append (shell_string, parameter);
written_nonspace = TRUE;
g_free (parameter);
}
else
@ -179,9 +230,9 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
}
else if (expand_prefix_found)
{
expand_prefix_found = 0;
expand_prefix_found = FALSE;
if (*lc_data == '{')
parameter_found = 1;
parameter_found = TRUE;
else
{
int i;
@ -191,17 +242,17 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
if (i != 0)
{
lc_data += i - 1;
run_view = 1;
run_view = TRUE;
}
else
{
i = check_format_cd (lc_data);
if (i > 0)
{
is_cd = 1;
is_cd = TRUE;
quote_func = fake_name_quote;
do_local_copy = 0;
p = buffer;
do_local_copy = FALSE;
pbuffer = buffer;
lc_data += i - 1;
}
else
@ -209,7 +260,7 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
i = check_format_var (lc_data, &v);
if (i > 0 && v != NULL)
{
fputs (v, cmd_file);
g_string_append (shell_string, v);
g_free (v);
lc_data += i;
}
@ -221,57 +272,185 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
text = expand_format (NULL, *lc_data, !is_cd);
else
{
if (do_local_copy)
text = exec_get_file_name (filename_vpath);
if (text == NULL)
{
localcopy_vpath = mc_getlocalcopy (vpath);
if (localcopy_vpath == NULL)
{
fclose (cmd_file);
mc_unlink (file_name_vpath);
goto ret;
}
mc_stat (localcopy_vpath, &mystat);
localmtime = mystat.st_mtime;
text =
quote_func (vfs_path_get_last_path_str (localcopy_vpath),
0);
}
else
{
const vfs_path_element_t *path_element;
path_element = vfs_path_get_by_index (vpath, -1);
text = quote_func (path_element->path, 0);
g_string_free (shell_string, TRUE);
return NULL;
}
}
if (!is_cd)
fputs (text, cmd_file);
g_string_append (shell_string, text);
else
{
strcpy (p, text);
p = strchr (p, 0);
strcpy (pbuffer, text);
pbuffer = strchr (pbuffer, 0);
}
g_free (text);
written_nonspace = 1;
written_nonspace = TRUE;
}
}
}
}
}
else if (*lc_data == '%')
expand_prefix_found = 1;
expand_prefix_found = TRUE;
else
{
if (*lc_data != ' ' && *lc_data != '\t')
written_nonspace = 1;
written_nonspace = TRUE;
if (is_cd)
*(p++) = *lc_data;
*(pbuffer++) = *lc_data;
else
fputc (*lc_data, cmd_file);
g_string_append_c (shell_string, *lc_data);
}
} /* for */
return g_string_free (shell_string, FALSE);
}
/* --------------------------------------------------------------------------------------------- */
static void
exec_extension_view (char *cmd, vfs_path_t * filename_vpath, int *move_dir, int start_line,
vfs_path_t * temp_file_name_vpath)
{
mcview_ret_t ret;
int def_hex_mode = mcview_default_hex_mode, changed_hex_mode = 0;
int def_nroff_flag = mcview_default_nroff_flag, changed_nroff_flag = 0;
mcview_altered_hex_mode = 0;
mcview_altered_nroff_flag = 0;
if (def_hex_mode != mcview_default_hex_mode)
changed_hex_mode = 1;
if (def_nroff_flag != mcview_default_nroff_flag)
changed_nroff_flag = 1;
/* If we've written whitespace only, then just load filename
* into view
*/
if (written_nonspace)
{
ret = mcview_viewer (cmd, filename_vpath, start_line);
mc_unlink (temp_file_name_vpath);
}
else
ret = mcview_viewer (NULL, filename_vpath, start_line);
if (move_dir != NULL)
switch (ret)
{
case MCVIEW_WANT_NEXT:
*move_dir = 1;
break;
case MCVIEW_WANT_PREV:
*move_dir = -1;
break;
default:
*move_dir = 0;
}
if (changed_hex_mode && !mcview_altered_hex_mode)
mcview_default_hex_mode = def_hex_mode;
if (changed_nroff_flag && !mcview_altered_nroff_flag)
mcview_default_nroff_flag = def_nroff_flag;
dialog_switch_process_pending ();
}
/* --------------------------------------------------------------------------------------------- */
static void
exec_extension_cd (void)
{
char *q;
vfs_path_t *p_vpath;
*pbuffer = '\0';
pbuffer = buffer;
/* while (*p == ' ' && *p == '\t')
* p++;
*/
/* Search last non-space character. Start search at the end in order
not to short filenames containing spaces. */
q = pbuffer + strlen (pbuffer) - 1;
while (q >= pbuffer && (*q == ' ' || *q == '\t'))
q--;
q[1] = 0;
p_vpath = vfs_path_from_str_flags (pbuffer, VPF_NO_CANON);
do_cd (p_vpath, cd_parse_command);
vfs_path_free (p_vpath);
}
/* --------------------------------------------------------------------------------------------- */
static void
exec_extension (const char *filename, const char *lc_data, int *move_dir, int start_line)
{
char *shell_string, *export_variables;
vfs_path_t *temp_file_name_vpath = NULL;
int cmd_file_fd;
FILE *cmd_file;
char *cmd = NULL;
vfs_path_t *filename_vpath;
g_return_if_fail (filename != NULL);
g_return_if_fail (lc_data != NULL);
pbuffer = NULL;
localmtime = 0;
quote_func = name_quote;
run_view = FALSE;
is_cd = FALSE;
written_nonspace = FALSE;
filename_vpath = vfs_path_from_str (filename);
/* Avoid making a local copy if we are doing a cd */
do_local_copy = !vfs_file_is_local (filename_vpath);
shell_string = exec_make_shell_string (lc_data, filename_vpath);
if (shell_string == NULL)
goto ret;
if (is_cd)
{
exec_extension_cd ();
g_free (shell_string);
goto ret;
}
/*
* All commands should be run in /bin/sh regardless of user shell.
* To do that, create temporary shell script and run it.
* Sometimes it's not needed (e.g. for %cd and %view commands),
* but it's easier to create it anyway.
*/
cmd_file_fd = mc_mkstemps (&temp_file_name_vpath, "mcext", SCRIPT_SUFFIX);
if (cmd_file_fd == -1)
{
message (D_ERROR, MSG_ERROR,
_("Cannot create temporary command file\n%s"), unix_error_string (errno));
goto ret;
}
cmd_file = fdopen (cmd_file_fd, "w");
fputs ("#! /bin/sh\n\n", cmd_file);
export_variables = exec_get_export_variables (filename_vpath);
if (export_variables != NULL)
{
fprintf (cmd_file, "%s\n", export_variables);
g_free (export_variables);
}
fputs (shell_string, cmd_file);
g_free (shell_string);
/*
* Make the script remove itself when it finishes.
@ -282,7 +461,7 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
{
char *file_name;
file_name = vfs_path_to_str (file_name_vpath);
file_name = vfs_path_to_str (temp_file_name_vpath);
fprintf (cmd_file, "\n/bin/rm -f %s\n", file_name);
g_free (file_name);
}
@ -291,85 +470,24 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
if ((run_view && !written_nonspace) || is_cd)
{
mc_unlink (file_name_vpath);
vfs_path_free (file_name_vpath);
file_name_vpath = NULL;
mc_unlink (temp_file_name_vpath);
vfs_path_free (temp_file_name_vpath);
temp_file_name_vpath = NULL;
}
else
{
char *file_name;
file_name = vfs_path_to_str (file_name_vpath);
file_name = vfs_path_to_str (temp_file_name_vpath);
/* Set executable flag on the command file ... */
mc_chmod (file_name_vpath, S_IRWXU);
mc_chmod (temp_file_name_vpath, S_IRWXU);
/* ... but don't rely on it - run /bin/sh explicitly */
cmd = g_strconcat ("/bin/sh ", file_name, (char *) NULL);
g_free (file_name);
}
if (run_view)
{
mcview_ret_t ret;
mcview_altered_hex_mode = 0;
mcview_altered_nroff_flag = 0;
if (def_hex_mode != mcview_default_hex_mode)
changed_hex_mode = 1;
if (def_nroff_flag != mcview_default_nroff_flag)
changed_nroff_flag = 1;
/* If we've written whitespace only, then just load filename
* into view
*/
if (written_nonspace)
{
ret = mcview_viewer (cmd, vpath, start_line);
mc_unlink (file_name_vpath);
}
else
ret = mcview_viewer (NULL, vpath, start_line);
if (move_dir != NULL)
switch (ret)
{
case MCVIEW_WANT_NEXT:
*move_dir = 1;
break;
case MCVIEW_WANT_PREV:
*move_dir = -1;
break;
default:
*move_dir = 0;
}
if (changed_hex_mode && !mcview_altered_hex_mode)
mcview_default_hex_mode = def_hex_mode;
if (changed_nroff_flag && !mcview_altered_nroff_flag)
mcview_default_nroff_flag = def_nroff_flag;
dialog_switch_process_pending ();
}
else if (is_cd)
{
char *q;
vfs_path_t *p_vpath;
*p = 0;
p = buffer;
/* while (*p == ' ' && *p == '\t')
* p++;
*/
/* Search last non-space character. Start search at the end in order
not to short filenames containing spaces. */
q = p + strlen (p) - 1;
while (q >= p && (*q == ' ' || *q == '\t'))
q--;
q[1] = 0;
p_vpath = vfs_path_from_str_flags (p, VPF_NO_CANON);
do_cd (p_vpath, cd_parse_command);
vfs_path_free (p_vpath);
}
exec_extension_view (cmd, filename_vpath, move_dir, start_line, temp_file_name_vpath);
else
{
shell_execute (cmd, EXECUTE_INTERNAL);
@ -385,15 +503,10 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
g_free (cmd);
if (localcopy_vpath != NULL)
{
mc_stat (localcopy_vpath, &mystat);
mc_ungetlocalcopy (vpath, localcopy_vpath, localmtime != mystat.st_mtime);
vfs_path_free (localcopy_vpath);
}
exec_cleanup_file_name (filename_vpath, TRUE);
ret:
vfs_path_free (file_name_vpath);
vfs_path_free (vpath);
vfs_path_free (temp_file_name_vpath);
vfs_path_free (filename_vpath);
}
/* --------------------------------------------------------------------------------------------- */
@ -512,7 +625,7 @@ regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, int *have_
if (*have_type == 0)
{
vfs_path_t *localfile_vpath;
const char *realname; /* name used with "file" */
const char *realname; /* name used with "file" */
#ifdef HAVE_CHARSET
int got_encoding_data;
@ -766,14 +879,14 @@ regex_command (const vfs_path_t * filename_vpath, const char *action, int *move_
else if (!strncmp (p, "shell/", 6))
{
p += 6;
if (*p == '.' && file_len >= (size_t)(q - p))
if (*p == '.' && file_len >= (size_t) (q - p))
{
if (!strncmp (p, filename + file_len - (q - p), q - p))
found = 1;
}
else
{
if ((size_t)(q - p) == file_len && !strncmp (p, filename, q - p))
if ((size_t) (q - p) == file_len && !strncmp (p, filename, q - p))
found = 1;
}
}
@ -829,32 +942,26 @@ regex_command (const vfs_path_t * filename_vpath, const char *action, int *move_
break;
continue;
}
if (!strcmp (action, p))
if (strcmp (action, p) != 0)
*r = c;
else
{
*r = c;
for (p = r + 1; *p == ' ' || *p == '\t'; p++);
for (p = r + 1; *p == ' ' || *p == '\t'; p++)
;
/* Empty commands just stop searching
* through, they don't do anything
*
* We need to copy the filename because exec_extension
* may end up invoking update_panels thus making the
* filename parameter invalid (ie, most of the time,
* we get filename as a pointer from current_panel->dir).
*/
if (p < q)
{
char *filename_copy = g_strdup (filename);
exec_extension (filename_copy, r + 1, move_dir, view_at_line_number);
g_free (filename_copy);
exec_extension (filename, r + 1, move_dir, view_at_line_number);
ret = 1;
}
break;
}
else
*r = c;
}
}
p = q;