changeset 204:de7c64c4d6fd

themwi-update-outrt: add inn-default-rt possibility
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 04 Apr 2023 21:21:04 -0800
parents e89619893c1e
children 0047c4c08d9e
files utils/themwi-update-outrt.c
diffstat 1 files changed, 41 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/utils/themwi-update-outrt.c	Tue Apr 04 21:09:50 2023 -0800
+++ b/utils/themwi-update-outrt.c	Tue Apr 04 21:21:04 2023 -0800
@@ -215,6 +215,45 @@
 }
 
 static void
+handle_default_rt(cp)
+	char *cp;
+{
+	char *dest_name;
+	struct inn_route *rec;
+	int dest_id;
+
+	for (dest_name = cp; *cp && !isspace(*cp); cp++)
+		;
+	if (*cp)
+		*cp++ = '\0';
+	while (isspace(*cp))
+		cp++;
+	if (*cp != '\0' && *cp != '#') {
+		fprintf(stderr,
+		"out-routes line %d: invalid syntax for inn-default-rt\n",
+			lineno);
+		exit(1);
+	}
+	dest_id = find_dest_by_name(dest_name);
+	if (dest_id < 0) {
+		fprintf(stderr,
+		"out-routes line %d: SIP destination \"%s\" not defined\n",
+			lineno, dest_name);
+		exit(1);
+	}
+	if (inn_rec_count >= MAX_INN_ENTRIES) {
+		fprintf(stderr,
+			"out-routes line %d: MAX_INN_ENTRIES exceeded\n",
+			lineno);
+		exit(1);
+	}
+	rec = inn_records + inn_rec_count;
+	rec->prefix[0] = '\0';
+	rec->sip_dest_id = dest_id;
+	inn_rec_count++;
+}
+
+static void
 preen_special_num_code(num_code)
 	char *num_code;
 {
@@ -391,6 +430,8 @@
 		handler = handle_dest_line;
 	else if (!strcmp(np, "inn-route"))
 		handler = handle_inn_route;
+	else if (!strcmp(np, "inn-default-rt"))
+		handler = handle_default_rt;
 	else if (!strcmp(np, "special-num"))
 		handler = handle_special_num;
 	else {