diff --git a/img.c b/img.c index 79bbeb34f75a17c5919ae38d8eeb907fefa17ed5..547d7bf4727cafde90ed38fd90a418ff80d69b43 100644 --- a/img.c +++ b/img.c @@ -163,7 +163,8 @@ struct User* find_curr(struct User* user_arr[], char* buff) // the user in arrsy if not this one, then should be that one struct User* the_other_user(struct User* curr_user, struct User* user_arr[]){ for(int i=0; i<2; i++){ - if (user_arr[i]!=curr_user){ + if (user_arr[i]->userID!=curr_user->userID){ + printf("the other user id is %d\n", user_arr[i]->userID); return user_arr[i]; } } @@ -183,8 +184,10 @@ bool match(char* w1, char** w2, int n_word){ // only load page void simple_load_html(char* html, int sockfd, char* buff, int n, struct User* curr_user){ + struct stat st; stat(html, &st); + // print into buff n = sprintf(buff, HTTP_200_FORMAT, st.st_size,curr_user->userID); if (write(sockfd, buff, n) < 0) { @@ -271,7 +274,7 @@ void edit_load_html(char* html, int sockfd, char* buff, char* newword,struct Use // read the words into the curr_user->keywords void record_keyword(struct User* curr_user, char *new_guess){ for (int i=0; i<=curr_user->n_word; i++){ - + // add to the first NULL bit and malloc if(curr_user->keywords[curr_user->n_word]==NULL){ curr_user->keywords[curr_user->n_word] = malloc((1 + strlen(new_guess)) * sizeof(char*)); strcpy(curr_user->keywords[curr_user->n_word],new_guess);