-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_functions_2.c
68 lines (62 loc) · 1.69 KB
/
print_functions_2.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "shell.h"
/**
* error_output - Prints the same error output as sh (/bin/sh)
* @prog_name: Program name
* @argv_tkn: Null-terminated array of command and parameters
* @error_msg: The error message string
* @line_no: Number of lines processed
*/
void error_output(char *prog_name, char **argv_tkn,
char *error_msg, int line_no)
{
e_cust_puts(prog_name);
e_cust_puts(": ");
print_numbers(line_no, STDERR_FILENO);
e_cust_puts(": ");
e_cust_puts(argv_tkn[0]);
e_cust_puts(": ");
e_cust_puts(error_msg);
e_put_char('\n');
}
/**
* exit_error_output - Prints the same error output as sh (/bin/sh) for "exit"
* @prog_name: Program name
* @argv_tkn: Null-terminated array of command and parameters
* @error_msg: The error message string
* @line_no: Number of lines processed
*/
void exit_error_output(char *prog_name, char **argv_tkn,
char *error_msg, int line_no)
{
e_cust_puts(prog_name);
e_cust_puts(": ");
print_numbers(line_no, STDERR_FILENO);
e_cust_puts(": ");
e_cust_puts(argv_tkn[0]);
e_cust_puts(": ");
e_cust_puts(error_msg);
e_cust_puts(": ");
e_cust_puts(argv_tkn[1]);
e_put_char('\n');
}
/**
* cd_error_output - Prints the same error output as sh (/bin/sh) for "exit"
* @prog_name: Program name
* @argv_tkn: Null-terminated array of command and parameters
* @error_msg: The error message string
* @line_no: Number of lines processed
*/
void cd_error_output(char *prog_name, char **argv_tkn,
char *error_msg, int line_no)
{
e_cust_puts(prog_name);
e_cust_puts(": ");
print_numbers(line_no, STDERR_FILENO);
e_cust_puts(": ");
e_cust_puts(argv_tkn[0]);
e_cust_puts(": ");
e_cust_puts(error_msg);
e_put_char(' ');
e_cust_puts(argv_tkn[1]);
e_put_char('\n');
}