From 2f1cc56dd0f855265e1558600c4ab104525b0456 Mon Sep 17 00:00:00 2001 From: CSRG Date: Fri, 24 Jul 1992 00:03:38 -0800 Subject: [PATCH] BSD 4_4_Lite2 development Work on file usr/src/contrib/news/inn/samples/nnrp.access Work on file usr/src/contrib/news/inn/samples/nntpsend.ctl Work on file usr/src/contrib/news/inn/samples/passwd.nntp Work on file usr/src/contrib/news/inn/lib/readin.c Work on file usr/src/contrib/news/inn/lib/xmalloc.c Work on file usr/src/contrib/news/inn/lib/xrealloc.c Synthesized-from: CSRG/cd3/4.4BSD-Lite2 --- usr/src/contrib/news/inn/lib/readin.c | 91 +++++++++++++++++++ usr/src/contrib/news/inn/lib/xmalloc.c | 25 +++++ usr/src/contrib/news/inn/lib/xrealloc.c | 26 ++++++ usr/src/contrib/news/inn/samples/nnrp.access | 18 ++++ usr/src/contrib/news/inn/samples/nntpsend.ctl | 14 +++ usr/src/contrib/news/inn/samples/passwd.nntp | 14 +++ 6 files changed, 188 insertions(+) create mode 100644 usr/src/contrib/news/inn/lib/readin.c create mode 100644 usr/src/contrib/news/inn/lib/xmalloc.c create mode 100644 usr/src/contrib/news/inn/lib/xrealloc.c create mode 100644 usr/src/contrib/news/inn/samples/nnrp.access create mode 100644 usr/src/contrib/news/inn/samples/nntpsend.ctl create mode 100644 usr/src/contrib/news/inn/samples/passwd.nntp diff --git a/usr/src/contrib/news/inn/lib/readin.c b/usr/src/contrib/news/inn/lib/readin.c new file mode 100644 index 0000000000..d90264a23d --- /dev/null +++ b/usr/src/contrib/news/inn/lib/readin.c @@ -0,0 +1,91 @@ +/* $Revision: 1.4 $ +** +*/ +#include +#include +#include +#include +#include +#include "configdata.h" +#include "libinn.h" +#include "clibrary.h" +#include "macros.h" + + +/* +** Read a big amount, looping until it is all done. Return TRUE if +** successful. +*/ +int +xread(fd, p, i) + register int fd; + register char *p; + register off_t i; +{ + register int count; + + for ( ; i; p += count, i -= count) + if ((count = read(fd, p, (SIZE_T)i)) <= 0) + return -1; + return 0; +} + + +/* +** Read an already-open file into memory. +*/ +char * +ReadInDescriptor(fd, Sbp) + int fd; + struct stat *Sbp; +{ + struct stat mystat; + char *p; + int oerrno; + + if (Sbp == NULL) + Sbp = &mystat; + + /* Get the size, and enough memory. */ + if (fstat(fd, Sbp) < 0) { + oerrno = errno; + (void)close(fd); + errno = oerrno; + return NULL; + } + p = NEW(char, Sbp->st_size + 1); + + /* Slurp, slurp. */ + if (xread(fd, p, Sbp->st_size) < 0) { + oerrno = errno; + DISPOSE(p); + (void)close(fd); + errno = oerrno; + return NULL; + } + + /* Terminate the string; terminate the routine. */ + p[Sbp->st_size] = '\0'; + return p; +} + + +/* +** Read a file into allocated memory. Optionally fill in the stat(2) data. +** Return a pointer to the file contents, or NULL on error. +*/ +char * +ReadInFile(name, Sbp) + char *name; + struct stat *Sbp; +{ + char *p; + int fd; + + if ((fd = open(name, O_RDONLY)) < 0) + return NULL; + + p = ReadInDescriptor(fd, Sbp); + (void)close(fd); + return p; +} diff --git a/usr/src/contrib/news/inn/lib/xmalloc.c b/usr/src/contrib/news/inn/lib/xmalloc.c new file mode 100644 index 0000000000..9abb4a3369 --- /dev/null +++ b/usr/src/contrib/news/inn/lib/xmalloc.c @@ -0,0 +1,25 @@ +/* $Revision: 1.6 $ +** +*/ +#include +#include +#include +#include "configdata.h" +#include "libinn.h" +#include "clibrary.h" +#include "macros.h" + + +/* +** Allocate some memory or call the memory failure handler. +*/ +ALIGNPTR +xmalloc(i) + unsigned int i; +{ + POINTER new; + + while ((new = malloc(i)) == NULL) + (*xmemfailure)("malloc", i); + return CAST(ALIGNPTR, new); +} diff --git a/usr/src/contrib/news/inn/lib/xrealloc.c b/usr/src/contrib/news/inn/lib/xrealloc.c new file mode 100644 index 0000000000..a6ee18bb73 --- /dev/null +++ b/usr/src/contrib/news/inn/lib/xrealloc.c @@ -0,0 +1,26 @@ +/* $Revision: 1.6 $ +** +*/ +#include +#include +#include +#include "configdata.h" +#include "libinn.h" +#include "clibrary.h" +#include "macros.h" + + +/* +** Reallocate some memory or call the memory failure handler. +*/ +ALIGNPTR +xrealloc(p, i) + char *p; + unsigned int i; +{ + POINTER new; + + while ((new = realloc((POINTER)p, i)) == NULL) + (*xmemfailure)("remalloc", i); + return CAST(ALIGNPTR, new); +} diff --git a/usr/src/contrib/news/inn/samples/nnrp.access b/usr/src/contrib/news/inn/samples/nnrp.access new file mode 100644 index 0000000000..756c7ba4ae --- /dev/null +++ b/usr/src/contrib/news/inn/samples/nnrp.access @@ -0,0 +1,18 @@ +## $Revision: 1.4 $ +## nnrp.access - access file for on-campus NNTP sites +## Format: +## :::: +## Connecting host must be found in this file; the last match found is +## used, so put defaults first. +## Wildcard name or IP address +## R to read; P to post +## Username for authentication before posting +## Password, for same reason +## Newsgroup patterns that can be read or not read +## To disable posting put a space in the and fields, since +## there is no way for client to enter one. +## +## Default is no access, no way to authentication, and no groups. +*:: -no- : -no- :!* +## Foo, Incorporated, hosts have no password, can read anything. +*.foo.com:Read Post:::* diff --git a/usr/src/contrib/news/inn/samples/nntpsend.ctl b/usr/src/contrib/news/inn/samples/nntpsend.ctl new file mode 100644 index 0000000000..9cc74f9c5e --- /dev/null +++ b/usr/src/contrib/news/inn/samples/nntpsend.ctl @@ -0,0 +1,14 @@ +## $Revision: 1.2 $ +## Control file for nntpsend. +## Format: +## site:fqdn:max_size:[] +## The name used in the newsfeeds file for this site; +## this determines the name of the batchfile, etc. +## The fully-qualified domain name of the site, +## passed as the parameter to innxmit. +## Size to truncate batchfile if it gets too big; +## see trunc(1). +## Other args to pass to innxmit +## Everything after the pound sign is ignored. +nsavax:erehwon.nsavax.gov::-S -t60 +walldrug:walldrug.com:1m:-T1800 -t300 diff --git a/usr/src/contrib/news/inn/samples/passwd.nntp b/usr/src/contrib/news/inn/samples/passwd.nntp new file mode 100644 index 0000000000..2ddacf1105 --- /dev/null +++ b/usr/src/contrib/news/inn/samples/passwd.nntp @@ -0,0 +1,14 @@ +## $Revision: 1.4 $ +## passwd.nntp - passwords for connecting to remote NNTP servers +## Format: +## ::[: