17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 237c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* 277c478bd9Sstevel@tonic-gate * Copyright (c) 1997,1998 by Sun Microsystems, Inc. 287c478bd9Sstevel@tonic-gate * All rights reserved. 297c478bd9Sstevel@tonic-gate */ 30*4656d474SGarrett D'Amore /* 31*4656d474SGarrett D'Amore * Copyright 2010 Nexenta Systems, Inc. All rights reserved. 32*4656d474SGarrett D'Amore */ 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate /*LINTLIBRARY*/ 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #include <stdio.h> 377c478bd9Sstevel@tonic-gate #include <string.h> 387c478bd9Sstevel@tonic-gate #include <ctype.h> 397c478bd9Sstevel@tonic-gate #include <limits.h> 407c478bd9Sstevel@tonic-gate #include <sys/types.h> 417c478bd9Sstevel@tonic-gate #include <stdlib.h> 427c478bd9Sstevel@tonic-gate #include "libadm.h" 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate static int fmtcheck(char *); 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #define PROMPT "Enter the time of day" 477c478bd9Sstevel@tonic-gate #define ERRMSG "Please enter the time of day. Format is" 487c478bd9Sstevel@tonic-gate #define DEFAULT "%H:%M" 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate #define TLEN 3 517c478bd9Sstevel@tonic-gate #define LH 00 527c478bd9Sstevel@tonic-gate #define UH 23 537c478bd9Sstevel@tonic-gate #define USH 12 547c478bd9Sstevel@tonic-gate #define LM 00 557c478bd9Sstevel@tonic-gate #define UM 59 567c478bd9Sstevel@tonic-gate #define LS 00 577c478bd9Sstevel@tonic-gate #define US 59 587c478bd9Sstevel@tonic-gate #define DELIM1 ':' 597c478bd9Sstevel@tonic-gate #define BLANK ' ' 607c478bd9Sstevel@tonic-gate #define TAB ' ' 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate static void 63*4656d474SGarrett D'Amore setmsg(char *msg, char *fmt, size_t sz) 647c478bd9Sstevel@tonic-gate { 657c478bd9Sstevel@tonic-gate if (fmt == NULL) 667c478bd9Sstevel@tonic-gate fmt = DEFAULT; 67*4656d474SGarrett D'Amore (void) snprintf(msg, sz, "%s <%s>.", ERRMSG, fmt); 687c478bd9Sstevel@tonic-gate } 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate static char * 717c478bd9Sstevel@tonic-gate p_ndig(char *string, int *value) 727c478bd9Sstevel@tonic-gate { 737c478bd9Sstevel@tonic-gate char *ptr; 747c478bd9Sstevel@tonic-gate int accum = 0; 757c478bd9Sstevel@tonic-gate int n = 2; 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate if (!string) 787c478bd9Sstevel@tonic-gate return (0); 797c478bd9Sstevel@tonic-gate for (ptr = string; *ptr && n > 0; n--, ptr++) { 807c478bd9Sstevel@tonic-gate if (! isdigit((unsigned char)*ptr)) 817c478bd9Sstevel@tonic-gate return (NULL); 827c478bd9Sstevel@tonic-gate accum = (10 * accum) + (*ptr - '0'); 837c478bd9Sstevel@tonic-gate } 847c478bd9Sstevel@tonic-gate if (n) 857c478bd9Sstevel@tonic-gate return (NULL); 867c478bd9Sstevel@tonic-gate *value = accum; 877c478bd9Sstevel@tonic-gate return (ptr); 887c478bd9Sstevel@tonic-gate } 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate static char * 917c478bd9Sstevel@tonic-gate p_time(char *string, int llim, int ulim) 927c478bd9Sstevel@tonic-gate { 937c478bd9Sstevel@tonic-gate char *ptr; 947c478bd9Sstevel@tonic-gate int begin = -1; 957c478bd9Sstevel@tonic-gate if (!(ptr = p_ndig(string, &begin))) 967c478bd9Sstevel@tonic-gate return (NULL); 977c478bd9Sstevel@tonic-gate if (begin >= llim && begin <= ulim) 987c478bd9Sstevel@tonic-gate return (ptr); 997c478bd9Sstevel@tonic-gate else return (NULL); 1007c478bd9Sstevel@tonic-gate } 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate /* p_meridian will parse the string for the meridian - AM/PM or am/pm */ 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate static char * 1057c478bd9Sstevel@tonic-gate p_meridian(char *string) 1067c478bd9Sstevel@tonic-gate { 1077c478bd9Sstevel@tonic-gate static char *middle[] = { "AM", "PM", "am", "pm" }; 1087c478bd9Sstevel@tonic-gate int legit, n; 1097c478bd9Sstevel@tonic-gate char mid[TLEN]; 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate legit = 0; 1127c478bd9Sstevel@tonic-gate n = 0; 1137c478bd9Sstevel@tonic-gate mid[2] = '\0'; 1147c478bd9Sstevel@tonic-gate (void) sscanf(string, "%2s", mid); 1157c478bd9Sstevel@tonic-gate while (!(legit) && (n < 4)) { 1167c478bd9Sstevel@tonic-gate if ((strncmp(mid, middle[n], 2)) == 0) 1177c478bd9Sstevel@tonic-gate legit = 1; /* found legitimate string */ 1187c478bd9Sstevel@tonic-gate n++; 1197c478bd9Sstevel@tonic-gate } 1207c478bd9Sstevel@tonic-gate if (legit) 1217c478bd9Sstevel@tonic-gate return (string+2); 1227c478bd9Sstevel@tonic-gate return (NULL); 1237c478bd9Sstevel@tonic-gate } 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate static char * 1267c478bd9Sstevel@tonic-gate p_delim(char *string, char dchoice) 1277c478bd9Sstevel@tonic-gate { 1287c478bd9Sstevel@tonic-gate char dlm; 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate if (! string) 1317c478bd9Sstevel@tonic-gate return (NULL); 1327c478bd9Sstevel@tonic-gate (void) sscanf(string, "%1c", &dlm); 1337c478bd9Sstevel@tonic-gate return ((dlm == dchoice) ? string + 1 : NULL); 1347c478bd9Sstevel@tonic-gate } 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate int 1377c478bd9Sstevel@tonic-gate cktime_val(char *fmt, char *input) 1387c478bd9Sstevel@tonic-gate { 1397c478bd9Sstevel@tonic-gate char ltrl, dfl; 1407c478bd9Sstevel@tonic-gate int valid = 1; /* time of day string is valid for format */ 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate if ((fmt != NULL) && (fmtcheck(fmt) == 1)) 1437c478bd9Sstevel@tonic-gate return (4); 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate if (fmt == NULL) 1467c478bd9Sstevel@tonic-gate fmt = DEFAULT; 1477c478bd9Sstevel@tonic-gate ltrl = '\0'; 1487c478bd9Sstevel@tonic-gate while (*fmt && valid) { 1497c478bd9Sstevel@tonic-gate if ((*fmt) == '%') { 1507c478bd9Sstevel@tonic-gate switch (*++fmt) { 1517c478bd9Sstevel@tonic-gate case 'H': 1527c478bd9Sstevel@tonic-gate input = p_time(input, LH, UH); 1537c478bd9Sstevel@tonic-gate if (!input) 1547c478bd9Sstevel@tonic-gate valid = 0; 1557c478bd9Sstevel@tonic-gate break; 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate case 'M': 1587c478bd9Sstevel@tonic-gate input = p_time(input, LM, UM); 1597c478bd9Sstevel@tonic-gate if (!input) 1607c478bd9Sstevel@tonic-gate valid = 0; 1617c478bd9Sstevel@tonic-gate break; 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate case 'S': 1647c478bd9Sstevel@tonic-gate input = p_time(input, LS, US); 1657c478bd9Sstevel@tonic-gate if (!input) 1667c478bd9Sstevel@tonic-gate valid = 0; 1677c478bd9Sstevel@tonic-gate break; 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate case 'T': 1707c478bd9Sstevel@tonic-gate input = p_time(input, LH, UH); 1717c478bd9Sstevel@tonic-gate if (!input) { 1727c478bd9Sstevel@tonic-gate valid = 0; 1737c478bd9Sstevel@tonic-gate break; 1747c478bd9Sstevel@tonic-gate } 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate input = p_delim(input, DELIM1); 1777c478bd9Sstevel@tonic-gate if (!input) { 1787c478bd9Sstevel@tonic-gate valid = 0; 1797c478bd9Sstevel@tonic-gate break; 1807c478bd9Sstevel@tonic-gate } 1817c478bd9Sstevel@tonic-gate input = p_time(input, LM, UM); 1827c478bd9Sstevel@tonic-gate if (!input) { 1837c478bd9Sstevel@tonic-gate valid = 0; 1847c478bd9Sstevel@tonic-gate break; 1857c478bd9Sstevel@tonic-gate } 1867c478bd9Sstevel@tonic-gate input = p_delim(input, DELIM1); 1877c478bd9Sstevel@tonic-gate if (!input) { 1887c478bd9Sstevel@tonic-gate valid = 0; 1897c478bd9Sstevel@tonic-gate break; 1907c478bd9Sstevel@tonic-gate } 1917c478bd9Sstevel@tonic-gate input = p_time(input, LS, US); 1927c478bd9Sstevel@tonic-gate if (!input) 1937c478bd9Sstevel@tonic-gate valid = 0; 1947c478bd9Sstevel@tonic-gate break; 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate case 'R': 1977c478bd9Sstevel@tonic-gate input = p_time(input, LH, UH); 1987c478bd9Sstevel@tonic-gate if (!input) { 1997c478bd9Sstevel@tonic-gate valid = 0; 2007c478bd9Sstevel@tonic-gate break; 2017c478bd9Sstevel@tonic-gate } 2027c478bd9Sstevel@tonic-gate input = p_delim(input, DELIM1); 2037c478bd9Sstevel@tonic-gate if (!input) { 2047c478bd9Sstevel@tonic-gate valid = 0; 2057c478bd9Sstevel@tonic-gate break; 2067c478bd9Sstevel@tonic-gate } 2077c478bd9Sstevel@tonic-gate input = p_time(input, LM, UM); 2087c478bd9Sstevel@tonic-gate if (!input) { 2097c478bd9Sstevel@tonic-gate valid = 0; 2107c478bd9Sstevel@tonic-gate break; 2117c478bd9Sstevel@tonic-gate } 2127c478bd9Sstevel@tonic-gate break; 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate case 'r': 2157c478bd9Sstevel@tonic-gate input = p_time(input, LH, USH); 2167c478bd9Sstevel@tonic-gate if (!input) { 2177c478bd9Sstevel@tonic-gate valid = 0; 2187c478bd9Sstevel@tonic-gate break; 2197c478bd9Sstevel@tonic-gate } 2207c478bd9Sstevel@tonic-gate input = p_delim(input, DELIM1); 2217c478bd9Sstevel@tonic-gate if (!input) { 2227c478bd9Sstevel@tonic-gate valid = 0; 2237c478bd9Sstevel@tonic-gate break; 2247c478bd9Sstevel@tonic-gate } 2257c478bd9Sstevel@tonic-gate input = p_time(input, LM, UM); 2267c478bd9Sstevel@tonic-gate if (!input) { 2277c478bd9Sstevel@tonic-gate valid = 0; 2287c478bd9Sstevel@tonic-gate break; 2297c478bd9Sstevel@tonic-gate } 2307c478bd9Sstevel@tonic-gate input = p_delim(input, DELIM1); 2317c478bd9Sstevel@tonic-gate if (!input) { 2327c478bd9Sstevel@tonic-gate valid = 0; 2337c478bd9Sstevel@tonic-gate break; 2347c478bd9Sstevel@tonic-gate } 2357c478bd9Sstevel@tonic-gate input = p_time(input, LS, US); 2367c478bd9Sstevel@tonic-gate if (!input) { 2377c478bd9Sstevel@tonic-gate valid = 0; 2387c478bd9Sstevel@tonic-gate break; 2397c478bd9Sstevel@tonic-gate } 2407c478bd9Sstevel@tonic-gate input = p_delim(input, BLANK); 2417c478bd9Sstevel@tonic-gate if (!input) { 2427c478bd9Sstevel@tonic-gate valid = 0; 2437c478bd9Sstevel@tonic-gate break; 2447c478bd9Sstevel@tonic-gate } 2457c478bd9Sstevel@tonic-gate input = p_meridian(input); 2467c478bd9Sstevel@tonic-gate if (!input) 2477c478bd9Sstevel@tonic-gate valid = 0; 2487c478bd9Sstevel@tonic-gate break; 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate case 'I': 2517c478bd9Sstevel@tonic-gate input = p_time(input, LH, USH); 2527c478bd9Sstevel@tonic-gate if (!input) 2537c478bd9Sstevel@tonic-gate valid = 0; 2547c478bd9Sstevel@tonic-gate break; 2557c478bd9Sstevel@tonic-gate 2567c478bd9Sstevel@tonic-gate case 'p': 2577c478bd9Sstevel@tonic-gate input = p_meridian(input); 2587c478bd9Sstevel@tonic-gate if (!input) 2597c478bd9Sstevel@tonic-gate valid = 0; 2607c478bd9Sstevel@tonic-gate break; 2617c478bd9Sstevel@tonic-gate 2627c478bd9Sstevel@tonic-gate default: 2637c478bd9Sstevel@tonic-gate (void) sscanf(input++, "%1c", <rl); 2647c478bd9Sstevel@tonic-gate } 2657c478bd9Sstevel@tonic-gate } else { 2667c478bd9Sstevel@tonic-gate dfl = '\0'; 2677c478bd9Sstevel@tonic-gate (void) sscanf(input, "%1c", &dfl); 2687c478bd9Sstevel@tonic-gate input++; 2697c478bd9Sstevel@tonic-gate } 2707c478bd9Sstevel@tonic-gate fmt++; 2717c478bd9Sstevel@tonic-gate } 2727c478bd9Sstevel@tonic-gate 2737c478bd9Sstevel@tonic-gate if (!(*fmt) && (input) && (*input)) 2747c478bd9Sstevel@tonic-gate valid = 0; 2757c478bd9Sstevel@tonic-gate 2767c478bd9Sstevel@tonic-gate return ((valid == 0)); 2777c478bd9Sstevel@tonic-gate } 2787c478bd9Sstevel@tonic-gate 2797c478bd9Sstevel@tonic-gate int 2807c478bd9Sstevel@tonic-gate cktime_err(char *fmt, char *error) 2817c478bd9Sstevel@tonic-gate { 2827c478bd9Sstevel@tonic-gate char defmesg[128]; 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate if ((fmt != NULL) && (fmtcheck(fmt) == 1)) 2857c478bd9Sstevel@tonic-gate return (4); 286*4656d474SGarrett D'Amore setmsg(defmesg, fmt, sizeof (defmesg)); 2877c478bd9Sstevel@tonic-gate puterror(stdout, defmesg, error); 2887c478bd9Sstevel@tonic-gate return (0); 2897c478bd9Sstevel@tonic-gate } 2907c478bd9Sstevel@tonic-gate 2917c478bd9Sstevel@tonic-gate int 2927c478bd9Sstevel@tonic-gate cktime_hlp(char *fmt, char *help) 2937c478bd9Sstevel@tonic-gate { 2947c478bd9Sstevel@tonic-gate char defmesg[128]; 2957c478bd9Sstevel@tonic-gate 2967c478bd9Sstevel@tonic-gate if ((fmt != NULL) && (fmtcheck(fmt) == 1)) 2977c478bd9Sstevel@tonic-gate return (4); 298*4656d474SGarrett D'Amore setmsg(defmesg, fmt, sizeof (defmesg)); 2997c478bd9Sstevel@tonic-gate puthelp(stdout, defmesg, help); 3007c478bd9Sstevel@tonic-gate return (0); 3017c478bd9Sstevel@tonic-gate } 3027c478bd9Sstevel@tonic-gate 3037c478bd9Sstevel@tonic-gate /* 3047c478bd9Sstevel@tonic-gate * A little state machine that checks out the format to 3057c478bd9Sstevel@tonic-gate * make sure it is acceptable. 3067c478bd9Sstevel@tonic-gate * return value 1: NG 3077c478bd9Sstevel@tonic-gate * return value 0: OK 3087c478bd9Sstevel@tonic-gate */ 3097c478bd9Sstevel@tonic-gate int 3107c478bd9Sstevel@tonic-gate fmtcheck(char *fmt) 3117c478bd9Sstevel@tonic-gate { 3127c478bd9Sstevel@tonic-gate int percent = 0; 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate while (*fmt) { 3157c478bd9Sstevel@tonic-gate switch (*fmt++) { 3167c478bd9Sstevel@tonic-gate case '%': /* previous state must be start or letter */ 3177c478bd9Sstevel@tonic-gate if (percent == 0) 3187c478bd9Sstevel@tonic-gate percent = 1; 3197c478bd9Sstevel@tonic-gate else 3207c478bd9Sstevel@tonic-gate return (1); 3217c478bd9Sstevel@tonic-gate break; 3227c478bd9Sstevel@tonic-gate case 'H': /* previous state must be "%" */ 3237c478bd9Sstevel@tonic-gate case 'M': 3247c478bd9Sstevel@tonic-gate case 'S': 3257c478bd9Sstevel@tonic-gate case 'T': 3267c478bd9Sstevel@tonic-gate case 'R': 3277c478bd9Sstevel@tonic-gate case 'r': 3287c478bd9Sstevel@tonic-gate case 'I': 3297c478bd9Sstevel@tonic-gate case 'p': 3307c478bd9Sstevel@tonic-gate if (percent == 1) 3317c478bd9Sstevel@tonic-gate percent = 0; 3327c478bd9Sstevel@tonic-gate else 3337c478bd9Sstevel@tonic-gate return (1); 3347c478bd9Sstevel@tonic-gate break; 3357c478bd9Sstevel@tonic-gate case TAB: /* previous state must be start or letter */ 3367c478bd9Sstevel@tonic-gate case BLANK: 3377c478bd9Sstevel@tonic-gate case DELIM1: 3387c478bd9Sstevel@tonic-gate if (percent == 1) 3397c478bd9Sstevel@tonic-gate return (1); 3407c478bd9Sstevel@tonic-gate break; 3417c478bd9Sstevel@tonic-gate default: 3427c478bd9Sstevel@tonic-gate return (1); 3437c478bd9Sstevel@tonic-gate } 3447c478bd9Sstevel@tonic-gate } 3457c478bd9Sstevel@tonic-gate return (percent); 3467c478bd9Sstevel@tonic-gate } 3477c478bd9Sstevel@tonic-gate 3487c478bd9Sstevel@tonic-gate int 3497c478bd9Sstevel@tonic-gate cktime(char *tod, char *fmt, char *defstr, char *error, char *help, 3507c478bd9Sstevel@tonic-gate char *prompt) 3517c478bd9Sstevel@tonic-gate { 3527c478bd9Sstevel@tonic-gate char input[MAX_INPUT], 3537c478bd9Sstevel@tonic-gate defmesg[128]; 3547c478bd9Sstevel@tonic-gate 3557c478bd9Sstevel@tonic-gate if ((fmt != NULL) && (fmtcheck(fmt) == 1)) 3567c478bd9Sstevel@tonic-gate return (4); 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate if (fmt == NULL) 3597c478bd9Sstevel@tonic-gate fmt = DEFAULT; 360*4656d474SGarrett D'Amore setmsg(defmesg, fmt, sizeof (defmesg)); 3617c478bd9Sstevel@tonic-gate if (!prompt) 3627c478bd9Sstevel@tonic-gate prompt = "Enter a time of day"; 3637c478bd9Sstevel@tonic-gate 3647c478bd9Sstevel@tonic-gate start: 3657c478bd9Sstevel@tonic-gate putprmpt(stderr, prompt, NULL, defstr); 3667c478bd9Sstevel@tonic-gate if (getinput(input)) 3677c478bd9Sstevel@tonic-gate return (1); 3687c478bd9Sstevel@tonic-gate 3697c478bd9Sstevel@tonic-gate if (!strlen(input)) { 3707c478bd9Sstevel@tonic-gate if (defstr) { 3717c478bd9Sstevel@tonic-gate (void) strcpy(tod, defstr); 3727c478bd9Sstevel@tonic-gate return (0); 3737c478bd9Sstevel@tonic-gate } 3747c478bd9Sstevel@tonic-gate puterror(stderr, defmesg, error); 3757c478bd9Sstevel@tonic-gate goto start; 3767c478bd9Sstevel@tonic-gate } 3777c478bd9Sstevel@tonic-gate if (strcmp(input, "?") == 0) { 3787c478bd9Sstevel@tonic-gate puthelp(stderr, defmesg, help); 3797c478bd9Sstevel@tonic-gate goto start; 3807c478bd9Sstevel@tonic-gate } 3817c478bd9Sstevel@tonic-gate if (ckquit && (strcmp(input, "q") == 0)) 3827c478bd9Sstevel@tonic-gate return (3); 3837c478bd9Sstevel@tonic-gate 3847c478bd9Sstevel@tonic-gate if (cktime_val(fmt, input)) { 3857c478bd9Sstevel@tonic-gate puterror(stderr, defmesg, error); 3867c478bd9Sstevel@tonic-gate goto start; 3877c478bd9Sstevel@tonic-gate } 3887c478bd9Sstevel@tonic-gate (void) strcpy(tod, input); 3897c478bd9Sstevel@tonic-gate return (0); 3907c478bd9Sstevel@tonic-gate } 391