summaryrefslogtreecommitdiff
path: root/lib/77bit
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2025-09-15 23:04:33 +0200
committerChristoph Berg <myon@debian.org>2025-09-15 23:04:33 +0200
commite1c678ef00f0159bbeb5571e5ebb0d4697121334 (patch)
tree6547edef81a62a812a4d0f64e03fda226b5f0a7e /lib/77bit
parentb9daa22c4c3ad51cd4bc0ef624a19f21d01c9305 (diff)
parent0a13f1fdb9928b6d012569dd65f7f6ef18fac2f8 (diff)
Update upstream source from tag 'upstream/3.0.0_rc1+repack'
Update to upstream version '3.0.0~rc1+repack' with Debian dir 68c212e23136fecf9ebc6f12ff355579224d27ee
Diffstat (limited to 'lib/77bit')
-rwxr-xr-xlib/77bit/hash22calc.f9042
-rwxr-xr-xlib/77bit/packjt77.f90118
2 files changed, 152 insertions, 8 deletions
diff --git a/lib/77bit/hash22calc.f90 b/lib/77bit/hash22calc.f90
new file mode 100755
index 00000000..46581a98
--- /dev/null
+++ b/lib/77bit/hash22calc.f90
@@ -0,0 +1,42 @@
+program hash22calc
+! Given a valid callsign, calculate and print its 22-bit hash.
+
+ use packjt77
+
+ character*13 callsign
+ character*1 c
+ character*6 basecall
+ logical cok
+
+ nargs=iargc()
+ if(nargs.ne.1) then
+ print*,'Given a valid callsign, print its 22-bit hash.'
+ print*,'Usage: hash22calc <callsign>'
+ print*,' e.g. hash22calc W9ABC'
+ go to 999
+ endif
+ call getarg(1,callsign)
+
+! convert to upper case
+ ilen=len(trim(callsign))
+ do i=1, ilen
+ c=callsign(i:i)
+ if(c.ge.'a' .and. c.le.'z') c=char(ichar(c)-32) !Force upper case
+ callsign(i:i)=c
+ enddo
+
+! check for a valid callsign
+ call chkcall(callsign,basecall,cok)
+ if(.not.cok) then
+ print*,'Invalid callsign'
+ print*,'Usage: hash22calc <callsign>'
+ goto 999
+ endif
+
+! calculate the hash
+ n22 = ihashcall(callsign,22)
+ write(*,'(a,i7.7)') callsign,n22
+
+999 end program hash22calc
+
+include '../chkcall.f90'
diff --git a/lib/77bit/packjt77.f90 b/lib/77bit/packjt77.f90
index af655723..121032a7 100755
--- a/lib/77bit/packjt77.f90
+++ b/lib/77bit/packjt77.f90
@@ -1,5 +1,7 @@
module packjt77
+use packjt77var, only : hash10var,hash12var,hash22var
+
! These variables are accessible from outside via "use packjt77":
parameter (MAXHASH=1000,MAXRECENT=10)
character (len=13), dimension(0:1023) :: calls10=''
@@ -319,8 +321,14 @@ subroutine unpack77(c77,nrx,msg,unpk77_success)
call unpack28(n28b,call_2,unpk28_success)
if(.not.unpk28_success .or. n28b.le.2) unpk77_success=.false.
call hash10(n10,call_3)
+ if(call_3.eq.'<...>') then
+ ! print*,'pre std n10 ',n10,' call_3 ',call_3
+ call hash10var(n10,call_3,1)
+ ! print*,'std n10 ',n10,' call_3 ',call_3
+ endif
if(nrx.eq.1 .and. &
dxcall13_set .and. &
+ len(trim(dxcall13)).ge.3 .and. &
hashdx10.eq.n10) call_3='<'//trim(dxcall13)//'>'
if(nrx.eq.0 .and. &
mycall13_set .and. &
@@ -370,15 +378,28 @@ subroutine unpack77(c77,nrx,msg,unpk77_success)
msg=adjustl(msg)
else if(i3.eq.0 .and. n3.eq.6) then
- read(c77(49:50),'(2b1)') j2a,j2b
- itype=2
- if(j2b.eq.0 .and. j2a.eq.0) itype=1
- if(j2b.eq.0 .and. j2a.eq.1) itype=3
+ read(c77(48:50),'(3b1)') j48,j49,j50
+! bits 48:50
+! itype=1: x00
+! itype=2: xx1
+! itype=3: 010
+ if(j50.eq.1) then
+ itype=2
+ else if(j49.eq.0) then
+ itype=1
+ else if(j48.eq.0) then
+ itype=3
+ else
+ itype=-1
+ unpk77_success=.false.
+ endif
+
if(itype.eq.1) then
! WSPR Type 1
read(c77,2010) n28,igrid4,idbm
2010 format(b28.28,b15.15,b5.5)
idbm=nint(idbm*10.0/3.0)
+ if(idbm.lt.0 .or. idbm.gt.60) unpk77_success=.false.
call unpack28(n28,call_1,unpk28_success)
if(.not.unpk28_success) unpk77_success=.false.
call to_grid4(igrid4,grid4,unpkg4_success)
@@ -392,6 +413,7 @@ subroutine unpack77(c77,nrx,msg,unpk77_success)
read(c77,2020) n28,npfx,idbm
2020 format(b28.28,b16.16,b5.5)
idbm=nint(idbm*10.0/3.0)
+ if(idbm.lt.0 .or. idbm.gt.60) unpk77_success=.false.
call unpack28(n28,call_1,unpk28_success)
if(.not.unpk28_success) unpk77_success=.false.
write(crpt,'(i3)') idbm
@@ -460,13 +482,17 @@ subroutine unpack77(c77,nrx,msg,unpk77_success)
i=index(call_1,' ')
if(i.ge.4 .and. ipa.eq.1 .and. i3.eq.1) call_1(i:i+1)='/R'
if(i.ge.4 .and. ipa.eq.1 .and. i3.eq.2) call_1(i:i+1)='/P'
- if(i.ge.4) call add_call_to_recent_calls(call_1)
+ if(i.ge.4) call add_call_to_recent_calls(call_1)
endif
if(index(call_2,'<').le.0) then
i=index(call_2,' ')
if(i.ge.4 .and. ipb.eq.1 .and. i3.eq.1) call_2(i:i+1)='/R'
if(i.ge.4 .and. ipb.eq.1 .and. i3.eq.2) call_2(i:i+1)='/P'
- if(i.ge.4) call add_call_to_recent_calls(call_2)
+ if(i.ge.4) then
+ call add_call_to_recent_calls(call_2)
+! only hash the "from" call
+ call save_hash_call(call_2,ndum10,ndum12,ndum22)
+ endif
endif
if(igrid4.le.MAXGRID4) then
call to_grid4(igrid4,grid4,unpkg4_success)
@@ -542,10 +568,16 @@ subroutine unpack77(c77,nrx,msg,unpk77_success)
n58=n58/38
enddo
call hash12(n12,call_3)
+ if(call_3.eq.'<...>') then
+ ! print*,'pre std n12 1 ',n12,' call_3 ',call_3
+ call hash12var(n12,call_3,1)
+ ! print*,'std n12 1 ',n12,' call_3 ',call_3
+ endif
if(iflip.eq.0) then ! 12 bit hash for TO call
call_1=call_3
call_2=adjustl(c11)//' '
call add_call_to_recent_calls(call_2)
+ call save_hash_call(call_2,ndum10,ndum12,ndum22)
if(nrx.eq.1 .and. &
dxcall13_set .and. mycall13_set .and. &
call_2.eq.dxcall13 .and. &
@@ -582,8 +614,18 @@ subroutine unpack77(c77,nrx,msg,unpk77_success)
return
endif
call hash12(n12,call_1)
+ if(call_1.eq.'<...>') then
+ ! print*,'pre std n12 1 ',n12,' call_1 ',call_1
+ call hash12var(n12,call_1,1)
+ ! print*,'std n12 2 ',n12,' call_1 ',call_1
+ endif
if(n12.eq.hashmy12) call_1='<'//trim(mycall13)//'>'
call hash22(n22,call_2)
+ if(call_2.eq.'<...>') then
+ ! print*,'pre std n22 ',n22,' call_2 ',call_2
+ call hash22var(n22,call_2,1)
+ ! print*,'std n22 ',n22,' call_2 ',call_2
+ endif
nrs=52+irpt
write(cexch,1022) nrs,iserial
1022 format(i2,i4.4)
@@ -735,7 +777,7 @@ end subroutine pack28
subroutine unpack28(n28_0,c13,success)
parameter (NTOKENS=2063592,MAX22=4194304)
- logical success
+ logical success,callok
character*13 c13
character*37 c1
character*36 c2
@@ -779,6 +821,11 @@ subroutine unpack28(n28_0,c13,success)
! This is a 22-bit hash of a callsign
n22=n28
call hash22(n22,c13) !Retrieve callsign from hash table
+ if(c13.eq.'<...>') then
+ ! print*,'pre std n22 ',n22,' c13 ',c13
+ call hash22var(n22,c13,1)
+ ! print*,'std n22 ',n22,' c13 ',c13
+ endif
go to 900
endif
@@ -798,11 +845,17 @@ subroutine unpack28(n28_0,c13,success)
c4(i5+1:i5+1)//c4(i6+1:i6+1)
c13=adjustl(c13)
+ if(.not.callok(trim(c13))) then
+ c13='QU1RK'
+ success=.false.
+ endif
+
900 i0=index(c13,' ')
if(i0.ne.0 .and. i0.lt.len(trim(c13))) then
c13='QU1RK'
success=.false.
endif
+
return
end subroutine unpack28
@@ -1526,7 +1579,7 @@ subroutine add_call_to_recent_calls(callsign)
endif
! Make sure that callsign is hashed
- call save_hash_call(callsign,n10,n12,n22)
+! call save_hash_call(callsign,n10,n12,n22) ! commented out - do this in the calling routine:
return
end subroutine add_call_to_recent_calls
@@ -1624,3 +1677,52 @@ subroutine to_grid(n,grid6,ok)
end subroutine to_grid
end module packjt77
+
+logical function callok(w)
+
+ character*(*) w
+ character*1 c1
+ character*2 pfx
+ character*3 sfx
+ logical isdig,islet
+
+ islet(c1)=(ichar(c1).ge.65 .and. ichar(c1).le.90) .or. &
+ (ichar(c1).ge.97 .and. ichar(c1).le.122)
+ isdig(c1)=(ichar(c1).ge.48 .and. ichar(c1).le.57)
+
+ callok=.false.
+ n=len(trim(w))
+ if(n.lt.3) return !Must be at lkeast three characters
+ if(w(1:1).eq.'Q') return !Callsigns can't start with Q
+
+ i0=0
+ do i=n,1,-1
+ if(isdig(w(i:i))) exit
+ enddo
+ i0=i !Call area position in word
+
+ if(i0.ne.2 .and. i0.ne.3) return
+
+ pfx=w(1:i0-1) !Prefix, without call area
+ sfx=w(i0+1:) !Suffix
+
+ nlp=0
+ ndp=0
+ np=len(trim(pfx))
+ do i=1,np
+ if(isdig(pfx(i:i))) ndp=ndp+1
+ if(islet(pfx(i:i))) nlp=nlp+1
+ enddo
+ if(nlp.eq.0) return !Prefix must have at least one letter
+
+ nls=0
+ ns=len(trim(sfx))
+ do i=1,ns
+ if(islet(sfx(i:i))) nls=nls+1
+ enddo
+ if(nls.lt.ns) return !Suffix must be all letters
+
+ callok=.true.
+
+ return
+end function callok