Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

textops : added a new function for getting substring with regular expression #1733

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/modules/textops/textops.c
Expand Up @@ -778,7 +778,7 @@ static int replace_helper(sip_msg_t *msg, regex_t *re, str *val)
@param dst , given pseudo-variable, result will be setted
@param matched_index , index number for finding array ,When nmatch is non-zero, points to an array with at least nmatch elements.
@param match_count , Is the number of matches allowed
return ; 0 is success , -1 or less is failed
@return ; 1 is success , -1 or less is failed
*/
static int get_regsub_string_f(struct sip_msg* msg, char* regex, char* input,
char* dst, char *matched_index, char *match_count)
Expand Down Expand Up @@ -843,7 +843,8 @@ static int get_regsub_string_f(struct sip_msg* msg, char* regex, char* input,
rc = regcomp(&preg , regex , REG_EXTENDED);

if (0 != rc) {
LM_ERR("regular experession coudnt be compiled, Error code: (%d)\n", rc);
LM_ERR("regular experession coudnt be compiled, Error code: (%d)\n", rc);
regfree(&preg);
return -1;
}

Expand All @@ -852,7 +853,7 @@ static int get_regsub_string_f(struct sip_msg* msg, char* regex, char* input,
if(rc==0){ // is matched

if (pmatch[index].rm_so==-1) {
LM_ERR("Unknown offset for reguler expression \n");
LM_ERR("Unknown offset for regular expression \n");
return -1;
}

Expand All @@ -874,10 +875,10 @@ static int get_regsub_string_f(struct sip_msg* msg, char* regex, char* input,
pvresult->setf(msg, &pvresult->pvp, (int)EQ_T, &valx);
return 1;
}else{
LM_ERR("result is NULL \n" );
LM_ERR("match is NULL \n" );
}
}else{
LM_ERR("There isnt any matched\n");
LM_ERR("There isnt any match\n");
}

return 1;
Expand Down