-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror_utils.c
More file actions
61 lines (51 loc) · 1.09 KB
/
error_utils.c
File metadata and controls
61 lines (51 loc) · 1.09 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
59
60
61
#include "monty.h"
/**
* u_err - handle usage error message
* Return: FAILURE
*/
void u_err(void)
{
fprintf(stderr, "USAGE: monty file\n");
exit(EXIT_FAILURE);
}
/**
*o_err - handle open file error message
*@file: file
* Return: FAILURE
*/
void o_err(char *file)
{
fprintf(stderr, "Error: Can't open file %s\n", file);
exit(EXIT_FAILURE);
}
/**
* p_err - handles a push error
* @file: file desciptor
* @line: buffer
* @head: head stack or queue
* @line_num: line number of the command
*/
void p_err(FILE *file, char *line, stack_t *head, int line_num)
{
fprintf(stderr, "L%u: usage: push integer\n", line_num);
fclose(file);
free(line);
free_stack(head);
exit(EXIT_FAILURE);
}
/**
* inst_err - Handle error for unknown instructions
* @file: file descriptor
* @line: buffer
* @head: head stack or queue
* @line_num: line number of the command
* @val: value
*/
void inst_err(FILE *file, char *line, stack_t *head, char *val, int line_num)
{
fprintf(stderr, "L%u: unknown instruction %s\n", line_num, val);
fclose(file);
free(line);
free_stack(head);
exit(EXIT_FAILURE);
}