2 * Copyright © 2008 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 #include <sys/types.h>
22 #include <sys/socket.h>
23 #include <netinet/in.h>
25 static int s51_port = 0;
26 static char *cpu = "8051";
27 static double freq = 11059200;
28 char *s51_prompt = "> ";
29 struct ccdbg *s51_dbg;
34 fprintf(stderr, "You're doing it wrong.\n");
39 main(int argc, char **argv)
42 FILE *console_in = stdin;
43 FILE *console_out = stdout;
46 while ((opt = getopt(argc, argv, "PVvHht:X:c:Z:s:S:p:")) != -1) {
52 freq = strtod(optarg, &endptr);
55 if (endptr[0] != '\0') {
56 if (!strcmp(endptr, "k"))
58 else if (!strcmp(endptr, "M") )
67 s51_port = strtol(optarg, &endptr, 0);
68 if (endptr == optarg || strlen(endptr) != 0)
96 struct sockaddr_in in;
98 l = socket(AF_INET, SOCK_STREAM, 0);
103 in.sin_family = AF_INET;
104 in.sin_port = htons(s51_port);
105 in.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
106 r = bind(l, (struct sockaddr *) &in, sizeof (in));
111 r = setsockopt(l, SOL_SOCKET, SO_REUSEADDR, &one, sizeof (int));
113 perror("setsockopt");
122 struct sockaddr_in client_addr;
123 socklen_t client_len = sizeof (struct sockaddr_in);
126 s = accept(r, (struct sockaddr *)
127 &client_addr, &client_len);
132 client = fdopen(s, "rw");
137 command_read(client, client);
141 command_read(console_in, console_out);