diff options
Diffstat (limited to 'openbsc/src/libcommon/gsm_data.c')
-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 3df69d69c..3cc0c13bc 100644 --- a/openbsc/src/libcommon/gsm_data.c +++ b/openbsc/src/libcommon/gsm_data.c @@ -420,3 +420,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; +} + |