diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-06-09 21:48:49 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-08-22 18:21:33 +0200 |
commit | 06c9da6c22f674c86e16e1c4dde9932a49b8cbea (patch) | |
tree | 933ac21823ea2bd9f785c9364354a248f0e4dbb6 /openbsc/src/libcommon | |
parent | 8697e43bb2b9d6f217090ca93057d9d4ab6942a9 (diff) |
misc: Move the bsc_parse_reg to libcommom and name it gsm_parse_reg
Move the regexp parsing code from the NAT to libcommon as it will
be used by the NAT and BSC code. This also adds the #include <regex.h>
include to gsm_data. This header should be split up.
Diffstat (limited to 'openbsc/src/libcommon')
-rw-r--r-- | openbsc/src/libcommon/gsm_data.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c index c70ffaee7..832775823 100644 --- a/openbsc/src/libcommon/gsm_data.c +++ b/openbsc/src/libcommon/gsm_data.c @@ -419,3 +419,29 @@ int gsm48_ra_id_by_bts(uint8_t *buf, struct gsm_bts *bts) return gsm48_construct_ra(buf, &raid); } + +int gsm_parse_reg(void *ctx, regex_t *reg, char **str, int argc, const char **argv) +{ + int ret; + + ret = 0; + if (*str) { + talloc_free(*str); + *str = NULL; + } + regfree(reg); + + if (argc > 0) { + *str = talloc_strdup(ctx, argv[0]); + ret = regcomp(reg, argv[0], 0); + + /* handle compilation failures */ + if (ret != 0) { + talloc_free(*str); + *str = NULL; + } + } + + return ret; +} + |