rsalz@bbn.com (Rich Salz) (06/23/91)
In <scs.677425398@wotan.iti.org> scs@iti.org (Steve Simmons) writes: >Good point. What we really need is a "standard library" that will do >syntax checking on article headers. This is amazingly trivial to do. The inews that comes with InterNetNews copies all headers into a table: typedef enum _HEADERTYPE { HTobs, /* obsolete header */ HTreq, /* required header */ HTstd /* standard header */ } HEADERTYPE; typedef struct _HEADER { char *Name; BOOL CanSet; HEADERTYPE Type; char *Value; } HEADER; The table has entries like this: { "Path", FALSE, HTstd } { "Subject", TRUE, HTreq } Scan the article, fill in the table. Run through it once to make sure the user didn't try to specify any headers where HEADER.CanSet == FALSE. Make sure that Header.Value != NULL for all entries where HEADER.Type == HTreq. If the put a From, add a Sender. Verify the newsgroups, and send the article as mail if any are moderated and there is no approved line. Add a Date, MessageID (if needed), a Path, Lines, and you're all set. The whole thing can be done in roughly 118 lines, not counting the table-building. Code will be freely redistributable in early August. /r$ -- Please send comp.sources.unix-related mail to rsalz@uunet.uu.net. Use a domain-based address or give alternate paths, or you may lose out.