mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-04 19:47:31 +00:00
78dbab76d6
* Add _write and _puts methods for r_socket api - fgets -> gets - fix r_socket_printf * More random fixes * typedef all structures in r_util
30 lines
648 B
C
30 lines
648 B
C
/* radare - LGPL - Copyright 2007-2009 pancake<nopcode.org> */
|
|
|
|
#include <r_util.h>
|
|
|
|
#if HAVE_REGEXP
|
|
#include <regex.h>
|
|
/* XXX: This code uses POSIX 2001 . can be nonportable */
|
|
#define NUM_MATCHES 16
|
|
#endif
|
|
|
|
/* returns 1 if 'str' matches 'reg' regexp */
|
|
R_API int r_str_re_match(const char *str, const char *reg)
|
|
{
|
|
#if HAVE_REGEXP
|
|
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;
|
|
#else
|
|
return -1;
|
|
#endif
|
|
}
|
|
|
|
R_API int r_str_re_replace(const char *str, const char *reg, const char *sub)
|
|
{
|
|
/* TODO: not yet implemented */
|
|
return -1;
|
|
}
|