本文整理汇总了C++中rio_read函数的典型用法代码示例。如果您正苦于以下问题:C++ rio_read函数的具体用法?C++ rio_read怎么用?C++ rio_read使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rio_read函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: rio_readnb
ssize_t rio_readnb(rio_t *rp, void *usrbuf, size_t n)
{
size_t nleft = n;
size_t nread;
char *bufp = (char*)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:Lervard,项目名称:tinyWebServer,代码行数:20,代码来源:csapp.cpp
示例17: rio_readlineb
/* $begin rio_readlineb */
ssize_t rio_readlineb(rio_t *rp, void *usrbuf, size_t maxlen)
{
int n, rc;
char c, *bufp = usrbuf;
n = 0;
while (n < maxlen-1) {
if ((rc = rio_read(rp, &c, 1)) == 1) {
n++;
*bufp++ = c;
if (c == '\n')
break;
} else if (rc == 0) {
break; /* EOF */
} else
return -1; /* error */
}
*bufp = 0;
return n;
}
开发者ID:JunhaoLi,项目名称:Network-Proxy,代码行数:22,代码来源:csapp.c
示例18: rio_readnb
ssize_t rio_readnb(rio_t *rio_ptr, void *buf, size_t n) {
size_t nleft = n;
ssize_t nread;
char *bufptr = buf;
while (nleft > 0) {
nread = rio_read(rio_ptr, bufptr, nleft);
if (nread < 0) {
if (errno == EINTR) {
nread = 0;
} else {
return -1;
}
} else if (nread == 0) {
break;
}
nleft -= nread;
bufptr += nread;
}
return (n - nleft);
}
开发者ID:foreverbell,项目名称:playground,代码行数:21,代码来源:rio_socket.c
示例19: rio_readnb
ssize_t rio_readnb(rio_t* rp, void* usrbuf, size_t n) {
size_t nleft = 0;
ssize_t nread;
char* bufp = usrbuf;
while (nleft > 0) {
if ((nread = rio_read(rp, bufp, nleft)) < 0) {
if (EINTR == errno)
nread = 0;
else
return -1;
}
else if (0 == nread) {
break;
}
nleft -= nread;
bufp += nread;
}
return (n - nleft);
}
开发者ID:songtzu,项目名称:study,代码行数:22,代码来源:rio.c
示例20: rio_readlineb
ssize_t rio_readlineb(rio_t *rp, void *usrbuf, size_t maxlen)
{
size_t n;
char *bufp = usrbuf;
for (n = 1; n < maxlen; n++) {
ssize_t rc = rio_read(rp, bufp, 1);
if (rc < 0)
return -1; /* errno set by read(), give up */
if (rc == 0) {
if (n == 1)
return 0; /* EOF, no data read */
else
break; /* EOF, some data was read */
}
if (*bufp++ == '\n') /* read() success, 0 < rc <= 1 */
break;
}
*bufp = '\0';
return n;
}
开发者ID:Thomas-C-Voegeli,项目名称:web-server-c,代码行数:22,代码来源:tiny_server.c
注:本文中的rio_read函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论