void _AddTransaction(struct Transaction *t) { if (t == NULL) return; SetTransactionObserver(t, &TransactionManager); put_in_list(&TransactionManager.transactions, t); }
static int set_socket_gui(t_zappy *s, t_node *node, t_type t, int *ret) { t_clientGUI *client; t_node *loop; if (t != GUI) return (1); client = ((t_clientGUI*)node->data); if (client->socket != -1) { if ((*ret) < client->socket) (*ret) = client->socket; if (s->listWrite->length > 0) { loop = s->listWrite->head; while (loop) { put_in_list(client->listWrite, dup_gui_answer(((t_gui_answer*)loop->data))); loop = loop->next; } } do_fd_sets(s, client); } return (0); }
void client_init2(t_env *env, int socket, t_list *list, int num_team) { char *str; env->team[num_team].slot_team--; my_putstr(socket, env->team[num_team].NUM_CLIENT); my_putstr(1, env->team[num_team].NUM_CLIENT); put_in_list(socket, "mort\n", list, env); init_pos(env, socket); env->fd[socket].inventaire.linemate = 0; env->fd[socket].inventaire.deraumere = 0; env->fd[socket].inventaire.sibur = 0; env->fd[socket].inventaire.mendiane = 0; env->fd[socket].inventaire.phiras = 0; env->fd[socket].inventaire.thystame = 0; env->fd[socket].inventaire.food = 10; env->fd[socket].f_read = client_read; env->fd[socket].f_write = client_write; env->fd[socket].type = FD_CLIENT; str = xmalloc(100); sprintf(str, "pnw %d %d %d %d %d %s\n", socket, env->fd[socket].x, env->fd[socket].y, env->fd[socket].sens, env->fd[socket].lvl, env->team_[atoi(env->fd[socket].team->NUM_CLIENT)] ); send_to_all_graph(str, env); free(str); }
int call_plv(t_zappy *server, t_clientIA *client, double tick) { server->currentRessource = client; if (!put_in_list(server->listWrite, create_gui_ans(tograph_plv(server), tick))) return (1); return (0); }
static void *sub_get_bestfit(t_chunk **b_fit, unsigned long total_size, t_chunk **flist, t_chunk **alist) { t_chunk *tmp_sbrk; (*b_fit)->magic = M_ALLOC; if ((*b_fit)->size > total_size + HEADER_SIZE && (tmp_sbrk = sbrk(0)) != (void *)FAIL && (void *)(*b_fit) + total_size <= (void *)tmp_sbrk) { split_chunk(*b_fit, total_size); put_in_list(&flist[MAPSIZE - 1], (*b_fit)->next); (*b_fit)->next = NULL; } put_in_list(&(alist[INDEX((*b_fit)->size)]), *b_fit); return ((t_chunk *)(*b_fit) + 1); }
int key_other(t_link *link, unsigned char buff[5]) { if (buff[0] >= 32 && buff[1] == 0) { link->line = put_in_list(link->line, buff[0]); del_one(); my_show_list(link->line, link); } return (TRUE); }
t_line *convert_str_to_list(char *str) { t_line *tmp; int i; i = 0; tmp = NULL; str = my_epur_str(str); while (str[i] != '\0') tmp = put_in_list(tmp, str[i++]); return (tmp); }
bool set_player_addstone(t_player *player, e_stone type, uint nb) { t_stone *stone; if ((stone = get_data_as_arg(player->stones, match_stone, &type))) stone->nb += nb; else if (!(stone = new_stone(type, nb)) || !put_in_list(&(player->stones), stone)) return (false); return (true); }
t_env *get_env(char **env) { int i; t_env *root; i = 0; if ((root = get_root()) == NULL) return (NULL); while (env[i]) if (put_in_list(root, env[i++]) == NULL) return (NULL); return (root); }
t_list * list_from_table(char ** table) { t_list * list; ssize_t i; list = NULL; i = 0; while (table && table[i]) { if (!(put_in_list(&list, table[i]))) return (NULL); ++i; } return (list); }
int set_environ_completion(char *cmd, t_list **st_list) { char buf[MAX_SET_SIZE]; t_env *tmp; tmp = gl_st.st_set; while (tmp) { get_value_before_equal(tmp->var, buf); if (!strncmp(cmd, buf, strlen(cmd))) put_in_list(buf, st_list, 0); tmp = tmp->next; } return (TRUE); }
int call_pie(t_zappy *server, t_clientIA *client, double tick, int cond) { t_incantation_ended *ans; if (!(ans = malloc(sizeof(*ans)))) return (1); ans->ncase = server->map->map[client->y][client->x]; ans->result = cond; server->currentRessource = ans; if (!put_in_list(server->listWrite, create_gui_ans(tograph_pie(server), tick))) return (1); free(ans); return (0); }
static t_egg *new_egg(t_player *player, uint id) { t_egg *egg; if (!player || !(egg = calloc(1, sizeof(*egg)))) return (NULL); egg->id = id; egg->idf = player->id; egg->x = player->x; egg->y = player->y; egg->status = GROWING; egg->father = player; egg->team = get_team_of_player(player); put_in_list(&gserv->egg, egg); return (egg); }
int call_pic(t_zappy *server, t_clientIA *client, double tick) { t_incantation_for_players *ans; if (!(ans = malloc(sizeof(*ans)))) return (1); ans->ncase = server->map->map[client->y][client->x]; ans->listPlayer = ans->ncase->players; ans->incanter = client; server->currentRessource = ans; if (!put_in_list(server->listWrite, create_gui_ans(tograph_pic(server), tick))) return (1); free(ans); return (0); }
int create_var(t_cmd *tmp, t_env *var) { int i; i = 0; while (tmp->word[i] && tmp->word[i] != '=') ++i; if (tmp->word[i]) { tmp->word[i] = '\0'; ++i; } if (put_in_list(var, tmp->word) == NULL || (var->prev->content = ft_strdup(tmp->word + i)) == NULL) return (-1); return (0); }
static void *get_chunk_empty_freelist(unsigned long total_needed_size, t_chunk **flist, t_chunk **alist) { t_chunk *new_elem; unsigned long allocated_size; if (!(new_elem = extend_heap(allocated_size = A_PAGE(total_needed_size + PAD_MUL + 1, get_power(getpagesize()))))) return (NULL); new_elem->size = total_needed_size - HEADER_SIZE; new_elem->magic = M_ALLOC; put_in_list(&alist[INDEX(new_elem->size)], new_elem); if (total_needed_size == allocated_size) return (new_elem + 1); add_remaining(&flist[0], new_elem, total_needed_size); return (new_elem + 1); }
t_egg *set_box_addegg(t_player *player) { t_player *p; t_box *box; t_egg *egg; if (!player || !(box = get_box(player->x, player->y))) return (NULL); if (!player->team || !(p = init_player(player->team))) return (NULL); player->team->max_conn += 1; p->x = player->x; p->y = player->y; if (!(egg = new_egg(player, p->id)) || !put_in_list(&(box->eggs), egg)) return (NULL); egg->himself = p; return (egg); }
t_list * duplicate_list_elem(t_list * list, void * (*duplicate)(void *)) { t_list * newlist; newlist = NULL; if (list) { list->cur = list->begin; while (list->cur) { if (!(put_in_list(&newlist, (duplicate ? duplicate(list->cur->data) : list->cur->data)))) return (NULL); list->cur = list->cur->next; } } return (newlist); }
t_list * sub_list_arg(t_list * list, bool (*function)(void *, void * arg), void * arg) { t_list * sub; sub = NULL; if (list) { list->cur = list->begin; while (list->cur) { if (function(list->cur->data, arg)) if (!(put_in_list(&sub, list->cur->data))) return (NULL); list->cur = list->cur->next; } } return (sub); }
bool parse_name_team(t_zappy *s, int argc, char **argv, int *flags) { int index; t_team *team; (*flags) += FLAGS_N; index = optind - 2; while (++index < argc && argv[index][0] != '-') { if (strlen(argv[index]) < 1) { fprintf(stderr, "Invalid length of team name\n"); return (false); } if (!(team = alloc_team(argv[index]))) return (false); team->nb_slots_max = s->nbClients; if (!(put_in_list(s->listTeam, team))) return (false); } return (true); }
int parse_syscall(t_syscall **sys) { FILE *fd; char *line; size_t size; int i; int ret; size = 256; line = NULL; i = 0; if ((fd = fopen(FILE_SYSCALL, "r")) == NULL) return (FAIL); while (getline(&line, &size, fd) != -1) { if ((ret = put_in_list(line, sys)) == FAIL) return (FAIL); if (ret == LINE_PARSE_ERR) printf("Error parsing line %d\n", i); i++; } fclose(fd); return (SUCCESS); }
os_status hwTimer32PutInList(void **timer) { return put_in_list((hw_timer32_t_ **)timer); }