function out = oms_getcfgfiles(cfgFile)
% OMS_GETCFGFILES - Gets the names of all the cfg files listed in cfgFile and the history
%
% Use as: f = oms_getcfgfiles(cfgFile)
%
% Inputs: cfgFile = name of a root cfgFile (ex. 'g:/cfg/ep1.cfg')
%
% Output: f = a cell array of all cfg files used 

% Brian Schlining
% 02 Feb 2000

% Get the specprr pointer files
n = 0;
fid = fopen(cfgFile, 'rt');

while ~feof(fid)
   
   s = fgetl(fid);
   if ~isempty(s)
      if ~strcmp(s(1), '#')
         firstWord = stringtokenizer(s, 1);
         
         if strcmp(firstWord, 'specprr')
            n = n + 1;
            out{n} = stringtokenizer(s, 2);
            
         end
         
         if (abs(firstWord(1)) > 47 & abs(firstWord(1)) < 58)
            forthWord = stringtokenizer(s, 4);
            
            if strcmp(forthWord, 'specprr')
               n = n + 1;
               out{n} = stringtokenizer(s, 5);
               
            end
            
         end
         
      end
   end
   
end
fclose(fid);

% Loop throught the pointer files and get the cfg files
r = length(out);
for i = 1:length(out)
   fid = fopen(['//tsunami.shore.mbari.org' out{i}], 'rt');
   while ~feof(fid)
      s = fgetl(fid);
      if ~isempty(s)
         if strcmp(s(1),'/')
            n = n + 1;
            out{n} = s;
         end
      end
      
      
   end
   fclose(fid);
end

r = length(out);
for i = 1:r
   [trash filename ext] = fileparts(out{i});
   out{i} = [filename ext];
end

