FreeBSD/usr.sbin/edquota/edquota.c
/*
 * Convert ASCII input times to seconds.
 */
Convert ASCII input times to seconds.
Convert ASCII input times to seconds .
int
cvtatos(uint64_t period, char *units, uint64_t *seconds)
{
	if (bcmp(units, "second", 6) == 0)
		*seconds = period;
	else if (bcmp(units, "minute", 6) == 0)
		*seconds = period * 60;
	else if (bcmp(units, "hour", 4) == 0)
		*seconds = period * 60 * 60;
	else if (bcmp(units, "day", 3) == 0)
		*seconds = period * 24 * 60 * 60;
	else {
		warnx("%s: bad units, specify %s\n", units,
		    "days, hours, minutes, or seconds");
		return (0);
	}
	return (1);
}
int cvtatos ( uint64_t period , char * units , uint64_t * seconds ) { if ( bcmp ( units , " " , 6 ) == 0 ) * seconds = period ; else if ( bcmp ( units , " " , 6 ) == 0 ) * seconds = period * 60 ; else if ( bcmp ( units , " " , 4 ) == 0 ) * seconds = period * 60 * 60 ; else if ( bcmp ( units , " " , 3 ) == 0 ) * seconds = period * 24 * 60 * 60 ; else { warnx ( " \n " , units , " " ) ; return ( 0 ) ; } return ( 1 ) ; }
Convert ASCII input times to seconds.
Convert ASCII input times to seconds .