summaryrefslogtreecommitdiffstats
path: root/hw1/connection.h
blob: 9a4cfe7c085cd7484819baee3dd7dea4378bbafa (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
30
31
32
33
34
#ifndef RAS_CONNECTION_H
#define RAS_CONNECTION_H

#include <stdio.h>
#include <sys/types.h>

typedef enum {
    RAS_CONN_PERM_RESTRICTED,
    RAS_CONN_PERM_REGULAR,
    RAS_CONN_PERM_ADMIN
} RasConnPerm;

#define RAS_CONN(x)  ((RasConn*)(x))

typedef struct {
    RasConnPerm perm;
    int domain;
    int id;
    int fd;
    int fd_is_set  : 1;
    pid_t pid;
    char* name;
    FILE* log;
    char* log_file;
    int log_fd;
    int log_is_set : 1;
} RasConn;

int  ras_conn_init (RasConn* conn, RasConnPerm perm, int domain,
        const char* name, const char* log_file, int* id);
void ras_conn_destroy (RasConn* conn);
void ras_conn_log (RasConn* conn, const char* format, ...);

#endif /* RAS_CONNECTION_H */