-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUI.c
46 lines (43 loc) · 1 KB
/
UI.c
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
#include "header.h"
/*
Function which initializes
the values of paths and
names for the prompt.
*/
extern char *shell_path, *prev_dir;
extern size_t buffer_size;
extern int output_file_no;
extern int input_file_no;
extern char *hostname, *systemname;
extern int hostname_size;
extern int systemname_size;
extern int path_length;
extern int parent_pid;
void UI(int args, char *argv[])
{
if(args == 1)
{
output_file_no = 1;
input_file_no = 0;
hostname = (char *) malloc(sizeof(char) * hostname_size);
if(getlogin_r(hostname, 100) == -1)
{
perror("Error:");
exit(1);
}
systemname = (char *) malloc(sizeof(char) * systemname_size);
if(gethostname(systemname, 100) == -1)
{
perror("gethostname:");
exit(1);
}
shell_path = PWD();
prev_dir = PWD();
parent_pid = getpid();
}
else
{
printf("Illegal number of arguments");
exit(1);
}
}