-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler_funcs3.c
67 lines (58 loc) · 1.46 KB
/
handler_funcs3.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 "monty.h"
#include "lists.h"
/**
* rotl_handler - handles the rotl instruction
* @stack: double pointer to the stack to push to
* @line_number: number of the line in the file
*/
void rotl_handler(stack_t **stack, unsigned int line_number)
{
stack_t *temp = *stack;
int num = 0;
(void)line_number;
if (*stack == NULL)
return;
temp = get_dnodeint_at_index(*stack, 0);
num = temp->n;
delete_dnodeint_at_index(stack, 0);
add_dnodeint_end(stack, num);
}
/**
* rotr_handler - handles the rotr instruction
* @stack: double pointer to the stack to push to
* @line_number: number of the line in the file
*/
void rotr_handler(stack_t **stack, unsigned int line_number)
{
stack_t *temp = *stack;
int num = 0, len = dlistint_len(*stack);
(void)line_number;
if (*stack == NULL)
return;
temp = get_dnodeint_at_index(*stack, len - 1);
num = temp->n;
delete_dnodeint_at_index(stack, len - 1);
add_dnodeint(stack, num);
}
/**
* stack_handler - handles the stack instruction
* @stack: double pointer to the stack to push to
* @line_number: number of the line in the file
*/
void stack_handler(stack_t **stack, unsigned int line_number)
{
(void)stack;
(void)line_number;
data.qflag = 0;
}
/**
* queue_handler - handles the queue instruction
* @stack: double pointer to the stack to push to
* @line_number: number of the line in the file
*/
void queue_handler(stack_t **stack, unsigned int line_number)
{
(void)stack;
(void)line_number;
data.qflag = 1;
}