示例#1
0
文件: jam_io.c 项目: 0x90sled/keen
//---------------------------------------------------------------------------
// ReadPtr()  -- Reads data from a particular ptr type
//
//	PtrType MUST be of type SRC_TYPE.
//
// RETURNS :
//		The char read in or EOF for SRC_FFILE type of reads.
//
//
//---------------------------------------------------------------------------
int ReadPtr(long infile, unsigned PtrType)
{
	int returnval = 0;

	switch (PtrType & SRC_TYPES)
	{
		case SRC_FILE:
			read(*(int far *)infile,(char *)&returnval,1);
		break;

		case SRC_FFILE:
			returnval = getc(*(FILE far **)infile);
		break;

		case SRC_BFILE:
			returnval = bio_readch((BufferedIO *)*(void far **)infile);
		break;

//		case SRC_IMEM:
//			printf("WritePtr - unsupported ptr type\n");
//			exit(0);
//		break;

		case SRC_MEM:
			returnval = (unsigned char)*((char far *)*(char far **)infile)++;
		break;
	}

	return(returnval);
}
示例#2
0
文件: jam_io.c 项目: BSzili/refkeen
//---------------------------------------------------------------------------
// ReadPtr()  -- Reads data from a particular ptr type
//
//	PtrType MUST be of type SRC_TYPE.
//
// RETURNS :
//		The char read in or EOF for SRC_FFILE type of reads.
//
//
//---------------------------------------------------------------------------
id0_int_t ReadPtr(void **infile, id0_unsigned_t PtrType)
{
	id0_int_t returnval = 0;

	switch (PtrType & SRC_TYPES)
	{
		case SRC_FILE:
			// REFKEEN: Actually SRC_FFILE but done for compatibility
			returnval = BE_Cross_getc(*(BE_FILE_T *)infile);
			//read(*(int *)infile,(id0_char_t *)&returnval,1);
		break;

		case SRC_FFILE:
			returnval = getc(*(FILE id0_far **)infile);
		break;

		case SRC_BFILE:
			returnval = bio_readch((BufferedIO *)*(void id0_far **)infile);
		break;

//		case SRC_IMEM:
//			BE_ST_printf("WritePtr - unsupported ptr type\n");
//			BE_ST_HandleExit(0);
//		break;

		case SRC_MEM:
			//returnval = (id0_unsigned_char_t)*((id0_char_t id0_far *)*(id0_char_t id0_far **)infile)++;
		{
			id0_char_t **ptrptr = (id0_char_t **)infile;
			returnval = (id0_unsigned_char_t)*((*ptrptr)++);
		}		
		break;
	}

	return(returnval);
}