0 posixerrorrc pthreadmutexinit error void

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: iargs, ""); strcpy(filename, "."); strcat(filename, uri); return 0; } } code/net/tiny/tiny.c Figure 12.50: T INY parse uri: Parses an HTTP URI. 660 CHAPTER 12. NETWORK PROGRAMMING code/net/tiny/tiny.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 void serve_static(int fd, char *filename, int filesize) { int srcfd; char *srcp, filetype[MAXLINE], buf[MAXBUF]; /* send response headers to client */ get_filetype(filename, filetype); sprintf(buf, "HTTP/1.0 200 OK\r\n"); sprintf(buf, "%sServer: Tiny Web Server\r\n", buf); sprintf(buf, "%sContent-length: %d\n", buf, filesize); sprintf(buf, "%sContent-type: %s\r\n\r\n", buf, filetype); Writen(fd, buf, strlen(buf)); /* send response body to client */ srcfd = Open(filename, O_RDONLY, 0); srcp = Mmap(0, filesize, PROT_READ, MAP_PRIVATE, srcfd, 0); Close(srcfd); Writen(fd, srcp, filesize); Munmap(srcp, filesize); } /* * get_filetype - derive file typ...
View Full Document

Ask a homework question - tutors are online