comparison utils/themwi-update-outrt.c @ 260:b997de027717

themwi-update-outrt: special-num route-to: add support for explicit setting of SIP user part
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 15 Aug 2023 23:23:57 -0800
parents b0bf167bb846
children
comparison
equal deleted inserted replaced
259:9f96e5b14755 260:b997de027717
335 static void 335 static void
336 handle_special_num_route_to(num_code, cp, is_e911) 336 handle_special_num_route_to(num_code, cp, is_e911)
337 char *num_code, *cp; 337 char *num_code, *cp;
338 { 338 {
339 struct special_num_route *rec; 339 struct special_num_route *rec;
340 char *dest_name; 340 char *dest_name, *new_sip_user;
341 int dest_id; 341 int dest_id;
342 342
343 while (isspace(*cp)) 343 while (isspace(*cp))
344 cp++; 344 cp++;
345 if (*cp == '\0' || *cp == '#') { 345 if (*cp == '\0' || *cp == '#') {
352 ; 352 ;
353 if (*cp) 353 if (*cp)
354 *cp++ = '\0'; 354 *cp++ = '\0';
355 while (isspace(*cp)) 355 while (isspace(*cp))
356 cp++; 356 cp++;
357 if (*cp != '\0' && *cp != '#') 357 if (*cp != '\0' && *cp != '#') {
358 goto inv_syntax; 358 for (new_sip_user = cp; *cp && !isspace(*cp); cp++)
359 ;
360 if (*cp)
361 *cp++ = '\0';
362 while (isspace(*cp))
363 cp++;
364 if (*cp != '\0' && *cp != '#')
365 goto inv_syntax;
366 if (strlen(new_sip_user) > MAX_SIP_USER_PART) {
367 fprintf(stderr,
368 "out-routes line %d: new SIP user part is too long\n",
369 lineno);
370 exit(1);
371 }
372 } else
373 new_sip_user = 0;
359 dest_id = find_dest_by_name(dest_name); 374 dest_id = find_dest_by_name(dest_name);
360 if (dest_id < 0) { 375 if (dest_id < 0) {
361 fprintf(stderr, 376 fprintf(stderr,
362 "out-routes line %d: SIP destination \"%s\" not defined\n", 377 "out-routes line %d: SIP destination \"%s\" not defined\n",
363 lineno, dest_name); 378 lineno, dest_name);
364 exit(1); 379 exit(1);
365 } 380 }
366 rec = special_num_records + special_num_count; 381 rec = special_num_records + special_num_count;
367 strcpy(rec->special_num, num_code); 382 strcpy(rec->special_num, num_code);
368 strcpy(rec->sip_user, num_code); 383 strcpy(rec->sip_user, new_sip_user ? new_sip_user : num_code);
369 rec->sip_dest_id = dest_id; 384 rec->sip_dest_id = dest_id;
370 rec->flags = is_e911 ? SPECIAL_NUM_FLAG_E911 : 0; 385 rec->flags = is_e911 ? SPECIAL_NUM_FLAG_E911 : 0;
371 special_num_count++; 386 special_num_count++;
372 } 387 }
373 388