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 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the *
20 * Free Software Foundation, Inc., *
21 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22 ***************************************************************************/
27 #include "binarybuffer.h"
28 #include "replacements.h"
30 #include <sys/types.h>
39 typedef struct connection_s
42 struct sockaddr_in sin;
43 command_context_t *cmd_ctx;
44 struct service_s *service;
47 struct connection_s *next;
50 typedef int (*new_connection_handler_t)(connection_t *connection);
51 typedef int (*input_handler_t)(connection_t *connection);
52 typedef int (*connection_closed_handler_t)(connection_t *connection);
54 typedef struct service_s
57 enum connection_type type;
60 struct sockaddr_in sin;
62 connection_t *connections;
63 new_connection_handler_t new_connection;
64 input_handler_t input;
65 connection_closed_handler_t connection_closed;
67 struct service_s *next;
70 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);
71 extern int server_init(void);
72 extern int server_quit(void);
73 extern int server_loop(command_context_t *command_context);
74 extern int server_register_commands(command_context_t *context);
76 #define ERROR_SERVER_REMOTE_CLOSED (-400)
77 #define ERROR_CONNECTION_REJECTED (-401)