Advertisement
AnonymousNamefag

chat.h

Oct 10th, 2018
92
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #ifndef _CHAT_H_
  2. #define _CHAT_H_
  3.  
  4. #define SERVER_MESSAGE_TYPE 65536
  5. #define SHM_SIZE 65536 /* 4KB */
  6.  
  7. int shm_id;
  8. int msg_id;
  9. void *shm_addr;
  10.  
  11. void *cur_addr;
  12. /*
  13.  * Pointer starts at beginning of shared memory region,
  14.  * then advances every time a new message is written until
  15.  * it reaches the end, at which point it starts over at the
  16.  * beginning, overwriting the oldest entries.
  17.  */
  18.  
  19. struct message {
  20.     long mtype; /* Holds the client's PID */
  21.     char mtext[4096];
  22. };
  23. /*
  24.  * The mtype for messages sent from server to clients needs
  25.  * to encode both the client's PID and the fact that it's a
  26.  * message to the client rather than from the client.  To do
  27.  * this, I will have it be 65536 plus the PID of the client.
  28.  */
  29.  
  30. __BEGIN_DECLS
  31. void deamonize( void );
  32. void initialize_user_list( void );
  33. void create_shared_memory( void );
  34. void create_message_queue( void );
  35. void poll( void );
  36. void server_process( struct message * );
  37. void broadcast( char * );
  38. void adduser( long );
  39. void deluser( long );
  40. void say( struct message * );
  41. void echo( char *, long );
  42. void write_memory( struct message * );
  43. void memwrite( char * );
  44. void signals( void );
  45. void stop( int );
  46. void cont( int );
  47. void quit( int );
  48. void client_process( int );
  49. void setup_user( void );
  50. void register_shared_memory( void );
  51. void register_message_queue( void );
  52. void enter_raw_mode( void );
  53. void input_loop( void );
  54. void exit_raw_mode( void );
  55. void mwrite( struct message * );
  56. void kick( void );
  57. void update_ptr( void );
  58. void mread( void );
  59. char *memread( void );
  60. __END_DECLS
  61.  
  62. #endif
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement