241 lines
6.2 KiB
HTML
241 lines
6.2 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of RPMATCH</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>RPMATCH</H1>
|
|
Section: Linux Programmer's Manual (3)<BR>Updated: 2019-03-06<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
rpmatch - determine if the answer to a question is affirmative or negative
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/stdlib.h">stdlib.h</A>></B>
|
|
|
|
<B>int rpmatch(const char *</B><I>response</I><B>);</B>
|
|
</PRE>
|
|
|
|
<P>
|
|
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
|
|
|
|
|
|
<P>
|
|
|
|
<B>rpmatch</B>():
|
|
|
|
<BR> Since glibc 2.19:
|
|
<BR> _DEFAULT_SOURCE
|
|
<BR> Glibc 2.19 and earlier:
|
|
<BR> _SVID_SOURCE
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<B>rpmatch</B>()
|
|
|
|
handles a user response to yes or no questions, with
|
|
support for internationalization.
|
|
<P>
|
|
|
|
<I>response</I>
|
|
|
|
should be a null-terminated string containing a
|
|
user-supplied response, perhaps obtained with
|
|
<B><A HREF="/cgi-bin/man/man2html?3+fgets">fgets</A></B>(3)
|
|
|
|
or
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getline">getline</A></B>(3).
|
|
|
|
<P>
|
|
|
|
The user's language preference is taken into account per the
|
|
environment variables
|
|
<B>LANG</B>,
|
|
|
|
<B>LC_MESSAGES</B>,
|
|
|
|
and
|
|
<B>LC_ALL</B>,
|
|
|
|
if the program has called
|
|
<B><A HREF="/cgi-bin/man/man2html?3+setlocale">setlocale</A></B>(3)
|
|
|
|
to effect their changes.
|
|
<P>
|
|
|
|
Regardless of the locale, responses matching
|
|
<B>^[Yy]</B>
|
|
|
|
are always accepted as affirmative, and those matching
|
|
<B>^[Nn]</B>
|
|
|
|
are always accepted as negative.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
After examining
|
|
<I>response</I>,
|
|
|
|
<B>rpmatch</B>()
|
|
|
|
returns 0 for a recognized negative response ("no"), 1
|
|
for a recognized positive response ("yes"), and -1 when the value
|
|
of
|
|
<I>response</I>
|
|
|
|
is unrecognized.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
A return value of -1 may indicate either an invalid input, or some
|
|
other error.
|
|
It is incorrect to only test if the return value is nonzero.
|
|
<P>
|
|
|
|
<B>rpmatch</B>()
|
|
|
|
can fail for any of the reasons that
|
|
<B><A HREF="/cgi-bin/man/man2html?3+regcomp">regcomp</A></B>(3)
|
|
|
|
or
|
|
<B><A HREF="/cgi-bin/man/man2html?3+regexec">regexec</A></B>(3)
|
|
|
|
can fail; the cause of the error
|
|
is not available from
|
|
<I>errno</I>
|
|
|
|
or anywhere else, but indicates a
|
|
failure of the regex engine (but this case is indistinguishable from
|
|
that of an unrecognized value of
|
|
<I>response</I>).
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H2>ATTRIBUTES</H2>
|
|
|
|
For an explanation of the terms used in this section, see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
|
|
|
|
<TABLE BORDER>
|
|
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
|
|
<TR VALIGN=top><TD>
|
|
<B>rpmatch</B>()
|
|
|
|
</TD><TD>Thread safety</TD><TD>MT-Safe locale<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
<A NAME="lbAH"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
<B>rpmatch</B>()
|
|
|
|
is not required by any standard, but
|
|
is available on a few other systems.
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H2>BUGS</H2>
|
|
|
|
The
|
|
<B>rpmatch</B>()
|
|
|
|
implementation looks at only the first character
|
|
of
|
|
<I>response</I>.
|
|
|
|
As a consequence, "nyes" returns 0, and
|
|
"ynever; not in a million years" returns 1.
|
|
It would be preferable to accept input strings much more
|
|
strictly, for example (using the extended regular
|
|
expression notation described in
|
|
<B><A HREF="/cgi-bin/man/man2html?7+regex">regex</A></B>(7)):
|
|
|
|
<B>^([yY]|yes|YES)$</B>
|
|
|
|
and
|
|
<B>^([nN]|no|NO)$</B>.
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>EXAMPLE</H2>
|
|
|
|
The following program displays the results when
|
|
<B>rpmatch</B>()
|
|
|
|
is applied to the string given in the program's command-line argument.
|
|
<P>
|
|
|
|
|
|
#define _SVID_SOURCE
|
|
#include <<A HREF="file:///usr/include/locale.h">locale.h</A>>
|
|
#include <<A HREF="file:///usr/include/stdlib.h">stdlib.h</A>>
|
|
#include <<A HREF="file:///usr/include/string.h">string.h</A>>
|
|
#include <<A HREF="file:///usr/include/stdio.h">stdio.h</A>>
|
|
<P>
|
|
int
|
|
main(int argc, char *argv[])
|
|
{
|
|
<BR> if (argc != 2 || strcmp(argv[1], "--help") == 0) {
|
|
<BR> fprintf(stderr, "%s response\n", argv[0]);
|
|
<BR> exit(EXIT_FAILURE);
|
|
<BR> }
|
|
<P>
|
|
<BR> setlocale(LC_ALL, "");
|
|
<BR> printf("rpmatch() returns: %d\n", rpmatch(argv[1]));
|
|
<BR> exit(EXIT_SUCCESS);
|
|
}
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+fgets">fgets</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getline">getline</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+nl_langinfo">nl_langinfo</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+regcomp">regcomp</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+setlocale">setlocale</A></B>(3)
|
|
|
|
<A NAME="lbAL"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="4"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">ATTRIBUTES</A><DD>
|
|
<DT id="7"><A HREF="#lbAH">CONFORMING TO</A><DD>
|
|
<DT id="8"><A HREF="#lbAI">BUGS</A><DD>
|
|
<DT id="9"><A HREF="#lbAJ">EXAMPLE</A><DD>
|
|
<DT id="10"><A HREF="#lbAK">SEE ALSO</A><DD>
|
|
<DT id="11"><A HREF="#lbAL">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:54 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|