* terms and conditions of the copyright.
*/
-#define WANT_SYS_IOCTL_H
#include <slirp.h>
-u_int curtime, time_fasttimo, last_slowtimo, detach_time;
-u_int detach_wait = 600000; /* 10 minutes */
+u_int curtime, time_fasttimo, last_slowtimo;
#if 0
int x_port = -1;
}
#endif
-#ifndef HAVE_INET_ATON
-int
-inet_aton(cp, ia)
- const char *cp;
- struct in_addr *ia;
-{
- u_int32_t addr = inet_addr(cp);
- if (addr == 0xffffffff)
- return 0;
- ia->s_addr = addr;
- return 1;
-}
-#endif
-
/*
* Get our IP address and put it in our_addr
*/
void
-getouraddr()
+getouraddr(void)
{
char buff[256];
struct hostent *he = NULL;
our_addr.s_addr = loopback_addr.s_addr;
}
-#if SIZEOF_CHAR_P == 8
-
-struct quehead_32 {
- u_int32_t qh_link;
- u_int32_t qh_rlink;
-};
-
-inline void
-insque_32(a, b)
- void *a;
- void *b;
-{
- register struct quehead_32 *element = (struct quehead_32 *) a;
- register struct quehead_32 *head = (struct quehead_32 *) b;
- element->qh_link = head->qh_link;
- head->qh_link = (u_int32_t)element;
- element->qh_rlink = (u_int32_t)head;
- ((struct quehead_32 *)(element->qh_link))->qh_rlink
- = (u_int32_t)element;
-}
-
-inline void
-remque_32(a)
- void *a;
-{
- register struct quehead_32 *element = (struct quehead_32 *) a;
- ((struct quehead_32 *)(element->qh_link))->qh_rlink = element->qh_rlink;
- ((struct quehead_32 *)(element->qh_rlink))->qh_link = element->qh_link;
- element->qh_rlink = 0;
-}
-
-#endif /* SIZEOF_CHAR_P == 8 */
-
struct quehead {
struct quehead *qh_link;
struct quehead *qh_rlink;
};
inline void
-insque(a, b)
- void *a, *b;
+insque(void *a, void *b)
{
register struct quehead *element = (struct quehead *) a;
register struct quehead *head = (struct quehead *) b;
}
inline void
-remque(a)
- void *a;
+remque(void *a)
{
register struct quehead *element = (struct quehead *) a;
((struct quehead *)(element->qh_link))->qh_rlink = element->qh_rlink;
int
-add_exec(ex_ptr, do_pty, exec, addr, port)
- struct ex_list **ex_ptr;
- int do_pty;
- char *exec;
- int addr;
- int port;
+add_exec(struct ex_list **ex_ptr, int do_pty, char *exec, int addr, int port)
{
struct ex_list *tmp_ptr;
(*ex_ptr)->ex_fport = port;
(*ex_ptr)->ex_addr = addr;
(*ex_ptr)->ex_pty = do_pty;
- (*ex_ptr)->ex_exec = strdup(exec);
+ (*ex_ptr)->ex_exec = (do_pty == 3) ? exec : strdup(exec);
(*ex_ptr)->ex_next = tmp_ptr;
return 0;
}
#ifdef _WIN32
int
-fork_exec(so, ex, do_pty)
- struct socket *so;
- char *ex;
- int do_pty;
+fork_exec(struct socket *so, const char *ex, int do_pty)
{
/* not implemented */
return 0;
#else
+#ifndef CONFIG_QEMU
int
slirp_openpty(amaster, aslave)
int *amaster, *aslave;
return (-1);
#endif
}
+#endif
/*
* XXX This is ugly
* do_ptr = 2 Fork/exec using pty
*/
int
-fork_exec(so, ex, do_pty)
- struct socket *so;
- char *ex;
- int do_pty;
+fork_exec(struct socket *so, const char *ex, int do_pty)
{
int s;
struct sockaddr_in addr;
- int addrlen = sizeof(addr);
+ socklen_t addrlen = sizeof(addr);
int opt;
- int master;
- char *argv[256];
+ int master = -1;
+ const char *argv[256];
#if 0
char buff[256];
#endif
/* don't want to clobber the original */
char *bptr;
- char *curarg;
+ const char *curarg;
int c, i, ret;
DEBUG_CALL("fork_exec");
DEBUG_ARG("do_pty = %lx", (long)do_pty);
if (do_pty == 2) {
+#if 0
if (slirp_openpty(&master, &s) == -1) {
lprint("Error: openpty failed: %s\n", strerror(errno));
return 0;
}
+#else
+ return 0;
+#endif
} else {
addr.sin_family = AF_INET;
addr.sin_port = 0;
dup2(s, 0);
dup2(s, 1);
dup2(s, 2);
- for (s = 3; s <= 255; s++)
+ for (s = getdtablesize() - 1; s >= 3; s--)
close(s);
i = 0;
argv[i++] = strdup(curarg);
} while (c);
- argv[i] = 0;
- execvp(argv[0], argv);
+ argv[i] = NULL;
+ execvp(argv[0], (char **)argv);
/* Ooops, failed, let's tell the user why */
{
char buff[256];
- sprintf(buff, "Error: execvp of %s failed: %s\n",
- argv[0], strerror(errno));
+ snprintf(buff, sizeof(buff),
+ "Error: execvp of %s failed: %s\n",
+ argv[0], strerror(errno));
write(2, buff, strlen(buff)+1);
}
close(0); close(1); close(2); /* XXX */
fd_nonblock(so->s);
/* Append the telnet options now */
- if (so->so_m != 0 && do_pty == 1) {
+ if (so->so_m != NULL && do_pty == 1) {
sbappend(so, so->so_m);
- so->so_m = 0;
+ so->so_m = NULL;
}
return 1;
#endif
#ifdef CONFIG_QEMU
+#include "monitor.h"
+
void lprint(const char *format, ...)
{
va_list args;
va_start(args, format);
- term_vprintf(format, args);
+ monitor_vprintf(cur_mon, format, args);
va_end(args);
}
#else
#endif
void
-u_sleep(usec)
- int usec;
+u_sleep(int usec)
{
struct timeval t;
fd_set fdset;
*/
void
-fd_nonblock(fd)
- int fd;
+fd_nonblock(int fd)
{
#ifdef FIONBIO
- int opt = 1;
+#ifdef _WIN32
+ long opt = 1;
+#else
+ int opt = 1;
+#endif
ioctlsocket(fd, FIONBIO, &opt);
#else
}
void
-fd_block(fd)
- int fd;
+fd_block(int fd)
{
#ifdef FIONBIO
int opt = 0;