![]() |
Home page |
Mailing list |
Docs
Asterisk developer's documentation :: Codename Pineapple
enum.c File Reference
Definition in file enum.c.
#include "asterisk.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <regex.h>
#include <unistd.h>
#include <errno.h>
#include "asterisk/logger.h"
#include "asterisk/options.h"
#include "asterisk/enum.h"
#include "asterisk/dns.h"
#include "asterisk/channel.h"
#include "asterisk/config.h"
#include "asterisk/utils.h"
Include dependency graph for enum.c:

Go to the source code of this file.
Data Structures | |
| struct | enum_context |
| struct | enum_naptr_rr |
| struct | enum_search |
| struct | naptr |
Defines | |
| #define | ENUMLOOKUP_OPTIONS_COUNT 1 |
| #define | TOPLEV "e164.arpa." |
Functions | |
| int | ast_enum_init (void) |
| Initialize the ENUM support subsystem. | |
| int | ast_enum_reload (void) |
| int | ast_get_enum (struct ast_channel *chan, const char *number, char *dst, int dstlen, char *tech, int techlen, char *suffix, char *options, unsigned int record) |
| Lookup entry in ENUM Returns 1 if found, 0 if not found, -1 on hangup. | |
| int | ast_get_txt (struct ast_channel *chan, const char *number, char *dst, int dstlen, char *tech, int techlen, char *txt, int txtlen) |
| Lookup DNS TXT record (used by app TXTCIDnum. | |
| AST_MUTEX_DEFINE_STATIC (enumlock) | |
| static int | enum_callback (void *context, unsigned char *answer, int len, unsigned char *fullanswer) |
| Callback from ENUM lookup function. | |
| static struct enum_search * | enum_newtoplev (char *s) |
| Add enum tree to linked list. | |
| static unsigned int | parse_ie (char *data, unsigned int maxdatalen, unsigned char *src, unsigned int srclen) |
| Parse NAPTR record information elements. | |
| static int | parse_naptr (char *dst, int dstsize, char *tech, int techsize, unsigned char *answer, int len, char *naptrinput) |
| Parse DNS NAPTR record used in ENUM ---. | |
| static int | txt_callback (void *context, unsigned char *answer, int len, unsigned char *fullanswer) |
| Callback for TXT record lookup. | |
Variables | |
| naptr | __packed__ |
| static int | enumver |
| static struct enum_search * | toplevs |
|
|
Definition at line 297 of file enum.c. Referenced by ast_get_enum(), and enum_callback(). |
|
|
The IETF Enum standard root, managed by the ITU Definition at line 80 of file enum.c. Referenced by ast_enum_init(). |
|
|
Initialize the ENUM support subsystem.
Definition at line 628 of file enum.c. References ast_config_destroy(), ast_config_load(), ast_mutex_lock(), ast_mutex_unlock(), ast_variable_browse(), enum_newtoplev(), free, ast_variable::name, ast_variable::next, s, TOPLEV, toplevs, and ast_variable::value. Referenced by ast_enum_reload(). 00629 { 00630 struct ast_config *cfg; 00631 struct enum_search *s, *sl; 00632 struct ast_variable *v; 00633 00634 /* Destroy existing list */ 00635 ast_mutex_lock(&enumlock); 00636 s = toplevs; 00637 while (s) { 00638 sl = s; 00639 s = s->next; 00640 free(sl); 00641 } 00642 toplevs = NULL; 00643 cfg = ast_config_load("enum.conf"); 00644 if (cfg) { 00645 sl = NULL; 00646 v = ast_variable_browse(cfg, "general"); 00647 while (v) { 00648 if (!strcasecmp(v->name, "search")) { 00649 s = enum_newtoplev(v->value); 00650 if (s) { 00651 if (sl) 00652 sl->next = s; 00653 else 00654 toplevs = s; 00655 sl = s; 00656 } 00657 } 00658 v = v->next; 00659 } 00660 ast_config_destroy(cfg); 00661 } else { 00662 toplevs = enum_newtoplev(TOPLEV); 00663 } 00664 enumver++; 00665 ast_mutex_unlock(&enumlock); 00666 return 0; 00667 }
|
|
|
Definition at line 669 of file enum.c. References ast_enum_init(). 00670 { 00671 return ast_enum_init(); 00672 }
|
|
||||||||||||||||||||||||||||||||||||||||
|
Lookup entry in ENUM Returns 1 if found, 0 if not found, -1 on hangup.
Definition at line 390 of file enum.c. References ast_autoservice_start(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_search_dns(), context, enum_callback(), ENUMLOOKUP_OPTIONS_COUNT, LOG_DEBUG, enum_context::naptrinput, s, and toplevs. 00391 { 00392 struct enum_context context; 00393 char tmp[259 + 512]; 00394 char naptrinput[512]; 00395 int pos = strlen(number) - 1; 00396 int newpos = 0; 00397 int ret = -1; 00398 struct enum_search *s = NULL; 00399 int version = -1; 00400 /* for ISN rewrite */ 00401 char *p1 = NULL; 00402 char *p2 = NULL; 00403 int k = 0; 00404 int i = 0; 00405 int z = 0; 00406 00407 ast_copy_string(naptrinput, number[0] == 'n' ? number+1 : number, sizeof(naptrinput)); 00408 00409 context.naptrinput = naptrinput; /* The number */ 00410 context.dst = dst; /* Return string */ 00411 context.dstlen = dstlen; 00412 context.tech = tech; 00413 context.techlen = techlen; 00414 context.options = 0; 00415 context.position = record; 00416 context.naptr_rrs = NULL; 00417 context.naptr_rrs_count = 0; 00418 00419 if (options != NULL) { 00420 if (*options == 'c') { 00421 context.options = ENUMLOOKUP_OPTIONS_COUNT; 00422 context.position = 0; 00423 } 00424 } 00425 00426 ast_log(LOG_DEBUG, "ast_get_enum(): n='%s', tech='%s', suffix='%s', options='%d', record='%d'\n", 00427 number, tech, suffix, context.options, context.position); 00428 00429 if (pos > 128) 00430 pos = 128; 00431 00432 /* ISN rewrite */ 00433 p1 = strchr(number, '*'); 00434 00435 if (number[0] == 'n') { /* do not perform ISN rewrite ('n' is testing flag) */ 00436 p1 = NULL; 00437 k = 1; /* strip 'n' from number */ 00438 } 00439 00440 if (p1 != NULL) { 00441 p2 = p1+1; 00442 while (p1 > number){ 00443 p1--; 00444 tmp[newpos++] = *p1; 00445 tmp[newpos++] = '.'; 00446 } 00447 if (*p2) { 00448 while (*p2 && newpos < 128){ 00449 tmp[newpos++] = *p2; 00450 p2++; 00451 } 00452 tmp[newpos++] = '.'; 00453 } 00454 00455 } else { 00456 while (pos >= k) { 00457 if (isdigit(number[pos])) { 00458 tmp[newpos++] = number[pos]; 00459 tmp[newpos++] = '.'; 00460 } 00461 pos--; 00462 } 00463 } 00464 00465 if (chan && ast_autoservice_start(chan) < 0) 00466 return -1; 00467 00468 if(suffix) { 00469 ast_copy_string(tmp + newpos, suffix, sizeof(tmp) - newpos); 00470 ret = ast_search_dns(&context, tmp, C_IN, T_NAPTR, enum_callback); 00471 ast_log(LOG_DEBUG, "ast_get_enum: ast_search_dns(%s) returned %d\n", tmp, ret); 00472 } else { 00473 ret = -1; /* this is actually dead code since the demise of app_enum.c */ 00474 for (;;) { 00475 ast_mutex_lock(&enumlock); 00476 if (version != enumver) { 00477 /* Ooh, a reload... */ 00478 s = toplevs; 00479 version = enumver; 00480 } else { 00481 s = s->next; 00482 } 00483 ast_mutex_unlock(&enumlock); 00484 00485 if (!s) 00486 break; 00487 00488 ast_copy_string(tmp + newpos, s->toplev, sizeof(tmp) - newpos); 00489 ret = ast_search_dns(&context, tmp, C_IN, T_NAPTR, enum_callback); 00490 ast_log(LOG_DEBUG, "ast_get_enum: ast_search_dns(%s) returned %d\n", tmp, ret); 00491 if (ret > 0) 00492 break; 00493 } 00494 } 00495 00496 if (ret < 0) { 00497 if (option_debug) 00498 ast_log(LOG_DEBUG, "No such number found: %s (%s)\n", tmp, strerror(errno)); 00499 strcpy(dst, "0"); 00500 ret = 0; 00501 } 00502 00503 if (context.naptr_rrs_count >= context.position && ! (context.options & ENUMLOOKUP_OPTIONS_COUNT)) { 00504 /* sort array by NAPTR order/preference */ 00505 for (k = 0; k < context.naptr_rrs_count; k++) { 00506 for (i = 0; i < context.naptr_rrs_count; i++) { 00507 /* use order first and then preference to compare */ 00508 if ((ntohs(context.naptr_rrs[k].naptr.order) < ntohs(context.naptr_rrs[i].naptr.order) 00509 && context.naptr_rrs[k].sort_pos > context.naptr_rrs[i].sort_pos) 00510 || (ntohs(context.naptr_rrs[k].naptr.order) > ntohs(context.naptr_rrs[i].naptr.order) 00511 && context.naptr_rrs[k].sort_pos < context.naptr_rrs[i].sort_pos)){ 00512 z = context.naptr_rrs[k].sort_pos; 00513 context.naptr_rrs[k].sort_pos = context.naptr_rrs[i].sort_pos; 00514 context.naptr_rrs[i].sort_pos = z; 00515 continue; 00516 } 00517 if (ntohs(context.naptr_rrs[k].naptr.order) == ntohs(context.naptr_rrs[i].naptr.order)) { 00518 if ((ntohs(context.naptr_rrs[k].naptr.pref) < ntohs(context.naptr_rrs[i].naptr.pref) 00519 && context.naptr_rrs[k].sort_pos > context.naptr_rrs[i].sort_pos) 00520 || (ntohs(context.naptr_rrs[k].naptr.pref) > ntohs(context.naptr_rrs[i].naptr.pref) 00521 && context.naptr_rrs[k].sort_pos < context.naptr_rrs[i].sort_pos)){ 00522 z = context.naptr_rrs[k].sort_pos; 00523 context.naptr_rrs[k].sort_pos = context.naptr_rrs[i].sort_pos; 00524 context.naptr_rrs[i].sort_pos = z; 00525 } 00526 } 00527 } 00528 } 00529 for (k = 0; k < context.naptr_rrs_count; k++) { 00530 if (context.naptr_rrs[k].sort_pos == context.position-1) { 00531 ast_copy_string(context.dst, context.naptr_rrs[k].result, dstlen); 00532 ast_copy_string(context.tech, context.naptr_rrs[k].tech, techlen); 00533 break; 00534 } 00535 } 00536 } else if (!(context.options & ENUMLOOKUP_OPTIONS_COUNT)) { 00537 context.dst[0] = 0; 00538 } 00539 if (chan) 00540 ret |= ast_autoservice_stop(chan); 00541 00542 for (k = 0; k < context.naptr_rrs_count; k++) { 00543 free(context.naptr_rrs[k].result); 00544 free(context.naptr_rrs[k].tech); 00545 } 00546 00547 free(context.naptr_rrs); 00548 00549 return ret; 00550 }
|
|
||||||||||||||||||||||||||||||||||||
|
Lookup DNS TXT record (used by app TXTCIDnum.
Definition at line 555 of file enum.c. References ast_autoservice_start(), ast_mutex_lock(), context, enum_context::naptrinput, s, and toplevs. 00556 { 00557 struct enum_context context; 00558 char tmp[259 + 512]; 00559 char naptrinput[512] = "+"; 00560 int pos = strlen(number) - 1; 00561 int newpos = 0; 00562 int ret = -1; 00563 struct enum_search *s = NULL; 00564 int version = -1; 00565 00566 strncat(naptrinput, number, sizeof(naptrinput) - 2); 00567 00568 context.naptrinput = naptrinput; 00569 context.dst = dst; 00570 context.dstlen = dstlen; 00571 context.tech = tech; 00572 context.techlen = techlen; 00573 context.txt = txt; 00574 context.txtlen = txtlen; 00575 00576 if (pos > 128) 00577 pos = 128; 00578 while (pos >= 0) { 00579 tmp[newpos++] = number[pos--]; 00580 tmp[newpos++] = '.'; 00581 } 00582 00583 if (chan && ast_autoservice_start(chan) < 0) 00584 return -1; 00585 00586 for (;;) { 00587 ast_mutex_lock(&enumlock); 00588 if (version != enumver) { 00589 /* Ooh, a reload... */ 00590 s = toplevs; 00591 version = enumver; 00592 } else { 00593 s = s->next; 00594 } 00595 if (s) { 00596 ast_copy_string(tmp + newpos, s->toplev, sizeof(tmp) - newpos); 00597 } 00598 ast_mutex_unlock(&enumlock); 00599 if (!s) 00600 break; 00601 00602 ret = ast_search_dns(&context, tmp, C_IN, T_TXT, txt_callback); 00603 if (ret > 0) 00604 break; 00605 } 00606 if (ret < 0) { 00607 if (option_debug > 1) 00608 ast_log(LOG_DEBUG, "No such number found in ENUM: %s (%s)\n", tmp, strerror(errno)); 00609 ret = 0; 00610 } 00611 if (chan) 00612 ret |= ast_autoservice_stop(chan); 00613 return ret; 00614 }
|
|
|
|
|
||||||||||||||||||||
|
Callback from ENUM lookup function.
Definition at line 353 of file enum.c. References ast_log(), ast_realloc, ast_strlen_zero(), enum_context::dst, enum_context::dstlen, ENUMLOOKUP_OPTIONS_COUNT, LOG_WARNING, enum_naptr_rr::naptr, enum_context::naptr_rrs, enum_context::naptr_rrs_count, enum_context::naptrinput, enum_context::options, parse_naptr(), enum_context::position, enum_naptr_rr::result, enum_naptr_rr::sort_pos, strdup, enum_naptr_rr::tech, enum_context::tech, and enum_context::techlen. Referenced by ast_get_enum(). 00354 { 00355 struct enum_context *c = context; 00356 void *p = NULL; 00357 int res; 00358 00359 res = parse_naptr(c->dst, c->dstlen, c->tech, c->techlen, answer, len, c->naptrinput); 00360 00361 if (res < 0) { 00362 ast_log(LOG_WARNING, "Failed to parse naptr :(\n"); 00363 return -1; 00364 } else if (res > 0 && !ast_strlen_zero(c->dst)){ /* ok, we got needed NAPTR */ 00365 if (c->options & ENUMLOOKUP_OPTIONS_COUNT){ /* counting RRs */ 00366 c->position++; 00367 snprintf(c->dst, c->dstlen, "%d", c->position); 00368 } else { 00369 if ((p = ast_realloc(c->naptr_rrs, sizeof(*c->naptr_rrs) * (c->naptr_rrs_count + 1)))) { 00370 c->naptr_rrs = p; 00371 memcpy(&c->naptr_rrs[c->naptr_rrs_count].naptr, answer, sizeof(c->naptr_rrs->naptr)); 00372 c->naptr_rrs[c->naptr_rrs_count].result = strdup(c->dst); 00373 c->naptr_rrs[c->naptr_rrs_count].tech = strdup(c->tech); 00374 c->naptr_rrs[c->naptr_rrs_count].sort_pos = c->naptr_rrs_count; 00375 c->naptr_rrs_count++; 00376 } 00377 c->dst[0] = 0; 00378 } 00379 return 0; 00380 } 00381 00382 if (c->options & ENUMLOOKUP_OPTIONS_COUNT) { /* counting RRs */ 00383 snprintf(c->dst, c->dstlen, "%d", c->position); 00384 } 00385 00386 return 0; 00387 }
|
|
|
Add enum tree to linked list.
Definition at line 617 of file enum.c. References ast_calloc. Referenced by ast_enum_init(). 00618 { 00619 struct enum_search *tmp; 00620 00621 if ((tmp = ast_calloc(1, sizeof(*tmp)))) { 00622 ast_copy_string(tmp->toplev, s, sizeof(tmp->toplev)); 00623 } 00624 return tmp; 00625 }
|
|
||||||||||||||||||||
|
Parse NAPTR record information elements.
Definition at line 98 of file enum.c. References ast_log(), len, and LOG_WARNING. Referenced by parse_naptr(). 00099 { 00100 unsigned int len, olen; 00101 00102 len = olen = (unsigned int) src[0]; 00103 src++; 00104 srclen--; 00105 00106 if (len > srclen) { 00107 ast_log(LOG_WARNING, "ENUM parsing failed: Wanted %d characters, got %d\n", len, srclen); 00108 return -1; 00109 } 00110 00111 if (len > maxdatalen) 00112 len = maxdatalen; 00113 memcpy(data, src, len); 00114 00115 return olen + 1; 00116 }
|
|
||||||||||||||||||||||||||||||||
|
Parse DNS NAPTR record used in ENUM ---.
Definition at line 119 of file enum.c. References ast_log(), LOG_DEBUG, LOG_WARNING, option_debug, and parse_ie(). Referenced by enum_callback(). 00120 { 00121 char tech_return[80]; 00122 unsigned char *oanswer = answer; 00123 char flags[512] = ""; 00124 char services[512] = ""; 00125 char *p; 00126 char regexp[512] = ""; 00127 char repl[512] = ""; 00128 char temp[512] = ""; 00129 char delim; 00130 char *delim2; 00131 char *pattern, *subst, *d; 00132 int res; 00133 int regexp_len, size, backref; 00134 int d_len = sizeof(temp) - 1; 00135 regex_t preg; 00136 regmatch_t pmatch[9]; 00137 00138 tech_return[0] = '\0'; 00139 00140 dst[0] = '\0'; 00141 00142 if (len < sizeof(struct naptr)) { 00143 ast_log(LOG_WARNING, "NAPTR record length too short\n"); 00144 return -1; 00145 } 00146 answer += sizeof(struct naptr); 00147 len -= sizeof(struct naptr); 00148 if ((res = parse_ie(flags, sizeof(flags) - 1, answer, len)) < 0) { 00149 ast_log(LOG_WARNING, "Failed to get flags from NAPTR record\n"); 00150 return -1; 00151 } else { 00152 answer += res; 00153 len -= res; 00154 } 00155 if ((res = parse_ie(services, sizeof(services) - 1, answer, len)) < 0) { 00156 ast_log(LOG_WARNING, "Failed to get services from NAPTR record\n"); 00157 return -1; 00158 } else { 00159 answer += res; 00160 len -= res; 00161 } 00162 if ((res = parse_ie(regexp, sizeof(regexp) - 1, answer, len)) < 0) { 00163 ast_log(LOG_WARNING, "Failed to get regexp from NAPTR record\n"); 00164 return -1; 00165 } else { 00166 answer += res; 00167 len -= res; 00168 } 00169 00170 if ((res = dn_expand(oanswer, answer + len, answer, repl, sizeof(repl) - 1)) < 0) { 00171 ast_log(LOG_WARNING, "Failed to expand hostname\n"); 00172 return -1; 00173 } 00174 00175 if (option_debug > 2) /* Advanced NAPTR debugging */ 00176 ast_log(LOG_DEBUG, "NAPTR input='%s', flags='%s', services='%s', regexp='%s', repl='%s'\n", 00177 naptrinput, flags, services, regexp, repl); 00178 00179 if (tolower(flags[0]) != 'u') { 00180 ast_log(LOG_WARNING, "NAPTR Flag must be 'U' or 'u'.\n"); 00181 return -1; 00182 } 00183 00184 p = strstr(services, "e2u+"); 00185 if (p == NULL) 00186 p = strstr(services, "E2U+"); 00187 if (p){ 00188 p = p + 4; 00189 if (strchr(p, ':')){ 00190 p = strchr(p, ':') + 1; 00191 } 00192 ast_copy_string(tech_return, p, sizeof(tech_return)); 00193 } else { 00194 00195 p = strstr(services, "+e2u"); 00196 if (p == NULL) 00197 p = strstr(services, "+E2U"); 00198 if (p) { 00199 *p = 0; 00200 p = strchr(services, ':'); 00201 if (p) 00202 *p = 0; 00203 ast_copy_string(tech_return, services, sizeof(tech_return)); 00204 } 00205 } 00206 00207 /* DEDBUGGING STUB 00208 ast_copy_string(regexp, "!^\\+43(.*)$!\\1@bla.fasel!", sizeof(regexp) - 1); 00209 */ 00210 00211 regexp_len = strlen(regexp); 00212 if (regexp_len < 7) { 00213 ast_log(LOG_WARNING, "Regex too short to be meaningful.\n"); 00214 return -1; 00215 } 00216 00217 00218 delim = regexp[0]; 00219 delim2 = strchr(regexp + 1, delim); 00220 if ((delim2 == NULL) || (regexp[regexp_len-1] != delim)) { 00221 ast_log(LOG_WARNING, "Regex delimiter error (on \"%s\").\n",regexp); 00222 return -1; 00223 } 00224 00225 pattern = regexp + 1; 00226 *delim2 = 0; 00227 subst = delim2 + 1; 00228 regexp[regexp_len-1] = 0; 00229 00230 /* 00231 * now do the regex wizardry. 00232 */ 00233 00234 if (regcomp(&preg, pattern, REG_EXTENDED | REG_NEWLINE)) { 00235 ast_log(LOG_WARNING, "NAPTR Regex compilation error (regex = \"%s\").\n",regexp); 00236 return -1; 00237 } 00238 00239 if (preg.re_nsub > 9) { 00240 ast_log(LOG_WARNING, "NAPTR Regex compilation error: too many subs.\n"); 00241 regfree(&preg); 00242 return -1; 00243 } 00244 00245 if (regexec(&preg, naptrinput, 9, pmatch, 0)) { 00246 ast_log(LOG_WARNING, "NAPTR Regex match failed.\n"); 00247 regfree(&preg); 00248 return -1; 00249 } 00250 regfree(&preg); 00251 00252 d = temp; 00253 d_len--; 00254 while (*subst && (d_len > 0)) { 00255 if ((subst[0] == '\\') && isdigit(subst[1]) && (pmatch[subst[1]-'0'].rm_so != -1)) { 00256 backref = subst[1]-'0'; 00257 size = pmatch[backref].rm_eo - pmatch[backref].rm_so; 00258 if (size > d_len) { 00259 ast_log(LOG_WARNING, "Not enough space during NAPTR regex substitution.\n"); 00260 return -1; 00261 } 00262 memcpy(d, naptrinput + pmatch[backref].rm_so, size); 00263 d += size; 00264 d_len -= size; 00265 subst += 2; 00266 } else if (isprint(*subst)) { 00267 *d++ = *subst++; 00268 d_len--; 00269 } else { 00270 ast_log(LOG_WARNING, "Error during regex substitution.\n"); 00271 return -1; 00272 } 00273 } 00274 *d = 0; 00275 ast_copy_string(dst, temp, dstsize); 00276 dst[dstsize - 1] = '\0'; 00277 00278 if (*tech != '\0'){ /* check if it is requested NAPTR */ 00279 if (!strncasecmp(tech, "ALL", techsize)){ 00280 return 1; /* return or count any RR */ 00281 } 00282 if (!strncasecmp(tech_return, tech, sizeof(tech_return)<techsize?sizeof(tech_return):techsize)){ 00283 ast_copy_string(tech, tech_return, techsize); 00284 return 1; /* we got out RR */ 00285 } else { /* go to the next RR in the DNS answer */ 00286 return 0; 00287 } 00288 } 00289 00290 /* tech was not specified, return first parsed RR */ 00291 ast_copy_string(tech, tech_return, techsize); 00292 00293 return 1; 00294 }
|
|
||||||||||||||||||||
|
Callback for TXT record lookup.
Definition at line 321 of file enum.c. References enum_context::txt, and enum_context::txtlen. 00322 { 00323 struct enum_context *c = (struct enum_context *)context; 00324 00325 if (answer == NULL) { 00326 c->txt = NULL; 00327 c->txtlen = 0; 00328 return 0; 00329 } 00330 00331 /* skip over first byte, as for some reason it's a vertical tab character */ 00332 answer += 1; 00333 len -= 1; 00334 00335 /* answer is not null-terminated, but should be */ 00336 /* this is safe to do, as answer has extra bytes on the end we can 00337 * safely overwrite with a null */ 00338 answer[len] = '\0'; 00339 /* now increment len so that len includes the null, so that we can 00340 * compare apples to apples */ 00341 len +=1; 00342 00343 /* finally, copy the answer into c->txt */ 00344 ast_copy_string(c->txt, (const char *) answer, len < c->txtlen ? len : (c->txtlen)); 00345 00346 /* just to be safe, let's make sure c->txt is null terminated */ 00347 c->txt[(c->txtlen)-1] = '\0'; 00348 00349 return 1; 00350 }
|
|
|
|
|
|
|
|
|
Referenced by ast_enum_init(), ast_get_enum(), and ast_get_txt(). |