-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.cpp
More file actions
58 lines (57 loc) · 1.14 KB
/
Copy pathinit.cpp
File metadata and controls
58 lines (57 loc) · 1.14 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include "./def.h"
#include "./externs.h"
#include "./init.h"
void SIGINTHandler(int sig)
{
char pathbuf[kPathBufSize];
getcwd(pathbuf, sizeof(pathbuf));
printf("\e[1;32m[ShirleyShell]:\e[1;34m%s$ \033[0m", pathbuf);
fflush(stdout);
}
void SetUp()
{
signal(SIGINT, SIGINTHandler);
signal(SIGQUIT, SIGINTHandler);
}
extern void InitCmd(Command* cmd)
{
int i = 0;
while(cmd->args[i] != NULL)
{
cmd->args[i] = NULL;
i++;
}
cmd->append = false;
cmd->next = NULL;
cmd->infd = 0;
cmd->outfd = 1;
}
void init()
{
int i, j;
SIGINTHandler(0);
fflush(stdout);
memset(cmdline, 0, sizeof(cmdline));
memset(argsstore, 0, sizeof(argsstore));
memset(infile, 0, sizeof(infile));
memset(outfile, 0, sizeof(outfile));
lineptr = cmdline;
argsptr = argsstore;
append = -1;
isbackgnd = false;
parsedcmd = 0;
for(i = 0; i < kCmdSize; i++)
{
InitCmd(&cmd[i]);
}
curcmd = NULL;
cmdfree = NULL;
}
void PrintWelcome()
{
printf("\nWelcome to ShirleyShell~\n");
}