view utils/themwi-short-dial.c @ 152:7176dc850d7a

sip-in hold/retr error handling: simply send BYE Because we know that the SIP state is CONNECTED at the time of any such error event, we can call initiate_bye() instead of disconnect_sip(), and thereby get rid of struct gsm_mncc_cause which will never be used in this scenario anyway.
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 11 Oct 2022 16:11:21 -0800
parents aea422af79dd
children 19d1c39ae4e7
line wrap: on
line source

/*
 * This command line utility looks up a 4-digit short dialing code
 * in ThemWi number database and reports its status: not defined,
 * ITN or mapping to NANP.
 */

#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>

main(argc, argv)
	char **argv;
{
	char nanp[11];
	int res;

	if (argc != 2) {
usage:		fprintf(stderr, "usage: %s 4-digit-number\n", argv[0]);
		exit(1);
	}
	if (grok_number_string(argv[1], 0) != 4)
		goto usage;
	openlog("themwi-short-dial", 0, LOG_LOCAL5);
	if (read_number_db() < 0) {
		fprintf(stderr, "error reading number database\n");
		exit(1);
	}
	res = lookup_short_dial_number(argv[1], nanp);
	if (!res)
		printf("Short number %s is not defined\n", argv[1]);
	else if (nanp[0])
		printf("Short number %s maps to +1-%.3s-%.3s-%s\n", argv[1],
			nanp, nanp+3, nanp+6);
	else
		printf("Short number %s is an ITN\n", argv[1]);
	exit(0);
}