int tty_read(int16 minor, int16 rawflag) { int nread; nread = 0; while (nread < udata.u_count) { for (;;) { di(); if (remq(&ttyinq, udata.u_base)) break; psleep(&ttyinq); /* XXX - messy */ if (udata.u_cursig || udata.u_ptab->p_pending) { udata.u_error = EINTR; return (-1); } } ei(); if ((nread++ == 0) && (*udata.u_base == '\004')) /* ^D */ return (0); if (*udata.u_base == '\n') break; ++udata.u_base; } return (nread); }
int platform_input_read(uint8_t *slot) { uint8_t r, k; if (remq(&kqueue, &r)) { remq(&kqueue, &k); *slot++ = KEYPRESS_CODE | r; *slot = k; return 2; } ay_reg = 0x0E; if (ay_js(slot)) return 2; if (ay_js2(slot)) return 2; return 0; }
int tty_read(uint8_t minor, uint8_t rawflag, uint8_t flag) { uint16_t nread; unsigned char c; struct s_queue *q; struct termios *t; rawflag; flag; // shut up compiler /* Minor == 0 means that it is the controlling tty of the process */ if (!minor) minor = udata.u_ptab->p_tty; if (!udata.u_ptab->p_tty) udata.u_ptab->p_tty = minor; q = &ttyinq[minor]; t = &ttydata[minor]; nread = 0; while (nread < udata.u_count) { for (;;) { if (deadflag[minor]) { udata.u_error = ENXIO; return -1; } if (remq(q, &c)) { if (udata.u_sysio) *udata.u_base = c; else uputc(c, udata.u_base); break; } if (psleep_flags(q, flag)) return -1; } ++nread; /* return according to mode */ if (!(t->c_lflag & ICANON)) { if (nread >= t->c_cc[VMIN]) break; } else { if (nread == 1 && (c == t->c_cc[VEOF])) { /* ^D */ nread = 0; break; } if (c == '\n') break; } ++udata.u_base; } wakeup(&q->q_count); return nread; }
void rtp_session_remove_contributing_source(RtpSession *session, uint32_t ssrc) { queue_t *q=&session->contributing_sources; mblk_t *tmp; for (tmp=qbegin(q); !qend(q,tmp); tmp=qnext(q,tmp)){ uint32_t csrc=sdes_chunk_get_ssrc(tmp); if (csrc==ssrc) { remq(q,tmp); break; } } tmp=rtcp_create_simple_bye_packet(ssrc, NULL); rtp_session_rtcp_send(session,tmp); }
int pty_read(uint8_t minor, uint8_t rawflag, uint8_t flag) { struct s_queue q = &ttyinq[minor + PTY_OFFSET + PTY_PAIR]; char c; while (nread < udata.u_count) { if (remq(q, &c)) { if (udata.u_sysio) *udata.u_base = c; else uputc(c, udata.u_base); udata.u_base++; nread++; continue; } if (nread == 0 && psleep_flags(q, flag)) return -1; } return nread; }
int tty_read(uint8_t minor, uint8_t rawflag, uint8_t flag) { usize_t nread; unsigned char c; struct s_queue *q; struct tty *t; used(rawflag); used(flag); /* shut up compiler */ q = &ttyinq[minor]; t = &ttydata[minor]; nread = 0; while (nread < udata.u_count) { for (;;) { if ((t->flag & TTYF_DEAD)&&(!q->q_count)) { udata.u_error = ENXIO; return -1; } jobcontrol_in(minor, t); if (remq(q, &c)) { if (udata.u_sysio) *udata.u_base = c; else uputc(c, udata.u_base); break; } if (!(t->termios.c_lflag & ICANON)) { uint8_t n = t->termios.c_cc[VTIME]; if (n) udata.u_ptab->p_timeout = n + 1; } if (psleep_flags_io(q, flag, &nread)) return nread; /* timer expired */ if (udata.u_ptab->p_timeout == 1) goto out; } ++nread; /* return according to mode */ if (!(t->termios.c_lflag & ICANON)) { if (nread >= t->termios.c_cc[VMIN]) break; } else { if (nread == 1 && (c == t->termios.c_cc[VEOF])) { /* ^D */ nread = 0; break; } if (c == '\n') break; } ++udata.u_base; } out: wakeup(&q->q_count); return nread; }