//-----------------------------------------------------------------------------
// Copyright © 2006 - Philip Howard - All rights reserved
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//-----------------------------------------------------------------------------
// package	libh/helloworld
// homepage	http://phil.ipal.org/freeware/libh/
//-----------------------------------------------------------------------------
// author	Philip Howard
// email	libh at ipal dot org
// homepage	http://phil.ipal.org/
//-----------------------------------------------------------------------------
// This file is best viewed using a fixed spaced font such as Courier
// and in a display at least 120 columns wide.
//-----------------------------------------------------------------------------

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <libh/ftr.h>
#include <libh/string.h>

//-----------------------------------------------------------------------------
// program	ftr-quiet
//
// purpose	Demonstrate the ftr_new(), ftr_get(), ftr_end(), and related
//		functions and macros.  Scan the file tree but output nothing
//		for timing and error check purposes.
//
// syntax	ftr-quiet  [ filenames ... ]
//
// returns	(int) >= 0 : success
//		(int) == EOF : error
//-----------------------------------------------------------------------------
int
main (
    int		argc
    ,
    char * *	argv
    ,
    char * *	envp
    )
{
    FTR		this_ftr	;
    char *	argp		;
    char *	pgm		;
    int		argi		;
    int		ftype		;

    pgm = str_tail_one( argv[0], '/' );
    argp = ( argi = 1 ) < argc ? argv[ argi ] : NULL;
    do {
	if ( ! ( this_ftr = ftr_new( argp ) ) ) {
            if ( argp )	fprintf( stderr, "%s: ftr_new( \"%s\" ) fails: %s\n", pgm, argp, strerror( errno ) );
            else	fprintf( stderr, "%s: ftr_new( NULL ) fails: %s\n", pgm, strerror( errno ) );
	    continue;
	}
	while ( ( ftype = ftr_get( this_ftr ) ) > 0 );
	ftr_end( this_ftr );
    } while ( ++ argi < argc && ( argp = argv[ argi ] ) );
    return 0;
}

