Article View: news.software.readers
Article #50297Re: [slrn] Return-Path: header..?
From: Dawn Owens-Nicholson
Date: Sun, 01 Aug 1999 00:00
Date: Sun, 01 Aug 1999 00:00
58 lines
2546 bytes
2546 bytes
Morten Bo Johansen wrote:
> Can I have a custom header inserted dynamically depending on which group
> I'm posting to ?
Yes, if you use an S-Lang macro. It depends on how elaborate you want to
get and what you want to do. You could use strchop() to break up the custom
headers slrn variable into a string array then modify the array and use
strjoin() to put it all back together:
variable hdrs = strchop (get_variable_value ("custom_headers"), '\n', 0);
if (string_match (current_newsgroup (), "^rec\.", 1)
{
.
. % do something in here
.
}
set_string_variable ("custom_headers", strjoin (hdrs, "\n");
Another approach is to load the headers and values into a hash...
variable
h = "",
header = "",
my_header_hash = Assoc_Type [String_Type];
foreach (strchop (get_variable_value ("custom_headers"), '\n', 0))
{
h = ();
header = strchop (h, ' ', 0);
my_header_hash[header[0]] = strjoin (header[[1:]], " ");
}
...modify the hash, rejoin the keys & values of the hash and put them back
into the slrn custom_headers variable when you're done...
variable
custom_headers = "",
value;
foreach (my_header_hash) using ("keys", "values")
{
(header, value) = ();
custom_headers += sprintf ("%s %S\n", header, value);
}
custom_headers = custom_headers[[:-2]]; % trim the trailing \n
set_string_variable ("custom_headers", custom_headers);
(The capital-s in "%S" is just in case you used a numeric value for some
header somewhere--%S gets you automatic string conversion, %s doesn't.)
If you want some basic set of custom headers for all groups, it might be
easier to set those headers in your slrn.rc and use the macro to add new
headers. Again, it all depends on what you want to do.
Technical Details
Message-ID:
<slrn7q9eij.mdh.bluemoon@ux6.cso.uiuc.edu>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mailReferences:
<slrn7q8u74.27q.mojo@localhost.localdomain> <slrn7q9bso.53b.mojo@localhost.localdomain>Show Full Headers
Complete Article Headers
Message-ID: <slrn7q9eij.mdh.bluemoon@ux6.cso.uiuc.edu> Subject: Re: [slrn] Return-Path: header..? Date: Sun, 01 Aug 1999 00:00:00 +0000 From: bluemoon@ux6.cso.uiuc.edu (Dawn Owens-Nicholson) References: <slrn7q8u74.27q.mojo@localhost.localdomain> <slrn7q9bso.53b.mojo@localhost.localdomain> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail X-Deja-AN: 507957246 Organization: University of Illinois at Urbana-Champaign User-Agent: slrn/0.9.5.7 (UNIX) Newsgroups: news.software.readers