% 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= "usenet"; variable hostname= "piggo.com"; 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>", create_msg_id ())); } define followup_hook() { set_string_variable ("followup_custom_headers", sprintf ("Message-ID: <%s>", create_msg_id ())); } define reply_hook() { set_string_variable ("reply_custom_headers", sprintf ("Message-ID: <%s>", create_msg_id ())); }