#ifdef	ournix
#include "ournix.h"
#endif
char sccsID[] = "@(#) touch.c V1.1 Copyright Julian H. Stacey January 89.\n" ;

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef	MSDOS	/* { */
#include <sys/utime.h>
#endif		/* } */
#include <errno.h>

#ifdef	ns32000
#define	BSD
#endif

extern long	time() ;

extern int errno ;
char unknown[] = "Unknown error" ;

char	**ARGV ;
main(argc,  argv)
	int	argc ;
	char	**argv ;
	{
	char	*file_p, *er_p ;
	int	rslt ;
#ifdef	BSD	/* { */
	time_t	timep[2];
#endif		/* } */

	ARGV = argv ;
#ifdef	VSL	/* { */
#include	"../../include/vsl.h"
#endif		/* } */

	while (--argc)
		{
		file_p = *++argv ;
#ifdef	DEBUG
		printf("doing %s\n",file_p);
#endif
#ifdef	MSDOS	/* { */
		if ((rslt = utime(file_p,(struct utimbuf *)0)) != 0 )
#endif		/* } */
#ifdef	BSD	/* { */
		timep[1] = timep[2] = time((long *)0) ;
		if ((rslt = utime(file_p,timep)) != 0 )
#endif		/* } */
			{
			if (rslt != -1) er_p = unknown ;
			else switch (errno)
				{
				case EACCES :
					er_p = "cannot access" ;
					break ;
				case EMFILE :
					er_p = "too many open files" ;
					break ;
				case ENOENT :
					er_p = "not found" ;
					break ;
				default :
					er_p = unknown ;
					break ;
				}
			fprintf(stderr,"%s: Error on %s, (%s).\n", 
				*ARGV, file_p, er_p );
			}
#ifdef	DEBUG
		printf("done %s\n",file_p);
#endif
		}
	exit(0);
	}
