% % 2005-01-18 Alexander Bartolich % http://tux.bartolich.at/slrn/ % % This is free software; you can redistribute it and/or modify it % under the terms of the GPL as published by the Free Software % Foundation; either version 2 of the License, or (at your option) % any later version. % define get_date() { variable date_fp = popen ("date '+%Y-%m-%d %H:%M:%S %Z'", "r"); variable line = ""; () = fgets (&line, date_fp); return strtrim (line); } define get_custom_headers(varname) { variable header = Assoc_Type [String_Type]; foreach(strchop (get_variable_value ("followup_custom_headers"), '\n', 0)) { variable line = (); variable index = string_match (line, ": ", 1); if (index > 0) header[substr(line, 1, index - 1)] = substr(line, index + 2, -1); } return header; } define set_custom_headers (varname, header) { variable a, b, fch = ""; foreach (header) using ("keys", "values") { (a, b) = (); fch += sprintf ("%s: %s\n", a, b); } set_string_variable (varname, fch); } define add_editing_begin(varname) { variable header, original_from; original_from = extract_article_header("From"); header = get_custom_headers (varname); header["X-Editing-Begin"] = get_date (); header["X-Original-From"] = original_from; set_custom_headers (varname, header); variable fs = "begin followup to %r:"; if ( string_match(original_from, "Sabine 'Sani' Schulz", 1) or ( not string_match(current_newsgroup, "\\", 1) and not string_match(current_newsgroup, "\\", 1) ) ) { if ( string_match(current_newsgroup, "^at\\.", 1) or string_match(current_newsgroup, "^de\\.", 1) ) fs = "%r schrieb:"; else fs = "%r wrote:"; } set_string_variable("followup_string", fs); } define add_editing_close (file) { variable fp = fopen (file, "r"); if (fp == NULL) return; variable lines = fgetslines (fp); % file is closed by fgetslines fp = fopen (file, "w"); if (fp == NULL) return; variable i; for (i = 0; i < length (lines); i++) { variable line = lines[i]; if (line == "\n") break; () = fputs (line, fp); } () = fputs (sprintf ("X-Editing-Close: %s\n", get_date ()), fp); for (; i < length (lines); i++) () = fputs (sprintf("%s", lines[i]), fp); } define post_hook () { add_editing_begin ("custom_headers"); } define followup_hook () { add_editing_begin ("followup_custom_headers"); } define post_file_hook (file) { add_editing_close (file); }