本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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 */
}
示例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);
}
示例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);
}
示例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 */
}
示例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;
}
示例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;
}