*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Tru64 Unix man pages -> rpmatch (3)              



NAME    [Toc]    [Back]

       rpmatch  -  Determine whether a response is affirmative or

SYNOPSIS    [Toc]    [Back]

       #include <stdlib.h>

       int rpmatch(
               const char *response );

LIBRARY    [Toc]    [Back]

       Standard C Library (libc)

PARAMETERS    [Toc]    [Back]

       User input entered in response to a question that requires
       an affirmative or negative answer.

DESCRIPTION    [Toc]    [Back]

       The rpmatch() function determines whether the string value
       of the response parameter matches the affirmative or negative
  response  expression as specified by the LC_MESSAGES
       category in the program's current  locale.  Both  response
       expressions,  defined in the locale, may be extended regular

       A possible value of the affirmative  expression,  yesexpr,
       for  a  English-language locale is "^([yY]|[yY][eE][sS])".
       This expression will  match  any  value  of  the  response
       parameter  that has consists of the letter Y (in uppercase
       or lowercase) or the letters YES (in any mixture of uppercase
 and lowercase letters).

RETURN VALUES    [Toc]    [Back]

       A  value  of  1  is  returned  if  the string value of the
       response parameter is matched by the  affirmative  expression;
  a value of 0 (zero) is returned if the string value
       of the response  parameter  is  matched  by  the  negative
       expression. If neither expression matches the string value
       of the response parameter, a value of -1 is returned.

EXAMPLES    [Toc]    [Back]

       The following example requests a response  from  the  user
       and  uses  the  rpmatch()  function  to  determine  if the
       response is affirmative or negative.

       #include <stdlib.h> #include <stdio.h> #include <locale.h>
       #include <string.h> #define SLENGTH 80

       main() {

           char    str[SLENGTH], *eol;
           int    ans;

           (void)setlocale(LC_ALL, " " );

           printf("Do you want to perform this operation: ");
           fgets(str, SLENGTH, stdin);
           if ((eol = strchr(str, '\n')) != NULL)
               *eol = '\0';  /* Replace newline with null */
               return;  /* Line entered too long */

           ans = rpmatch(str);
           if (ans == 1)
               printf("You responded affirmatively\n");
           else if (ans == 0)
               printf("You responded negatively\n");
            printf("Your answer did not match\n"); }

SEE ALSO    [Toc]    [Back]

       Commands: grep(1).

       Functions: regcomp(3), regexec(3), setlocale(3).

       Files: locale(4).

[ Back ]
 Similar pages
Name OS Title
signbit FreeBSD determine whether a floating-point number's sign is negative
yes FreeBSD be repetitively affirmative
yes HP-UX be repetitively affirmative
yes OpenBSD be repetitively affirmative
minexponent IRIX Returns the minimum (most negative) exponent of a real number in the numeric model
swask HP-UX ask for user response
bindtable IRIX invoke scripts in response to X events
dialog IRIX Create modal dialog and wait for response
res_search Tru64 Query a domain server and check the response
res_send Tru64 Send a query to a name server and retrieve a response
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service