From: joel@crpi.UUCP (Joel C. Justen)
Newsgroups: alt.sys.amiga.uucp
Subject: Re: Cnews?  Help!
Date: Sun, 27 Sep 1992 20:54:58 EST
Organization: Crazyrat Software Productions
X-Newsreader: Arn V1.00 beta rel2

In article <1992Sep27.012941.1538@ckctpa.UUCP>, Frank "Crash" Edwards writes:

> bobl@bobsbox.rent.com (Bob Lindabury - SysAdmin) writes:
> >Well, I've setup CNews on my system and I seem to be in hell!
> 
> I take full credit (and full blame) for things that don't work in my
> port of CNews for AmigaDOS.  Before I start answering some of the
> questions that were posted, I'd like to point out that further
> changes/enhancements have pretty much come to a standstill since I've
> gotten Amiga Unix 2.1 up and running.  I just very rarely use AmigaDOS
> anymore (I'm a Unix freak -- what can I say? :-)

I'd love to be exclusively in UNIX, but owning a 500, I don't get to do
that (yet!  :))..  

> 
> >I have setup in.coming and out.going directories in NewsArts: (UUNEWS:)
> >and have also setup directories for each site that receives batches
> >inside of the out.going directory.
> 
> Good.
> 
> >RNews seems to run fine after news is transfered into my system. It then
> >produces *.z files in the in.coming directory which are processed fine
> >by the unbatch.e script.  However, this script doesn't seem to work with
> >uncompressed items.  The *.z files are uncompressed and then posted to
> >the appropriate directories, the sys file is read and appropriate togo
> >files are created in the newsarts:out.going/[system] directories.
> 
> Yes.  I presume you got the Fred Fish distribution which had incorrect
> filenames in the UnBatch.#? script(s).  Unshar the one below and see
> if it is the same as what you're using -- it's the latest one I've
> got.  (I've heard of people finding bugs in the scripts, telling me
> that they've fixed them, and then I never receive a copy.  How am I
> supposed to distribute fixed versions [for bugs I haven't seen] when I
> don't get a copy.  I've stopped trying.)
> 

Personally, I don't use any of the original batch scripts that came with
the setup.  I ended up writing new scripts (with a friend) and using those
as well as a small C program which work exclusively under 2.04.  

> >However, relaynews doesn't seem to update the .next files in the
> >NewsArts: (UUNEWS:) directories.  Is this the way it is suppose to work?
> >GRn doesn't recognize the new articles because the .next files are not
> >updated.  How can I fix this?
> 
> Yes.
> 
> I don't know what GRn expects to see in the .next file, so I can't
> tell you what to fix.  Perhaps the author of GRn would consider using
> the files provided with the stock (Unix) CNews as an option?  [The
> "active" file keeps track of new articles; and "history" contains
> information on what has been expired and what hasn't.]
> 
> Otherwise, find out what the .next files should have and execute
> another script after you do UNBATCHing which fixes those files.

I also found this really annoying, but finally realized that if a newsreader
wasn't going to support a far superior format (ie CNews with active and 
news article database) I wasn't going to use it.  I since use ARN as my
newsreader of choice..

I might be coaxed into writing a small fix to relaynews which will update
.next files for those who want it.  Shouldn't be very hard to do as all the 
.next file contains is the number of the next available file number in the 
directory.

> >Also, anything posted locally doesn't get posted.  It gets queued into
> >NewsArts:incoming as an uncompressed article and unbatch doesn't
> >recognize it.  How can I get articles posted to queue out?
> 

Take a look below at the batch program.  In the case of this program, it 
should work better than the script.  It should also work under both 
revisions of the operating system.

Also, this could be something wrong with your POSTNEWS string in your
newsreader.  Mine is

SENDNEWS    relaynews <%s -i ; %s

This causes the article to be placed in it's correct directory (in the
case of this article UUNews:alt/sys/amiga/uucp/1178.  A file is created
in my uunews:out.going/coplex (my feed site) called togo. This file
contains the string "UUNews:alt/sys/amiga/uucp/1178 5770".  The batch
program reads this togo file and creates an entry that is batched to
the feed site.

> 
> Concerning the manually created batch_#?.z files:  yes, you must
> provide the transport interface.  CNews _is not_ a transport, it's a
> message handling package.  UUCP is a transport agent.  I would suggest
> either adding a line to DoBatch.e to queue up the transfers at the end
> of the batching or run a separate program to do it after DoBatch
> finishes.

If you use my batch program, you won't have any problem with this.

> >The following batching script fails miserably.  I had to change the
> >"batcher" command line to remove the -p (prefix) option as I kept
> >getting some sort of error about prefix specified twice.  Also, if there
> >isn't any "togo" file in the system's directory, the script seems to
> >just quit when it should return back and try to process the next
> >system's togo file. Here's the Dobatch.e2 script...
> 
> Hmmm; does it do that under 2.0 or 1.3?  I don't recall having a
> problem with DoBatch.e2 causing DoBatch.e to quit prematurely.  But
> again, I think I must've munged DoBatch.e and DoBatch.e2 while trying
> to create diffs using RCS.  That's the only reason I can think of why
> both scripts should be as back-dated as they were.
> 
> Sorry for the hassles.  After I sent CNews to Fred Fish for inclusion
> in the library, I contacted C= about being a developer.  Then I
> bought an A3000 and started beta testing Amiga Unix, and I've worked
> on CNews very little since then.  But I suppose it's just as well,
> since I never hear about anyone using it (except for the 3 or 4 people
> who sent me shareware donations and to whom I apologize about neglecting
> support when I jumped into Amiga Unix).  There was little or no reason
> to continue working on it since I wasn't using it and no one else was
> either.

Since I myself paid the shareware donation and have 3 friends who use
CNews, I would like to see the problems fixed.  We have been discussing
the possibility of creating an entire new system based on CNews but have
not progressed further on it.  I hope you or someone else takes it from
here.  

Here's some of my scripts/programs:

----------------------------  Batch.c  --------------------------------

/*  Use this program at your own risk. */


#include <stdio.h>
#include <string.h>
#include <exec/memory.h>
#include <exec/io.h>

#define BATCHSIZE 50000
#define BUFF_SIZE 20000

main(argc,argv)
int argc;
char *argv[];

{
  FILE *togo, *batch, *art;
  
  char artname[256];
  char batchname[60];
  char command[100];
  char togofile[50];
  char temp[50];
  char sysid[20];
  char *buffer;
  int currartsize=0;
  int currbatsize=0;
  int batchcount=0;
  int wrotesize;
  int readsize;
  int remainsize;

  batch = NULL;

  if (argc != 2) {
      printf("Usage: %s SYSTEM\n",argv[0]);
      exit(0);
    }
  strcpy(sysid,argv[1]);
  sprintf(togofile,"UUNews:out.going/%s/togo",sysid);

  if ((togo = fopen(togofile, "r")) == NULL) {
      printf("Unable to open togo file!\n");
      exit(0);
    }
  else /* togo got opened */ {
    if ((buffer=(char *)malloc(BUFF_SIZE))==NULL)  {
        printf("Not enough memory for buffer\n");
        exit(10);
      }
    while (fscanf(togo, "%s %d\n", artname, &currartsize) == 2) {
      if (currbatsize > BATCHSIZE) {
	fclose(batch);
	procbatch(batchname,sysid);
	currbatsize = 0;
	batch = NULL;
      }
      if (!batch) {
	sprintf(batchname, "t:batch_%04d", ++batchcount);
	if ((batch = fopen(batchname, "w")) == NULL) {
	  fclose(togo);
	  printf("Unable to open batch!\n");
          free(buffer);
	  exit(10);
	}
      }
      if ((art = fopen(artname, "r")) == NULL)
	printf("Unable to open article: %s\n", artname);
      else {
	fprintf(batch, "#! rnews %ld\n", currartsize);
	remainsize = currartsize;
	while (remainsize) {
	  if (remainsize > BUFF_SIZE)
	    readsize = BUFF_SIZE;
	  else
	    readsize = remainsize;
	  remainsize = remainsize - readsize;
	  if (fread(buffer, 1, readsize, art) != readsize)
	    printf("Read from article failure!\n");
	  else if (fwrite(buffer, 1, readsize, batch) != readsize)
	    printf("Write to batch failure!\n");
	}
      }
      fclose(art);
      currbatsize += currartsize;
    }
  }
  fclose(batch);
  free(buffer);
  procbatch(batchname, sysid);
  fclose(togo);
  sprintf(command,"copy UUNews:out.going/%s/togo UUNews:out.going/togo.%s.old", sysid, sysid);
  system(command);   /*  Keep an old copy of the togo file in case of problems */
  sprintf(command,"delete uunews:out.going/%s/togo QUIET", sysid);
  system(command);
}

int
procbatch(char *batchname, char *sysid)
{
char command[100];

sprintf(command, "compress %s",batchname);
system(command);
sprintf(command, "uux %s.z %s!rnews", batchname, sysid);
system(command);
sprintf(command, "delete %s.z QUIET", batchname); 
system(command);
}


----------------------------  UnBatchNews  ----------------------------

.key type
.bra {
.ket }
;
; Primary script to process incoming news.  This file is executed after a
; successful connect to a feed site.
;
; Set the CNews lock and save our directory
;
CNewsLock
cd >Env:Dir{$$}
cd uunews:in.coming
failat 11
;
; List all file in uunews:in.coming and unbatch them in order
;
List >T:unbatch{$$}.tmp #?.z LFORMAT "UnBatchNewsFile %s"
Sort T:unbatch{$$}.tmp T:unbatch{$$}.sh >nil:
If warn
  Skip Exit
EndIf
Execute T:unbatch{$$}.sh
;
; Run ArnMaster to update the .newsdb's
;
ArnMaster >NIL:
;
; Return us to out starting directory and clean up
;
Lab Exit
Cd $Dir{$$}
Delete T:unbatch{$$}.#? QUIET
Delete Env:Dir{$$} T:CNews.lock QUIET
Quit

--------------------------  UnBatchNewsFile  -------------------------

.key file/a,type
.bra {
.ket }
;echo "Processing ... {file}" NOLINE
uncompress <{file} >t:tempfile
failat 20
relaynews <t:tempfile -r
cd uunews:in.coming
delete {file} QUIET
;echo " ... Done" 


------------------------------------------------------------------------------
     /// Joel C. Justen                |    UUNET:  uunet!coplex.com!crpi!joel
\\\ ///  System Administrator          |    BITNET: jcjust01@ulkyvx.BITNET
 \XXX/   Crazyrat Software Productions |    UUCP:   joel@crpi.UUCP
------------------------------------------------------------------------------
flames <NIL: >NIL: | "This is *MY* damn amiga and I'll say what I want to say!"