DIM k&(11),d$(6),m$(11),fjd&(11,1),njd&(11,1),seg$(499),node$(499),typ$(499),pw$(499),pw!(499),field$(7),bps%(6),arg$(50),arc$(25,1),pb&(999),node!(32767),net!(32767),zone!(32767),fieldname$(7),reg%(15)
nbps&=6
bps%(1)=300
bps%(2)=1200
bps%(3)=2400
bps%(4)=9600
bps%(5)=19200
bps%(6)=38400
fieldname$(0)="Keyword"
fieldname$(1)="Node number"
fieldname$(2)="Node name"
fieldname$(3)="Location"
fieldname$(4)="Sysop name"
fieldname$(5)="Phone number"
fieldname$(6)="BPS rate"
fieldname$(7)="Flags"
rev$=CHR$(27)+"p"
nor$=CHR$(27)+"q"
CLS
PRINT "MakeDiff Nodelist Editor/Creator version ";ver$;" - Created using GFA Basic v3.5E E"
PRINT "Copyright David J. Thomas, B.Sc.(Hons.); 1991, 1992, 1993, 1994."
PRINT
PRINT "Use and distribution of this program is governed by the GNU General Public"
PRINT "License (see file COPYING for details). This means that the program is freely"
PRINT "usable and distributable under the conditions contained therein."
PRINT
PRINT "Initialising"
PRINT
FOR i&=0 TO 11
READ k&(i&)
NEXT i&
FOR i&=0 TO 6
READ d$(i&)
NEXT i&
FOR i&=0 TO 11
READ m$(i&)
NEXT i&
FOR l&=0 TO 1
d&=0
FOR i&=0 TO 11
fjd&(i&,l&)=d&
READ x&
njd&(i&,l&)=x&
d&=d&+x&
NEXT i&
NEXT l&
argc&=0
IF BYTE{BASEPAGE+128}
cl$=TRIM$(CHAR{BASEPAGE+129})+" "
ELSE
cl$=""
ENDIF
ctl$="MAKEDIFF.CTL"
DO UNTIL cl$="" OR cl$=" "
INC argc&
arg$(argc&)=TRIM$(LEFT$(cl$,INSTR(cl$," ")-1))
cl$=TRIM$(MID$(cl$,INSTR(cl$," ")))+" "
LOOP
FOR i&=1 TO argc&
IF LEFT$(arg$(i&))="-"
FOR j&=2 TO LEN(arg$(i&))
x$=UPPER$(MID$(arg$(i&),j&,1))
IF x$="P"
pro!=-1
ENDIF
IF x$="T"
test!=-1
cltest!=-1
ENDIF
IF x$="M"
merge!=-1
ENDIF
IF x$="R"
rept!=-1
ENDIF
NEXT j&
ELSE
IF LEFT$(arg$(i&))<>"-" AND arg$(i&)<>""
ctl$=UPPER$(arg$(i&))
IF NOT EXIST(ctl$) AND RINSTR(ctl$,"\")>RINSTR(ctl$,".")
ctl$=ctl$+".CTL"
ENDIF
ENDIF
ENDIF
NEXT i&
IF NOT EXIST(ctl$)
nobar!=-1
PRINT "Control file does not exist - aborting"
fin(255)
ENDIF
PRINT "Reading control file ";ctl$
PRINT
inpctl(ctl$)
IF NOT nobar!
ytop&=INT{L~A-4}-INT{L~A-46}+1
ybot&=INT{L~A-4}-1
origlines&=INT{L~A-42}
xwid&=INT{L~A-12}-2
INT{L~A-42}=origlines&-1
timebar(0)
ENDIF
DIM nold$(maxsize&-1),nnew$(maxsize&-1),ndif$(maxsize&-1),index&(maxsize&-1)
ELSE IF RIGHT$(ext$,2)="D"+RIGHT$(daynxt$) OR RIGHT$(ext$,2)="D"+RIGHT$(daylst$) OR RIGHT$(ext$,2)=RIGHT$(daynxt$,2) OR RIGHT$(ext$,2)=RIGHT$(daylst$,2)
' this file is an archived diff file from current segment
' or it is an archived file for the current segment
' file is unarc'ed, and then Fsfirst() is recalled to process the file
' that was unpacked
log(":Archive "+inb$+from$+" found, unpacking")
archiver%=ASC(ext$)-65
IF arc$(archiver%,0)=""
log("!No archiver defined for type "+CHR$(archiver%+65)+" files")
report$=report$+"- This system does not have "+seg$(i%)+"."+daylst$+", please send a copy of your full segment (it can be found in your Master directory)"+CHR$(10)
INC nerrs%
ENDIF
ELSE IF da!
' This is a file written by a human
log("#Pure data file "+inb$+from$)
OPEN "I",#0,inb$+from$
IF @generic(seg$(i%))
OPEN "O",#1,upd$+seg$(i%)+"."+daynxt$
ELSE
OPEN "O",#1,upd$+seg$(i%)
ENDIF
lnew%=0
status("Constructing new segment")
timebar(0)
DO UNTIL EOF(#0)
INC lnew%
x$=@in$(0)
IF x$<>eof$
timebar(LOC(#0)/LOF(#0))
nnew$(lnew%)=x$
IF lnew%=1 AND MID$(node$(i%),INSTR(node$(i%)," ")+1,1)<>"H" AND nnew$(1)<>";"
nnew$(2)=nnew$(1)
nnew$(1)=";"
ENDIF
ENDIF
LOOP
timebar(1)
SELECT MID$(node$(i%),INSTR(node$(i%)," ")+1,1)
CASE "Z"
x$="Zone"
CASE "R"
x$="Region"
CASE "N"
x$="Host"
CASE "H"
x$="Hub"
ENDSELECT
nnew$(0)=";A "+x$+" Nodelist for "+daynxt$+" : "
status("Calculating CRC")
timebar(0)
crc%=0
FOR i%=1 TO lnew%
timebar(i%/lnew%)
x$=nnew$(i%)
FOR j%=0 TO LEN(x$)-1
crc%=@xcrc(crc%,BYTE{V:x$+j%})
NEXT j%
crc%=@xcrc(crc%,13)
crc%=@xcrc(crc%,10)
NEXT i%
nnew$(0)=nnew$(0)+RIGHT$("0000"+STR$(crc%),5)
log(">CRC = "+STR$(crc%))
log(">File written")
FOR i%=0 TO lnew%
PRINT #1,nnew$(i%)
NEXT i%
OUT #1,&H1A
CLOSE #1
ELSE
IF @generic(seg$(i%))
~@copy(inb$+from$,upd$+seg$(i%)+"."+daynxt$)
ELSE
~@copy(inb$+from$,upd$+seg$(i%))
ENDIF
ENDIF
' delete file from inbound
KILL inb$+from$
log(" File "+inb$+from$+" deleted")
' perform CRC check on new file here
IF NOT da! !no point if we've made the CRC here!
OPEN "I",#0,upd$+seg$(i%)+"."+daynxt$
x$=@in$(0)
expect_crc%=VAL(MID$(x$,RINSTR(x$," : ")+3))
crc%=0
status("Checking CRC")
timebar(0)
DO UNTIL EOF(#0)
x$=@in$(0)
timebar(LOC(#0)/LOF(#0))
IF x$<>eof$
FOR j%=0 TO LEN(x$)-1
crc%=@xcrc(crc%,BYTE{V:x$+j%})
NEXT j%
crc%=@xcrc(crc%,13)
crc%=@xcrc(crc%,10)
ENDIF
LOOP
CLOSE #0
timebar(1)
crc%=AND(crc%,&HFFFF)
IF crc%<>expect_crc%
report$=report$+"- Your submitted nodelist segment does not have a valid CRC"+CHR$(10)
INC nerrs%
log("!CRC error - "+STR$(crc%)+" calculated, "+STR$(expect_crc%)+" shown in file")
ENDIF
ENDIF
x$=upd$+seg$(i%)
IF @generic(seg$(i%))
x$=x$+"."+daynxt$
ENDIF
checkfile(x$,typ$(i%),pw$(i%),pw!(i%))
IF nerrs%=0 AND badpvt%=0
report$=LEFT$(report$,INSTR(report$,CHR$(10))-1)
report$=report$+" and processed OK, the changes should be processed for the "+datnxt$+" nodelist edition (number "+daynxt$+")"
log("!Archiver has not produced "+hold$+olist$+"."+CHR$(sendarc&+65)+RIGHT$(daynxt$,2))
ENDIF
ELSE
log("!Archiver "+arc$(sendarc&,0)+" does not exist")
ENDIF
ELSE
log("!No archiver specified")
ENDIF
RETURN
> PROCEDURE testmyseg
LOCAL lnew%
lnew%=1
IF dat!
OPEN "I",#0,ctl$
x$=""
DO UNTIL UPPER$(x$)="DATA"
x$=@in$(0)
DO WHILE RIGHT$(x$)=" "
x$=LEFT$(x$,LEN(x$)-1)
LOOP
LOOP
x$=@in$(0)
DO WHILE RIGHT$(x$)=" "
x$=LEFT$(x$,LEN(x$)-1)
LOOP
DO WHILE UPPER$(x$)<>"END"
nnew$(lnew%)=x$
INC lnew%
x$=@in$(0)
DO WHILE RIGHT$(x$)=" "
x$=LEFT$(x$,LEN(x$)-1)
LOOP
LOOP
CLOSE #0
log(">Our segment data found from "+ctl$)
ELSE
addlistnocom(mas$+seg$)
log(">Our segment data found from "+mas$+seg$)
ENDIF
FOR i%=0 TO nsegs&-1
IF @nameseg$(i%)>""
addlistnocom(@nameseg$(i%))
ENDIF
NEXT i%
check(-1)
IF type$="Compound"
start$="Zone"
ELSE
start$=type$
ENDIF
IF LEFT$(start$,4)="Host"
segtype$="Net"
ELSE
segtype$=start$
ENDIF
IF type$="Zone"
desc$="Zone "+STR$(aozone&)
start$="Zone,"+STR$(aozone&)+","
ELSE IF type$="Region" OR type$="Host"
desc$=start$+" "+STR$(aonet&)
start$=start$+","+STR$(aonet&)+","
ELSE IF type$="Hub"
desc$="Hub "+STR$(aonode&)
start$="Hub,"+STR$(aonode&)+","
ENDIF
i%=1
DO WHILE LEFT$(nnew$(i%))=";"
INC i%
LOOP
IF LEFT$(nnew$(i%),LEN(start$))<>start$
log("!Local segment must start with "+desc$+" entry")
log("!Fatal Error")
INC nerrs%
rpt$="Error in line 1: Segment must start with "+desc$+" line"+lf$+rpt$
fat!=-1 !fatal error!
ENDIF
FOR i%=i%+1 TO lnew%
IF ((type$="Zone" AND equhier!=0) OR type$="Region" OR type$="Host" OR type$="Hub") AND LEFT$(nnew$(i%),5)="Zone,"
IF type$="Zone"
log("!Local error: Zone entry not allowed after first line in a Zone")
ELSE
log("!Local error: Zone entry not allowed in a "+segtype$)
ENDIF
log("!Error in line "+STR$(i%))
log("!Fatal Error")
IF type$="Zone"
rpt$=rpt$+"Error in line "+STR$(i%)+": Zone entry not allowed after first line in a Zone"+lf$
ELSE
rpt$=rpt$+"Error in line "+STR$(i%)+": Zone entry not allowed in a "+segtype$+lf$
ENDIF
INC nerrs%
fat!=-1
ENDIF
IF ((type$="Region" AND equhier!=0) OR type$="Host" OR type$="Hub") AND LEFT$(nnew$(i%),7)="Region,"
IF type$="Region"
log("!Local error: Region entry not allowed after first line in a Region")
ELSE
log("!Local error: Region entry not allowed in a "+segtype$)
ENDIF
log("!Error in line "+STR$(i%))
log("!Fatal Error")
IF type$="Region"
rpt$=rpt$+"Error in line "+STR$(i%)+": Region entry not allowed after first line in a Region"+lf$
ELSE
rpt$=rpt$+"Error in line "+STR$(i%)+": Region entry not allowed in a "+segtype$+lf$
ENDIF
INC nerrs%
fat!=-1
ENDIF
IF ((type$="Host" AND equhier!=0) OR type$="Hub") AND LEFT$(nnew$(i%),5)="Host,"
IF type$="Host"
log("!Local error: Host entry not allowed after first line in a Net")
ELSE
log("!Local error: Host entry not allowed in a Hub")
ENDIF
log("!Error in line "+STR$(i%))
log("!Fatal Error")
IF type$="Host"
rpt$=rpt$+"Error in line "+STR$(i%)+": Host entry not allowed after first line in a Net"+lf$
ELSE
rpt$=rpt$+"Error in line "+STR$(i%)+": Host entry not allowed in a Hub"+lf$
ENDIF
INC nerrs%
fat!=-1
ENDIF
IF (type$="Hub" AND equhier!=0) AND LEFT$(nnew$(i%),4)="Hub,"
log("!Local error: Hub entry not allowed after first line in a Hub")
log("!Error in line "+STR$(i%))
log("!Fatal Error")
rpt$=rpt$+"Error in line "+STR$(i%)+": Hub entry not allowed after first line in a Hub"+lf$
fat!=-1
ENDIF
NEXT i%
timebar(1)
IF nerrs%>0
IF nerrs%<>1
log("!"+STR$(nerrs%)+" errors found in current segment")
ELSE
log("!1 error found in current segment")
ENDIF
log(">Sending netmail to sysop")
nmsend(ozone&,onet&,onode&,ozone&,onet&,onode&,"MakeDiff","Coordinator","Local error notification",257,"Error report of current nodelist segment:"+lf$+lf$+rpt$)
ELSE
log("#Current segment is OK")
ENDIF
IF fat!
fin(deflevel%+2)
ENDIF
RETURN
> PROCEDURE test
LOCAL i%
log("*Test mode")
testmyseg
IF (type$="Compound" OR EXIST(nldir$+nlnam$+"."+daylst$)) AND merge!
log(":Merging new data into old nodelist")
' merge current data into nodelist
current_nl
check(0)
IF type$="Distribution"
FOR i%=1 TO lnew%
nold$(i%)=nnew$(i%)
NEXT i%
ELSE IF EXIST(nldir$+nlnam$+"."+daylst$)
log(">Opening "+nldir$+nlnam$+"."+daylst$)
OPEN "I",#0,nldir$+nlnam$+"."+daylst$
log(">Reading header information")
flin$=@in$(0) !save the first line
x$=flin$
cmerg%=1
DO UNTIL LEFT$(x$)<>";"
x$=@in$(0)
nold$(cmerg%)=x$
INC cmerg%
LOOP
log(">Header information passed")
DEC cmerg%
zone%=VAL(MID$(x$,6))
net%=zone%
hub%=0
term!=FALSE
IF type$="Zone"
log(">Replacing Zone "+STR$(ozone&))
ELSE IF type$="Region"
log(">Replacing Region "+STR$(ozone&)+":"+STR$(onet&))
ELSE IF type$="Host"
log(">Replacing Net "+STR$(ozone&)+":"+STR$(onet&))
txt$=txt$+"Your coordinator is running MakeDiff (copyright AutoMagic Software) to cause the nodelist updating with your details. If you would, please check the following, and report any errors to your coordinator:"+CHR$(10)+CHR$(10)
IF (j%=5 AND (UPPER$(field$(j%))<>"-UNPUBLISHED-") OR j%<>5)
FOR k&=1 TO LEN(field$(j%))
IF INSTR(ok$,MID$(field$(j%),k&,1))=0 AND j%<>6 AND UPPER$(field$(j%))<>"-UNPUBLISHED-"
RETURN "Invalid character(s) in "+fieldname$(j%)
ENDIF
NEXT k&
ENDIF
ENDIF
NEXT j%
IF uppcor%=0 AND field$(0)<>"Host" AND field$(0)<>"Region" AND field$(0)<>"Zone" AND type$<>"Hub"
RETURN "Node is not of a Zone, Region or Net"
ELSE IF field$(0)<>"" AND field$(0)<>"Zone" AND field$(0)<>"Region" AND field$(0)<>"Host" AND field$(0)<>"Hub" AND field$(0)<>"Hold" AND field$(0)<>"Down" AND field$(0)<>"Pvt"
RETURN "Invalid keyword"
ELSE IF field$(0)="Pvt" AND uppcor%>2
IF uppcor%=3
RETURN "Private nodes not valid in a region"
ELSE
RETURN "Private nodes not valid in a zone"
ENDIF
ELSE IF field$(0)="Pvt"
tnode%=VAL(field$(1))
IF zone%=0 AND region%=0
xx$="/"+STR$(tnode%)
ELSE IF zone%=0
xx$=":"+STR$(net%)+"/"+STR$(tnode%)
ELSE
xx$=STR$(zone%)+":"+STR$(net%)+"/"+STR$(tnode%)
ENDIF
IF (pvtvalid!=0 AND INSTR(pvtlist$,xx$)=0)
RETURN "Unauthorised private node"
ENDIF
ENDIF
IF VAL(field$(1))<1 OR VAL(field$(1))>32767
IF field$(0)="Zone" OR field$(0)="Region"
xx$=field$(0)
ELSE IF field$(0)="Host"
xx$="Net"
ELSE
xx$="Node"
ENDIF
RETURN xx$+" number is not in range [1..32767]"
ELSE IF field$(0)="" OR field$(0)="Hold" OR field$(0)="Down" OR field$(0)="Pvt"
node%=VAL(field$(1))
IF node!(node%)
RETURN "Duplicate node number"
ELSE
node!(node%)=-1
ENDIF
ELSE IF field$(0)="Hub"
uppcor%=1
node%=VAL(field$(1))
IF node!(node%)
RETURN "Duplicate node number"
ELSE
node!(node%)=-1
ENDIF
ELSE IF field$(0)="Host"
uppcor%=2
IF net!(VAL(field$(1)))
RETURN "Duplicate net number"
ELSE
ARRAYFILL node!(),0
net%=VAL(field$(1))
node%=0
net!(net%)=-1
ENDIF
ELSE IF field$(0)="Region"
uppcor%=3
IF net!(VAL(field$(1)))
RETURN "Duplicate net number"
ELSE
ARRAYFILL node!(),0
net%=VAL(field$(1))
node%=0
net!(net%)=-1
ENDIF
ELSE IF field$(0)="Zone"
uppcor%=4
IF zone!(VAL(field$(1)))
RETURN "Duplicate zone number"
ELSE
ARRAYFILL node!(),0
ARRAYFILL net!(),0
zone%=VAL(field$(1))
net%=zone%
node%=0
zone!(zone%)=-1
net!(net%)=-1
ENDIF
ENDIF
IF (field$(0)<>"Pvt" AND field$(0)<>"Hold" AND field$(0)<>"Down") AND UPPER$(field$(5))="-UNPUBLISHED-"
RETURN "Non-private nodes should have a phone number"
ELSE
ok!=FALSE
FOR j%=1 TO nbps&
IF VAL(field$(6))=bps%(j%)
ok!=TRUE
ENDIF
NEXT j%
IF NOT ok!
RETURN """"+field$(6)+""" is an invalid BPS rate"
ENDIF
ENDIF
ENDIF
RETURN ""
ENDFUNC
> FUNCTION nameseg$(n%)
LOCAL y$,z$
IF @generic(seg$(n%))
y$=seg$(n%)+"."+daynxt$
z$=seg$(n%)+"."+daylst$
ELSE
y$=seg$(n%)
z$=seg$(n%)
ENDIF
IF EXIST(upd$+y$)
RETURN upd$+y$
ELSE IF EXIST(mas$+y$)
RETURN mas$+y$
ELSE IF EXIST(mas$+z$)
RETURN mas$+z$
ENDIF
RETURN ""
ENDFUNC
> FUNCTION fullreq
LOCAL x$,x%
IF fullreq!=-1
RETURN fullreq%
ENDIF
log(":Scanning Netmail for full segment request")
fullreq!=-1
fullreq%=0
timebar(0)
IF EXIST(netmail$+".HDR")
OPEN "R",#5,netmail$+".HDR",216
msgs&=LOF(#5)\216
FIELD #5,216 AS record$
FOR m&=1 TO msgs&
GET #5,m&
IF AND(ASC(MID$(record$,178,1)),4)=0 AND AND(ASC(MID$(record$,177,1)),128)=0 !not Recv or Del
IF @tr$(LEFT$(record$,36))="MakeDiff"
IF @tr$(MID$(record$,37,36))="Coordinator"
IF @tr$(MID$(record$,73,72))="Request for "+UPPER$(olist$)
IF MID$(record$,201,8)=MKI$(dzone&)+MKI$(dnet&)+MKI$(dnode&)+MKI$(0)
IF MID$(record$,209,8)=MKI$(ozone&)+MKI$(onet&)+MKI$(onode&)+MKI$(0)
MID$(record$,178,1)=CHR$(OR(ASC(MID$(record$,178,1)),4)) ! set Recv
MID$(record$,177,1)=CHR$(OR(ASC(MID$(record$,177,1)),128)) ! set Del