rpmatch(3)


NAME

   rpmatch  -  determine  if  the  answer  to a question is affirmative or
   negative

SYNOPSIS

   #include <stdlib.h>

   int rpmatch(const char *response);

   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

   rpmatch():
       Since glibc 2.19:
           _DEFAULT_SOURCE
       Glibc 2.19 and earlier:
           _SVID_SOURCE

DESCRIPTION

   rpmatch() handles a user response to yes or no questions, with  support
   for internationalization.

   response  should be a null-terminated string containing a user-supplied
   response, perhaps obtained with fgets(3) or getline(3).

   The  user's  language  preference  is  taken  into  account   per   the
   environment variables LANG, LC_MESSAGES, and LC_ALL, if the program has
   called setlocale(3) to effect their changes.

   Regardless of the locale, responses matching ^[Yy] are always  accepted
   as  affirmative,  and  those  matching  ^[Nn]  are  always  accepted as
   negative.

RETURN VALUE

   After examining response, rpmatch() returns 0 for a recognized negative
   response  ("no"),  1 for a recognized positive response ("yes"), and -1
   when the value of response is unrecognized.

ERRORS

   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.

   rpmatch() can fail for any of the reasons that regcomp(3) or regexec(3)
   can  fail;  the  cause  of  the  error  is  not available from errno or
   anywhere else, but indicates a failure of the regex  engine  (but  this
   case  is  indistinguishable  from  that  of  an  unrecognized  value of
   response).

ATTRIBUTES

   For  an  explanation  of  the  terms  used   in   this   section,   see
   attributes(7).

   
   Interface  Attribute      Value          
   
   rpmatch()  Thread safety  MT-Safe locale 
   

CONFORMING TO

   rpmatch()  is  not  required by any standard, but is available on a few
   other systems.

BUGS

   The rpmatch() implementation looks  at  only  the  first  character  of
   response.   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  regex(7)):  ^([yY]|yes|YES)$   and
   ^([nN]|no|NO)$.

EXAMPLE

   The following program displays the results when rpmatch() is applied to
   the string given in the program's command-line argument.

   #define _SVID_SOURCE
   #include <locale.h>
   #include <stdlib.h>
   #include <string.h>
   #include <stdio.h>

   int
   main(int argc, char *argv[])
   {
       if (argc != 2 || strcmp(argv[1], "--help") == 0) {
           fprintf(stderr, "%s response\n", argv[0]);
           exit(EXIT_FAILURE);
       }

       setlocale(LC_ALL, "");
       printf("rpmatch() returns: %d\n", rpmatch(argv[1]));
       exit(EXIT_SUCCESS);
   }

SEE ALSO

   fgets(3), getline(3), nl_langinfo(3), regcomp(3), setlocale(3)

COLOPHON

   This page is part of release 4.09 of the Linux  man-pages  project.   A
   description  of  the project, information about reporting bugs, and the
   latest    version    of    this    page,    can     be     found     at
   https://www.kernel.org/doc/man-pages/.


More Linux Commands

manpages/XkbLookupKeyBinding.3.html
XkbLookupKeyBinding(3) - Find the string bound to a key by X
XkbLookupKeyBinding is the equivalent of the core XLookupString function. XRebindKeysym binds an ASCII string to a specified keysym, so that the string and keys

manpages/grub2-mkconfig.8.html
grub2-mkconfig(8) generate a GRUB configuration file........
Generate a grub config file -o, --output=FILE output generated config to FILE [default=stdout] -h, --help print this message and exit -v, --version print the ve

manpages/Tk_GetOptionInfo.3.html
Tk_GetOptionInfo(3) - process configuration options.........
These procedures handle most of the details of parsing configuration options such as those for Tk widgets. Given a description of what options are supported, th

manpages/stime.2.html
stime(2) - set time (System calls - Linux man page).........
stime() sets the systems idea of the time and date. The time, pointed to by t, is measured in seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). stime()

manpages/grub2-set-default.8.html
grub2-set-default(8) set the saved default boot entry for GR
Set the default boot menu entry for GRUB. This requires setting GRUB_DEFAULT=saved in /etc/default/grub. -h, --help print this message and exit -v, --version pr

manpages/register_config_handler.3.html
register_config_handler(3) - netsnmp_config_api functions...
The functions are a fairly extensible system of parsing various configuration files at the run time of an application. The configuration file flow is broken int

manpages/qio.3.html
qio(3) - Quick I/O routines for reading files (Man Page)....
The routines described in this manual page are part of libinn(3). They are used to provide quick read access to files; the QIO routines use buffering adapted to

manpages/set_robust_list.2.html
set_robust_list(2) get set list of robust futexes (ManPage)
set_robust_list.2 - The robust futex implementation needs to maintain per-thread lists of robust futexes which are unlocked when the thread exits. These lists a

manpages/libsmbclient.7.html
libsmbclient(7) - An extension library for browsers and that
This tool is part of the samba(7) suite. libsmbclient is a library toolset that permits applications to manipulate CIFS/SMB network resources using many of the

manpages/argv.n.html
argv(n) Variables used by Tcl ______________________________
The following global variables are created and managed automatically by the Tcl library. Except where noted below, these variables should normally be treated as

manpages/xrdb.1.html
xrdb(1) - X server resource database utility (Man Page).....
Xrdb is used to get or set the contents of the RESOURCE_MANAGER property on the root window of screen 0, or the SCREEN_RESOURCES property on the root window of

manpages/rmid-java-1.7.0-openjdk.1.html
rmid-java-1.7.0-openjdk(1) (Commands - Linux man page)......
rmid-java-1.7.0-openjdk.1 - The rmid tool starts the activation system daemon. The activation system daemon must be started before activatable objects can be ei





We can't live, work or learn in freedom unless the software we use is free.