function [tagreflist, namelist, info]=hdfpeek( filename, tagref )
%HDFPEEK List object tag/ref pairs in HDF file.
%	[TAGREF,NAME,INFO]=HDFPEEK( 'filename' ) scans an HDF
%	file and returns a list of tag/reference no. pairs for image
%	groups in the file.  TAGREF is an Nx2 matrix where N is 
%	the number of images found, and each row contains the tag and 
%	reference no. for an image in the file.  NAME returns a matrix 
%	of strings containing the group names corresponding to the 
%	tags of the images, and INFO contains a corresponding list of
%	scalars denoting the image depth (8 for binary, intensity, and
%	indexed images, 24 for RGB images, -1 for unknown).
%
%	[TAGREF,NAME,INFO]=HDFPEEK( 'filename', [GROUPTAG GROUPREF] ) 
%	returns a list of data objects in the specified group, using
%	the same output format as given above, except INFO will be a
%	single scalar instead of a list of scalars.
%
%	See also: HDFREAD, HDFWRITE.

%	Author: J.M. Winograd	7-93
%	Copyright (c) 1993 The Mathworks, Inc.

error( nargchk( 1, 2, nargin ) );

if (~isstr(filename))
    error( 'FILENAME must be a string.' );
end

% Find full filename
fid = fopen(filename);
if fid == -1, error(['File ',filename' not found.']); end
fname = fopen(fid); fclose(fid);

if nargin == 1
    [tagreflist, namelist, info] = hdfpeekc( fname );
else
    [tagreflist, namelist, info] = hdfpeekc( fname, tagref );
end
