summaryrefslogtreecommitdiffstats
path: root/hw1/shell.h
blob: 5e5142c917fc935d9260003b22860a9b6e0af385 (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
35
36
37
38
39
40
41
42
#ifndef RAS_SHELL_H
#define RAS_SHELL_H

#include "basic-list.h"

#include <stdint.h>
#include <sys/types.h>
#include <termios.h>
#include <unistd.h>

typedef struct {
    char*    name;             /* This is argv[0]. Do not modify or free it. */
    uint64_t count;
    List*    saved_list;       /* A list of RasShellSaved */
    char*    saved_tmpdir;
    int      last_rval;
    pid_t    pid;
    pid_t    pgid;
    int      attr_login  : 1;  /* login shell */
    int      attr_rshell : 1;  /* restricted shell */
    int      attr_debug  : 1;  /* debug message */
    int      attr_isterm : 1;  /* shell is run in a terminal */
    char*    user_name;
    char     user_ps;
    int      req_exit    : 1;  /* request for exit */
    int      req_exit_status;  /* requested exit status */
    int      term_fd;          /* shell terminal fd */
    struct termios tmode;      /* shell terminal mode */
} RasShell;

typedef struct {
    uint64_t from;
    uint64_t to;
    char*    cmdorg;
} RasShellSaved;

typedef int (*RasShellFunc) (int argc, char* argv[], RasShell* shell);
typedef char* (*RasShellRead) (void* data);

int ras_shell_main (int argc, char* argv[]);

#endif /* RAS_SHELL_H */