From mcshh.Hanse.DE!uunet.UU.NET!coplex!crp!joel Sun Oct 18 02:40:44 UTC 1992
Return-Path: <mcshh!mail.germany.eu.net!uunet.UU.NET!coplex!crp!joel>
Received: by hactar (hactar.hanse.de) for wusel@hactar
	  (Amiga1.02l8*hactar-118r) with UUCP from mcshh.Hanse.DE 
	  id <m0mgQZQ-0000jIj@hactar.hanse.de>; Sun, 18 Oct 1992 02:40:44 UTC
Received: by mcshh.Hanse.DE; Sun, 18 Oct 1992 02:40:44 UTC
MTA-Warning: Preceding header rewritten due to violation(s) of RFC 822:
	     Message-ID not bracketed by <>
	     illegal `date-time' "Sat, 17 Oct 92 05:53 MEZ; "
 Received: by mcshh.Hanse.DE from relay1.UU.NET  Via smtp
	id m0mg6A7-0002Z6C; Sat, 17 Oct 92 05:53 MEZ; (Smail3.1.28.1)
Received: by relay1.UU.NET; Sat, 17 Oct 92 00:52:27 -0400
MTA-Warning: Preceding header rewritten due to violation(s) of RFC 822:
	     Message-ID not bracketed by <>
 Received: from uunet.uu.net (via LOCALHOST.UU.NET) by relay1.UU.NET with SMTP 
	(5.61/UUNET-internet-primary) id AA05693; Sat, 17 Oct 92 00:52:27 -0400
Received: by uunet.uu.net; Sat, 17 Oct 1992 00:51:48 EDT
MTA-Warning: Preceding header rewritten due to violation(s) of RFC 822:
	     Message-ID not bracketed by <>
 Received: from coplex.UUCP by uunet.uu.net with UUCP/RMAIL
	(queueing-rmail) id 005148.10396; Sat, 17 Oct 1992 00:51:48 EDT
Received: by coplex.com (/\==/\ Smail3.1.25.1 #25.1)
	id <m0mg4YU-0000BaC@coplex.com>; Fri, 16 Oct 92 23:10 EDT
Received: by crp.UUCP; Thu, 15 Oct 92 16:06:59 EST
MTA-Warning: Preceding header rewritten due to violation(s) of RFC 822:
	     Message-ID not bracketed by <>
 Received: by crp.UUCP (V1.15/Amiga)
	id AA009gq; Thu, 15 Oct 92 16:06:59 EST
In-Reply-To: <m0mdBhx-0000hzF@hactar.hanse.de>
X-Mailer: //\\miga Electronic Mail (AmiElm 1.13)
Organization: Crazyrat Software Productions
Reply-To: crpi!joel@uunet.UU.NET
X-Charset: usa
Message-Id: <9210152106.AA009gq@crp.UUCP>
Date: Thu, 15 Oct 92 16:06:59 EST
From: crp!joel@uunet.UU.NET (Joel C. Justen)
To: uunet!hactar.hanse.de!wusel@uunet.UU.NET
Subject: Re: CNews and Tin - Sources available - Who are the keepers?
X-Status: O

Hello Kai, in <m0mdBhx-0000hzF@hactar.hanse.de> on Oct 9 you wrote:

>      Ok, hope  to hear from you soon =:-> (Gee, never though that there was
> such a interest in CNews ...)
> 			kai

Enclosed is a couple of scripts/programs I use locally under WB 2.0 (2.1).
Feel free to include any of them in a cnews distribution.  I would like
to see CNews take a different face..  The underlying mechanism for CNews
(active file and article history) works very well, but the external one
needs quite a bit of work..  We're not working on a bland no-graphics
unix station here..this is an amiga, and I want to see amiga-tized programs
to do my news handling.  It could be cleaned up quite a bit..hope to see
that for the next amiga release..

---------------

---   OLD/batchnews  { Everything in the OLD directory is stuff that used to work,
                       but not well.  Feel free to look it over/use it if you wish.
                     }

.key none
.bra {
.ket }
;
; Primary script to batch out going news to other sites 
;
cd >Env:Dir{$$}
list >T:batch{$$}.tmp uunews:out.going/#? lformat "BatchNewsSys %s" 
sort T:batch{$$}.tmp T:batch{$$}.sh
execute T:batch{$$}.sh
cd $Dir{$$}
delete Env:Dir{$$} T:batch{$$}.#? quiet

---   OLD/batchnewssys

.key sys
.bra {
.ket }
cd uunews:out.going/{sys}
if exists togo
  rename togo togo.tmp
  c:replace <togo.tmp >togo.{sys} "UUNews:" ""
  failat 11
  batcher -S {sys} -f togo.{sys}
  list >T:batch{$$}.tmp1 batch_???? lformat "compress %s%s"
  list >T:batch{$$}.tmp2 batch_???? lformat "delete %s"
  sort T:batch{$$}.tmp1 T:batch{$$}.cmp
  execute T:batch{$$}.cmp
  sort T:batch{$$}.tmp2 T:batch{$$}.cmp2
  execute T:batch{$$}.cmp2
delete T:batch{$$}.cmp T:batch{$$}.cmp2 T:batch{$$}.tmp1 T:batch{$$}.tmp2 togo.tmp quiet
  endif 

---    OLD/BatchTo  { This script was replaced by the following program. }

.key sys
.bra {
.ket }

if exists uunews:in.coming
  cd uunews:in.coming
  List ~(#?.#?) FILES QUICK TO t:incoming.a LFORMAT "unbatchnewsfile %s"
  failat 10
  execute >nil: t:incoming.a
endif

if exists uunews:out.going/{sys}
  cd uunews:out.going/{sys}
  if exists togo
    batchnewssys {sys}
  endif
endif

copy togo.{sys} /togo.{sys}.old
List FILES QUICK TO t:incoming.b LFORMAT "uux %s {sys}!rnews"
execute >nil: t:incoming.b
if not WARN
  delete uunews:out.going/{sys}/#?.Z
  delete uunews:out.going/{sys}/togo.{sys}
endif

delete t:incoming.a t:incoming.b quiet

---   batch.c

#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);
  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);
}

---  OLD/CNewsLock

LAB Check_Again
If EXISTS T:Cnews.lock
	Wait 65
	Skip Back Check_Again
EndIf
Echo >T:Cnews.lock "locked"

---  DoExpire

.key VAR
.bra {
.ket }

cnewslock
changetaskpri PRIORITY=-1
expire >NIL: -v -l UULib:News/Expire.{VAR}

Delete Quiet T:Cnews.lock uulib:News/(log|errlog)
Copy UULib:News/active uulib:news/active.old

;arnmaster >NIL:
changetaskpri PRIORITY=0

---  UULib:News/Expire.d  { Daily expire of news }

# :ts=8
# hold onto history lines 14 days
/bounds/			x	14-14-14        -

# no article gets more than 6 days
/expired/			x	0-14-14		-

# real noise gets thrown away fast
# (handled by "all" below)
junk,control			x	0-0-0		-

# unmoderated groups get 7 days, moderated ones 7 also
# comp				x	7		-
misc.forsale.computers          x      2-2-2            -
comp.sys.amiga.marketplace      x      2-2-2            -
news.groups                     x      2-2-2            -
all				x      14-14-14	        -


---  OLD/Poll   {  Could never get this to work correctly.  Needs work. }

.key hostname/A,tries/A,delay
.bra {
.ket }
;
; Batch news to coplex
Failat 11
Batch coplex >NIL:
;
;  Keep track of how many times we've tried
;
SetEnv Poll{hostname} 1
;
; Will be deleted if the connection was successful
;
Echo >uuspool:C.{hostname}DUMMY
;
; Call every two minutes until we connect or get tired
;
Lab Loop
Echo "Call #" NOLINE
Echo $Poll{hostname} NOLINE
Echo " of " NOLINE
Echo {tries} NOLINE
Echo " started at " NOLINE
Date
;
; Make the call
;
uucico -s{hostname}
;
; Increment our attempt counter
;
Eval <Env:Poll{hostname} >NIL: TO T:PollTemp{$$} value2=1 op=+ ?
Copy T:PollTemp{$$} Env:Poll{hostname} quiet
Delete T:PollTemp{$$} quiet
;
; Are we done trying?
;
If $Poll{hostname} NOT GT {tries}
; Did we connect?
  If exists uuspool:C.{hostname}DUMMY
;   If not, try again later
    Wait {delay} min
    Skip back Loop
  Else
    Skip Connected
  Endif
Endif
;
; Cleanup
;
Delete Env:Poll{hostname} quiet
Quit
;
; Here's where we go once we've connected
;
Lab Connected
;
; Check to see if uuxqt is still running
;
If exists t:UUXQT.lock
  Wait 1 min
  Skip back Connected
Endif
;
; Unbatch any news we may have recieved
;
UnBatchNews >NIL:
Quit


---  UUIO  { What I currently use to call out. }

; $Ver UUIO 1.0 5-23-92
;
Batch coplex >NIL:
;
Poll.mine coplex
; check for connection complete
lab connected
if exists env:retrycoplex
  wait 2 min
  Skip connected BACK
endif
; check for uuxqt still running
lab unbatching
if exists t:UUXQT.LOCK
  wait 2 min
  Skip unbatching BACK
endif
;
changetaskpri PRIORITY=-1
unbatchnews <NIL: >NIL:
wait 15 mins
arnmaster <NIL: >NIL:
changetaskpri PRIORITY=0

---  Poll.mine

.KEY hostname/A
.BRA {
.KET }

setenv retry{hostname} x

echo >uuspool:C.{hostname}DUMMY

lab loop
;echo "Call started at "
;date
uucico -A -7 -U1 -n7 -pri -p1 -s{hostname}
echo >>env:retry{hostname} x NOLINE
if $retry{hostname} NOT EQ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 if EXISTS uuspool:C.{hostname}DUMMY
  wait 2 min
  skip loop BACK
 endif
endif
delete env:retry{hostname} QUIET


---  UnBatchNews

.key type
.bra {
.ket }
;
; Primary script to process in coming news
;
; 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!"
