ESAPI-C 1.0
The OWASP Enterprise Security API for C

validate.c File Reference

A Validation module implementation. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <regex.h>
#include "validate.h"

Go to the source code of this file.

Data Structures

struct  element
 A precompiled regex cache entry. More...

Typedefs

typedef struct element element
 A precompiled regex cache entry.

Functions

int _cmp_ele (element *a, element *b)
int contains_char (char *s, char c)
char * strip_chars (char *s, char *valid_chars)
 Remove all characters from the given input character array that are also found in the given valid characters array.
int is_valid (char *input, char *regex, int flags)
 Returns true if the given regular expression matches the given data.

Variables

elementpattern_list = NULL
 A cache of pre-compiled regex's stored as doubly-linked list.

Detailed Description

A Validation module implementation.

Since:
January 30, 2011

Definition in file validate.c.


Function Documentation

int is_valid ( char *  ,
char *  ,
int   
)

Returns true if the given regular expression matches the given data.

Parameters:
inputA character array containing the user input data to validate.
typeThe regular expression name that maps to the actual regular expression from "ESAPI.properties".
flagsMay be the bitwise-or of one or more of the following: REG_EXTENDED, REG_ICASE, REG_NOSUB, REG_NEWLINE.
Returns:
0 on successful completion, or nonzero to indicate an error.

Definition at line 60 of file validate.c.

char* strip_chars ( char *  ,
char *   
)

Remove all characters from the given input character array that are also found in the given valid characters array.

Parameters:
inputA character array containing the user input data to validate.
valid_charsA character array containing the characters to strip.

Definition at line 38 of file validate.c.

 All Data Structures Files Functions Variables Typedefs Defines