#ifndef _CHAT_H #define _CHAT_H #include #define LBUFFSIZE 128 #define CBUFFSIZE 331 #define INCRSLOT(V) { \ ++(*V) ; \ if ((*V) >= CBUFFSIZE) \ (*V) = 0 ; \ } enum Lstates {UNUSED, MESSAGE} ; struct linebuff { enum Lstates status; /* status of this linebuffer */ int created ; /* Time (seconds since 1970?) entry was made */ int size ; /* number of characters used in buffer */ char buff[LBUFFSIZE] ; /* characters of the buffer */ } ; struct chatbuff { int nextSlot ; /* Index of nextSlot to use */ pthread_mutex_t nextSlotMutex ; pthread_cond_t nextSlotConditional ; struct linebuff buff[CBUFFSIZE] ; /* We didn't talk about this one in class... * Using it requires you to define _GNU_SOURCE in the Makefile * There probably is a better way to do this */ pthread_rwlock_t buffRWlock[CBUFFSIZE] ; } ; struct ptGenericArg { struct chatbuff *G ; /* Pointer to the global chatbuff */ int sock ; /* File Descriptor for socket */ } ; /* prototypes for pthread_create */ void *InputFromUser(void *) ; void *OutputToUser(void *) ; void *InputRecept(void *) ; void *OutputRecept(void *) ; void *MessageReaper(void *) ; #endif