pancake c5e588e6e5 * Initial import of libr
- Previous commits has been reported in the ChangeLog file
  - hg log has been lost (moved inside ChangeLog)
  - Old radare1 repository has removed all the libr
2009-02-05 22:08:46 +01:00

25 lines
595 B
C

/* radare - LGPL - Copyright 2007-2009 pancake<nopcode.org> */
#include <r_util.h>
#include <sys/types.h>
#include <regex.h>
/* XXX: This code uses POSIX 2001 . can be nonportable */
#define NUM_MATCHES 16
/* returns 1 if 'str' matches 'reg' regexp */
int r_str_re_match(const char *str, const char *reg)
{
regex_t preg;
regmatch_t pmatch[NUM_MATCHES];
if (regcomp(&preg, reg, REG_EXTENDED))
return -1;
return (regexec (&preg, str, NUM_MATCHES, pmatch, 0))?1:0;
}
int r_str_re_replace(const char *str, const char *reg, const char *sub)
{
/* TODO: not yet implemented */
return -1;
}