view libcommon/plmncodes.c @ 55:4c570522de5d

fc-simtool iccid command: strip padding F digits from display
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 13 Feb 2021 19:42:14 +0000
parents 4eb447be01c0
children d2e800abd257
line wrap: on
line source

/*
 * This module implements some functions for working with MCC-MNC PLMN codes.
 */

#include <sys/types.h>

decode_plmn_3bytes(bin, asc, space_pad)
	u_char *bin;
	char *asc;
{
	asc[0] = encode_hex_digit(bin[0] & 0xF);
	asc[1] = encode_hex_digit(bin[0] >> 4);
	asc[2] = encode_hex_digit(bin[1] & 0xF);
	asc[3] = '-';
	asc[4] = encode_hex_digit(bin[2] & 0xF);
	asc[5] = encode_hex_digit(bin[2] >> 4);
	asc[6] = encode_hex_digit(bin[1] >> 4);
	asc[7] = '\0';
	if (asc[6] == 'F') {
		if (space_pad)
			asc[6] = ' ';
		else
			asc[6] = '\0';
	}
}