/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <regex.h>
#include <locale.h>
#include <langinfo.h>
#include <limits.h>
#include <errno.h>
#include "getresponse.h"
/* defaults - C locale values for yesstr, nostr, yesexpr (LC_MESSAGES) */
#define FREE_MEM \
if (yesstr) \
if (nostr) \
if (yesexpr) \
if (noexpr) \
#define SET_DEFAULT_STRS \
yesstr = DEFAULT_YESSTR; \
nostr = DEFAULT_NOSTR; \
yesexpr = DEFAULT_YESEXPR; \
/* variables used by getresponse functions */
/* for regcomp()/regexec() yesexpr and noexpr */
/*
* This function compiles a regular expression that is used to match an
* affirmative response from the user, and also assigns the strings used
* in the prompts that request affirmative or negative responses. The
* locale's values for YESEXPR, NOEXPR, YESSTR and NOSTR are used.
*
* If there are any problems using the locale's YESEXPR, NOEXPR, YESSTR or NOSTR
* values, default values of YESEXPR, YESSTR and NOSTR will be used
* as a fallback. The default values are the same as the C locale values.
*/
int
init_yes(void)
{
int fallback = 0;
char *yesexpr;
char *noexpr;
return (-1);
}
/* if problem with locale strings, use default values */
fallback = 1;
}
/* Compile the yes and no expressions */
if (fallback == 1) {
/* The fallback yesexpr failed, so exit */
return (-1);
}
/* The locale's yesexpr or noexpr failed so use fallback */
fallback = 1;
}
return (0);
}
static int
{
int i, b;
/* Get user's answer */
i = 0;
for (;;) {
b = getchar();
break;
if (i < LINE_MAX)
ans[i] = b;
i++;
}
if (i >= LINE_MAX)
else
ans[i] = '\0';
}
static int
{
/* Both Expressions Match (reg2 conservative) */
return (0);
}
/* Match */
return (1);
}
return (0);
}
/*
* yes_check() returns 1 if the input string is matched by yesexpr and is
* not matched by noexpr; otherwise yes_check() returns 0.
*/
int
{
}
/*
* no_check() returns 1 if the input string is matched by noexpr and is
* not matched by yesexpr; otherwise no_check() returns 0.
*/
int
{
}
int
yes(void)
{
}
int
no(void)
{
}