| Line |
Branch |
Exec |
Source |
| 1 |
|
|
/* |
| 2 |
|
|
** EPITECH PROJECT, 2024 |
| 3 |
|
|
** zappy |
| 4 |
|
|
** File description: |
| 5 |
|
|
** teams.c |
| 6 |
|
|
*/ |
| 7 |
|
|
|
| 8 |
|
|
#include "server.h" |
| 9 |
|
|
|
| 10 |
|
✗ |
team_t *get_team_by_name(struct teams_tailq *teams, const char *team_name) |
| 11 |
|
|
{ |
| 12 |
|
|
team_list_t *item_t; |
| 13 |
|
|
|
| 14 |
|
✗ |
if (team_name == NULL) |
| 15 |
|
|
return NULL; |
| 16 |
|
✗ |
TAILQ_FOREACH(item_t, teams, entries) { |
| 17 |
|
✗ |
if (strcmp(item_t->team->name, team_name) == 0) |
| 18 |
|
|
return item_t->team; |
| 19 |
|
|
} |
| 20 |
|
|
return NULL; |
| 21 |
|
|
} |
| 22 |
|
|
|
| 23 |
|
4 |
size_t team_nb_slots(struct teams_tailq *teams, const char *team_name) |
| 24 |
|
|
{ |
| 25 |
|
|
size_t counter = 0; |
| 26 |
|
|
bool team_found = false; |
| 27 |
|
|
|
| 28 |
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 |
if (team_name == NULL) |
| 29 |
|
|
return 0; |
| 30 |
|
4 |
for (team_list_t *item_t = TAILQ_FIRST(teams); |
| 31 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 |
item_t; |
| 32 |
|
✗ |
item_t = TAILQ_NEXT(item_t, entries)) { |
| 33 |
|
✗ |
if (strcmp(item_t->team->name, team_name) == 0) |
| 34 |
|
|
team_found = true; |
| 35 |
|
✗ |
if (team_found == false) |
| 36 |
|
|
continue; |
| 37 |
|
✗ |
for (eggs_list_t *item_e = TAILQ_FIRST(&item_t->team->eggs); |
| 38 |
|
✗ |
item_e; |
| 39 |
|
✗ |
item_e = TAILQ_NEXT(item_e, entries)) |
| 40 |
|
✗ |
counter++; |
| 41 |
|
|
break; |
| 42 |
|
|
} |
| 43 |
|
|
return counter; |
| 44 |
|
|
} |
| 45 |
|
|
|