xref: /illumos-gate/usr/src/cmd/oamuser/lib/vexpire.c (revision 8b6b46dcb073dba71917d6a7309f0df7bad798a2)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright 1997 Sun Microsystems, Inc. All rights reserved. */
23 /*	Use is subject to license terms. */
24 
25 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
26 /*	All Rights Reserved  	*/
27 
28 #include	<sys/types.h>
29 #include	<time.h>
30 #include	<users.h>
31 
32 extern long p_getdate();
33 
34 /*
35 	Validate an expiration date string
36 */
37 int
38 valid_expire( string, expire )
39 char *string;
40 time_t *expire;
41 {
42 	time_t tmp, now;
43 	struct tm *tm;
44 
45 	if( !(tmp = (time_t) p_getdate( string ) ) )
46 		return( INVALID );
47 
48 	now = time( (time_t *)0 );
49 
50 	/* Make a time_t for midnight tonight */
51 	tm = localtime( &now );
52 	now -= tm->tm_hour * 60*60 + tm->tm_min * 60 + tm->tm_sec;
53 	now += 24 * 60 * 60;
54 
55 	if( tmp < now ) return( INVALID );
56 
57 	if( expire ) *expire = now;
58 
59 	return( UNIQUE );
60 }
61