Re: Signature
Ivan Popovski <[email protected]>
| Newsgroups | gmane.network.slrn.user |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Feb 21, 2008 at 09:45:22AM +1000, Troy Piggins wrote:
>
> I'd be interested to see what you've come up with. Please post to the list.
Ok dont be cruel, this is my first slang script, and I didnt have time
to polish it (exams atm). If you find error pls let me know :)
Oh and it is working so me happy :p
define random_sig ()
{
variable str, pd, fd, buf;
variable signature_file = get_variable_value ("signature");
variable matched, pos, len;
; matched = string_match(signature_file, "\\([a-z]+\\)\\(\|\\)", 1);
matched = string_match(signature_file, "^\\(.+\\)\\(\|\\)$", 1);
if (matched)
{
(pos, len) = string_match_nth(2);
if(pos)
{
set_string_variable("signature", ".sigtmp");
str = strtrans (signature_file, "|", "");
pd=popen(str,"r");
if (pd == NULL) return;
fd=fopen(".sigtmp","w");
if (fd == NULL) { pclose(pd); return; }
while (-1 != fgets (&buf, pd)) {
if ((-1 == fputs (buf, fd))) { pclose(pd); fclose(fd); return; }
}
pclose(pd);
fclose(fd);
}
return;
}
}
() = register_hook ("post_hook", "random_sig");
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/