BSD 4_4_Lite2 development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Fri, 24 Jul 1992 08:03:38 +0000 (00:03 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Fri, 24 Jul 1992 08:03:38 +0000 (00:03 -0800)
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 [new file with mode: 0644]
usr/src/contrib/news/inn/lib/xmalloc.c [new file with mode: 0644]
usr/src/contrib/news/inn/lib/xrealloc.c [new file with mode: 0644]
usr/src/contrib/news/inn/samples/nnrp.access [new file with mode: 0644]
usr/src/contrib/news/inn/samples/nntpsend.ctl [new file with mode: 0644]
usr/src/contrib/news/inn/samples/passwd.nntp [new file with mode: 0644]

diff --git a/usr/src/contrib/news/inn/lib/readin.c b/usr/src/contrib/news/inn/lib/readin.c
new file mode 100644 (file)
index 0000000..d90264a
--- /dev/null
@@ -0,0 +1,91 @@
+/*  $Revision: 1.4 $
+**
+*/
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#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 (file)
index 0000000..9abb4a3
--- /dev/null
@@ -0,0 +1,25 @@
+/*  $Revision: 1.6 $
+**
+*/
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#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 (file)
index 0000000..a6ee18b
--- /dev/null
@@ -0,0 +1,26 @@
+/*  $Revision: 1.6 $
+**
+*/
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#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 (file)
index 0000000..756c7ba
--- /dev/null
@@ -0,0 +1,18 @@
+##  $Revision: 1.4 $
+##  nnrp.access - access file for on-campus NNTP sites
+##  Format:
+##     <host>:<perm>:<user>:<pass>:<groups>
+##  Connecting host must be found in this file; the last match found is
+##  used, so put defaults first.
+##     <host>          Wildcard name or IP address
+##     <perm>          R to read; P to post
+##     <user>          Username for authentication before posting
+##     <pass>          Password, for same reason
+##     <groups>        Newsgroup patterns that can be read or not read
+##  To disable posting put a space in the <user> and <pass> 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 (file)
index 0000000..9cc74f9
--- /dev/null
@@ -0,0 +1,14 @@
+##  $Revision: 1.2 $
+##  Control file for nntpsend.
+## Format:
+##     site:fqdn:max_size:[<args...>]
+##     <site>          The name used in the newsfeeds file for this site;
+##                     this determines the name of the batchfile, etc.
+##     <fqdn>          The fully-qualified domain name of the site,
+##                     passed as the parameter to innxmit.
+##     <size>          Size to truncate batchfile if it gets too big;
+##                     see trunc(1).
+##     <args>          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 (file)
index 0000000..2ddacf1
--- /dev/null
@@ -0,0 +1,14 @@
+##  $Revision: 1.4 $
+##  passwd.nntp - passwords for connecting to remote NNTP servers
+##  Format:
+##     <host>:<name>:<pass>[:<style>]
+##  Clients need only one entry, for where innd is running.  The
+##  server will have more entries for connecting to peers to feed them
+##  articles.
+##     <host>          Host this line is for.
+##     <name>          Name to use to authenticate with
+##     <pass>          Password to send, after sending name
+##     <style>         Optional authentication style, defaults to "authinfo"
+##  <name> and <pass> can be empty string; a peer innd doesn't need a
+##  <name>, for example.
+news.foo.com:rsalz:martha