1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
5 * Copyright (C) 2007,2008 Øyvind Harboe *
6 * oyvind.harboe@zylin.com *
8 * Copyright (C) 2008 by Spencer Oliver *
9 * spen@spen-soft.co.uk *
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. *
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. *
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 ***************************************************************************/
31 #ifdef HAVE_NETINET_IN_H
32 #include <netinet/in.h>
41 typedef struct connection_s
44 struct sockaddr_in sin
;
45 command_context_t
*cmd_ctx
;
46 struct service_s
*service
;
49 struct connection_s
*next
;
52 typedef int (*new_connection_handler_t
)(connection_t
*connection
);
53 typedef int (*input_handler_t
)(connection_t
*connection
);
54 typedef int (*connection_closed_handler_t
)(connection_t
*connection
);
56 typedef struct service_s
59 enum connection_type type
;
62 struct sockaddr_in sin
;
64 connection_t
*connections
;
65 new_connection_handler_t new_connection
;
66 input_handler_t input
;
67 connection_closed_handler_t connection_closed
;
69 struct service_s
*next
;
72 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
);
73 extern int server_init(void);
74 extern int server_quit(void);
75 extern int server_loop(command_context_t
*command_context
);
76 extern int server_register_commands(command_context_t
*context
);
78 extern int server_use_pipes
;
80 #define ERROR_SERVER_REMOTE_CLOSED (-400)
81 #define ERROR_CONNECTION_REJECTED (-401)