sw_sel * sel_copy (sw_sel * sel) { sw_sel * nsel; nsel = sel_new (sel->sel_start, sel->sel_end); return nsel; }
GList * sels_add_selection_1 (GList * sels, sw_framecount_t start, sw_framecount_t end) { sw_sel * sel; sel = sel_new (start, end); return sels_add_selection (sels, sel); }
sw_sel * sounddata_add_selection_1 (sw_sounddata * sounddata, sw_framecount_t start, sw_framecount_t end) { sw_sel * sel; sel = sel_new (start, end); sounddata_add_selection(sounddata, sel); return sel; }
int main(int argc, char **argv) { int ret; int shell_started = 0; char *directory = NULL; char **program_args = NULL; if (argc > 1 && argv[1][0]) { directory = argv[1]; argc--, argv++; } if (argc > 1) { program_args = argv + 1; } pty_preinit(); asel = sel_new(NULL); netr = sel_rfd_add(asel, 0, net_readdata, net_readerr, NULL); netw = sel_wfd_add(asel, 1, net_written, net_writeerr, NULL); ptyr = sel_rfd_add(asel, -1, pty_readdata, pty_readerr, NULL); ptyw = sel_wfd_add(asel, -1, pty_written, pty_writeerr, NULL); telnet = telnet_new(netw, ptyw); if (pipe(signalpipe) < 0) { perror("pipe"); return 1; } sigr = sel_rfd_add(asel, signalpipe[0], sig_readdata, sig_readerr, NULL); signal(SIGCHLD, sigchld); do { struct shell_data shdata; ret = sel_iterate(asel, -1); if (!shell_started && telnet_shell_ok(telnet, &shdata)) { ptyfd = run_program_in_pty(&shdata, directory, program_args); sel_rfd_setfd(ptyr, ptyfd); sel_wfd_setfd(ptyw, ptyfd); shell_started = 1; } } while (ret == 0); return 0; }
/* * sels_invert (sels, nr_frames) * * inverts sels in place */ GList * sels_invert (GList * sels, sw_framecount_t nr_frames) { GList * gl; GList * osels; sw_sel * osel, * sel; if (!sels) { g_list_free (sels); sel = sel_new (0, nr_frames); sels = NULL; sels = g_list_append (sels, sel); return sels; } gl = osels = sels; sels = NULL; sel = osel = (sw_sel *)gl->data; if (osel->sel_start > 0) { sels = sels_add_selection_1 (sels, 0, osel->sel_start - 1); } gl = gl->next; for (; gl; gl = gl->next) { sel = (sw_sel *)gl->data; sels = sels_add_selection_1 (sels, osel->sel_end, sel->sel_start - 1); osel = sel; } if (sel->sel_end != nr_frames) { sels = sels_add_selection_1 (sels, sel->sel_end, nr_frames); } g_list_free (osels); return sels; }