+void
+serial_close (struct serial *scb)
+{
+ do_serial_close (scb, 1);
+}
+
+void
+serial_un_fdopen (struct serial *scb)
+{
+ do_serial_close (scb, 0);
+}
+
+int
+serial_readchar (struct serial *scb, int timeout)
+{
+ int ch;
+
+ /* FIXME: cagney/1999-10-11: Don't enable this check until the ASYNC
+ code is finished. */
+ if (0 && serial_is_async_p (scb) && timeout < 0)
+ internal_error (__FILE__, __LINE__,
+ _("serial_readchar: blocking read in async mode"));
+
+ ch = scb->ops->readchar (scb, timeout);
+ if (serial_logfp != NULL)
+ {
+ serial_logchar (serial_logfp, 'r', ch, timeout);
+
+ /* Make sure that the log file is as up-to-date as possible,
+ in case we are getting ready to dump core or something. */
+ gdb_flush (serial_logfp);
+ }
+ if (serial_debug_p (scb))
+ {
+ fprintf_unfiltered (gdb_stdlog, "[");
+ serial_logchar (gdb_stdlog, 'r', ch, timeout);
+ fprintf_unfiltered (gdb_stdlog, "]");
+ gdb_flush (gdb_stdlog);
+ }
+
+ return (ch);
+}
+
+int
+serial_write (struct serial *scb, const char *str, int len)
+{
+ if (serial_logfp != NULL)
+ {
+ int count;
+
+ for (count = 0; count < len; count++)
+ serial_logchar (serial_logfp, 'w', str[count] & 0xff, 0);
+
+ /* Make sure that the log file is as up-to-date as possible,
+ in case we are getting ready to dump core or something. */
+ gdb_flush (serial_logfp);
+ }
+ if (serial_debug_p (scb))
+ {
+ int count;
+
+ for (count = 0; count < len; count++)
+ {
+ fprintf_unfiltered (gdb_stdlog, "[");
+ serial_logchar (gdb_stdlog, 'w', str[count] & 0xff, 0);
+ fprintf_unfiltered (gdb_stdlog, "]");
+ }
+ gdb_flush (gdb_stdlog);
+ }
+
+ return (scb->ops->write (scb, str, len));
+}
+
+void
+serial_printf (struct serial *desc, const char *format,...)
+{
+ va_list args;
+ char *buf;
+ va_start (args, format);
+
+ buf = xstrvprintf (format, args);
+ serial_write (desc, buf, strlen (buf));
+
+ xfree (buf);
+ va_end (args);
+}
+
+int
+serial_drain_output (struct serial *scb)
+{
+ return scb->ops->drain_output (scb);
+}
+
+int
+serial_flush_output (struct serial *scb)
+{
+ return scb->ops->flush_output (scb);
+}
+
+int
+serial_flush_input (struct serial *scb)
+{
+ return scb->ops->flush_input (scb);
+}
+
+int
+serial_send_break (struct serial *scb)
+{
+ if (serial_logfp != NULL)
+ serial_logchar (serial_logfp, 'w', SERIAL_BREAK, 0);
+
+ return (scb->ops->send_break (scb));
+}
+
+void
+serial_raw (struct serial *scb)
+{
+ scb->ops->go_raw (scb);
+}
+
+serial_ttystate
+serial_get_tty_state (struct serial *scb)
+{
+ return scb->ops->get_tty_state (scb);
+}
+
+int
+serial_set_tty_state (struct serial *scb, serial_ttystate ttystate)
+{
+ return scb->ops->set_tty_state (scb, ttystate);
+}
+
+void
+serial_print_tty_state (struct serial *scb,
+ serial_ttystate ttystate,
+ struct ui_file *stream)
+{
+ scb->ops->print_tty_state (scb, ttystate, stream);
+}
+
+int
+serial_noflush_set_tty_state (struct serial *scb,
+ serial_ttystate new_ttystate,
+ serial_ttystate old_ttystate)
+{
+ return scb->ops->noflush_set_tty_state (scb, new_ttystate, old_ttystate);
+}
+
+int
+serial_setbaudrate (struct serial *scb, int rate)
+{
+ return scb->ops->setbaudrate (scb, rate);
+}
+
+int
+serial_setstopbits (struct serial *scb, int num)
+{
+ return scb->ops->setstopbits (scb, num);
+}
+
+int
+serial_can_async_p (struct serial *scb)
+{
+ return (scb->ops->async != NULL);
+}
+
+int
+serial_is_async_p (struct serial *scb)
+{
+ return (scb->ops->async != NULL) && (scb->async_handler != NULL);
+}
+
+void
+serial_async (struct serial *scb,
+ serial_event_ftype *handler,
+ void *context)
+{
+ int changed = ((scb->async_handler == NULL) != (handler == NULL));
+
+ scb->async_handler = handler;
+ scb->async_context = context;
+ /* Only change mode if there is a need. */
+ if (changed)
+ scb->ops->async (scb, handler != NULL);
+}
+
+int
+deprecated_serial_fd (struct serial *scb)
+{
+ /* FIXME: should this output a warning that deprecated code is being
+ called? */
+ if (scb->fd < 0)
+ {
+ internal_error (__FILE__, __LINE__,
+ _("serial: FD not valid"));
+ }
+ return scb->fd; /* sigh */
+}
+
+void
+serial_debug (struct serial *scb, int debug_p)
+{
+ scb->debug_p = debug_p;
+}
+
+int
+serial_debug_p (struct serial *scb)
+{
+ return scb->debug_p || global_serial_debug_p;
+}
+
+#ifdef USE_WIN32API
+void
+serial_wait_handle (struct serial *scb, HANDLE *read, HANDLE *except)
+{
+ if (scb->ops->wait_handle)
+ scb->ops->wait_handle (scb, read, except);
+ else
+ {
+ *read = (HANDLE) _get_osfhandle (scb->fd);
+ *except = NULL;
+ }
+}
+
+void
+serial_done_wait_handle (struct serial *scb)
+{
+ if (scb->ops->done_wait_handle)
+ scb->ops->done_wait_handle (scb);
+}
+#endif
+