/**
 * Display file statistics
 * -- First iteration, only report st_mtime
 */
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <time.h>

#define MAXBUF 256

int
main(int argc,char **argv) {
	int i;
	struct stat stats;
	struct tm *ptm;
	char buffer[MAXBUF];
	char template[] = "%Y%m%d%H%M%S";

	buffer[0] = '\0';
	/* do getopt */
	for (i=0; i < argc && NULL != argv[i+1]; i++) {
		if ( 0 != stat(argv[i+1], &stats) ) {
			perror("stat()");
			exit(EXIT_FAILURE);
		}
		if ( NULL == (ptm = localtime(&stats.st_mtime))) {
			perror("localtime()");
			exit(EXIT_FAILURE);
		}
		if ( 0 == strftime(buffer, MAXBUF, template, ptm) && 
				buffer[0] != '\0') {
			perror("strftime()");
			exit(EXIT_FAILURE); 
		}
		fprintf(stdout, "%s\t%s\n", argv[i+1], buffer);
	}
	exit(EXIT_SUCCESS);
}

