/* writeln string */ void writeln_str(char *s) { if (has_network_socket()) { MESSAGE msg; msg.msg_type = MSG_GRAPH; msg.param.pword[1] = GraphRes; msg.param.pword[2] = GRAPH_WRITE; strcpy(msg.param.pstr, s); send_to_graph(&msg); strcpy(msg.param.pstr, "\n"); send_to_graph(&msg); } else { printf("%s\n", s); } }
static void process(ID3ASFilterContext *context, AVFrame *frame, AVRational timebase) { codec_t *this = context->priv_data; int ret; do_init(this, frame, timebase); if (av_buffersrc_write_frame(this->buffersrc_ctx, frame) < 0) { ERROR("Error while feeding the filtergraph\n"); exit(-1); } while (1) { ret = av_buffersink_get_frame(this->buffersink_ctx, this->output_frame); if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) break; if (ret < 0) { ERROR("Error from get_frame"); exit(-1); } send_to_graph(context, this->output_frame, this->output_timebase); av_frame_unref(this->output_frame); } }
/* read string */ void read_str(char *s) { char ss[255]; size_t limit = 80; MESSAGE msg; int st; if (has_network_socket()) { msg.msg_type = MSG_GRAPH; msg.param.pword[1] = GraphRes; msg.param.pword[0] = GRAPH_READSTR; send_to_graph(&msg); while (TRUE) { st = receive_message(network_socket, &msg); if (st == 0) { if ((msg.msg_type == MSG_GRAPH) && (msg.param.pword[0] == GRAPH_READSTR_RESPONSE)) { strcpy(ss, msg.param.pstr); break; } } } strcpy(s, ss); } else { char *empty_str_pointer =NULL; _getline(empty_str_pointer, &limit , stdin); strcpy(s,empty_str_pointer); } }
/* read char */ char read_char() { char ch; MESSAGE msg; if (has_network_socket()) { int st; msg.msg_type = MSG_GRAPH; msg.param.pword[1] = GraphRes; msg.param.pword[0] = GRAPH_READCHAR; send_to_graph(&msg); while (TRUE) { st = receive_message(network_socket, &msg); if (st == 0) { if ((msg.msg_type == MSG_GRAPH) && (msg.param.pword[0] == GRAPH_READCHAR_RESPONSE)) { ch = msg.param.pchar; break; } } } return (ch); } else { ch = getchar(); return (ch); } }
/* write char */ void write_char(char a) { if (has_network_socket()) { MESSAGE msg; msg.msg_type = MSG_GRAPH; msg.param.pword[1] = GraphRes; msg.param.pword[0] = GRAPH_PUTCHAR; msg.param.pchar = a; send_to_graph(&msg); } else { printf("%c", a); } }
/* read line */ void read_line() { MESSAGE msg; int st; if (has_network_socket()) { msg.msg_type = MSG_GRAPH; msg.param.pword[1] = GraphRes; msg.param.pword[0] = GRAPH_READLN; send_to_graph(&msg); while (TRUE) { st = receive_message(network_socket, &msg); if (st == 0) if ((msg.msg_type == MSG_GRAPH) && (msg.param.pword[0] == GRAPH_READLN_RESPONSE)) break; } } else { size_t limit = 255; char s[limit]; _getline((char**)&s, &limit , stdin); } }
int clt_incantation_7(t_env *e, int cs) { int x; int y; char msg[BUF_SIZE]; x = e->fds[cs].player.pos_x; y = e->fds[cs].player.pos_y; if (e->data.map[y][x].linemate >= 2 && e->data.map[y][x].deraumere >= 2 && e->data.map[y][x].sibur >= 2 && e->data.map[y][x].mendiane >= 2 && e->data.map[y][x].phiras >= 2 && e->data.map[y][x].thystame >= 1 && nb_joueur(e, x, y) >= 6) { ft_bzero(msg, BUF_SIZE); sprintf(msg, "ppos\nseg %s\n", e->fds[cs].player.team); send_to_graph(e, msg); return (1); } return (0); }