Name

ap_checkmask — check whether a string matches a mask

Synopsis

int ap_checkmask(const char *data, const char *mask)

Checks whether data conforms to the mask in mask. mask is composed of the following characters:

@

An uppercase letter

$

A lowercase letter

&

A hexadecimal digit

#

A decimal digit

~

A decimal digit or a space

*

Any number of any character

Anything else

Itself

data is arbitrarily limited to 256 characters. It returns 1 for a match, 0 if not. For example, the following code checks for RFC 1123 date format:

if(ap_checkmask(date, "## @$$ #### ##:##:## *"))
    ...

Get Apache: The Definitive Guide, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.