当前位置: 首页>>代码示例>>C++>>正文


C++ rio_read函数代码示例

本文整理汇总了C++中rio_read函数的典型用法代码示例。如果您正苦于以下问题:C++ rio_read函数的具体用法?C++ rio_read怎么用?C++ rio_read使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rio_read函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rio_readlineb

/* $begin rio_readlineb */
ssize_t rio_readlineb(rio_t *rp, void *usrbuf, size_t maxlen) 
{
    int n, rc;
    char c, *bufp = usrbuf;
	char line[8192];
	
	while(strstr(line, "HTTP") == NULL)
	{
		for (n = 1; n < maxlen; n++) { 
		if ((rc = rio_read(rp, &c, 1)) == 1) {
			*bufp++ = c;
			line[n-1] = c;
			if (c == '\n')
			break;
		} else if (rc == 0) {
			if (n == 1)
			return 0; /* EOF, no data read */
			else
			break;    /* EOF, some data was read */
		} else
			return -1;	  /* error */
		}
		*bufp = 0;
	}
	if (strstr(line, "HTTP/1.1") == NULL)
	{
		
		for (n = 1; n < maxlen; n++) { 
		if ((rc = rio_read(rp, &c, 1)) == 1) {
			*bufp++ = c;
			line[n-1] = c;
			if (c == '\n')
			{
			break;}
		} else if (rc == 0) {
			if (n == 1)
			return 0; /* EOF, no data read */
			else
			break;    /* EOF, some data was read */
		} else
			return -1;	  /* error */
		}
		*bufp = 0;
		
		rio_read(rp, &c, 1);
		//rio_read(rp, &c, 1);
		
		
		return n;
	}
	
    return n;
}
开发者ID:NealSchneier,项目名称:School,代码行数:54,代码来源:csapp.c

示例2: rio_readlineb

ssize_t rio_readlineb(rio_t* rp, void* usrbuf, size_t maxlen) {
  int n, rc;
  char c;
  char* bufp = usrbuf;

  for (n = 1; n < maxlen; ++n) {
    if (1 == (rc = rio_read(rp, &c, 1))) {
      *bufp++ = c;
      if ('\n' == c)
        break;
    }
    else if (0 == rc) {
      if (1 == n)
        return 0;
      else
        break;
    }
    else {
      return -1;
    }
  }

  *bufp = 0;

  return n;
}
开发者ID:songtzu,项目名称:study,代码行数:26,代码来源:rio.c

示例3: rio_readnb

/*	Robustly read n bytes(buffered)	*/
ssize_t rio_readnb(rio_t *rp, void *usrbuf, size_t n)
{
	int rc, nleft;
	char *bufp = usrbuf;
	nleft = n;
	while( nleft > 0)
	{
		if ((rc = rio_read(rp, bufp, nleft)) < 0)
		{
			if(errno != EINTR)
				return -1;
			else 
				continue;
		}
		else if (rc == 0)
		{
			return 0;
		}
		else
		{
			bufp += rc;
			nleft -= rc;
		}
	}
	return n - nleft;
}
开发者ID:jack-lijing,项目名称:unix,代码行数:27,代码来源:csapp.c

示例4: rio_readlineb

ssize_t rio_readlineb(rio_t *rp,void *usrbuf,size_t maxlen)
{
	int n,rc;
	char c,*bufp = usrbuf;

	for(n = 1;n < maxlen; n++)
	{
		if((rc = rio_read(rp,&c,1)) == 1)
		{
			*bufp++ = c;
			if(c == '\n')
			{
				break;
			}
		}else if(rc == 0)
		{
			if(n == 1)
			{
				return 0;
			}else
			{
				break;
			}
		}else 
		{
			return -1;
		}
	}
	*bufp = 0;
	return n;
}
开发者ID:QaoA,项目名称:csapp-tinyweb,代码行数:31,代码来源:RIO.c

示例5: rio_readnb

ssize_t rio_readnb(rio_t *rp,void *usrbuf,size_t n)
{
	size_t nleft = n;
	ssize_t nread;
	char *bufp = usrbuf;

	while(nleft > 0)
	{
		if((nread = rio_read(rp,bufp,nleft)) < 0)
		{
			if(errno == EINTR)
			{
				nread = 0;
			}else
			{
				return -1;
			}
		}else if(nread == 0)
		{
			break;
		}

		nleft -= nread;
		bufp += nread;
	}
	return (n-nleft);
}
开发者ID:QaoA,项目名称:csapp-tinyweb,代码行数:27,代码来源:RIO.c

示例6: rio_readlineb

ssize_t rio_readlineb(rio_t *rp, void *buf, size_t n)
{
    size_t i, ret;
    char c;
    char *bp = (char *)buf;
    for(i = 1; i < n; ++i)
    {
        if((ret = rio_read(rp, &c, 1)) == 1)
        {
            *bp++ = c;
            if(c == '\n')
                break;
        }
        else if(ret == 0)
        {
            if(i == 1)
                return 0;
            else break;
        }
        else
            return -1;
    }
    *bp = '\0';
    return i;
}
开发者ID:Zirconi,项目名称:whd,代码行数:25,代码来源:rio.c

示例7: rio_readlineb

/* $begin rio_readlineb */
ssize_t rio_readlineb(rio_t *rp, void *usrbuf, size_t maxlen) 
{
    int n, rc;
    char c, *bufp = usrbuf;


    for (n = 1; n < maxlen; n++) { 
	if ((rc = rio_read(rp, &c, 1)) == 1) {
	    *bufp++ = c;
	    if (c == '\n')
			break;
	} else if (rc == 0) {
	    if (n == 1)
		{
			return 0; /* EOF, no data read */
		}
	    else
		{
			break;    /* EOF, some data was read */
		}
	}
	 else
	{
	    return -1;	  /* error */
    }
	}
    *bufp = 0;
    return n;
}
开发者ID:Firkraag,项目名称:http-proxy,代码行数:30,代码来源:csapp.c

示例8: rio_readlineb

ssize_t rio_readlineb(rio_t *rp, char *usrbuf, size_t maxlen)
{	/* read_one_line function WITH buffer */
	int n, rc;
	char c, *bufp = usrbuf;
	
	for (n = 1; n < maxlen; n++)
	{
		if ((rc = rio_read(rp, &c, 1)) == 1)
		{
			*bufp++ = c;
			if (c == '\n')
				break;
		}
		else if (rc == 0)
		{
			if (n == 1)
				return 0;	/* EOF, no data was read */
			else
				break;		/* EOF, some data was read */
		}
		else
		{
			return -1;		/* error */
		}
	}
	
	*bufp = 0;
	
	return n;
}
开发者ID:ChenKode,项目名称:Tiny,代码行数:30,代码来源:rio.cpp

示例9: Rio_read

static ssize_t Rio_read(rio_t *rp, char *usrbuf, size_t n)
{
	ssize_t rt;
	rt = rio_read(rp, usrbuf, n);
	if (rt == -1)
		unix_error("Rio_read error");
	return rt;
}
开发者ID:jack-lijing,项目名称:unix,代码行数:8,代码来源:csapp.c

示例10: rio_readnb

/* $begin rio_readnb */
ssize_t rio_readnb(rio_t *rp, void *usrbuf, size_t n) 
{
    size_t nleft = n;
    ssize_t nread;
    char *bufp = usrbuf;
    
    while (nleft > 0) {
	if ((nread = rio_read(rp, bufp, nleft)) < 0) 
            return -1;          /* errno set by read() */ 
	else if (nread == 0)
	    break;              /* EOF */
	nleft -= nread;
	bufp += nread;
    }
    return (n - nleft);         /* return >= 0 */
}
开发者ID:ShenTensen,项目名称:CSAPP,代码行数:17,代码来源:csapp.c

示例11: while

int Rio::rio_readn(void *usrbuf, int n)
{
	int nread;
	int nleft = n;
	char *bufp = (char*)usrbuf;
	while(nleft > 0)
	{
		if((nread = rio_read(bufp, nleft)) == -1)
			return -1;
		else if(nread == 0)
			return 0;
		nleft -= nread;
		bufp += nread;
	}
	return (n - nleft);
}
开发者ID:souldong1591,项目名称:project,代码行数:16,代码来源:Rio.cpp

示例12: while

ssize_t Rio::rio_readn(char *usrbuf, size_t n)
{
	ssize_t nread;
	size_t nleft = n;
	char *bufp = usrbuf;
	while(nleft > 0)
	{
		if((nread = rio_read(bufp, nleft)) == -1)
			return -1;
		else if(nread == 0)
			return 0;
		nleft -= nread;
		bufp += nread;
	}
	return (n - nleft);
}
开发者ID:souldong1591,项目名称:project,代码行数:16,代码来源:Rio.cpp

示例13: rio_readnb

/* $begin rio_readnb */
ssize_t rio_readnb(rio_t *rp, void *usrbuf, size_t n) {
	size_t nleft = n;
	ssize_t nread;
	char *bufp = usrbuf;

	while (nleft > 0) {
		if ((nread = rio_read(rp, bufp, nleft)) < 0) {
			if (errno == EINTR) /* interrupted by sig handler return */
				nread = 0; /* call read() again */
			else
				return -1; /* errno set by read() */
		} else if (nread == 0)
			break; /* EOF */
		nleft -= nread;
		bufp += nread;
	}
	return (n - nleft); /* return >= 0 */
}
开发者ID:ZxMYS,项目名称:Xiaos-IPv4-IPv6-Transmit-Toolkit,代码行数:19,代码来源:csapp.c

示例14: rio_readline

ssize_t rio_readline(rio_t *rp, char *usrbuf, size_t maxlen)
{
	ssize_t nread;
	char c;
	int i;
	for (i = 0; i < maxlen - 1; ++i) {
		nread = rio_read(rp, &c, 1);
		if (nread == -1) 
			return -1;
		else if (nread == 0) 
			break;
		//放入usrbuf
		*usrbuf++ = c;
		if (c == '\n')
			break;
	}
	*usrbuf = '\0';
	return i;
}
开发者ID:guoqunabc,项目名称:C-Cplusplus,代码行数:19,代码来源:test.c

示例15: rio_readlineb

ssize_t rio_readlineb(rio_t *rp, void *usrbuf, size_t maxlen) {
  int n, rc;
  char c, *bufp = usrbuf;
  // copy at most maxlen - 1 bytes, the left 1 byte for null terminate ch
  for (n = 1; n < maxlen; ++n) {
    if ((rc = rio_read(rp, &c, 1)) == 1) {
      *bufp++ = c;
      if (c == '\n') {
        break;
      }
    } else if (rc == 0) {
      if (n == 1) return 0; // EOF, no data read
      else break;
    } else {
      return -1;
    }
  }
  *bufp = '\0';
  return n;
}
开发者ID:Guitang-Lan,项目名称:CSAPP,代码行数:20,代码来源:xnix_helper.c


注:本文中的rio_read函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。