示例#1
0
qword sys_read(qword file, qword buffer, qword size, qword r8, qword r9) {
    if (file == 0) {
        readFull((char*) buffer, (int) size);
    }else if(file>2 && file<8){
        pipe_t pipe=getMyProcessData()->fd[file-3];
        readPipe(pipe,buffer,size);
    }
    return 1;
}
示例#2
0
文件: req4.c 项目: x3ro/tinyos-legacy
int readHeader(int file){
    char scratch[200];
    int place = 0;
    int err;
    int i;
    bzero(scratch, 200);
    err = readFull(file, scratch, 1);
	printf("looking for header:, %x, %x, %x\n", scratch[0], scratch[1], scratch[2]);
    if(err == -1) return err;

while((scratch[0] != (char)0x7e)){
        printf("%x\n", scratch[0]);
	place++;
        err = readFull(file, scratch, 1);
        printf("Header: %d\n", scratch[0]&0xFF);
        if(err == -1) return err;
	if(place == 190) place = 0;
    }
   printf("header found\n");
   return 1;
}
示例#3
0
LineReader::State LineReader::readLine(StringPiece& line) {
  bol_ = eol_;  // Start past what we already returned
  for (;;) {
    // Search for newline
    char* newline = static_cast<char*>(memchr(eol_, '\n', end_ - eol_));
    if (newline) {
      eol_ = newline + 1;
      break;
    } else if (state_ != kReading || (bol_ == buf_ && end_ == bufEnd_)) {
      // If the buffer is full with one line (line too long), or we're
      // at the end of the file, return what we have.
      eol_ = end_;
      break;
    }

    // We don't have a full line in the buffer, but we have room to read.
    // Move to the beginning of the buffer.
    memmove(buf_, eol_, end_ - eol_);
    end_ -= (eol_ - buf_);
    bol_ = buf_;
    eol_ = end_;

    // Refill
    ssize_t available = bufEnd_ - end_;
    ssize_t n = readFull(fd_, end_, available);
    if (n < 0) {
      state_ = kError;
      n = 0;
    } else if (n < available) {
      state_ = kEof;
    }
    end_ += n;
  }

  line.assign(bol_, eol_);
  return eol_ != bol_ ? kReading : state_;
}
示例#4
0
dav_ssize_t HttpIOChain::readFull(IOChainContext & iocontext, std::string & str_buffer){
    std::vector<char> buffer;
    dav_ssize_t s = readFull(iocontext, buffer);
    str_buffer.assign(buffer.begin(), buffer.end());
    return s;
}
示例#5
0
dav_ssize_t HttpIOChain::readFull(IOChainContext & iocontext, std::vector<char> &buffer){
    CHAIN_FORWARD(readFull(iocontext, buffer));
}