% Filename: demime.sl % Version: 0.9.1 % Author: Troy Piggins % Thanks: Christian Ebert from the slrn-user mailing list. % Code needs some tidying up and commenting, but it's functional. % *** Check the path to demime is correct for your system. *** define demime () { variable xcharset = extract_displayed_article_header("Content-Type"); if ((string_match(xcharset,"\\Cmultipart/mixed",1)) | (string_match(xcharset,"\\Cmultipart/alternative",1)) | (string_match(xcharset,"\\Cmultipart/signed",1))) { variable demime_tmp, raw_art, fp, art_demime; variable macro_sig = "\n-- \n[-- TP's demime macro removed MIME content --]"; demime_tmp = "/tmp/slrn_demime."+ string (getpid () ); raw_art = raw_article_as_string (); fp = fopen (demime_tmp, "w"); if (fp == NULL) error (_function_name () +": could not open "+demime_tmp); fputs (raw_art, fp); fclose (fp); fp = popen ("/usr/local/bin/demime --quiet - < "+demime_tmp, "r"); if (fp == NULL) error (_function_name () +": demime pipe failed" ); art_demime = strjoin (fgetslines (fp), ""); pclose (fp); if (art_demime != "") replace_article (art_demime+macro_sig); else error (_function_name () +": failed"); system ("rm "+demime_tmp); } } % () = register_hook ("read_article_hook", "demime");