% Filename: create_msg_id.sl
% Version: 0.9.2
% Author: Troy Piggins
% Thanks: Sven Guckes from the slrn-user mailing list, and John E Davis from
% the slang-user mailing list

% returns a string of the format YYYYMMDDhhmmss.xyz@subdomain.hostname
% eg for my setup I get:
% Message-ID: 20070220143000.xyz@usenet.piggo.com
% where xyz are random characters
% you need to change the value of sd and hostname to suit

% Pseudo-random function provided by John E Davis on the slang-users mailing
% list, because from what I can tell at the time of writing this there is no
% way of generating random numbers in s-lang without the gsl module which most
% people won't have.  Possible in slang 2.1.4.

private variable Random;
define srandom (r)
{
   Random = r;
}
srandom (_time() * getpid());
define random ()
{
  Random = (Random*69069U + 1013904243U)&0xFFFFFFFFU;
  return Random;
}
% end pseudo-random function

define create_msg_id()
{

   variable sd= "illuminati";
   variable hostname= "rules.goy";

   variable tm= localtime( _time ());

% some random chars for "true uniqueness" as recommended by Peter J Ross
%   in 
 
   variable rnd=  random() mod 1000;

   return sprintf ("%d%02d%02d%02d%02d%02d.%d@%s.%s",
                   tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
                   tm.tm_hour, tm.tm_min, tm.tm_sec,
                   rnd,
                   sd, hostname);

}

define post_hook ()
{
  set_string_variable ( "custom_headers",
                       sprintf ("Message-ID: <%s>\nX-Face: #qJVhFD9mTcJIE6s;3%%kN#,}PT`x;Qr`xIQ*z.T#^\\C]/l$!a)P7;x}[cK_n\"T:60cXgSz:yJ_&B0UiXiKr!)DSo8,A>]Lw^.<[0YaX0WZ6q#H_ri9t'|b[OR^a3G!qcX^.HV\\", create_msg_id ()));
}

define followup_hook()
{

  set_string_variable ("followup_custom_headers",
                       sprintf ("Message-ID: <%s>\nX-Face: #qJVhFD9mTcJIE6s;3%%kN#,}PT`x;Qr`xIQ*z.T#^\\C]/l$!a)P7;x}[cK_n\"T:60cXgSz:yJ_&B0UiXiKr!)DSo8,A>]Lw^.<[0YaX0WZ6q#H_ri9t'|b[OR^a3G!qcX^.HV\\", create_msg_id ()));
}

define reply_hook()
{
  set_string_variable ("reply_custom_headers",
                       sprintf ("Message-ID: <%s>\nX-Face: #qJVhFD9mTcJIE6s;3%%kN#,}PT`x;Qr`xIQ*z.T#^\\C]/l$!a)P7;x}[cK_n\"T:60cXgSz:yJ_&B0UiXiKr!)DSo8,A>]Lw^.<[0YaX0WZ6q#H_ri9t'|b[OR^a3G!qcX^.HV\\", create_msg_id ()));
}

Kruppt