/* Generic template for machine-dependent functions. */

/****************
function trunc() truncates a file.
*/

int trunc (handle)
int handle;
{
   /* code to truncate file goes here -- may be left empty */
}

/*****************
Function gettime() or getutime() gets the date and time of the file handle 
or filename supplied.  Date and time is in MSDOS format.
*/
#ifdef GETUTIME
getutime (fname, date, time)
char *fname;
#else
gettime (handle,date,time)
int handle;
#endif
int *date, *time;
{
   *date = *time = 0; /* not yet implemented */
}

/*****************
Function settime() or setutime() sets the date and time of the file handle
or filename supplied.  Date and time is in MSDOS format.
*/
#ifdef NIXTIME
int setutime(path,date,time)
char *path;
#else
int settime(handle, date, time)
int handle;
#endif
unsigned int date, time;
{
   /* not yet implemented */
}

/*****************
Function mktemp() accepts a template of the form `baseXXXXXX' where
base is an arbitrary string, and returns a unique temporary filename.
If template is not correct, it is returned unchanged.
*/
char *mktemp(template)
char *template;
{

#ifndef NDEBUG
   if (index(template, "XXXXXX") == -1)
      prterror ('w', "Incorrect template [%s] supplied to mktemp().\n",
         template);
#endif

   strcpy(&template[index(template, "XXXXXX")],"{zoo}.@@@");
   return (template);
}

/*****************
Function isadir() or isuadir() returns 1 if supplied handle or 
filename is a directory or other special file that should not be 
archived, else it returns 0.
*/

#ifdef CHEKDIR
int isadir(han)
int han;
{
   return (0); /* by default assume never a directory */
}
#endif

#ifdef CHEKUDIR
int isuadir(path)
char *path;
{
   return (0); /* by default assume never a directory */
}
#endif

/****************
Function fixfname() converts the supplied filename to a syntax
legal for the host system.  It is used during extraction to make sure
that a file can be extracted even if a badly-implemented archiver
stored it with an illegal filename.
*/

char *fixfname(fname)
char *fname;
{
   return (fname); /* default is no-op */
}

/*****************
Function nextfile() is effectively a no-op.  Any wildcard expansion 
must have been done before Zoo receives the arguments.
*/

#define FMAX 1
char *nextfile (what, filespec, fileset)
int what;                        /* whether to initialize or match      */
register char *filespec;         /* filespec to match if initializing   */
register int fileset;            /* which set of files                  */
{
   static int first_time [FMAX+1];
   static char saved_fspec [FMAX+1][PATHSIZE];  /* our own copy of filespec */

   if (what == 0) {
      strcpy (saved_fspec[fileset], filespec);  /* save the filespec */
      first_time[fileset] = 1;
      return (NULL);
   }

   if (first_time[fileset]) {
      first_time[fileset] = 0;
      return (saved_fspec[fileset]);
   } else {
      return (NULL);
   }
}
