-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmsg_txt.c
57 lines (53 loc) · 2 KB
/
msg_txt.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* msg_values.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: astein <astein@student.42lisboa.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/06 04:41:41 by astein #+# #+# */
/* Updated: 2023/08/08 19:33:10 by astein ### ########.fr */
/* */
/* ************************************************************************** */
#include "philo.h"
static const char *get_msg_with_clr(int msg_id)
{
if (msg_id == MSG_FORK_TAKE)
return ("\033[0;31mhas taken a fork\033[0m");
if (msg_id == MSG_FORK_DROP)
return ("\033[0;32mhas dropped a fork\033[0m");
if (msg_id == MSG_EAT)
return ("\033[0;33mis eating\033[0m");
if (msg_id == MSG_EAT_END)
return ("\033[0;34mhas finished eating\033[0m");
if (msg_id == MSG_SLEEP)
return ("\033[0;36mis sleeping\033[0m");
if (msg_id == MSG_THINK)
return ("\033[0;35mis thinking\033[0m");
if (msg_id == MSG_DIED)
return ("\033[0;31mdied\033[0m");
if (msg_id == MSG_ALL_EAT)
return ("\033[0;32mall philos have eaten enough - success\033[0m");
return ("");
}
static const char *get_msg_without_clr(int msg_id)
{
if (msg_id == MSG_FORK_TAKE)
return ("has taken a fork");
if (msg_id == MSG_EAT)
return ("is eating");
if (msg_id == MSG_SLEEP)
return ("is sleeping");
if (msg_id == MSG_THINK)
return ("is thinking");
if (msg_id == MSG_DIED)
return ("died");
return ("");
}
const char *get_msg(int msg_id)
{
if (PUT_MORE_INFOS)
return (get_msg_with_clr(msg_id));
else
return (get_msg_without_clr(msg_id));
}