1 #ifndef __RLS_SESSIONS__
2 #define __RLS_SESSIONS__
11 typedef struct session_info
13 int child_pid
; // or 0
16 char user_name
[USER_NAME_LEN
];
17 char game
[GAME_NAME_LEN
];
18 time_t last_activity
; // to display idle time
20 int term_wid
, term_hgt
; // terminal size
22 int pty_master
; // forked processes should close this
24 int observer_count
; // prohibit observing if -1
25 int *observers
; // array of sockets
27 pthread_mutex_t mutex
; // used to lock one session only
29 // for the current game, not for the whole session
32 time_t start_time
; // when the game was started
33 int bytes_in
, bytes_out
; // not including observers
36 struct session_info
*prev
, *next
;
40 session_info
* add_session (int sock
);
41 // remove session from the list, socket and master_pty are not closed
42 // socket is removed from observers of all other sessions
43 void remove_session (session_info
*sess
);
45 // check if user is already logged in
46 int user_is_connected (int id
);
48 int add_observer (int n
, int sock
);
49 void stop_observing (session_info
*sess
);
51 // send SIGTERM to all running games
52 void terminate_games (void);
54 // NB! not protected by mutex
55 void close_sessions (void);
56 // NB! not protected by mutex
57 void release_sessions (void);