BSD 4_2 development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Sun, 27 Mar 1983 12:49:15 +0000 (04:49 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Sun, 27 Mar 1983 12:49:15 +0000 (04:49 -0800)
Work on file usr/src/new/new/news/cvt/cvt.clean.sh
Work on file usr/src/new/new/news/cvt/cvt.hist.c
Work on file usr/src/new/new/news/cvt/cvt.mkdirs.sh
Work on file usr/src/new/new/news/cvt/cvtactive.c

Synthesized-from: CSRG/cd1/4.2

usr/src/new/new/news/cvt/cvt.clean.sh [new file with mode: 0644]
usr/src/new/new/news/cvt/cvt.hist.c [new file with mode: 0644]
usr/src/new/new/news/cvt/cvt.mkdirs.sh [new file with mode: 0644]
usr/src/new/new/news/cvt/cvtactive.c [new file with mode: 0644]

diff --git a/usr/src/new/new/news/cvt/cvt.clean.sh b/usr/src/new/new/news/cvt/cvt.clean.sh
new file mode 100644 (file)
index 0000000..67f109e
--- /dev/null
@@ -0,0 +1,9 @@
+: "clean up after 2.10 works cleanly.  This tears down the 2.9 structure."
+: "The one parameter should be SPOOL"
+if test x$1 = x ; then
+       echo "Usage: cvt.clean /usr/spool/news" 
+       exit 1
+fi
+cd $1
+rm -f .??*
+rm -rf *.*
diff --git a/usr/src/new/new/news/cvt/cvt.hist.c b/usr/src/new/new/news/cvt/cvt.hist.c
new file mode 100644 (file)
index 0000000..2e5caf8
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Program to convert history file to dbm file.  The old 3 field
+ * history file is still kept there, because we need it for expire
+ * and for a human readable copy.  But we keep a dbm hashed copy
+ * around by message ID so we can answer the yes/no question "have
+ * we already seen this message".  The content is the ftell offset
+ * into the real history file when we get the article - you can't
+ * really do much with this because the file gets compacted.
+ */
+
+#include <stdio.h>
+
+typedef struct {
+       char *dptr;
+       int dsize;
+} datum;
+
+FILE *fd;
+
+char namebuf[BUFSIZ];
+char lb[BUFSIZ];
+
+char *index();
+
+main(argc, argv)
+char **argv;
+{
+       register char *p, *q;
+       long fpos;
+       datum lhs, rhs;
+       int rv;
+
+       if (argc != 2 ) {
+               fprintf(stderr, "Usage: cvt.hist /usr/lib/news\n");
+               exit(1);
+       }
+
+       umask(0);
+       sprintf(namebuf, "%s/history.dir", argv[1]);
+       close(creat(namebuf, 0666));
+       sprintf(namebuf, "%s/history.pag", argv[1]);
+       close(creat(namebuf, 0666));
+       sprintf(namebuf, "%s/history", argv[1]);
+
+       fd = fopen(namebuf, "r");
+       if (fd == NULL) {
+               perror(namebuf);
+               exit(2);
+       }
+
+       dbminit(namebuf);
+       while (fpos=ftell(fd), fgets(lb, BUFSIZ, fd) != NULL) {
+               p = index(lb, '\t');
+               if (p)
+                       *p = 0;
+               lhs.dptr = lb;
+               lhs.dsize = strlen(lb) + 1;
+               rhs.dptr = (char *) &fpos;
+               rhs.dsize = sizeof fpos;
+               rv = store(lhs, rhs);
+               if (rv < 0)
+                       fprintf(stderr, "store(%s) failed\n", lb);
+       }
+       exit(0);
+}
diff --git a/usr/src/new/new/news/cvt/cvt.mkdirs.sh b/usr/src/new/new/news/cvt/cvt.mkdirs.sh
new file mode 100644 (file)
index 0000000..897c074
--- /dev/null
@@ -0,0 +1,8 @@
+: "Convert from B 2.9 to 2.10 spool format, with dots turned into slashes."
+L=$1
+S=$2
+echo Do not be surprised at error messages for local or duplicate groups.
+cd $S
+cat $L/active | sed 's/\.[^.]*$//' | sort -u > parents
+mkdir `tr '.' '/' < parents`
+mkdir `tr '.' '/' < $L/active | grep /`
diff --git a/usr/src/new/new/news/cvt/cvtactive.c b/usr/src/new/new/news/cvt/cvtactive.c
new file mode 100644 (file)
index 0000000..ef717c7
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Convert from the dot files and one field active file to a
+ * two field active file.
+ */
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+char *LIB, *SPOOL;
+char oactive[100], nactive[100];
+char dotfile[100];
+char ng[100];
+FILE *ofd, *nfd;
+
+struct stat sbuf;
+
+main(argc, argv)
+char **argv;
+{
+       register char *p;
+       
+       if (argc != 3) {
+               printf("Usage: cvtdot LIB SPOOL\n");
+               exit(1);
+       }
+
+       LIB = argv[1];
+       SPOOL = argv[2];
+
+       sprintf(oactive, "%s/%s", LIB, "active");
+       sprintf(nactive, "%s/%s", LIB, "nactive");
+       ofd = fopen(oactive, "r");
+       if (ofd == NULL) {
+               fprintf(stderr, "Cannot open %s\n", oactive);
+               exit(1);
+       }
+       nfd = fopen(nactive, "w");
+       if (nfd == NULL) {
+               fprintf(stderr, "Cannot create %s\n", nactive);
+               exit(1);
+       }
+
+       while (fgets(ng, sizeof ng, ofd) != NULL) {
+               for (p=ng; *p!='\n'; p++)
+                       ;
+               *p = 0;
+               sprintf(dotfile, "%s/.%s", SPOOL, ng);
+               stat(dotfile, &sbuf);
+               fprintf(nfd, "%s %05ld\n", ng, sbuf.st_size);
+       }
+       fclose(ofd);
+       fclose(nfd);
+}