FreeBSD/contrib/openbsm/libauditd/auditd_lib.c
/*
 * Convert a trailname into a timestamp (seconds).  Return 0 if the conversion
 * was successful.
 */
Convert a trailname into a timestamp (seconds).  Return 0 if the conversion
was successful.
Convert a trailname into a timestamp ( seconds ) . Return 0 if the conversion was successful .
static int
trailname_to_tstamp(char *fn, time_t *tstamp)
{
	struct tm tm;
	char ts[TIMESTAMP_LEN + 1];
	char *p;
	*tstamp = 0;
	if ((p = strchr(fn, '.')) == NULL)
		return (1);
	strlcpy(ts, ++p, sizeof(ts));
	if (strlen(ts) != POSTFIX_LEN)
		return (1);
	bzero(&tm, sizeof(tm));
	p = ts + POSTFIX_LEN - 2;
	tm.tm_sec = atol(p);
	if (tm.tm_sec < 0 || tm.tm_sec > 60)
		return (1);
	*p = '\0'; p -= 2;
	tm.tm_min = atol(p);
	if (tm.tm_min < 0 || tm.tm_min > 59)
		return (1);
	*p = '\0'; p -= 2;
	tm.tm_hour = atol(p);
	if (tm.tm_hour < 0 || tm.tm_hour > 23)
		return (1);
	*p = '\0'; p -= 2;
	tm.tm_mday = atol(p);
	if (tm.tm_mday < 1 || tm.tm_mday > 31)
		return (1);
	*p = '\0'; p -= 2;
	tm.tm_mon = atol(p) - 1;
	if (tm.tm_mon < 0 || tm.tm_mon > 11)
		return (1);
	*p = '\0'; p -= 4;
	tm.tm_year = atol(p) - 1900;
	if (tm.tm_year < 0)
		return (1);
	*tstamp = timegm(&tm);
	return (0);
}
static int trailname_to_tstamp ( char * fn , time_t * tstamp ) { struct tm tm ; char ts [ TIMESTAMP_LEN + 1 ] ; char * p ; * tstamp = 0 ; if ( ( p = strchr ( fn , ' ' ) ) == NULL ) return ( 1 ) ; strlcpy ( ts , ++ p , sizeof ( ts ) ) ; if ( strlen ( ts ) != POSTFIX_LEN ) return ( 1 ) ; bzero ( & tm , sizeof ( tm ) ) ; p = ts + POSTFIX_LEN - 2 ; tm . tm_sec = atol ( p ) ; if ( tm . tm_sec < 0 || tm . tm_sec > 60 ) return ( 1 ) ; * p = ' \0 ' ; p -= 2 ; tm . tm_min = atol ( p ) ; if ( tm . tm_min < 0 || tm . tm_min > 59 ) return ( 1 ) ; * p = ' \0 ' ; p -= 2 ; tm . tm_hour = atol ( p ) ; if ( tm . tm_hour < 0 || tm . tm_hour > 23 ) return ( 1 ) ; * p = ' \0 ' ; p -= 2 ; tm . tm_mday = atol ( p ) ; if ( tm . tm_mday < 1 || tm . tm_mday > 31 ) return ( 1 ) ; * p = ' \0 ' ; p -= 2 ; tm . tm_mon = atol ( p ) - 1 ; if ( tm . tm_mon < 0 || tm . tm_mon > 11 ) return ( 1 ) ; * p = ' \0 ' ; p -= 4 ; tm . tm_year = atol ( p ) - 1900 ; if ( tm . tm_year < 0 ) return ( 1 ) ; * tstamp = timegm ( & tm ) ; return ( 0 ) ; }
Convert a trailname into a timestamp (seconds).
Convert a trailname into a timestamp ( seconds ) .
/*
	 * Get the ending time stamp.
	 */ /* seconds (0-60) */ /* minutes (0-59) */ /* hours (0 - 23) */ /* day of month (1-31) */ /* month (0 - 11) */ /* year (year - 1900) */