# HG changeset patch # User Mychaela Falconia # Date 1615102833 0 # Node ID 50bdc48e748703c48d03ac58eb8dab17b48d69b4 # Parent 43b57865fdb506f61572779cffea5996c0a18865 libutil: gsm7_pack.c brought over from FC uptools diff -r 43b57865fdb5 -r 50bdc48e7487 libutil/Makefile --- a/libutil/Makefile Sun Mar 07 06:46:21 2021 +0000 +++ b/libutil/Makefile Sun Mar 07 07:40:33 2021 +0000 @@ -2,9 +2,9 @@ CFLAGS= -O2 OBJS= alpha_decode.o alpha_fromfile.o alpha_valid.o decimal_str.o \ filesearch.o gsm7_decode.o gsm7_encode.o gsm7_encode_table.o \ - gsm7_unpack.o hexdigits.o hexread.o hexstr.o iccid_luhn.o nibbles2asc.o\ - number_decode.o number_encode.o pinentry.o plmncodes.o plmnlist.o \ - revnibbles.o shorthand.o + gsm7_pack.o gsm7_unpack.o hexdigits.o hexread.o hexstr.o iccid_luhn.o \ + nibbles2asc.o number_decode.o number_encode.o pinentry.o plmncodes.o \ + plmnlist.o revnibbles.o shorthand.o LIB= libutil.a all: ${LIB} diff -r 43b57865fdb5 -r 50bdc48e7487 libutil/gsm7_pack.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libutil/gsm7_pack.c Sun Mar 07 07:40:33 2021 +0000 @@ -0,0 +1,22 @@ +/* + * This library module implements the function for packing septets into octets. + */ + +#include + +gsm7_pack(inbuf, outbuf, noctets) + u_char *inbuf, *outbuf; + unsigned noctets; +{ + u_char *ip = inbuf, *op = outbuf; + unsigned n, c; + + for (n = 0; n < noctets; n++) { + c = n % 7; + *op++ = ((ip[1] << 7) | ip[0]) >> c; + if (c == 6) + ip += 2; + else + ip += 1; + } +}