亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? readbufffd.cpp

?? 機器人足球AI設計比賽
?? CPP
字號:
/***************************************************************************************** *                                      SEU-3D *                     ------------------------------------------------- * Copyright (c) 2005, Yuan XU<xychn15@yahoo.com.cn>,Chang'e SHI<evelinesce@yahoo.com.cn> * Copyright (c) 2006, Yuan XU<xuyuan.cn@gmail.com>,Chunlu JIANG<JamAceWatermelon@gmail.com> * Southeast University ,China * All rights reserved. * * Additionally,this program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ****************************************************************************************//* -*- Mode: c++ -*- *//* *Copyright: Copyright (C) 2002, 2003 Patrick Riley Copyright (C) 2001 Patrick Riley and Emil Talpes This file is part of the SPADES simulation system. The SPADES simulation system is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The SPADES simulation system is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the SPADES simulation system; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *EndCopyright:*//* this read buffer a file descriptor, notably allowing a read until a particular demlimeter */#include <errno.h>#include <string.h>#include <fcntl.h>#include <unistd.h>#include <netinet/in.h>#include "ReadBuffFD.h"using namespace spades;/**********************************************************************************/const intspades::ReadBuffFD::s_default_read_buffer_size = 1024;/**********************************************************************************/spades::ReadBuffFD::ReadBuffFD(int new_fd)  : fd(-1){  read_buffer = new char[s_default_read_buffer_size];  read_buffer_size = s_default_read_buffer_size;  read_buffer_len = 0;  setNewFD(new_fd);}spades::ReadBuffFD::~ReadBuffFD(){  close();  delete [] read_buffer;}voidspades::ReadBuffFD::forgetFD(){  //actlog(100, SLC->network()) << "ReadBuffFD: forgetting fd " << fd << ende;  fd = -1;}voidspades::ReadBuffFD::setNewFD(int new_fd){  close();  fd = new_fd;  if (fd != -1)    {      if (fcntl (fd, F_SETFL, O_NONBLOCK) != 0)		  ;	//errorlog << *this << ": Error on fcntl " << errno << ": " << strerror(errno) << ende;    }}boolspades::ReadBuffFD::close(){  if (fd == -1)    return true;    bool ret = true;    if (::close (fd) != 0)    {      //warninglog(10) << *this << ": Error on close " << errno << ": " << strerror(errno) << ende;      ret = false;    }  fd = -1;    return ret;}/* return   > 0: number of bytes read   0  : not enough available right now   -1 : fd is now invalid (errno will be set)   Note that the delimiter is on the buf   if we reach the max len on the buffer, the buffer is filled */intspades::ReadBuffFD::readline(char* buf, int maxlen, char delim){  //warninglog(10) << "You are now using ReadBuffFD::readline; this function has been modified and not tested as it was not used at the time of modification" << ende;    for (;;)    {      /* check to see if we have enough data */      char* rb = read_buffer;      for (int i=0; i<read_buffer_len; i++)	{	  if (*rb == delim || i+1 == maxlen)	    {	      //actlog(220, SLC->network()) << *this << ": satisfying from read buffer " << i << ende;	      memcpy(buf, read_buffer, i+1);	      if (i+1 != read_buffer_len)		memmove(read_buffer, rb+1, read_buffer_len - i - 1);	      read_buffer_len = read_buffer_len - i - 1;	      return i+1;	    }	  rb++;	}      /* there was not enough data in the read buffer, so let's try to get some more */      /* rb points to the location right after the last valid byte in the buffer */      int res = ::read(fd, rb, read_buffer_size - read_buffer_len);      if (res < 0)	{	  /* error case */	  if (errno == EAGAIN)	    {	      /* no more data available */	      //actlog(220, SLC->network()) << *this << ": no more data " << read_buffer_len << ende;	      return 0;	    }	  else if (errno == EINTR)	    {	      /* Note that we really could keep trying in this case. However,		 I want to avoid looping on a single socket. A select call on this		 socket will still return immediately, so it shouldn't slow us down		 (much). Plus I don't think we get interrupted all that often */	      //actlog(200, SLC->network()) << *this << ": interrupted system call, returning" << ende;	      return 0;	    }	  else	    {	      //errorlog << *this << ": error on read "		  //     << errno << ": " << strerror(errno) << ende;	      if (read_buffer_len)		{		  /* let's copy whatever data we have */		  int len = read_buffer_len;		  memcpy(buf, read_buffer, len);		  read_buffer_len = 0;		  return len;		}	      return -1;	    }	}      else if (res == 0)	{	  /* we got an eof! */	  //actlog(220, SLC->network()) << *this << ": EOF with " << read_buffer_len << ende;	  if (read_buffer_len)	    {	      /* let's copy whatever data we have */	      int len = read_buffer_len;	      memcpy(buf, read_buffer, len);	      read_buffer_len = 0;	      return len;	    }	  errno = EBADF;	  return -1;	}        /* res is > 0 */      //actlog(220, SLC->network()) << *this << ": read " << res << ende;      read_buffer_len += res;          }  }intspades::ReadBuffFD::isFixedLengthDataAvailable(int len){  if (len == 0)    return 1;    /* check whether the read_buffer is large enough to handle this request     if not, reallocate the array */  if (read_buffer_size < len)    {      reallocReadBuffer(len);    }  for (;;)    {      /* See if we have enough data to satisfy request */      if (read_buffer_len >= len)	{	  return 1;	}      /* there was not enough data in the read buffer, so let's try to get some more */      int res = ::read(fd, read_buffer + read_buffer_len, read_buffer_size - read_buffer_len);      if (res < 0)	{	  /* error case */	  if (errno == EAGAIN)	    {	      /* no more data available */	      //actlog(210, SLC->network()) << "ReadBuffFD::isFixedLengthDataAvailable: only "			//		  << read_buffer_len << " available, < " << len << ende;	      return 0;	    }	  else	    {	      //errorlog << *this << "::readFixedLength: error on read "		  //     << errno << ": " << strerror(errno) << ende;	      return -1;	    }	}      else if (res == 0)	{	  /* we got an eof! */	  //actlog(150, SLC->network()) << *this << ": EOF with " << read_buffer_len		//		      << " of " << len << " desired" << ende;	  errno = EBADF;	  return -1;	}        /* res is > 0 */      read_buffer_len += res;          }	    }/* return   1  : succesfully read   0  : not enough available right now   -1 : fd is now invalid (errno will be set)   Note that this could cause a realloc of read_buffer 	*/intspades::ReadBuffFD::readFixedLength(char* buf, int len){  if (len == 0)    return 1;  int res = isFixedLengthDataAvailable(len);  if (res == 1)    {      memcpy(buf, read_buffer, len);      memmove(read_buffer, read_buffer+len, read_buffer_len - len);      read_buffer_len -= len;      return len;    }  //res is 0 or -1  return res;  }/* the first sizeof(int) bytes (in net byte order) say how long this   "message" is. The buffer may be reallocated to fill this. The four byte length   is *not* put into buf    return   >0 : amt successfully read   0: not enough data avilable   -1: fd is invalid, errno wil be set */intspades::ReadBuffFD::readLengthPrefixed(char** pbuf, unsigned int* plen){  unsigned int mess_len;  int res;    res = isFixedLengthDataAvailable(sizeof(int));  if (res != 1)    return res;  //get the message length  memcpy(&mess_len, read_buffer, sizeof(int));  mess_len = ntohl(mess_len);  //make sure the target buffer is big enough  if (*pbuf == NULL || mess_len > *plen)    {      //use a doubling sort of scheme so that we don't waste too much time reallocing      int new_len = (*plen*2 >= mess_len) ? *plen*2 : mess_len;      //actlog(200, SLC->network()) << "readLengthPrefixed: requiring realloc of " << new_len		//		  << ": " << mess_len << " > " << *plen << ende;      delete [] (*pbuf);      *pbuf = new char[new_len];      *plen = new_len;    }    //try and get the data  res = isFixedLengthDataAvailable(mess_len+sizeof(int));  if (res != 1)    return res;  //we have to copy, skipping the sizeof(int) bytes at the beginning  memcpy(*pbuf, read_buffer+sizeof(int), mess_len);  memmove(read_buffer, read_buffer+sizeof(int)+mess_len, read_buffer_len - (sizeof(int) + mess_len));  read_buffer_len -= sizeof(int) + mess_len;  return mess_len;}boolspades::ReadBuffFD::addToReadBuffer(const char* b, int l){  if ( b == NULL || l <= 0 )    return false;  if (read_buffer_len + l > read_buffer_size)    reallocReadBuffer(read_buffer_len + l);  memcpy(read_buffer + read_buffer_len, b, l);  read_buffer_len += l;  return true;}voidspades::ReadBuffFD::reallocReadBuffer(int new_len){#ifdef SANITY_CHECKING  if (new_len > 1 << 16)    errorlog << "ReadBuffFD::reallocReadBuffer: new_len seems really big: " << new_len << ende;#endif	  char* old_read_buffer = read_buffer;  read_buffer = new char[new_len];  memcpy(read_buffer, old_read_buffer, read_buffer_len);  read_buffer_size = new_len;  delete [] old_read_buffer;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩国产欧美在线播放| 精品一区二区三区免费播放| 三级精品在线观看| 国产成人av在线影院| 欧美色视频一区| 国产精品美女一区二区三区| 美女免费视频一区二区| 91丨porny丨户外露出| 久久免费的精品国产v∧| 午夜精品福利久久久| 91小视频在线免费看| 久久精品亚洲乱码伦伦中文| 毛片av中文字幕一区二区| 欧美色视频在线| 亚洲激情自拍视频| 96av麻豆蜜桃一区二区| 国产女同互慰高潮91漫画| 久久66热偷产精品| 欧美一区二区三区视频| 五月激情综合网| 欧亚洲嫩模精品一区三区| 国产精品无人区| 国产精品一卡二卡| 精品久久久久久久人人人人传媒| 秋霞国产午夜精品免费视频| 欧美日韩国产影片| 亚洲成人av一区二区| 欧美三级中文字幕在线观看| 亚洲大片免费看| 欧美日韩免费一区二区三区 | 日本黄色一区二区| 国产精品久久影院| 99久久夜色精品国产网站| 国产精品毛片久久久久久| 国产99久久久国产精品免费看 | 黄色成人免费在线| 欧美va亚洲va在线观看蝴蝶网| 日本视频一区二区三区| 日韩欧美精品三级| 国产一区二三区| 日本一区二区三区免费乱视频| 国产suv一区二区三区88区| 中文字幕va一区二区三区| 成人不卡免费av| 一区二区三区在线观看欧美| 在线视频欧美精品| 亚洲第一会所有码转帖| 欧美xingq一区二区| 国产精品自拍网站| 亚洲日本一区二区| 5月丁香婷婷综合| 激情国产一区二区| 国产精品久久久久久久久快鸭| 91原创在线视频| 天天综合色天天综合色h| 精品国产一区二区三区av性色| 国产成人免费视频精品含羞草妖精| 国产精品毛片大码女人| 在线日韩国产精品| 秋霞午夜鲁丝一区二区老狼| 中文字幕+乱码+中文字幕一区| 91免费观看在线| 人人狠狠综合久久亚洲| 中文字幕不卡在线观看| 欧美性猛片aaaaaaa做受| 久久av老司机精品网站导航| 欧美激情一区二区三区全黄| 欧美日韩的一区二区| 国产毛片精品国产一区二区三区| 亚洲日本在线天堂| wwwwxxxxx欧美| 91久久奴性调教| 国产美女精品在线| 亚洲成人免费看| 日本一区二区三级电影在线观看 | 国产成人午夜精品5599| 亚洲已满18点击进入久久| 久久久亚洲精品一区二区三区| 在线视频国内自拍亚洲视频| 国产成人免费9x9x人网站视频| 一区二区三区鲁丝不卡| 国产午夜亚洲精品不卡| 欧美日本在线一区| 91猫先生在线| 国产成人鲁色资源国产91色综| 日本女优在线视频一区二区| 亚洲欧美偷拍三级| 国产丝袜美腿一区二区三区| 91麻豆精品国产91久久久久久久久 | 午夜欧美电影在线观看| ...中文天堂在线一区| 精品国产自在久精品国产| 91黄色免费网站| 99热国产精品| 成人免费不卡视频| 精品一区二区三区免费| 免费av网站大全久久| 亚洲第一会所有码转帖| 一区二区在线观看不卡| 中文字幕一区二区三区在线播放| xf在线a精品一区二区视频网站| 欧美美女一区二区三区| 欧美日韩亚洲综合在线| 91免费版在线| 99精品在线观看视频| 国产成人免费9x9x人网站视频| 国内外成人在线| 看国产成人h片视频| 日韩av二区在线播放| 五月天网站亚洲| 日产国产高清一区二区三区| 亚洲mv在线观看| 亚洲成人av免费| 免费观看一级特黄欧美大片| 日本人妖一区二区| 青青草97国产精品免费观看 | 久久综合九色综合97婷婷女人 | 欧美成人在线直播| 精品乱人伦小说| 久久久亚洲高清| 久久精品视频网| 亚洲欧美在线视频| 一区二区三区精品视频| 亚洲午夜激情网页| 五月婷婷另类国产| 日韩电影一区二区三区四区| 美女网站色91| 国产精品一区二区你懂的| 成人av动漫在线| 色婷婷av一区二区三区大白胸| 欧美色中文字幕| 欧美一区二区三区男人的天堂| 亚洲精品一区二区三区精华液| 久久久精品一品道一区| 亚洲欧洲日产国码二区| 一区二区三区日本| 亚洲电影你懂得| 久久精品国产秦先生| 国产91色综合久久免费分享| 99精品欧美一区| 欧美日韩电影在线播放| 久久久亚洲欧洲日产国码αv| 国产精品传媒视频| 亚洲444eee在线观看| 国产一区二区福利视频| 色婷婷国产精品综合在线观看| 欧美日本一区二区三区四区| 精品国产精品网麻豆系列| 自拍视频在线观看一区二区| 视频一区国产视频| 国产a久久麻豆| 欧美日韩视频在线第一区 | 国产成人免费视频一区| 在线视频欧美区| 久久人人超碰精品| 亚洲在线成人精品| 粉嫩蜜臀av国产精品网站| 欧美性色综合网| 国产精品三级久久久久三级| 人人爽香蕉精品| 在线观看日韩电影| 国产欧美日韩三区| 日本网站在线观看一区二区三区| 成人国产亚洲欧美成人综合网 | 蜜臀av性久久久久蜜臀aⅴ | 亚洲免费观看高清完整版在线观看| 青青草原综合久久大伊人精品 | 国产亚洲精品福利| 午夜亚洲福利老司机| 成人性生交大片免费看中文| 欧美精品乱码久久久久久| 国产精品国产三级国产a | 亚洲精品在线观看网站| 一区二区视频免费在线观看| 国产精品123| 欧美一区二区三区啪啪| 亚洲大片精品永久免费| 色吧成人激情小说| 综合激情成人伊人| 国产成人精品亚洲777人妖| 精品剧情在线观看| 日韩精品三区四区| 欧美精选一区二区| 亚洲国产毛片aaaaa无费看| 99精品视频在线播放观看| 国产午夜精品久久| 国产一区二区中文字幕| 精品免费国产二区三区| 久久机这里只有精品| 欧美一卡二卡三卡四卡| 日本欧美在线看| 91精品国产福利在线观看| 日韩福利视频导航| 欧美一区永久视频免费观看| 丝袜美腿亚洲一区二区图片| 欧美日韩第一区日日骚| 日韩在线播放一区二区| 欧美一区二区三区免费在线看| 日精品一区二区三区| 日韩一区二区不卡|