139 |
*/ |
*/ |
140 |
int search_response(char *results) |
int search_response(char *results) |
141 |
{ |
{ |
142 |
int s; |
int s, len; |
143 |
char buf[RESPONSE_BUFFER_MAX]; |
char buf[RESPONSE_BUFFER_MAX]; |
144 |
regex_t compexp; |
regex_t compexp; |
145 |
regmatch_t match[2]; |
regmatch_t match[2]; |
146 |
const char *reg = "\\* SEARCH ([[:digit:] ]*)"; |
const char *reg = "\\* SEARCH([[:digit:] ]*)"; |
147 |
|
|
148 |
|
len = strlen(results); |
149 |
|
|
150 |
get_response(buf); |
get_response(buf); |
151 |
|
|
153 |
|
|
154 |
if (!regexec(&compexp, buf, 2, match, 0)) { |
if (!regexec(&compexp, buf, 2, match, 0)) { |
155 |
s = min(match[1].rm_eo - match[1].rm_so, SEARCH_RESULTS_MAX - 1); |
s = min(match[1].rm_eo - match[1].rm_so, SEARCH_RESULTS_MAX - 1); |
156 |
strncpy(results, buf + match[1].rm_so, s); |
strncpy(results + len, buf + match[1].rm_so, s); |
157 |
results[s] = 0; |
results[s + len] = 0; |
158 |
return SUCCESS; |
return SUCCESS; |
159 |
} else |
} else |
160 |
return FAILURE; |
return FAILURE; |