void send_file(t_server *serv, t_user *user, char *cmd) { struct stat st; t_user *tomsg; char *nick; char *file; nick = split_string(cmd, ' ', 1); file = split_string(cmd, ' ', 2); if (nick != NULL && file != NULL) { stat(file, &st); if (open(file, O_RDONLY) != -1 && S_ISREG(st.st_mode)) { tomsg = get_user_by_nick(serv->users, nick); if (tomsg != NULL) receiving(serv, user, tomsg, file); else swrite(user->fd, "401 ERR_NOSUCHNICK :No such nick\r\n"); } else swrite(user->fd, "424 ERR_FILERROR :File error\r\n"); free(nick); free(file); } else swrite(user->fd, "461 ERR_NEEDMOREPARAMS :Not enough parameters\r\n"); }
void main(void) { net_init(); init_app(); ipsum_len = strlen(lorem_ipsum); #if defined(CONFIG_NETWORKING_WITH_BT) if (bt_enable(NULL)) { PRINT("Bluetooth init failed\n"); return; } ipss_init(); ipss_advertise(); #endif if (!get_context(&unicast, &multicast)) { PRINT("%s: Cannot get network context\n", __func__); return; } #if defined(CONFIG_MICROKERNEL) receiving(); #else task_fiber_start(&stack_receiving[0], STACKSIZE, (nano_fiber_entry_t)receiving, 0, 0, 7, 0); #endif }
static void dispatch(void) { while(noderoot) { MsgNode *node = noderoot; receiving(node->from, node->to, node->msg); free(node->from); free(node->to); free(node->msg); noderoot = node->next; free(node); if (noderoot == NULL) nodeend = &noderoot; } }
void run(std::istream& streamOfMessagesToSend, std::ostream& streamForReceivedMessages) { try { std::thread sending(std::bind(&messenger::Messenger<Message>::sendMessages, this, std::ref(streamOfMessagesToSend))); std::thread receiving(std::bind(&messenger::Messenger<Message>::receiveMessages, this, std::ref(streamForReceivedMessages))); sending.join(); receiving.join(); } catch(const std::exception& e) { std::cerr << e.what() << std::endl; } }
void main(void) { net_init(); init_server(); ipsum_len = strlen(lorem_ipsum); if (!get_context(&unicast, &multicast)) { PRINT("%s: Cannot get network context\n", __func__); return; } #ifdef CONFIG_MICROKERNEL receiving(); #else task_fiber_start(&stack_receiving[0], STACKSIZE, (nano_fiber_entry_t)receiving, 0, 0, 7, 0); #endif }