pro rd_bsd_header, lun_filnam, header
;+
;	NAME:
;		rd_bsd_header v0.9
;
;	PURPOSE:
;		Read and extract the header section from a BSD file
;
;	CALLING SEQUENCE:
;		rd_bsd_header, lun_filnam, header
;
;	INPUT:
;		lun_filnam	input file specification or the unit number
;				of an opened BSD file
;
;	OUTPUT:
;		header		the header section see bsd_struct.pro
;
;	HISTORY:
;		JTM: (24 Oct 91)
;		ATP: (13 may 92)
;		ATP: (18 may 92)
;		atp: (7/7/92) header, minor fixes
;-
bsd_struct

siz = size(lun_filnam)
vtyp = siz(siz(0) + 1)
;
if (vtyp eq 7) then begin	;passed file name
	get_lun, lun
	openr, lun, lun_filnam, /block
endif else begin		;passed logical unit number
	lun = lun_filnam
endelse
;
; define header from structure defined in bsd_struct
;
header = {bsd_h}
;
; read header
;
readu, lun, header
;
; subtract 1900 from time field if necessary.
;
if (header.tdf(6) ge 1000) then header.tdf(6) = header.tdf(6) - 1900
if (header.tdl(6) ge 1000) then header.tdl(6) = header.tdl(6) - 1900
;
; finish
;
if (vtyp eq 7) then begin
	close,lun
	free_lun, lun
	endif	
end
