1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
24 #include "binarybuffer.h"
25 #include "replacements.h"
27 #include <sys/types.h>
35 typedef struct connection_s
38 struct sockaddr_in sin;
39 command_context_t *cmd_ctx;
40 struct service_s *service;
43 struct connection_s *next;
46 typedef int (*new_connection_handler_t)(connection_t *connection);
47 typedef int (*input_handler_t)(connection_t *connection);
48 typedef int (*connection_closed_handler_t)(connection_t *connection);
50 typedef struct service_s
53 enum connection_type type;
56 struct sockaddr_in sin;
58 connection_t *connections;
59 new_connection_handler_t new_connection;
60 input_handler_t input;
61 connection_closed_handler_t connection_closed;
63 struct service_s *next;
66 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);
67 extern int server_init();
68 extern int server_quit();
69 extern int server_loop(command_context_t *command_context);
70 extern int server_register_commands(command_context_t *context);
72 #define ERROR_SERVER_REMOTE_CLOSED (-400)
73 #define ERROR_CONNECTION_REJECTED (-401)