view libcommon/be_init.c @ 99:97ba63d9361a

scripts/fcsim1-sst: turn off STK & OTA services In the initial unprogrammed state of the cards from Grcard, SST has services 25 through 29 set to allocated and activated. However, these cards appear to not actually support OTA, ENVELOPE commands do nothing (just return SW 9000), and they were never observed issuing any proactive SIM commands, even after a feature-generous TERMINAL PROFILE. Therefore, let's list these STK & OTA services as allocated, but not activated in our FCSIM1 SST.
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 05 May 2021 04:26:07 +0000
parents e2ef4b8e4136
children
line wrap: on
line source

/*
 * This module is responsible for collecting the initial info
 * strings emitted by the back end.
 */

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>

extern FILE *rpipeF;

#define	MAX_INIT_STRING	254

char be_reader_name[MAX_INIT_STRING+1];
char be_atr_string[MAX_INIT_STRING+1];
char be_extra_info[MAX_INIT_STRING+1];

static void
copy_without_leading_space(input_str, dest)
	char *input_str, *dest;
{
	char *cp;

	for (cp = input_str; isspace(*cp); cp++)
		;
	strcpy(dest, cp);
}

collect_backend_init_strings()
{
	char inbuf[MAX_INIT_STRING+2], *cp;

	for (;;) {
		if (!fgets(inbuf, sizeof inbuf, rpipeF)) {
			fprintf(stderr,
		"start-up error: EOF reading init strings from back end\n");
			exit(1);
		}
		cp = index(inbuf, '\n');
		if (!cp) {
			fprintf(stderr,
		"start-up error: init string from back end has no newline\n");
			exit(1);
		}
		*cp = '\0';
		if (!inbuf[0])
			break;
		switch (inbuf[0]) {
		case 'A':
			copy_without_leading_space(inbuf + 1, be_atr_string);
			break;
		case 'R':
			copy_without_leading_space(inbuf + 1, be_reader_name);
			break;
		case 'X':
			copy_without_leading_space(inbuf + 1, be_extra_info);
			break;
		}
	}
	return(0);
}