/******************************************************************************
* This file is Copyright 1993 by Philip G. Richards.  All Rights Reserved.
* See the file README that came with this distribution for permissions on
* code usage, copying, and distribution.  It comes with absolutely no warranty.
* email: <pgr@prg.ox.ac.uk>
******************************************************************************/

/* ---INFOBEGIN--- *  DO NOT DELETE THIS COMMENT BLOCK!!!
COMMAND since local "make ls show only files since time/file given"
 *  ---INFOEND---  */

#include "client.h"
#include "util.h"
#include "table.h"
#include <ctype.h>
#include <stdlib.h>

time_t sincetime = 0;

int
lsince_main(int argc, char *const*argv, char **envp)
{
    char *newsincetime;

    if (argc < 2)
    {
	if (STDPROMPT)
	{
	    ffprintf(STDPROMPT,"(since) ");
	    newsincetime = readword();
	}
	else
	   newsincetime = 0;
    }
    else
	newsincetime = argv[1];

    if (newsincetime == 0)
	return 1;

    if (isdigit(*newsincetime))
	sincetime = atoi(newsincetime);
    else
    {
	struct stat buf;

	if (strlen(newsincetime) > 0)
	{
	    if (stat(newsincetime, &buf) < 0)
	    {
		ffprintf(STDERR, "since: stat(%s): %s\n",
			      newsincetime, strerror(errno));
		return 1;
	    }
	    sincetime = buf.st_mtime;
	}
    }

    return 0;
}


syntax highlighted by Code2HTML, v. 0.9.1