C figure 1250 t iny parse uri parses an http uri 660

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: tr->rl_buf; } code/src/csapp.c Figure 12.37: readline rint: Initialization function for readline r. Figure 12.38 shows the code for the readline r package. The only difference between readline r and readline is that readline r calls my read r instead of my read in line 28. The my read r function is similar to the original my read function, except that it references members of the Rline struct instead of static variables. 12.6. CONCURRENT SERVERS 645 code/src/csapp.c 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 static ssize_t my_read_r(Rline *rptr, char *ptr) { if (rptr->rl_cnt <= 0) { again: rptr->rl_cnt = read(rptr->read_fd, rptr->rl_buf, sizeof(rptr->rl_buf)); if (rptr->rl_cnt < 0) { if (errno == EINTR) goto again; else return(-1); } else if (rptr->rl_cnt == 0) return(0); rptr->rl_bufptr = rptr->rl_buf; } rptr->rl_cnt--; *ptr = *rptr->rl_bufptr++ & 255; return(1); } ssize_t readline_r(Rline *r...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online