Aazure.714
net.sources
utzoo!decvax!ucbvax!ARPAVAX:CAD:teklabs!tekmdp!azure!stevenm
Thu Apr 15 16:36:59 1982
Some MH Mail hooks for news
Here are some modifications to readnews (module readr.c) which
allow use of the MHMAIL 'comp' program for replying to articles,
and the similar 'submit' program (just like comp) for submitting
new or followup articles. The 'submit' program itself is included.
The modifications enclosed are to 'readr.c', 'header.c', 'defs.h',
and 'Makefile.v7'. The source and manual page for 'submit' are
also enclosed.
Note that you will have to have the MH system already for 'submit'
to compile, because it depends heavily on routines in the MH
libraries. Also note that we run the Feb 1980 release of MH Mail,
and if any of the subroutine calls made by 'submit' have changed,
it may not work.
I would like to hear from anyone who actually uses this code,
or is working on integrating MH and News, so that we can share
our work.
S. McGeady
teklabs!stevenm
#############
# readr.c #
#############
32c32
char *ptr1, *ptr2, *ptr3, *ptr4;/* for reply manipulation */
[shortly after case 'r':]
393a394,396
> ptr2 = h.ident;
> ptr3 = h.title;
> ptr4 = h.subdate;
396c399
if (*hbuf1.path) {
397a401,404
> ptr2 = hbuf1.ident;
> ptr3 = hbuf1.title;
> ptr4 = hbuf1.subdate;
> }
428a436,467
> #ifdef MHMAIL
>
> {
> char *tmpp;
> FILE *tfd;
> extern char *mktemp();
>
> tmpp = mktemp("/tmp/newsXXXXXX");
> if ((tfd = fopen(tmpp, "w")) == NULL) {
> fprintf(ofp, "Can't create tmpfile\n");
> break;
> }
>
> fprintf(tfd, "To: %s\n", rcbuf);
> fprintf(tfd, "Subject: ");
>
> if (*bptr == '\0') {
> if (strncmp(ptr3, "Re: ", 4)) {
> fprintf(tfd, "Re: ");
> }
> fprintf(tfd, "%s\n", ptr3);
> } else {
> fprintf(tfd, "%s\n", bptr);
> }
> fprintf(tfd, "In-reply-to: Your news article %s of %s\n", ptr2, ptr4);
> fprintf(tfd, "-----------------\n");
> fclose(tfd);
> sprintf(bfr, "%s %s %s", COMP, DFLAG, tmpp);
> system(bfr);
> unlink(tmpp);
> }
> #else
438a478
> #endif
440d479
#ifdef MHMAIL
> {
> char *tmpp;
> FILE *tfd;
> extern char *mktemp();
>
550a596
>
558a605,645
> while (isspace(*bptr))
> bptr++;
>
> launder(ptr2);
>
> tmpp = mktemp("/tmp/newsXXXXXX");
> if ((tfd = fopen(tmpp, "w")) == NULL) {
> fprintf(ofp, "Can't create tmpfile\n");
> break;
> }
> fprintf(tfd, "Newsgroups: %s\n", ptr2);
> sprintf(bfr, "%s %s %s", SUBMIT, DFLAG, tmpp);
> fprintf(tfd, "Subject: ");
>
> if (*bptr == '\0') {
> if (strncmp(tfilename, "Re: ", 4)) {
> fprintf(tfd, "Re: ");
> }
> fprintf(tfd, "%s\n", tfilename);
> } else {
> fprintf(tfd, "%s\n", bptr);
> }
> fprintf(tfd, "Followup-to: %s\n", ptr3);
> fprintf(tfd, "-----------------\n");
> fclose(tfd);
>
> system(bfr);
> unlink(tmpp);
> }
> #else
> tfilename = h.title;
> ptr2 = h.nbuf;
> ptr3 = h.ident;
> if (*bptr == '-') {
> if (*hbuf1.title && *hbuf1.nbuf) {
> tfilename = hbuf1.title;
> ptr2 = hbuf1.nbuf;
> ptr3 = hbuf1.ident;
> }
> bptr++;
> }
617a705
> #endif
619d706
#define SUBMT 4
104c104
case SUBMT:
181c181
return SUBMT;
#############
# defs.h #
#############
[Add these lines]
> #define MHMAIL 1
>
> #ifdef MHMAIL
> #define SUBMIT "/usr/bin/submit"
> #define COMP "/usr/bin/comp"
> #define DFLAG "-form"
> #endif
>
#############
# submit.c #
#############
/*
* this program uses the MH Mail system subroutine librarys
* found in subs.a and strings.a in /usr1/src/cmd/mh
* 'mh.h' is also there
*/
#include "mh.h"
#include <STDIO.H>
#include <STRINGS.H>
#include <SIGNAL.H>
#include <SYS/TYPES.H>
#include <SYS/STAT.H>
/*
* submit - submit a note to the Duke NewsNet news service
*
*******************************************************************
*
* 27-aug-80 sdg Written
* 02-nov-80 sdg fixed bug that inserted \n every 512 characters
*
* 6/24/81 mcg hacked from the 'post' program
*
* 7/27/81 mcg modified to take 'post' entrypoint, and to
* back the input file up in ',<INFILE>'
* changed all error messages to print argv[0]
* instead of 'submit'
*
* 12/29/81 mcg modfied for B news
*
* 4/15/82 mcg modified for 2.3 B News
*/
#define NONE 0
#define DEFAULTGROUP "general"
#define NEWSCOMPS "newscomps"
#define STDNEWSCOMPS LIBDIR/newscomps"
#define NEWSDIR SPOOLDIR"
#define NEWSDRAFT "ndraft"
#define MAXSUBJ 128
char *newsproc = "inews";
char *myname;
char *anyul[] = {
"no", 0,
"yes", 0,
"use", 0,
"list", 0,
0
};
char *any[] = {
"no", 0,
"yes", 0,
0
};
char *alfeqs[] = {
"list", 0, /* 0 */
"format", 0, /* 1 */
"edit [<EDITOR>]", 0, /* 2 */
"quit [delete]", 0, /* 3 */
"submit", 0, /* 4 */
"post", 0, /* same as submit */
0
};
struct swit switches[] = {
"editor editor", 0, /* 0 */
"form formfile", 0, /* 1 */
"use", 0, /* 2 */
"nouse", 0, /* 3 */
"dfile draftfile",0, /* 4 */
"debug", 0, /* 5 */
"help", 4, /* 6 */
0, 0
};
char *rindex();
int debug = 0;
main(argc, argv)
char *argv[];
{
register char *cp;
register int in;
register int out;
int use;
int cnt;
int status;
int intr;
char buf[BUFSIZ];
char *newsgroup;
char *ed;
char *file;
char *form;
static char path[128];
char **ap;
char *arguments[50];
char **argp;
myname = argv[0];
form = 0; use = 0; file = 0; ed = 0;
cp = r1bindex(argv[0], '/');
if((cp = m_find(cp)) != NULL) {
ap = brkstring(cp = getcpy(cp), " ", '\n');
ap = copyip(ap, arguments);
} else
ap = arguments;
copyip(argv+1, ap);
argp = arguments;
while(cp = *argp++) {
if(*cp == '-') {
switch(smatch(++cp, switches)) {
case -2:
ambigsw(cp, switches); /* ambiguous */
goto leave; /* unknown */
case -1:
fprintf(stderr, "%s: -%s unknown\n", myname, cp);
goto leave;
case 0:
if(!(ed = *argp++)) { /* -editor */
missing: fprintf(stderr, "%s: Missing argument ", myname);
fprintf(stderr, "for %s switch\n", argp[-2]);
goto leave;
}
continue;
case 1:
if(!(form = *argp++)) /* -form */
goto missing;
continue;
case 2:
use = 1;
continue; /* -use */
case 3:
use = 0;
continue; /* -nouse */
case 4:
if(!(file = *argp++)) /* -dfile */
goto missing;
continue;
case 5:
debug++;
continue; /* -debug */
case 6:
help("submit/post [switches]", switches);
goto leave;
}
}
}
if(form) {
if((in = open(m_maildir(form), 0)) = 0) {
cp = concat("\n\"", path, "\" exists; delete? ", 0);
if(use || fdcompare(in, out))
goto editit;
while((status = gans(cp, anyul)) == 3)
showfile(path);
if(status == 2) {
use++;
goto editit;
}
if(status == 0)
goto leave;
close(out);
} else if(use) {
fprintf(stderr, "%s: \"%s\" doesn't exist!\n", myname, path);
goto leave;
}
if((out = creat(path, m_gmprot())) MAXSUBJ) {
fprintf(stderr, "%s: subject field too long\n", myname);
retcode = 4;
goto leave;
}
}
fputs(buf, tfile);
break;
case FILEEOF:
goto process;
case LENERR:
case FMTERR:
fprintf(stderr, "%s: ??Message Format Error ", myname);
fprintf(stderr, "in component #%d.\n", compnum);
retcode = 6;
goto leave;
}
}
process:
fclose(tfile);
fclose(pfile);
m_update();
fflush(stdout);
if (follow) {
for (p = follow; *p; p++) {
if (*p == '\n') *p = ' ';
}
}
for (p=subjp; *p; p++) {
if (*p == '\n') *p = ' ';
}
if (!newsgroup) {
newsgroup = DEFAULTGROUP;
}
for(p=newsgroup; *p; p++) {
if (*p == ' ' || *p == '\t' || *p == '\n') {
*p = '\0';
}
}
while (*newsgroup++ == '\0');
--newsgroup;
/************
*
* This code no longer needed - mortals can't create newsgroups
*
* sprintf(tmp, "%s/%s", NEWSDIR, newsgroup);
*
* if (stat(tmp, &statb)
<HR>
This Usenet Oldnews Archive
article may be copied and distributed freely, provided:
<P>
1. There is no money collected for the text(s) of the articles.
<BR>
2. The following notice remains appended to each copy:
<P>
<EM>The Usenet Oldnews Archive: Compilation Copyright© 1981, 1996
<BR> Bruce Jones, Henry Spencer, David Wiseman.</EM>
<P>
<HR>
Goto <A HREF="82.04.15_azure.716_net.sources.html">NEXT</A> article in NET.sources Newsgroup
<BR>Return to <A HREF="NET.sources-index.html">NET.sources index</A>
<BR>Return to the
<A HREF="../index.html">Usenet Oldnews Archive index</A>
</HTML>
-----------------------------------------------------------------
gopher://quux.org/ conversion by John Goerzen <jgoerzen@complete.org>
of http://communication.ucsd.edu/A-News/
This Usenet Oldnews Archive
article may be copied and distributed freely, provided:
1. There is no money collected for the text(s) of the articles.
2. The following notice remains appended to each copy:
The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996
Bruce Jones, Henry Spencer, David Wiseman.