FreeCalypso > hg > sms-coding-utils
comparison enc-text/main.c @ 23:e56bb9f09ff1
sms-encode-text: port over -e option from fcup-smsend
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sat, 02 Sep 2023 19:22:05 +0000 |
| parents | a16b1b9728f6 |
| children |
comparison
equal
deleted
inserted
replaced
| 22:8a2038c6a156 | 23:e56bb9f09ff1 |
|---|---|
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <strings.h> | 9 #include <strings.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| 11 #include "defs.h" | 11 #include "defs.h" |
| 12 | 12 |
| 13 int utf8_input, ucs2_mode; | 13 int utf8_input, ucs2_mode, allow_escape; |
| 14 int concat_enable, concat_refno_set; | 14 int concat_enable, concat_refno_set; |
| 15 char msgtext[MAX_MSG_CHARS*2+2]; | 15 char msgtext[MAX_MSG_CHARS*3+2]; |
| 16 u_char concat_refno; | 16 u_char concat_refno; |
| 17 | 17 |
| 18 process_cmdline(argc, argv) | 18 process_cmdline(argc, argv) |
| 19 char **argv; | 19 char **argv; |
| 20 { | 20 { |
| 21 int c; | 21 int c; |
| 22 extern int optind; | 22 extern int optind; |
| 23 extern char *optarg; | 23 extern char *optarg; |
| 24 | 24 |
| 25 while ((c = getopt(argc, argv, "cC:uU")) != EOF) { | 25 while ((c = getopt(argc, argv, "cC:euU")) != EOF) { |
| 26 switch (c) { | 26 switch (c) { |
| 27 case 'c': | 27 case 'c': |
| 28 concat_enable = 1; | 28 concat_enable = 1; |
| 29 continue; | 29 continue; |
| 30 case 'C': | 30 case 'C': |
| 31 concat_enable = 1; | 31 concat_enable = 1; |
| 32 concat_refno = strtoul(optarg, 0, 0); | 32 concat_refno = strtoul(optarg, 0, 0); |
| 33 concat_refno_set = 1; | 33 concat_refno_set = 1; |
| 34 continue; | |
| 35 case 'e': | |
| 36 allow_escape = 1; | |
| 34 continue; | 37 continue; |
| 35 case 'u': | 38 case 'u': |
| 36 utf8_input = 1; | 39 utf8_input = 1; |
| 37 continue; | 40 continue; |
| 38 case 'U': | 41 case 'U': |
| 47 fprintf(stderr, "usage: %s [options] [message]\n", argv[0]); | 50 fprintf(stderr, "usage: %s [options] [message]\n", argv[0]); |
| 48 exit(1); | 51 exit(1); |
| 49 } | 52 } |
| 50 if (argc < optind + 1) | 53 if (argc < optind + 1) |
| 51 return(0); | 54 return(0); |
| 52 if (strlen(argv[optind]) > MAX_MSG_CHARS*2) { | 55 if (strlen(argv[optind]) > MAX_MSG_CHARS*3) { |
| 53 fprintf(stderr, "error: message argument is too long\n"); | 56 fprintf(stderr, "error: message argument is too long\n"); |
| 54 exit(1); | 57 exit(1); |
| 55 } | 58 } |
| 56 strcpy(msgtext, argv[optind]); | 59 strcpy(msgtext, argv[optind]); |
| 57 return(1); | 60 return(1); |
