aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Strapp <strap012@umn.edu>2020-11-02 18:40:44 -0600
committerMatt Strapp <strap012@umn.edu>2020-11-02 18:40:44 -0600
commit0306093118d171bb332bd8b8d4cf9d66a6ff1d84 (patch)
tree0941416ff4d623340b56a77a1ddd7fff57785c69
parentAdd link (diff)
downloadcsci4061-0306093118d171bb332bd8b8d4cf9d66a6ff1d84.tar
csci4061-0306093118d171bb332bd8b8d4cf9d66a6ff1d84.tar.gz
csci4061-0306093118d171bb332bd8b8d4cf9d66a6ff1d84.tar.bz2
csci4061-0306093118d171bb332bd8b8d4cf9d66a6ff1d84.tar.lz
csci4061-0306093118d171bb332bd8b8d4cf9d66a6ff1d84.tar.xz
csci4061-0306093118d171bb332bd8b8d4cf9d66a6ff1d84.tar.zst
csci4061-0306093118d171bb332bd8b8d4cf9d66a6ff1d84.zip
Pain
-rw-r--r--P2/lib/utils.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/P2/lib/utils.c b/P2/lib/utils.c
index b9454bb..577ca64 100644
--- a/P2/lib/utils.c
+++ b/P2/lib/utils.c
@@ -38,7 +38,6 @@ void sendChunkData(char *inputFile, int nMappers) {
int fd = open(inputFile, O_RDONLY);
// construct chunks of 1024 bytes
while(read(fd, message.msgText, chunkSize) != 0) {
- // printf("%s\n", message.msgText);
/* 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.
@@ -46,16 +45,18 @@ void sendChunkData(char *inputFile, int nMappers) {
Maybe copy message.msgText into a new array, do the
backwards iteration, and then replace message.msgText
with the temp array? Or something? */
- //fseek()??
- //https://www.tutorialspoint.com/c_standard_library/c_function_fseek.htm
+ //lseek()?? (LOW LEVEL)
+ //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] != ' ') {
+ i--;
+ printf("%d\n", i);
+ }
+ lseek(fd, (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);