#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <regex.h>#include <string.h>#include <errno.h>#include "../include/cupl.h"Go to the source code of this file.
Functions | |
| int | cupl_match_regex (char *buffer, char *pattern) |
|
||||||||||||
|
Definition at line 63 of file string.c. References errno. Referenced by main(). 00064 {
00065 int ret = 0;
00066 regex_t *regexp; /* Regular expression pointer for the filter. */
00067
00068 /* Allocate space for the regular expressions. */
00069 if ((regexp = (regex_t *) malloc(sizeof(regex_t))) == NULL) {
00070 fprintf(stderr, "%s: %d: malloc(): %s.\n", __FILE__, __LINE__, strerror(errno));
00071 return -1;
00072 }
00073
00074 memset(regexp, 0, sizeof(regex_t));
00075
00076 if ((ret = regcomp(regexp, pattern, 0)) != 0) /* Compile the regular expression. */
00077 {
00078 regfree(regexp);
00079 free(regexp);
00080 return -1;
00081 }
00082
00083 ret = regex_match_pattern(regexp, buffer);
00084
00085 regfree(regexp);
00086 free(regexp);
00087
00088 return ret;
00089 }
|
1.3.9.1