2022-03-18 12:09:30 +00:00
|
|
|
|
edit:add-var winmail~ {|@argv|
|
|
|
|
|
use path
|
2024-03-02 14:15:47 +00:00
|
|
|
|
use os
|
2022-03-18 12:09:30 +00:00
|
|
|
|
|
|
|
|
|
var curdir = (pwd)
|
2024-03-02 14:15:47 +00:00
|
|
|
|
var tmpdir = (os:temp-dir 'winmail-*')
|
2022-03-18 12:09:30 +00:00
|
|
|
|
var remove = $false
|
|
|
|
|
var browse = $e:falkon~
|
|
|
|
|
var explore = $e:dolphin~
|
|
|
|
|
var data = ''
|
|
|
|
|
|
|
|
|
|
fn print_help {||
|
|
|
|
|
echo 'winmail [(-h|-k|-r)] [<winmail_file>]'
|
|
|
|
|
echo ''
|
|
|
|
|
echo 'Options:'
|
|
|
|
|
echo ' -h, --help Affiche cette aide'
|
|
|
|
|
echo ' -k, --keep Conserve le fichier winmail.dat fourni en entrée (option par défaut)'
|
|
|
|
|
echo ' -r, --remove Supprime le fichier winmail.dat une fois le programme terminé'
|
|
|
|
|
echo ''
|
2022-03-18 12:16:49 +00:00
|
|
|
|
echo 'Si le fichier de données winmail.dat n’est pas défini, utilise le winmail.dat du répertoire courant, si trouvé'
|
2022-03-18 12:09:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
each {|e|
|
|
|
|
|
if (or (eq $e -r) (eq $e --remove)) {
|
|
|
|
|
set remove = $true
|
|
|
|
|
} elif (or (eq $e -k) (eq $e --keep)) {
|
|
|
|
|
set remove = $false
|
|
|
|
|
} elif (or (eq $e -h) (eq $e --help)) {
|
|
|
|
|
print_help
|
|
|
|
|
exit
|
|
|
|
|
} else {
|
2022-03-18 12:16:49 +00:00
|
|
|
|
set data = (path:abs $e)
|
2022-03-18 12:09:30 +00:00
|
|
|
|
}
|
|
|
|
|
} $argv
|
|
|
|
|
|
|
|
|
|
if (eq $data '') {
|
2022-03-18 12:16:49 +00:00
|
|
|
|
set data = (path:abs 'winmail.dat')
|
2022-03-18 12:09:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-02 14:15:47 +00:00
|
|
|
|
if (not (os:is-regular $data)) {
|
2022-03-18 12:09:30 +00:00
|
|
|
|
fail (printf 'Le fichier %s n’existe pas.' $data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cd $tmpdir
|
|
|
|
|
tnef --save-body $data
|
|
|
|
|
|
2024-03-02 14:15:47 +00:00
|
|
|
|
if (os:is-regular message.html) {
|
2022-03-18 12:09:30 +00:00
|
|
|
|
perl -pe 's/cid:(image(\\d{3})\.(jpe?g|png|gif))@[[:alnum:]]{8}\.[[:alnum:]]{8}/\\1/g' message.html > message2.html
|
|
|
|
|
$browse message2.html > /dev/null 2> /dev/null
|
|
|
|
|
} else {
|
|
|
|
|
$explore . > /dev/null 2> /dev/null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cd $curdir
|
2024-03-02 14:15:47 +00:00
|
|
|
|
os:remove-all $tmpdir
|
2022-03-18 12:09:30 +00:00
|
|
|
|
if $remove {
|
2024-03-02 14:15:47 +00:00
|
|
|
|
os:remove $data
|
2022-03-18 12:09:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|