本文整理汇总了C++中read_byte函数的典型用法代码示例。如果您正苦于以下问题:C++ read_byte函数的具体用法?C++ read_byte怎么用?C++ read_byte使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_byte函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle_input
int handle_input(struct plyr *p){
int z;
z = read_byte(p->fd);
if(z == -1){
return 1;
}
if(z == 0 || z == 1) return 0;
p->lastinput = time(NULL);
printf("user input: @ (%d,%d) = %d\n",p->x,p->y,z);
if(z == 0x1b){
handle_escapes(p);
}
else if(z == 253U)
{
read_byte(p->fd); //3
}
else if(z == 255U){
read_byte(p->fd); //1
dump_world(p);
} else if(z == 126 || z == 127)
{
move_left(p);
set_byte(p, ' ');
CHARAT(p,p->x,p->y) = ' ';
}
else if(z == 13)
{
move_down(p);
} else if(z == 10){
} else {
set_byte(p, z);
move_right(p);
}
return 0;
}
示例2: packet_17
void packet_17(char *buffer,int *offset,int *flag) {
/* display information contained within packet 17 */
short spare,boxes,rows,numbytes;
int i,j;
int k;
unsigned char run;
unsigned char level;
printf("Packet 17: Digital Precipitation Data Array Packet\n");
spare=read_half(buffer,offset);
spare=read_half(buffer,offset);
boxes=read_half(buffer,offset);
printf("Number of LFM Boxes in Row = %hd\n",boxes );
rows=read_half(buffer,offset);
printf("Number of Rows = %hd\n",rows);
for(i=0; i<rows; i++) {
numbytes=read_half(buffer,offset);
printf("Number of Bytes in Row %d = %hd\n",i+1,numbytes);
k=0;
for(j=0; j<numbytes/2; j++) {
run = (unsigned char) read_byte(buffer,offset);
level = (unsigned char) read_byte(buffer,offset);
/* report pre-build 8 byte swap error */
if((i==0) && (j==0) && (run==255))
printf("Linux DPA Error, the Run and Level values are reversed in packet 17.\n");
printf("Run(%03hd) Level(%03hd) ", run, level);
if(k==2) {
printf("\n");
k=0;
} else {
k++;
}
}
printf("\n");
}
printf("\n");
printf("Message 17 Complete\n");
}
示例3: memory_read
unsigned char memory_read(struct _asm_context *asm_context, uint32_t address)
{
if (address >= asm_context->memory.size)
{
printf("Warning: Data read address %d overran %d byte boundary at %s:%d\n", address, asm_context->memory.size, asm_context->filename, asm_context->line);
return 0;
}
return read_byte(&asm_context->memory, address);
}
示例4: EEPROM_MAP_SIZE
EEPROM_MAP_END
#define EEPROM_MAP_SIZE (sizeof(eeprom_map)/sizeof(*eeprom_map))
bool EEPROM::hasCalibration()
{
int16_t read = read_byte(EEPROM_CAL_PROG);
return read == 1;
}
示例5: ADD_SP_r8
void ADD_SP_r8(struct machine_t *gem) {
struct cpu_t *cpu = gem->cpu;
word before = cpu->sp;
cpu->sp += read_byte(gem, cpu->pc);
cpu->pc++;
cpu->z = 0;
cpu->n = 0;
cpu->hc = ((before & 0x0FFF) > (cpu->hl & 0x0FFF))? 1 : 0;
cpu->ca = (before > cpu->hl)? 1 : 0;
}
示例6: read_value
bool read_value(uint8_t& value)
{
int v = read_byte();
if (v < 0)
{
return false;
}
value = (uint8_t)v;
return true;
}
示例7: ShtReadStatus
/* Reads the status register with checksum (8-bit) */
char ShtReadStatus(unsigned char *p_value, int datapin){
unsigned char error=0;
/* unsigned char checksum=0; */ /* Don't see the need of this yet */
transstart(datapin); /* Transmission start */
error = write_byte(STATUS_REG_R, datapin); /* Send command to sensor */
*p_value = read_byte(datapin); /* Read status register (8-bit) */
/* checksum = read_byte(); */ /* Read checksum (8-bit) */
return error; /* error=1 in case of no response form the sensor */
}
示例8: read_next_tag
/* Reads until the next tag, and returns its code */
static int read_next_tag(FILE * file, int *eof)
{
int c;
*eof = 0;
/* Discard non 0xFF bytes */
do {
c = read_byte(file, eof);
if(*eof)
return 0xFF;
} while(c != 0xFF);
do {
c = read_byte(file, eof);
if(*eof)
return 0xFF;
} while (c == 0xFF);
return c;
}
示例9: memcpy_from_tvm
/* Copy a block of memory from the Transterpreter's possibly-virtual memory
space into real memory. */
static void memcpy_from_tvm (BYTEPTR from, void *to, int size) {
uint8_t *real_to = (uint8_t *) to;
while (size > 0) {
*real_to = read_byte (from);
from = byteptr_plus (from, 1);
++real_to;
--size;
}
}
示例10: read_byte
void IStream::end()
{
Byte8 byte;
read_byte(byte);
if (byte != End)
{
RCF::Exception e(RCF::_SfError_DataFormat(), "no end symbol");
RCF_THROW(e)(byte);
}
}
示例11: skip_leb128
static bfd_boolean
skip_leb128 (bfd_byte **iter, bfd_byte *end)
{
unsigned char byte;
do
if (!read_byte (iter, end, &byte))
return FALSE;
while (byte & 0x80);
return TRUE;
}
示例12: read_4bytes_endian
uint32_t read_4bytes_endian(uint32_t *cpt, FILE *f,uint8_t Endian)
{
if ( Endian == 0 ) { // BigEndian
uint32_t oct1 = 0;
uint32_t oct2 = 0;
oct1 = read_2bytes_endian(cpt,f,Endian);
oct2 = read_2bytes_endian(cpt,f,Endian);
return (oct1 << 16) + oct2;
} else if ( Endian == 1 ) { // LittleEndian
uint8_t oct1,oct2,oct3,oct4;
oct1 =read_byte(cpt,f);
oct2 =read_byte(cpt,f);
oct3 =read_byte(cpt,f);
oct4 =read_byte(cpt,f);
return (oct4 << 24) + (oct3 << 16) + (oct2 << 8) + oct1;
}
return 0;
}
示例13: read_2bytes_endian
uint16_t read_2bytes_endian(uint32_t *cpt, FILE *f, uint8_t Endian)
{
if ( Endian == 0 ) { // BigEndian
uint16_t oct1 = 0;
uint16_t oct2 = 0;
oct1 = read_byte(cpt,f);
oct2 = read_byte(cpt,f);
return (oct1 << 8) + oct2;
} else if ( Endian == 1 ) { // LittleEndian
uint16_t oct1 = 0;
uint16_t oct2 = 0;
oct1 = read_byte(cpt,f);
oct2 = read_byte(cpt,f);
return (oct2 << 8) + oct1;
}
return 0;
}
示例14: read_mct_marker
/**
* @brief Reads MCT marker.
*
* @param buffer
* @param img
*/
void read_mct_marker(type_buffer *buffer, type_image *img) {
int marker;
int length;
uint16_t Smct;
uint8_t type;
int i;
/* Read MCT Marker */
marker = read_buffer(buffer, 2);
if(marker != MCT)
{
println_var(INFO, "Error: Expected MCT marker instead of %x", marker);
}
length = read_buffer(buffer, 4)-5;
/* Read Smct */
Smct = read_byte(buffer);
type = (Smct&(3<<4))>>4;
type_mct* old_mcts = img->mct_data->mcts[type];
img->mct_data->mcts[type] = (type_mct*)realloc(img->mct_data->mcts[type], sizeof(type_mct) * (++img->mct_data->mcts_count[type]));
type_mct* mct = &img->mct_data->mcts[type][img->mct_data->mcts_count[type]-1];
if(img->mct_data->mcts[type] == NULL) {
img->mct_data->mcts[type] = old_mcts;
--img->mct_data->mcts_count[type];
println_var(INFO, "Error: Memory reallocation failed! Ignoring MCT with Smct %u Skipping data", Smct);
for(i=0; i<length-1; ++i) {
read_byte(buffer);
}
} else {
mct->index = Smct&0x0F;
mct->type = type;
mct->element_type = (Smct&(3<<6))>>6;
mct->length = length/(1<<mct->element_type);
mct->data = (uint8_t*)malloc(length);
for(i=0; i<length; ++i) {
mct->data[i] = read_byte(buffer);
}
}
}
示例15: parse_auth
/**
* Parse username and password
*/
static int parse_auth(SSH *ssh) {
byte *p;
byte *out;
byte aux;
word32 outSz;
p = ssh->sp.data;
/* Get username */
read_bin(&p, &out, &outSz);
/* Size valid? */
if (outSz > MAX_UN_LEN)
return -1;
memcpy(ssh->user, out, outSz);
ssh->user[outSz] = 0;
/* Get service */
read_bin(&p, &out, &outSz);
/* Get method */
read_bin(&p, &out, &outSz);
/* Only support password based autentication */
if (memcmp(out, PASSWORD_STR, strlen(PASSWORD_STR)) != 0) {
return 1;
}
/* Read byte */
read_byte(&p, &aux);
/* Get password */
read_bin(&p, &out, &outSz);
/* Size valid? */
if (outSz > MAX_PW_LEN)
return -1;
memcpy(ssh->pass, out, outSz);
ssh->pass[outSz] = 0;
/* Check username and password */
if (check_password(ssh->user, ssh->pass) < 0) {
/* Limit auth attempts */
if (ssh->authAtt++ > 1) {
return -1;
}
return 1;
}
ssh->state = SSH_AUTH;
return 0;
}