# HG changeset patch # User Mychaela Falconia # Date 1693002534 28800 # Node ID 18b7f75fed9bfe3e5467d3209990a5c81bdb99e8 # Parent cef4677a4cf86917cb82424a1233566b1eaae542 smsc-sendmt/smsc_addr.c: temporary code stashaway diff -r cef4677a4cf8 -r 18b7f75fed9b smsc-sendmt/smsc_addr.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/smsc-sendmt/smsc_addr.c Fri Aug 25 14:28:54 2023 -0800 @@ -0,0 +1,51 @@ +/* + * This C module is being stashed here temporarily until we figure out + * where this function ultimately needs to go. The parsing of the SMSC + * address is being moved out of proto-smsc-daemon to proto-smsc-sendmt, + * but we haven't started putting together the latter program yet. + */ + +#include +#include +#include +#include + +char smsc_addr_num[21]; /* maximum of 20 digits per GSM 04.11 */ +uint8_t smsc_addr_ton_npi; + +void parse_smsc_addr_arg(char *arg) +{ + char *cp, *dp, *endp; + unsigned ndig; + + cp = arg; + dp = smsc_addr_num; + ndig = 0; + while (isdigit(*cp)) { + if (ndig >= 20) { + fprintf(stderr, + "error: SMSC address argument exceeds GSM 04.11 limit of 20 digits\n"); + exit(1); + } + *dp++ = *cp++; + ndig++; + } + if (!ndig) { +invalid: fprintf(stderr, + "error: SMSC address argument \"%s\" is invalid\n", + arg); + exit(1); + } + if (!*cp) { + /* default to TON=1, NPI=1, i.e., a pretend Global Title */ + smsc_addr_ton_npi = 0x91; + return; + } + if (*cp++ != ',') + goto invalid; + if (!*cp) + goto invalid; + smsc_addr_ton_npi = strtoul(cp, &endp, 0); + if (*endp) + goto invalid; +}