From 6fdff9d14098412dddab9d23256d90f833faf663 Mon Sep 17 00:00:00 2001 From: Benjamin VAUDOUR Date: Fri, 18 Mar 2022 13:09:30 +0100 Subject: [PATCH] Ajout editorconfig + tnef --- .editorconfig | 8 +++++++ aliases/tnef.elv | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 .editorconfig create mode 100644 aliases/tnef.elv diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..1923d41 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/aliases/tnef.elv b/aliases/tnef.elv new file mode 100644 index 0000000..b701ba7 --- /dev/null +++ b/aliases/tnef.elv @@ -0,0 +1,58 @@ +edit:add-var winmail~ {|@argv| + use path + + var curdir = (pwd) + var tmpdir = (mktemp --tmpdir -d winmail-XXXXXXXX) + var remove = $false + var browse = $e:falkon~ + var explore = $e:dolphin~ + var data = '' + + fn print_help {|| + echo 'winmail [(-h|-k|-r)] []' + 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 '' + echo 'Si le fichier de données winmail.dat n’est pas, utilise le winmail.dat du répertoire courant, si trouvé' + } + + 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 { + set data = $e + } + } $argv + + if (eq $data '') { + set data = $curdir'/winmail.dat' + } + + if (not (path:is-regular $data)) { + fail (printf 'Le fichier %s n’existe pas.' $data) + } + + cd $tmpdir + tnef --save-body $data + + if (path:is-regular message.html) { + 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 + rm -rf $tmpdir + if $remove { + rm $data + } +}