int main (int argc, char *argv[]) { int index; set_program_name (argv[0]); iu_argp_init ("talk", program_authors); argp_parse (&argp, argc, argv, 0, &index, NULL); argc -= index; argv += index; if (argc == 0) { printf ("Usage: talk user [ttyname]\n"); exit (-1); } if (!isatty (0)) { printf ("Standard input must be a tty, not a pipe or a file\n"); exit (-1); } get_names (argc, argv); init_display (); open_ctl (); open_sockt (); start_msgs (); if (!check_local ()) invite_remote (); end_msgs (); set_edit_chars (); talk (); }
int main(int argc, char *argv[]) { if (pledge("stdio rpath inet dns getpw tty", NULL) == -1) err(1, "pledge"); get_names(argc, argv); init_display(); open_ctl(); open_sockt(); start_msgs(); if (!check_local()) invite_remote(); end_msgs(); set_edit_chars(); if (his_machine_addr.s_addr == my_machine_addr.s_addr) { if (pledge("stdio tty", NULL) == -1) err(1, "pledge"); } else { if (pledge("stdio inet tty", NULL) == -1) err(1, "pledge"); } talk(); return (0); }
int invite_remote (void) { int new_sockt; struct itimerval itimer; CTL_RESPONSE response; itimer.it_value.tv_sec = RING_WAIT; itimer.it_value.tv_usec = 0; itimer.it_interval = itimer.it_value; if (listen (sockt, 5) != 0) p_error ("Error on attempt to listen for caller"); msg.addr.sa_family = htons (my_addr.sin_family); memcpy (msg.addr.sa_data, ((struct sockaddr *) &my_addr)->sa_data, sizeof ((struct sockaddr *) & my_addr)->sa_data); msg.id_num = htonl (-1); /* an impossible id_num */ invitation_waiting = 1; announce_invite (); /* * Shut off the automatic messages for a while, * so we can use the interupt timer to resend the invitation */ end_msgs (); setitimer (ITIMER_REAL, &itimer, (struct itimerval *) 0); message ("Waiting for your party to respond"); signal (SIGALRM, re_invite); setjmp (invitebuf); while ((new_sockt = accept (sockt, 0, 0)) < 0) { if (errno == EINTR) continue; p_error ("Unable to connect with your party"); } close (sockt); sockt = new_sockt; /* * Have the daemons delete the invitations now that we * have connected. */ current_state = "Waiting for your party to respond"; start_msgs (); msg.id_num = htonl (local_id); ctl_transact (my_machine_addr, msg, DELETE, &response); msg.id_num = htonl (remote_id); ctl_transact (his_machine_addr, msg, DELETE, &response); invitation_waiting = 0; return 0; }
static int load_module(void) { int res; spots = table_new(cmpstr, hashmurmur2, kfree, vfree); load_config(); if (msgs_init(&vxo_msgs, "vxo_msgs", mod_info->self) == -1) return MODULE_LOAD_FAILURE; if (start_msgs(vxo_msgs) == -1) return MODULE_LOAD_FAILURE; if ((res = msgs_hook_name(inmsg, vxo_exec, vxo_msgs)) < 0) { if (res == -2) xcb_log(XCB_LOG_WARNING, "Queue '%s' not found", inmsg); return MODULE_LOAD_FAILURE; } return register_application(app, vxo_exec, desc, fmt, mod_info->self); }
int main(int argc, char **argv) { (void) setlocale(LC_CTYPE, ""); get_names(argc, argv); check_writeable(); init_display(); open_ctl(); open_sockt(); start_msgs(); if (!check_local()) invite_remote(); end_msgs(); set_edit_chars(); talk(); return 0; }
static int load_module(void) { int res; spots = table_new(cmpstr, hashmurmur2, kfree, NULL); optns = table_new(cmpstr, hashmurmur2, kfree, vfree); expiries = table_new(cmpstr, hashmurmur2, NULL, NULL); contracts = table_new(cmpstr, hashmurmur2, kfree, vfree); load_config(); if (msgs_init(&impvbaw_msgs, "impvbaw_msgs", mod_info->self) == -1) return MODULE_LOAD_FAILURE; if (start_msgs(impvbaw_msgs) == -1) return MODULE_LOAD_FAILURE; if (msgs_hook(impvbaw_msgs, mm_impvbaw_exec, NULL) == -1) return MODULE_LOAD_FAILURE; if (msgs_hook(&default_msgs, impvbaw_exec, impvbaw_msgs) == -1) return MODULE_LOAD_FAILURE; res = register_application(app, impvbaw_exec, desc, fmt, mod_info->self); res |= register_application(app2, mm_impvbaw_exec, desc2, fmt2, mod_info->self); return res; }