rpmatch() — Test for a yes or no response match
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
z/OS® UNIX | both |
Format
#include <stdlib.h>
int rpmatch(const char *response);
External entry point: @@RPMTCH, __rpmtch
General description
Tests whether a string pointed to by response matches either the affirmative or the negative response set by LC_MESSAGES category in the current locale.
To avoid infringing on the user's name space, this nonstandard function has two names. One name is prefixed with two underscore characters, and one name is not. The name without the prefix underscore characters is exposed only when you use LANGLVL(EXTENDED).
To use this function, you must either invoke the function using its external entry point name (that is, the name that begins with two underscore characters), or compile with LANGLVL(EXTENDED). When you use LANGLVL(EXTENDED) any relevant information in the header is also exposed.
Returned value
If the string pointed to by response matches the affirmative
expression in the current locale, rpmatch() returns:
- 1
- If the response string matches the affirmative expression.
- 0
- If the response string matches the negative expression.
- -1
- If the response string does not match either the affirmative or the negative expression.
Example
CELEBR17
/* CELEBR17
This example asks for a reply, and checks the response.
*/
#include "locale.h"
#include "stdio.h"
#include "stdlib.h"
main() {
char *response;
char buffer??(100??);
int rc;
printf("Enter reply");
response = fgets(buffer, 100, stdin);
rc = rpmatch(response);
if (rc > 0)
printf("Response was affirmative\n");
else if (rc == 0)
printf("Response was negative\n");
else
printf("Response was neither negative or affirmative\n");
}