/usr/share/gnudatalanguage/astrolib/dbrd.pro is in gdl-astrolib 2018.02.16+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | pro dbrd,enum,entry,available,dbno, noconvert=noconvert
;+
; NAME:
; DBRD
; PURPOSE:
; procedure to read an entry from a data base file or from
; linked multiple databases.
;
; CALLING SEQUENCE:
; dbrd, enum, entry, [available, dbno, /NoConvert]
;
; INPUTS:
; enum - entry number to read, integer scalar
;
; OUTPUT:
; entry - byte array containing the entry
;
; OPTIONAL OUTPUT:
; available - byte array with length equal to number of data
; bases opened. available(i) eq 1 if an entry (pointed
; to) is available. It always equals 1 for the first
; data base, otherwise it is an error condition.
;
; OPTIONAL INPUT:
; dbno - specification of the data base number to return. If
; supplied, only the record for the requested data base
; number is returned in entry. Normally this input should
; not be supplied. dbno is numbered for 0 to n-1 and gives
; the number of the data base opened. The data bases are
; numbered in the order supplied to dbopen. If dbno is supplied
; then the entry number refers to that data base and not the
; primary or first data base. If set to -1, then it means all
; data bases opened (same as not supplying it)
; OPTIONAL INPUT KEYWORD:
; noconvert - if set then don't convert external to host format.
; Assumes that calling program will take care of this
; requirement.
; OPERATIONAL NOTES:
; If multiple data base files are opened, the records are
; concatenated with each other
; HISTORY
; version 2 D. Lindler Nov. 1987
; William Thompson, GSFC/CDS (ARC), 1 June 1994
; Added support for external (IEEE) representation.
; Version 3, Richard Schwartz, GSFC/SDAC, 23-Aug-1996
; Add noconvert keyword
;
; Converted to IDL V5.0 W. Landsman September 1997
; Version 4, 2 May 2003, W. Thompson
; Use BSWAP keyword to DBXVAL instead of calling IEEE_TO_HOST.
;-
;
;-----------------------------------------------------------------------
On_error,2
if N_params() LT 2 then begin
print,'Syntax - dbrd, enum, entry, [available, dbno, /NoConvert]'
return
endif
COMMON db_com,qdb,qitems,qdbrec
; Find out if databases are in external format.
externali= db_info('EXTERNAL')
external = externali * (1-keyword_set(noconvert))
if N_params() LT 4 then dbno = -1
if dbno GE 0 then begin ;get only requeseted data base entry
available = bytarr(1)+1b
if dbno EQ 0 then begin
entry = qdbrec[enum]
if external[0] then db_ent2host, entry, 0
end else begin
len = db_info( 'LENGTH', dbno)
unit = db_info( 'UNIT_DBF', dbno)
p = assoc(unit,bytarr(len, /NOZERO), enum)
entry = p[0] ;read entry
if external[dbno] then db_ent2host, entry, dbno
end
return
end
; get info on open data bases
len = db_info( 'LENGTH' ) ;record lengths
units = db_info( 'UNIT_DBF' ) ;unit numbers
n = N_elements(len) ;number of db's opened
entry = qdbrec[enum] ;read entry for first db
if external[0] then db_ent2host, entry, 0
irec = enum ;record number
available = bytarr(n)+1B ;entry available
if n GT 1 then begin
for i = 1,n-1 do begin ;loop on db's
pointer = db_info('pointer',i) ;what points to it
db_item, pointer,itnum,ival,dtype,sb,nv,nb
;Make sure irec is in internal format!
if externali[db_item_info('dbnumber',itnum[0])] and keyword_set(noconvert) $
then bswap=1 else bswap=0
irec = dbxval(entry,dtype[0],1,sb[0],nb[0],bswap=bswap)
if irec GT 0 then begin
p = assoc( units[i], bytarr( len[i],/NOZERO ))
tmp = p[irec]
if external[i] then db_ent2host, tmp, i
entry = [ entry, tmp ] ;add to end
end else begin
available[i] = 0B
entry = [ entry, bytarr(len[i])]
end
end
end
return
end
|