Esempio n. 1
0
int readMembersFromCard(CARD *card, MEMBER *member) {

	MEMBER *memberCurr = member, *memberPrev;
	int k;

	SELECT_EF[6]+=0x01;

	fprintf(fp, "This is the current EF:%x, %d\n", SELECT_EF[6], SELECT_EF[6]);
	fflush(fp);

	if (SendCommand_Smartcard(SELECT_EF, 7)==ERROR) {
		lk_dispclr();
		lk_disptext(2, 0, "2.Record Not Present", 1);
		sleep(2);
	}

	fprintf(fp, "This is the number of members:%d\n", atoi(card->no_of_members));
	fflush(fp);

	for (k=0; k<atoi(card->no_of_members); k++) {
		if (k!=0) {
			if ((memberCurr = (MEMBER *)malloc(sizeof(MEMBER))) == NULL)
				return ERROR;

			memberPrev->next = memberCurr;
			memberCurr->next = NULL;
		}
		if (readMember(k*2200, 2200) == ERROR)
			return ERROR;

		getMemberDetails_smart(card, memberCurr, k, response);

		memberPrev = memberCurr;
	}
}
Esempio n. 2
0
/*
 * Read the next normal member of the archive file if possible.
 * If the member is being rescanned, clear the rescan flag and
 * return the header that was already read.  Returns TRUE on
 * success.  On a failure, the eof flag will be set if end of
 * file has been reached.
 */
static BOOL
readNormalMember(Archive * arch)
{
	struct ar_hdr	hdr;

	/*
	 * If we are rereading an old header then just clear the
	 * rescan flag and return success.
	 */
	if (arch->rescan)
	{
		arch->rescan = FALSE;

		return TRUE;
	}

	/*
	 * We need to read a new member header.
	 */
	if (!readMember(arch, &hdr))
		return FALSE;

	return canonicalize(arch, &hdr);
}
Esempio n. 3
0
/*
 * Read the first member of the archive file and check whether it
 * is a special one, and if so, handle it.  If the first member is
 * a normal archive member, then set up to rescan it for the next
 * readNormalMember call.  Returns TRUE on success.
 */
static BOOL
readSpecialMember(Archive * arch)
{
	struct ar_hdr	hdr;

	/*
	 * 1. Read a header H.  Fail if impossible.
	 */
	if (!readMember(arch, &hdr))
		return FALSE;

	/*
	 * 2. If H is a symbol table, ditch it.
	 * Fail if impossible.
	 */
	if ((strncmp(hdr.ar_name, "/ ", 2) == 0) ||
		(strncmp(hdr.ar_name, "__.SYMTAB       ",
			sizeof(hdr.ar_name)) == 0))
	{
		if (!canonicalize(arch, &hdr))
			return FALSE;

		return skipMember(arch);
	}

	/*
	 * 3. If H is a SysV longname table, read it into ARCH.
	 */
	if (strncmp(hdr.ar_name, "//", 2) == 0)
	{
		unsigned long	len;
		ssize_t		cc;

		if (!getNumber(hdr.ar_size, 10, sizeof(hdr.ar_size), &len))
		{
			fprintf(stderr, "Invalid name-table size\n");

			return FALSE;
		}

		arch->nameTable = malloc(len + 1);

		if (!arch->nameTable)
		{
			fprintf(stderr, "Out of memory\n");

			return FALSE;
		}

		cc = read(arch->fd, arch->nameTable, len);

		if (cc == -1)
		{
			fprintf(stderr, "Error reading name-table: %s\n",
				strerror(errno));

			return FALSE;
		}

		if (cc != (ssize_t) len)
		{
			fprintf(stderr,
				"Unexpected end of file in name-table\n");

			return FALSE;
		}

		arch->nameTable[len] = 0;

		return skipPadding(arch->fd, len % 2);
	}

	/*
	 * 4. We read a normal header.
	 * Canonicalize it, and mark it as needing rescanning.
	 */
	arch->rescan = TRUE;

	return canonicalize(arch, &hdr);
}