From 2192ac32e36ad5c50aa0401797752deb12091389 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Tue, 17 Nov 2020 09:58:26 -0600 Subject: add most recent things --- P3/server.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'P3') diff --git a/P3/server.c b/P3/server.c index 49ec1be..8b26864 100644 --- a/P3/server.c +++ b/P3/server.c @@ -108,7 +108,7 @@ char* getContentType(char * mybuf) { // Function to open and read the file from the disk into the memory // Add necessary arguments as needed -int readFromDisk(const char* fileName) { +int readFromDisk(const char* fileName, char* buffer) { // Open and read the contents of file given the request } @@ -136,7 +136,7 @@ void * dispatch(void *arg) { if (get_request(newReq, dispatchBuf) != 0) continue; // If get_request fails, try again - + //Hopefully this works. Please work. Please. tempNode->fd = newReq; tempNode->request = dispatchBuf; @@ -181,8 +181,12 @@ void * worker(void *arg) { char *workerBuf = (char *)calloc(BUFF_SIZE, sizeof(char)); //TODO! Fix this holy shit // call readFromDisk and read that shit into workerBuf and then call - readFromDisk(... dispatchBuf); - return_result(request->fd, getContentType(request->request), workerBuf, ); + readFromDisk(... workerBuf); + //use fstat's stat_st to get numbytes? + struct stat* oob; + fstat(request->fd, &oob); + numbytes = oob->st_size; + return_result(request->fd, getContentType(request->request), workerBuf, numbytes); } return NULL; } -- cgit v1.2.3