FreeCalypso > hg > osmo-playpen
view smsc-sendmt/read_pdu.c @ 19:9ff041d85da5
proto-smsc-daemon: allow HLR GSUP server other than 127.0.0.1
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 16 Dec 2023 22:23:23 +0000 |
parents | 7543aa173634 |
children |
line wrap: on
line source
/* * This module implements the reading of hex-encoded SMS-DELIVER TPDU * from stdin. */ #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> extern int decode_hex_line(const char *inbuf, uint8_t *outbuf, unsigned outmax); uint8_t tpdu_buf[176]; unsigned tpdu_len; void read_pdu_from_stdin(void) { char linebuf[512], *nl; int rc; if (!fgets(linebuf, sizeof(linebuf), stdin)) { fprintf(stderr, "error: empty stdin is not acceptable\n"); exit(1); } nl = strchr(linebuf, '\n'); if (!nl) { fprintf(stderr, "error: stdin line is too long or unterminated\n"); exit(1); } *nl = '\0'; rc = decode_hex_line(linebuf, tpdu_buf, sizeof(tpdu_buf)); if (rc <= 0) { fprintf(stderr, "error: stdin line is not a valid hex PDU\n"); exit(1); } tpdu_len = rc; }