🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #44628

Re: SLRN, can hooks be useed?

#44628
From: John E. Davis
Date: Wed, 18 Nov 1998 00:00
114 lines
3221 bytes
On 18 Nov 98 17:12:38 GMT, Peppe <c928400@student.dtu.dk>
wrote:
>    set signature	.signature
>    set editor_command	"getsig>~/.signature; vim -c ':0;/^$/+' '%s'"

I think that the most elegant solution is to make .signature a named
pipe.  Then create a signature process, e.g., a modification of
getsig, that waits for something to open .signature, at which point
the process would write something to the pipe and then close it.  For
example, consider the following `silly' program (silly.c follows below).
(Note also that this will not work across NFS, which does not
implement named pipes).

# ls -l /tmp/XXXX
/bin/ls: /tmp/XXXX: No such file or directory
# gcc silly.c -o silly
# ./silly /tmp/XXXX &
[2] 5864
# ls -l /tmp/XXXX
prw-r--r--   1 davis    asc             0 Nov 18 13:51 /tmp/XXXX|
# cat /tmp/XXXX
Signature 1
# cat /tmp/XXXX
Signature 2
# cat /tmp/XXXX
Signature 3
# cat /tmp/XXXX
Signature 4
# cat /tmp/XXXX
Signature 5
# cat /tmp/XXXX
Signature 1
# cat /tmp/XXXX
Signature 2
# cat /tmp/XXXX
Signature 3
# cat /tmp/XXXX
Signature 4
# cat /tmp/XXXX
Signature 5


I think you get the idea.  Here is silly.c.  I do not know why `sleep'
is required.  Perhaps someone will tell me.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>

static int write_signature (char *file, char *sig)
{
   FILE *fp;
   
   if (NULL == (fp = fopen (file, "w")))
     {
	fprintf (stderr, "Unable to open %s\n", file);
	return -1;
     }
   
   (void) fputs (sig, fp);
   (void) fclose (fp);
   
   sleep (2);
   return 0;
}

   
			     
static char *Silly_Signatures[] = 
{
   "Signature 1\n",
   "Signature 2\n",
   "Signature 3\n",
   "Signature 4\n",
   "Signature 5\n",
   NULL
};

int main (int argc, char **argv)
{
   char *file;
   char **sig;

   if (argc != 2)
     {
	fprintf (stderr, "Usage: %s SIGNATURE-NAMED-PIPE\n", argv[0]);
	return 1;
     }
   file = argv[1];
   
   (void) remove (file);
   if (-1 == mkfifo (file, 0666))
     {
	fprintf (stderr, "Unable to create %s\n", file);
	return 1;
     }
   
   while (1)
     {
	sig = Silly_Signatures;
	while (*sig != NULL)
	  {
	     if (-1 == write_signature (file, *sig))
	       return 1;
	     sig++;
	  }
     }
}


Technical Details
Message-ID: <slrn756666.5cl.davis@aluche.mit.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-mail
References: <slrn755pk0.2kf.toby@g0ucu.ampr.org> <slrn755vvg.dh.c928400@urdybet.bergsoe.dtu.dk>

Show Full Headers
Complete Article Headers
Message-ID: <slrn756666.5cl.davis@aluche.mit.edu>
Subject: Re: SLRN, can hooks be useed?
Date: Wed, 18 Nov 1998 00:00:00 +0000
From: davis@space.mit.edu (John E. Davis)
References: <slrn755pk0.2kf.toby@g0ucu.ampr.org> <slrn755vvg.dh.c928400@urdybet.bergsoe.dtu.dk>
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: 413229889
X-Complaints-To: usenet@eecs-usenet-02.mit.edu
X-Trace: eecs-usenet-02.mit.edu 911415497 13652 18.75.2.45 (18 Nov 1998 18:58:17 GMT)
Organization: Center for Space Research
User-Agent: slrn/0.9.5.4 (UNIX)
Reply-To: davis@space.mit.edu
NNTP-Posting-Date: 18 Nov 1998 18:58:17 GMT
Newsgroups: news.software.readers