aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Strapp <strap012@umn.edu>2020-11-17 09:58:26 -0600
committerMatt Strapp <strap012@umn.edu>2020-11-17 09:58:26 -0600
commit2192ac32e36ad5c50aa0401797752deb12091389 (patch)
treea0246f47c9c13b437754cd0ab34c96d580e7c532
parenthelp (diff)
downloadcsci4061-2192ac32e36ad5c50aa0401797752deb12091389.tar
csci4061-2192ac32e36ad5c50aa0401797752deb12091389.tar.gz
csci4061-2192ac32e36ad5c50aa0401797752deb12091389.tar.bz2
csci4061-2192ac32e36ad5c50aa0401797752deb12091389.tar.lz
csci4061-2192ac32e36ad5c50aa0401797752deb12091389.tar.xz
csci4061-2192ac32e36ad5c50aa0401797752deb12091389.tar.zst
csci4061-2192ac32e36ad5c50aa0401797752deb12091389.zip
add most recent things
Diffstat (limited to '')
-rw-r--r--P3/server.c12
1 files changed, 8 insertions, 4 deletions
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;
}