[comp.sources.amiga] fnams

ain@j.cc.purdue.edu (Patrick White) (05/18/88)

Submitted by:	d87sg@efd.lu.se  (Svante Gellerstam)
Summary:	Produces directory listings for use with the zoo archiver.
Poster Boy:	Patrick White	(ain@j.cc.purdue.edu)
Archive Name:	sources/amiga/volume4/fnams.src.sh.Z
tested, but not compiled.
 
NOTES:
   Tested, but didn't compile it.
 
 
-- Pat White   (co-moderator comp.sources/binaries.amiga)
ARPA/UUCP: j.cc.purdue.edu!ain  BITNET: PATWHITE@PURCCVM  PHONE: (317) 743-8421
U.S.  Mail:  320 Brown St. apt. 406,    West Lafayette, IN 47906
 
========================================
 
#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar:	Shell Archiver
#	Run the following text with /bin/sh to create:
#	readme
#	fnams.man
#	fnams.c
# This archive created: Mon May 16 11:35:33 1988
# By:	Patrick White (PUCC Land, USA)
echo shar: extracting readme '(161 characters)'
cat << \SHAR_EOF > readme
This archive should contain:

	fnams		- executable.

	fnams.c 	- C-source for the Lattice 4.0 C-compiler.

	fnams.man	- Documentation pages for fnams.

/svante

SHAR_EOF
if test 161 -ne "`wc -c readme`"
then
echo shar: error transmitting readme '(should have been 161 characters)'
fi
echo shar: extracting fnams.man '(1478 characters)'
cat << \SHAR_EOF > fnams.man
	NAME
		FNAMS - a filter program for the ZOO archiver. Amiga
		version.

	SYNOPSIS
		FNAMS <directory>
		FNAMS <unit>

	DESCRIPTION
		FNAMS will produce a listing on stdout of all files under
		the given directory/unit with their full pathnames. Thus
		FNAMS is a complement to the ZOO archiver. The first
		objective is to provide a easy way to archive entire
		directory structures.


		The intended use is as follows:

		First produce a listing of the desired directory using
		FNAMS:

			FNAMS > <tempfile> <dirpath>

		Then use <tempfile> together with the ZOO option I:

			ZOO < <tempfile> aI <archivename>


		ZOO will then put into <archivename> all files described in
		<tempfile>.

		Please note that when producing a list of the files in a
		subdirectory you have to append a '/' to the path like
		this:

			unit:dir/subdir/
				      -+- note this!

	FILES
		<tempfile>

	SEE ALSO
		ZOO documentation.

	BUGS
		None known...

	DIAGNOSTICS
		Since the program is intended as a filter it will not emit
		any error messages. Erratic input will result in zero files
		listed. This with one single execption, and that is when no
		parameter is given, wich will produce the usual 'Usage:...'
		message.

	THANKS TO
		Lattice for including those hints on how to squeeze
		filesize to a minimum.
		Rahul Dhesi for writing ZOO in the first place.

	AUTHOR
		Svante Gellerstam

		Please send hints, flames, bugs and/or suggestions to me
		at:

				USENET - d87sg@efd.lu.se

SHAR_EOF
if test 1478 -ne "`wc -c fnams.man`"
then
echo shar: error transmitting fnams.man '(should have been 1478 characters)'
fi
echo shar: extracting fnams.c '(1732 characters)'
cat << \SHAR_EOF > fnams.c
#include "proto/all.h"
#include "libraries/dos.h"
#include "stdio.h"

void myputs();

extern int msflag;
extern int errno,_OSERR;

char dirstr[108];
struct FileInfoBlock myfib[20];
BPTR flock[20];

void
main(argc,argv)
int argc;
char *argv[];
   {
   int kris=0;
   int oldflag;
   int fibcnt=0;
   char *killptr,temp;

   oldflag = msflag;
   msflag = 0;

   if(argc < 2)
      {
      myputs("Usage: fnams <dir>");
      myputs("\n");
      exit(0);
      }

   strcpy(dirstr,argv[1]);

   if( (flock[fibcnt] = Lock(dirstr,ACCESS_READ)) == 0)
      kris = 1;
   if( Examine(flock[fibcnt],&myfib[fibcnt]) == 0)
      kris = 1;
   if( ExNext(flock[fibcnt],&myfib[fibcnt]) == 0)
      kris = 1;

   temp = dirstr[strlen(dirstr)-1];
   if(temp != ':' && temp != '/' )
      kris = 1;

   while(!kris)
      {
      if(myfib[fibcnt].fib_EntryType > 0)
         {
         strcat(dirstr,myfib[fibcnt].fib_FileName);
         strcat(dirstr,"/");
         fibcnt++;
         if( (flock[fibcnt] = Lock(dirstr,ACCESS_READ)) == 0)
            continue;
         else
            Examine(flock[fibcnt],&myfib[fibcnt]);
         }
      else
         {
         myputs(dirstr);
         myputs(myfib[fibcnt].fib_FileName);
         myputs("\n");
         }

      while( (ExNext(flock[fibcnt],&myfib[fibcnt]) == 0) && !kris )
         {
         fibcnt--;

         if(fibcnt < 0)
            {
            kris = 1;
            break;
            }

         killptr = dirstr + strlen(dirstr) - 3;
         while( (*killptr != '/') && (*killptr != ':') )
            killptr--;
         *(killptr+1) = '\0';
         }
      }
   msflag = oldflag;
   }

void
myputs(string)
char *string;
   {
   Write(Output(),string,strlen(string));
   }


SHAR_EOF
if test 1732 -ne "`wc -c fnams.c`"
then
echo shar: error transmitting fnams.c '(should have been 1732 characters)'
fi
#	End of shell archive
exit 0