/*
* trunc v1.0
* (c) 2006 Joe Laffey, http://laffey.tv/
*
* This program comes with ABSOLUTELY NO WARRANTY. You may use the
* code how ever you wish
*
* Simple program to truncate a file in unix.
*
* This program sets the given file's length to zero.
* This means it clears the file, which is helpful to reset
* log files. But don't use it on an important file!
*
*
* I use this under NetBSD.
*
*
* Save file as trunc.c
* Compile with gcc -O -o trunc trunc.c
*
*
* usage: trunc <filename>
*
*/




#include <unistd.h>
#include <stdio.h>
#include <sysexits.h>
#include <errno.h>

int main(int argc, char **argv)
{
	if(argc != 2)
	{
		fprintf(stderr, "usage: %s <filename>\n", argv[0]);
		exit(EX_USAGE);
	};

	if(truncate(argv[1], 0L))
	{

		perror("truncation failed");
		exit(errno);
	}

	return 0; /* success */
}
