summaryrefslogtreecommitdiffstats
path: root/hw1/session.h
blob: 566157faafb759b40141f63e2f1e25b69d57e834 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef RAS_SESSION_H
#define RAS_SESSION_H

#include "socktool.h"
#include "connection.h"
#include "server.h"

#include <sys/types.h>

#define RAS_SESSION(x)  ((RasSession*)(x))

typedef struct {
    RasConn   conn;
    RasBuffer buffer;
    pid_t     shell_pid;
    int       shell_stdio;
    int       shell_use_pty : 1;
} RasSession;

int   ras_session_init (RasSession* sesssion, RasServer* server, int fd, int cid);
void  ras_session_destroy (RasSession* session);
char* ras_session_getline (RasSession* session, int* len);
int   ras_session_read_header (RasSession* session);
int   ras_session_start_shell (RasSession* session);

/* Access parent methods */
#define ras_session_log(x, ...) ras_conn_log(RAS_CONN(x), __VA_ARGS__)

#endif /* RAS_SESSION_H */