annotate uptools/libcoding/sms_submit8.c @ 465:003e48f8ebe1

rvinterf/etmsync/fsnew.c: cast 0 to (char *) for execl sentinel I generally don't use NULL and use plain 0 instead, based on a "NULL considered harmful" discussion on the classiccmp mailing list many aeons ago (I couldn't find it, and I reason that it must have been 2005 or earlier), but a recent complaint by a packager sent me searching, and I found this: https://ewontfix.com/11/ While I don't give a @#$% about "modern" systems and code-nazi tools, I realized that passing a plain 0 as a pointer sentinel in execl is wrong because it will break on systems where pointers are longer than the plain int type. Again, I don't give a @#$% about the abomination of x86_64 and the like, but if anyone ever manages to port my code to something like a PDP-11 (16-bit int, 32-bit long and pointers), then passing a plain 0 as a function argument where a pointer is expected most definitely won't work: if the most natural stack slot and SP alignment unit is 16 bits, fitting an int, with longs and pointers taking up two such slots, then the call stack will be totally wrong with a plain 0 passed for a pointer. Casting the 0 to (char *) ought to be the most kosher solution for the most retro systems possible.
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 11 Feb 2019 00:00:19 +0000
parents 759cb6dc501b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
375
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This library module implements the function for constructing outgoing
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * SMS-SUBMIT PDUs, 8-bit version for raw data or UCS-2.
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <strings.h>
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 make_sms_submit_pdu_8bit(da, pid, dcs, textsrc, textlen, udh, udhl, outbuf)
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 u_char *da, *textsrc, *udh, *outbuf;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 unsigned textlen, udhl;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 {
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 u_char *outp = outbuf;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 unsigned addr_field_len;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 unsigned udh_octets;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 unsigned udl;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if (udh)
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 *outp++ = 0x41;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 else
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 *outp++ = 0x01;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 *outp++ = 0;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 addr_field_len = ((da[0] + 1) >> 1) + 2;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 bcopy(da, outp, addr_field_len);
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 outp += addr_field_len;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 *outp++ = pid;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 *outp++ = dcs;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 if (udh)
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 udh_octets = udhl + 1;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 else
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 udh_octets = 0;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 udl = udh_octets + textlen;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 *outp++ = udl;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 if (udh) {
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 *outp++ = udhl;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 bcopy(udh, outp, udhl);
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 outp += udhl;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 }
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 bcopy(textsrc, outp, textlen);
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 outp += textlen;
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 return (outp - outbuf);
759cb6dc501b uptools/libcoding: added function for generating SMS PDUs with 8-bit text
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 }