diff options
author | Matt Strapp <strap012@umn.edu> | 2020-11-02 18:54:56 -0600 |
---|---|---|
committer | Matt Strapp <strap012@umn.edu> | 2020-11-02 18:54:56 -0600 |
commit | 0e4ce9c46fffa6e41c41e368f428578d9816c923 (patch) | |
tree | 248cf1c0e561d514bdc90e257e1d4e1521d97d3e | |
parent | Add ideas (diff) | |
parent | please help (diff) | |
download | csci4061-0e4ce9c46fffa6e41c41e368f428578d9816c923.tar csci4061-0e4ce9c46fffa6e41c41e368f428578d9816c923.tar.gz csci4061-0e4ce9c46fffa6e41c41e368f428578d9816c923.tar.bz2 csci4061-0e4ce9c46fffa6e41c41e368f428578d9816c923.tar.lz csci4061-0e4ce9c46fffa6e41c41e368f428578d9816c923.tar.xz csci4061-0e4ce9c46fffa6e41c41e368f428578d9816c923.tar.zst csci4061-0e4ce9c46fffa6e41c41e368f428578d9816c923.zip |
Merge branch 'Branch-2'
Diffstat (limited to '')
-rw-r--r-- | P2/lib/utils.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/P2/lib/utils.c b/P2/lib/utils.c index cb43574..5849296 100644 --- a/P2/lib/utils.c +++ b/P2/lib/utils.c @@ -35,10 +35,9 @@ void sendChunkData(char *inputFile, int nMappers) { // open message queue int msgid = openQueue("map"); int map = 1; - int fd = open(inputFile, O_RDONLY); + FILE* file = fopen(inputFile, "r"); // construct chunks of 1024 bytes - while(read(fd, message.msgText, chunkSize) != 0) { - // printf("%s\n", message.msgText); + while(fgets(message.msgText, chunkSize + 1, file) != NULL) { /* Go to the end of the chunk, check if final character is a space if character is a space, do nothing else cut off before that word and put back file. @@ -52,12 +51,14 @@ void sendChunkData(char *inputFile, int nMappers) { //http://crasseux.com/books/ctutorial/Finding-file-positions-at-a-low-level.html // TODO! help - - // int i = 1023; - // while(message.msgText[i] != ' ') { - // message.msgText - // } - + int i = 1023; + while(message.msgText[i] != ' ' || message.msgText[i] != '.') { + i--; + message.msgText[i] == '\0'; + printf("%d\n", i); + } + fseek(file, (i - 1023), SEEK_CUR); + printf("%s\n", message.msgText); message.msgType = (map++ % nMappers) + 1 ; //THIS IS DEBUG, NOT ACTUALLY FUNCTIONAL (like at all) msgsnd(msgid, &message, map, 0); @@ -67,7 +68,7 @@ void sendChunkData(char *inputFile, int nMappers) { struct msgBuffer END = {i, "END"}; msgsnd(msgid, &END, MSGSIZE, 0); } - + fclose(file); } // hash function to divide the list of word.txt files across reducers |