Article View: news.software.readers
Article #127301Re: slrn - Will it show uptime like Mutt?
From: Emmanuele Bassi
Date: Sun, 29 Jun 2003 10:58
Date: Sun, 29 Jun 2003 10:58
108 lines
4703 bytes
4703 bytes
* surtin [2003-06-29 06:15]:
>> header line when I use it.
>
> The code erases all of the other custom headers you would've had and replaces
> them with X-Uptime. I tried to use the macro and it killed my X-Face... anyone
> know a work around?
Since that macro is quite old, more than a "work around", it should need
an update.
The macro is untested. It works by simply adding new headers to the
"Headers" variable.
I'm afraid it could collide with my "Identity" macro, and with every
other macro that pokes around with headers... Other than that, it should
work (did I mention it is untested? :-))
#v+
% This macro needs SLRN >= 0.9.7.3 and S-Lang > 1.4.x
implements("myheaders");
% Variables {{{
private variable
custom_headers_dfl,
followup_headers_dfl,
private variable
Headers = Assoc_Tyoe [];
%}}}
% Custom headers: the key in the associative array is the header name,
% whilst the value is the command that should be used to generate the
% header's payload. Using the "set_preference" function by J.B.
% Nicholson-Owens, it should be easy to add more custom headers without
% actually touching this macro every time.
Headers["X-Uptime"] = "uptime";
Headers["X-OS-Name"] = "uname -sr";
private define get_command(command) %{{{
{
variable cmd_fp, output;
cmd_fp = popen(command, "r");
if (NULL == cmd_fp)
return "";
output = strjoin(fgetslines(cmd_fp), "");
return output;
} %}}}
private define retrieve_default() %{{{
{
custom_headers_dfl = get_variable_value("custom_headers");
followup_headers_dfl = get_variable_value("followup_custom_headers");
} %}}}
static define add_command_header() %{{{
{
variable custom_headers = custom_headers_dfl;
variable followup_headers = followup_headers_dfl
!if (0 == strlen(custom_headers))
custom_headers = custom_headers + "\n";
!if (0 == strlen(followup_headers))
followup_headers = followup_headers + "\n";
foreach (Headers) using ("keys")
{
variable name = ();
variable payload = get_command(Headers[name]);
!if (0 == strlen(payload))
{
custom_headers = sprintf("%s%s: %s\n",
custom_headers,
name, payload);
followup_headers = sprintf("%s%s: %s\n",
followup_headers,
name, payload);
}
}
set_string_variable("custom_headers", custom_headers);
set_string_variable("followup_headers", followup_headers);
} %}}}
% Register hooks {{{
!if (1 == register_hook("startup_hook", "myheaders->retrieve_default"))
error ("register_hook(startup_hook) for retrieve_default failed");
!if (1 == register_hook("post_hook", "myheaders->add_command_header"))
error ("register_hook(post_hook) for add_command_header failed");
!if (1 == register_hook("followup_hook", "myheaders->add_command_header"))
error ("register_hook(followup_hook) for add_command_header failed");
%}}}
#v-
I'll give it a test later, just to be sure it doesn't turn your box into
a microwave oven...
Bye,
Emmanuele.
--
Emmanuele Bassi [ http://digilander.libero.it/ebassi/slrn.html ]
GnuPG Key fingerprint = 4DD0 C90D 4070 F071 5738 08BD 8ECC DB8F A432 0FF4
Technical Details
Message-ID:
<slrnbfthi6.5fv.zefram@wolverine.lohacker.net>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!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.infostrada.it!twister2.libero.it.POSTED!not-for-mailReferences:
<5b5d4e99f7010bc79d6f175b05231f5a@free.teranews.com> <slrnbfrlo2.aia.mark_usenet@bubble.markhill.me.uk> <2c8b5b5781cd49e472818395d8a46aa5@free.teranews.com> <k0j1t-m62.ln1@news.gates_of_hell.INVALID> <0f3aae932af5b69aaae9ca9cab521c94@free.teranews.com> <slrnbfspse.325.surtin@who.ate.a.boat.that.floats.org>Show Full Headers
Complete Article Headers
Message-ID: <slrnbfthi6.5fv.zefram@wolverine.lohacker.net>
Subject: Re: slrn - Will it show uptime like Mutt?
Date: Sun, 29 Jun 2003 10:58:33 GMT
From: Emmanuele Bassi <zefram@wolverine.lohacker.home>
References: <5b5d4e99f7010bc79d6f175b05231f5a@free.teranews.com> <slrnbfrlo2.aia.mark_usenet@bubble.markhill.me.uk> <2c8b5b5781cd49e472818395d8a46aa5@free.teranews.com> <k0j1t-m62.ln1@news.gates_of_hell.INVALID> <0f3aae932af5b69aaae9ca9cab521c94@free.teranews.com> <slrnbfspse.325.surtin@who.ate.a.boat.that.floats.org>
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!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.infostrada.it!twister2.libero.it.POSTED!not-for-mail
Newsgroups: news.software.readers
Lines: 107
Reply-To: Emmanuele Bassi <emmanuele.bassi@iol.it>
X-Face: &2.Q,Qgj{KA*q4G%p`*s`1f!hjGTi-9~Ju,L^d#P49tt}?jS(h@;s/K/]gc?bi-9=>%E\6#?o&[Kmng:@W+8W4y6dCuyl?L>k3i7D
User-Agent: slrn/0.9.7.4pl1-eb2 (Linux)
NNTP-Posting-Host: 151.29.209.50
X-Complaints-To: abuse@libero.it
X-Trace: twister2.libero.it 1056884313 151.29.209.50 (Sun, 29 Jun 2003 12:58:33 MET DST)
NNTP-Posting-Date: Sun, 29 Jun 2003 12:58:33 MET DST
Organization: [Infostrada]