- added myself to copyright on files i remember adding large contributions for over...
[openocd.git] / src / server / server.h
blobfd1abbf59c4d74c425295b7f9bc1827b25aff465
1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
4 * *
5 * Copyright (C) 2007,2008 Øyvind Harboe *
6 * oyvind.harboe@zylin.com *
7 * *
8 * Copyright (C) 2008 by Spencer Oliver *
9 * spen@spen-soft.co.uk *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License for more details. *
20 * *
21 * You should have received a copy of the GNU General Public License *
22 * along with this program; if not, write to the *
23 * Free Software Foundation, Inc., *
24 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 ***************************************************************************/
26 #ifndef SERVER_H
27 #define SERVER_H
29 #include "command.h"
30 #include "binarybuffer.h"
31 #include "replacements.h"
33 #include <sys/types.h>
35 enum connection_type
37 CONNECTION_GDB,
38 CONNECTION_TELNET,
39 CONNECTION_TCL,
42 typedef struct connection_s
44 int fd;
45 struct sockaddr_in sin;
46 command_context_t *cmd_ctx;
47 struct service_s *service;
48 int input_pending;
49 void *priv;
50 struct connection_s *next;
51 } connection_t;
53 typedef int (*new_connection_handler_t)(connection_t *connection);
54 typedef int (*input_handler_t)(connection_t *connection);
55 typedef int (*connection_closed_handler_t)(connection_t *connection);
57 typedef struct service_s
59 char *name;
60 enum connection_type type;
61 unsigned short port;
62 int fd;
63 struct sockaddr_in sin;
64 int max_connections;
65 connection_t *connections;
66 new_connection_handler_t new_connection;
67 input_handler_t input;
68 connection_closed_handler_t connection_closed;
69 void *priv;
70 struct service_s *next;
71 } service_t;
73 extern int add_service(char *name, enum connection_type type, unsigned short port, int max_connections, new_connection_handler_t new_connection_handler, input_handler_t input_handler, connection_closed_handler_t connection_closed_handler, void *priv);
74 extern int server_init(void);
75 extern int server_quit(void);
76 extern int server_loop(command_context_t *command_context);
77 extern int server_register_commands(command_context_t *context);
79 #define ERROR_SERVER_REMOTE_CLOSED (-400)
80 #define ERROR_CONNECTION_REJECTED (-401)
82 #endif /* SERVER_H */