FreeCalypso > hg > themwi-system-sw
comparison smpp-send/msg_cmd.c @ 223:f11c3e40c87a
new program smpp-send
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 05 Aug 2023 12:24:31 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
222:9d6e8d99d2b1 | 223:f11c3e40c87a |
---|---|
1 /* | |
2 * This module implements msg and msg-udh input commands, | |
3 * after all settings have been captured. | |
4 */ | |
5 | |
6 #include <sys/types.h> | |
7 #include <ctype.h> | |
8 #include <stdio.h> | |
9 #include <stdlib.h> | |
10 #include <string.h> | |
11 #include <strings.h> | |
12 #include "error.h" | |
13 | |
14 extern int input_lineno; | |
15 | |
16 static int | |
17 decode_hex_digit(c) | |
18 { | |
19 if (c >= '0' && c <= '9') | |
20 return(c - '0'); | |
21 if (c >= 'A' && c <= 'F') | |
22 return(c - 'A' + 10); | |
23 if (c >= 'a' && c <= 'f') | |
24 return(c - 'a' + 10); | |
25 return(-1); | |
26 } | |
27 | |
28 static void | |
29 cmd_msg_common(arg, udhi) | |
30 char *arg; | |
31 { | |
32 u_char input[160]; | |
33 unsigned input_len; | |
34 | |
35 for (input_len = 0; ; input_len++) { | |
36 while (isspace(*arg)) | |
37 arg++; | |
38 if (!*arg) | |
39 break; | |
40 if (!isxdigit(arg[0]) || !isxdigit(arg[1])) { | |
41 fprintf(stderr, ERR_PREFIX "invalid hex string\n", | |
42 input_lineno); | |
43 exit(1); | |
44 } | |
45 if (input_len >= 160) { | |
46 fprintf(stderr, ERR_PREFIX "hex string is too long\n", | |
47 input_lineno); | |
48 exit(1); | |
49 } | |
50 input[input_len] = (decode_hex_digit(arg[0]) << 4) | | |
51 decode_hex_digit(arg[1]); | |
52 arg += 2; | |
53 } | |
54 build_submit_sm(input, input_len, udhi); | |
55 } | |
56 | |
57 void | |
58 cmd_msg_plain(argc, argv) | |
59 char **argv; | |
60 { | |
61 cmd_msg_common(argv[1], 0); | |
62 } | |
63 | |
64 void | |
65 cmd_msg_udh(argc, argv) | |
66 char **argv; | |
67 { | |
68 cmd_msg_common(argv[1], 1); | |
69 } |