#ifndef PROGRAM4_SERVER_H #define PROGRAM4_SERVER_H #define MAX_PEERS 1000 // each client may only publish 10 files, each with a length of 255 #define MAX_FILES 10 #define MAX_FILENAME_LEN 255 #include #include #include #include #include struct peer_entry { uint32_t id; // ID of peer int socket_descriptor; // Socket descriptor for connection to peer char files[MAX_FILES][MAX_FILENAME_LEN]; // Files published by peer struct sockaddr_in address; // Contains IP address and port number }; // Returns index of a peer_entry from an array with the given file descriptor int find_peer(struct peer_entry **peers, int file_descriptor); // Control flow function for handling commands from peers int process_request(char *buf, struct peer_entry **peers, int socket_descriptor); //Process Request sends to these three functions int parse_join(char *buf, struct peer_entry *peer); int parse_publish(char *buf, struct peer_entry *peer); int parse_search(char *buf, struct peer_entry **peers, int sender_fd); // Returns the index of the first open peer int find_open_peer(struct peer_entry **peers); #endif //PROGRAM4_SERVER_H