leres@ace.ee.lbl.gov (Craig Leres) (08/28/90)
Nick Sayer recently posted his patch that causes to bnews to generate cnews style message-id's. I've done the opposite; appended is the (unoffical) cnews program I wrote last week to generate bnews style message-id's. Craig ------ #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # Makefile # uniqmsgid.8 # uniqmsgid.c # PATCH.anne.jones # This archive created: Mon Aug 27 19:54:06 1990 export PATH; PATH=/bin:$PATH echo shar: extracting "'Makefile'" '(510 characters)' if test -f 'Makefile' then echo shar: will not over-write existing file "'Makefile'" else sed 's/^X//' << \SHAR_EOF > 'Makefile' X# @(#) $Header: Makefile,v 1.3 90/08/27 19:46:15 leres Exp $ (LBL) X XINCL= -I../include XCFLAGS= -g ${INCL} X#CC= gcc -g -fstrength-reduce -fcombine-regs -finline-functions -fpcc-struct-return XLIBS= ../libcnews.a X Xall: uniqmsgid X Xuniqmsgid: uniqmsgid.c X ${CC} ${CFLAGS} uniqmsgid.c -o uniqmsgid ${LIBS} X Xinstall: uniqmsgid X install -m 775 uniqmsgid /usr/new/lib/news/bin X Xshar: X shar -v -c -p X Makefile uniqmsgid.8 uniqmsgid.c PATCH.anne.jones > \ X uniqmsgid.shar X Xclean: X rm -f uniqmsgid uniqmsgid.shar *.o SHAR_EOF if test 510 -ne "`wc -c < 'Makefile'`" then echo shar: error transmitting "'Makefile'" '(should have been 510 characters)' fi fi # end of overwriting check echo shar: extracting "'uniqmsgid.8'" '(856 characters)' if test -f 'uniqmsgid.8' then echo shar: will not over-write existing file "'uniqmsgid.8'" else sed 's/^X//' << \SHAR_EOF > 'uniqmsgid.8' X.\" @(#) $Header: uniqmsgid.8,v 1.1 90/08/27 19:46:24 leres Exp $ (LBL) X.\" =()<.ds b @<NEWSBIN>@>()= X.ds b /usr/new/lib/news/bin X.\" =()<.ds c @<NEWSCTL>@>()= X.ds c /usr/new/lib/news X.TH UNIQTIME 1 "27 Aug 1990" X.BY "C News" X.SH NAME Xuniqtime \- bnews style message-id generator X.SH SYNOPSIS X.B \*b/uniqmsgid X.SH DESCRIPTION X.I Uniqtime Xoutputs a unique, bnews style message-id to stdout. X.SH FILES X.B \*c/seq sequence number file X.SH SEE ALSO Xinews(1), news(5), newsaux(8). X.SH DIAGNOSTICS X.I Uniqtime Xexits with status 1 if it is unable to generate a message-id. XIt syslog's the reason for failure. X.SH HISTORY XWritten at the Lawrence Berkeley Laboratory by Craig Leres (with Xripoffs from the bnews module ifuncs.c). X.SH BUGS XCurrently, X.I uniqtime Xuses newslock()/newsunlock() to do its locking. It's probably only Xnecessary to lock the sequence file. SHAR_EOF if test 856 -ne "`wc -c < 'uniqmsgid.8'`" then echo shar: error transmitting "'uniqmsgid.8'" '(should have been 856 characters)' fi fi # end of overwriting check echo shar: extracting "'uniqmsgid.c'" '(1145 characters)' if test -f 'uniqmsgid.c' then echo shar: will not over-write existing file "'uniqmsgid.c'" else sed 's/^X//' << \SHAR_EOF > 'uniqmsgid.c' X#ifndef lint Xstatic char rcsid[] = X "@(#) $Header: uniqmsgid.c,v 1.2 90/08/21 19:01:56 leres Exp $ (LBL)"; X#endif X X#include <stdio.h> X#include <syslog.h> X#include "config.h" X Xchar *progname; Xstatic void bail(); Xextern char *strsave(); X Xmain(argc, argv) X int argc; X char **argv; X{ X register FILE *fp; X register int seqn; X register char *seqfile; X register char *fmt = "%ld\n"; X char buf[512]; X X openlog("uniqmsgid", 0, LOG_NEWS); X progname = argv[0]; X seqfile = strsave(ctlfile("seq")); X newslock(); X if ((fp = fopen(seqfile, "r+w")) == NULL) X bail("fopen", seqfile); X if (fgets(buf, sizeof(buf), fp) == NULL) X bail("fgets", seqfile); X seqn = atol(buf) + 1; X if (fseek(fp, 0L, 0) < 0) X bail("fseek", seqfile); X if (fprintf(fp, fmt, seqn) == EOF) X bail("fprintf", seqfile); X if (ferror(fp)) X bail("ferror", seqfile); X if (fclose(fp) == EOF) X bail("fclose", seqfile); X newsunlock(); X printf(fmt, seqn); X exit(0); X} X Xstatic void Xbail(msg, seqfile) X char *msg, *seqfile; X{ X newsunlock(); X syslog(LOG_ERR, "%s: %s: %m", msg, seqfile); X exit(1); X} X Xvoid Xunprivileged(reason) Xchar *reason; X{ X syslog(LOG_WARNING, "unprivileged: %s", reason); X} SHAR_EOF if test 1145 -ne "`wc -c < 'uniqmsgid.c'`" then echo shar: error transmitting "'uniqmsgid.c'" '(should have been 1145 characters)' fi fi # end of overwriting check echo shar: extracting "'PATCH.anne.jones'" '(776 characters)' if test -f 'PATCH.anne.jones' then echo shar: will not over-write existing file "'PATCH.anne.jones'" else sed 's/^X//' << \SHAR_EOF > 'PATCH.anne.jones' XRCS file: RCS/anne.jones,v Xretrieving revision 1.3 Xdiff -c -r1.3 anne.jones X*** /tmp/,RCSt1a14830 Mon Aug 27 19:22:26 1990 X--- anne.jones Tue Aug 21 18:40:35 1990 X*************** X*** 122,125 **** X deffrom="$FROM" defsender="$SENDER" deforg="$deforg" \ X defdate="` set $date; echo $1, $3 $2 \` echo $6 | sed 's/^..//' \` $4 $5`" \ X deflocaldate="` set $localdate; echo $1, $3 $2 \` echo $6 | sed 's/^..//' \` $4 $5`" \ X! defmsgid="`set $date; echo \<$6$2$3.\` echo $4 | tr -d : \`.$$@$host\>`" - X--- 122,125 ---- X deffrom="$FROM" defsender="$SENDER" deforg="$deforg" \ X defdate="` set $date; echo $1, $3 $2 \` echo $6 | sed 's/^..//' \` $4 $5`" \ X deflocaldate="` set $localdate; echo $1, $3 $2 \` echo $6 | sed 's/^..//' \` $4 $5`" \ X! defmsgid="<`uniqmsgid`@$host>" - SHAR_EOF if test 776 -ne "`wc -c < 'PATCH.anne.jones'`" then echo shar: error transmitting "'PATCH.anne.jones'" '(should have been 776 characters)' fi fi # end of overwriting check # End of shell archive exit 0